WebKit Bugzilla
Attachment 370396 Details for
Bug 198009
: Intersection Observer: bounding client rect is wrong for an inline element
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198009-20190522110059.patch (text/plain), 7.01 KB, created by
Ali Juma
on 2019-05-22 08:01:00 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Ali Juma
Created:
2019-05-22 08:01:00 PDT
Size:
7.01 KB
patch
obsolete
>Subversion Revision: 245569 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 48edb2b1c23095081c423b679d51a45fb19f1dc9..11f547132c60ae40763af681674327887cb3f948 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,22 @@ >+2019-05-22 Ali Juma <ajuma@chromium.org> >+ >+ Intersection Observer: bounding client rect is wrong for an inline element >+ https://bugs.webkit.org/show_bug.cgi?id=198009 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Make target rect computation for inline elements share logic with the computation >+ of bounding client rects. >+ >+ Test: imported/w3c/web-platform-tests/intersection-observer/inline-with-block-child-client-rect.html >+ >+ * dom/Document.cpp: >+ (WebCore::computeIntersectionState): >+ * dom/Element.cpp: >+ (WebCore::Element::boundingAbsoluteRectWithoutLayout): >+ (WebCore::Element::boundingClientRect): >+ * dom/Element.h: >+ > 2019-05-21 Antti Koivisto <antti@apple.com> > > RTL/overflow scroll tests fail with async overflow enabled >diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp >index 92605852d261272f53fbd52638f111cabd9c64c6..640d9f4aebe7f7bae80760af02a1698c1f2f1dae 100644 >--- a/Source/WebCore/dom/Document.cpp >+++ b/Source/WebCore/dom/Document.cpp >@@ -7349,9 +7349,10 @@ static Optional<IntersectionObservationState> computeIntersectionState(FrameView > LayoutRect localTargetBounds; > if (is<RenderBox>(*targetRenderer)) > localTargetBounds = downcast<RenderBox>(targetRenderer)->borderBoundingBox(); >- else if (is<RenderInline>(targetRenderer)) >- localTargetBounds = downcast<RenderInline>(targetRenderer)->linesBoundingBox(); >- else if (is<RenderLineBreak>(targetRenderer)) >+ else if (is<RenderInline>(targetRenderer)) { >+ FloatRect absoluteTargetBounds = target.boundingAbsoluteRectWithoutLayout(); >+ localTargetBounds = enclosingLayoutRect(targetRenderer->absoluteToLocalQuad(absoluteTargetBounds).boundingBox()); >+ } else if (is<RenderLineBreak>(targetRenderer)) > localTargetBounds = downcast<RenderLineBreak>(targetRenderer)->linesBoundingBox(); > > Optional<LayoutRect> rootLocalTargetRect; >diff --git a/Source/WebCore/dom/Element.cpp b/Source/WebCore/dom/Element.cpp >index c4913bebf58c05ef9ff2c594e684514f943f490e..d7bf7ae744479f3efada77a5a227a90b9d1ab683 100644 >--- a/Source/WebCore/dom/Element.cpp >+++ b/Source/WebCore/dom/Element.cpp >@@ -1414,10 +1414,8 @@ Ref<DOMRectList> Element::getClientRects() > return DOMRectList::create(quads); > } > >-FloatRect Element::boundingClientRect() >+FloatRect Element::boundingAbsoluteRectWithoutLayout() > { >- document().updateLayoutIgnorePendingStylesheets(); >- > RenderObject* renderer = this->renderer(); > Vector<FloatQuad> quads; > if (isSVGElement() && renderer && !renderer->isSVGRoot()) { >@@ -1439,7 +1437,14 @@ FloatRect Element::boundingClientRect() > for (size_t i = 1; i < quads.size(); ++i) > result.unite(quads[i].boundingBox()); > >- document().convertAbsoluteToClientRect(result, renderer->style()); >+ return result; >+} >+ >+FloatRect Element::boundingClientRect() >+{ >+ document().updateLayoutIgnorePendingStylesheets(); >+ FloatRect result = boundingAbsoluteRectWithoutLayout(); >+ document().convertAbsoluteToClientRect(result, this->renderer()->style()); > return result; > } > >diff --git a/Source/WebCore/dom/Element.h b/Source/WebCore/dom/Element.h >index 5f3f876268ca5687677a6710e3dce03554270fc2..b40571b0bacc7553009a3119a6e2148677b16444 100644 >--- a/Source/WebCore/dom/Element.h >+++ b/Source/WebCore/dom/Element.h >@@ -189,6 +189,8 @@ public: > > WEBCORE_EXPORT IntRect boundsInRootViewSpace(); > >+ FloatRect boundingAbsoluteRectWithoutLayout(); >+ > WEBCORE_EXPORT FloatRect boundingClientRect(); > > WEBCORE_EXPORT Ref<DOMRectList> getClientRects(); >diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog >index b9152e70ec7431af4639ac248704d180f93bffd1..71c49330f2db99e51b00e97dcf2769c1855c9fee 100644 >--- a/LayoutTests/imported/w3c/ChangeLog >+++ b/LayoutTests/imported/w3c/ChangeLog >@@ -1,3 +1,16 @@ >+2019-05-22 Ali Juma <ajuma@chromium.org> >+ >+ Intersection Observer: bounding client rect is wrong for an inline element >+ https://bugs.webkit.org/show_bug.cgi?id=198009 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Import test added upstream in >+ https://github.com/web-platform-tests/wpt/commit/cf40205c68f739ae23429439de13d125e3df9f7a >+ >+ * web-platform-tests/intersection-observer/inline-with-block-child-client-rect-expected.txt: Added. >+ * web-platform-tests/intersection-observer/inline-with-block-child-client-rect.html: Added. >+ > 2019-05-17 Rob Buis <rbuis@igalia.com> > > Implement imagesrcset and imagesizes attributes on link rel=preload >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/inline-with-block-child-client-rect-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/inline-with-block-child-client-rect-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..17c97453febc411ce1962d5f27cabc551c21a6ca >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/inline-with-block-child-client-rect-expected.txt >@@ -0,0 +1,5 @@ >+ >+ >+PASS Inline target containing a block child >+PASS First rAF >+ >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/inline-with-block-child-client-rect.html b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/inline-with-block-child-client-rect.html >new file mode 100644 >index 0000000000000000000000000000000000000000..81a8fd125691bbfca73ff73e861e80ecf69818f8 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/inline-with-block-child-client-rect.html >@@ -0,0 +1,46 @@ >+<!DOCTYPE html> >+<script src="/resources/testharness.js"></script> >+<script src="/resources/testharnessreport.js"></script> >+<script src="./resources/intersection-observer-test-utils.js"></script> >+ >+<style> >+pre, #log { >+ position: absolute; >+ top: 120px; >+ left: 0; >+} >+#target { >+ display: inline; >+} >+</style> >+ >+<div id="target"> >+ <div> >+ <img width=100 height=100 /> >+ </div> >+</div> >+ >+<script> >+var vw = document.documentElement.clientWidth; >+var vh = document.documentElement.clientHeight; >+var entries = []; >+var target; >+ >+runTestCycle(function() { >+ target = document.getElementById("target"); >+ assert_true(!!target, "target exists"); >+ var observer = new IntersectionObserver(function(changes) { >+ entries = entries.concat(changes) >+ }); >+ observer.observe(target); >+ entries = entries.concat(observer.takeRecords()); >+ assert_equals(entries.length, 0, "No initial notifications."); >+ runTestCycle(step0, "First rAF"); >+}, "Inline target containing a block child"); >+ >+function step0() { >+ assert_equals(entries.length, 1); >+ checkRect(entries[0].boundingClientRect, clientBounds(target), >+ "entry.boundingClientRect == target.getBoundingClientRect()"); >+} >+</script>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198009
:
370170
|
370337
|
370396
|
370402
|
370403
|
370405
|
370411
|
370413
|
370420