mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Don't use cached client_rect() when a reflow is needed (#31210)
Fixes #31195: ```js element.style.width = "5px"; element.clientWidth; // 5 element.style.width = "15px"; element.clientWidth; // Was 5, now 15 ```
This commit is contained in:
parent
742d3ed97f
commit
38d9245726
3 changed files with 8 additions and 30 deletions
|
@ -3372,30 +3372,26 @@ impl<'a> SelectorsElement for DomRoot<Element> {
|
||||||
|
|
||||||
impl Element {
|
impl Element {
|
||||||
fn client_rect(&self) -> Rect<i32> {
|
fn client_rect(&self) -> Rect<i32> {
|
||||||
|
let doc = self.node.owner_doc();
|
||||||
|
|
||||||
if let Some(rect) = self
|
if let Some(rect) = self
|
||||||
.rare_data()
|
.rare_data()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|data| data.client_rect.as_ref())
|
.and_then(|data| data.client_rect.as_ref())
|
||||||
.and_then(|rect| rect.get().ok())
|
.and_then(|rect| rect.get().ok())
|
||||||
{
|
{
|
||||||
return rect;
|
if doc.needs_reflow().is_none() {
|
||||||
|
return rect;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut rect = self.upcast::<Node>().client_rect();
|
let mut rect = self.upcast::<Node>().client_rect();
|
||||||
let in_quirks_mode = self.node.owner_doc().quirks_mode() == QuirksMode::Quirks;
|
let in_quirks_mode = doc.quirks_mode() == QuirksMode::Quirks;
|
||||||
|
|
||||||
if (in_quirks_mode &&
|
if (in_quirks_mode && doc.GetBody().as_deref() == self.downcast::<HTMLElement>()) ||
|
||||||
self.node.owner_doc().GetBody().as_deref() == self.downcast::<HTMLElement>()) ||
|
|
||||||
(!in_quirks_mode && *self.root_element() == *self)
|
(!in_quirks_mode && *self.root_element() == *self)
|
||||||
{
|
{
|
||||||
let viewport_dimensions = self
|
let viewport_dimensions = doc.window().window_size().initial_viewport.round().to_i32();
|
||||||
.node
|
|
||||||
.owner_doc()
|
|
||||||
.window()
|
|
||||||
.window_size()
|
|
||||||
.initial_viewport
|
|
||||||
.round()
|
|
||||||
.to_i32();
|
|
||||||
rect.size = Size2D::<i32>::new(viewport_dimensions.width, viewport_dimensions.height);
|
rect.size = Size2D::<i32>::new(viewport_dimensions.width, viewport_dimensions.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,6 @@
|
||||||
[clientWidth, offsetWidth and scrollWidth round 5.9 to 6]
|
[clientWidth, offsetWidth and scrollWidth round 5.9 to 6]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[clientHeight, offsetHeight and scrollHeight round 5.1 to 5]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[clientHeight, offsetHeight and scrollHeight round 5.5 to 6]
|
[clientHeight, offsetHeight and scrollHeight round 5.5 to 6]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,4 @@
|
||||||
[subpixel-sizes-and-offsets.tentative.html]
|
[subpixel-sizes-and-offsets.tentative.html]
|
||||||
[clientWidth, offsetWidth and scrollWidth round 5.5 to 6]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[clientWidth, offsetWidth and scrollWidth round 5.9 to 6]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[clientHeight, offsetHeight and scrollHeight round 5.1 to 5]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[clientHeight, offsetHeight and scrollHeight round 5.5 to 6]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[clientHeight, offsetHeight and scrollHeight round 5.9 to 6]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[clientLeft and clientTop don't round 44.9]
|
[clientLeft and clientTop don't round 44.9]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue