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

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

Issue 34623009: Revamp style resolver stats (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix stats for mac, crazy StyleResolver constructor side effects Created 7 years, 1 month 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 | « Source/core/css/resolver/StyleResolverStats.cpp ('k') | Source/core/testing/Internals.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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "core/css/CSSDefaultStyleSheets.h" 48 #include "core/css/CSSDefaultStyleSheets.h"
49 #include "core/css/CSSFontSelector.h" 49 #include "core/css/CSSFontSelector.h"
50 #include "core/css/CSSStyleDeclaration.h" 50 #include "core/css/CSSStyleDeclaration.h"
51 #include "core/css/CSSStyleSheet.h" 51 #include "core/css/CSSStyleSheet.h"
52 #include "core/css/MediaQueryMatcher.h" 52 #include "core/css/MediaQueryMatcher.h"
53 #include "core/css/StylePropertySet.h" 53 #include "core/css/StylePropertySet.h"
54 #include "core/css/StyleSheetContents.h" 54 #include "core/css/StyleSheetContents.h"
55 #include "core/css/StyleSheetList.h" 55 #include "core/css/StyleSheetList.h"
56 #include "core/css/resolver/FontBuilder.h" 56 #include "core/css/resolver/FontBuilder.h"
57 #include "core/css/resolver/StyleResolver.h" 57 #include "core/css/resolver/StyleResolver.h"
58 #include "core/css/resolver/StyleResolverStats.h"
58 #include "core/dom/AddConsoleMessageTask.h" 59 #include "core/dom/AddConsoleMessageTask.h"
59 #include "core/dom/Attr.h" 60 #include "core/dom/Attr.h"
60 #include "core/dom/CDATASection.h" 61 #include "core/dom/CDATASection.h"
61 #include "core/dom/Comment.h" 62 #include "core/dom/Comment.h"
62 #include "core/dom/ContextFeatures.h" 63 #include "core/dom/ContextFeatures.h"
63 #include "core/dom/DOMImplementation.h" 64 #include "core/dom/DOMImplementation.h"
64 #include "core/dom/DOMNamedFlowCollection.h" 65 #include "core/dom/DOMNamedFlowCollection.h"
65 #include "core/dom/DocumentFragment.h" 66 #include "core/dom/DocumentFragment.h"
66 #include "core/dom/DocumentLifecycleNotifier.h" 67 #include "core/dom/DocumentLifecycleNotifier.h"
67 #include "core/dom/DocumentLifecycleObserver.h" 68 #include "core/dom/DocumentLifecycleObserver.h"
(...skipping 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after
1684 1685
1685 { 1686 {
1686 PostAttachCallbacks::SuspendScope suspendPostAttachCallbacks; 1687 PostAttachCallbacks::SuspendScope suspendPostAttachCallbacks;
1687 RenderWidget::UpdateSuspendScope suspendWidgetHierarchyUpdates; 1688 RenderWidget::UpdateSuspendScope suspendWidgetHierarchyUpdates;
1688 FrameView::DeferredRepaintScope deferRepaints(*view()); 1689 FrameView::DeferredRepaintScope deferRepaints(*view());
1689 TemporaryChange<bool> changeInStyleRecalc(m_inStyleRecalc, true); 1690 TemporaryChange<bool> changeInStyleRecalc(m_inStyleRecalc, true);
1690 1691
1691 if (styleChangeType() >= SubtreeStyleChange) 1692 if (styleChangeType() >= SubtreeStyleChange)
1692 change = Force; 1693 change = Force;
1693 1694
1695 // FIXME: Cannot access the styleResolver() before calling styleForDocum ent below because
1696 // apparently the StyleResolver's constructor has side effects. We shoul d fix it.
1697 // See printing/setPrinting.html, printing/width-overflow.html though th ey only fail on
1698 // mac when accessing the resolver by what appears to be a viewport size difference.
1699
1694 if (change == Force || (change >= Inherit && shouldDisplaySeamlesslyWith Parent())) { 1700 if (change == Force || (change >= Inherit && shouldDisplaySeamlesslyWith Parent())) {
1695 m_hasNodesWithPlaceholderStyle = false; 1701 m_hasNodesWithPlaceholderStyle = false;
1696 RefPtr<RenderStyle> documentStyle = StyleResolver::styleForDocument( *this, m_styleResolver ? m_styleResolver->fontSelector() : 0); 1702 RefPtr<RenderStyle> documentStyle = StyleResolver::styleForDocument( *this, m_styleResolver ? m_styleResolver->fontSelector() : 0);
1697 StyleRecalcChange localChange = RenderStyle::compare(documentStyle.g et(), renderView()->style()); 1703 StyleRecalcChange localChange = RenderStyle::compare(documentStyle.g et(), renderView()->style());
1698 if (localChange != NoChange) 1704 if (localChange != NoChange)
1699 renderView()->setStyle(documentStyle.release()); 1705 renderView()->setStyle(documentStyle.release());
1700 } 1706 }
1701 1707
1702 clearNeedsStyleRecalc(); 1708 clearNeedsStyleRecalc();
1703 1709
1710 // Uncomment to enable printing of statistics about style sharing and th e matched property cache.
1711 // Optionally pass StyleResolver::ReportSlowStats to print numbers that require crawling the
1712 // entire DOM (where collecting them is very slow).
1713 // FIXME: Expose this as a runtime flag.
1714 // styleResolver()->enableStats(/*StyleResolver::ReportSlowStats*/);
1715
1716 if (StyleResolverStats* stats = styleResolver()->stats())
1717 stats->reset();
1718
1704 if (Element* documentElement = this->documentElement()) { 1719 if (Element* documentElement = this->documentElement()) {
1705 inheritHtmlAndBodyElementStyles(change); 1720 inheritHtmlAndBodyElementStyles(change);
1706 if (shouldRecalcStyle(change, documentElement)) 1721 if (shouldRecalcStyle(change, documentElement))
1707 documentElement->recalcStyle(change); 1722 documentElement->recalcStyle(change);
1708 } 1723 }
1709 1724
1725 styleResolver()->printStats();
1726
1710 view()->updateCompositingLayersAfterStyleChange(); 1727 view()->updateCompositingLayersAfterStyleChange();
1711 1728
1712 clearChildNeedsStyleRecalc(); 1729 clearChildNeedsStyleRecalc();
1713 unscheduleStyleRecalc(); 1730 unscheduleStyleRecalc();
1714 1731
1715 // FIXME: SVG <use> element can schedule a recalc in the middle of an al ready running one. 1732 // FIXME: SVG <use> element can schedule a recalc in the middle of an al ready running one.
1716 // See StyleEngine::updateActiveStyleSheets. 1733 // See StyleEngine::updateActiveStyleSheets.
1717 if (m_styleEngine->needsUpdateActiveStylesheetsOnStyleRecalc()) 1734 if (m_styleEngine->needsUpdateActiveStylesheetsOnStyleRecalc())
1718 setNeedsStyleRecalc(); 1735 setNeedsStyleRecalc();
1719 1736
1720 if (m_styleResolver) { 1737 if (m_styleResolver) {
1721 // Pseudo element removal and similar may only work with these flags still set. Reset them after the style recalc. 1738 // Pseudo element removal and similar may only work with these flags still set. Reset them after the style recalc.
1722 m_styleEngine->resetCSSFeatureFlags(m_styleResolver->ruleFeatureSet( )); 1739 m_styleEngine->resetCSSFeatureFlags(m_styleResolver->ruleFeatureSet( ));
1723 m_styleResolver->clearStyleSharingList(); 1740 m_styleResolver->clearStyleSharingList();
1724 } 1741 }
1725 } 1742 }
1726 1743
1727 STYLE_STATS_PRINT();
1728 STYLE_STATS_CLEAR();
1729
1730 InspectorInstrumentation::didRecalculateStyle(cookie); 1744 InspectorInstrumentation::didRecalculateStyle(cookie);
1731 1745
1732 // As a result of the style recalculation, the currently hovered element mig ht have been 1746 // As a result of the style recalculation, the currently hovered element mig ht have been
1733 // detached (for example, by setting display:none in the :hover style), sche dule another mouseMove event 1747 // detached (for example, by setting display:none in the :hover style), sche dule another mouseMove event
1734 // to check if any other elements ended up under the mouse pointer due to re -layout. 1748 // to check if any other elements ended up under the mouse pointer due to re -layout.
1735 if (hoverNode() && !hoverNode()->renderer() && frame()) 1749 if (hoverNode() && !hoverNode()->renderer() && frame())
1736 frame()->eventHandler().dispatchFakeMouseMoveEventSoon(); 1750 frame()->eventHandler().dispatchFakeMouseMoveEventSoon();
1737 } 1751 }
1738 1752
1739 void Document::updateStyleIfNeeded() 1753 void Document::updateStyleIfNeeded()
(...skipping 3448 matching lines...) Expand 10 before | Expand all | Expand 10 after
5188 void Document::modifiedStyleSheet(StyleSheet* sheet, RecalcStyleTime when, Style ResolverUpdateMode updateMode) 5202 void Document::modifiedStyleSheet(StyleSheet* sheet, RecalcStyleTime when, Style ResolverUpdateMode updateMode)
5189 { 5203 {
5190 if (!isActive()) 5204 if (!isActive())
5191 return; 5205 return;
5192 5206
5193 styleEngine()->modifiedStyleSheet(sheet); 5207 styleEngine()->modifiedStyleSheet(sheet);
5194 styleResolverChanged(when, updateMode); 5208 styleResolverChanged(when, updateMode);
5195 } 5209 }
5196 5210
5197 } // namespace WebCore 5211 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/resolver/StyleResolverStats.cpp ('k') | Source/core/testing/Internals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698