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

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

Issue 1156273002: Add assert that updateLayoutTree clears dirty bits. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add a comment. Created 5 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 1693 matching lines...) Expand 10 before | Expand all | Expand 10 after
1704 body->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonF orTracing::create(StyleChangeReason::WritingModeChange)); 1704 body->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonF orTracing::create(StyleChangeReason::WritingModeChange));
1705 } 1705 }
1706 } 1706 }
1707 1707
1708 if (const ComputedStyle* style = documentElement()->computedStyle()) { 1708 if (const ComputedStyle* style = documentElement()->computedStyle()) {
1709 if (style->direction() != rootDirection || style->writingMode() != rootW ritingMode) 1709 if (style->direction() != rootDirection || style->writingMode() != rootW ritingMode)
1710 documentElement()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChan geReasonForTracing::create(StyleChangeReason::WritingModeChange)); 1710 documentElement()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChan geReasonForTracing::create(StyleChangeReason::WritingModeChange));
1711 } 1711 }
1712 } 1712 }
1713 1713
1714 #if ENABLE(ASSERT)
1715 static void assertLayoutTreeUpdated(Node& root)
1716 {
1717 for (Node& node : NodeTraversal::inclusiveDescendantsOf(root)) {
1718 // We leave some nodes with dirty bits in the tree because they don't
1719 // matter like Comment and ProcessingInstruction nodes.
1720 // TODO(esprehn): Don't even mark those nodes as needing recalcs in the
1721 // first place.
1722 if (!node.isElementNode()
1723 && !node.isTextNode()
1724 && !node.isShadowRoot()
1725 && !node.isDocumentNode())
1726 continue;
1727 ASSERT(!node.needsStyleRecalc());
1728 ASSERT(!node.childNeedsStyleRecalc());
1729 ASSERT(!node.childNeedsDistributionRecalc());
1730 ASSERT(!node.needsStyleInvalidation());
1731 ASSERT(!node.childNeedsStyleInvalidation());
1732 for (ShadowRoot* shadowRoot = node.youngestShadowRoot(); shadowRoot; sha dowRoot = shadowRoot->olderShadowRoot())
1733 assertLayoutTreeUpdated(*shadowRoot);
1734 }
1735 }
1736 #endif
1737
1714 void Document::updateLayoutTree(StyleRecalcChange change) 1738 void Document::updateLayoutTree(StyleRecalcChange change)
1715 { 1739 {
1716 ASSERT(isMainThread()); 1740 ASSERT(isMainThread());
1717 1741
1718 ScriptForbiddenScope forbidScript; 1742 ScriptForbiddenScope forbidScript;
1719 1743
1720 if (!view() || !isActive()) 1744 if (!view() || !isActive())
1721 return; 1745 return;
1722 1746
1723 if (change != Force && !needsLayoutTreeUpdate()) 1747 if (change != Force && !needsLayoutTreeUpdate())
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1771 frame()->eventHandler().dispatchFakeMouseMoveEventSoon(); 1795 frame()->eventHandler().dispatchFakeMouseMoveEventSoon();
1772 1796
1773 if (m_focusedElement && !m_focusedElement->isFocusable()) 1797 if (m_focusedElement && !m_focusedElement->isFocusable())
1774 clearFocusedElementSoon(); 1798 clearFocusedElementSoon();
1775 layoutView()->clearHitTestCache(); 1799 layoutView()->clearHitTestCache();
1776 1800
1777 ASSERT(!m_timeline->hasOutdatedAnimation()); 1801 ASSERT(!m_timeline->hasOutdatedAnimation());
1778 1802
1779 TRACE_EVENT_END1("blink,devtools.timeline", "UpdateLayoutTree", "elementCoun t", m_styleRecalcElementCounter); 1803 TRACE_EVENT_END1("blink,devtools.timeline", "UpdateLayoutTree", "elementCoun t", m_styleRecalcElementCounter);
1780 InspectorInstrumentation::didRecalculateStyle(cookie, m_styleRecalcElementCo unter); 1804 InspectorInstrumentation::didRecalculateStyle(cookie, m_styleRecalcElementCo unter);
1805
1806 #if ENABLE(ASSERT)
1807 assertLayoutTreeUpdated(*this);
1808 #endif
1781 } 1809 }
1782 1810
1783 void Document::updateStyle(StyleRecalcChange change) 1811 void Document::updateStyle(StyleRecalcChange change)
1784 { 1812 {
1785 TRACE_EVENT_BEGIN0("blink,blink_style", "Document::updateStyle"); 1813 TRACE_EVENT_BEGIN0("blink,blink_style", "Document::updateStyle");
1786 unsigned initialResolverAccessCount = styleEngine().resolverAccessCount(); 1814 unsigned initialResolverAccessCount = styleEngine().resolverAccessCount();
1787 1815
1788 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; 1816 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates;
1789 m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc); 1817 m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc);
1790 1818
(...skipping 3948 matching lines...) Expand 10 before | Expand all | Expand 10 after
5739 #ifndef NDEBUG 5767 #ifndef NDEBUG
5740 using namespace blink; 5768 using namespace blink;
5741 void showLiveDocumentInstances() 5769 void showLiveDocumentInstances()
5742 { 5770 {
5743 WeakDocumentSet& set = liveDocumentSet(); 5771 WeakDocumentSet& set = liveDocumentSet();
5744 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5772 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5745 for (Document* document : set) 5773 for (Document* document : set)
5746 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); 5774 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data());
5747 } 5775 }
5748 #endif 5776 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698