Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Unified Diff: third_party/WebKit/Source/core/dom/Element.cpp

Issue 2825343003: Clean compositing inputs for location APIs for sticky-affected elements. (Closed)
Patch Set: Add test for sticky subtrees Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/Element.cpp
diff --git a/third_party/WebKit/Source/core/dom/Element.cpp b/third_party/WebKit/Source/core/dom/Element.cpp
index 3f31f0a9877d3845d5260312a9899c18ed08faaf..97c267ae2eb0575038c397b8177b0268cb7cc36a 100644
--- a/third_party/WebKit/Source/core/dom/Element.cpp
+++ b/third_party/WebKit/Source/core/dom/Element.cpp
@@ -431,7 +431,7 @@ AtomicString Element::LowercaseIfNecessary(const AtomicString& name) const {
}
void Element::scrollIntoView(bool align_to_top) {
- GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheetsForNode(this);
+ EnsureLifecycleValidForLocationAPIs();
if (!GetLayoutObject())
return;
@@ -456,7 +456,7 @@ void Element::scrollIntoView(bool align_to_top) {
}
void Element::scrollIntoViewIfNeeded(bool center_if_needed) {
- GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheetsForNode(this);
+ EnsureLifecycleValidForLocationAPIs();
if (!GetLayoutObject())
return;
@@ -643,7 +643,7 @@ void Element::CallApplyScroll(ScrollState& scroll_state) {
}
int Element::OffsetLeft() {
- GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheetsForNode(this);
+ EnsureLifecycleValidForLocationAPIs();
if (LayoutBoxModelObject* layout_object = GetLayoutBoxModelObject())
return AdjustLayoutUnitForAbsoluteZoom(
LayoutUnit(
@@ -654,7 +654,7 @@ int Element::OffsetLeft() {
}
int Element::OffsetTop() {
- GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheetsForNode(this);
+ EnsureLifecycleValidForLocationAPIs();
fs 2017/04/29 09:59:06 I think OffsetWidth/Height needs this too (because
smcgruer 2017/05/01 20:15:15 Done, though I'm having trouble coming up with a u
fs 2017/05/01 21:19:34 Yes, effects would very likely be minor since only
smcgruer 2017/05/02 15:25:41 After looking at this for some time, I believe tha
if (LayoutBoxModelObject* layout_object = GetLayoutBoxModelObject())
return AdjustLayoutUnitForAbsoluteZoom(
LayoutUnit(layout_object->PixelSnappedOffsetTop(OffsetParent())),
@@ -1132,7 +1132,7 @@ IntRect Element::VisibleBoundsInVisualViewport() const {
}
void Element::ClientQuads(Vector<FloatQuad>& quads) {
- GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheetsForNode(this);
+ EnsureLifecycleValidForLocationAPIs();
fs 2017/04/29 09:59:06 Potentially a lot of other methods needs this trea
smcgruer 2017/05/01 20:15:15 Added to BoundsInViewport, but I suspect that gett
fs 2017/05/01 21:19:34 Yes, I'm a bit worried that we're heading into a g
smcgruer 2017/05/02 15:25:41 I've no experience to rely on here, so if someone
fs 2017/05/02 15:58:07 Well, you don't necessarily need to do any (additi
smcgruer 2017/05/02 17:25:30 Ack, opened http://crbug.com/717601 to track this.
LayoutObject* element_layout_object = GetLayoutObject();
if (!element_layout_object)
@@ -4328,6 +4328,28 @@ void Element::LogUpdateAttributeIfIsolatedWorldAndInDocument(
activity_logger->LogEvent("blinkSetAttribute", argv.size(), argv.data());
}
+void Element::EnsureLifecycleValidForLocationAPIs() {
fs 2017/04/29 09:59:06 Maybe this method would be better placed in Docume
smcgruer 2017/05/01 20:15:15 Done. I welcome bike-shedding on the name, it's pr
fs 2017/05/01 21:19:33 Yes, naming... the lifecycle "duality" makes it ev
smcgruer 2017/05/02 15:25:41 Sgtm; if nobody has any objections I will update t
smcgruer 2017/05/03 17:56:58 So, I realized that this CL actually replaces the
+ if (!InActiveDocument())
+ return;
+
+ GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets();
+
+ // The location of elements that are position: sticky is not known until
+ // compositing inputs are cleaned. Therefore, for any elements that are either
+ // sticky or are in a sticky sub-tree (e.g. are affected by a sticky element),
+ // we need to also clean compositing inputs.
+ FrameView* view = GetDocument().View();
+ if (UNLIKELY(view && GetLayoutObject() &&
+ GetLayoutObject()->Style()->IsInStickySubtree())) {
+ if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
+ // In SPv2, compositing inputs are cleaned as part of PrePaint.
+ view->UpdateAllLifecyclePhasesExceptPaint();
+ } else {
+ view->UpdateLifecycleToCompositingInputsClean();
+ }
+ }
+}
+
DEFINE_TRACE(Element) {
if (HasRareData())
visitor->Trace(GetElementRareData());

Powered by Google App Engine
This is Rietveld 408576698