Allow updating DPI, viewport, and theme of a pre-existing Device#260
Allow updating DPI, viewport, and theme of a pre-existing Device#260mrobinson merged 1 commit intoservo:mainfrom
Device#260Conversation
There was a problem hiding this comment.
I'm definitely in favour of the concept.
I have some questions around invalidation:
I know the set_device function automatically marks some things as dirty:
- Is the intention of
device_mutand these new functions to bypass that (because it's not needed for these use cases). Or is it required that the caller apply those invalidation manually when calling these functions. - If invalidation is required, should we make
device_mutapply it automatically? and/or document correct usage of the function?
Finally: I wonder, would we be better off with a single device_mut function with setters on the Device?
(EDIT: I see these function are on Device and device_mut already exist)
The intention isn't to bypass it, but delay it until the next layout. In the meantime, the device can be used for media queries which do not require the stylesheets to be dirtied.
I'm not sure these function can apply it automatically, because the invalidation actually happens in the |
I see. This makes sense.
I think we could do this in My suggestion would be to store the |
nicoburns
left a comment
There was a problem hiding this comment.
Looks good.
I think it would be nice to document the need for:
let sheet_origins_affected_by_device_change = stylist
.media_features_change_changed_style(&guards, self.device());
stylist
.force_stylesheet_origins_dirty(sheet_origins_affected_by_device_change);on the device_mut method.
This will allow Servo to update the `Device` and do media queries without having to create a new one. Signed-off-by: Martin Robinson <[email protected]>
be63d50 to
ef89ad1
Compare
Since |
Instead of waiting for a reflow to update the `Device` in layout, update it eagerly. This ensures that media queries can be answered correctly in script before the next reflow. Also, it ensure that a new reflow is triggered and reflects the change to the theme or viewport. In addition, an unused viewport-related message from the Constellation is removed. This would have needed to be updated by change, but since it's unused I've just removed it. This depends on servo/stylo#260. Testing: This fixes a WebView API test. Fixes: #40395. Fixes: #40129. Signed-off-by: Martin Robinson <[email protected]>
Instead of waiting for a reflow to update the `Device` in layout, update it eagerly. This ensures that media queries can be answered correctly in script before the next reflow. Also, it ensure that a new reflow is triggered and reflects the change to the theme or viewport. In addition, an unused viewport-related message from the Constellation is removed. This would have needed to be updated by change, but since it's unused I've just removed it. This depends on servo/stylo#260. Testing: This fixes a WebView API test and improves `/html/semantics/embedded-content/the-img-element/environment-changes/viewport-change.html`. Fixes: #40395. Fixes: #40129. Signed-off-by: Martin Robinson <[email protected]>
This will allow Servo to update the
Deviceand do media querieswithout having to create a new one.