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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 #include "platform/scroll/ScrollAnimatorBase.h" | 114 #include "platform/scroll/ScrollAnimatorBase.h" |
115 #include "platform/scroll/ScrollbarTheme.h" | 115 #include "platform/scroll/ScrollbarTheme.h" |
116 #include "platform/text/TextStream.h" | 116 #include "platform/text/TextStream.h" |
117 #include "public/platform/WebDisplayItemList.h" | 117 #include "public/platform/WebDisplayItemList.h" |
118 #include "public/platform/WebFrameScheduler.h" | 118 #include "public/platform/WebFrameScheduler.h" |
119 #include "wtf/CurrentTime.h" | 119 #include "wtf/CurrentTime.h" |
120 #include "wtf/PtrUtil.h" | 120 #include "wtf/PtrUtil.h" |
121 #include "wtf/StdLibExtras.h" | 121 #include "wtf/StdLibExtras.h" |
122 #include <memory> | 122 #include <memory> |
123 | 123 |
| 124 // Change the the following line to "#if 0" to disable crash on unexpected |
| 125 // dirty layout (crbug.com/590856) when dcheck is off. |
| 126 #if 1 |
| 127 #define CHECK_FOR_DIRTY_LAYOUT CHECK |
| 128 #else |
| 129 #define CHECK_FOR_DIRTY_LAYOUT(arg) \ |
| 130 do { \ |
| 131 if (!(arg)) { \ |
| 132 NOTREACHED(); \ |
| 133 return false; \ |
| 134 } \ |
| 135 } while (false) |
| 136 #endif |
| 137 |
124 namespace blink { | 138 namespace blink { |
125 | 139 |
126 using namespace HTMLNames; | 140 using namespace HTMLNames; |
127 | 141 |
128 // The maximum number of updateWidgets iterations that should be done before ret
urning. | 142 // The maximum number of updateWidgets iterations that should be done before ret
urning. |
129 static const unsigned maxUpdateWidgetsIterations = 2; | 143 static const unsigned maxUpdateWidgetsIterations = 2; |
130 static const double resourcePriorityUpdateDelayAfterScroll = 0.250; | 144 static const double resourcePriorityUpdateDelayAfterScroll = 0.250; |
131 | 145 |
132 static bool s_initialTrackAllPaintInvalidations = false; | 146 static bool s_initialTrackAllPaintInvalidations = false; |
133 | 147 |
(...skipping 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1838 || root->isOutOfFlowPositioned() | 1852 || root->isOutOfFlowPositioned() |
1839 || root->isColumnSpanAll() | 1853 || root->isColumnSpanAll() |
1840 || !root->styleRef().logicalHeight().isIntrinsicOrAuto()) { | 1854 || !root->styleRef().logicalHeight().isIntrinsicOrAuto()) { |
1841 continue; | 1855 continue; |
1842 } | 1856 } |
1843 LayoutState layoutState(*root); | 1857 LayoutState layoutState(*root); |
1844 root->layout(); | 1858 root->layout(); |
1845 } | 1859 } |
1846 } | 1860 } |
1847 | 1861 |
1848 void FrameView::checkLayoutInvalidationIsAllowed() const | 1862 bool FrameView::checkLayoutInvalidationIsAllowed() const |
1849 { | 1863 { |
1850 if (m_allowsLayoutInvalidationAfterLayoutClean) | 1864 if (m_allowsLayoutInvalidationAfterLayoutClean) |
1851 return; | 1865 return true; |
1852 | |
1853 if (!m_frame->document()) | |
1854 return; | |
1855 | 1866 |
1856 // If we are updating all lifecycle phases beyond LayoutClean, we don't expe
ct dirty layout after LayoutClean. | 1867 // If we are updating all lifecycle phases beyond LayoutClean, we don't expe
ct dirty layout after LayoutClean. |
1857 CHECK(lifecycle().state() < DocumentLifecycle::LayoutClean); | 1868 CHECK_FOR_DIRTY_LAYOUT(lifecycle().state() < DocumentLifecycle::LayoutClean)
; |
| 1869 |
| 1870 return true; |
1858 } | 1871 } |
1859 | 1872 |
1860 void FrameView::scheduleRelayout() | 1873 void FrameView::scheduleRelayout() |
1861 { | 1874 { |
1862 DCHECK(m_frame->view() == this); | 1875 DCHECK(m_frame->view() == this); |
1863 | 1876 |
1864 if (!m_layoutSchedulingEnabled) | 1877 if (!m_layoutSchedulingEnabled) |
1865 return; | 1878 return; |
1866 | 1879 // TODO(crbug.com/590856): It's still broken when we choose not to crash whe
n the check fails. |
1867 checkLayoutInvalidationIsAllowed(); | 1880 if (!checkLayoutInvalidationIsAllowed()) |
1868 | 1881 return; |
1869 if (!needsLayout()) | 1882 if (!needsLayout()) |
1870 return; | 1883 return; |
1871 if (!m_frame->document()->shouldScheduleLayout()) | 1884 if (!m_frame->document()->shouldScheduleLayout()) |
1872 return; | 1885 return; |
1873 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Invali
dateLayout", TRACE_EVENT_SCOPE_THREAD, "data", InspectorInvalidateLayoutEvent::d
ata(m_frame.get())); | 1886 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Invali
dateLayout", TRACE_EVENT_SCOPE_THREAD, "data", InspectorInvalidateLayoutEvent::d
ata(m_frame.get())); |
1874 | 1887 |
1875 clearLayoutSubtreeRootsAndMarkContainingBlocks(); | 1888 clearLayoutSubtreeRootsAndMarkContainingBlocks(); |
1876 | 1889 |
1877 if (m_hasPendingLayout) | 1890 if (m_hasPendingLayout) |
1878 return; | 1891 return; |
1879 m_hasPendingLayout = true; | 1892 m_hasPendingLayout = true; |
1880 | 1893 |
1881 if (!shouldThrottleRendering()) | 1894 if (!shouldThrottleRendering()) |
1882 page()->animator().scheduleVisualUpdate(m_frame.get()); | 1895 page()->animator().scheduleVisualUpdate(m_frame.get()); |
1883 } | 1896 } |
1884 | 1897 |
1885 void FrameView::scheduleRelayoutOfSubtree(LayoutObject* relayoutRoot) | 1898 void FrameView::scheduleRelayoutOfSubtree(LayoutObject* relayoutRoot) |
1886 { | 1899 { |
1887 DCHECK(m_frame->view() == this); | 1900 DCHECK(m_frame->view() == this); |
1888 | 1901 |
1889 checkLayoutInvalidationIsAllowed(); | 1902 // TODO(crbug.com/590856): It's still broken when we choose not to crash whe
n the check fails. |
| 1903 if (!checkLayoutInvalidationIsAllowed()) |
| 1904 return; |
1890 | 1905 |
1891 // FIXME: Should this call shouldScheduleLayout instead? | 1906 // FIXME: Should this call shouldScheduleLayout instead? |
1892 if (!m_frame->document()->isActive()) | 1907 if (!m_frame->document()->isActive()) |
1893 return; | 1908 return; |
1894 | 1909 |
1895 LayoutView* layoutView = this->layoutView(); | 1910 LayoutView* layoutView = this->layoutView(); |
1896 if (layoutView && layoutView->needsLayout()) { | 1911 if (layoutView && layoutView->needsLayout()) { |
1897 if (relayoutRoot) | 1912 if (relayoutRoot) |
1898 relayoutRoot->markContainerChainForLayout(false); | 1913 relayoutRoot->markContainerChainForLayout(false); |
1899 return; | 1914 return; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1931 // This can return true in cases where the document does not have a body yet
. | 1946 // This can return true in cases where the document does not have a body yet
. |
1932 // Document::shouldScheduleLayout takes care of preventing us from schedulin
g | 1947 // Document::shouldScheduleLayout takes care of preventing us from schedulin
g |
1933 // layout in that case. | 1948 // layout in that case. |
1934 | 1949 |
1935 LayoutViewItem layoutViewItem = this->layoutViewItem(); | 1950 LayoutViewItem layoutViewItem = this->layoutViewItem(); |
1936 return layoutPending() | 1951 return layoutPending() |
1937 || (!layoutViewItem.isNull() && layoutViewItem.needsLayout()) | 1952 || (!layoutViewItem.isNull() && layoutViewItem.needsLayout()) |
1938 || isSubtreeLayout(); | 1953 || isSubtreeLayout(); |
1939 } | 1954 } |
1940 | 1955 |
1941 NOINLINE void FrameView::checkDoesNotNeedLayout() const | 1956 NOINLINE bool FrameView::checkDoesNotNeedLayout() const |
1942 { | 1957 { |
1943 CHECK(!layoutPending()); | 1958 CHECK_FOR_DIRTY_LAYOUT(!layoutPending()); |
1944 CHECK(layoutViewItem().isNull() || !layoutViewItem().needsLayout()); | 1959 CHECK_FOR_DIRTY_LAYOUT(layoutViewItem().isNull() || !layoutViewItem().needsL
ayout()); |
1945 CHECK(!isSubtreeLayout()); | 1960 CHECK_FOR_DIRTY_LAYOUT(!isSubtreeLayout()); |
| 1961 return true; |
1946 } | 1962 } |
1947 | 1963 |
1948 void FrameView::setNeedsLayout() | 1964 void FrameView::setNeedsLayout() |
1949 { | 1965 { |
1950 checkLayoutInvalidationIsAllowed(); | |
1951 | |
1952 LayoutViewItem layoutViewItem = this->layoutViewItem(); | 1966 LayoutViewItem layoutViewItem = this->layoutViewItem(); |
1953 if (!layoutViewItem.isNull()) | 1967 if (layoutViewItem.isNull()) |
1954 layoutViewItem.setNeedsLayout(LayoutInvalidationReason::Unknown); | 1968 return; |
| 1969 // TODO(crbug.com/590856): It's still broken if we choose not to crash when
the check fails. |
| 1970 if (!checkLayoutInvalidationIsAllowed()) |
| 1971 return; |
| 1972 layoutViewItem.setNeedsLayout(LayoutInvalidationReason::Unknown); |
1955 } | 1973 } |
1956 | 1974 |
1957 bool FrameView::isTransparent() const | 1975 bool FrameView::isTransparent() const |
1958 { | 1976 { |
1959 return m_isTransparent; | 1977 return m_isTransparent; |
1960 } | 1978 } |
1961 | 1979 |
1962 void FrameView::setTransparent(bool isTransparent) | 1980 void FrameView::setTransparent(bool isTransparent) |
1963 { | 1981 { |
1964 m_isTransparent = isTransparent; | 1982 m_isTransparent = isTransparent; |
(...skipping 2343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4308 } | 4326 } |
4309 | 4327 |
4310 bool FrameView::canThrottleRendering() const | 4328 bool FrameView::canThrottleRendering() const |
4311 { | 4329 { |
4312 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled()) | 4330 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled()) |
4313 return false; | 4331 return false; |
4314 return m_subtreeThrottled || (m_hiddenForThrottling && m_crossOriginForThrot
tling); | 4332 return m_subtreeThrottled || (m_hiddenForThrottling && m_crossOriginForThrot
tling); |
4315 } | 4333 } |
4316 | 4334 |
4317 } // namespace blink | 4335 } // namespace blink |
OLD | NEW |