Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 #include "core/dom/MainThreadTaskRunner.h" | 76 #include "core/dom/MainThreadTaskRunner.h" |
| 77 #include "core/dom/MutationObserver.h" | 77 #include "core/dom/MutationObserver.h" |
| 78 #include "core/dom/NodeChildRemovalTracker.h" | 78 #include "core/dom/NodeChildRemovalTracker.h" |
| 79 #include "core/dom/NodeFilter.h" | 79 #include "core/dom/NodeFilter.h" |
| 80 #include "core/dom/NodeIterator.h" | 80 #include "core/dom/NodeIterator.h" |
| 81 #include "core/dom/NodeRareData.h" | 81 #include "core/dom/NodeRareData.h" |
| 82 #include "core/dom/NodeRenderStyle.h" | 82 #include "core/dom/NodeRenderStyle.h" |
| 83 #include "core/dom/NodeRenderingTraversal.h" | 83 #include "core/dom/NodeRenderingTraversal.h" |
| 84 #include "core/dom/NodeTraversal.h" | 84 #include "core/dom/NodeTraversal.h" |
| 85 #include "core/dom/NodeWithIndex.h" | 85 #include "core/dom/NodeWithIndex.h" |
| 86 #include "core/dom/PostAttachCallbacks.h" | |
| 87 #include "core/dom/ProcessingInstruction.h" | 86 #include "core/dom/ProcessingInstruction.h" |
| 88 #include "core/dom/RequestAnimationFrameCallback.h" | 87 #include "core/dom/RequestAnimationFrameCallback.h" |
| 89 #include "core/dom/ScriptRunner.h" | 88 #include "core/dom/ScriptRunner.h" |
| 90 #include "core/dom/ScriptedAnimationController.h" | 89 #include "core/dom/ScriptedAnimationController.h" |
| 91 #include "core/dom/SelectorQuery.h" | 90 #include "core/dom/SelectorQuery.h" |
| 92 #include "core/dom/StyleEngine.h" | 91 #include "core/dom/StyleEngine.h" |
| 93 #include "core/dom/TouchList.h" | 92 #include "core/dom/TouchList.h" |
| 94 #include "core/dom/TransformSource.h" | 93 #include "core/dom/TransformSource.h" |
| 95 #include "core/dom/TreeWalker.h" | 94 #include "core/dom/TreeWalker.h" |
| 96 #include "core/dom/VisitedLinkState.h" | 95 #include "core/dom/VisitedLinkState.h" |
| (...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1526 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node")); | 1525 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node")); |
| 1527 return nullptr; | 1526 return nullptr; |
| 1528 } | 1527 } |
| 1529 return TreeWalker::create(root, whatToShow, filter); | 1528 return TreeWalker::create(root, whatToShow, filter); |
| 1530 } | 1529 } |
| 1531 | 1530 |
| 1532 bool Document::shouldCallRecalcStyleForDocument() | 1531 bool Document::shouldCallRecalcStyleForDocument() |
| 1533 { | 1532 { |
| 1534 if (!isActive() || !view()) | 1533 if (!isActive() || !view()) |
| 1535 return false; | 1534 return false; |
| 1536 return needsStyleRecalc() || childNeedsStyleRecalc() || childNeedsDistributi onRecalc() || !m_useElementsNeedingUpdate.isEmpty() || childNeedsStyleInvalidati on(); | 1535 if (needsStyleRecalc() || childNeedsStyleRecalc()) |
| 1536 return true; | |
| 1537 if (childNeedsDistributionRecalc()) | |
| 1538 return true; | |
| 1539 if (!m_useElementsNeedingUpdate.isEmpty()) | |
| 1540 return true; | |
| 1541 if (!m_layerUpdateElements.isEmpty()) | |
| 1542 return true; | |
| 1543 if (childNeedsStyleInvalidation()) | |
| 1544 return true; | |
| 1545 return false; | |
| 1537 } | 1546 } |
| 1538 | 1547 |
| 1539 bool Document::shouldScheduleStyleRecalc() | 1548 bool Document::shouldScheduleStyleRecalc() |
| 1540 { | 1549 { |
| 1541 if (!isActive()) | 1550 if (!isActive()) |
| 1542 return false; | 1551 return false; |
| 1543 if (hasPendingStyleRecalc()) | 1552 if (hasPendingStyleRecalc()) |
| 1544 return false; | 1553 return false; |
| 1545 if (inStyleRecalc()) | 1554 if (inStyleRecalc()) |
| 1546 return false; | 1555 return false; |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1720 | 1729 |
| 1721 if (inStyleRecalc()) | 1730 if (inStyleRecalc()) |
| 1722 return; | 1731 return; |
| 1723 | 1732 |
| 1724 // Entering here from inside layout or paint would be catastrophic since rec alcStyle can | 1733 // Entering here from inside layout or paint would be catastrophic since rec alcStyle can |
| 1725 // tear down the render tree or (unfortunately) run script. Kill the whole r enderer if | 1734 // tear down the render tree or (unfortunately) run script. Kill the whole r enderer if |
| 1726 // someone managed to get into here from inside layout or paint. | 1735 // someone managed to get into here from inside layout or paint. |
| 1727 RELEASE_ASSERT(!view()->isInPerformLayout()); | 1736 RELEASE_ASSERT(!view()->isInPerformLayout()); |
| 1728 RELEASE_ASSERT(!view()->isPainting()); | 1737 RELEASE_ASSERT(!view()->isPainting()); |
| 1729 | 1738 |
| 1730 // Script can run below in PostAttachCallbacks or WidgetUpdates, so protect the LocalFrame. | 1739 // Script can run below in WidgetUpdates, so protect the LocalFrame. |
| 1731 RefPtr<LocalFrame> protect(m_frame); | 1740 RefPtr<LocalFrame> protect(m_frame); |
| 1732 | 1741 |
| 1733 TRACE_EVENT0("webkit", "Document::recalcStyle"); | 1742 TRACE_EVENT0("webkit", "Document::recalcStyle"); |
| 1734 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "RecalcStyle"); | 1743 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "RecalcStyle"); |
| 1735 | 1744 |
| 1736 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalc ulateStyle(this); | 1745 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalc ulateStyle(this); |
| 1737 | 1746 |
| 1738 updateDistributionIfNeeded(); | 1747 updateDistributionIfNeeded(); |
| 1739 updateUseShadowTreesIfNeeded(); | 1748 updateUseShadowTreesIfNeeded(); |
| 1740 updateStyleInvalidationIfNeeded(); | 1749 updateStyleInvalidationIfNeeded(); |
| 1741 | 1750 |
| 1742 if (m_evaluateMediaQueriesOnStyleRecalc) { | 1751 if (m_evaluateMediaQueriesOnStyleRecalc) { |
| 1743 m_evaluateMediaQueriesOnStyleRecalc = false; | 1752 m_evaluateMediaQueriesOnStyleRecalc = false; |
| 1744 evaluateMediaQueryList(); | 1753 evaluateMediaQueryList(); |
| 1745 } | 1754 } |
| 1746 | 1755 |
| 1747 // FIXME: We should update style on our ancestor chain before proceeding | 1756 // FIXME: We should update style on our ancestor chain before proceeding |
| 1748 // however doing so currently causes several tests to crash, as LocalFrame:: setDocument calls Document::attach | 1757 // however doing so currently causes several tests to crash, as LocalFrame:: setDocument calls Document::attach |
| 1749 // before setting the DOMWindow on the LocalFrame, or the SecurityOrigin on the document. The attach, in turn | 1758 // before setting the DOMWindow on the LocalFrame, or the SecurityOrigin on the document. The attach, in turn |
| 1750 // resolves style (here) and then when we resolve style on the parent chain, we may end up | 1759 // resolves style (here) and then when we resolve style on the parent chain, we may end up |
| 1751 // re-attaching our containing iframe, which when asked HTMLFrameElementBase ::isURLAllowed | 1760 // re-attaching our containing iframe, which when asked HTMLFrameElementBase ::isURLAllowed |
| 1752 // hits a null-dereference due to security code always assuming the document has a SecurityOrigin. | 1761 // hits a null-dereference due to security code always assuming the document has a SecurityOrigin. |
| 1753 | 1762 |
| 1754 if (m_elemSheet && m_elemSheet->contents()->usesRemUnits()) | 1763 if (m_elemSheet && m_elemSheet->contents()->usesRemUnits()) |
| 1755 m_styleEngine->setUsesRemUnit(true); | 1764 m_styleEngine->setUsesRemUnit(true); |
| 1756 | 1765 |
| 1757 { | 1766 { |
| 1758 PostAttachCallbacks::SuspendScope suspendPostAttachCallbacks; | |
| 1759 RenderWidget::UpdateSuspendScope suspendWidgetHierarchyUpdates; | 1767 RenderWidget::UpdateSuspendScope suspendWidgetHierarchyUpdates; |
| 1760 m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc); | 1768 m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc); |
| 1761 | 1769 |
| 1762 if (styleChangeType() >= SubtreeStyleChange) | 1770 if (styleChangeType() >= SubtreeStyleChange) |
| 1763 change = Force; | 1771 change = Force; |
| 1764 | 1772 |
| 1765 // FIXME: Cannot access the ensureStyleResolver() before calling styleFo rDocument below because | 1773 // FIXME: Cannot access the ensureStyleResolver() before calling styleFo rDocument below because |
| 1766 // apparently the StyleResolver's constructor has side effects. We shoul d fix it. | 1774 // apparently the StyleResolver's constructor has side effects. We shoul d fix it. |
| 1767 // See printing/setPrinting.html, printing/width-overflow.html though th ey only fail on | 1775 // See printing/setPrinting.html, printing/width-overflow.html though th ey only fail on |
| 1768 // mac when accessing the resolver by what appears to be a viewport size difference. | 1776 // mac when accessing the resolver by what appears to be a viewport size difference. |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1781 // Optionally pass StyleResolver::ReportSlowStats to print numbers that require crawling the | 1789 // Optionally pass StyleResolver::ReportSlowStats to print numbers that require crawling the |
| 1782 // entire DOM (where collecting them is very slow). | 1790 // entire DOM (where collecting them is very slow). |
| 1783 // FIXME: Expose this as a runtime flag. | 1791 // FIXME: Expose this as a runtime flag. |
| 1784 // ensureStyleResolver().enableStats(/*StyleResolver::ReportSlowStats*/) ; | 1792 // ensureStyleResolver().enableStats(/*StyleResolver::ReportSlowStats*/) ; |
| 1785 | 1793 |
| 1786 if (StyleResolverStats* stats = ensureStyleResolver().stats()) | 1794 if (StyleResolverStats* stats = ensureStyleResolver().stats()) |
| 1787 stats->reset(); | 1795 stats->reset(); |
| 1788 | 1796 |
| 1789 if (Element* documentElement = this->documentElement()) { | 1797 if (Element* documentElement = this->documentElement()) { |
| 1790 inheritHtmlAndBodyElementStyles(change); | 1798 inheritHtmlAndBodyElementStyles(change); |
| 1799 dirtyElementsForLayerUpdate(); | |
| 1791 if (documentElement->shouldCallRecalcStyle(change)) | 1800 if (documentElement->shouldCallRecalcStyle(change)) |
| 1792 documentElement->recalcStyle(change); | 1801 documentElement->recalcStyle(change); |
| 1802 while (dirtyElementsForLayerUpdate()) | |
| 1803 documentElement->recalcStyle(NoChange); | |
|
abarth-chromium
2014/03/24 17:47:09
Can we really spin an arbitrary number of times he
| |
| 1793 } | 1804 } |
| 1794 | 1805 |
| 1795 ensureStyleResolver().printStats(); | 1806 ensureStyleResolver().printStats(); |
| 1796 | 1807 |
| 1797 view()->updateCompositingLayersAfterStyleChange(); | 1808 view()->updateCompositingLayersAfterStyleChange(); |
| 1798 | 1809 |
| 1799 clearChildNeedsStyleRecalc(); | 1810 clearChildNeedsStyleRecalc(); |
| 1800 | 1811 |
| 1801 if (m_styleEngine->hasResolver()) { | 1812 if (m_styleEngine->hasResolver()) { |
| 1802 // Pseudo element removal and similar may only work with these flags still set. Reset them after the style recalc. | 1813 // Pseudo element removal and similar may only work with these flags still set. Reset them after the style recalc. |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1981 void Document::setIsViewSource(bool isViewSource) | 1992 void Document::setIsViewSource(bool isViewSource) |
| 1982 { | 1993 { |
| 1983 m_isViewSource = isViewSource; | 1994 m_isViewSource = isViewSource; |
| 1984 if (!m_isViewSource) | 1995 if (!m_isViewSource) |
| 1985 return; | 1996 return; |
| 1986 | 1997 |
| 1987 setSecurityOrigin(SecurityOrigin::createUnique()); | 1998 setSecurityOrigin(SecurityOrigin::createUnique()); |
| 1988 didUpdateSecurityOrigin(); | 1999 didUpdateSecurityOrigin(); |
| 1989 } | 2000 } |
| 1990 | 2001 |
| 2002 bool Document::dirtyElementsForLayerUpdate() | |
| 2003 { | |
| 2004 if (m_layerUpdateElements.isEmpty()) | |
| 2005 return false; | |
| 2006 HashSet<Element*>::iterator end = m_layerUpdateElements.end(); | |
| 2007 for (HashSet<Element*>::iterator it = m_layerUpdateElements.begin(); it != e nd; ++it) | |
| 2008 (*it)->setNeedsStyleRecalc(LocalStyleChange); | |
| 2009 m_layerUpdateElements.clear(); | |
| 2010 return true; | |
| 2011 } | |
| 2012 | |
| 2013 void Document::scheduleLayerUpdate(Element& element) | |
| 2014 { | |
| 2015 if (element.styleChangeType() == NeedsReattachStyleChange) | |
| 2016 return; | |
| 2017 element.setNeedsLayerUpdate(); | |
| 2018 m_layerUpdateElements.add(&element); | |
| 2019 scheduleStyleRecalc(); | |
| 2020 } | |
| 2021 | |
| 2022 void Document::unscheduleLayerUpdate(Element& element) | |
| 2023 { | |
| 2024 element.clearNeedsLayerUpdate(); | |
| 2025 m_layerUpdateElements.remove(&element); | |
| 2026 } | |
| 2027 | |
| 1991 void Document::scheduleUseShadowTreeUpdate(SVGUseElement& element) | 2028 void Document::scheduleUseShadowTreeUpdate(SVGUseElement& element) |
| 1992 { | 2029 { |
| 1993 m_useElementsNeedingUpdate.add(&element); | 2030 m_useElementsNeedingUpdate.add(&element); |
| 1994 scheduleStyleRecalc(); | 2031 scheduleStyleRecalc(); |
| 1995 } | 2032 } |
| 1996 | 2033 |
| 1997 void Document::unscheduleUseShadowTreeUpdate(SVGUseElement& element) | 2034 void Document::unscheduleUseShadowTreeUpdate(SVGUseElement& element) |
| 1998 { | 2035 { |
| 1999 m_useElementsNeedingUpdate.remove(&element); | 2036 m_useElementsNeedingUpdate.remove(&element); |
| 2000 } | 2037 } |
| (...skipping 3463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5464 } | 5501 } |
| 5465 | 5502 |
| 5466 void Document::invalidateNodeListCaches(const QualifiedName* attrName) | 5503 void Document::invalidateNodeListCaches(const QualifiedName* attrName) |
| 5467 { | 5504 { |
| 5468 HashSet<LiveNodeListBase*>::iterator end = m_listsInvalidatedAtDocument.end( ); | 5505 HashSet<LiveNodeListBase*>::iterator end = m_listsInvalidatedAtDocument.end( ); |
| 5469 for (HashSet<LiveNodeListBase*>::iterator it = m_listsInvalidatedAtDocument. begin(); it != end; ++it) | 5506 for (HashSet<LiveNodeListBase*>::iterator it = m_listsInvalidatedAtDocument. begin(); it != end; ++it) |
| 5470 (*it)->invalidateCache(attrName); | 5507 (*it)->invalidateCache(attrName); |
| 5471 } | 5508 } |
| 5472 | 5509 |
| 5473 } // namespace WebCore | 5510 } // namespace WebCore |
| OLD | NEW |