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