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

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: reasons as tuple 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 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 setEncodingData(newEncodingData); 1193 setEncodingData(newEncodingData);
1194 } 1194 }
1195 1195
1196 void Document::setContentLanguage(const AtomicString& language) 1196 void Document::setContentLanguage(const AtomicString& language)
1197 { 1197 {
1198 if (m_contentLanguage == language) 1198 if (m_contentLanguage == language)
1199 return; 1199 return;
1200 m_contentLanguage = language; 1200 m_contentLanguage = language;
1201 1201
1202 // Document's style depends on the content language. 1202 // Document's style depends on the content language.
1203 setNeedsStyleRecalc(SubtreeStyleChange); 1203 setNeedsStyleRecalc(StyleChangeReasonForTracing::create(StyleChangeReason::L anguage), SubtreeStyleChange);
1204 } 1204 }
1205 1205
1206 void Document::setXMLVersion(const String& version, ExceptionState& exceptionSta te) 1206 void Document::setXMLVersion(const String& version, ExceptionState& exceptionSta te)
1207 { 1207 {
1208 if (!XMLDocumentParser::supportsXMLVersion(version)) { 1208 if (!XMLDocumentParser::supportsXMLVersion(version)) {
1209 exceptionState.throwDOMException(NotSupportedError, "This document does not support the XML version '" + version + "'."); 1209 exceptionState.throwDOMException(NotSupportedError, "This document does not support the XML version '" + version + "'.");
1210 return; 1210 return;
1211 } 1211 }
1212 1212
1213 m_xmlVersion = version; 1213 m_xmlVersion = version;
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 1703
1704 // Resolved rem units are stored in the matched properties cache so we need to make sure to 1704 // Resolved rem units are stored in the matched properties cache so we need to make sure to
1705 // invalidate the cache if the documentElement needed to reattach or the fon t size changed 1705 // invalidate the cache if the documentElement needed to reattach or the fon t size changed
1706 // and then trigger a full document recalc. We also need to clear it here si nce the 1706 // and then trigger a full document recalc. We also need to clear it here si nce the
1707 // call to styleForElement on the body above can cache bad values for rem un its if the 1707 // call to styleForElement on the body above can cache bad values for rem un its if the
1708 // documentElement's style was dirty. We could keep track of which elements depend on 1708 // documentElement's style was dirty. We could keep track of which elements depend on
1709 // rem units like we do for viewport styles, but we assume root font size ch anges are 1709 // rem units like we do for viewport styles, but we assume root font size ch anges are
1710 // rare and just invalidate the cache for now. 1710 // rare and just invalidate the cache for now.
1711 if (styleEngine()->usesRemUnits() && (documentElement()->needsAttach() || do cumentElement()->computedStyle()->fontSize() != documentElementStyle->fontSize() )) { 1711 if (styleEngine()->usesRemUnits() && (documentElement()->needsAttach() || do cumentElement()->computedStyle()->fontSize() != documentElementStyle->fontSize() )) {
1712 ensureStyleResolver().invalidateMatchedPropertiesCache(); 1712 ensureStyleResolver().invalidateMatchedPropertiesCache();
1713 documentElement()->setNeedsStyleRecalc(SubtreeStyleChange); 1713 documentElement()->setNeedsStyleRecalc(StyleChangeReasonForTracing::crea te(StyleChangeReason::FontSizeChange), SubtreeStyleChange);
1714 } 1714 }
1715 1715
1716 EOverflow overflowX = OAUTO; 1716 EOverflow overflowX = OAUTO;
1717 EOverflow overflowY = OAUTO; 1717 EOverflow overflowY = OAUTO;
1718 float columnGap = 0; 1718 float columnGap = 0;
1719 if (overflowStyle) { 1719 if (overflowStyle) {
1720 overflowX = overflowStyle->overflowX(); 1720 overflowX = overflowStyle->overflowX();
1721 overflowY = overflowStyle->overflowY(); 1721 overflowY = overflowStyle->overflowY();
1722 // Visible overflow on the viewport is meaningless, and the spec says to treat it as 'auto': 1722 // Visible overflow on the viewport is meaningless, and the spec says to treat it as 'auto':
1723 if (overflowX == OVISIBLE) 1723 if (overflowX == OVISIBLE)
(...skipping 17 matching lines...) Expand all
1741 newStyle->setColumnGap(columnGap); 1741 newStyle->setColumnGap(columnGap);
1742 newStyle->setOverflowX(overflowX); 1742 newStyle->setOverflowX(overflowX);
1743 newStyle->setOverflowY(overflowY); 1743 newStyle->setOverflowY(overflowY);
1744 renderView()->setStyle(newStyle); 1744 renderView()->setStyle(newStyle);
1745 setupFontBuilder(newStyle.get()); 1745 setupFontBuilder(newStyle.get());
1746 } 1746 }
1747 1747
1748 if (body) { 1748 if (body) {
1749 if (RenderStyle* style = body->renderStyle()) { 1749 if (RenderStyle* style = body->renderStyle()) {
1750 if (style->direction() != rootDirection || style->writingMode() != r ootWritingMode) 1750 if (style->direction() != rootDirection || style->writingMode() != r ootWritingMode)
1751 body->setNeedsStyleRecalc(SubtreeStyleChange); 1751 body->setNeedsStyleRecalc(StyleChangeReasonForTracing::create(St yleChangeReason::WritingModeChange), SubtreeStyleChange);
1752 } 1752 }
1753 } 1753 }
1754 1754
1755 if (RenderStyle* style = documentElement()->renderStyle()) { 1755 if (RenderStyle* style = documentElement()->renderStyle()) {
1756 if (style->direction() != rootDirection || style->writingMode() != rootW ritingMode) 1756 if (style->direction() != rootDirection || style->writingMode() != rootW ritingMode)
1757 documentElement()->setNeedsStyleRecalc(SubtreeStyleChange); 1757 documentElement()->setNeedsStyleRecalc(StyleChangeReasonForTracing:: create(StyleChangeReason::WritingModeChange), SubtreeStyleChange);
1758 } 1758 }
1759 } 1759 }
1760 1760
1761 void Document::updateRenderTree(StyleRecalcChange change) 1761 void Document::updateRenderTree(StyleRecalcChange change)
1762 { 1762 {
1763 ASSERT(isMainThread()); 1763 ASSERT(isMainThread());
1764 1764
1765 ScriptForbiddenScope forbidScript; 1765 ScriptForbiddenScope forbidScript;
1766 1766
1767 if (!view() || !isActive()) 1767 if (!view() || !isActive())
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1930 1930
1931 if (frameView->needsLayout()) 1931 if (frameView->needsLayout())
1932 frameView->layout(); 1932 frameView->layout();
1933 1933
1934 if (lifecycle().state() < DocumentLifecycle::LayoutClean) 1934 if (lifecycle().state() < DocumentLifecycle::LayoutClean)
1935 lifecycle().advanceTo(DocumentLifecycle::LayoutClean); 1935 lifecycle().advanceTo(DocumentLifecycle::LayoutClean);
1936 } 1936 }
1937 1937
1938 void Document::setNeedsFocusedElementCheck() 1938 void Document::setNeedsFocusedElementCheck()
1939 { 1939 {
1940 setNeedsStyleRecalc(LocalStyleChange); 1940 setNeedsStyleRecalc(StyleChangeReasonForTracing::createWithExtraData(StyleCh angeReason::PseudoClass, StyleChangeExtraData::Focus), LocalStyleChange);
1941 } 1941 }
1942 1942
1943 void Document::clearFocusedElementSoon() 1943 void Document::clearFocusedElementSoon()
1944 { 1944 {
1945 if (!m_clearFocusedElementTimer.isActive()) 1945 if (!m_clearFocusedElementTimer.isActive())
1946 m_clearFocusedElementTimer.startOneShot(0, FROM_HERE); 1946 m_clearFocusedElementTimer.startOneShot(0, FROM_HERE);
1947 } 1947 }
1948 1948
1949 void Document::clearFocusedElementTimerFired(Timer<Document>*) 1949 void Document::clearFocusedElementTimerFired(Timer<Document>*)
1950 { 1950 {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2056 setSecurityOrigin(SecurityOrigin::createUnique()); 2056 setSecurityOrigin(SecurityOrigin::createUnique());
2057 didUpdateSecurityOrigin(); 2057 didUpdateSecurityOrigin();
2058 } 2058 }
2059 2059
2060 bool Document::dirtyElementsForLayerUpdate() 2060 bool Document::dirtyElementsForLayerUpdate()
2061 { 2061 {
2062 if (m_layerUpdateSVGFilterElements.isEmpty()) 2062 if (m_layerUpdateSVGFilterElements.isEmpty())
2063 return false; 2063 return false;
2064 2064
2065 for (WillBeHeapHashSet<RawPtrWillBeMember<Element> >::iterator it = m_layerU pdateSVGFilterElements.begin(), end = m_layerUpdateSVGFilterElements.end(); it ! = end; ++it) 2065 for (WillBeHeapHashSet<RawPtrWillBeMember<Element> >::iterator it = m_layerU pdateSVGFilterElements.begin(), end = m_layerUpdateSVGFilterElements.end(); it ! = end; ++it)
2066 (*it)->setNeedsStyleRecalc(LocalStyleChange); 2066 (*it)->setNeedsStyleRecalc(StyleChangeReasonForTracing::create(StyleChan geReason::SVGFilterLayerUpdate), LocalStyleChange);
2067 m_layerUpdateSVGFilterElements.clear(); 2067 m_layerUpdateSVGFilterElements.clear();
2068 return true; 2068 return true;
2069 } 2069 }
2070 2070
2071 void Document::scheduleSVGFilterLayerUpdateHack(Element& element) 2071 void Document::scheduleSVGFilterLayerUpdateHack(Element& element)
2072 { 2072 {
2073 if (element.styleChangeType() == NeedsReattachStyleChange) 2073 if (element.styleChangeType() == NeedsReattachStyleChange)
2074 return; 2074 return;
2075 element.setSVGFilterNeedsLayerUpdate(); 2075 element.setSVGFilterNeedsLayerUpdate();
2076 m_layerUpdateSVGFilterElements.add(&element); 2076 m_layerUpdateSVGFilterElements.add(&element);
(...skipping 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after
3642 SetFocusedElementDone: 3642 SetFocusedElementDone:
3643 updateRenderTreeIfNeeded(); 3643 updateRenderTreeIfNeeded();
3644 if (LocalFrame* frame = this->frame()) 3644 if (LocalFrame* frame = this->frame())
3645 frame->selection().didChangeFocus(); 3645 frame->selection().didChangeFocus();
3646 return !focusChangeBlocked; 3646 return !focusChangeBlocked;
3647 } 3647 }
3648 3648
3649 void Document::setCSSTarget(Element* newTarget) 3649 void Document::setCSSTarget(Element* newTarget)
3650 { 3650 {
3651 if (m_cssTarget) 3651 if (m_cssTarget)
3652 m_cssTarget->didAffectSelector(AffectedSelectorTarget); 3652 m_cssTarget->didAffectSelector(StyleChangeReasonForTracing::createWithEx traData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Target), AffectedS electorTarget);
3653 m_cssTarget = newTarget; 3653 m_cssTarget = newTarget;
3654 if (m_cssTarget) 3654 if (m_cssTarget)
3655 m_cssTarget->didAffectSelector(AffectedSelectorTarget); 3655 m_cssTarget->didAffectSelector(StyleChangeReasonForTracing::createWithEx traData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Target), AffectedS electorTarget);
3656 } 3656 }
3657 3657
3658 void Document::registerNodeList(const LiveNodeListBase* list) 3658 void Document::registerNodeList(const LiveNodeListBase* list)
3659 { 3659 {
3660 #if ENABLE(OILPAN) 3660 #if ENABLE(OILPAN)
3661 m_nodeLists[list->invalidationType()].add(list); 3661 m_nodeLists[list->invalidationType()].add(list);
3662 #else 3662 #else
3663 m_nodeListCounts[list->invalidationType()]++; 3663 m_nodeListCounts[list->invalidationType()]++;
3664 #endif 3664 #endif
3665 if (list->isRootedAtDocument()) 3665 if (list->isRootedAtDocument())
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
4301 4301
4302 m_encodingData = newData; 4302 m_encodingData = newData;
4303 4303
4304 // FIXME: Should be removed as part of https://code.google.com/p/chromium/is sues/detail?id=319643 4304 // FIXME: Should be removed as part of https://code.google.com/p/chromium/is sues/detail?id=319643
4305 bool shouldUseVisualOrdering = m_encodingData.encoding().usesVisualOrdering( ); 4305 bool shouldUseVisualOrdering = m_encodingData.encoding().usesVisualOrdering( );
4306 if (shouldUseVisualOrdering != m_visuallyOrdered) { 4306 if (shouldUseVisualOrdering != m_visuallyOrdered) {
4307 m_visuallyOrdered = shouldUseVisualOrdering; 4307 m_visuallyOrdered = shouldUseVisualOrdering;
4308 // FIXME: How is possible to not have a renderer here? 4308 // FIXME: How is possible to not have a renderer here?
4309 if (renderView()) 4309 if (renderView())
4310 renderView()->style()->setRTLOrdering(m_visuallyOrdered ? VisualOrde r : LogicalOrder); 4310 renderView()->style()->setRTLOrdering(m_visuallyOrdered ? VisualOrde r : LogicalOrder);
4311 setNeedsStyleRecalc(SubtreeStyleChange); 4311 setNeedsStyleRecalc(StyleChangeReasonForTracing::create(StyleChangeReaso n::VisuallyOrdered), SubtreeStyleChange);
4312 } 4312 }
4313 } 4313 }
4314 4314
4315 KURL Document::completeURL(const String& url) const 4315 KURL Document::completeURL(const String& url) const
4316 { 4316 {
4317 return completeURLWithOverride(url, m_baseURL); 4317 return completeURLWithOverride(url, m_baseURL);
4318 } 4318 }
4319 4319
4320 KURL Document::completeURLWithOverride(const String& url, const KURL& baseURLOve rride) const 4320 KURL Document::completeURLWithOverride(const String& url, const KURL& baseURLOve rride) const
4321 { 4321 {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
4463 } 4463 }
4464 4464
4465 void Document::setDesignMode(InheritedBool value) 4465 void Document::setDesignMode(InheritedBool value)
4466 { 4466 {
4467 m_designMode = value; 4467 m_designMode = value;
4468 for (Frame* frame = m_frame; frame; frame = frame->tree().traverseNext(m_fra me)) { 4468 for (Frame* frame = m_frame; frame; frame = frame->tree().traverseNext(m_fra me)) {
4469 if (!frame->isLocalFrame()) 4469 if (!frame->isLocalFrame())
4470 continue; 4470 continue;
4471 if (!toLocalFrame(frame)->document()) 4471 if (!toLocalFrame(frame)->document())
4472 break; 4472 break;
4473 toLocalFrame(frame)->document()->setNeedsStyleRecalc(SubtreeStyleChange) ; 4473 toLocalFrame(frame)->document()->setNeedsStyleRecalc(StyleChangeReasonFo rTracing::create(StyleChangeReason::DesignMode), SubtreeStyleChange);
4474 } 4474 }
4475 } 4475 }
4476 4476
4477 Document::InheritedBool Document::getDesignMode() const 4477 Document::InheritedBool Document::getDesignMode() const
4478 { 4478 {
4479 return m_designMode; 4479 return m_designMode;
4480 } 4480 }
4481 4481
4482 bool Document::inDesignMode() const 4482 bool Document::inDesignMode() const
4483 { 4483 {
(...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after
5852 using namespace blink; 5852 using namespace blink;
5853 void showLiveDocumentInstances() 5853 void showLiveDocumentInstances()
5854 { 5854 {
5855 WeakDocumentSet& set = liveDocumentSet(); 5855 WeakDocumentSet& set = liveDocumentSet();
5856 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5856 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5857 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) { 5857 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) {
5858 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data()); 5858 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data());
5859 } 5859 }
5860 } 5860 }
5861 #endif 5861 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698