| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> | 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> |
| 3 * 1999 Lars Knoll <knoll@kde.org> | 3 * 1999 Lars Knoll <knoll@kde.org> |
| 4 * 1999 Antti Koivisto <koivisto@kde.org> | 4 * 1999 Antti Koivisto <koivisto@kde.org> |
| 5 * 2000 Dirk Mueller <mueller@kde.org> | 5 * 2000 Dirk Mueller <mueller@kde.org> |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) | 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
| 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
| 9 * Copyright (C) 2009 Google Inc. All rights reserved. | 9 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 10 * | 10 * |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 if (!(arg)) { \ | 131 if (!(arg)) { \ |
| 132 NOTREACHED(); \ | 132 NOTREACHED(); \ |
| 133 return false; \ | 133 return false; \ |
| 134 } \ | 134 } \ |
| 135 } while (false) | 135 } while (false) |
| 136 | 136 |
| 137 namespace blink { | 137 namespace blink { |
| 138 | 138 |
| 139 using namespace HTMLNames; | 139 using namespace HTMLNames; |
| 140 | 140 |
| 141 // The maximum number of updateWidgets iterations that should be done before ret
urning. | 141 // The maximum number of updateWidgets iterations that should be done before |
| 142 // returning. |
| 142 static const unsigned maxUpdateWidgetsIterations = 2; | 143 static const unsigned maxUpdateWidgetsIterations = 2; |
| 143 static const double resourcePriorityUpdateDelayAfterScroll = 0.250; | 144 static const double resourcePriorityUpdateDelayAfterScroll = 0.250; |
| 144 | 145 |
| 145 static bool s_initialTrackAllPaintInvalidations = false; | 146 static bool s_initialTrackAllPaintInvalidations = false; |
| 146 | 147 |
| 147 FrameView::FrameView(LocalFrame* frame) | 148 FrameView::FrameView(LocalFrame* frame) |
| 148 : m_frame(frame), | 149 : m_frame(frame), |
| 149 m_displayMode(WebDisplayModeBrowser), | 150 m_displayMode(WebDisplayModeBrowser), |
| 150 m_canHaveScrollbars(true), | 151 m_canHaveScrollbars(true), |
| 151 m_hasPendingLayout(false), | 152 m_hasPendingLayout(false), |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 m_visuallyNonEmptyPixelCount = 0; | 248 m_visuallyNonEmptyPixelCount = 0; |
| 248 m_isVisuallyNonEmpty = false; | 249 m_isVisuallyNonEmpty = false; |
| 249 m_layoutObjectCounter.reset(); | 250 m_layoutObjectCounter.reset(); |
| 250 clearFragmentAnchor(); | 251 clearFragmentAnchor(); |
| 251 m_viewportConstrainedObjects.reset(); | 252 m_viewportConstrainedObjects.reset(); |
| 252 m_layoutSubtreeRootList.clear(); | 253 m_layoutSubtreeRootList.clear(); |
| 253 m_orthogonalWritingModeRootList.clear(); | 254 m_orthogonalWritingModeRootList.clear(); |
| 254 } | 255 } |
| 255 | 256 |
| 256 // Call function for each non-throttled frame view in pre tree order. | 257 // Call function for each non-throttled frame view in pre tree order. |
| 257 // Note it needs a null check of the frame's layoutView to access it in case of
detached frames. | 258 // Note it needs a null check of the frame's layoutView to access it in case of |
| 259 // detached frames. |
| 258 template <typename Function> | 260 template <typename Function> |
| 259 void FrameView::forAllNonThrottledFrameViews(const Function& function) { | 261 void FrameView::forAllNonThrottledFrameViews(const Function& function) { |
| 260 if (shouldThrottleRendering()) | 262 if (shouldThrottleRendering()) |
| 261 return; | 263 return; |
| 262 | 264 |
| 263 function(*this); | 265 function(*this); |
| 264 | 266 |
| 265 for (Frame* child = m_frame->tree().firstChild(); child; | 267 for (Frame* child = m_frame->tree().firstChild(); child; |
| 266 child = child->tree().nextSibling()) { | 268 child = child->tree().nextSibling()) { |
| 267 if (!child->isLocalFrame()) | 269 if (!child->isLocalFrame()) |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 if (ownerElement && ownerElement->ownedWidget() == this) | 322 if (ownerElement && ownerElement->ownedWidget() == this) |
| 321 ownerElement->setWidget(nullptr); | 323 ownerElement->setWidget(nullptr); |
| 322 | 324 |
| 323 #if ENABLE(ASSERT) | 325 #if ENABLE(ASSERT) |
| 324 m_hasBeenDisposed = true; | 326 m_hasBeenDisposed = true; |
| 325 #endif | 327 #endif |
| 326 } | 328 } |
| 327 | 329 |
| 328 void FrameView::detachScrollbars() { | 330 void FrameView::detachScrollbars() { |
| 329 // Previously, we detached custom scrollbars as early as possible to prevent | 331 // Previously, we detached custom scrollbars as early as possible to prevent |
| 330 // Document::detachLayoutTree() from messing with the view such that its scrol
l bars | 332 // Document::detachLayoutTree() from messing with the view such that its |
| 331 // won't be torn down. However, scripting in Document::detachLayoutTree() is f
orbidden | 333 // scroll bars won't be torn down. However, scripting in |
| 334 // Document::detachLayoutTree() is forbidden |
| 332 // now, so it's not clear if these edge cases can still happen. | 335 // now, so it's not clear if these edge cases can still happen. |
| 333 // However, for Oilpan, we still need to remove the native scrollbars before | 336 // However, for Oilpan, we still need to remove the native scrollbars before |
| 334 // we lose the connection to the HostWindow, so we just unconditionally | 337 // we lose the connection to the HostWindow, so we just unconditionally |
| 335 // detach any scrollbars now. | 338 // detach any scrollbars now. |
| 336 setHasHorizontalScrollbar(false); | 339 setHasHorizontalScrollbar(false); |
| 337 setHasVerticalScrollbar(false); | 340 setHasVerticalScrollbar(false); |
| 338 | 341 |
| 339 if (m_scrollCorner) { | 342 if (m_scrollCorner) { |
| 340 m_scrollCorner->destroy(); | 343 m_scrollCorner->destroy(); |
| 341 m_scrollCorner = nullptr; | 344 m_scrollCorner = nullptr; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 | 390 |
| 388 void FrameView::invalidateRect(const IntRect& rect) { | 391 void FrameView::invalidateRect(const IntRect& rect) { |
| 389 LayoutPartItem layoutItem = m_frame->ownerLayoutItem(); | 392 LayoutPartItem layoutItem = m_frame->ownerLayoutItem(); |
| 390 if (layoutItem.isNull()) | 393 if (layoutItem.isNull()) |
| 391 return; | 394 return; |
| 392 | 395 |
| 393 IntRect paintInvalidationRect = rect; | 396 IntRect paintInvalidationRect = rect; |
| 394 paintInvalidationRect.move( | 397 paintInvalidationRect.move( |
| 395 (layoutItem.borderLeft() + layoutItem.paddingLeft()).toInt(), | 398 (layoutItem.borderLeft() + layoutItem.paddingLeft()).toInt(), |
| 396 (layoutItem.borderTop() + layoutItem.paddingTop()).toInt()); | 399 (layoutItem.borderTop() + layoutItem.paddingTop()).toInt()); |
| 397 // FIXME: We should not allow paint invalidation out of paint invalidation sta
te. crbug.com/457415 | 400 // FIXME: We should not allow paint invalidation out of paint invalidation |
| 401 // state. crbug.com/457415 |
| 398 DisablePaintInvalidationStateAsserts paintInvalidationAssertDisabler; | 402 DisablePaintInvalidationStateAsserts paintInvalidationAssertDisabler; |
| 399 layoutItem.invalidatePaintRectangle(LayoutRect(paintInvalidationRect)); | 403 layoutItem.invalidatePaintRectangle(LayoutRect(paintInvalidationRect)); |
| 400 } | 404 } |
| 401 | 405 |
| 402 void FrameView::setFrameRect(const IntRect& newRect) { | 406 void FrameView::setFrameRect(const IntRect& newRect) { |
| 403 IntRect oldRect = frameRect(); | 407 IntRect oldRect = frameRect(); |
| 404 if (newRect == oldRect) | 408 if (newRect == oldRect) |
| 405 return; | 409 return; |
| 406 | 410 |
| 407 Widget::setFrameRect(newRect); | 411 Widget::setFrameRect(newRect); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 Element*& customScrollbarElement, | 488 Element*& customScrollbarElement, |
| 485 LocalFrame*& customScrollbarFrame) const { | 489 LocalFrame*& customScrollbarFrame) const { |
| 486 customScrollbarElement = nullptr; | 490 customScrollbarElement = nullptr; |
| 487 customScrollbarFrame = nullptr; | 491 customScrollbarFrame = nullptr; |
| 488 | 492 |
| 489 if (Settings* settings = m_frame->settings()) { | 493 if (Settings* settings = m_frame->settings()) { |
| 490 if (!settings->allowCustomScrollbarInMainFrame() && m_frame->isMainFrame()) | 494 if (!settings->allowCustomScrollbarInMainFrame() && m_frame->isMainFrame()) |
| 491 return false; | 495 return false; |
| 492 } | 496 } |
| 493 | 497 |
| 494 // FIXME: We need to update the scrollbar dynamically as documents change (or
as doc elements and bodies get discovered that have custom styles). | 498 // FIXME: We need to update the scrollbar dynamically as documents change (or |
| 499 // as doc elements and bodies get discovered that have custom styles). |
| 495 Document* doc = m_frame->document(); | 500 Document* doc = m_frame->document(); |
| 496 | 501 |
| 497 // Try the <body> element first as a scrollbar source. | 502 // Try the <body> element first as a scrollbar source. |
| 498 Element* body = doc ? doc->body() : 0; | 503 Element* body = doc ? doc->body() : 0; |
| 499 if (body && body->layoutObject() && | 504 if (body && body->layoutObject() && |
| 500 body->layoutObject()->style()->hasPseudoStyle(PseudoIdScrollbar)) { | 505 body->layoutObject()->style()->hasPseudoStyle(PseudoIdScrollbar)) { |
| 501 customScrollbarElement = body; | 506 customScrollbarElement = body; |
| 502 return true; | 507 return true; |
| 503 } | 508 } |
| 504 | 509 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 | 621 |
| 617 // Framesets can't scroll. | 622 // Framesets can't scroll. |
| 618 Node* body = m_frame->document()->body(); | 623 Node* body = m_frame->document()->body(); |
| 619 if (isHTMLFrameSetElement(body) && body->layoutObject()) | 624 if (isHTMLFrameSetElement(body) && body->layoutObject()) |
| 620 RETURN_SCROLLBAR_MODE(ScrollbarAlwaysOff); | 625 RETURN_SCROLLBAR_MODE(ScrollbarAlwaysOff); |
| 621 | 626 |
| 622 // Scrollbars can be disabled by FrameView::setCanHaveScrollbars. | 627 // Scrollbars can be disabled by FrameView::setCanHaveScrollbars. |
| 623 if (!m_canHaveScrollbars && strategy != RulesFromWebContentOnly) | 628 if (!m_canHaveScrollbars && strategy != RulesFromWebContentOnly) |
| 624 RETURN_SCROLLBAR_MODE(ScrollbarAlwaysOff); | 629 RETURN_SCROLLBAR_MODE(ScrollbarAlwaysOff); |
| 625 | 630 |
| 626 // This will be the LayoutObject for either the body element or the html eleme
nt | 631 // This will be the LayoutObject for either the body element or the html |
| 627 // (see Document::viewportDefiningElement). | 632 // element (see Document::viewportDefiningElement). |
| 628 LayoutObject* viewport = viewportLayoutObject(); | 633 LayoutObject* viewport = viewportLayoutObject(); |
| 629 if (!viewport || !viewport->style()) | 634 if (!viewport || !viewport->style()) |
| 630 RETURN_SCROLLBAR_MODE(ScrollbarAuto); | 635 RETURN_SCROLLBAR_MODE(ScrollbarAuto); |
| 631 | 636 |
| 632 if (viewport->isSVGRoot()) { | 637 if (viewport->isSVGRoot()) { |
| 633 // Don't allow overflow to affect <img> and css backgrounds | 638 // Don't allow overflow to affect <img> and css backgrounds |
| 634 if (toLayoutSVGRoot(viewport)->isEmbeddedThroughSVGImage()) | 639 if (toLayoutSVGRoot(viewport)->isEmbeddedThroughSVGImage()) |
| 635 RETURN_SCROLLBAR_MODE(ScrollbarAuto); | 640 RETURN_SCROLLBAR_MODE(ScrollbarAuto); |
| 636 | 641 |
| 637 // FIXME: evaluate if we can allow overflow for these cases too. | 642 // FIXME: evaluate if we can allow overflow for these cases too. |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 } | 743 } |
| 739 | 744 |
| 740 GraphicsLayer* FrameView::layerForScrollCorner() const { | 745 GraphicsLayer* FrameView::layerForScrollCorner() const { |
| 741 LayoutViewItem layoutView = this->layoutViewItem(); | 746 LayoutViewItem layoutView = this->layoutViewItem(); |
| 742 if (layoutView.isNull()) | 747 if (layoutView.isNull()) |
| 743 return nullptr; | 748 return nullptr; |
| 744 return layoutView.compositor()->layerForScrollCorner(); | 749 return layoutView.compositor()->layerForScrollCorner(); |
| 745 } | 750 } |
| 746 | 751 |
| 747 bool FrameView::isEnclosedInCompositingLayer() const { | 752 bool FrameView::isEnclosedInCompositingLayer() const { |
| 748 // FIXME: It's a bug that compositing state isn't always up to date when this
is called. crbug.com/366314 | 753 // FIXME: It's a bug that compositing state isn't always up to date when this |
| 754 // is called. crbug.com/366314 |
| 749 DisableCompositingQueryAsserts disabler; | 755 DisableCompositingQueryAsserts disabler; |
| 750 | 756 |
| 751 LayoutItem frameOwnerLayoutItem = m_frame->ownerLayoutItem(); | 757 LayoutItem frameOwnerLayoutItem = m_frame->ownerLayoutItem(); |
| 752 return !frameOwnerLayoutItem.isNull() && | 758 return !frameOwnerLayoutItem.isNull() && |
| 753 frameOwnerLayoutItem.enclosingLayer() | 759 frameOwnerLayoutItem.enclosingLayer() |
| 754 ->enclosingLayerForPaintInvalidationCrossingFrameBoundaries(); | 760 ->enclosingLayerForPaintInvalidationCrossingFrameBoundaries(); |
| 755 } | 761 } |
| 756 | 762 |
| 757 void FrameView::countObjectsNeedingLayout(unsigned& needsLayoutObjects, | 763 void FrameView::countObjectsNeedingLayout(unsigned& needsLayoutObjects, |
| 758 unsigned& totalObjects, | 764 unsigned& totalObjects, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 774 return; | 780 return; |
| 775 | 781 |
| 776 LayoutReplaced* contentBox = embeddedReplacedContent(); | 782 LayoutReplaced* contentBox = embeddedReplacedContent(); |
| 777 if (!contentBox) | 783 if (!contentBox) |
| 778 return; | 784 return; |
| 779 | 785 |
| 780 LayoutSVGRoot* svgRoot = toLayoutSVGRoot(contentBox); | 786 LayoutSVGRoot* svgRoot = toLayoutSVGRoot(contentBox); |
| 781 if (svgRoot->everHadLayout() && !svgRoot->needsLayout()) | 787 if (svgRoot->everHadLayout() && !svgRoot->needsLayout()) |
| 782 return; | 788 return; |
| 783 | 789 |
| 784 // If the embedded SVG document appears the first time, the ownerLayoutObject
has already finished | 790 // If the embedded SVG document appears the first time, the ownerLayoutObject |
| 785 // layout without knowing about the existence of the embedded SVG document, be
cause LayoutReplaced | 791 // has already finished layout without knowing about the existence of the |
| 786 // embeddedReplacedContent() returns 0, as long as the embedded document isn't
loaded yet. Before | 792 // embedded SVG document, because LayoutReplaced embeddedReplacedContent() |
| 787 // bothering to lay out the SVG document, mark the ownerLayoutObject needing l
ayout and ask its | 793 // returns 0, as long as the embedded document isn't loaded yet. Before |
| 788 // FrameView for a layout. After that the LayoutEmbeddedObject (ownerLayoutObj
ect) carries the | 794 // bothering to lay out the SVG document, mark the ownerLayoutObject needing |
| 789 // correct size, which LayoutSVGRoot::computeReplacedLogicalWidth/Height rely
on, when laying | 795 // layout and ask its FrameView for a layout. After that the |
| 790 // out for the first time, or when the LayoutSVGRoot size has changed dynamica
lly (eg. via <script>). | 796 // LayoutEmbeddedObject (ownerLayoutObject) carries the correct size, which |
| 797 // LayoutSVGRoot::computeReplacedLogicalWidth/Height rely on, when laying out |
| 798 // for the first time, or when the LayoutSVGRoot size has changed dynamically |
| 799 // (eg. via <script>). |
| 791 FrameView* frameView = ownerLayoutItem.frame()->view(); | 800 FrameView* frameView = ownerLayoutItem.frame()->view(); |
| 792 | 801 |
| 793 // Mark the owner layoutObject as needing layout. | 802 // Mark the owner layoutObject as needing layout. |
| 794 ownerLayoutItem.setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( | 803 ownerLayoutItem.setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( |
| 795 LayoutInvalidationReason::Unknown); | 804 LayoutInvalidationReason::Unknown); |
| 796 | 805 |
| 797 // Synchronously enter layout, to layout the view containing the host object/e
mbed/iframe. | 806 // Synchronously enter layout, to layout the view containing the host |
| 807 // object/embed/iframe. |
| 798 ASSERT(frameView); | 808 ASSERT(frameView); |
| 799 frameView->layout(); | 809 frameView->layout(); |
| 800 } | 810 } |
| 801 | 811 |
| 802 void FrameView::performPreLayoutTasks() { | 812 void FrameView::performPreLayoutTasks() { |
| 803 TRACE_EVENT0("blink,benchmark", "FrameView::performPreLayoutTasks"); | 813 TRACE_EVENT0("blink,benchmark", "FrameView::performPreLayoutTasks"); |
| 804 lifecycle().advanceTo(DocumentLifecycle::InPreLayout); | 814 lifecycle().advanceTo(DocumentLifecycle::InPreLayout); |
| 805 | 815 |
| 806 // Don't schedule more layouts, we're in one. | 816 // Don't schedule more layouts, we're in one. |
| 807 AutoReset<bool> changeSchedulingEnabled(&m_layoutSchedulingEnabled, false); | 817 AutoReset<bool> changeSchedulingEnabled(&m_layoutSchedulingEnabled, false); |
| 808 | 818 |
| 809 if (!m_nestedLayoutCount && !m_inSynchronousPostLayout && | 819 if (!m_nestedLayoutCount && !m_inSynchronousPostLayout && |
| 810 m_postLayoutTasksTimer.isActive()) { | 820 m_postLayoutTasksTimer.isActive()) { |
| 811 // This is a new top-level layout. If there are any remaining tasks from the
previous layout, finish them now. | 821 // This is a new top-level layout. If there are any remaining tasks from the |
| 822 // previous layout, finish them now. |
| 812 m_inSynchronousPostLayout = true; | 823 m_inSynchronousPostLayout = true; |
| 813 performPostLayoutTasks(); | 824 performPostLayoutTasks(); |
| 814 m_inSynchronousPostLayout = false; | 825 m_inSynchronousPostLayout = false; |
| 815 } | 826 } |
| 816 | 827 |
| 817 bool wasResized = wasViewportResized(); | 828 bool wasResized = wasViewportResized(); |
| 818 Document* document = m_frame->document(); | 829 Document* document = m_frame->document(); |
| 819 if (wasResized) | 830 if (wasResized) |
| 820 document->notifyResizeForViewportUnits(); | 831 document->notifyResizeForViewportUnits(); |
| 821 | 832 |
| 822 // Viewport-dependent or device-dependent media queries may cause us to need c
ompletely different style information. | 833 // Viewport-dependent or device-dependent media queries may cause us to need |
| 834 // completely different style information. |
| 823 bool mainFrameRotation = | 835 bool mainFrameRotation = |
| 824 m_frame->isMainFrame() && m_frame->settings() && | 836 m_frame->isMainFrame() && m_frame->settings() && |
| 825 m_frame->settings()->mainFrameResizesAreOrientationChanges(); | 837 m_frame->settings()->mainFrameResizesAreOrientationChanges(); |
| 826 if (!document->styleResolver() || | 838 if (!document->styleResolver() || |
| 827 (wasResized && | 839 (wasResized && |
| 828 document->styleResolver()->mediaQueryAffectedByViewportChange()) || | 840 document->styleResolver()->mediaQueryAffectedByViewportChange()) || |
| 829 (wasResized && mainFrameRotation && | 841 (wasResized && mainFrameRotation && |
| 830 document->styleResolver()->mediaQueryAffectedByDeviceChange())) { | 842 document->styleResolver()->mediaQueryAffectedByDeviceChange())) { |
| 831 document->mediaQueryAffectingValueChanged(); | 843 document->mediaQueryAffectingValueChanged(); |
| 832 } else if (wasResized) { | 844 } else if (wasResized) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 "FrameView::performLayout", "contentsHeightBeforeLayout", | 905 "FrameView::performLayout", "contentsHeightBeforeLayout", |
| 894 contentsHeightBeforeLayout); | 906 contentsHeightBeforeLayout); |
| 895 prepareLayoutAnalyzer(); | 907 prepareLayoutAnalyzer(); |
| 896 | 908 |
| 897 ScriptForbiddenScope forbidScript; | 909 ScriptForbiddenScope forbidScript; |
| 898 | 910 |
| 899 ASSERT(!isInPerformLayout()); | 911 ASSERT(!isInPerformLayout()); |
| 900 lifecycle().advanceTo(DocumentLifecycle::InPerformLayout); | 912 lifecycle().advanceTo(DocumentLifecycle::InPerformLayout); |
| 901 | 913 |
| 902 // performLayout is the actual guts of layout(). | 914 // performLayout is the actual guts of layout(). |
| 903 // FIXME: The 300 other lines in layout() probably belong in other helper func
tions | 915 // FIXME: The 300 other lines in layout() probably belong in other helper |
| 904 // so that a single human could understand what layout() is actually doing. | 916 // functions so that a single human could understand what layout() is actually |
| 917 // doing. |
| 905 | 918 |
| 906 forceLayoutParentViewIfNeeded(); | 919 forceLayoutParentViewIfNeeded(); |
| 907 | 920 |
| 908 if (hasOrthogonalWritingModeRoots()) | 921 if (hasOrthogonalWritingModeRoots()) |
| 909 layoutOrthogonalWritingModeRoots(); | 922 layoutOrthogonalWritingModeRoots(); |
| 910 | 923 |
| 911 if (inSubtreeLayout) { | 924 if (inSubtreeLayout) { |
| 912 if (m_analyzer) | 925 if (m_analyzer) |
| 913 m_analyzer->increment(LayoutAnalyzer::PerformLayoutRootLayoutObjects, | 926 m_analyzer->increment(LayoutAnalyzer::PerformLayoutRootLayoutObjects, |
| 914 m_layoutSubtreeRootList.size()); | 927 m_layoutSubtreeRootList.size()); |
| 915 for (auto& root : m_layoutSubtreeRootList.ordered()) { | 928 for (auto& root : m_layoutSubtreeRootList.ordered()) { |
| 916 if (!root->needsLayout()) | 929 if (!root->needsLayout()) |
| 917 continue; | 930 continue; |
| 918 layoutFromRootObject(*root); | 931 layoutFromRootObject(*root); |
| 919 | 932 |
| 920 // We need to ensure that we mark up all layoutObjects up to the LayoutVie
w | 933 // We need to ensure that we mark up all layoutObjects up to the |
| 921 // for paint invalidation. This simplifies our code as we just always | 934 // LayoutView for paint invalidation. This simplifies our code as we just |
| 922 // do a full tree walk. | 935 // always do a full tree walk. |
| 923 if (LayoutItem container = LayoutItem(root->container())) | 936 if (LayoutItem container = LayoutItem(root->container())) |
| 924 container.setMayNeedPaintInvalidation(); | 937 container.setMayNeedPaintInvalidation(); |
| 925 } | 938 } |
| 926 m_layoutSubtreeRootList.clear(); | 939 m_layoutSubtreeRootList.clear(); |
| 927 } else { | 940 } else { |
| 928 layoutFromRootObject(*layoutView()); | 941 layoutFromRootObject(*layoutView()); |
| 929 } | 942 } |
| 930 | 943 |
| 931 m_frame->document()->fetcher()->updateAllImageResourcePriorities(); | 944 m_frame->document()->fetcher()->updateAllImageResourcePriorities(); |
| 932 | 945 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 946 | 959 |
| 947 if (!m_inSynchronousPostLayout) { | 960 if (!m_inSynchronousPostLayout) { |
| 948 m_inSynchronousPostLayout = true; | 961 m_inSynchronousPostLayout = true; |
| 949 // Calls resumeScheduledEvents() | 962 // Calls resumeScheduledEvents() |
| 950 performPostLayoutTasks(); | 963 performPostLayoutTasks(); |
| 951 m_inSynchronousPostLayout = false; | 964 m_inSynchronousPostLayout = false; |
| 952 } | 965 } |
| 953 | 966 |
| 954 if (!m_postLayoutTasksTimer.isActive() && | 967 if (!m_postLayoutTasksTimer.isActive() && |
| 955 (needsLayout() || m_inSynchronousPostLayout)) { | 968 (needsLayout() || m_inSynchronousPostLayout)) { |
| 956 // If we need layout or are already in a synchronous call to postLayoutTasks
(), | 969 // If we need layout or are already in a synchronous call to |
| 957 // defer widget updates and event dispatch until after we return. postLayout
Tasks() | 970 // postLayoutTasks(), defer widget updates and event dispatch until after we |
| 958 // can make us need to update again, and we can get stuck in a nasty cycle u
nless | 971 // return. postLayoutTasks() can make us need to update again, and we can |
| 959 // we call it through the timer here. | 972 // get stuck in a nasty cycle unless we call it through the timer here. |
| 960 m_postLayoutTasksTimer.startOneShot(0, BLINK_FROM_HERE); | 973 m_postLayoutTasksTimer.startOneShot(0, BLINK_FROM_HERE); |
| 961 if (needsLayout()) | 974 if (needsLayout()) |
| 962 layout(); | 975 layout(); |
| 963 } | 976 } |
| 964 } | 977 } |
| 965 | 978 |
| 966 void FrameView::layout() { | 979 void FrameView::layout() { |
| 967 // We should never layout a Document which is not in a LocalFrame. | 980 // We should never layout a Document which is not in a LocalFrame. |
| 968 ASSERT(m_frame); | 981 ASSERT(m_frame); |
| 969 ASSERT(m_frame->view() == this); | 982 ASSERT(m_frame->view() == this); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 985 DocumentLifecycle::Scope lifecycleScope(lifecycle(), | 998 DocumentLifecycle::Scope lifecycleScope(lifecycle(), |
| 986 DocumentLifecycle::LayoutClean); | 999 DocumentLifecycle::LayoutClean); |
| 987 | 1000 |
| 988 TRACE_EVENT_BEGIN1("devtools.timeline", "Layout", "beginData", | 1001 TRACE_EVENT_BEGIN1("devtools.timeline", "Layout", "beginData", |
| 989 InspectorLayoutEvent::beginData(this)); | 1002 InspectorLayoutEvent::beginData(this)); |
| 990 | 1003 |
| 991 performPreLayoutTasks(); | 1004 performPreLayoutTasks(); |
| 992 | 1005 |
| 993 Document* document = m_frame->document(); | 1006 Document* document = m_frame->document(); |
| 994 | 1007 |
| 995 // TODO(crbug.com/460956): The notion of a single root for layout is no longer
applicable. Remove or update this code. | 1008 // TODO(crbug.com/460956): The notion of a single root for layout is no longer |
| 1009 // applicable. Remove or update this code. |
| 996 LayoutObject* rootForThisLayout = layoutView(); | 1010 LayoutObject* rootForThisLayout = layoutView(); |
| 997 | 1011 |
| 998 FontCachePurgePreventer fontCachePurgePreventer; | 1012 FontCachePurgePreventer fontCachePurgePreventer; |
| 999 { | 1013 { |
| 1000 AutoReset<bool> changeSchedulingEnabled(&m_layoutSchedulingEnabled, false); | 1014 AutoReset<bool> changeSchedulingEnabled(&m_layoutSchedulingEnabled, false); |
| 1001 m_nestedLayoutCount++; | 1015 m_nestedLayoutCount++; |
| 1002 | 1016 |
| 1003 updateCounters(); | 1017 updateCounters(); |
| 1004 | 1018 |
| 1005 // If the layout view was marked as needing layout after we added items in t
he subtree roots we need | 1019 // If the layout view was marked as needing layout after we added items in |
| 1006 // to clear the roots and do the layout from the layoutView. | 1020 // the subtree roots we need to clear the roots and do the layout from the |
| 1021 // layoutView. |
| 1007 if (layoutViewItem().needsLayout()) | 1022 if (layoutViewItem().needsLayout()) |
| 1008 clearLayoutSubtreeRootsAndMarkContainingBlocks(); | 1023 clearLayoutSubtreeRootsAndMarkContainingBlocks(); |
| 1009 layoutViewItem().clearHitTestCache(); | 1024 layoutViewItem().clearHitTestCache(); |
| 1010 | 1025 |
| 1011 bool inSubtreeLayout = isSubtreeLayout(); | 1026 bool inSubtreeLayout = isSubtreeLayout(); |
| 1012 | 1027 |
| 1013 // TODO(crbug.com/460956): The notion of a single root for layout is no long
er applicable. Remove or update this code. | 1028 // TODO(crbug.com/460956): The notion of a single root for layout is no |
| 1029 // longer applicable. Remove or update this code. |
| 1014 if (inSubtreeLayout) | 1030 if (inSubtreeLayout) |
| 1015 rootForThisLayout = m_layoutSubtreeRootList.randomRoot(); | 1031 rootForThisLayout = m_layoutSubtreeRootList.randomRoot(); |
| 1016 | 1032 |
| 1017 if (!rootForThisLayout) { | 1033 if (!rootForThisLayout) { |
| 1018 // FIXME: Do we need to set m_size here? | 1034 // FIXME: Do we need to set m_size here? |
| 1019 NOTREACHED(); | 1035 NOTREACHED(); |
| 1020 return; | 1036 return; |
| 1021 } | 1037 } |
| 1022 | 1038 |
| 1023 if (!inSubtreeLayout) { | 1039 if (!inSubtreeLayout) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1042 ScrollbarMode currentVMode = verticalScrollbarMode(); | 1058 ScrollbarMode currentVMode = verticalScrollbarMode(); |
| 1043 | 1059 |
| 1044 if (m_firstLayout) { | 1060 if (m_firstLayout) { |
| 1045 setScrollbarsSuppressed(true); | 1061 setScrollbarsSuppressed(true); |
| 1046 | 1062 |
| 1047 m_firstLayout = false; | 1063 m_firstLayout = false; |
| 1048 m_lastViewportSize = layoutSize(IncludeScrollbars); | 1064 m_lastViewportSize = layoutSize(IncludeScrollbars); |
| 1049 m_lastZoomFactor = layoutViewItem().style()->zoom(); | 1065 m_lastZoomFactor = layoutViewItem().style()->zoom(); |
| 1050 | 1066 |
| 1051 // Set the initial vMode to AlwaysOn if we're auto. | 1067 // Set the initial vMode to AlwaysOn if we're auto. |
| 1052 if (vMode == ScrollbarAuto) | 1068 if (vMode == ScrollbarAuto) { |
| 1053 setVerticalScrollbarMode( | 1069 // This causes a vertical scrollbar to appear. |
| 1054 ScrollbarAlwaysOn); // This causes a vertical scrollbar to appear
. | 1070 setVerticalScrollbarMode(ScrollbarAlwaysOn); |
| 1071 } |
| 1055 // Set the initial hMode to AlwaysOff if we're auto. | 1072 // Set the initial hMode to AlwaysOff if we're auto. |
| 1056 if (hMode == ScrollbarAuto) | 1073 if (hMode == ScrollbarAuto) { |
| 1057 setHorizontalScrollbarMode( | 1074 // This causes a horizontal scrollbar to disappear. |
| 1058 ScrollbarAlwaysOff); // This causes a horizontal scrollbar to dis
appear. | 1075 setHorizontalScrollbarMode(ScrollbarAlwaysOff); |
| 1076 } |
| 1059 | 1077 |
| 1060 setScrollbarModes(hMode, vMode); | 1078 setScrollbarModes(hMode, vMode); |
| 1061 setScrollbarsSuppressed(false); | 1079 setScrollbarsSuppressed(false); |
| 1062 } else if (hMode != currentHMode || vMode != currentVMode) { | 1080 } else if (hMode != currentHMode || vMode != currentVMode) { |
| 1063 setScrollbarModes(hMode, vMode); | 1081 setScrollbarModes(hMode, vMode); |
| 1064 } | 1082 } |
| 1065 | 1083 |
| 1066 updateScrollbarsIfNeeded(); | 1084 updateScrollbarsIfNeeded(); |
| 1067 | 1085 |
| 1068 LayoutSize oldSize = m_size; | 1086 LayoutSize oldSize = m_size; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1092 | 1110 |
| 1093 if (!inSubtreeLayout && !document->printing()) | 1111 if (!inSubtreeLayout && !document->printing()) |
| 1094 adjustViewSizeAndLayout(); | 1112 adjustViewSizeAndLayout(); |
| 1095 | 1113 |
| 1096 ASSERT(m_layoutSubtreeRootList.isEmpty()); | 1114 ASSERT(m_layoutSubtreeRootList.isEmpty()); |
| 1097 } // Reset m_layoutSchedulingEnabled to its previous value. | 1115 } // Reset m_layoutSchedulingEnabled to its previous value. |
| 1098 checkDoesNotNeedLayout(); | 1116 checkDoesNotNeedLayout(); |
| 1099 | 1117 |
| 1100 m_frameTimingRequestsDirty = true; | 1118 m_frameTimingRequestsDirty = true; |
| 1101 | 1119 |
| 1102 // FIXME: Could find the common ancestor layer of all dirty subtrees and mark
from there. crbug.com/462719 | 1120 // FIXME: Could find the common ancestor layer of all dirty subtrees and mark |
| 1121 // from there. crbug.com/462719 |
| 1103 layoutViewItem().enclosingLayer()->updateLayerPositionsAfterLayout(); | 1122 layoutViewItem().enclosingLayer()->updateLayerPositionsAfterLayout(); |
| 1104 | 1123 |
| 1105 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( | 1124 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( |
| 1106 TRACE_DISABLED_BY_DEFAULT("blink.debug.layout.trees"), "LayoutTree", this, | 1125 TRACE_DISABLED_BY_DEFAULT("blink.debug.layout.trees"), "LayoutTree", this, |
| 1107 TracedLayoutObject::create(*layoutView(), true)); | 1126 TracedLayoutObject::create(*layoutView(), true)); |
| 1108 | 1127 |
| 1109 layoutViewItem().compositor()->didLayout(); | 1128 layoutViewItem().compositor()->didLayout(); |
| 1110 | 1129 |
| 1111 m_layoutCount++; | 1130 m_layoutCount++; |
| 1112 | 1131 |
| 1113 if (AXObjectCache* cache = document->axObjectCache()) { | 1132 if (AXObjectCache* cache = document->axObjectCache()) { |
| 1114 const KURL& url = document->url(); | 1133 const KURL& url = document->url(); |
| 1115 if (url.isValid() && !url.isAboutBlankURL()) | 1134 if (url.isValid() && !url.isAboutBlankURL()) |
| 1116 cache->handleLayoutComplete(document); | 1135 cache->handleLayoutComplete(document); |
| 1117 } | 1136 } |
| 1118 updateDocumentAnnotatedRegions(); | 1137 updateDocumentAnnotatedRegions(); |
| 1119 checkDoesNotNeedLayout(); | 1138 checkDoesNotNeedLayout(); |
| 1120 | 1139 |
| 1121 scheduleOrPerformPostLayoutTasks(); | 1140 scheduleOrPerformPostLayoutTasks(); |
| 1122 checkDoesNotNeedLayout(); | 1141 checkDoesNotNeedLayout(); |
| 1123 | 1142 |
| 1124 // FIXME: The notion of a single root for layout is no longer applicable. Remo
ve or update this code. crbug.com/460596 | 1143 // FIXME: The notion of a single root for layout is no longer applicable. |
| 1144 // Remove or update this code. crbug.com/460596 |
| 1125 TRACE_EVENT_END1("devtools.timeline", "Layout", "endData", | 1145 TRACE_EVENT_END1("devtools.timeline", "Layout", "endData", |
| 1126 InspectorLayoutEvent::endData(rootForThisLayout)); | 1146 InspectorLayoutEvent::endData(rootForThisLayout)); |
| 1127 InspectorInstrumentation::didUpdateLayout(m_frame.get()); | 1147 InspectorInstrumentation::didUpdateLayout(m_frame.get()); |
| 1128 | 1148 |
| 1129 m_nestedLayoutCount--; | 1149 m_nestedLayoutCount--; |
| 1130 if (m_nestedLayoutCount) | 1150 if (m_nestedLayoutCount) |
| 1131 return; | 1151 return; |
| 1132 | 1152 |
| 1133 #if ENABLE(ASSERT) | 1153 #if ENABLE(ASSERT) |
| 1134 // Post-layout assert that nobody was re-marked as needing layout during layou
t. | 1154 // Post-layout assert that nobody was re-marked as needing layout during |
| 1155 // layout. |
| 1135 layoutView()->assertSubtreeIsLaidOut(); | 1156 layoutView()->assertSubtreeIsLaidOut(); |
| 1136 #endif | 1157 #endif |
| 1137 | 1158 |
| 1138 frame().document()->layoutUpdated(); | 1159 frame().document()->layoutUpdated(); |
| 1139 checkDoesNotNeedLayout(); | 1160 checkDoesNotNeedLayout(); |
| 1140 } | 1161 } |
| 1141 | 1162 |
| 1142 void FrameView::invalidateTreeIfNeeded( | 1163 void FrameView::invalidateTreeIfNeeded( |
| 1143 const PaintInvalidationState& paintInvalidationState) { | 1164 const PaintInvalidationState& paintInvalidationState) { |
| 1144 DCHECK(!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()); | 1165 DCHECK(!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1238 | 1259 |
| 1239 LayoutReplaced* FrameView::embeddedReplacedContent() const { | 1260 LayoutReplaced* FrameView::embeddedReplacedContent() const { |
| 1240 LayoutViewItem layoutViewItem = this->layoutViewItem(); | 1261 LayoutViewItem layoutViewItem = this->layoutViewItem(); |
| 1241 if (layoutViewItem.isNull()) | 1262 if (layoutViewItem.isNull()) |
| 1242 return nullptr; | 1263 return nullptr; |
| 1243 | 1264 |
| 1244 LayoutObject* firstChild = layoutView()->firstChild(); | 1265 LayoutObject* firstChild = layoutView()->firstChild(); |
| 1245 if (!firstChild || !firstChild->isBox()) | 1266 if (!firstChild || !firstChild->isBox()) |
| 1246 return nullptr; | 1267 return nullptr; |
| 1247 | 1268 |
| 1248 // Currently only embedded SVG documents participate in the size-negotiation l
ogic. | 1269 // Currently only embedded SVG documents participate in the size-negotiation |
| 1270 // logic. |
| 1249 if (firstChild->isSVGRoot()) | 1271 if (firstChild->isSVGRoot()) |
| 1250 return toLayoutSVGRoot(firstChild); | 1272 return toLayoutSVGRoot(firstChild); |
| 1251 | 1273 |
| 1252 return nullptr; | 1274 return nullptr; |
| 1253 } | 1275 } |
| 1254 | 1276 |
| 1255 void FrameView::addPart(LayoutPart* object) { | 1277 void FrameView::addPart(LayoutPart* object) { |
| 1256 m_parts.add(object); | 1278 m_parts.add(object); |
| 1257 } | 1279 } |
| 1258 | 1280 |
| 1259 void FrameView::removePart(LayoutPart* object) { | 1281 void FrameView::removePart(LayoutPart* object) { |
| 1260 m_parts.remove(object); | 1282 m_parts.remove(object); |
| 1261 } | 1283 } |
| 1262 | 1284 |
| 1263 void FrameView::updateWidgetGeometries() { | 1285 void FrameView::updateWidgetGeometries() { |
| 1264 Vector<RefPtr<LayoutPart>> parts; | 1286 Vector<RefPtr<LayoutPart>> parts; |
| 1265 copyToVector(m_parts, parts); | 1287 copyToVector(m_parts, parts); |
| 1266 | 1288 |
| 1267 for (auto part : parts) { | 1289 for (auto part : parts) { |
| 1268 // Script or plugins could detach the frame so abort processing if that happ
ens. | 1290 // Script or plugins could detach the frame so abort processing if that |
| 1291 // happens. |
| 1269 if (layoutViewItem().isNull()) | 1292 if (layoutViewItem().isNull()) |
| 1270 break; | 1293 break; |
| 1271 | 1294 |
| 1272 if (Widget* widget = part->widget()) { | 1295 if (Widget* widget = part->widget()) { |
| 1273 if (widget->isFrameView()) { | 1296 if (widget->isFrameView()) { |
| 1274 FrameView* frameView = toFrameView(widget); | 1297 FrameView* frameView = toFrameView(widget); |
| 1275 bool didNeedLayout = frameView->needsLayout(); | 1298 bool didNeedLayout = frameView->needsLayout(); |
| 1276 part->updateWidgetGeometry(); | 1299 part->updateWidgetGeometry(); |
| 1277 if (!didNeedLayout && !frameView->shouldThrottleRendering()) | 1300 if (!didNeedLayout && !frameView->shouldThrottleRendering()) |
| 1278 frameView->checkDoesNotNeedLayout(); | 1301 frameView->checkDoesNotNeedLayout(); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1381 if (ScrollingCoordinator* scrollingCoordinator = | 1404 if (ScrollingCoordinator* scrollingCoordinator = |
| 1382 this->scrollingCoordinator()) | 1405 this->scrollingCoordinator()) |
| 1383 scrollingCoordinator->frameViewFixedObjectsDidChange(this); | 1406 scrollingCoordinator->frameViewFixedObjectsDidChange(this); |
| 1384 } | 1407 } |
| 1385 } | 1408 } |
| 1386 | 1409 |
| 1387 void FrameView::viewportSizeChanged(bool widthChanged, bool heightChanged) { | 1410 void FrameView::viewportSizeChanged(bool widthChanged, bool heightChanged) { |
| 1388 DCHECK(widthChanged || heightChanged); | 1411 DCHECK(widthChanged || heightChanged); |
| 1389 | 1412 |
| 1390 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 1413 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 1391 // The background must be repainted when the FrameView is resized, even if t
he initial | 1414 // The background must be repainted when the FrameView is resized, even if |
| 1392 // containing block does not change (so we can't rely on layout to issue the
invalidation). | 1415 // the initial containing block does not change (so we can't rely on layout |
| 1393 // This is because the background fills the main GraphicsLayer, which takes
the size of the | 1416 // to issue the invalidation). This is because the background fills the |
| 1394 // layout viewport. | 1417 // main GraphicsLayer, which takes the size of the layout viewport. |
| 1395 // TODO(skobes): Paint non-fixed backgrounds into the scrolling contents lay
er and avoid | 1418 // TODO(skobes): Paint non-fixed backgrounds into the scrolling contents |
| 1396 // this invalidation (http://crbug.com/568847). | 1419 // layer and avoid this invalidation (http://crbug.com/568847). |
| 1397 LayoutViewItem lvi = layoutViewItem(); | 1420 LayoutViewItem lvi = layoutViewItem(); |
| 1398 if (!lvi.isNull()) | 1421 if (!lvi.isNull()) |
| 1399 lvi.setShouldDoFullPaintInvalidation(); | 1422 lvi.setShouldDoFullPaintInvalidation(); |
| 1400 } | 1423 } |
| 1401 | 1424 |
| 1402 if (!hasViewportConstrainedObjects()) | 1425 if (!hasViewportConstrainedObjects()) |
| 1403 return; | 1426 return; |
| 1404 | 1427 |
| 1405 for (const auto& viewportConstrainedObject : *m_viewportConstrainedObjects) { | 1428 for (const auto& viewportConstrainedObject : *m_viewportConstrainedObjects) { |
| 1406 LayoutObject* layoutObject = viewportConstrainedObject; | 1429 LayoutObject* layoutObject = viewportConstrainedObject; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1462 | 1485 |
| 1463 // invalidate even if there is an ancestor with a filter that moves pixels. | 1486 // invalidate even if there is an ancestor with a filter that moves pixels. |
| 1464 layoutItem | 1487 layoutItem |
| 1465 .setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(); | 1488 .setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(); |
| 1466 | 1489 |
| 1467 TRACE_EVENT_INSTANT1( | 1490 TRACE_EVENT_INSTANT1( |
| 1468 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.invalidationTracking"), | 1491 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.invalidationTracking"), |
| 1469 "ScrollInvalidationTracking", TRACE_EVENT_SCOPE_THREAD, "data", | 1492 "ScrollInvalidationTracking", TRACE_EVENT_SCOPE_THREAD, "data", |
| 1470 InspectorScrollInvalidationTrackingEvent::data(*layoutObject)); | 1493 InspectorScrollInvalidationTrackingEvent::data(*layoutObject)); |
| 1471 | 1494 |
| 1472 // If the fixed layer has a blur/drop-shadow filter applied on at least one
of its parents, we cannot | 1495 // If the fixed layer has a blur/drop-shadow filter applied on at least one |
| 1473 // scroll using the fast path, otherwise the outsets of the filter will be m
oved around the page. | 1496 // of its parents, we cannot scroll using the fast path, otherwise the |
| 1497 // outsets of the filter will be moved around the page. |
| 1474 if (layer->hasAncestorWithFilterThatMovesPixels()) | 1498 if (layer->hasAncestorWithFilterThatMovesPixels()) |
| 1475 fastPathAllowed = false; | 1499 fastPathAllowed = false; |
| 1476 } | 1500 } |
| 1477 return fastPathAllowed; | 1501 return fastPathAllowed; |
| 1478 } | 1502 } |
| 1479 | 1503 |
| 1480 bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta) { | 1504 bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta) { |
| 1481 if (!contentsInCompositedLayer()) | 1505 if (!contentsInCompositedLayer()) |
| 1482 return false; | 1506 return false; |
| 1483 | 1507 |
| 1484 invalidateBackgroundAttachmentFixedObjects(); | 1508 invalidateBackgroundAttachmentFixedObjects(); |
| 1485 | 1509 |
| 1486 if (!m_viewportConstrainedObjects || | 1510 if (!m_viewportConstrainedObjects || |
| 1487 m_viewportConstrainedObjects->isEmpty()) { | 1511 m_viewportConstrainedObjects->isEmpty()) { |
| 1488 InspectorInstrumentation::didUpdateLayout(m_frame.get()); | 1512 InspectorInstrumentation::didUpdateLayout(m_frame.get()); |
| 1489 return true; | 1513 return true; |
| 1490 } | 1514 } |
| 1491 | 1515 |
| 1492 if (!invalidateViewportConstrainedObjects()) | 1516 if (!invalidateViewportConstrainedObjects()) |
| 1493 return false; | 1517 return false; |
| 1494 | 1518 |
| 1495 InspectorInstrumentation::didUpdateLayout(m_frame.get()); | 1519 InspectorInstrumentation::didUpdateLayout(m_frame.get()); |
| 1496 return true; | 1520 return true; |
| 1497 } | 1521 } |
| 1498 | 1522 |
| 1499 void FrameView::scrollContentsSlowPath() { | 1523 void FrameView::scrollContentsSlowPath() { |
| 1500 TRACE_EVENT0("blink", "FrameView::scrollContentsSlowPath"); | 1524 TRACE_EVENT0("blink", "FrameView::scrollContentsSlowPath"); |
| 1501 // We need full invalidation during slow scrolling. For slimming paint, full i
nvalidation | 1525 // We need full invalidation during slow scrolling. For slimming paint, full |
| 1502 // of the LayoutView is not enough. We also need to invalidate all of the obje
cts. | 1526 // invalidation of the LayoutView is not enough. We also need to invalidate |
| 1503 // FIXME: Find out what are enough to invalidate in slow path scrolling. crbug
.com/451090#9. | 1527 // all of the objects. |
| 1528 // FIXME: Find out what are enough to invalidate in slow path scrolling. |
| 1529 // crbug.com/451090#9. |
| 1504 ASSERT(!layoutViewItem().isNull()); | 1530 ASSERT(!layoutViewItem().isNull()); |
| 1505 if (contentsInCompositedLayer()) | 1531 if (contentsInCompositedLayer()) |
| 1506 layoutViewItem() | 1532 layoutViewItem() |
| 1507 .layer() | 1533 .layer() |
| 1508 ->compositedLayerMapping() | 1534 ->compositedLayerMapping() |
| 1509 ->setContentsNeedDisplay(); | 1535 ->setContentsNeedDisplay(); |
| 1510 else | 1536 else |
| 1511 layoutViewItem() | 1537 layoutViewItem() |
| 1512 .setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(); | 1538 .setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(); |
| 1513 | 1539 |
| 1514 if (contentsInCompositedLayer()) { | 1540 if (contentsInCompositedLayer()) { |
| 1515 IntRect updateRect = visibleContentRect(); | 1541 IntRect updateRect = visibleContentRect(); |
| 1516 ASSERT(!layoutViewItem().isNull()); | 1542 ASSERT(!layoutViewItem().isNull()); |
| 1517 // FIXME: We should not allow paint invalidation out of paint invalidation s
tate. crbug.com/457415 | 1543 // FIXME: We should not allow paint invalidation out of paint invalidation |
| 1544 // state. crbug.com/457415 |
| 1518 DisablePaintInvalidationStateAsserts disabler; | 1545 DisablePaintInvalidationStateAsserts disabler; |
| 1519 layoutViewItem().invalidatePaintRectangle(LayoutRect(updateRect)); | 1546 layoutViewItem().invalidatePaintRectangle(LayoutRect(updateRect)); |
| 1520 } | 1547 } |
| 1521 LayoutPartItem frameLayoutItem = m_frame->ownerLayoutItem(); | 1548 LayoutPartItem frameLayoutItem = m_frame->ownerLayoutItem(); |
| 1522 if (!frameLayoutItem.isNull()) { | 1549 if (!frameLayoutItem.isNull()) { |
| 1523 if (isEnclosedInCompositingLayer()) { | 1550 if (isEnclosedInCompositingLayer()) { |
| 1524 LayoutRect rect( | 1551 LayoutRect rect( |
| 1525 frameLayoutItem.borderLeft() + frameLayoutItem.paddingLeft(), | 1552 frameLayoutItem.borderLeft() + frameLayoutItem.paddingLeft(), |
| 1526 frameLayoutItem.borderTop() + frameLayoutItem.paddingTop(), | 1553 frameLayoutItem.borderTop() + frameLayoutItem.paddingTop(), |
| 1527 LayoutUnit(visibleWidth()), LayoutUnit(visibleHeight())); | 1554 LayoutUnit(visibleWidth()), LayoutUnit(visibleHeight())); |
| 1528 // FIXME: We should not allow paint invalidation out of paint invalidation
state. crbug.com/457415 | 1555 // FIXME: We should not allow paint invalidation out of paint invalidation |
| 1556 // state. crbug.com/457415 |
| 1529 DisablePaintInvalidationStateAsserts disabler; | 1557 DisablePaintInvalidationStateAsserts disabler; |
| 1530 frameLayoutItem.invalidatePaintRectangle(rect); | 1558 frameLayoutItem.invalidatePaintRectangle(rect); |
| 1531 return; | 1559 return; |
| 1532 } | 1560 } |
| 1533 } | 1561 } |
| 1534 } | 1562 } |
| 1535 | 1563 |
| 1536 void FrameView::restoreScrollbar() { | 1564 void FrameView::restoreScrollbar() { |
| 1537 setScrollbarsSuppressed(false); | 1565 setScrollbarsSuppressed(false); |
| 1538 } | 1566 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1580 | 1608 |
| 1581 if (m_frame->document()->isSVGDocument()) { | 1609 if (m_frame->document()->isSVGDocument()) { |
| 1582 if (SVGSVGElement* svg = | 1610 if (SVGSVGElement* svg = |
| 1583 SVGDocumentExtensions::rootElement(*m_frame->document())) { | 1611 SVGDocumentExtensions::rootElement(*m_frame->document())) { |
| 1584 svg->setupInitialView(name, anchorNode); | 1612 svg->setupInitialView(name, anchorNode); |
| 1585 if (!anchorNode) | 1613 if (!anchorNode) |
| 1586 return true; | 1614 return true; |
| 1587 } | 1615 } |
| 1588 } | 1616 } |
| 1589 | 1617 |
| 1590 // Implement the rule that "" and "top" both mean top of page as in other brow
sers. | 1618 // Implement the rule that "" and "top" both mean top of page as in other |
| 1619 // browsers. |
| 1591 if (!anchorNode && !(name.isEmpty() || equalIgnoringCase(name, "top"))) | 1620 if (!anchorNode && !(name.isEmpty() || equalIgnoringCase(name, "top"))) |
| 1592 return false; | 1621 return false; |
| 1593 | 1622 |
| 1594 if (behavior == UrlFragmentScroll) | 1623 if (behavior == UrlFragmentScroll) |
| 1595 setFragmentAnchor(anchorNode ? static_cast<Node*>(anchorNode) | 1624 setFragmentAnchor(anchorNode ? static_cast<Node*>(anchorNode) |
| 1596 : m_frame->document()); | 1625 : m_frame->document()); |
| 1597 | 1626 |
| 1598 // If the anchor accepts keyboard focus and fragment scrolling is allowed, | 1627 // If the anchor accepts keyboard focus and fragment scrolling is allowed, |
| 1599 // move focus there to aid users relying on keyboard navigation. | 1628 // move focus there to aid users relying on keyboard navigation. |
| 1600 // If anchorNode is not focusable or fragment scrolling is not allowed, | 1629 // If anchorNode is not focusable or fragment scrolling is not allowed, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1613 return true; | 1642 return true; |
| 1614 } | 1643 } |
| 1615 | 1644 |
| 1616 void FrameView::setFragmentAnchor(Node* anchorNode) { | 1645 void FrameView::setFragmentAnchor(Node* anchorNode) { |
| 1617 ASSERT(anchorNode); | 1646 ASSERT(anchorNode); |
| 1618 m_fragmentAnchor = anchorNode; | 1647 m_fragmentAnchor = anchorNode; |
| 1619 | 1648 |
| 1620 // We need to update the layout tree before scrolling. | 1649 // We need to update the layout tree before scrolling. |
| 1621 m_frame->document()->updateStyleAndLayoutTree(); | 1650 m_frame->document()->updateStyleAndLayoutTree(); |
| 1622 | 1651 |
| 1623 // If layout is needed, we will scroll in performPostLayoutTasks. Otherwise, s
croll immediately. | 1652 // If layout is needed, we will scroll in performPostLayoutTasks. Otherwise, |
| 1653 // scroll immediately. |
| 1624 LayoutViewItem layoutViewItem = this->layoutViewItem(); | 1654 LayoutViewItem layoutViewItem = this->layoutViewItem(); |
| 1625 if (!layoutViewItem.isNull() && layoutViewItem.needsLayout()) | 1655 if (!layoutViewItem.isNull() && layoutViewItem.needsLayout()) |
| 1626 layout(); | 1656 layout(); |
| 1627 else | 1657 else |
| 1628 scrollToFragmentAnchor(); | 1658 scrollToFragmentAnchor(); |
| 1629 } | 1659 } |
| 1630 | 1660 |
| 1631 void FrameView::clearFragmentAnchor() { | 1661 void FrameView::clearFragmentAnchor() { |
| 1632 m_fragmentAnchor = nullptr; | 1662 m_fragmentAnchor = nullptr; |
| 1633 } | 1663 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1700 LayoutObject* layoutObject = viewportConstrainedObject; | 1730 LayoutObject* layoutObject = viewportConstrainedObject; |
| 1701 PaintLayer* layer = toLayoutBoxModelObject(layoutObject)->layer(); | 1731 PaintLayer* layer = toLayoutBoxModelObject(layoutObject)->layer(); |
| 1702 if (layoutObject->style()->position() == StickyPosition) { | 1732 if (layoutObject->style()->position() == StickyPosition) { |
| 1703 // TODO(skobes): Resolve circular dependency between scroll offset and | 1733 // TODO(skobes): Resolve circular dependency between scroll offset and |
| 1704 // compositing state, and remove this disabler. https://crbug.com/420741 | 1734 // compositing state, and remove this disabler. https://crbug.com/420741 |
| 1705 DisableCompositingQueryAsserts disabler; | 1735 DisableCompositingQueryAsserts disabler; |
| 1706 layer->updateLayerPositionsAfterOverflowScroll(scrollDelta); | 1736 layer->updateLayerPositionsAfterOverflowScroll(scrollDelta); |
| 1707 } | 1737 } |
| 1708 } | 1738 } |
| 1709 | 1739 |
| 1710 // If there fixed position elements, scrolling may cause compositing layers to
change. | 1740 // If there fixed position elements, scrolling may cause compositing layers to |
| 1711 // Update widget and layer positions after scrolling, but only if we're not in
side of | 1741 // change. Update widget and layer positions after scrolling, but only if |
| 1712 // layout. | 1742 // we're not inside of layout. |
| 1713 if (!m_nestedLayoutCount) { | 1743 if (!m_nestedLayoutCount) { |
| 1714 updateWidgetGeometries(); | 1744 updateWidgetGeometries(); |
| 1715 LayoutViewItem layoutViewItem = this->layoutViewItem(); | 1745 LayoutViewItem layoutViewItem = this->layoutViewItem(); |
| 1716 if (!layoutViewItem.isNull()) | 1746 if (!layoutViewItem.isNull()) |
| 1717 layoutViewItem.layer()->setNeedsCompositingInputsUpdate(); | 1747 layoutViewItem.layer()->setNeedsCompositingInputsUpdate(); |
| 1718 } | 1748 } |
| 1719 } | 1749 } |
| 1720 | 1750 |
| 1721 bool FrameView::computeCompositedSelection(LocalFrame& frame, | 1751 bool FrameView::computeCompositedSelection(LocalFrame& frame, |
| 1722 CompositedSelection& selection) { | 1752 CompositedSelection& selection) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1806 if (TextAutosizer* textAutosizer = m_frame->document()->textAutosizer()) | 1836 if (TextAutosizer* textAutosizer = m_frame->document()->textAutosizer()) |
| 1807 textAutosizer->updatePageInfoInAllFrames(); | 1837 textAutosizer->updatePageInfoInAllFrames(); |
| 1808 } | 1838 } |
| 1809 | 1839 |
| 1810 ScrollableArea::contentsResized(); | 1840 ScrollableArea::contentsResized(); |
| 1811 setNeedsLayout(); | 1841 setNeedsLayout(); |
| 1812 } | 1842 } |
| 1813 | 1843 |
| 1814 void FrameView::scrollbarExistenceDidChange() { | 1844 void FrameView::scrollbarExistenceDidChange() { |
| 1815 // We check to make sure the view is attached to a frame() as this method can | 1845 // We check to make sure the view is attached to a frame() as this method can |
| 1816 // be triggered before the view is attached by LocalFrame::createView(...) set
ting | 1846 // be triggered before the view is attached by LocalFrame::createView(...) |
| 1817 // various values such as setScrollBarModes(...) for example. An ASSERT is | 1847 // setting various values such as setScrollBarModes(...) for example. An |
| 1818 // triggered when a view is layout before being attached to a frame(). | 1848 // ASSERT is triggered when a view is layout before being attached to a |
| 1849 // frame(). |
| 1819 if (!frame().view()) | 1850 if (!frame().view()) |
| 1820 return; | 1851 return; |
| 1821 | 1852 |
| 1822 bool hasOverlayScrollbars = this->hasOverlayScrollbars(); | 1853 bool hasOverlayScrollbars = this->hasOverlayScrollbars(); |
| 1823 | 1854 |
| 1824 // FIXME: this call to layout() could be called within FrameView::layout(), bu
t before performLayout(), | 1855 // FIXME: this call to layout() could be called within FrameView::layout(), |
| 1825 // causing double-layout. See also crbug.com/429242. | 1856 // but before performLayout(), causing double-layout. See also |
| 1857 // crbug.com/429242. |
| 1826 if (!hasOverlayScrollbars && needsLayout()) | 1858 if (!hasOverlayScrollbars && needsLayout()) |
| 1827 layout(); | 1859 layout(); |
| 1828 | 1860 |
| 1829 if (!layoutViewItem().isNull() && layoutViewItem().usesCompositing()) { | 1861 if (!layoutViewItem().isNull() && layoutViewItem().usesCompositing()) { |
| 1830 layoutViewItem().compositor()->frameViewScrollbarsExistenceDidChange(); | 1862 layoutViewItem().compositor()->frameViewScrollbarsExistenceDidChange(); |
| 1831 | 1863 |
| 1832 if (!hasOverlayScrollbars) | 1864 if (!hasOverlayScrollbars) |
| 1833 layoutViewItem().compositor()->frameViewDidChangeSize(); | 1865 layoutViewItem().compositor()->frameViewDidChangeSize(); |
| 1834 } | 1866 } |
| 1835 } | 1867 } |
| 1836 | 1868 |
| 1837 void FrameView::handleLoadCompleted() { | 1869 void FrameView::handleLoadCompleted() { |
| 1838 // Once loading has completed, allow autoSize one last opportunity to | 1870 // Once loading has completed, allow autoSize one last opportunity to |
| 1839 // reduce the size of the frame. | 1871 // reduce the size of the frame. |
| 1840 if (m_autoSizeInfo) | 1872 if (m_autoSizeInfo) |
| 1841 m_autoSizeInfo->autoSizeIfNeeded(); | 1873 m_autoSizeInfo->autoSizeIfNeeded(); |
| 1842 | 1874 |
| 1843 // If there is a pending layout, the fragment anchor will be cleared when it f
inishes. | 1875 // If there is a pending layout, the fragment anchor will be cleared when it |
| 1876 // finishes. |
| 1844 if (!needsLayout()) | 1877 if (!needsLayout()) |
| 1845 clearFragmentAnchor(); | 1878 clearFragmentAnchor(); |
| 1846 } | 1879 } |
| 1847 | 1880 |
| 1848 void FrameView::clearLayoutSubtreeRoot(const LayoutObject& root) { | 1881 void FrameView::clearLayoutSubtreeRoot(const LayoutObject& root) { |
| 1849 m_layoutSubtreeRootList.remove(const_cast<LayoutObject&>(root)); | 1882 m_layoutSubtreeRootList.remove(const_cast<LayoutObject&>(root)); |
| 1850 } | 1883 } |
| 1851 | 1884 |
| 1852 void FrameView::clearLayoutSubtreeRootsAndMarkContainingBlocks() { | 1885 void FrameView::clearLayoutSubtreeRootsAndMarkContainingBlocks() { |
| 1853 m_layoutSubtreeRootList.clearAndMarkContainingBlocksForLayout(); | 1886 m_layoutSubtreeRootList.clearAndMarkContainingBlocksForLayout(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1894 | 1927 |
| 1895 removeFloatingObjectsForSubtreeRoot(*root); | 1928 removeFloatingObjectsForSubtreeRoot(*root); |
| 1896 layoutFromRootObject(*root); | 1929 layoutFromRootObject(*root); |
| 1897 } | 1930 } |
| 1898 } | 1931 } |
| 1899 | 1932 |
| 1900 bool FrameView::checkLayoutInvalidationIsAllowed() const { | 1933 bool FrameView::checkLayoutInvalidationIsAllowed() const { |
| 1901 if (m_allowsLayoutInvalidationAfterLayoutClean) | 1934 if (m_allowsLayoutInvalidationAfterLayoutClean) |
| 1902 return true; | 1935 return true; |
| 1903 | 1936 |
| 1904 // If we are updating all lifecycle phases beyond LayoutClean, we don't expect
dirty layout after LayoutClean. | 1937 // If we are updating all lifecycle phases beyond LayoutClean, we don't expect |
| 1938 // dirty layout after LayoutClean. |
| 1905 CHECK_FOR_DIRTY_LAYOUT(lifecycle().state() < DocumentLifecycle::LayoutClean); | 1939 CHECK_FOR_DIRTY_LAYOUT(lifecycle().state() < DocumentLifecycle::LayoutClean); |
| 1906 | 1940 |
| 1907 return true; | 1941 return true; |
| 1908 } | 1942 } |
| 1909 | 1943 |
| 1910 void FrameView::scheduleRelayout() { | 1944 void FrameView::scheduleRelayout() { |
| 1911 DCHECK(m_frame->view() == this); | 1945 DCHECK(m_frame->view() == this); |
| 1912 | 1946 |
| 1913 if (!m_layoutSchedulingEnabled) | 1947 if (!m_layoutSchedulingEnabled) |
| 1914 return; | 1948 return; |
| 1915 // TODO(crbug.com/590856): It's still broken when we choose not to crash when
the check fails. | 1949 // TODO(crbug.com/590856): It's still broken when we choose not to crash when |
| 1950 // the check fails. |
| 1916 if (!checkLayoutInvalidationIsAllowed()) | 1951 if (!checkLayoutInvalidationIsAllowed()) |
| 1917 return; | 1952 return; |
| 1918 if (!needsLayout()) | 1953 if (!needsLayout()) |
| 1919 return; | 1954 return; |
| 1920 if (!m_frame->document()->shouldScheduleLayout()) | 1955 if (!m_frame->document()->shouldScheduleLayout()) |
| 1921 return; | 1956 return; |
| 1922 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), | 1957 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), |
| 1923 "InvalidateLayout", TRACE_EVENT_SCOPE_THREAD, "data", | 1958 "InvalidateLayout", TRACE_EVENT_SCOPE_THREAD, "data", |
| 1924 InspectorInvalidateLayoutEvent::data(m_frame.get())); | 1959 InspectorInvalidateLayoutEvent::data(m_frame.get())); |
| 1925 | 1960 |
| 1926 clearLayoutSubtreeRootsAndMarkContainingBlocks(); | 1961 clearLayoutSubtreeRootsAndMarkContainingBlocks(); |
| 1927 | 1962 |
| 1928 if (m_hasPendingLayout) | 1963 if (m_hasPendingLayout) |
| 1929 return; | 1964 return; |
| 1930 m_hasPendingLayout = true; | 1965 m_hasPendingLayout = true; |
| 1931 | 1966 |
| 1932 if (!shouldThrottleRendering()) | 1967 if (!shouldThrottleRendering()) |
| 1933 page()->animator().scheduleVisualUpdate(m_frame.get()); | 1968 page()->animator().scheduleVisualUpdate(m_frame.get()); |
| 1934 } | 1969 } |
| 1935 | 1970 |
| 1936 void FrameView::scheduleRelayoutOfSubtree(LayoutObject* relayoutRoot) { | 1971 void FrameView::scheduleRelayoutOfSubtree(LayoutObject* relayoutRoot) { |
| 1937 DCHECK(m_frame->view() == this); | 1972 DCHECK(m_frame->view() == this); |
| 1938 | 1973 |
| 1939 // TODO(crbug.com/590856): It's still broken when we choose not to crash when
the check fails. | 1974 // TODO(crbug.com/590856): It's still broken when we choose not to crash when |
| 1975 // the check fails. |
| 1940 if (!checkLayoutInvalidationIsAllowed()) | 1976 if (!checkLayoutInvalidationIsAllowed()) |
| 1941 return; | 1977 return; |
| 1942 | 1978 |
| 1943 // FIXME: Should this call shouldScheduleLayout instead? | 1979 // FIXME: Should this call shouldScheduleLayout instead? |
| 1944 if (!m_frame->document()->isActive()) | 1980 if (!m_frame->document()->isActive()) |
| 1945 return; | 1981 return; |
| 1946 | 1982 |
| 1947 LayoutView* layoutView = this->layoutView(); | 1983 LayoutView* layoutView = this->layoutView(); |
| 1948 if (layoutView && layoutView->needsLayout()) { | 1984 if (layoutView && layoutView->needsLayout()) { |
| 1949 if (relayoutRoot) | 1985 if (relayoutRoot) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1994 CHECK_FOR_DIRTY_LAYOUT(layoutViewItem().isNull() || | 2030 CHECK_FOR_DIRTY_LAYOUT(layoutViewItem().isNull() || |
| 1995 !layoutViewItem().needsLayout()); | 2031 !layoutViewItem().needsLayout()); |
| 1996 CHECK_FOR_DIRTY_LAYOUT(!isSubtreeLayout()); | 2032 CHECK_FOR_DIRTY_LAYOUT(!isSubtreeLayout()); |
| 1997 return true; | 2033 return true; |
| 1998 } | 2034 } |
| 1999 | 2035 |
| 2000 void FrameView::setNeedsLayout() { | 2036 void FrameView::setNeedsLayout() { |
| 2001 LayoutViewItem layoutViewItem = this->layoutViewItem(); | 2037 LayoutViewItem layoutViewItem = this->layoutViewItem(); |
| 2002 if (layoutViewItem.isNull()) | 2038 if (layoutViewItem.isNull()) |
| 2003 return; | 2039 return; |
| 2004 // TODO(crbug.com/590856): It's still broken if we choose not to crash when th
e check fails. | 2040 // TODO(crbug.com/590856): It's still broken if we choose not to crash when |
| 2041 // the check fails. |
| 2005 if (!checkLayoutInvalidationIsAllowed()) | 2042 if (!checkLayoutInvalidationIsAllowed()) |
| 2006 return; | 2043 return; |
| 2007 layoutViewItem.setNeedsLayout(LayoutInvalidationReason::Unknown); | 2044 layoutViewItem.setNeedsLayout(LayoutInvalidationReason::Unknown); |
| 2008 } | 2045 } |
| 2009 | 2046 |
| 2010 bool FrameView::isTransparent() const { | 2047 bool FrameView::isTransparent() const { |
| 2011 return m_isTransparent; | 2048 return m_isTransparent; |
| 2012 } | 2049 } |
| 2013 | 2050 |
| 2014 void FrameView::setTransparent(bool isTransparent) { | 2051 void FrameView::setTransparent(bool isTransparent) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2051 frameView.setTransparent(transparent); | 2088 frameView.setTransparent(transparent); |
| 2052 frameView.setBaseBackgroundColor(backgroundColor); | 2089 frameView.setBaseBackgroundColor(backgroundColor); |
| 2053 }); | 2090 }); |
| 2054 } | 2091 } |
| 2055 | 2092 |
| 2056 void FrameView::scrollToFragmentAnchor() { | 2093 void FrameView::scrollToFragmentAnchor() { |
| 2057 Node* anchorNode = m_fragmentAnchor; | 2094 Node* anchorNode = m_fragmentAnchor; |
| 2058 if (!anchorNode) | 2095 if (!anchorNode) |
| 2059 return; | 2096 return; |
| 2060 | 2097 |
| 2061 // Scrolling is disabled during updateScrollbars (see isProgrammaticallyScroll
able). | 2098 // Scrolling is disabled during updateScrollbars (see |
| 2062 // Bail now to avoid clearing m_fragmentAnchor before we actually have a chanc
e to scroll. | 2099 // isProgrammaticallyScrollable). Bail now to avoid clearing m_fragmentAnchor |
| 2100 // before we actually have a chance to scroll. |
| 2063 if (m_inUpdateScrollbars) | 2101 if (m_inUpdateScrollbars) |
| 2064 return; | 2102 return; |
| 2065 | 2103 |
| 2066 if (anchorNode->layoutObject()) { | 2104 if (anchorNode->layoutObject()) { |
| 2067 LayoutRect rect; | 2105 LayoutRect rect; |
| 2068 if (anchorNode != m_frame->document()) { | 2106 if (anchorNode != m_frame->document()) { |
| 2069 rect = anchorNode->boundingBox(); | 2107 rect = anchorNode->boundingBox(); |
| 2070 } else if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 2108 } else if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 2071 if (Element* documentElement = m_frame->document()->documentElement()) | 2109 if (Element* documentElement = m_frame->document()->documentElement()) |
| 2072 rect = documentElement->boundingBox(); | 2110 rect = documentElement->boundingBox(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2088 | 2126 |
| 2089 if (boundaryFrame && boundaryFrame->isLocalFrame()) | 2127 if (boundaryFrame && boundaryFrame->isLocalFrame()) |
| 2090 toLocalFrame(boundaryFrame) | 2128 toLocalFrame(boundaryFrame) |
| 2091 ->view() | 2129 ->view() |
| 2092 ->setSafeToPropagateScrollToParent(true); | 2130 ->setSafeToPropagateScrollToParent(true); |
| 2093 | 2131 |
| 2094 if (AXObjectCache* cache = m_frame->document()->existingAXObjectCache()) | 2132 if (AXObjectCache* cache = m_frame->document()->existingAXObjectCache()) |
| 2095 cache->handleScrolledToAnchor(anchorNode); | 2133 cache->handleScrolledToAnchor(anchorNode); |
| 2096 } | 2134 } |
| 2097 | 2135 |
| 2098 // The fragment anchor should only be maintained while the frame is still load
ing. | 2136 // The fragment anchor should only be maintained while the frame is still |
| 2099 // If the frame is done loading, clear the anchor now. Otherwise, restore it | 2137 // loading. If the frame is done loading, clear the anchor now. Otherwise, |
| 2100 // since it may have been cleared during scrollRectToVisible. | 2138 // restore it since it may have been cleared during scrollRectToVisible. |
| 2101 m_fragmentAnchor = | 2139 m_fragmentAnchor = |
| 2102 m_frame->document()->isLoadCompleted() ? nullptr : anchorNode; | 2140 m_frame->document()->isLoadCompleted() ? nullptr : anchorNode; |
| 2103 } | 2141 } |
| 2104 | 2142 |
| 2105 bool FrameView::updateWidgets() { | 2143 bool FrameView::updateWidgets() { |
| 2106 // This is always called from updateWidgetsTimerFired. | 2144 // This is always called from updateWidgetsTimerFired. |
| 2107 // m_updateWidgetsTimer should only be scheduled if we have widgets to update. | 2145 // m_updateWidgetsTimer should only be scheduled if we have widgets to update. |
| 2108 // Thus I believe we can stop checking isEmpty here, and just ASSERT isEmpty: | 2146 // Thus I believe we can stop checking isEmpty here, and just ASSERT isEmpty: |
| 2109 // FIXME: This assert has been temporarily removed due to https://crbug.com/43
0344 | 2147 // FIXME: This assert has been temporarily removed due to |
| 2148 // https://crbug.com/430344 |
| 2110 if (m_nestedLayoutCount > 1 || m_partUpdateSet.isEmpty()) | 2149 if (m_nestedLayoutCount > 1 || m_partUpdateSet.isEmpty()) |
| 2111 return true; | 2150 return true; |
| 2112 | 2151 |
| 2113 // Need to swap because script will run inside the below loop and invalidate t
he iterator. | 2152 // Need to swap because script will run inside the below loop and invalidate |
| 2153 // the iterator. |
| 2114 EmbeddedObjectSet objects; | 2154 EmbeddedObjectSet objects; |
| 2115 objects.swap(m_partUpdateSet); | 2155 objects.swap(m_partUpdateSet); |
| 2116 | 2156 |
| 2117 for (const auto& embeddedObject : objects) { | 2157 for (const auto& embeddedObject : objects) { |
| 2118 LayoutEmbeddedObject& object = *embeddedObject; | 2158 LayoutEmbeddedObject& object = *embeddedObject; |
| 2119 HTMLPlugInElement* element = toHTMLPlugInElement(object.node()); | 2159 HTMLPlugInElement* element = toHTMLPlugInElement(object.node()); |
| 2120 | 2160 |
| 2121 // The object may have already been destroyed (thus node cleared), | 2161 // The object may have already been destroyed (thus node cleared), |
| 2122 // but FrameView holds a manual ref, so it won't have been deleted. | 2162 // but FrameView holds a manual ref, so it won't have been deleted. |
| 2123 if (!element) | 2163 if (!element) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2161 if (m_updateWidgetsTimer.isActive() || m_partUpdateSet.isEmpty()) | 2201 if (m_updateWidgetsTimer.isActive() || m_partUpdateSet.isEmpty()) |
| 2162 return; | 2202 return; |
| 2163 m_updateWidgetsTimer.startOneShot(0, BLINK_FROM_HERE); | 2203 m_updateWidgetsTimer.startOneShot(0, BLINK_FROM_HERE); |
| 2164 } | 2204 } |
| 2165 | 2205 |
| 2166 void FrameView::performPostLayoutTasks() { | 2206 void FrameView::performPostLayoutTasks() { |
| 2167 // FIXME: We can reach here, even when the page is not active! | 2207 // FIXME: We can reach here, even when the page is not active! |
| 2168 // http/tests/inspector/elements/html-link-import.html and many other | 2208 // http/tests/inspector/elements/html-link-import.html and many other |
| 2169 // tests hit that case. | 2209 // tests hit that case. |
| 2170 // We should ASSERT(isActive()); or at least return early if we can! | 2210 // We should ASSERT(isActive()); or at least return early if we can! |
| 2171 ASSERT( | 2211 |
| 2172 !isInPerformLayout()); // Always before or after performLayout(), part of
the highest-level layout() call. | 2212 // Always called before or after performLayout(), part of the highest-level |
| 2213 // layout() call. |
| 2214 ASSERT(!isInPerformLayout()); |
| 2173 TRACE_EVENT0("blink,benchmark", "FrameView::performPostLayoutTasks"); | 2215 TRACE_EVENT0("blink,benchmark", "FrameView::performPostLayoutTasks"); |
| 2174 | 2216 |
| 2175 m_postLayoutTasksTimer.stop(); | 2217 m_postLayoutTasksTimer.stop(); |
| 2176 | 2218 |
| 2177 m_frame->selection().setCaretRectNeedsUpdate(); | 2219 m_frame->selection().setCaretRectNeedsUpdate(); |
| 2178 m_frame->selection().updateAppearance(); | 2220 m_frame->selection().updateAppearance(); |
| 2179 | 2221 |
| 2180 ASSERT(m_frame->document()); | 2222 ASSERT(m_frame->document()); |
| 2181 | 2223 |
| 2182 FontFaceSet::didLayout(*m_frame->document()); | 2224 FontFaceSet::didLayout(*m_frame->document()); |
| 2183 // Cursor update scheduling is done by the local root, which is the main frame
if there | 2225 // Cursor update scheduling is done by the local root, which is the main frame |
| 2184 // are no RemoteFrame ancestors in the frame tree. Use of localFrameRoot() is | 2226 // if there are no RemoteFrame ancestors in the frame tree. Use of |
| 2185 // discouraged but will change when cursor update scheduling is moved from Eve
ntHandler | 2227 // localFrameRoot() is discouraged but will change when cursor update |
| 2186 // to PageEventHandler. | 2228 // scheduling is moved from EventHandler to PageEventHandler. |
| 2187 frame().localFrameRoot()->eventHandler().scheduleCursorUpdate(); | 2229 frame().localFrameRoot()->eventHandler().scheduleCursorUpdate(); |
| 2188 | 2230 |
| 2189 updateWidgetGeometries(); | 2231 updateWidgetGeometries(); |
| 2190 | 2232 |
| 2191 // Plugins could have torn down the page inside updateWidgetGeometries(). | 2233 // Plugins could have torn down the page inside updateWidgetGeometries(). |
| 2192 if (layoutViewItem().isNull()) | 2234 if (layoutViewItem().isNull()) |
| 2193 return; | 2235 return; |
| 2194 | 2236 |
| 2195 scheduleUpdateWidgetsIfNecessary(); | 2237 scheduleUpdateWidgetsIfNecessary(); |
| 2196 | 2238 |
| 2197 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator()) | 2239 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator()) |
| 2198 scrollingCoordinator->notifyGeometryChanged(); | 2240 scrollingCoordinator->notifyGeometryChanged(); |
| 2199 | 2241 |
| 2200 scrollToFragmentAnchor(); | 2242 scrollToFragmentAnchor(); |
| 2201 // TODO(skobes): Figure out interactions between scroll anchor, fragment ancho
r, and history restoration. | 2243 // TODO(skobes): Figure out interactions between scroll anchor, fragment |
| 2244 // anchor, and history restoration. |
| 2202 if (shouldPerformScrollAnchoring()) | 2245 if (shouldPerformScrollAnchoring()) |
| 2203 m_scrollAnchor.restore(); | 2246 m_scrollAnchor.restore(); |
| 2204 | 2247 |
| 2205 sendResizeEventIfNeeded(); | 2248 sendResizeEventIfNeeded(); |
| 2206 } | 2249 } |
| 2207 | 2250 |
| 2208 bool FrameView::wasViewportResized() { | 2251 bool FrameView::wasViewportResized() { |
| 2209 ASSERT(m_frame); | 2252 ASSERT(m_frame); |
| 2210 LayoutViewItem layoutViewItem = this->layoutViewItem(); | 2253 LayoutViewItem layoutViewItem = this->layoutViewItem(); |
| 2211 if (layoutViewItem.isNull()) | 2254 if (layoutViewItem.isNull()) |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2465 // If the <body> didn't have a custom style, then the root element might. | 2508 // If the <body> didn't have a custom style, then the root element might. |
| 2466 if (Element* docElement = doc->documentElement()) { | 2509 if (Element* docElement = doc->documentElement()) { |
| 2467 if (LayoutObject* layoutObject = docElement->layoutObject()) | 2510 if (LayoutObject* layoutObject = docElement->layoutObject()) |
| 2468 cornerStyle = layoutObject->getUncachedPseudoStyle( | 2511 cornerStyle = layoutObject->getUncachedPseudoStyle( |
| 2469 PseudoStyleRequest(PseudoIdScrollbarCorner), | 2512 PseudoStyleRequest(PseudoIdScrollbarCorner), |
| 2470 layoutObject->style()); | 2513 layoutObject->style()); |
| 2471 } | 2514 } |
| 2472 } | 2515 } |
| 2473 | 2516 |
| 2474 if (!cornerStyle) { | 2517 if (!cornerStyle) { |
| 2475 // If we have an owning ipage/LocalFrame element, then it can set the cust
om scrollbar also. | 2518 // If we have an owning ipage/LocalFrame element, then it can set the |
| 2519 // custom scrollbar also. |
| 2476 LayoutPartItem layoutItem = m_frame->ownerLayoutItem(); | 2520 LayoutPartItem layoutItem = m_frame->ownerLayoutItem(); |
| 2477 if (!layoutItem.isNull()) | 2521 if (!layoutItem.isNull()) |
| 2478 cornerStyle = layoutItem.getUncachedPseudoStyle( | 2522 cornerStyle = layoutItem.getUncachedPseudoStyle( |
| 2479 PseudoStyleRequest(PseudoIdScrollbarCorner), layoutItem.style()); | 2523 PseudoStyleRequest(PseudoIdScrollbarCorner), layoutItem.style()); |
| 2480 } | 2524 } |
| 2481 } | 2525 } |
| 2482 | 2526 |
| 2483 if (cornerStyle) { | 2527 if (cornerStyle) { |
| 2484 if (!m_scrollCorner) | 2528 if (!m_scrollCorner) |
| 2485 m_scrollCorner = LayoutScrollbarPart::createAnonymous(doc, this); | 2529 m_scrollCorner = LayoutScrollbarPart::createAnonymous(doc, this); |
| 2486 m_scrollCorner->setStyleWithWritingModeOfParent(cornerStyle.release()); | 2530 m_scrollCorner->setStyleWithWritingModeOfParent(cornerStyle.release()); |
| 2487 setScrollCornerNeedsPaintInvalidation(); | 2531 setScrollCornerNeedsPaintInvalidation(); |
| 2488 } else if (m_scrollCorner) { | 2532 } else if (m_scrollCorner) { |
| 2489 m_scrollCorner->destroy(); | 2533 m_scrollCorner->destroy(); |
| 2490 m_scrollCorner = nullptr; | 2534 m_scrollCorner = nullptr; |
| 2491 } | 2535 } |
| 2492 } | 2536 } |
| 2493 | 2537 |
| 2494 Color FrameView::documentBackgroundColor() const { | 2538 Color FrameView::documentBackgroundColor() const { |
| 2495 // The LayoutView's background color is set in Document::inheritHtmlAndBodyEle
mentStyles. | 2539 // The LayoutView's background color is set in |
| 2496 // Blend this with the base background color of the FrameView. This should mat
ch the color | 2540 // Document::inheritHtmlAndBodyElementStyles. Blend this with the base |
| 2497 // drawn by ViewPainter::paintBoxDecorationBackground. | 2541 // background color of the FrameView. This should match the color drawn by |
| 2542 // ViewPainter::paintBoxDecorationBackground. |
| 2498 Color result = baseBackgroundColor(); | 2543 Color result = baseBackgroundColor(); |
| 2499 LayoutItem documentLayoutObject = layoutViewItem(); | 2544 LayoutItem documentLayoutObject = layoutViewItem(); |
| 2500 if (!documentLayoutObject.isNull()) | 2545 if (!documentLayoutObject.isNull()) |
| 2501 result = result.blend( | 2546 result = result.blend( |
| 2502 documentLayoutObject.resolveColor(CSSPropertyBackgroundColor)); | 2547 documentLayoutObject.resolveColor(CSSPropertyBackgroundColor)); |
| 2503 return result; | 2548 return result; |
| 2504 } | 2549 } |
| 2505 | 2550 |
| 2506 FrameView* FrameView::parentFrameView() const { | 2551 FrameView* FrameView::parentFrameView() const { |
| 2507 if (!parent()) | 2552 if (!parent()) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2545 void FrameView::updateLifecycleToLayoutClean() { | 2590 void FrameView::updateLifecycleToLayoutClean() { |
| 2546 frame().localFrameRoot()->view()->updateLifecyclePhasesInternal( | 2591 frame().localFrameRoot()->view()->updateLifecyclePhasesInternal( |
| 2547 DocumentLifecycle::LayoutClean); | 2592 DocumentLifecycle::LayoutClean); |
| 2548 } | 2593 } |
| 2549 | 2594 |
| 2550 void FrameView::scheduleVisualUpdateForPaintInvalidationIfNeeded() { | 2595 void FrameView::scheduleVisualUpdateForPaintInvalidationIfNeeded() { |
| 2551 LocalFrame* localFrameRoot = frame().localFrameRoot(); | 2596 LocalFrame* localFrameRoot = frame().localFrameRoot(); |
| 2552 if (localFrameRoot->view()->m_currentUpdateLifecyclePhasesTargetState < | 2597 if (localFrameRoot->view()->m_currentUpdateLifecyclePhasesTargetState < |
| 2553 DocumentLifecycle::PaintInvalidationClean || | 2598 DocumentLifecycle::PaintInvalidationClean || |
| 2554 lifecycle().state() >= DocumentLifecycle::PrePaintClean) { | 2599 lifecycle().state() >= DocumentLifecycle::PrePaintClean) { |
| 2555 // Schedule visual update to process the paint invalidation in the next cycl
e. | 2600 // Schedule visual update to process the paint invalidation in the next |
| 2601 // cycle. |
| 2556 localFrameRoot->scheduleVisualUpdateUnlessThrottled(); | 2602 localFrameRoot->scheduleVisualUpdateUnlessThrottled(); |
| 2557 } | 2603 } |
| 2558 // Otherwise the paint invalidation will be handled in paint invalidation phas
e of this cycle. | 2604 // Otherwise the paint invalidation will be handled in paint invalidation |
| 2605 // phase of this cycle. |
| 2559 } | 2606 } |
| 2560 | 2607 |
| 2561 void FrameView::notifyResizeObservers() { | 2608 void FrameView::notifyResizeObservers() { |
| 2562 // Controller exists only if ResizeObserver was created. | 2609 // Controller exists only if ResizeObserver was created. |
| 2563 if (!frame().document()->resizeObserverController()) | 2610 if (!frame().document()->resizeObserverController()) |
| 2564 return; | 2611 return; |
| 2565 | 2612 |
| 2566 ResizeObserverController& resizeController = | 2613 ResizeObserverController& resizeController = |
| 2567 m_frame->document()->ensureResizeObserverController(); | 2614 m_frame->document()->ensureResizeObserverController(); |
| 2568 | 2615 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2583 SourceLocation::capture(m_frame->document()), nullptr); | 2630 SourceLocation::capture(m_frame->document()), nullptr); |
| 2584 m_frame->document()->dispatchErrorEvent(error, NotSharableCrossOrigin); | 2631 m_frame->document()->dispatchErrorEvent(error, NotSharableCrossOrigin); |
| 2585 // Ensure notifications will get delivered in next cycle. | 2632 // Ensure notifications will get delivered in next cycle. |
| 2586 if (FrameView* frameView = m_frame->view()) | 2633 if (FrameView* frameView = m_frame->view()) |
| 2587 frameView->scheduleAnimation(); | 2634 frameView->scheduleAnimation(); |
| 2588 } | 2635 } |
| 2589 | 2636 |
| 2590 DCHECK(!layoutView()->needsLayout()); | 2637 DCHECK(!layoutView()->needsLayout()); |
| 2591 } | 2638 } |
| 2592 | 2639 |
| 2593 // TODO(leviw): We don't assert lifecycle information from documents in child Pl
uginViews. | 2640 // TODO(leviw): We don't assert lifecycle information from documents in child |
| 2641 // PluginViews. |
| 2594 void FrameView::updateLifecyclePhasesInternal( | 2642 void FrameView::updateLifecyclePhasesInternal( |
| 2595 DocumentLifecycle::LifecycleState targetState) { | 2643 DocumentLifecycle::LifecycleState targetState) { |
| 2596 if (m_currentUpdateLifecyclePhasesTargetState != | 2644 if (m_currentUpdateLifecyclePhasesTargetState != |
| 2597 DocumentLifecycle::Uninitialized) { | 2645 DocumentLifecycle::Uninitialized) { |
| 2598 NOTREACHED() << "FrameView::updateLifecyclePhasesInternal() reentrance"; | 2646 NOTREACHED() << "FrameView::updateLifecyclePhasesInternal() reentrance"; |
| 2599 return; | 2647 return; |
| 2600 } | 2648 } |
| 2601 | 2649 |
| 2602 // This must be called from the root frame, since it recurses down, not up. | 2650 // This must be called from the root frame, since it recurses down, not up. |
| 2603 // Otherwise the lifecycles of the frames might be out of sync. | 2651 // Otherwise the lifecycles of the frames might be out of sync. |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2733 frameView.lifecycle().advanceTo(DocumentLifecycle::InPaint); | 2781 frameView.lifecycle().advanceTo(DocumentLifecycle::InPaint); |
| 2734 }); | 2782 }); |
| 2735 | 2783 |
| 2736 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 2784 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 2737 if (layoutView()->layer()->needsRepaint()) { | 2785 if (layoutView()->layer()->needsRepaint()) { |
| 2738 GraphicsContext graphicsContext(*m_paintController); | 2786 GraphicsContext graphicsContext(*m_paintController); |
| 2739 paint(graphicsContext, CullRect(LayoutRect::infiniteIntRect())); | 2787 paint(graphicsContext, CullRect(LayoutRect::infiniteIntRect())); |
| 2740 m_paintController->commitNewDisplayItems(LayoutSize()); | 2788 m_paintController->commitNewDisplayItems(LayoutSize()); |
| 2741 } | 2789 } |
| 2742 } else { | 2790 } else { |
| 2743 // A null graphics layer can occur for painting of SVG images that are not p
arented into the main frame tree, | 2791 // A null graphics layer can occur for painting of SVG images that are not |
| 2744 // or when the FrameView is the main frame view of a page overlay. The page
overlay is in the layer tree of | 2792 // parented into the main frame tree, or when the FrameView is the main |
| 2745 // the host page and will be painted during synchronized painting of the hos
t page. | 2793 // frame view of a page overlay. The page overlay is in the layer tree of |
| 2794 // the host page and will be painted during synchronized painting of the |
| 2795 // host page. |
| 2746 if (GraphicsLayer* rootGraphicsLayer = | 2796 if (GraphicsLayer* rootGraphicsLayer = |
| 2747 view.compositor()->rootGraphicsLayer()) { | 2797 view.compositor()->rootGraphicsLayer()) { |
| 2748 synchronizedPaintRecursively(rootGraphicsLayer); | 2798 synchronizedPaintRecursively(rootGraphicsLayer); |
| 2749 } | 2799 } |
| 2750 | 2800 |
| 2751 // TODO(sataya.m):Main frame doesn't create RootFrameViewport in some | 2801 // TODO(sataya.m):Main frame doesn't create RootFrameViewport in some |
| 2752 // webkit_unit_tests (http://crbug.com/644788). | 2802 // webkit_unit_tests (http://crbug.com/644788). |
| 2753 if (m_viewportScrollableArea) { | 2803 if (m_viewportScrollableArea) { |
| 2754 if (GraphicsLayer* layerForHorizontalScrollbar = | 2804 if (GraphicsLayer* layerForHorizontalScrollbar = |
| 2755 m_viewportScrollableArea->layerForHorizontalScrollbar()) { | 2805 m_viewportScrollableArea->layerForHorizontalScrollbar()) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2828 void FrameView::updateStyleAndLayoutIfNeededRecursiveInternal() { | 2878 void FrameView::updateStyleAndLayoutIfNeededRecursiveInternal() { |
| 2829 if (shouldThrottleRendering() || !m_frame->document()->isActive()) | 2879 if (shouldThrottleRendering() || !m_frame->document()->isActive()) |
| 2830 return; | 2880 return; |
| 2831 | 2881 |
| 2832 ScopedFrameBlamer frameBlamer(m_frame); | 2882 ScopedFrameBlamer frameBlamer(m_frame); |
| 2833 TRACE_EVENT0("blink", "FrameView::updateStyleAndLayoutIfNeededRecursive"); | 2883 TRACE_EVENT0("blink", "FrameView::updateStyleAndLayoutIfNeededRecursive"); |
| 2834 | 2884 |
| 2835 // We have to crawl our entire subtree looking for any FrameViews that need | 2885 // We have to crawl our entire subtree looking for any FrameViews that need |
| 2836 // layout and make sure they are up to date. | 2886 // layout and make sure they are up to date. |
| 2837 // Mac actually tests for intersection with the dirty region and tries not to | 2887 // Mac actually tests for intersection with the dirty region and tries not to |
| 2838 // update layout for frames that are outside the dirty region. Not only does
this seem | 2888 // update layout for frames that are outside the dirty region. Not only does |
| 2839 // pointless (since those frames will have set a zero timer to layout anyway),
but | 2889 // this seem pointless (since those frames will have set a zero timer to |
| 2840 // it is also incorrect, since if two frames overlap, the first could be exclu
ded from the dirty | 2890 // layout anyway), but it is also incorrect, since if two frames overlap, the |
| 2841 // region but then become included later by the second frame adding rects to t
he dirty region | 2891 // first could be excluded from the dirty region but then become included |
| 2842 // when it lays out. | 2892 // later by the second frame adding rects to the dirty region when it lays |
| 2893 // out. |
| 2843 | 2894 |
| 2844 m_frame->document()->updateStyleAndLayoutTree(); | 2895 m_frame->document()->updateStyleAndLayoutTree(); |
| 2845 | 2896 |
| 2846 CHECK(!shouldThrottleRendering()); | 2897 CHECK(!shouldThrottleRendering()); |
| 2847 CHECK(m_frame->document()->isActive()); | 2898 CHECK(m_frame->document()->isActive()); |
| 2848 CHECK(!m_nestedLayoutCount); | 2899 CHECK(!m_nestedLayoutCount); |
| 2849 | 2900 |
| 2850 if (needsLayout()) | 2901 if (needsLayout()) |
| 2851 layout(); | 2902 layout(); |
| 2852 | 2903 |
| 2853 checkDoesNotNeedLayout(); | 2904 checkDoesNotNeedLayout(); |
| 2854 | 2905 |
| 2855 // WebView plugins need to update regardless of whether the LayoutEmbeddedObje
ct | 2906 // WebView plugins need to update regardless of whether the |
| 2856 // that owns them needed layout. | 2907 // LayoutEmbeddedObject that owns them needed layout. |
| 2857 // TODO(leviw): This currently runs the entire lifecycle on plugin WebViews. W
e | 2908 // TODO(leviw): This currently runs the entire lifecycle on plugin WebViews. |
| 2858 // should have a way to only run these other Documents to the same lifecycle s
tage | 2909 // We should have a way to only run these other Documents to the same |
| 2859 // as this frame. | 2910 // lifecycle stage as this frame. |
| 2860 const ChildrenWidgetSet* viewChildren = children(); | 2911 const ChildrenWidgetSet* viewChildren = children(); |
| 2861 for (const Member<Widget>& child : *viewChildren) { | 2912 for (const Member<Widget>& child : *viewChildren) { |
| 2862 if ((*child).isPluginContainer()) | 2913 if ((*child).isPluginContainer()) |
| 2863 toPluginView(child.get())->updateAllLifecyclePhases(); | 2914 toPluginView(child.get())->updateAllLifecyclePhases(); |
| 2864 } | 2915 } |
| 2865 checkDoesNotNeedLayout(); | 2916 checkDoesNotNeedLayout(); |
| 2866 | 2917 |
| 2867 // FIXME: Calling layout() shouldn't trigger script execution or have any | 2918 // FIXME: Calling layout() shouldn't trigger script execution or have any |
| 2868 // observable effects on the frame tree but we're not quite there yet. | 2919 // observable effects on the frame tree but we're not quite there yet. |
| 2869 HeapVector<Member<FrameView>> frameViews; | 2920 HeapVector<Member<FrameView>> frameViews; |
| 2870 for (Frame* child = m_frame->tree().firstChild(); child; | 2921 for (Frame* child = m_frame->tree().firstChild(); child; |
| 2871 child = child->tree().nextSibling()) { | 2922 child = child->tree().nextSibling()) { |
| 2872 if (!child->isLocalFrame()) | 2923 if (!child->isLocalFrame()) |
| 2873 continue; | 2924 continue; |
| 2874 if (FrameView* view = toLocalFrame(child)->view()) | 2925 if (FrameView* view = toLocalFrame(child)->view()) |
| 2875 frameViews.append(view); | 2926 frameViews.append(view); |
| 2876 } | 2927 } |
| 2877 | 2928 |
| 2878 for (const auto& frameView : frameViews) | 2929 for (const auto& frameView : frameViews) |
| 2879 frameView->updateStyleAndLayoutIfNeededRecursiveInternal(); | 2930 frameView->updateStyleAndLayoutIfNeededRecursiveInternal(); |
| 2880 | 2931 |
| 2881 checkDoesNotNeedLayout(); | 2932 checkDoesNotNeedLayout(); |
| 2882 | 2933 |
| 2883 // When SVG filters are invalidated using Document::scheduleSVGFilterLayerUpda
teHack() they may trigger an | 2934 // When SVG filters are invalidated using |
| 2884 // extra style recalc. See PaintLayer::filterNeedsPaintInvalidation(). | 2935 // Document::scheduleSVGFilterLayerUpdateHack() they may trigger an extra |
| 2936 // style recalc. See PaintLayer::filterNeedsPaintInvalidation(). |
| 2885 if (m_frame->document()->hasSVGFilterElementsRequiringLayerUpdate()) { | 2937 if (m_frame->document()->hasSVGFilterElementsRequiringLayerUpdate()) { |
| 2886 m_frame->document()->updateStyleAndLayoutTree(); | 2938 m_frame->document()->updateStyleAndLayoutTree(); |
| 2887 | 2939 |
| 2888 if (needsLayout()) | 2940 if (needsLayout()) |
| 2889 layout(); | 2941 layout(); |
| 2890 } | 2942 } |
| 2891 | 2943 |
| 2892 // These asserts ensure that parent frames are clean, when child frames finish
ed updating layout and style. | 2944 // These asserts ensure that parent frames are clean, when child frames |
| 2945 // finished updating layout and style. |
| 2893 checkDoesNotNeedLayout(); | 2946 checkDoesNotNeedLayout(); |
| 2894 ASSERT(!m_frame->document()->hasSVGFilterElementsRequiringLayerUpdate()); | 2947 ASSERT(!m_frame->document()->hasSVGFilterElementsRequiringLayerUpdate()); |
| 2895 #if ENABLE(ASSERT) | 2948 #if ENABLE(ASSERT) |
| 2896 m_frame->document()->layoutView()->assertLaidOut(); | 2949 m_frame->document()->layoutView()->assertLaidOut(); |
| 2897 #endif | 2950 #endif |
| 2898 | 2951 |
| 2899 updateWidgetGeometriesIfNeeded(); | 2952 updateWidgetGeometriesIfNeeded(); |
| 2900 | 2953 |
| 2901 if (lifecycle().state() < DocumentLifecycle::LayoutClean) | 2954 if (lifecycle().state() < DocumentLifecycle::LayoutClean) |
| 2902 lifecycle().advanceTo(DocumentLifecycle::LayoutClean); | 2955 lifecycle().advanceTo(DocumentLifecycle::LayoutClean); |
| 2903 | 2956 |
| 2904 // Ensure that we become visually non-empty eventually. | 2957 // Ensure that we become visually non-empty eventually. |
| 2905 // TODO(esprehn): This should check isRenderingReady() instead. | 2958 // TODO(esprehn): This should check isRenderingReady() instead. |
| 2906 if (frame().document()->hasFinishedParsing() && | 2959 if (frame().document()->hasFinishedParsing() && |
| 2907 frame().loader().stateMachine()->committedFirstRealDocumentLoad()) | 2960 frame().loader().stateMachine()->committedFirstRealDocumentLoad()) |
| 2908 m_isVisuallyNonEmpty = true; | 2961 m_isVisuallyNonEmpty = true; |
| 2909 } | 2962 } |
| 2910 | 2963 |
| 2911 void FrameView::invalidateTreeIfNeededRecursive() { | 2964 void FrameView::invalidateTreeIfNeededRecursive() { |
| 2912 SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Blink.PaintInvalidation.UpdateTime"); | 2965 SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Blink.PaintInvalidation.UpdateTime"); |
| 2913 invalidateTreeIfNeededRecursiveInternal(); | 2966 invalidateTreeIfNeededRecursiveInternal(); |
| 2914 } | 2967 } |
| 2915 | 2968 |
| 2916 void FrameView::invalidateTreeIfNeededRecursiveInternal() { | 2969 void FrameView::invalidateTreeIfNeededRecursiveInternal() { |
| 2917 DCHECK(!RuntimeEnabledFeatures::slimmingPaintV2Enabled()); | 2970 DCHECK(!RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| 2918 CHECK(layoutView()); | 2971 CHECK(layoutView()); |
| 2919 | 2972 |
| 2920 // We need to stop recursing here since a child frame view might not be thrott
led | 2973 // We need to stop recursing here since a child frame view might not be |
| 2921 // even though we are (e.g., it didn't compute its visibility yet). | 2974 // throttled even though we are (e.g., it didn't compute its visibility yet). |
| 2922 if (shouldThrottleRendering()) | 2975 if (shouldThrottleRendering()) |
| 2923 return; | 2976 return; |
| 2924 TRACE_EVENT1("blink", "FrameView::invalidateTreeIfNeededRecursive", "root", | 2977 TRACE_EVENT1("blink", "FrameView::invalidateTreeIfNeededRecursive", "root", |
| 2925 layoutView()->debugName().ascii()); | 2978 layoutView()->debugName().ascii()); |
| 2926 | 2979 |
| 2927 Vector<const LayoutObject*> pendingDelayedPaintInvalidations; | 2980 Vector<const LayoutObject*> pendingDelayedPaintInvalidations; |
| 2928 PaintInvalidationState rootPaintInvalidationState( | 2981 PaintInvalidationState rootPaintInvalidationState( |
| 2929 *layoutView(), pendingDelayedPaintInvalidations); | 2982 *layoutView(), pendingDelayedPaintInvalidations); |
| 2930 | 2983 |
| 2931 if (lifecycle().state() < DocumentLifecycle::PaintInvalidationClean) | 2984 if (lifecycle().state() < DocumentLifecycle::PaintInvalidationClean) |
| 2932 invalidateTreeIfNeeded(rootPaintInvalidationState); | 2985 invalidateTreeIfNeeded(rootPaintInvalidationState); |
| 2933 | 2986 |
| 2934 // Some frames may be not reached during the above invalidateTreeIfNeeded beca
use | 2987 // Some frames may be not reached during the above invalidateTreeIfNeeded |
| 2988 // because |
| 2935 // - the frame is a detached frame; or | 2989 // - the frame is a detached frame; or |
| 2936 // - it didn't need paint invalidation. | 2990 // - it didn't need paint invalidation. |
| 2937 // We need to call invalidateTreeIfNeededRecursive() for such frames to finish
required | 2991 // We need to call invalidateTreeIfNeededRecursive() for such frames to finish |
| 2938 // paint invalidation and advance their life cycle state. | 2992 // required paint invalidation and advance their life cycle state. |
| 2939 for (Frame* child = m_frame->tree().firstChild(); child; | 2993 for (Frame* child = m_frame->tree().firstChild(); child; |
| 2940 child = child->tree().nextSibling()) { | 2994 child = child->tree().nextSibling()) { |
| 2941 if (child->isLocalFrame()) { | 2995 if (child->isLocalFrame()) { |
| 2942 FrameView& childFrameView = *toLocalFrame(child)->view(); | 2996 FrameView& childFrameView = *toLocalFrame(child)->view(); |
| 2943 // The children frames can be in any state, including stopping. | 2997 // The children frames can be in any state, including stopping. |
| 2944 // Thus we have to check that it makes sense to do paint | 2998 // Thus we have to check that it makes sense to do paint |
| 2945 // invalidation onto them here. | 2999 // invalidation onto them here. |
| 2946 if (!childFrameView.layoutView()) | 3000 if (!childFrameView.layoutView()) |
| 2947 continue; | 3001 continue; |
| 2948 childFrameView.invalidateTreeIfNeededRecursiveInternal(); | 3002 childFrameView.invalidateTreeIfNeededRecursiveInternal(); |
| 2949 } | 3003 } |
| 2950 } | 3004 } |
| 2951 | 3005 |
| 2952 // Process objects needing paint invalidation on the next frame. See the defin
ition of PaintInvalidationDelayedFull for more details. | 3006 // Process objects needing paint invalidation on the next frame. See the |
| 3007 // definition of PaintInvalidationDelayedFull for more details. |
| 2953 for (auto& target : pendingDelayedPaintInvalidations) | 3008 for (auto& target : pendingDelayedPaintInvalidations) |
| 2954 target->getMutableForPainting().setShouldDoFullPaintInvalidation( | 3009 target->getMutableForPainting().setShouldDoFullPaintInvalidation( |
| 2955 PaintInvalidationDelayedFull); | 3010 PaintInvalidationDelayedFull); |
| 2956 } | 3011 } |
| 2957 | 3012 |
| 2958 void FrameView::enableAutoSizeMode(const IntSize& minSize, | 3013 void FrameView::enableAutoSizeMode(const IntSize& minSize, |
| 2959 const IntSize& maxSize) { | 3014 const IntSize& maxSize) { |
| 2960 if (!m_autoSizeInfo) | 3015 if (!m_autoSizeInfo) |
| 2961 m_autoSizeInfo = FrameViewAutoSizeInfo::create(this); | 3016 m_autoSizeInfo = FrameViewAutoSizeInfo::create(this); |
| 2962 | 3017 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2977 // Since autosize mode forces the scrollbar mode, change them to being auto. | 3032 // Since autosize mode forces the scrollbar mode, change them to being auto. |
| 2978 setVerticalScrollbarLock(false); | 3033 setVerticalScrollbarLock(false); |
| 2979 setHorizontalScrollbarLock(false); | 3034 setHorizontalScrollbarLock(false); |
| 2980 setScrollbarModes(ScrollbarAuto, ScrollbarAuto); | 3035 setScrollbarModes(ScrollbarAuto, ScrollbarAuto); |
| 2981 m_autoSizeInfo.clear(); | 3036 m_autoSizeInfo.clear(); |
| 2982 } | 3037 } |
| 2983 | 3038 |
| 2984 void FrameView::forceLayoutForPagination(const FloatSize& pageSize, | 3039 void FrameView::forceLayoutForPagination(const FloatSize& pageSize, |
| 2985 const FloatSize& originalPageSize, | 3040 const FloatSize& originalPageSize, |
| 2986 float maximumShrinkFactor) { | 3041 float maximumShrinkFactor) { |
| 2987 // Dumping externalRepresentation(m_frame->layoutObject()).ascii() is a good t
rick to see | 3042 // Dumping externalRepresentation(m_frame->layoutObject()).ascii() is a good |
| 2988 // the state of things before and after the layout | 3043 // trick to see the state of things before and after the layout |
| 2989 if (LayoutView* layoutView = this->layoutView()) { | 3044 if (LayoutView* layoutView = this->layoutView()) { |
| 2990 float pageLogicalWidth = layoutView->style()->isHorizontalWritingMode() | 3045 float pageLogicalWidth = layoutView->style()->isHorizontalWritingMode() |
| 2991 ? pageSize.width() | 3046 ? pageSize.width() |
| 2992 : pageSize.height(); | 3047 : pageSize.height(); |
| 2993 float pageLogicalHeight = layoutView->style()->isHorizontalWritingMode() | 3048 float pageLogicalHeight = layoutView->style()->isHorizontalWritingMode() |
| 2994 ? pageSize.height() | 3049 ? pageSize.height() |
| 2995 : pageSize.width(); | 3050 : pageSize.width(); |
| 2996 | 3051 |
| 2997 LayoutUnit flooredPageLogicalWidth = | 3052 LayoutUnit flooredPageLogicalWidth = |
| 2998 static_cast<LayoutUnit>(pageLogicalWidth); | 3053 static_cast<LayoutUnit>(pageLogicalWidth); |
| 2999 LayoutUnit flooredPageLogicalHeight = | 3054 LayoutUnit flooredPageLogicalHeight = |
| 3000 static_cast<LayoutUnit>(pageLogicalHeight); | 3055 static_cast<LayoutUnit>(pageLogicalHeight); |
| 3001 layoutView->setLogicalWidth(flooredPageLogicalWidth); | 3056 layoutView->setLogicalWidth(flooredPageLogicalWidth); |
| 3002 layoutView->setPageLogicalHeight(flooredPageLogicalHeight); | 3057 layoutView->setPageLogicalHeight(flooredPageLogicalHeight); |
| 3003 layoutView->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( | 3058 layoutView->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( |
| 3004 LayoutInvalidationReason::PrintingChanged); | 3059 LayoutInvalidationReason::PrintingChanged); |
| 3005 layout(); | 3060 layout(); |
| 3006 | 3061 |
| 3007 // If we don't fit in the given page width, we'll lay out again. If we don't
fit in the | 3062 // If we don't fit in the given page width, we'll lay out again. If we don't |
| 3008 // page width when shrunk, we will lay out at maximum shrink and clip extra
content. | 3063 // fit in the page width when shrunk, we will lay out at maximum shrink and |
| 3009 // FIXME: We are assuming a shrink-to-fit printing implementation. A croppi
ng | 3064 // clip extra content. |
| 3010 // implementation should not do this! | 3065 // FIXME: We are assuming a shrink-to-fit printing implementation. A |
| 3066 // cropping implementation should not do this! |
| 3011 bool horizontalWritingMode = layoutView->style()->isHorizontalWritingMode(); | 3067 bool horizontalWritingMode = layoutView->style()->isHorizontalWritingMode(); |
| 3012 const LayoutRect& documentRect = LayoutRect(layoutView->documentRect()); | 3068 const LayoutRect& documentRect = LayoutRect(layoutView->documentRect()); |
| 3013 LayoutUnit docLogicalWidth = | 3069 LayoutUnit docLogicalWidth = |
| 3014 horizontalWritingMode ? documentRect.width() : documentRect.height(); | 3070 horizontalWritingMode ? documentRect.width() : documentRect.height(); |
| 3015 if (docLogicalWidth > pageLogicalWidth) { | 3071 if (docLogicalWidth > pageLogicalWidth) { |
| 3016 FloatSize expectedPageSize( | 3072 FloatSize expectedPageSize( |
| 3017 std::min<float>(documentRect.width().toFloat(), | 3073 std::min<float>(documentRect.width().toFloat(), |
| 3018 pageSize.width() * maximumShrinkFactor), | 3074 pageSize.width() * maximumShrinkFactor), |
| 3019 std::min<float>(documentRect.height().toFloat(), | 3075 std::min<float>(documentRect.height().toFloat(), |
| 3020 pageSize.height() * maximumShrinkFactor)); | 3076 pageSize.height() * maximumShrinkFactor)); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3075 return rect; | 3131 return rect; |
| 3076 } | 3132 } |
| 3077 | 3133 |
| 3078 IntRect FrameView::convertToLayoutObject(const LayoutObject& layoutObject, | 3134 IntRect FrameView::convertToLayoutObject(const LayoutObject& layoutObject, |
| 3079 const IntRect& frameRect) const { | 3135 const IntRect& frameRect) const { |
| 3080 IntRect rectInContent = frameToContents(frameRect); | 3136 IntRect rectInContent = frameToContents(frameRect); |
| 3081 | 3137 |
| 3082 // Convert from FrameView coords into page ("absolute") coordinates. | 3138 // Convert from FrameView coords into page ("absolute") coordinates. |
| 3083 rectInContent.moveBy(scrollPosition()); | 3139 rectInContent.moveBy(scrollPosition()); |
| 3084 | 3140 |
| 3085 // FIXME: we don't have a way to map an absolute rect down to a local quad, so
just | 3141 // FIXME: we don't have a way to map an absolute rect down to a local quad, so |
| 3086 // move the rect for now. | 3142 // just move the rect for now. |
| 3087 rectInContent.setLocation(roundedIntPoint( | 3143 rectInContent.setLocation(roundedIntPoint( |
| 3088 layoutObject.absoluteToLocal(rectInContent.location(), UseTransforms))); | 3144 layoutObject.absoluteToLocal(rectInContent.location(), UseTransforms))); |
| 3089 return rectInContent; | 3145 return rectInContent; |
| 3090 } | 3146 } |
| 3091 | 3147 |
| 3092 IntPoint FrameView::convertFromLayoutObject( | 3148 IntPoint FrameView::convertFromLayoutObject( |
| 3093 const LayoutObject& layoutObject, | 3149 const LayoutObject& layoutObject, |
| 3094 const IntPoint& layoutObjectPoint) const { | 3150 const IntPoint& layoutObjectPoint) const { |
| 3095 IntPoint point = roundedIntPoint( | 3151 IntPoint point = roundedIntPoint( |
| 3096 layoutObject.localToAbsolute(layoutObjectPoint, UseTransforms)); | 3152 layoutObject.localToAbsolute(layoutObjectPoint, UseTransforms)); |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3372 ScrollbarOrientation orientation) { | 3428 ScrollbarOrientation orientation) { |
| 3373 ScrollableArea::didAddScrollbar(scrollbar, orientation); | 3429 ScrollableArea::didAddScrollbar(scrollbar, orientation); |
| 3374 } | 3430 } |
| 3375 | 3431 |
| 3376 void FrameView::setTopControlsViewportAdjustment(float adjustment) { | 3432 void FrameView::setTopControlsViewportAdjustment(float adjustment) { |
| 3377 m_topControlsViewportAdjustment = adjustment; | 3433 m_topControlsViewportAdjustment = adjustment; |
| 3378 } | 3434 } |
| 3379 | 3435 |
| 3380 IntPoint FrameView::maximumScrollPosition() const { | 3436 IntPoint FrameView::maximumScrollPosition() const { |
| 3381 // Make the same calculation as in CC's LayerImpl::MaxScrollOffset() | 3437 // Make the same calculation as in CC's LayerImpl::MaxScrollOffset() |
| 3382 // FIXME: We probably shouldn't be storing the bounds in a float. crbug.com/42
2331. | 3438 // FIXME: We probably shouldn't be storing the bounds in a float. |
| 3439 // crbug.com/422331. |
| 3383 IntSize visibleSize = | 3440 IntSize visibleSize = |
| 3384 visibleContentSize(ExcludeScrollbars) + topControlsSize(); | 3441 visibleContentSize(ExcludeScrollbars) + topControlsSize(); |
| 3385 IntSize contentBounds = contentsSize(); | 3442 IntSize contentBounds = contentsSize(); |
| 3386 IntPoint maximumPosition = -scrollOrigin() + (contentBounds - visibleSize); | 3443 IntPoint maximumPosition = -scrollOrigin() + (contentBounds - visibleSize); |
| 3387 return maximumPosition.expandedTo(minimumScrollPosition()); | 3444 return maximumPosition.expandedTo(minimumScrollPosition()); |
| 3388 } | 3445 } |
| 3389 | 3446 |
| 3390 void FrameView::addChild(Widget* child) { | 3447 void FrameView::addChild(Widget* child) { |
| 3391 ASSERT(child != this && !child->parent()); | 3448 ASSERT(child != this && !child->parent()); |
| 3392 child->setParent(this); | 3449 child->setParent(this); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3444 | 3501 |
| 3445 setScrollCornerNeedsPaintInvalidation(); | 3502 setScrollCornerNeedsPaintInvalidation(); |
| 3446 } | 3503 } |
| 3447 | 3504 |
| 3448 void FrameView::setScrollbarModes(ScrollbarMode horizontalMode, | 3505 void FrameView::setScrollbarModes(ScrollbarMode horizontalMode, |
| 3449 ScrollbarMode verticalMode, | 3506 ScrollbarMode verticalMode, |
| 3450 bool horizontalLock, | 3507 bool horizontalLock, |
| 3451 bool verticalLock) { | 3508 bool verticalLock) { |
| 3452 bool needsUpdate = false; | 3509 bool needsUpdate = false; |
| 3453 | 3510 |
| 3454 // If the page's overflow setting has disabled scrolling, do not allow anythin
g to override that setting. | 3511 // If the page's overflow setting has disabled scrolling, do not allow |
| 3455 // http://crbug.com/426447 | 3512 // anything to override that setting, http://crbug.com/426447 |
| 3456 LayoutObject* viewport = viewportLayoutObject(); | 3513 LayoutObject* viewport = viewportLayoutObject(); |
| 3457 if (viewport && !shouldIgnoreOverflowHidden()) { | 3514 if (viewport && !shouldIgnoreOverflowHidden()) { |
| 3458 if (viewport->style()->overflowX() == OverflowHidden) | 3515 if (viewport->style()->overflowX() == OverflowHidden) |
| 3459 horizontalMode = ScrollbarAlwaysOff; | 3516 horizontalMode = ScrollbarAlwaysOff; |
| 3460 if (viewport->style()->overflowY() == OverflowHidden) | 3517 if (viewport->style()->overflowY() == OverflowHidden) |
| 3461 verticalMode = ScrollbarAlwaysOff; | 3518 verticalMode = ScrollbarAlwaysOff; |
| 3462 } | 3519 } |
| 3463 | 3520 |
| 3464 if (horizontalMode != horizontalScrollbarMode() && | 3521 if (horizontalMode != horizontalScrollbarMode() && |
| 3465 !m_horizontalScrollbarLock) { | 3522 !m_horizontalScrollbarLock) { |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3713 setScrollbarNeedsPaintInvalidation(VerticalScrollbar); | 3770 setScrollbarNeedsPaintInvalidation(VerticalScrollbar); |
| 3714 | 3771 |
| 3715 m_verticalScrollbar->setEnabled(contentsHeight() > clientHeight); | 3772 m_verticalScrollbar->setEnabled(contentsHeight() > clientHeight); |
| 3716 m_verticalScrollbar->setProportion(clientHeight, contentsHeight()); | 3773 m_verticalScrollbar->setProportion(clientHeight, contentsHeight()); |
| 3717 m_verticalScrollbar->offsetDidChange(); | 3774 m_verticalScrollbar->offsetDidChange(); |
| 3718 } | 3775 } |
| 3719 } | 3776 } |
| 3720 | 3777 |
| 3721 IntRect FrameView::adjustScrollbarRectForResizer(const IntRect& rect, | 3778 IntRect FrameView::adjustScrollbarRectForResizer(const IntRect& rect, |
| 3722 Scrollbar& scrollbar) { | 3779 Scrollbar& scrollbar) { |
| 3723 // Get our window resizer rect and see if we overlap. Adjust to avoid the over
lap | 3780 // Get our window resizer rect and see if we overlap. Adjust to avoid the |
| 3724 // if necessary. | 3781 // overlap if necessary. |
| 3725 IntRect adjustedRect(rect); | 3782 IntRect adjustedRect(rect); |
| 3726 bool overlapsResizer = false; | 3783 bool overlapsResizer = false; |
| 3727 if (!rect.isEmpty() && !windowResizerRect().isEmpty()) { | 3784 if (!rect.isEmpty() && !windowResizerRect().isEmpty()) { |
| 3728 IntRect resizerRect = convertFromRootFrame(windowResizerRect()); | 3785 IntRect resizerRect = convertFromRootFrame(windowResizerRect()); |
| 3729 if (rect.intersects(resizerRect)) { | 3786 if (rect.intersects(resizerRect)) { |
| 3730 if (scrollbar.orientation() == HorizontalScrollbar) { | 3787 if (scrollbar.orientation() == HorizontalScrollbar) { |
| 3731 int overlap = rect.maxX() - resizerRect.x(); | 3788 int overlap = rect.maxX() - resizerRect.x(); |
| 3732 if (overlap > 0 && resizerRect.maxX() >= rect.maxX()) { | 3789 if (overlap > 0 && resizerRect.maxX() >= rect.maxX()) { |
| 3733 adjustedRect.setWidth(rect.width() - overlap); | 3790 adjustedRect.setWidth(rect.width() - overlap); |
| 3734 overlapsResizer = true; | 3791 overlapsResizer = true; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3746 scrollbar.setOverlapsResizer(overlapsResizer); | 3803 scrollbar.setOverlapsResizer(overlapsResizer); |
| 3747 adjustScrollbarsAvoidingResizerCount(overlapsResizer ? 1 : -1); | 3804 adjustScrollbarsAvoidingResizerCount(overlapsResizer ? 1 : -1); |
| 3748 } | 3805 } |
| 3749 return adjustedRect; | 3806 return adjustedRect; |
| 3750 } | 3807 } |
| 3751 | 3808 |
| 3752 bool FrameView::adjustScrollbarExistence( | 3809 bool FrameView::adjustScrollbarExistence( |
| 3753 ComputeScrollbarExistenceOption option) { | 3810 ComputeScrollbarExistenceOption option) { |
| 3754 ASSERT(m_inUpdateScrollbars); | 3811 ASSERT(m_inUpdateScrollbars); |
| 3755 | 3812 |
| 3756 // If we came in here with the view already needing a layout, then go ahead an
d do that | 3813 // If we came in here with the view already needing a layout, then go ahead |
| 3757 // first. (This will be the common case, e.g., when the page changes due to w
indow resizing for example). | 3814 // and do that first. (This will be the common case, e.g., when the page |
| 3758 // This layout will not re-enter updateScrollbars and does not count towards o
ur max layout pass total. | 3815 // changes due to window resizing for example). This layout will not re-enter |
| 3816 // updateScrollbars and does not count towards our max layout pass total. |
| 3759 if (!m_scrollbarsSuppressed) | 3817 if (!m_scrollbarsSuppressed) |
| 3760 scrollbarExistenceDidChange(); | 3818 scrollbarExistenceDidChange(); |
| 3761 | 3819 |
| 3762 bool hasHorizontalScrollbar = m_horizontalScrollbar; | 3820 bool hasHorizontalScrollbar = m_horizontalScrollbar; |
| 3763 bool hasVerticalScrollbar = m_verticalScrollbar; | 3821 bool hasVerticalScrollbar = m_verticalScrollbar; |
| 3764 | 3822 |
| 3765 bool newHasHorizontalScrollbar = false; | 3823 bool newHasHorizontalScrollbar = false; |
| 3766 bool newHasVerticalScrollbar = false; | 3824 bool newHasVerticalScrollbar = false; |
| 3767 computeScrollbarExistence(newHasHorizontalScrollbar, newHasVerticalScrollbar, | 3825 computeScrollbarExistence(newHasHorizontalScrollbar, newHasVerticalScrollbar, |
| 3768 contentsSize(), option); | 3826 contentsSize(), option); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3842 updateScrollbarsPass < maxUpdateScrollbarsPass; updateScrollbarsPass++) { | 3900 updateScrollbarsPass < maxUpdateScrollbarsPass; updateScrollbarsPass++) { |
| 3843 if (!adjustScrollbarExistence(updateScrollbarsPass ? Incremental | 3901 if (!adjustScrollbarExistence(updateScrollbarsPass ? Incremental |
| 3844 : FirstPass)) | 3902 : FirstPass)) |
| 3845 break; | 3903 break; |
| 3846 scrollbarExistenceChanged = true; | 3904 scrollbarExistenceChanged = true; |
| 3847 } | 3905 } |
| 3848 | 3906 |
| 3849 updateScrollbarGeometry(); | 3907 updateScrollbarGeometry(); |
| 3850 | 3908 |
| 3851 if (scrollbarExistenceChanged) { | 3909 if (scrollbarExistenceChanged) { |
| 3852 // FIXME: Is frameRectsChanged really necessary here? Have any frame rects c
hanged? | 3910 // FIXME: Is frameRectsChanged really necessary here? Have any frame rects |
| 3911 // changed? |
| 3853 frameRectsChanged(); | 3912 frameRectsChanged(); |
| 3854 positionScrollbarLayers(); | 3913 positionScrollbarLayers(); |
| 3855 updateScrollCorner(); | 3914 updateScrollCorner(); |
| 3856 } | 3915 } |
| 3857 | 3916 |
| 3858 adjustScrollPositionFromUpdateScrollbars(); | 3917 adjustScrollPositionFromUpdateScrollbars(); |
| 3859 } | 3918 } |
| 3860 | 3919 |
| 3861 void FrameView::adjustScrollPositionFromUpdateScrollbars() { | 3920 void FrameView::adjustScrollPositionFromUpdateScrollbars() { |
| 3862 DoublePoint clamped = clampScrollPosition(scrollPositionDouble()); | 3921 DoublePoint clamped = clampScrollPosition(scrollPositionDouble()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3885 void FrameView::scrollContents(const IntSize& scrollDelta) { | 3944 void FrameView::scrollContents(const IntSize& scrollDelta) { |
| 3886 HostWindow* window = getHostWindow(); | 3945 HostWindow* window = getHostWindow(); |
| 3887 if (!window) | 3946 if (!window) |
| 3888 return; | 3947 return; |
| 3889 | 3948 |
| 3890 TRACE_EVENT0("blink", "FrameView::scrollContents"); | 3949 TRACE_EVENT0("blink", "FrameView::scrollContents"); |
| 3891 | 3950 |
| 3892 if (!scrollContentsFastPath(-scrollDelta)) | 3951 if (!scrollContentsFastPath(-scrollDelta)) |
| 3893 scrollContentsSlowPath(); | 3952 scrollContentsSlowPath(); |
| 3894 | 3953 |
| 3895 // This call will move children with native widgets (plugins) and invalidate t
hem as well. | 3954 // This call will move children with native widgets (plugins) and invalidate |
| 3955 // them as well. |
| 3896 frameRectsChanged(); | 3956 frameRectsChanged(); |
| 3897 } | 3957 } |
| 3898 | 3958 |
| 3899 IntPoint FrameView::contentsToFrame(const IntPoint& pointInContentSpace) const { | 3959 IntPoint FrameView::contentsToFrame(const IntPoint& pointInContentSpace) const { |
| 3900 return pointInContentSpace - scrollOffset(); | 3960 return pointInContentSpace - scrollOffset(); |
| 3901 } | 3961 } |
| 3902 | 3962 |
| 3903 IntRect FrameView::contentsToFrame(const IntRect& rectInContentSpace) const { | 3963 IntRect FrameView::contentsToFrame(const IntRect& rectInContentSpace) const { |
| 3904 return IntRect(contentsToFrame(rectInContentSpace.location()), | 3964 return IntRect(contentsToFrame(rectInContentSpace.location()), |
| 3905 rectInContentSpace.size()); | 3965 rectInContentSpace.size()); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3999 return !m_scrollbarsAvoidingResizer; | 4059 return !m_scrollbarsAvoidingResizer; |
| 4000 } | 4060 } |
| 4001 | 4061 |
| 4002 void FrameView::adjustScrollbarsAvoidingResizerCount(int overlapDelta) { | 4062 void FrameView::adjustScrollbarsAvoidingResizerCount(int overlapDelta) { |
| 4003 int oldCount = m_scrollbarsAvoidingResizer; | 4063 int oldCount = m_scrollbarsAvoidingResizer; |
| 4004 m_scrollbarsAvoidingResizer += overlapDelta; | 4064 m_scrollbarsAvoidingResizer += overlapDelta; |
| 4005 if (parent()) { | 4065 if (parent()) { |
| 4006 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(overlapDelta); | 4066 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(overlapDelta); |
| 4007 } else if (!scrollbarsSuppressed()) { | 4067 } else if (!scrollbarsSuppressed()) { |
| 4008 // If we went from n to 0 or from 0 to n and we're the outermost view, | 4068 // If we went from n to 0 or from 0 to n and we're the outermost view, |
| 4009 // we need to invalidate the windowResizerRect(), since it will now need to
paint | 4069 // we need to invalidate the windowResizerRect(), since it will now need to |
| 4010 // differently. | 4070 // paint differently. |
| 4011 if ((oldCount > 0 && m_scrollbarsAvoidingResizer == 0) || | 4071 if ((oldCount > 0 && m_scrollbarsAvoidingResizer == 0) || |
| 4012 (oldCount == 0 && m_scrollbarsAvoidingResizer > 0)) | 4072 (oldCount == 0 && m_scrollbarsAvoidingResizer > 0)) |
| 4013 invalidateRect(windowResizerRect()); | 4073 invalidateRect(windowResizerRect()); |
| 4014 } | 4074 } |
| 4015 } | 4075 } |
| 4016 | 4076 |
| 4017 Scrollbar* FrameView::scrollbarAtFramePoint(const IntPoint& pointInFrame) { | 4077 Scrollbar* FrameView::scrollbarAtFramePoint(const IntPoint& pointInFrame) { |
| 4018 if (m_horizontalScrollbar && | 4078 if (m_horizontalScrollbar && |
| 4019 m_horizontalScrollbar->shouldParticipateInHitTesting() && | 4079 m_horizontalScrollbar->shouldParticipateInHitTesting() && |
| 4020 m_horizontalScrollbar->frameRect().contains(pointInFrame)) | 4080 m_horizontalScrollbar->frameRect().contains(pointInFrame)) |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4093 LayoutRect FrameView::scrollIntoView(const LayoutRect& rectInContent, | 4153 LayoutRect FrameView::scrollIntoView(const LayoutRect& rectInContent, |
| 4094 const ScrollAlignment& alignX, | 4154 const ScrollAlignment& alignX, |
| 4095 const ScrollAlignment& alignY, | 4155 const ScrollAlignment& alignY, |
| 4096 ScrollType scrollType) { | 4156 ScrollType scrollType) { |
| 4097 LayoutRect viewRect(visibleContentRect()); | 4157 LayoutRect viewRect(visibleContentRect()); |
| 4098 LayoutRect exposeRect = | 4158 LayoutRect exposeRect = |
| 4099 ScrollAlignment::getRectToExpose(viewRect, rectInContent, alignX, alignY); | 4159 ScrollAlignment::getRectToExpose(viewRect, rectInContent, alignX, alignY); |
| 4100 if (exposeRect != viewRect) | 4160 if (exposeRect != viewRect) |
| 4101 setScrollPosition(DoublePoint(exposeRect.x(), exposeRect.y()), scrollType); | 4161 setScrollPosition(DoublePoint(exposeRect.x(), exposeRect.y()), scrollType); |
| 4102 | 4162 |
| 4103 // Scrolling the FrameView cannot change the input rect's location relative to
the document. | 4163 // Scrolling the FrameView cannot change the input rect's location relative to |
| 4164 // the document. |
| 4104 return rectInContent; | 4165 return rectInContent; |
| 4105 } | 4166 } |
| 4106 | 4167 |
| 4107 IntRect FrameView::scrollCornerRect() const { | 4168 IntRect FrameView::scrollCornerRect() const { |
| 4108 IntRect cornerRect; | 4169 IntRect cornerRect; |
| 4109 | 4170 |
| 4110 if (hasOverlayScrollbars()) | 4171 if (hasOverlayScrollbars()) |
| 4111 return cornerRect; | 4172 return cornerRect; |
| 4112 | 4173 |
| 4113 if (m_horizontalScrollbar && width() - m_horizontalScrollbar->width() > 0) { | 4174 if (m_horizontalScrollbar && width() - m_horizontalScrollbar->width() > 0) { |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4239 CompositingUpdateType updateType) { | 4300 CompositingUpdateType updateType) { |
| 4240 if (PaintLayerCompositor* compositor = | 4301 if (PaintLayerCompositor* compositor = |
| 4241 !layoutViewItem.isNull() ? layoutViewItem.compositor() : nullptr) | 4302 !layoutViewItem.isNull() ? layoutViewItem.compositor() : nullptr) |
| 4242 compositor->setNeedsCompositingUpdate(updateType); | 4303 compositor->setNeedsCompositingUpdate(updateType); |
| 4243 } | 4304 } |
| 4244 | 4305 |
| 4245 void FrameView::setParentVisible(bool visible) { | 4306 void FrameView::setParentVisible(bool visible) { |
| 4246 if (isParentVisible() == visible) | 4307 if (isParentVisible() == visible) |
| 4247 return; | 4308 return; |
| 4248 | 4309 |
| 4249 // As parent visibility changes, we may need to recomposite this frame view an
d potentially child frame views. | 4310 // As parent visibility changes, we may need to recomposite this frame view |
| 4311 // and potentially child frame views. |
| 4250 setNeedsCompositingUpdate(layoutViewItem(), CompositingUpdateRebuildTree); | 4312 setNeedsCompositingUpdate(layoutViewItem(), CompositingUpdateRebuildTree); |
| 4251 | 4313 |
| 4252 Widget::setParentVisible(visible); | 4314 Widget::setParentVisible(visible); |
| 4253 | 4315 |
| 4254 if (!isSelfVisible()) | 4316 if (!isSelfVisible()) |
| 4255 return; | 4317 return; |
| 4256 | 4318 |
| 4257 for (const auto& child : m_children) | 4319 for (const auto& child : m_children) |
| 4258 child->setParentVisible(visible); | 4320 child->setParentVisible(visible); |
| 4259 } | 4321 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4359 | 4421 |
| 4360 // Transform our bounds into the root frame's content coordinate space, | 4422 // Transform our bounds into the root frame's content coordinate space, |
| 4361 // making sure we have valid layout data in our parent document. If our | 4423 // making sure we have valid layout data in our parent document. If our |
| 4362 // parent is throttled, we'll use possible stale layout information and | 4424 // parent is throttled, we'll use possible stale layout information and |
| 4363 // rely on the fact that another lifecycle update will be scheduled once | 4425 // rely on the fact that another lifecycle update will be scheduled once |
| 4364 // our parent becomes unthrottled. | 4426 // our parent becomes unthrottled. |
| 4365 ASSERT(parent->lifecycle().state() >= DocumentLifecycle::LayoutClean || | 4427 ASSERT(parent->lifecycle().state() >= DocumentLifecycle::LayoutClean || |
| 4366 parent->shouldThrottleRendering()); | 4428 parent->shouldThrottleRendering()); |
| 4367 m_viewportIntersection = parent->contentsToRootFrame(frameRect()); | 4429 m_viewportIntersection = parent->contentsToRootFrame(frameRect()); |
| 4368 | 4430 |
| 4369 // TODO(skyostil): Expand the viewport to make it less likely to see stale con
tent while scrolling. | 4431 // TODO(skyostil): Expand the viewport to make it less likely to see stale |
| 4432 // content while scrolling. |
| 4370 IntRect viewport = parent->m_viewportIntersection; | 4433 IntRect viewport = parent->m_viewportIntersection; |
| 4371 m_viewportIntersection.intersect(viewport); | 4434 m_viewportIntersection.intersect(viewport); |
| 4372 } | 4435 } |
| 4373 | 4436 |
| 4374 void FrameView::updateViewportIntersectionsForSubtree( | 4437 void FrameView::updateViewportIntersectionsForSubtree( |
| 4375 DocumentLifecycle::LifecycleState targetState) { | 4438 DocumentLifecycle::LifecycleState targetState) { |
| 4376 bool hadValidIntersection = m_viewportIntersectionValid; | 4439 bool hadValidIntersection = m_viewportIntersectionValid; |
| 4377 bool hadEmptyIntersection = m_viewportIntersection.isEmpty(); | 4440 bool hadEmptyIntersection = m_viewportIntersection.isEmpty(); |
| 4378 updateViewportIntersectionIfNeeded(); | 4441 updateViewportIntersectionIfNeeded(); |
| 4379 | 4442 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4463 // If this FrameView became throttled, we must make sure all of its | 4526 // If this FrameView became throttled, we must make sure all of its |
| 4464 // children become throttled at the same time. Otherwise we might | 4527 // children become throttled at the same time. Otherwise we might |
| 4465 // attempt to paint one of the children with an out-of-date layout | 4528 // attempt to paint one of the children with an out-of-date layout |
| 4466 // before |notifyRenderThrottlingObservers| has made it throttled. | 4529 // before |notifyRenderThrottlingObservers| has made it throttled. |
| 4467 forAllNonThrottledFrameViews([](FrameView& frameView) { | 4530 forAllNonThrottledFrameViews([](FrameView& frameView) { |
| 4468 frameView.m_subtreeThrottled = true; | 4531 frameView.m_subtreeThrottled = true; |
| 4469 DCHECK(frameView.canThrottleRendering()); | 4532 DCHECK(frameView.canThrottleRendering()); |
| 4470 }); | 4533 }); |
| 4471 } | 4534 } |
| 4472 if (becameUnthrottled) { | 4535 if (becameUnthrottled) { |
| 4473 // ScrollingCoordinator needs to update according to the new throttling stat
us. | 4536 // ScrollingCoordinator needs to update according to the new throttling |
| 4537 // status. |
| 4474 if (scrollingCoordinator) | 4538 if (scrollingCoordinator) |
| 4475 scrollingCoordinator->notifyGeometryChanged(); | 4539 scrollingCoordinator->notifyGeometryChanged(); |
| 4476 // Start ticking animation frames again if necessary. | 4540 // Start ticking animation frames again if necessary. |
| 4477 if (page()) | 4541 if (page()) |
| 4478 page()->animator().scheduleVisualUpdate(m_frame.get()); | 4542 page()->animator().scheduleVisualUpdate(m_frame.get()); |
| 4479 // Force a full repaint of this frame to ensure we are not left with a | 4543 // Force a full repaint of this frame to ensure we are not left with a |
| 4480 // partially painted version of this frame's contents if we skipped | 4544 // partially painted version of this frame's contents if we skipped |
| 4481 // painting them while the frame was throttled. | 4545 // painting them while the frame was throttled. |
| 4482 LayoutViewItem layoutViewItem = this->layoutViewItem(); | 4546 LayoutViewItem layoutViewItem = this->layoutViewItem(); |
| 4483 if (!layoutViewItem.isNull()) | 4547 if (!layoutViewItem.isNull()) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 4506 } | 4570 } |
| 4507 | 4571 |
| 4508 bool FrameView::canThrottleRendering() const { | 4572 bool FrameView::canThrottleRendering() const { |
| 4509 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled()) | 4573 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled()) |
| 4510 return false; | 4574 return false; |
| 4511 return m_subtreeThrottled || | 4575 return m_subtreeThrottled || |
| 4512 (m_hiddenForThrottling && m_crossOriginForThrottling); | 4576 (m_hiddenForThrottling && m_crossOriginForThrottling); |
| 4513 } | 4577 } |
| 4514 | 4578 |
| 4515 } // namespace blink | 4579 } // namespace blink |
| OLD | NEW |