Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. |
| 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) |
| 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
| 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. |
| (...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1524 return false; | 1524 return false; |
| 1525 return true; | 1525 return true; |
| 1526 } | 1526 } |
| 1527 | 1527 |
| 1528 void Document::scheduleLayoutTreeUpdate() | 1528 void Document::scheduleLayoutTreeUpdate() |
| 1529 { | 1529 { |
| 1530 ASSERT(!hasPendingStyleRecalc()); | 1530 ASSERT(!hasPendingStyleRecalc()); |
| 1531 ASSERT(shouldScheduleLayoutTreeUpdate()); | 1531 ASSERT(shouldScheduleLayoutTreeUpdate()); |
| 1532 ASSERT(needsLayoutTreeUpdate()); | 1532 ASSERT(needsLayoutTreeUpdate()); |
| 1533 | 1533 |
| 1534 page()->animator().scheduleVisualUpdate(); | 1534 if (!view() || !view()->shouldThrottleRendering()) |
|
esprehn
2015/10/14 22:09:46
we shouldn't be able to get here without a view(),
Sami
2015/10/16 16:48:08
Thanks, I didn't realize isActive() implies view()
| |
| 1535 page()->animator().scheduleVisualUpdate(); | |
| 1535 m_lifecycle.ensureStateAtMost(DocumentLifecycle::VisualUpdatePending); | 1536 m_lifecycle.ensureStateAtMost(DocumentLifecycle::VisualUpdatePending); |
| 1536 | 1537 |
| 1537 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Schedu leStyleRecalculation", TRACE_EVENT_SCOPE_THREAD, "data", InspectorRecalculateSty lesEvent::data(frame())); | 1538 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Schedu leStyleRecalculation", TRACE_EVENT_SCOPE_THREAD, "data", InspectorRecalculateSty lesEvent::data(frame())); |
| 1538 InspectorInstrumentation::didScheduleStyleRecalculation(this); | 1539 InspectorInstrumentation::didScheduleStyleRecalculation(this); |
| 1539 | 1540 |
| 1540 ++m_styleVersion; | 1541 ++m_styleVersion; |
| 1541 } | 1542 } |
| 1542 | 1543 |
| 1543 bool Document::hasPendingForcedStyleRecalc() const | 1544 bool Document::hasPendingForcedStyleRecalc() const |
| 1544 { | 1545 { |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1714 | 1715 |
| 1715 void Document::updateLayoutTree(StyleRecalcChange change) | 1716 void Document::updateLayoutTree(StyleRecalcChange change) |
| 1716 { | 1717 { |
| 1717 ASSERT(isMainThread()); | 1718 ASSERT(isMainThread()); |
| 1718 | 1719 |
| 1719 ScriptForbiddenScope forbidScript; | 1720 ScriptForbiddenScope forbidScript; |
| 1720 | 1721 |
| 1721 if (!view() || !isActive()) | 1722 if (!view() || !isActive()) |
| 1722 return; | 1723 return; |
| 1723 | 1724 |
| 1725 if (view()->shouldThrottleRenderingIfAllowed()) | |
| 1726 return; | |
| 1727 | |
| 1724 if (change != Force && !needsLayoutTreeUpdate()) { | 1728 if (change != Force && !needsLayoutTreeUpdate()) { |
| 1725 ASSERT(lifecycle().state() != DocumentLifecycle::VisualUpdatePending); | 1729 ASSERT(lifecycle().state() != DocumentLifecycle::VisualUpdatePending); |
| 1726 return; | 1730 return; |
| 1727 } | 1731 } |
| 1728 | 1732 |
| 1729 if (inStyleRecalc()) | 1733 if (inStyleRecalc()) |
| 1730 return; | 1734 return; |
| 1731 | 1735 |
| 1732 // Entering here from inside layout or paint would be catastrophic since rec alcStyle can | 1736 // Entering here from inside layout or paint would be catastrophic since rec alcStyle can |
| 1733 // tear down the layout tree or (unfortunately) run script. Kill the whole l ayoutObject if | 1737 // tear down the layout tree or (unfortunately) run script. Kill the whole l ayoutObject if |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1781 TRACE_EVENT_END1("blink,devtools.timeline", "UpdateLayoutTree", "elementCoun t", m_styleRecalcElementCounter); | 1785 TRACE_EVENT_END1("blink,devtools.timeline", "UpdateLayoutTree", "elementCoun t", m_styleRecalcElementCounter); |
| 1782 InspectorInstrumentation::didRecalculateStyle(cookie, m_styleRecalcElementCo unter); | 1786 InspectorInstrumentation::didRecalculateStyle(cookie, m_styleRecalcElementCo unter); |
| 1783 | 1787 |
| 1784 #if ENABLE(ASSERT) | 1788 #if ENABLE(ASSERT) |
| 1785 assertLayoutTreeUpdated(*this); | 1789 assertLayoutTreeUpdated(*this); |
| 1786 #endif | 1790 #endif |
| 1787 } | 1791 } |
| 1788 | 1792 |
| 1789 void Document::updateStyle(StyleRecalcChange change) | 1793 void Document::updateStyle(StyleRecalcChange change) |
| 1790 { | 1794 { |
| 1795 if (view() && view()->shouldThrottleRenderingIfAllowed()) | |
|
esprehn
2015/10/14 22:09:46
you must have a view here, no need to null check,
Sami
2015/10/16 16:48:08
Done.
| |
| 1796 return; | |
| 1797 | |
| 1791 TRACE_EVENT_BEGIN0("blink,blink_style", "Document::updateStyle"); | 1798 TRACE_EVENT_BEGIN0("blink,blink_style", "Document::updateStyle"); |
| 1792 unsigned initialResolverAccessCount = styleEngine().resolverAccessCount(); | 1799 unsigned initialResolverAccessCount = styleEngine().resolverAccessCount(); |
| 1793 | 1800 |
| 1794 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; | 1801 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; |
| 1795 m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc); | 1802 m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc); |
| 1796 | 1803 |
| 1797 NthIndexCache nthIndexCache(*this); | 1804 NthIndexCache nthIndexCache(*this); |
| 1798 | 1805 |
| 1799 if (styleChangeType() >= SubtreeStyleChange) | 1806 if (styleChangeType() >= SubtreeStyleChange) |
| 1800 change = Force; | 1807 change = Force; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1898 RefPtrWillBeRawPtr<FrameView> frameView = view(); | 1905 RefPtrWillBeRawPtr<FrameView> frameView = view(); |
| 1899 if (frameView && frameView->isInPerformLayout()) { | 1906 if (frameView && frameView->isInPerformLayout()) { |
| 1900 // View layout should not be re-entrant. | 1907 // View layout should not be re-entrant. |
| 1901 ASSERT_NOT_REACHED(); | 1908 ASSERT_NOT_REACHED(); |
| 1902 return; | 1909 return; |
| 1903 } | 1910 } |
| 1904 | 1911 |
| 1905 if (HTMLFrameOwnerElement* owner = ownerElement()) | 1912 if (HTMLFrameOwnerElement* owner = ownerElement()) |
| 1906 owner->document().updateLayout(); | 1913 owner->document().updateLayout(); |
| 1907 | 1914 |
| 1915 lifecycle().setThrottlingMode(DocumentLifecycle::ThrottlingMode::Disallow); | |
|
esprehn
2015/10/14 22:09:45
Lets add a scope object for this instead of manual
Sami
2015/10/16 16:48:08
Much cleaner, done. In case it isn't obvious, I ma
| |
| 1908 updateLayoutTreeIfNeeded(); | 1916 updateLayoutTreeIfNeeded(); |
| 1909 | 1917 |
| 1910 if (!isActive()) | 1918 if (isActive()) { |
| 1911 return; | 1919 if (frameView->needsLayout()) |
| 1920 frameView->layout(); | |
| 1912 | 1921 |
| 1913 if (frameView->needsLayout()) | 1922 if (lifecycle().state() < DocumentLifecycle::LayoutClean) |
| 1914 frameView->layout(); | 1923 lifecycle().advanceTo(DocumentLifecycle::LayoutClean); |
| 1924 } | |
| 1915 | 1925 |
| 1916 if (lifecycle().state() < DocumentLifecycle::LayoutClean) | 1926 lifecycle().setThrottlingMode(DocumentLifecycle::ThrottlingMode::Allow); |
| 1917 lifecycle().advanceTo(DocumentLifecycle::LayoutClean); | |
| 1918 } | 1927 } |
| 1919 | 1928 |
| 1920 void Document::layoutUpdated() | 1929 void Document::layoutUpdated() |
| 1921 { | 1930 { |
| 1922 markers().updateRenderedRectsForMarkers(); | 1931 markers().updateRenderedRectsForMarkers(); |
| 1923 | 1932 |
| 1924 // The layout system may perform layouts with pending stylesheets. When | 1933 // The layout system may perform layouts with pending stylesheets. When |
| 1925 // recording first layout time, we ignore these layouts, since painting is | 1934 // recording first layout time, we ignore these layouts, since painting is |
| 1926 // suppressed for them. We're interested in tracking the time of the | 1935 // suppressed for them. We're interested in tracking the time of the |
| 1927 // first real or 'paintable' layout. | 1936 // first real or 'paintable' layout. |
| (...skipping 3840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5768 #ifndef NDEBUG | 5777 #ifndef NDEBUG |
| 5769 using namespace blink; | 5778 using namespace blink; |
| 5770 void showLiveDocumentInstances() | 5779 void showLiveDocumentInstances() |
| 5771 { | 5780 { |
| 5772 Document::WeakDocumentSet& set = Document::liveDocumentSet(); | 5781 Document::WeakDocumentSet& set = Document::liveDocumentSet(); |
| 5773 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5782 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 5774 for (Document* document : set) | 5783 for (Document* document : set) |
| 5775 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); | 5784 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); |
| 5776 } | 5785 } |
| 5777 #endif | 5786 #endif |
| OLD | NEW |