Add support for fullscreen #10102#13489
Conversation
|
Heads up! This PR modifies the following files:
|
|
I suspect an Option makes the most sense; I expect we still want to reflow the rest of the page even if an element is fullscreen. |
|
Do we plan to land this without implementing the per-platform bits? (Not a huge deal, just curious). |
|
Is the plan to make the DOM element full window, and than send a message to the glutin window to go fullscreen? |
|
Yep. |
|
@jdm For which purpose exists |
|
Thank you |
|
@jdm How to set a Pseudo-Class (:fullscreen)? |
|
I recommend looking at how the :target pseudoclass is implemented (look at target_element). |
components/script/dom/window.rs
Outdated
| let stylesheets_changed = document.get_and_reset_stylesheets_changed_since_reflow(); | ||
|
|
||
| // fullscreen actions | ||
| let entry_node = match self.Document().GetFullscreenElement() { |
There was a problem hiding this comment.
let entry_node = self.Document()
.GetFullScreenElement()
.map(|e| e.upcast::<Node>().to_trusted_node_address());
components/script/dom/window.rs
Outdated
| let document = self.Document(); | ||
| let stylesheets_changed = document.get_and_reset_stylesheets_changed_since_reflow(); | ||
|
|
||
| // fullscreen actions |
There was a problem hiding this comment.
I don't think this comment adds anything to the code.
| pub reflow_info: Reflow, | ||
| /// The document node. | ||
| pub document: TrustedNodeAddress, | ||
| /// The render entry point need for fullscreen. |
| } | ||
|
|
||
| #[allow(unrooted_must_root)] | ||
| fn RequestFullscreen(&self) -> Rc<Promise> { |
There was a problem hiding this comment.
There's a missing specification link comment.
components/script/dom/element.rs
Outdated
| fn RequestFullscreen(&self) -> Rc<Promise> { | ||
| let doc = document_from_node(self); | ||
| doc.set_fullscreen_element(Some(self)); | ||
| Promise::new(self.global().r()) |
There was a problem hiding this comment.
This promise needs to be resolved when the fullscreen status has changed. We can probably use this instead:
let global = self.global().r();
Promise::Resolve(global, global.get_cx(), HandleValue::undefined())| // https://html.spec.whatwg.org/multipage/#documentandelementeventhandlers | ||
| document_and_element_event_handlers!(); | ||
|
|
||
| event_handler!(fullscreenerror, GetOnfullscreenerror, SetOnfullscreenerror); |
There was a problem hiding this comment.
Specification links are missing for these changes.
components/script/dom/document.rs
Outdated
| #[allow(unrooted_must_root)] | ||
| fn ExitFullscreen(&self) -> Rc<Promise> { | ||
| self.set_fullscreen_element(None); | ||
| Promise::new(self.global().r()) |
There was a problem hiding this comment.
Same promise comment. set_fullscreen_element should probably return the Promise value so we don't duplicate the code.
|
☔ The latest upstream changes (presumably #13596) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@jdm i read the spec a bit more, due to spec i shouldn't set a new entry in reflow. |
|
Oh, that's interesting indeed. If we can do it entirely with CSS that would definitely be preferable. |
|
📌 Commit e9050b6 has been approved by |
|
@bors-servo: r- |
|
@jdm Updated |
|
@bors-servo r=jdm |
|
📌 Commit a9e5227 has been approved by |
|
⌛ Testing commit a9e5227 with merge b07f270... |
|
💔 Test failed - linux-rel-wpt |
|
@jdm ?
|
|
@bors-servo retry #10473 @farodin91 that's a known intermittent, no worries :) |
|
Stop bors servo that's not the only issue |
|
@bors-servo r- Right, you need to update a lot more expectations. |
|
☔ The latest upstream changes (presumably #14172) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@jdm This should run. |
| @@ -0,0 +1,308 @@ | |||
| ccopy_reg | |||
There was a problem hiding this comment.
This file should be removed from this commit.
|
Resolved |
|
☔ The latest upstream changes (presumably #14381) made this pull request unmergeable. Please resolve the merge conflicts. |
components/script/dom/element.rs
Outdated
| if let Some(ref value) = *self.id_attribute.borrow() { | ||
| let doc = document_from_node(self); | ||
| doc.unregister_named_element(self, value.clone()); | ||
| let fullscreen = doc.GetFullscreenElement(); |
There was a problem hiding this comment.
Oh, I just noticed that this comment wasn't addressed.
| /// in asynchronous operations. The underlying DOM object is guaranteed to live at least | ||
| /// as long as the last outstanding `TrustedPromise` instance. These values cannot be cloned, | ||
| /// only created from existing Rc<Promise> values. | ||
| #[derive(Clone)] |
There was a problem hiding this comment.
This is not safe. We need to make a new TrustedPromise value from the Rc<Promise> value instead.
components/script/dom/element.rs
Outdated
| let document = document_from_node(element.r()); | ||
| // JSAutoCompartment needs to be manually made. | ||
| // Otherwise, Servo will crash. | ||
| let promise = self.promise.clone().root(); |
There was a problem hiding this comment.
Why we can't use self.promise.root() here?
There was a problem hiding this comment.
I don't like my new solution.
|
☔ The latest upstream changes (presumably #14495) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@bors-servo: r+ |
|
📌 Commit 55f0e56 has been approved by |
|
☀️ Test successful - arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css, mac-rel-wpt1, mac-rel-wpt2, windows-dev |
|
Could @farodin91 or someone else take a look at web-platform-tests/wpt#4394 and my comment in 8b69e73? |
I'm start working on fullscreen support.
@jdm Should be the entry_point in ScriptReflow a Option if fullscreen is enabled or point on the entry_node? For example the RootNode.
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is