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

Side by Side Diff: sky/engine/core/dom/Document.cpp

Issue 838003008: Get rid of ensureStyleResolver(). (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 | « sky/engine/core/dom/Document.h ('k') | sky/engine/core/dom/Element.cpp » ('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 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 1054
1055 void Document::updateStyle(StyleRecalcChange change) 1055 void Document::updateStyle(StyleRecalcChange change)
1056 { 1056 {
1057 TRACE_EVENT0("blink", "Document::updateStyle"); 1057 TRACE_EVENT0("blink", "Document::updateStyle");
1058 1058
1059 m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc); 1059 m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc);
1060 1060
1061 if (styleChangeType() >= SubtreeStyleChange) 1061 if (styleChangeType() >= SubtreeStyleChange)
1062 change = Force; 1062 change = Force;
1063 1063
1064 // FIXME: Cannot access the ensureStyleResolver() before calling styleForDoc ument below because 1064 // FIXME: Cannot access the styleResolver() before calling styleForDocument below because
1065 // apparently the StyleResolver's constructor has side effects. We should fi x it. 1065 // apparently the StyleResolver's constructor has side effects. We should fi x it.
1066 // See printing/setPrinting.html, printing/width-overflow.html though they o nly fail on 1066 // See printing/setPrinting.html, printing/width-overflow.html though they o nly fail on
1067 // mac when accessing the resolver by what appears to be a viewport size dif ference. 1067 // mac when accessing the resolver by what appears to be a viewport size dif ference.
1068 1068
1069 if (change == Force) { 1069 if (change == Force) {
1070 RefPtr<RenderStyle> documentStyle = StyleResolver::styleForDocument(*thi s); 1070 RefPtr<RenderStyle> documentStyle = StyleResolver::styleForDocument(*thi s);
1071 StyleRecalcChange localChange = RenderStyle::stylePropagationDiff(docume ntStyle.get(), renderView()->style()); 1071 StyleRecalcChange localChange = RenderStyle::stylePropagationDiff(docume ntStyle.get(), renderView()->style());
1072 if (localChange != NoChange) 1072 if (localChange != NoChange)
1073 renderView()->setStyle(documentStyle.release()); 1073 renderView()->setStyle(documentStyle.release());
1074 } 1074 }
1075 1075
1076 clearNeedsStyleRecalc(); 1076 clearNeedsStyleRecalc();
1077 1077
1078 // Uncomment to enable printing of statistics about style sharing and the ma tched property cache. 1078 // Uncomment to enable printing of statistics about style sharing and the ma tched property cache.
1079 // Optionally pass StyleResolver::ReportSlowStats to print numbers that requ ire crawling the 1079 // Optionally pass StyleResolver::ReportSlowStats to print numbers that requ ire crawling the
1080 // entire DOM (where collecting them is very slow). 1080 // entire DOM (where collecting them is very slow).
1081 // FIXME: Expose this as a runtime flag. 1081 // FIXME: Expose this as a runtime flag.
1082 // ensureStyleResolver().enableStats(/*StyleResolver::ReportSlowStats*/); 1082 // styleResolver().enableStats(/*StyleResolver::ReportSlowStats*/);
1083 1083
1084 if (StyleResolverStats* stats = ensureStyleResolver().stats()) 1084 if (StyleResolverStats* stats = styleResolver().stats())
1085 stats->reset(); 1085 stats->reset();
1086 1086
1087 if (Element* documentElement = this->documentElement()) { 1087 if (Element* documentElement = this->documentElement()) {
1088 if (documentElement->shouldCallRecalcStyle(change)) 1088 if (documentElement->shouldCallRecalcStyle(change))
1089 documentElement->recalcStyle(change); 1089 documentElement->recalcStyle(change);
1090 } 1090 }
1091 1091
1092 ensureStyleResolver().printStats(); 1092 styleResolver().printStats();
1093 1093
1094 view()->recalcOverflowAfterStyleChange(); 1094 view()->recalcOverflowAfterStyleChange();
1095 1095
1096 clearChildNeedsStyleRecalc(); 1096 clearChildNeedsStyleRecalc();
1097 1097
1098 m_styleEngine->resolver().clearStyleSharingList(); 1098 m_styleEngine->resolver().clearStyleSharingList();
1099 1099
1100 ASSERT(!needsStyleRecalc()); 1100 ASSERT(!needsStyleRecalc());
1101 ASSERT(!childNeedsStyleRecalc()); 1101 ASSERT(!childNeedsStyleRecalc());
1102 ASSERT(inStyleRecalc()); 1102 ASSERT(inStyleRecalc());
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 1152
1153 void Document::clearFocusedElementTimerFired(Timer<Document>*) 1153 void Document::clearFocusedElementTimerFired(Timer<Document>*)
1154 { 1154 {
1155 updateRenderTreeIfNeeded(); 1155 updateRenderTreeIfNeeded();
1156 m_clearFocusedElementTimer.stop(); 1156 m_clearFocusedElementTimer.stop();
1157 1157
1158 if (m_focusedElement && !m_focusedElement->isFocusable()) 1158 if (m_focusedElement && !m_focusedElement->isFocusable())
1159 m_focusedElement->blur(); 1159 m_focusedElement->blur();
1160 } 1160 }
1161 1161
1162 StyleResolver* Document::styleResolver() const 1162 StyleResolver& Document::styleResolver() const
1163 {
1164 if (!isActive())
1165 return 0;
1166 return &m_styleEngine->resolver();
1167 }
1168
1169 StyleResolver& Document::ensureStyleResolver() const
1170 { 1163 {
1171 ASSERT(isActive()); 1164 ASSERT(isActive());
1172 return m_styleEngine->resolver(); 1165 return m_styleEngine->resolver();
1173 } 1166 }
1174 1167
1175 void Document::attach(const AttachContext& context) 1168 void Document::attach(const AttachContext& context)
1176 { 1169 {
1177 ASSERT(m_lifecycle.state() == DocumentLifecycle::Inactive); 1170 ASSERT(m_lifecycle.state() == DocumentLifecycle::Inactive);
1178 1171
1179 m_styleEngine = StyleEngine::create(*this); 1172 m_styleEngine = StyleEngine::create(*this);
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
1577 if (m_mediaQueryMatcher) 1570 if (m_mediaQueryMatcher)
1578 m_mediaQueryMatcher->mediaFeaturesChanged(); 1571 m_mediaQueryMatcher->mediaFeaturesChanged();
1579 } 1572 }
1580 1573
1581 void Document::notifyResizeForViewportUnits() 1574 void Document::notifyResizeForViewportUnits()
1582 { 1575 {
1583 if (m_mediaQueryMatcher) 1576 if (m_mediaQueryMatcher)
1584 m_mediaQueryMatcher->viewportChanged(); 1577 m_mediaQueryMatcher->viewportChanged();
1585 if (!hasViewportUnits()) 1578 if (!hasViewportUnits())
1586 return; 1579 return;
1587 ensureStyleResolver().notifyResizeForViewportUnits(); 1580 styleResolver().notifyResizeForViewportUnits();
1588 setNeedsStyleRecalcForViewportUnits(); 1581 setNeedsStyleRecalcForViewportUnits();
1589 } 1582 }
1590 1583
1591 void Document::styleResolverChanged() 1584 void Document::styleResolverChanged()
1592 { 1585 {
1593 // styleResolverChanged() can be invoked during Document destruction. 1586 // styleResolverChanged() can be invoked during Document destruction.
1594 // We just skip that case. 1587 // We just skip that case.
1595 if (!m_styleEngine) 1588 if (!m_styleEngine)
1596 return; 1589 return;
1597 m_styleEngine->resolverChanged(); 1590 m_styleEngine->resolverChanged();
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
2638 using namespace blink; 2631 using namespace blink;
2639 void showLiveDocumentInstances() 2632 void showLiveDocumentInstances()
2640 { 2633 {
2641 WeakDocumentSet& set = liveDocumentSet(); 2634 WeakDocumentSet& set = liveDocumentSet();
2642 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 2635 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
2643 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) { 2636 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) {
2644 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data()); 2637 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data());
2645 } 2638 }
2646 } 2639 }
2647 #endif 2640 #endif
OLDNEW
« no previous file with comments | « sky/engine/core/dom/Document.h ('k') | sky/engine/core/dom/Element.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698