| 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 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 ownerRenderer->setNeedsLayoutAndPrefWidthsRecalc(); | 770 ownerRenderer->setNeedsLayoutAndPrefWidthsRecalc(); |
| 771 | 771 |
| 772 // Synchronously enter layout, to layout the view containing the host object
/embed/iframe. | 772 // Synchronously enter layout, to layout the view containing the host object
/embed/iframe. |
| 773 ASSERT(frameView); | 773 ASSERT(frameView); |
| 774 frameView->layout(); | 774 frameView->layout(); |
| 775 } | 775 } |
| 776 | 776 |
| 777 void FrameView::performPreLayoutTasks() | 777 void FrameView::performPreLayoutTasks() |
| 778 { | 778 { |
| 779 TRACE_EVENT0("webkit", "FrameView::performPreLayoutTasks"); | 779 TRACE_EVENT0("webkit", "FrameView::performPreLayoutTasks"); |
| 780 lifecycle().advanceTo(DocumentLifecycle::InPreLayout); |
| 780 | 781 |
| 781 // Don't schedule more layouts, we're in one. | 782 // Don't schedule more layouts, we're in one. |
| 782 TemporaryChange<bool> changeSchedulingEnabled(m_layoutSchedulingEnabled, fal
se); | 783 TemporaryChange<bool> changeSchedulingEnabled(m_layoutSchedulingEnabled, fal
se); |
| 783 | 784 |
| 784 if (!m_nestedLayoutCount && !m_inSynchronousPostLayout && m_postLayoutTasksT
imer.isActive()) { | 785 if (!m_nestedLayoutCount && !m_inSynchronousPostLayout && m_postLayoutTasksT
imer.isActive()) { |
| 785 // This is a new top-level layout. If there are any remaining tasks from
the previous layout, finish them now. | 786 // This is a new top-level layout. If there are any remaining tasks from
the previous layout, finish them now. |
| 786 m_inSynchronousPostLayout = true; | 787 m_inSynchronousPostLayout = true; |
| 787 performPostLayoutTasks(); | 788 performPostLayoutTasks(); |
| 788 m_inSynchronousPostLayout = false; | 789 m_inSynchronousPostLayout = false; |
| 789 } | 790 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 804 } | 805 } |
| 805 | 806 |
| 806 // If there is any pagination to apply, it will affect the RenderView's styl
e, so we should | 807 // If there is any pagination to apply, it will affect the RenderView's styl
e, so we should |
| 807 // take care of that now. | 808 // take care of that now. |
| 808 applyPaginationToViewport(); | 809 applyPaginationToViewport(); |
| 809 | 810 |
| 810 // Always ensure our style info is up-to-date. This can happen in situations
where | 811 // Always ensure our style info is up-to-date. This can happen in situations
where |
| 811 // the layout beats any sort of style recalc update that needs to occur. | 812 // the layout beats any sort of style recalc update that needs to occur. |
| 812 TemporaryChange<bool> changeDoingPreLayoutStyleUpdate(m_doingPreLayoutStyleU
pdate, true); | 813 TemporaryChange<bool> changeDoingPreLayoutStyleUpdate(m_doingPreLayoutStyleU
pdate, true); |
| 813 document->updateStyleIfNeeded(); | 814 document->updateStyleIfNeeded(); |
| 815 lifecycle().advanceTo(DocumentLifecycle::StyleClean); |
| 814 } | 816 } |
| 815 | 817 |
| 816 void FrameView::performLayout(RenderObject* rootForThisLayout, bool inSubtreeLay
out) | 818 void FrameView::performLayout(RenderObject* rootForThisLayout, bool inSubtreeLay
out) |
| 817 { | 819 { |
| 818 ASSERT(!m_inPerformLayout); | 820 TRACE_EVENT0("webkit", "FrameView::performLayout"); |
| 819 | 821 |
| 820 TRACE_EVENT0("webkit", "FrameView::performLayout"); | 822 ASSERT(!isInPerformLayout()); |
| 823 lifecycle().advanceTo(DocumentLifecycle::InPerformLayout); |
| 821 | 824 |
| 822 TemporaryChange<bool> changeInPerformLayout(m_inPerformLayout, true); | 825 TemporaryChange<bool> changeInPerformLayout(m_inPerformLayout, true); |
| 823 | 826 |
| 824 // performLayout is the actual guts of layout(). | 827 // performLayout is the actual guts of layout(). |
| 825 // FIXME: The 300 other lines in layout() probably belong in other helper fu
nctions | 828 // FIXME: The 300 other lines in layout() probably belong in other helper fu
nctions |
| 826 // so that a single human could understand what layout() is actually doing. | 829 // so that a single human could understand what layout() is actually doing. |
| 827 | 830 |
| 828 { | 831 { |
| 829 bool disableLayoutState = false; | 832 bool disableLayoutState = false; |
| 830 if (inSubtreeLayout) { | 833 if (inSubtreeLayout) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 849 TextAutosizer* textAutosizer = frame().document()->textAutosizer(); | 852 TextAutosizer* textAutosizer = frame().document()->textAutosizer(); |
| 850 bool autosized = textAutosizer && textAutosizer->processSubtree(rootForThisL
ayout); | 853 bool autosized = textAutosizer && textAutosizer->processSubtree(rootForThisL
ayout); |
| 851 if (autosized && rootForThisLayout->needsLayout()) { | 854 if (autosized && rootForThisLayout->needsLayout()) { |
| 852 TRACE_EVENT0("webkit", "2nd layout due to Text Autosizing"); | 855 TRACE_EVENT0("webkit", "2nd layout due to Text Autosizing"); |
| 853 rootForThisLayout->layout(); | 856 rootForThisLayout->layout(); |
| 854 gatherDebugLayoutRects(rootForThisLayout); | 857 gatherDebugLayoutRects(rootForThisLayout); |
| 855 } | 858 } |
| 856 | 859 |
| 857 if (inSubtreeLayout) | 860 if (inSubtreeLayout) |
| 858 rootForThisLayout->view()->popLayoutState(rootForThisLayout); | 861 rootForThisLayout->view()->popLayoutState(rootForThisLayout); |
| 862 |
| 863 lifecycle().advanceTo(DocumentLifecycle::AfterPerformLayout); |
| 859 } | 864 } |
| 860 | 865 |
| 861 void FrameView::scheduleOrPerformPostLayoutTasks() | 866 void FrameView::scheduleOrPerformPostLayoutTasks() |
| 862 { | 867 { |
| 863 if (m_postLayoutTasksTimer.isActive()) | 868 if (m_postLayoutTasksTimer.isActive()) |
| 864 return; | 869 return; |
| 865 | 870 |
| 866 // Partial layouts should not happen with synchronous post layouts. | 871 // Partial layouts should not happen with synchronous post layouts. |
| 867 ASSERT(!(m_inSynchronousPostLayout && partialLayout().isStopping())); | 872 ASSERT(!(m_inSynchronousPostLayout && partialLayout().isStopping())); |
| 868 | 873 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 884 } | 889 } |
| 885 } | 890 } |
| 886 | 891 |
| 887 void FrameView::layout(bool allowSubtree) | 892 void FrameView::layout(bool allowSubtree) |
| 888 { | 893 { |
| 889 // We should never layout a Document which is not in a Frame. | 894 // We should never layout a Document which is not in a Frame. |
| 890 ASSERT(m_frame); | 895 ASSERT(m_frame); |
| 891 ASSERT(m_frame->view() == this); | 896 ASSERT(m_frame->view() == this); |
| 892 ASSERT(m_frame->page()); | 897 ASSERT(m_frame->page()); |
| 893 | 898 |
| 894 if (m_inPerformLayout) | 899 if (isInPerformLayout() || !m_frame->document()->isActive()) |
| 895 return; | |
| 896 | |
| 897 if (!m_frame->document()->isActive()) | |
| 898 return; | 900 return; |
| 899 | 901 |
| 900 ASSERT(!partialLayout().isStopping()); | 902 ASSERT(!partialLayout().isStopping()); |
| 901 | 903 |
| 902 TRACE_EVENT0("webkit", "FrameView::layout"); | 904 TRACE_EVENT0("webkit", "FrameView::layout"); |
| 903 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "Layout"); | 905 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "Layout"); |
| 904 | 906 |
| 905 // Protect the view from being deleted during layout (in recalcStyle) | 907 // Protect the view from being deleted during layout (in recalcStyle) |
| 906 RefPtr<FrameView> protector(this); | 908 RefPtr<FrameView> protector(this); |
| 907 | 909 |
| 908 // Every scroll that happens during layout is programmatic. | 910 // Every scroll that happens during layout is programmatic. |
| 909 TemporaryChange<bool> changeInProgrammaticScroll(m_inProgrammaticScroll, tru
e); | 911 TemporaryChange<bool> changeInProgrammaticScroll(m_inProgrammaticScroll, tru
e); |
| 910 | 912 |
| 911 m_hasPendingLayout = false; | 913 m_hasPendingLayout = false; |
| 914 DocumentLifecycle::Scope lifecycleScope(lifecycle(), DocumentLifecycle::Layo
utClean); |
| 912 | 915 |
| 913 // we shouldn't enter layout() while painting | 916 RELEASE_ASSERT(!isPainting()); |
| 914 ASSERT(!isPainting()); | |
| 915 if (isPainting()) | |
| 916 return; | |
| 917 | 917 |
| 918 // Store the current maximal outline size to use when computing the old/new | 918 // Store the current maximal outline size to use when computing the old/new |
| 919 // outline rects for repainting. | 919 // outline rects for repainting. |
| 920 renderView()->setOldMaximalOutlineSize(renderView()->maximalOutlineSize()); | 920 renderView()->setOldMaximalOutlineSize(renderView()->maximalOutlineSize()); |
| 921 | 921 |
| 922 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willLayout
(m_frame.get()); | 922 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willLayout
(m_frame.get()); |
| 923 | 923 |
| 924 if (!allowSubtree && isSubtreeLayout()) { | 924 if (!allowSubtree && isSubtreeLayout()) { |
| 925 m_layoutSubtreeRoot->markContainingBlocksForLayout(false); | 925 m_layoutSubtreeRoot->markContainingBlocksForLayout(false); |
| 926 m_layoutSubtreeRoot = 0; | 926 m_layoutSubtreeRoot = 0; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 937 bool inSubtreeLayout = isSubtreeLayout(); | 937 bool inSubtreeLayout = isSubtreeLayout(); |
| 938 RenderObject* rootForThisLayout = inSubtreeLayout ? m_layoutSubtreeRoot : do
cument->renderer(); | 938 RenderObject* rootForThisLayout = inSubtreeLayout ? m_layoutSubtreeRoot : do
cument->renderer(); |
| 939 if (!rootForThisLayout) { | 939 if (!rootForThisLayout) { |
| 940 // FIXME: Do we need to set m_size here? | 940 // FIXME: Do we need to set m_size here? |
| 941 ASSERT_NOT_REACHED(); | 941 ASSERT_NOT_REACHED(); |
| 942 return; | 942 return; |
| 943 } | 943 } |
| 944 | 944 |
| 945 bool isPartialLayout = partialLayout().isPartialLayout(); | 945 bool isPartialLayout = partialLayout().isPartialLayout(); |
| 946 | 946 |
| 947 if (isPartialLayout) |
| 948 lifecycleScope.setFinalState(DocumentLifecycle::StyleClean); |
| 949 |
| 947 FontCachePurgePreventer fontCachePurgePreventer; | 950 FontCachePurgePreventer fontCachePurgePreventer; |
| 948 RenderLayer* layer; | 951 RenderLayer* layer; |
| 949 { | 952 { |
| 950 TemporaryChange<bool> changeSchedulingEnabled(m_layoutSchedulingEnabled,
false); | 953 TemporaryChange<bool> changeSchedulingEnabled(m_layoutSchedulingEnabled,
false); |
| 951 | 954 |
| 952 m_nestedLayoutCount++; | 955 m_nestedLayoutCount++; |
| 953 if (!inSubtreeLayout) { | 956 if (!inSubtreeLayout) { |
| 954 Document* document = m_frame->document(); | 957 Document* document = m_frame->document(); |
| 955 Node* body = document->body(); | 958 Node* body = document->body(); |
| 956 if (body && body->renderer()) { | 959 if (body && body->renderer()) { |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 renderView()->setOldMaximalOutlineSize(0); | 1154 renderView()->setOldMaximalOutlineSize(0); |
| 1152 | 1155 |
| 1153 // Repaint the frameviews scrollbars if needed | 1156 // Repaint the frameviews scrollbars if needed |
| 1154 if (hasVerticalBarDamage()) | 1157 if (hasVerticalBarDamage()) |
| 1155 invalidateRect(verticalBarDamage()); | 1158 invalidateRect(verticalBarDamage()); |
| 1156 if (hasHorizontalBarDamage()) | 1159 if (hasHorizontalBarDamage()) |
| 1157 invalidateRect(horizontalBarDamage()); | 1160 invalidateRect(horizontalBarDamage()); |
| 1158 resetScrollbarDamage(); | 1161 resetScrollbarDamage(); |
| 1159 } | 1162 } |
| 1160 | 1163 |
| 1164 DocumentLifecycle& FrameView::lifecycle() const |
| 1165 { |
| 1166 return m_frame->document()->lifecycle(); |
| 1167 } |
| 1168 |
| 1161 void FrameView::gatherDebugLayoutRects(RenderObject* layoutRoot) | 1169 void FrameView::gatherDebugLayoutRects(RenderObject* layoutRoot) |
| 1162 { | 1170 { |
| 1163 bool isTracing; | 1171 bool isTracing; |
| 1164 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("blink.debug.la
yout"), &isTracing); | 1172 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("blink.debug.la
yout"), &isTracing); |
| 1165 if (!isTracing) | 1173 if (!isTracing) |
| 1166 return; | 1174 return; |
| 1167 if (!layoutRoot->enclosingLayer()->hasCompositedLayerMapping()) | 1175 if (!layoutRoot->enclosingLayer()->hasCompositedLayerMapping()) |
| 1168 return; | 1176 return; |
| 1169 GraphicsLayer* graphicsLayer = layoutRoot->enclosingLayer()->compositedLayer
Mapping()->mainGraphicsLayer(); | 1177 GraphicsLayer* graphicsLayer = layoutRoot->enclosingLayer()->compositedLayer
Mapping()->mainGraphicsLayer(); |
| 1170 if (!graphicsLayer) | 1178 if (!graphicsLayer) |
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1860 m_hasPendingLayout = true; | 1868 m_hasPendingLayout = true; |
| 1861 scheduleAnimation(); | 1869 scheduleAnimation(); |
| 1862 } | 1870 } |
| 1863 } | 1871 } |
| 1864 | 1872 |
| 1865 bool FrameView::layoutPending() const | 1873 bool FrameView::layoutPending() const |
| 1866 { | 1874 { |
| 1867 return m_hasPendingLayout; | 1875 return m_hasPendingLayout; |
| 1868 } | 1876 } |
| 1869 | 1877 |
| 1878 bool FrameView::isInPerformLayout() const |
| 1879 { |
| 1880 ASSERT(m_inPerformLayout == (lifecycle().state() == DocumentLifecycle::InPer
formLayout)); |
| 1881 return m_inPerformLayout; |
| 1882 } |
| 1883 |
| 1870 bool FrameView::needsLayout() const | 1884 bool FrameView::needsLayout() const |
| 1871 { | 1885 { |
| 1872 // This can return true in cases where the document does not have a body yet
. | 1886 // This can return true in cases where the document does not have a body yet
. |
| 1873 // Document::shouldScheduleLayout takes care of preventing us from schedulin
g | 1887 // Document::shouldScheduleLayout takes care of preventing us from schedulin
g |
| 1874 // layout in that case. | 1888 // layout in that case. |
| 1875 | 1889 |
| 1876 RenderView* renderView = this->renderView(); | 1890 RenderView* renderView = this->renderView(); |
| 1877 return layoutPending() | 1891 return layoutPending() |
| 1878 || (renderView && renderView->needsLayout()) | 1892 || (renderView && renderView->needsLayout()) |
| 1879 || isSubtreeLayout(); | 1893 || isSubtreeLayout(); |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2306 scrollPositionChanged(); | 2320 scrollPositionChanged(); |
| 2307 frame().loader().client()->didChangeScrollOffset(); | 2321 frame().loader().client()->didChangeScrollOffset(); |
| 2308 } | 2322 } |
| 2309 | 2323 |
| 2310 void FrameView::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rec
t) | 2324 void FrameView::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rec
t) |
| 2311 { | 2325 { |
| 2312 // Add in our offset within the FrameView. | 2326 // Add in our offset within the FrameView. |
| 2313 IntRect dirtyRect = rect; | 2327 IntRect dirtyRect = rect; |
| 2314 dirtyRect.moveBy(scrollbar->location()); | 2328 dirtyRect.moveBy(scrollbar->location()); |
| 2315 | 2329 |
| 2316 if (RuntimeEnabledFeatures::repaintAfterLayoutEnabled() && m_inPerformLayout
) { | 2330 if (RuntimeEnabledFeatures::repaintAfterLayoutEnabled() && isInPerformLayout
()) { |
| 2317 if (scrollbar == verticalScrollbar()) { | 2331 if (scrollbar == verticalScrollbar()) { |
| 2318 m_verticalBarDamage = dirtyRect; | 2332 m_verticalBarDamage = dirtyRect; |
| 2319 m_hasVerticalBarDamage = true; | 2333 m_hasVerticalBarDamage = true; |
| 2320 } else { | 2334 } else { |
| 2321 m_horizontalBarDamage = dirtyRect; | 2335 m_horizontalBarDamage = dirtyRect; |
| 2322 m_hasHorizontalBarDamage = true; | 2336 m_hasHorizontalBarDamage = true; |
| 2323 } | 2337 } |
| 2324 } else { | 2338 } else { |
| 2325 invalidateRect(dirtyRect); | 2339 invalidateRect(dirtyRect); |
| 2326 } | 2340 } |
| (...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3219 void FrameView::willRemoveScrollbar(Scrollbar* scrollbar, ScrollbarOrientation o
rientation) | 3233 void FrameView::willRemoveScrollbar(Scrollbar* scrollbar, ScrollbarOrientation o
rientation) |
| 3220 { | 3234 { |
| 3221 ScrollableArea::willRemoveScrollbar(scrollbar, orientation); | 3235 ScrollableArea::willRemoveScrollbar(scrollbar, orientation); |
| 3222 if (AXObjectCache* cache = axObjectCache()) { | 3236 if (AXObjectCache* cache = axObjectCache()) { |
| 3223 cache->remove(scrollbar); | 3237 cache->remove(scrollbar); |
| 3224 cache->handleScrollbarUpdate(this); | 3238 cache->handleScrollbarUpdate(this); |
| 3225 } | 3239 } |
| 3226 } | 3240 } |
| 3227 | 3241 |
| 3228 } // namespace WebCore | 3242 } // namespace WebCore |
| OLD | NEW |