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

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

Issue 547823002: Track reasons for |Node::SetNeedsStyleRecalc| (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 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
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 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 setEncodingData(newEncodingData); 1198 setEncodingData(newEncodingData);
1199 } 1199 }
1200 1200
1201 void Document::setContentLanguage(const AtomicString& language) 1201 void Document::setContentLanguage(const AtomicString& language)
1202 { 1202 {
1203 if (m_contentLanguage == language) 1203 if (m_contentLanguage == language)
1204 return; 1204 return;
1205 m_contentLanguage = language; 1205 m_contentLanguage = language;
1206 1206
1207 // Document's style depends on the content language. 1207 // Document's style depends on the content language.
1208 setNeedsStyleRecalc(SubtreeStyleChange); 1208 setNeedsStyleRecalc(StyleRecalcDueToLanguage, SubtreeStyleChange);
1209 } 1209 }
1210 1210
1211 void Document::setXMLVersion(const String& version, ExceptionState& exceptionSta te) 1211 void Document::setXMLVersion(const String& version, ExceptionState& exceptionSta te)
1212 { 1212 {
1213 if (!XMLDocumentParser::supportsXMLVersion(version)) { 1213 if (!XMLDocumentParser::supportsXMLVersion(version)) {
1214 exceptionState.throwDOMException(NotSupportedError, "This document does not support the XML version '" + version + "'."); 1214 exceptionState.throwDOMException(NotSupportedError, "This document does not support the XML version '" + version + "'.");
1215 return; 1215 return;
1216 } 1216 }
1217 1217
1218 m_xmlVersion = version; 1218 m_xmlVersion = version;
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1729 1729
1730 // Resolved rem units are stored in the matched properties cache so we need to make sure to 1730 // Resolved rem units are stored in the matched properties cache so we need to make sure to
1731 // invalidate the cache if the documentElement needed to reattach or the fon t size changed 1731 // invalidate the cache if the documentElement needed to reattach or the fon t size changed
1732 // and then trigger a full document recalc. We also need to clear it here si nce the 1732 // and then trigger a full document recalc. We also need to clear it here si nce the
1733 // call to styleForElement on the body above can cache bad values for rem un its if the 1733 // call to styleForElement on the body above can cache bad values for rem un its if the
1734 // documentElement's style was dirty. We could keep track of which elements depend on 1734 // documentElement's style was dirty. We could keep track of which elements depend on
1735 // rem units like we do for viewport styles, but we assume root font size ch anges are 1735 // rem units like we do for viewport styles, but we assume root font size ch anges are
1736 // rare and just invalidate the cache for now. 1736 // rare and just invalidate the cache for now.
1737 if (styleEngine()->usesRemUnits() && (documentElement()->needsAttach() || do cumentElement()->computedStyle()->fontSize() != documentElementStyle->fontSize() )) { 1737 if (styleEngine()->usesRemUnits() && (documentElement()->needsAttach() || do cumentElement()->computedStyle()->fontSize() != documentElementStyle->fontSize() )) {
1738 ensureStyleResolver().invalidateMatchedPropertiesCache(); 1738 ensureStyleResolver().invalidateMatchedPropertiesCache();
1739 documentElement()->setNeedsStyleRecalc(SubtreeStyleChange); 1739 documentElement()->setNeedsStyleRecalc(StyleRecalcDueToFontSizeChange, S ubtreeStyleChange);
1740 } 1740 }
1741 1741
1742 EOverflow overflowX = OAUTO; 1742 EOverflow overflowX = OAUTO;
1743 EOverflow overflowY = OAUTO; 1743 EOverflow overflowY = OAUTO;
1744 float columnGap = 0; 1744 float columnGap = 0;
1745 if (overflowStyle) { 1745 if (overflowStyle) {
1746 overflowX = overflowStyle->overflowX(); 1746 overflowX = overflowStyle->overflowX();
1747 overflowY = overflowStyle->overflowY(); 1747 overflowY = overflowStyle->overflowY();
1748 // Visible overflow on the viewport is meaningless, and the spec says to treat it as 'auto': 1748 // Visible overflow on the viewport is meaningless, and the spec says to treat it as 'auto':
1749 if (overflowX == OVISIBLE) 1749 if (overflowX == OVISIBLE)
(...skipping 17 matching lines...) Expand all
1767 newStyle->setColumnGap(columnGap); 1767 newStyle->setColumnGap(columnGap);
1768 newStyle->setOverflowX(overflowX); 1768 newStyle->setOverflowX(overflowX);
1769 newStyle->setOverflowY(overflowY); 1769 newStyle->setOverflowY(overflowY);
1770 renderView()->setStyle(newStyle); 1770 renderView()->setStyle(newStyle);
1771 setupFontBuilder(newStyle.get()); 1771 setupFontBuilder(newStyle.get());
1772 } 1772 }
1773 1773
1774 if (body) { 1774 if (body) {
1775 if (RenderStyle* style = body->renderStyle()) { 1775 if (RenderStyle* style = body->renderStyle()) {
1776 if (style->direction() != rootDirection || style->writingMode() != r ootWritingMode) 1776 if (style->direction() != rootDirection || style->writingMode() != r ootWritingMode)
1777 body->setNeedsStyleRecalc(SubtreeStyleChange); 1777 body->setNeedsStyleRecalc(StyleRecalcDueToWritingModeChange, Sub treeStyleChange);
1778 } 1778 }
1779 } 1779 }
1780 1780
1781 if (RenderStyle* style = documentElement()->renderStyle()) { 1781 if (RenderStyle* style = documentElement()->renderStyle()) {
1782 if (style->direction() != rootDirection || style->writingMode() != rootW ritingMode) 1782 if (style->direction() != rootDirection || style->writingMode() != rootW ritingMode)
1783 documentElement()->setNeedsStyleRecalc(SubtreeStyleChange); 1783 documentElement()->setNeedsStyleRecalc(StyleRecalcDueToWritingModeCh ange, SubtreeStyleChange);
1784 } 1784 }
1785 } 1785 }
1786 1786
1787 void Document::updateRenderTree(StyleRecalcChange change) 1787 void Document::updateRenderTree(StyleRecalcChange change)
1788 { 1788 {
1789 ASSERT(isMainThread()); 1789 ASSERT(isMainThread());
1790 1790
1791 ScriptForbiddenScope forbidScript; 1791 ScriptForbiddenScope forbidScript;
1792 1792
1793 if (!view() || !isActive()) 1793 if (!view() || !isActive())
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1956 1956
1957 if (frameView->needsLayout()) 1957 if (frameView->needsLayout())
1958 frameView->layout(); 1958 frameView->layout();
1959 1959
1960 if (lifecycle().state() < DocumentLifecycle::LayoutClean) 1960 if (lifecycle().state() < DocumentLifecycle::LayoutClean)
1961 lifecycle().advanceTo(DocumentLifecycle::LayoutClean); 1961 lifecycle().advanceTo(DocumentLifecycle::LayoutClean);
1962 } 1962 }
1963 1963
1964 void Document::setNeedsFocusedElementCheck() 1964 void Document::setNeedsFocusedElementCheck()
1965 { 1965 {
1966 setNeedsStyleRecalc(LocalStyleChange); 1966 setNeedsStyleRecalc(StyleRecalcDueToFocusPseudoClass, LocalStyleChange);
1967 } 1967 }
1968 1968
1969 void Document::clearFocusedElementSoon() 1969 void Document::clearFocusedElementSoon()
1970 { 1970 {
1971 if (!m_clearFocusedElementTimer.isActive()) 1971 if (!m_clearFocusedElementTimer.isActive())
1972 m_clearFocusedElementTimer.startOneShot(0, FROM_HERE); 1972 m_clearFocusedElementTimer.startOneShot(0, FROM_HERE);
1973 } 1973 }
1974 1974
1975 void Document::clearFocusedElementTimerFired(Timer<Document>*) 1975 void Document::clearFocusedElementTimerFired(Timer<Document>*)
1976 { 1976 {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2082 setSecurityOrigin(SecurityOrigin::createUnique()); 2082 setSecurityOrigin(SecurityOrigin::createUnique());
2083 didUpdateSecurityOrigin(); 2083 didUpdateSecurityOrigin();
2084 } 2084 }
2085 2085
2086 bool Document::dirtyElementsForLayerUpdate() 2086 bool Document::dirtyElementsForLayerUpdate()
2087 { 2087 {
2088 if (m_layerUpdateSVGFilterElements.isEmpty()) 2088 if (m_layerUpdateSVGFilterElements.isEmpty())
2089 return false; 2089 return false;
2090 2090
2091 for (WillBeHeapHashSet<RawPtrWillBeMember<Element> >::iterator it = m_layerU pdateSVGFilterElements.begin(), end = m_layerUpdateSVGFilterElements.end(); it ! = end; ++it) 2091 for (WillBeHeapHashSet<RawPtrWillBeMember<Element> >::iterator it = m_layerU pdateSVGFilterElements.begin(), end = m_layerUpdateSVGFilterElements.end(); it ! = end; ++it)
2092 (*it)->setNeedsStyleRecalc(LocalStyleChange); 2092 (*it)->setNeedsStyleRecalc(StyleRecalcDueToSVGFilterLayerUpdateHack, Loc alStyleChange);
pdr. 2014/09/06 22:36:27 We should probably just call this one StyleRecalcD
kouhei (in TOK) 2014/09/08 23:29:12 Done.
2093 m_layerUpdateSVGFilterElements.clear(); 2093 m_layerUpdateSVGFilterElements.clear();
2094 return true; 2094 return true;
2095 } 2095 }
2096 2096
2097 void Document::scheduleSVGFilterLayerUpdateHack(Element& element) 2097 void Document::scheduleSVGFilterLayerUpdateHack(Element& element)
2098 { 2098 {
2099 if (element.styleChangeType() == NeedsReattachStyleChange) 2099 if (element.styleChangeType() == NeedsReattachStyleChange)
2100 return; 2100 return;
2101 element.setSVGFilterNeedsLayerUpdate(); 2101 element.setSVGFilterNeedsLayerUpdate();
2102 m_layerUpdateSVGFilterElements.add(&element); 2102 m_layerUpdateSVGFilterElements.add(&element);
(...skipping 2205 matching lines...) Expand 10 before | Expand all | Expand 10 after
4308 4308
4309 m_encodingData = newData; 4309 m_encodingData = newData;
4310 4310
4311 // FIXME: Should be removed as part of https://code.google.com/p/chromium/is sues/detail?id=319643 4311 // FIXME: Should be removed as part of https://code.google.com/p/chromium/is sues/detail?id=319643
4312 bool shouldUseVisualOrdering = m_encodingData.encoding().usesVisualOrdering( ); 4312 bool shouldUseVisualOrdering = m_encodingData.encoding().usesVisualOrdering( );
4313 if (shouldUseVisualOrdering != m_visuallyOrdered) { 4313 if (shouldUseVisualOrdering != m_visuallyOrdered) {
4314 m_visuallyOrdered = shouldUseVisualOrdering; 4314 m_visuallyOrdered = shouldUseVisualOrdering;
4315 // FIXME: How is possible to not have a renderer here? 4315 // FIXME: How is possible to not have a renderer here?
4316 if (renderView()) 4316 if (renderView())
4317 renderView()->style()->setRTLOrdering(m_visuallyOrdered ? VisualOrde r : LogicalOrder); 4317 renderView()->style()->setRTLOrdering(m_visuallyOrdered ? VisualOrde r : LogicalOrder);
4318 setNeedsStyleRecalc(SubtreeStyleChange); 4318 setNeedsStyleRecalc(StyleRecalcDueToVisuallyOrdered, SubtreeStyleChange) ;
4319 } 4319 }
4320 } 4320 }
4321 4321
4322 KURL Document::completeURL(const String& url) const 4322 KURL Document::completeURL(const String& url) const
4323 { 4323 {
4324 return completeURLWithOverride(url, m_baseURL); 4324 return completeURLWithOverride(url, m_baseURL);
4325 } 4325 }
4326 4326
4327 KURL Document::completeURLWithOverride(const String& url, const KURL& baseURLOve rride) const 4327 KURL Document::completeURLWithOverride(const String& url, const KURL& baseURLOve rride) const
4328 { 4328 {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
4470 } 4470 }
4471 4471
4472 void Document::setDesignMode(InheritedBool value) 4472 void Document::setDesignMode(InheritedBool value)
4473 { 4473 {
4474 m_designMode = value; 4474 m_designMode = value;
4475 for (Frame* frame = m_frame; frame; frame = frame->tree().traverseNext(m_fra me)) { 4475 for (Frame* frame = m_frame; frame; frame = frame->tree().traverseNext(m_fra me)) {
4476 if (!frame->isLocalFrame()) 4476 if (!frame->isLocalFrame())
4477 continue; 4477 continue;
4478 if (!toLocalFrame(frame)->document()) 4478 if (!toLocalFrame(frame)->document())
4479 break; 4479 break;
4480 toLocalFrame(frame)->document()->setNeedsStyleRecalc(SubtreeStyleChange) ; 4480 toLocalFrame(frame)->document()->setNeedsStyleRecalc(StyleRecalcDueToDes ignMode, SubtreeStyleChange);
4481 } 4481 }
4482 } 4482 }
4483 4483
4484 Document::InheritedBool Document::getDesignMode() const 4484 Document::InheritedBool Document::getDesignMode() const
4485 { 4485 {
4486 return m_designMode; 4486 return m_designMode;
4487 } 4487 }
4488 4488
4489 bool Document::inDesignMode() const 4489 bool Document::inDesignMode() const
4490 { 4490 {
(...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after
5851 using namespace blink; 5851 using namespace blink;
5852 void showLiveDocumentInstances() 5852 void showLiveDocumentInstances()
5853 { 5853 {
5854 WeakDocumentSet& set = liveDocumentSet(); 5854 WeakDocumentSet& set = liveDocumentSet();
5855 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5855 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5856 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) { 5856 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) {
5857 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data()); 5857 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data());
5858 } 5858 }
5859 } 5859 }
5860 #endif 5860 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698