| 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 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 document->updateLayoutTreeIfNeeded(); | 805 document->updateLayoutTreeIfNeeded(); |
| 806 lifecycle().advanceTo(DocumentLifecycle::StyleClean); | 806 lifecycle().advanceTo(DocumentLifecycle::StyleClean); |
| 807 } | 807 } |
| 808 | 808 |
| 809 static inline void layoutFromRootObject(LayoutObject& root) | 809 static inline void layoutFromRootObject(LayoutObject& root) |
| 810 { | 810 { |
| 811 LayoutState layoutState(root); | 811 LayoutState layoutState(root); |
| 812 root.layout(); | 812 root.layout(); |
| 813 } | 813 } |
| 814 | 814 |
| 815 void FrameView::prepareLayoutAnalyzer() |
| 816 { |
| 817 bool isTracing = false; |
| 818 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("blink.debug.la
yout"), &isTracing); |
| 819 if (!isTracing) { |
| 820 m_analyzer.clear(); |
| 821 return; |
| 822 } |
| 823 if (!m_analyzer) |
| 824 m_analyzer = adoptPtr(new LayoutAnalyzer()); |
| 825 m_analyzer->reset(); |
| 826 } |
| 827 |
| 815 PassRefPtr<TracedValue> FrameView::analyzerCounters() | 828 PassRefPtr<TracedValue> FrameView::analyzerCounters() |
| 816 { | 829 { |
| 817 RefPtr<TracedValue> value = layoutAnalyzer().toTracedValue(); | 830 if (!m_analyzer) |
| 831 return TracedValue::create(); |
| 832 RefPtr<TracedValue> value = m_analyzer->toTracedValue(); |
| 818 value->setString("host", layoutView()->document().location()->host()); | 833 value->setString("host", layoutView()->document().location()->host()); |
| 819 return value; | 834 return value; |
| 820 } | 835 } |
| 821 | 836 |
| 822 #define PERFORM_LAYOUT_TRACE_CATEGORIES "blink,benchmark," TRACE_DISABLED_BY_DEF
AULT("blink.debug.layout") | 837 #define PERFORM_LAYOUT_TRACE_CATEGORIES "blink,benchmark," TRACE_DISABLED_BY_DEF
AULT("blink.debug.layout") |
| 823 | 838 |
| 824 void FrameView::performLayout(bool inSubtreeLayout) | 839 void FrameView::performLayout(bool inSubtreeLayout) |
| 825 { | 840 { |
| 826 ASSERT(inSubtreeLayout || m_layoutSubtreeRoots.isEmpty()); | 841 ASSERT(inSubtreeLayout || m_layoutSubtreeRoots.isEmpty()); |
| 827 | 842 |
| 828 TRACE_EVENT_BEGIN0(PERFORM_LAYOUT_TRACE_CATEGORIES, "FrameView::performLayou
t"); | 843 TRACE_EVENT_BEGIN0(PERFORM_LAYOUT_TRACE_CATEGORIES, "FrameView::performLayou
t"); |
| 829 layoutAnalyzer().reset(); | 844 prepareLayoutAnalyzer(); |
| 830 | 845 |
| 831 ScriptForbiddenScope forbidScript; | 846 ScriptForbiddenScope forbidScript; |
| 832 | 847 |
| 833 ASSERT(!isInPerformLayout()); | 848 ASSERT(!isInPerformLayout()); |
| 834 lifecycle().advanceTo(DocumentLifecycle::InPerformLayout); | 849 lifecycle().advanceTo(DocumentLifecycle::InPerformLayout); |
| 835 | 850 |
| 836 TemporaryChange<bool> changeInPerformLayout(m_inPerformLayout, true); | 851 TemporaryChange<bool> changeInPerformLayout(m_inPerformLayout, true); |
| 837 | 852 |
| 838 // performLayout is the actual guts of layout(). | 853 // performLayout is the actual guts of layout(). |
| 839 // FIXME: The 300 other lines in layout() probably belong in other helper fu
nctions | 854 // FIXME: The 300 other lines in layout() probably belong in other helper fu
nctions |
| 840 // so that a single human could understand what layout() is actually doing. | 855 // so that a single human could understand what layout() is actually doing. |
| 841 | 856 |
| 842 forceLayoutParentViewIfNeeded(); | 857 forceLayoutParentViewIfNeeded(); |
| 843 | 858 |
| 844 if (inSubtreeLayout) { | 859 if (inSubtreeLayout) { |
| 845 layoutAnalyzer().increment(LayoutAnalyzer::PerformLayoutRootLayoutObject
s, m_layoutSubtreeRoots.size()); | 860 if (m_analyzer) |
| 861 m_analyzer->increment(LayoutAnalyzer::PerformLayoutRootLayoutObjects
, m_layoutSubtreeRoots.size()); |
| 846 while (m_layoutSubtreeRoots.size()) { | 862 while (m_layoutSubtreeRoots.size()) { |
| 847 LayoutObject& root = *m_layoutSubtreeRoots.takeAny(); | 863 LayoutObject& root = *m_layoutSubtreeRoots.takeAny(); |
| 848 if (!root.needsLayout()) | 864 if (!root.needsLayout()) |
| 849 continue; | 865 continue; |
| 850 layoutFromRootObject(root); | 866 layoutFromRootObject(root); |
| 851 | 867 |
| 852 // We need to ensure that we mark up all renderers up to the LayoutV
iew | 868 // We need to ensure that we mark up all renderers up to the LayoutV
iew |
| 853 // for paint invalidation. This simplifies our code as we just alway
s | 869 // for paint invalidation. This simplifies our code as we just alway
s |
| 854 // do a full tree walk. | 870 // do a full tree walk. |
| 855 if (LayoutObject* container = root.container()) | 871 if (LayoutObject* container = root.container()) |
| 856 container->setMayNeedPaintInvalidation(); | 872 container->setMayNeedPaintInvalidation(); |
| 857 } | 873 } |
| 858 } else { | 874 } else { |
| 859 layoutFromRootObject(*layoutView()); | 875 layoutFromRootObject(*layoutView()); |
| 860 } | 876 } |
| 861 | 877 |
| 862 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->updateAllIma
geResourcePriorities(); | 878 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->updateAllIma
geResourcePriorities(); |
| 863 | 879 |
| 864 lifecycle().advanceTo(DocumentLifecycle::AfterPerformLayout); | 880 lifecycle().advanceTo(DocumentLifecycle::AfterPerformLayout); |
| 865 | 881 |
| 866 layoutAnalyzer().recordCounters(); | 882 if (m_analyzer) |
| 883 m_analyzer->recordCounters(); |
| 867 TRACE_EVENT_END1(PERFORM_LAYOUT_TRACE_CATEGORIES, "FrameView::performLayout"
, | 884 TRACE_EVENT_END1(PERFORM_LAYOUT_TRACE_CATEGORIES, "FrameView::performLayout"
, |
| 868 "counters", analyzerCounters()); | 885 "counters", analyzerCounters()); |
| 869 } | 886 } |
| 870 | 887 |
| 871 void FrameView::scheduleOrPerformPostLayoutTasks() | 888 void FrameView::scheduleOrPerformPostLayoutTasks() |
| 872 { | 889 { |
| 873 if (m_postLayoutTasksTimer.isActive()) | 890 if (m_postLayoutTasksTimer.isActive()) |
| 874 return; | 891 return; |
| 875 | 892 |
| 876 if (!m_inSynchronousPostLayout) { | 893 if (!m_inSynchronousPostLayout) { |
| (...skipping 3117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3994 LayoutObject* FrameView::viewportLayoutObject() | 4011 LayoutObject* FrameView::viewportLayoutObject() |
| 3995 { | 4012 { |
| 3996 if (Document* document = frame().document()) { | 4013 if (Document* document = frame().document()) { |
| 3997 if (Element* element = document->viewportDefiningElement()) | 4014 if (Element* element = document->viewportDefiningElement()) |
| 3998 return element->layoutObject(); | 4015 return element->layoutObject(); |
| 3999 } | 4016 } |
| 4000 return nullptr; | 4017 return nullptr; |
| 4001 } | 4018 } |
| 4002 | 4019 |
| 4003 } // namespace blink | 4020 } // namespace blink |
| OLD | NEW |