Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 1696233002: Make render pipeline throttling opt-in (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Windows build fix. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/DocumentLifecycle.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1518 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 return false; 1529 return false;
1530 return true; 1530 return true;
1531 } 1531 }
1532 1532
1533 void Document::scheduleLayoutTreeUpdate() 1533 void Document::scheduleLayoutTreeUpdate()
1534 { 1534 {
1535 ASSERT(!hasPendingStyleRecalc()); 1535 ASSERT(!hasPendingStyleRecalc());
1536 ASSERT(shouldScheduleLayoutTreeUpdate()); 1536 ASSERT(shouldScheduleLayoutTreeUpdate());
1537 ASSERT(needsLayoutTreeUpdate()); 1537 ASSERT(needsLayoutTreeUpdate());
1538 1538
1539 if (!view()->shouldThrottleRendering()) 1539 if (!view()->canThrottleRendering())
1540 page()->animator().scheduleVisualUpdate(frame()); 1540 page()->animator().scheduleVisualUpdate(frame());
1541 m_lifecycle.ensureStateAtMost(DocumentLifecycle::VisualUpdatePending); 1541 m_lifecycle.ensureStateAtMost(DocumentLifecycle::VisualUpdatePending);
1542 1542
1543 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Schedu leStyleRecalculation", TRACE_EVENT_SCOPE_THREAD, "data", InspectorRecalculateSty lesEvent::data(frame())); 1543 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Schedu leStyleRecalculation", TRACE_EVENT_SCOPE_THREAD, "data", InspectorRecalculateSty lesEvent::data(frame()));
1544 InspectorInstrumentation::didScheduleStyleRecalculation(this); 1544 InspectorInstrumentation::didScheduleStyleRecalculation(this);
1545 1545
1546 ++m_styleVersion; 1546 ++m_styleVersion;
1547 } 1547 }
1548 1548
1549 bool Document::hasPendingForcedStyleRecalc() const 1549 bool Document::hasPendingForcedStyleRecalc() const
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 TRACE_EVENT_END1("blink,devtools.timeline", "UpdateLayoutTree", "elementCoun t", elementCount); 1804 TRACE_EVENT_END1("blink,devtools.timeline", "UpdateLayoutTree", "elementCoun t", elementCount);
1805 InspectorInstrumentation::didRecalculateStyle(cookie, elementCount); 1805 InspectorInstrumentation::didRecalculateStyle(cookie, elementCount);
1806 1806
1807 #if ENABLE(ASSERT) 1807 #if ENABLE(ASSERT)
1808 assertLayoutTreeUpdated(*this); 1808 assertLayoutTreeUpdated(*this);
1809 #endif 1809 #endif
1810 } 1810 }
1811 1811
1812 void Document::updateStyle(StyleRecalcChange change) 1812 void Document::updateStyle(StyleRecalcChange change)
1813 { 1813 {
1814 if (view()->shouldThrottleRendering()) 1814 ASSERT(!view()->shouldThrottleRendering());
1815 return;
1816
1817 TRACE_EVENT_BEGIN0("blink,blink_style", "Document::updateStyle"); 1815 TRACE_EVENT_BEGIN0("blink,blink_style", "Document::updateStyle");
1818 unsigned initialElementCount = styleEngine().styleForElementCount(); 1816 unsigned initialElementCount = styleEngine().styleForElementCount();
1819 1817
1820 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; 1818 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates;
1821 m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc); 1819 m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc);
1822 1820
1823 NthIndexCache nthIndexCache(*this); 1821 NthIndexCache nthIndexCache(*this);
1824 1822
1825 if (styleChangeType() >= SubtreeStyleChange) 1823 if (styleChangeType() >= SubtreeStyleChange)
1826 change = Force; 1824 change = Force;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1910 return true; 1908 return true;
1911 } 1909 }
1912 return false; 1910 return false;
1913 } 1911 }
1914 1912
1915 void Document::updateLayoutTreeForNodeIfNeeded(Node* node) 1913 void Document::updateLayoutTreeForNodeIfNeeded(Node* node)
1916 { 1914 {
1917 ASSERT(node); 1915 ASSERT(node);
1918 if (!needsLayoutTreeUpdateForNode(*node)) 1916 if (!needsLayoutTreeUpdateForNode(*node))
1919 return; 1917 return;
1920 DocumentLifecycle::PreventThrottlingScope preventThrottling(lifecycle());
1921 updateLayoutTreeIfNeeded(); 1918 updateLayoutTreeIfNeeded();
1922 } 1919 }
1923 1920
1924 void Document::updateLayout() 1921 void Document::updateLayout()
1925 { 1922 {
1926 ASSERT(isMainThread()); 1923 ASSERT(isMainThread());
1927 1924
1928 ScriptForbiddenScope forbidScript; 1925 ScriptForbiddenScope forbidScript;
1929 1926
1930 RefPtrWillBeRawPtr<FrameView> frameView = view(); 1927 RefPtrWillBeRawPtr<FrameView> frameView = view();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1995 1992
1996 // FIXME: This is a bad idea and needs to be removed eventually. 1993 // FIXME: This is a bad idea and needs to be removed eventually.
1997 // Other browsers load stylesheets before they continue parsing the web page. 1994 // Other browsers load stylesheets before they continue parsing the web page.
1998 // Since we don't, we can run JavaScript code that needs answers before the 1995 // Since we don't, we can run JavaScript code that needs answers before the
1999 // stylesheets are loaded. Doing a layout ignoring the pending stylesheets 1996 // stylesheets are loaded. Doing a layout ignoring the pending stylesheets
2000 // lets us get reasonable answers. The long term solution to this problem is 1997 // lets us get reasonable answers. The long term solution to this problem is
2001 // to instead suspend JavaScript execution. 1998 // to instead suspend JavaScript execution.
2002 void Document::updateLayoutTreeIgnorePendingStylesheets() 1999 void Document::updateLayoutTreeIgnorePendingStylesheets()
2003 { 2000 {
2004 StyleEngine::IgnoringPendingStylesheet ignoring(styleEngine()); 2001 StyleEngine::IgnoringPendingStylesheet ignoring(styleEngine());
2005 DocumentLifecycle::PreventThrottlingScope preventThrottling(lifecycle());
2006 2002
2007 if (styleEngine().hasPendingSheets()) { 2003 if (styleEngine().hasPendingSheets()) {
2008 // FIXME: We are willing to attempt to suppress painting with outdated s tyle info only once. 2004 // FIXME: We are willing to attempt to suppress painting with outdated s tyle info only once.
2009 // Our assumption is that it would be dangerous to try to stop it a seco nd time, after page 2005 // Our assumption is that it would be dangerous to try to stop it a seco nd time, after page
2010 // content has already been loaded and displayed with accurate style inf ormation. (Our 2006 // content has already been loaded and displayed with accurate style inf ormation. (Our
2011 // suppression involves blanking the whole page at the moment. If it wer e more refined, we 2007 // suppression involves blanking the whole page at the moment. If it wer e more refined, we
2012 // might be able to do something better.) It's worth noting though that this entire method 2008 // might be able to do something better.) It's worth noting though that this entire method
2013 // is a hack, since what we really want to do is suspend JS instead of d oing a layout with 2009 // is a hack, since what we really want to do is suspend JS instead of d oing a layout with
2014 // inaccurate information. 2010 // inaccurate information.
2015 HTMLElement* bodyElement = body(); 2011 HTMLElement* bodyElement = body();
2016 if (bodyElement && !bodyElement->layoutObject() && m_pendingSheetLayout == NoLayoutWithPendingSheets) { 2012 if (bodyElement && !bodyElement->layoutObject() && m_pendingSheetLayout == NoLayoutWithPendingSheets) {
2017 m_pendingSheetLayout = DidLayoutWithPendingSheets; 2013 m_pendingSheetLayout = DidLayoutWithPendingSheets;
2018 styleResolverChanged(); 2014 styleResolverChanged();
2019 } else if (m_hasNodesWithPlaceholderStyle) { 2015 } else if (m_hasNodesWithPlaceholderStyle) {
2020 // If new nodes have been added or style recalc has been done with s tyle sheets still 2016 // If new nodes have been added or style recalc has been done with s tyle sheets still
2021 // pending, some nodes may not have had their real style calculated yet. Normally this 2017 // pending, some nodes may not have had their real style calculated yet. Normally this
2022 // gets cleaned when style sheets arrive but here we need up-to-date style immediately. 2018 // gets cleaned when style sheets arrive but here we need up-to-date style immediately.
2023 updateLayoutTree(Force); 2019 updateLayoutTree(Force);
2024 } 2020 }
2025 } 2021 }
2026 updateLayoutTreeIfNeeded(); 2022 updateLayoutTreeIfNeeded();
2027 } 2023 }
2028 2024
2029 void Document::updateLayoutIgnorePendingStylesheets(Document::RunPostLayoutTasks runPostLayoutTasks) 2025 void Document::updateLayoutIgnorePendingStylesheets(Document::RunPostLayoutTasks runPostLayoutTasks)
2030 { 2026 {
2031 DocumentLifecycle::PreventThrottlingScope preventThrottling(lifecycle());
2032
2033 updateLayoutTreeIgnorePendingStylesheets(); 2027 updateLayoutTreeIgnorePendingStylesheets();
2034 updateLayout(); 2028 updateLayout();
2035 2029
2036 if (runPostLayoutTasks == RunPostLayoutTasksSynchronously && view()) 2030 if (runPostLayoutTasks == RunPostLayoutTasksSynchronously && view())
2037 view()->flushAnyPendingPostLayoutTasks(); 2031 view()->flushAnyPendingPostLayoutTasks();
2038 } 2032 }
2039 2033
2040 PassRefPtr<ComputedStyle> Document::styleForElementIgnoringPendingStylesheets(El ement* element) 2034 PassRefPtr<ComputedStyle> Document::styleForElementIgnoringPendingStylesheets(El ement* element)
2041 { 2035 {
2042 ASSERT_ARG(element, element->document() == this); 2036 ASSERT_ARG(element, element->document() == this);
(...skipping 3908 matching lines...) Expand 10 before | Expand all | Expand 10 after
5951 #ifndef NDEBUG 5945 #ifndef NDEBUG
5952 using namespace blink; 5946 using namespace blink;
5953 void showLiveDocumentInstances() 5947 void showLiveDocumentInstances()
5954 { 5948 {
5955 Document::WeakDocumentSet& set = Document::liveDocumentSet(); 5949 Document::WeakDocumentSet& set = Document::liveDocumentSet();
5956 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5950 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5957 for (Document* document : set) 5951 for (Document* document : set)
5958 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); 5952 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data());
5959 } 5953 }
5960 #endif 5954 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/DocumentLifecycle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698