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

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

Issue 129633003: Add a first pass of a class descendant invalidator, and a containing RuleSetAnalyzer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Implement tree walk for descendant class invalidation. Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/Element.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 1520 matching lines...) Expand 10 before | Expand all | Expand 10 after
1531 } 1531 }
1532 1532
1533 void Document::updateDistributionIfNeeded() 1533 void Document::updateDistributionIfNeeded()
1534 { 1534 {
1535 if (!childNeedsDistributionRecalc()) 1535 if (!childNeedsDistributionRecalc())
1536 return; 1536 return;
1537 TRACE_EVENT0("webkit", "Document::recalcDistribution"); 1537 TRACE_EVENT0("webkit", "Document::recalcDistribution");
1538 recalcDistribution(); 1538 recalcDistribution();
1539 } 1539 }
1540 1540
1541 void Document::updateInvalidationIfNeeded()
1542 {
1543 if (!childNeedsInvalidation())
1544 return;
1545 TRACE_EVENT0("webkit", "Document::recalcInvalidation");
1546 if (!styleResolver()) {
1547 clearChildNeedsInvalidation();
1548 return;
1549 }
1550
1551 if (RuleSetAnalyzer* analyzer = styleResolver()->ensureRuleFeatureSet().getR uleSetAnalyzer())
1552 analyzer->recalcInvalidation(this);
1553 }
1554
1541 void Document::updateDistributionForNodeIfNeeded(Node* node) 1555 void Document::updateDistributionForNodeIfNeeded(Node* node)
1542 { 1556 {
1543 if (node->inDocument()) { 1557 if (node->inDocument()) {
1544 updateDistributionIfNeeded(); 1558 updateDistributionIfNeeded();
1545 return; 1559 return;
1546 } 1560 }
1547 Node* root = node; 1561 Node* root = node;
1548 while (Node* host = root->shadowHost()) 1562 while (Node* host = root->shadowHost())
1549 root = host; 1563 root = host;
1550 while (Node* ancestor = root->parentOrShadowHostNode()) 1564 while (Node* ancestor = root->parentOrShadowHostNode())
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1610 if (style->direction() != rootDirection || style->writingMode() != r ootWritingMode) 1624 if (style->direction() != rootDirection || style->writingMode() != r ootWritingMode)
1611 body->setNeedsStyleRecalc(); 1625 body->setNeedsStyleRecalc();
1612 } 1626 }
1613 } 1627 }
1614 1628
1615 if (RenderStyle* style = documentElement()->renderStyle()) { 1629 if (RenderStyle* style = documentElement()->renderStyle()) {
1616 if (style->direction() != rootDirection || style->writingMode() != rootW ritingMode) 1630 if (style->direction() != rootDirection || style->writingMode() != rootW ritingMode)
1617 documentElement()->setNeedsStyleRecalc(); 1631 documentElement()->setNeedsStyleRecalc();
1618 } 1632 }
1619 } 1633 }
1634 static bool debug = false;
1620 1635
1621 void Document::recalcStyle(StyleRecalcChange change) 1636 void Document::recalcStyle(StyleRecalcChange change)
1622 { 1637 {
1623 // we should not enter style recalc while painting 1638 // we should not enter style recalc while painting
1624 RELEASE_ASSERT(!view() || !view()->isPainting()); 1639 RELEASE_ASSERT(!view() || !view()->isPainting());
1640 if (debug)
1641 printf("----------------- Document::recalcStyle\n");
1642 // FIXME: We should never enter here without a FrameView or with an inactive document.
1643 if (!isActive() || !view()) {
1644 if (debug)
1645 printf("document::recalcstyle...not active or view?\n");
1646 return;
1647 }
1625 1648
1626 // FIXME: We should never enter here without a FrameView or with an inactive document. 1649 if (m_inStyleRecalc) {
1627 if (!isActive() || !view()) 1650 if (debug)
1651 printf("document::recalcstyle...m_inStyleRecalc is true?\n");
1628 return; 1652 return;
1629 1653 }
1630 if (m_inStyleRecalc)
1631 return;
1632 1654
1633 TRACE_EVENT0("webkit", "Document::recalcStyle"); 1655 TRACE_EVENT0("webkit", "Document::recalcStyle");
1634 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "RecalcStyle"); 1656 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "RecalcStyle");
1635 1657
1658 updateInvalidationIfNeeded();
1659
1636 updateDistributionIfNeeded(); 1660 updateDistributionIfNeeded();
1637 1661
1638 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalc ulateStyle(this); 1662 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalc ulateStyle(this);
1639 1663
1640 if (m_evaluateMediaQueriesOnStyleRecalc) { 1664 if (m_evaluateMediaQueriesOnStyleRecalc) {
1641 m_evaluateMediaQueriesOnStyleRecalc = false; 1665 m_evaluateMediaQueriesOnStyleRecalc = false;
1642 evaluateMediaQueryList(); 1666 evaluateMediaQueryList();
1643 } 1667 }
1644 1668
1645 // FIXME: We should update style on our ancestor chain before proceeding (es pecially for seamless), 1669 // FIXME: We should update style on our ancestor chain before proceeding (es pecially for seamless),
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1714 } 1738 }
1715 } 1739 }
1716 1740
1717 InspectorInstrumentation::didRecalculateStyle(cookie); 1741 InspectorInstrumentation::didRecalculateStyle(cookie);
1718 1742
1719 // As a result of the style recalculation, the currently hovered element mig ht have been 1743 // As a result of the style recalculation, the currently hovered element mig ht have been
1720 // detached (for example, by setting display:none in the :hover style), sche dule another mouseMove event 1744 // detached (for example, by setting display:none in the :hover style), sche dule another mouseMove event
1721 // to check if any other elements ended up under the mouse pointer due to re -layout. 1745 // to check if any other elements ended up under the mouse pointer due to re -layout.
1722 if (hoverNode() && !hoverNode()->renderer() && frame()) 1746 if (hoverNode() && !hoverNode()->renderer() && frame())
1723 frame()->eventHandler().dispatchFakeMouseMoveEventSoon(); 1747 frame()->eventHandler().dispatchFakeMouseMoveEventSoon();
1748 if (debug)
1749 printf("********************** Document::recalcStyle DONE\n\n");
1724 } 1750 }
1725 1751
1752
1726 void Document::updateStyleIfNeeded() 1753 void Document::updateStyleIfNeeded()
1727 { 1754 {
1728 ASSERT(isMainThread()); 1755 ASSERT(isMainThread());
1729 ASSERT(!view() || (!view()->isInLayout() && !view()->isPainting())); 1756 ASSERT(!view() || (!view()->isInLayout() && !view()->isPainting()));
1730 1757
1731 if (!needsStyleRecalc() && !childNeedsStyleRecalc() && !childNeedsDistributi onRecalc()) 1758 // FIXME: unify this logic with shouldRecalcStyle()
1759 if (!needsStyleRecalc() && !childNeedsStyleRecalc() && !childNeedsDistributi onRecalc() && !childNeedsInvalidation())
1732 return; 1760 return;
1733 1761
1734 RefPtr<Frame> holder(m_frame); 1762 RefPtr<Frame> holder(m_frame);
1735 AnimationUpdateBlock animationUpdateBlock(m_frame ? &m_frame->animation() : 0); 1763 AnimationUpdateBlock animationUpdateBlock(m_frame ? &m_frame->animation() : 0);
1736 recalcStyle(NoChange); 1764 recalcStyle(NoChange);
1737 DocumentAnimations::serviceAfterStyleRecalc(*this); 1765 DocumentAnimations::serviceAfterStyleRecalc(*this);
1738 } 1766 }
1739 1767
1740 void Document::updateStyleForNodeIfNeeded(Node* node) 1768 void Document::updateStyleForNodeIfNeeded(Node* node)
1741 { 1769 {
1742 if (!hasPendingForcedStyleRecalc() && !childNeedsStyleRecalc() && !needsStyl eRecalc()) 1770 if (debug)
1771 printf("Document::updateStyleForNodeIfNeeded\n");
1772 // FIXME: Why is this different than updateStyleIfNeeded???
1773 if (!hasPendingForcedStyleRecalc() && !childNeedsStyleRecalc() && !needsStyl eRecalc() && !childNeedsInvalidation())
1743 return; 1774 return;
1744 1775
1745 bool needsStyleRecalc = hasPendingForcedStyleRecalc(); 1776 bool needsStyleRecalc = hasPendingForcedStyleRecalc();
1746 for (Node* ancestor = node; ancestor && !needsStyleRecalc; ancestor = ancest or->parentOrShadowHostNode()) 1777 for (Node* ancestor = node; ancestor && !needsStyleRecalc; ancestor = ancest or->parentOrShadowHostNode())
1747 needsStyleRecalc = ancestor->needsStyleRecalc(); 1778 needsStyleRecalc = ancestor->needsStyleRecalc() || ancestor->needsInvali dation();
1748 if (needsStyleRecalc) 1779 if (needsStyleRecalc) {
1780 if (debug)
1781 printf("updateStyleForNodeIfNeeded calls updateStyleIfNeeded\n");
1749 updateStyleIfNeeded(); 1782 updateStyleIfNeeded();
1783 }
1750 } 1784 }
1751 1785
1752 void Document::updateLayout() 1786 void Document::updateLayout()
1753 { 1787 {
1754 ASSERT(isMainThread()); 1788 ASSERT(isMainThread());
1755 1789
1756 RefPtr<FrameView> frameView = view(); 1790 RefPtr<FrameView> frameView = view();
1757 if (frameView && frameView->isInLayout()) { 1791 if (frameView && frameView->isInLayout()) {
1758 // View layout should not be re-entrant. 1792 // View layout should not be re-entrant.
1759 ASSERT_NOT_REACHED(); 1793 ASSERT_NOT_REACHED();
(...skipping 3488 matching lines...) Expand 10 before | Expand all | Expand 10 after
5248 } 5282 }
5249 5283
5250 FastTextAutosizer* Document::fastTextAutosizer() 5284 FastTextAutosizer* Document::fastTextAutosizer()
5251 { 5285 {
5252 if (!m_fastTextAutosizer && RuntimeEnabledFeatures::fastTextAutosizingEnable d()) 5286 if (!m_fastTextAutosizer && RuntimeEnabledFeatures::fastTextAutosizingEnable d())
5253 m_fastTextAutosizer = FastTextAutosizer::create(this); 5287 m_fastTextAutosizer = FastTextAutosizer::create(this);
5254 return m_fastTextAutosizer.get(); 5288 return m_fastTextAutosizer.get();
5255 } 5289 }
5256 5290
5257 } // namespace WebCore 5291 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/Element.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698