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

Side by Side Diff: third_party/WebKit/Source/core/dom/Element.cpp

Issue 2647533002: Force compositing inputs to be clean for getBoundingClientRect (Closed)
Patch Set: Remove extraneous whitespace Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
8 * All rights reserved. 8 * All rights reserved.
9 * (C) 2007 Eric Seidel (eric@webkit.org) 9 * (C) 2007 Eric Seidel (eric@webkit.org)
10 * 10 *
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 if (const Attribute* attribute = elementData()->attributes().find(name)) 422 if (const Attribute* attribute = elementData()->attributes().find(name))
423 return attribute->value(); 423 return attribute->value();
424 return nullAtom; 424 return nullAtom;
425 } 425 }
426 426
427 bool Element::shouldIgnoreAttributeCase() const { 427 bool Element::shouldIgnoreAttributeCase() const {
428 return isHTMLElement() && document().isHTMLDocument(); 428 return isHTMLElement() && document().isHTMLDocument();
429 } 429 }
430 430
431 void Element::scrollIntoView(bool alignToTop) { 431 void Element::scrollIntoView(bool alignToTop) {
432 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); 432 ensureCompositingInputsClean();
433 433
434 if (!layoutObject()) 434 if (!layoutObject())
435 return; 435 return;
436 436
437 bool makeVisibleInVisualViewport = 437 bool makeVisibleInVisualViewport =
438 !document().page()->settings().getInertVisualViewport(); 438 !document().page()->settings().getInertVisualViewport();
439 439
440 LayoutRect bounds = boundingBox(); 440 LayoutRect bounds = boundingBox();
441 // Align to the top / bottom and to the closest edge. 441 // Align to the top / bottom and to the closest edge.
442 if (alignToTop) 442 if (alignToTop)
443 layoutObject()->scrollRectToVisible( 443 layoutObject()->scrollRectToVisible(
444 bounds, ScrollAlignment::alignToEdgeIfNeeded, 444 bounds, ScrollAlignment::alignToEdgeIfNeeded,
445 ScrollAlignment::alignTopAlways, ProgrammaticScroll, 445 ScrollAlignment::alignTopAlways, ProgrammaticScroll,
446 makeVisibleInVisualViewport); 446 makeVisibleInVisualViewport);
447 else 447 else
448 layoutObject()->scrollRectToVisible( 448 layoutObject()->scrollRectToVisible(
449 bounds, ScrollAlignment::alignToEdgeIfNeeded, 449 bounds, ScrollAlignment::alignToEdgeIfNeeded,
450 ScrollAlignment::alignBottomAlways, ProgrammaticScroll, 450 ScrollAlignment::alignBottomAlways, ProgrammaticScroll,
451 makeVisibleInVisualViewport); 451 makeVisibleInVisualViewport);
452 452
453 document().setSequentialFocusNavigationStartingPoint(this); 453 document().setSequentialFocusNavigationStartingPoint(this);
454 } 454 }
455 455
456 void Element::scrollIntoViewIfNeeded(bool centerIfNeeded) { 456 void Element::scrollIntoViewIfNeeded(bool centerIfNeeded) {
457 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); 457 ensureCompositingInputsClean();
458 458
459 if (!layoutObject()) 459 if (!layoutObject())
460 return; 460 return;
461 461
462 bool makeVisibleInVisualViewport = 462 bool makeVisibleInVisualViewport =
463 !document().page()->settings().getInertVisualViewport(); 463 !document().page()->settings().getInertVisualViewport();
464 464
465 LayoutRect bounds = boundingBox(); 465 LayoutRect bounds = boundingBox();
466 if (centerIfNeeded) 466 if (centerIfNeeded)
467 layoutObject()->scrollRectToVisible( 467 layoutObject()->scrollRectToVisible(
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 callback->handleEvent(&scrollState); 627 callback->handleEvent(&scrollState);
628 if (callback->nativeScrollBehavior() != 628 if (callback->nativeScrollBehavior() !=
629 WebNativeScrollBehavior::DisableNativeScroll) 629 WebNativeScrollBehavior::DisableNativeScroll)
630 nativeApplyScroll(scrollState); 630 nativeApplyScroll(scrollState);
631 if (callback->nativeScrollBehavior() == 631 if (callback->nativeScrollBehavior() ==
632 WebNativeScrollBehavior::PerformAfterNativeScroll) 632 WebNativeScrollBehavior::PerformAfterNativeScroll)
633 callback->handleEvent(&scrollState); 633 callback->handleEvent(&scrollState);
634 } 634 }
635 635
636 int Element::offsetLeft() { 636 int Element::offsetLeft() {
637 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); 637 ensureCompositingInputsClean();
638 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) 638 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject())
639 return adjustLayoutUnitForAbsoluteZoom( 639 return adjustLayoutUnitForAbsoluteZoom(
640 LayoutUnit(layoutObject->pixelSnappedOffsetLeft(offsetParent())), 640 LayoutUnit(layoutObject->pixelSnappedOffsetLeft(offsetParent())),
641 layoutObject->styleRef()) 641 layoutObject->styleRef())
642 .round(); 642 .round();
643 return 0; 643 return 0;
644 } 644 }
645 645
646 int Element::offsetTop() { 646 int Element::offsetTop() {
647 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); 647 ensureCompositingInputsClean();
648 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) 648 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject())
649 return adjustLayoutUnitForAbsoluteZoom( 649 return adjustLayoutUnitForAbsoluteZoom(
650 LayoutUnit(layoutObject->pixelSnappedOffsetTop(offsetParent())), 650 LayoutUnit(layoutObject->pixelSnappedOffsetTop(offsetParent())),
651 layoutObject->styleRef()) 651 layoutObject->styleRef())
652 .round(); 652 .round();
653 return 0; 653 return 0;
654 } 654 }
655 655
656 int Element::offsetWidth() { 656 int Element::offsetWidth() {
657 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); 657 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this);
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 IntSize viewportSize = document().page()->frameHost().visualViewport().size(); 1112 IntSize viewportSize = document().page()->frameHost().visualViewport().size();
1113 IntRect rect(0, 0, viewportSize.width(), viewportSize.height()); 1113 IntRect rect(0, 0, viewportSize.width(), viewportSize.height());
1114 // We don't use absoluteBoundingBoxRect() because it can return an IntRect 1114 // We don't use absoluteBoundingBoxRect() because it can return an IntRect
1115 // larger the actual size by 1px. crbug.com/470503 1115 // larger the actual size by 1px. crbug.com/470503
1116 rect.intersect(document().view()->contentsToViewport( 1116 rect.intersect(document().view()->contentsToViewport(
1117 roundedIntRect(layoutObject()->absoluteBoundingBoxFloatRect()))); 1117 roundedIntRect(layoutObject()->absoluteBoundingBoxFloatRect())));
1118 return rect; 1118 return rect;
1119 } 1119 }
1120 1120
1121 void Element::clientQuads(Vector<FloatQuad>& quads) { 1121 void Element::clientQuads(Vector<FloatQuad>& quads) {
1122 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); 1122 ensureCompositingInputsClean();
1123 1123
1124 LayoutObject* elementLayoutObject = layoutObject(); 1124 LayoutObject* elementLayoutObject = layoutObject();
1125 if (!elementLayoutObject) 1125 if (!elementLayoutObject)
1126 return; 1126 return;
1127 1127
1128 if (isSVGElement() && !elementLayoutObject->isSVGRoot()) { 1128 if (isSVGElement() && !elementLayoutObject->isSVGRoot()) {
1129 // Get the bounding rectangle from the SVG model. 1129 // Get the bounding rectangle from the SVG model.
1130 if (toSVGElement(this)->isSVGGraphicsElement()) 1130 if (toSVGElement(this)->isSVGGraphicsElement())
1131 quads.push_back(elementLayoutObject->localToAbsoluteQuad( 1131 quads.push_back(elementLayoutObject->localToAbsoluteQuad(
1132 elementLayoutObject->objectBoundingBox())); 1132 elementLayoutObject->objectBoundingBox()));
(...skipping 2979 matching lines...) Expand 10 before | Expand all | Expand 10 after
4112 if (!activityLogger) 4112 if (!activityLogger)
4113 return; 4113 return;
4114 Vector<String, 4> argv; 4114 Vector<String, 4> argv;
4115 argv.push_back(element); 4115 argv.push_back(element);
4116 argv.push_back(params.name.toString()); 4116 argv.push_back(params.name.toString());
4117 argv.push_back(params.oldValue); 4117 argv.push_back(params.oldValue);
4118 argv.push_back(params.newValue); 4118 argv.push_back(params.newValue);
4119 activityLogger->logEvent("blinkSetAttribute", argv.size(), argv.data()); 4119 activityLogger->logEvent("blinkSetAttribute", argv.size(), argv.data());
4120 } 4120 }
4121 4121
4122 void Element::ensureCompositingInputsClean() {
4123 if (!inActiveDocument())
4124 return;
4125
4126 // The call to updateLifecycleToCompositingCleanPlusScrolling| below would
4127 // also run layout for us if we omitted this call. However we do not want to
4128 // include pending style sheets when doing the layout, hence this call.
4129 document().updateStyleAndLayoutIgnorePendingStylesheets();
chrishtr 2017/01/25 21:36:28 Previously it was updateStyleAndLayoutIgnorePendin
smcgruer 2017/01/25 21:39:05 All updateStyleAndLayoutIgnorePendingStylesheetsFo
chrishtr 2017/01/25 22:18:56 Oh ok.
4130
4131 if (FrameView* view = document().view())
4132 view->updateLifecycleToCompositingCleanPlusScrolling();
4133 }
4134
4122 DEFINE_TRACE(Element) { 4135 DEFINE_TRACE(Element) {
4123 if (hasRareData()) 4136 if (hasRareData())
4124 visitor->trace(elementRareData()); 4137 visitor->trace(elementRareData());
4125 visitor->trace(m_elementData); 4138 visitor->trace(m_elementData);
4126 ContainerNode::trace(visitor); 4139 ContainerNode::trace(visitor);
4127 } 4140 }
4128 4141
4129 DEFINE_TRACE_WRAPPERS(Element) { 4142 DEFINE_TRACE_WRAPPERS(Element) {
4130 if (hasRareData()) { 4143 if (hasRareData()) {
4131 visitor->traceWrappers(elementRareData()); 4144 visitor->traceWrappers(elementRareData());
4132 } 4145 }
4133 ContainerNode::traceWrappers(visitor); 4146 ContainerNode::traceWrappers(visitor);
4134 } 4147 }
4135 4148
4136 } // namespace blink 4149 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698