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

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

Issue 150423004: Move Document::m_inStyleRecalc into DocumentLifecycle (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rename state Created 6 years, 10 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 | « Source/core/dom/Document.h ('k') | Source/core/dom/DocumentLifecycle.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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 , m_didPostCheckFocusedElementTask(false) 447 , m_didPostCheckFocusedElementTask(false)
448 , m_hasAutofocused(false) 448 , m_hasAutofocused(false)
449 , m_domTreeVersion(++s_globalTreeVersion) 449 , m_domTreeVersion(++s_globalTreeVersion)
450 , m_listenerTypes(0) 450 , m_listenerTypes(0)
451 , m_mutationObserverTypes(0) 451 , m_mutationObserverTypes(0)
452 , m_visitedLinkState(VisitedLinkState::create(*this)) 452 , m_visitedLinkState(VisitedLinkState::create(*this))
453 , m_visuallyOrdered(false) 453 , m_visuallyOrdered(false)
454 , m_readyState(Complete) 454 , m_readyState(Complete)
455 , m_bParsing(false) 455 , m_bParsing(false)
456 , m_hasPendingStyleRecalc(false) 456 , m_hasPendingStyleRecalc(false)
457 , m_inStyleRecalc(false)
458 , m_gotoAnchorNeededAfterStylesheetsLoad(false) 457 , m_gotoAnchorNeededAfterStylesheetsLoad(false)
459 , m_containsValidityStyleRules(false) 458 , m_containsValidityStyleRules(false)
460 , m_updateFocusAppearanceRestoresSelection(false) 459 , m_updateFocusAppearanceRestoresSelection(false)
461 , m_containsPlugins(false) 460 , m_containsPlugins(false)
462 , m_ignoreDestructiveWriteCount(0) 461 , m_ignoreDestructiveWriteCount(0)
463 , m_titleSetExplicitly(false) 462 , m_titleSetExplicitly(false)
464 , m_markers(adoptPtr(new DocumentMarkerController)) 463 , m_markers(adoptPtr(new DocumentMarkerController))
465 , m_updateFocusAppearanceTimer(this, &Document::updateFocusAppearanceTimerFi red) 464 , m_updateFocusAppearanceTimer(this, &Document::updateFocusAppearanceTimerFi red)
466 , m_cssTarget(0) 465 , m_cssTarget(0)
467 , m_loadEventProgress(LoadEventNotRun) 466 , m_loadEventProgress(LoadEventNotRun)
(...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1599 } 1598 }
1600 1599
1601 void Document::unscheduleStyleRecalc() 1600 void Document::unscheduleStyleRecalc()
1602 { 1601 {
1603 ASSERT(!isActive() || (!needsStyleRecalc() && !childNeedsStyleRecalc())); 1602 ASSERT(!isActive() || (!needsStyleRecalc() && !childNeedsStyleRecalc()));
1604 m_hasPendingStyleRecalc = false; 1603 m_hasPendingStyleRecalc = false;
1605 } 1604 }
1606 1605
1607 bool Document::hasPendingForcedStyleRecalc() const 1606 bool Document::hasPendingForcedStyleRecalc() const
1608 { 1607 {
1609 return m_hasPendingStyleRecalc && !m_inStyleRecalc && styleChangeType() >= S ubtreeStyleChange; 1608 return m_hasPendingStyleRecalc && !inStyleRecalc() && styleChangeType() >= S ubtreeStyleChange;
1610 } 1609 }
1611 1610
1612 void Document::updateDistributionIfNeeded() 1611 void Document::updateDistributionIfNeeded()
1613 { 1612 {
1614 if (!childNeedsDistributionRecalc()) 1613 if (!childNeedsDistributionRecalc())
1615 return; 1614 return;
1616 TRACE_EVENT0("webkit", "Document::recalcDistribution"); 1615 TRACE_EVENT0("webkit", "Document::recalcDistribution");
1617 recalcDistribution(); 1616 recalcDistribution();
1618 } 1617 }
1619 1618
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1707 1706
1708 void Document::recalcStyle(StyleRecalcChange change) 1707 void Document::recalcStyle(StyleRecalcChange change)
1709 { 1708 {
1710 // we should not enter style recalc while painting 1709 // we should not enter style recalc while painting
1711 RELEASE_ASSERT(!view() || !view()->isPainting()); 1710 RELEASE_ASSERT(!view() || !view()->isPainting());
1712 1711
1713 // FIXME: We should never enter here without a FrameView or with an inactive document. 1712 // FIXME: We should never enter here without a FrameView or with an inactive document.
1714 if (!isActive() || !view()) 1713 if (!isActive() || !view())
1715 return; 1714 return;
1716 1715
1717 if (m_inStyleRecalc) 1716 if (inStyleRecalc())
1718 return; 1717 return;
1719 1718
1720 TRACE_EVENT0("webkit", "Document::recalcStyle"); 1719 TRACE_EVENT0("webkit", "Document::recalcStyle");
1721 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "RecalcStyle"); 1720 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "RecalcStyle");
1722 1721
1723 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalc ulateStyle(this); 1722 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalc ulateStyle(this);
1724 1723
1725 updateDistributionIfNeeded(); 1724 updateDistributionIfNeeded();
1726 updateUseShadowTrees(); 1725 updateUseShadowTrees();
1727 1726
1728 if (m_evaluateMediaQueriesOnStyleRecalc) { 1727 if (m_evaluateMediaQueriesOnStyleRecalc) {
1729 m_evaluateMediaQueriesOnStyleRecalc = false; 1728 m_evaluateMediaQueriesOnStyleRecalc = false;
1730 evaluateMediaQueryList(); 1729 evaluateMediaQueryList();
1731 } 1730 }
1732 1731
1733 // FIXME: We should update style on our ancestor chain before proceeding 1732 // FIXME: We should update style on our ancestor chain before proceeding
1734 // however doing so currently causes several tests to crash, as Frame::setDo cument calls Document::attach 1733 // however doing so currently causes several tests to crash, as Frame::setDo cument calls Document::attach
1735 // before setting the DOMWindow on the Frame, or the SecurityOrigin on the d ocument. The attach, in turn 1734 // before setting the DOMWindow on the Frame, or the SecurityOrigin on the d ocument. The attach, in turn
1736 // resolves style (here) and then when we resolve style on the parent chain, we may end up 1735 // resolves style (here) and then when we resolve style on the parent chain, we may end up
1737 // re-attaching our containing iframe, which when asked HTMLFrameElementBase ::isURLAllowed 1736 // re-attaching our containing iframe, which when asked HTMLFrameElementBase ::isURLAllowed
1738 // hits a null-dereference due to security code always assuming the document has a SecurityOrigin. 1737 // hits a null-dereference due to security code always assuming the document has a SecurityOrigin.
1739 1738
1740 if (m_elemSheet && m_elemSheet->contents()->usesRemUnits()) 1739 if (m_elemSheet && m_elemSheet->contents()->usesRemUnits())
1741 m_styleEngine->setUsesRemUnit(true); 1740 m_styleEngine->setUsesRemUnit(true);
1742 1741
1743 { 1742 {
1744 PostAttachCallbacks::SuspendScope suspendPostAttachCallbacks; 1743 PostAttachCallbacks::SuspendScope suspendPostAttachCallbacks;
1745 RenderWidget::UpdateSuspendScope suspendWidgetHierarchyUpdates; 1744 RenderWidget::UpdateSuspendScope suspendWidgetHierarchyUpdates;
1746 TemporaryChange<bool> changeInStyleRecalc(m_inStyleRecalc, true); 1745 m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc);
1747 1746
1748 if (styleChangeType() >= SubtreeStyleChange) 1747 if (styleChangeType() >= SubtreeStyleChange)
1749 change = Force; 1748 change = Force;
1750 1749
1751 // FIXME: Cannot access the ensureStyleResolver() before calling styleFo rDocument below because 1750 // FIXME: Cannot access the ensureStyleResolver() before calling styleFo rDocument below because
1752 // apparently the StyleResolver's constructor has side effects. We shoul d fix it. 1751 // apparently the StyleResolver's constructor has side effects. We shoul d fix it.
1753 // See printing/setPrinting.html, printing/width-overflow.html though th ey only fail on 1752 // See printing/setPrinting.html, printing/width-overflow.html though th ey only fail on
1754 // mac when accessing the resolver by what appears to be a viewport size difference. 1753 // mac when accessing the resolver by what appears to be a viewport size difference.
1755 1754
1756 if (change == Force) { 1755 if (change == Force) {
(...skipping 27 matching lines...) Expand all
1784 1783
1785 clearChildNeedsStyleRecalc(); 1784 clearChildNeedsStyleRecalc();
1786 unscheduleStyleRecalc(); 1785 unscheduleStyleRecalc();
1787 1786
1788 if (m_styleEngine->hasResolver()) { 1787 if (m_styleEngine->hasResolver()) {
1789 // Pseudo element removal and similar may only work with these flags still set. Reset them after the style recalc. 1788 // Pseudo element removal and similar may only work with these flags still set. Reset them after the style recalc.
1790 StyleResolver& resolver = m_styleEngine->ensureResolver(); 1789 StyleResolver& resolver = m_styleEngine->ensureResolver();
1791 m_styleEngine->resetCSSFeatureFlags(resolver.ensureRuleFeatureSet()) ; 1790 m_styleEngine->resetCSSFeatureFlags(resolver.ensureRuleFeatureSet()) ;
1792 resolver.clearStyleSharingList(); 1791 resolver.clearStyleSharingList();
1793 } 1792 }
1793
1794 ASSERT(inStyleRecalc());
1795 m_lifecycle.advanceTo(DocumentLifecycle::Clean);
1794 } 1796 }
1795 1797
1796 InspectorInstrumentation::didRecalculateStyle(cookie); 1798 InspectorInstrumentation::didRecalculateStyle(cookie);
1797 1799
1798 // As a result of the style recalculation, the currently hovered element mig ht have been 1800 // As a result of the style recalculation, the currently hovered element mig ht have been
1799 // detached (for example, by setting display:none in the :hover style), sche dule another mouseMove event 1801 // detached (for example, by setting display:none in the :hover style), sche dule another mouseMove event
1800 // to check if any other elements ended up under the mouse pointer due to re -layout. 1802 // to check if any other elements ended up under the mouse pointer due to re -layout.
1801 if (hoverNode() && !hoverNode()->renderer() && frame()) 1803 if (hoverNode() && !hoverNode()->renderer() && frame())
1802 frame()->eventHandler().dispatchFakeMouseMoveEventSoon(); 1804 frame()->eventHandler().dispatchFakeMouseMoveEventSoon();
1803 } 1805 }
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
2057 setRenderer(m_renderView); 2059 setRenderer(m_renderView);
2058 2060
2059 m_renderView->setIsInWindow(true); 2061 m_renderView->setIsInWindow(true);
2060 m_renderView->setStyle(StyleResolver::styleForDocument(*this)); 2062 m_renderView->setStyle(StyleResolver::styleForDocument(*this));
2061 view()->updateCompositingLayersAfterStyleChange(); 2063 view()->updateCompositingLayersAfterStyleChange();
2062 2064
2063 m_styleEngine->didAttach(); 2065 m_styleEngine->didAttach();
2064 2066
2065 ContainerNode::attach(context); 2067 ContainerNode::attach(context);
2066 2068
2067 m_lifecycle.advanceTo(DocumentLifecycle::Active); 2069 m_lifecycle.advanceTo(DocumentLifecycle::Clean);
2068 } 2070 }
2069 2071
2070 void Document::detach(const AttachContext& context) 2072 void Document::detach(const AttachContext& context)
2071 { 2073 {
2072 ASSERT(isActive()); 2074 ASSERT(isActive());
2073 m_lifecycle.advanceTo(DocumentLifecycle::Stopping); 2075 m_lifecycle.advanceTo(DocumentLifecycle::Stopping);
2074 2076
2075 if (page()) 2077 if (page())
2076 page()->documentDetached(this); 2078 page()->documentDetached(this);
2077 2079
(...skipping 3300 matching lines...) Expand 10 before | Expand all | Expand 10 after
5378 if (!page->focusController().isActive() || !page->focusController().isFocuse d()) 5380 if (!page->focusController().isActive() || !page->focusController().isFocuse d())
5379 return false; 5381 return false;
5380 if (Frame* focusedFrame = page->focusController().focusedFrame()) { 5382 if (Frame* focusedFrame = page->focusController().focusedFrame()) {
5381 if (focusedFrame->tree().isDescendantOf(frame())) 5383 if (focusedFrame->tree().isDescendantOf(frame()))
5382 return true; 5384 return true;
5383 } 5385 }
5384 return false; 5386 return false;
5385 } 5387 }
5386 5388
5387 } // namespace WebCore 5389 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/DocumentLifecycle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698