| 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 1561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1572 { | 1572 { |
| 1573 if (!root) { | 1573 if (!root) { |
| 1574 exceptionState.throwDOMException(NotSupportedError, "The provided node i
s invalid."); | 1574 exceptionState.throwDOMException(NotSupportedError, "The provided node i
s invalid."); |
| 1575 return 0; | 1575 return 0; |
| 1576 } | 1576 } |
| 1577 return TreeWalker::create(root, whatToShow, filter); | 1577 return TreeWalker::create(root, whatToShow, filter); |
| 1578 } | 1578 } |
| 1579 | 1579 |
| 1580 bool Document::shouldCallRecalcStyleForDocument() | 1580 bool Document::shouldCallRecalcStyleForDocument() |
| 1581 { | 1581 { |
| 1582 return needsStyleRecalc() || childNeedsStyleRecalc() || childNeedsDistributi
onRecalc() || !m_useElementsNeedingUpdate.isEmpty(); | 1582 return needsStyleRecalc() || childNeedsStyleRecalc() || childNeedsDistributi
onRecalc() || !m_useElementsNeedingUpdate.isEmpty() || childNeedsStyleInvalidati
on(); |
| 1583 } | 1583 } |
| 1584 | 1584 |
| 1585 void Document::scheduleStyleRecalc() | 1585 void Document::scheduleStyleRecalc() |
| 1586 { | 1586 { |
| 1587 if (!isActive()) | 1587 if (!isActive()) |
| 1588 return; | 1588 return; |
| 1589 | 1589 |
| 1590 if (m_hasPendingStyleRecalc || !shouldScheduleLayout()) | 1590 if (m_hasPendingStyleRecalc || !shouldScheduleLayout()) |
| 1591 return; | 1591 return; |
| 1592 | 1592 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1610 } | 1610 } |
| 1611 | 1611 |
| 1612 void Document::updateDistributionIfNeeded() | 1612 void Document::updateDistributionIfNeeded() |
| 1613 { | 1613 { |
| 1614 if (!childNeedsDistributionRecalc()) | 1614 if (!childNeedsDistributionRecalc()) |
| 1615 return; | 1615 return; |
| 1616 TRACE_EVENT0("webkit", "Document::recalcDistribution"); | 1616 TRACE_EVENT0("webkit", "Document::recalcDistribution"); |
| 1617 recalcDistribution(); | 1617 recalcDistribution(); |
| 1618 } | 1618 } |
| 1619 | 1619 |
| 1620 void Document::updateStyleInvalidationIfNeeded() |
| 1621 { |
| 1622 if (!childNeedsStyleInvalidation()) |
| 1623 return; |
| 1624 TRACE_EVENT0("webkit", "Document::computeNeedsStyleRecalcState"); |
| 1625 if (!styleResolver()) { |
| 1626 clearChildNeedsStyleInvalidation(); |
| 1627 return; |
| 1628 } |
| 1629 |
| 1630 // FIXME: the style resolver can be deleted at present. Either resolve |
| 1631 // crbug.com/335964 or move the invalidation data elsewhere. |
| 1632 styleResolver()->ensureRuleFeatureSet().computeStyleInvalidation(*this); |
| 1633 } |
| 1634 |
| 1620 void Document::updateDistributionForNodeIfNeeded(Node* node) | 1635 void Document::updateDistributionForNodeIfNeeded(Node* node) |
| 1621 { | 1636 { |
| 1622 if (node->inDocument()) { | 1637 if (node->inDocument()) { |
| 1623 updateDistributionIfNeeded(); | 1638 updateDistributionIfNeeded(); |
| 1624 return; | 1639 return; |
| 1625 } | 1640 } |
| 1626 Node* root = node; | 1641 Node* root = node; |
| 1627 while (Node* host = root->shadowHost()) | 1642 while (Node* host = root->shadowHost()) |
| 1628 root = host; | 1643 root = host; |
| 1629 while (Node* ancestor = root->parentOrShadowHostNode()) | 1644 while (Node* ancestor = root->parentOrShadowHostNode()) |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1698 body->setNeedsStyleRecalc(); | 1713 body->setNeedsStyleRecalc(); |
| 1699 } | 1714 } |
| 1700 } | 1715 } |
| 1701 | 1716 |
| 1702 if (RenderStyle* style = documentElement()->renderStyle()) { | 1717 if (RenderStyle* style = documentElement()->renderStyle()) { |
| 1703 if (style->direction() != rootDirection || style->writingMode() != rootW
ritingMode) | 1718 if (style->direction() != rootDirection || style->writingMode() != rootW
ritingMode) |
| 1704 documentElement()->setNeedsStyleRecalc(); | 1719 documentElement()->setNeedsStyleRecalc(); |
| 1705 } | 1720 } |
| 1706 } | 1721 } |
| 1707 | 1722 |
| 1723 // FIXME: need a better name than recalcStyle. It's performing style invalidatio
n, style recalc, and distribution. |
| 1708 void Document::recalcStyle(StyleRecalcChange change) | 1724 void Document::recalcStyle(StyleRecalcChange change) |
| 1709 { | 1725 { |
| 1710 // we should not enter style recalc while painting | 1726 // we should not enter style recalc while painting |
| 1711 RELEASE_ASSERT(!view() || !view()->isPainting()); | 1727 RELEASE_ASSERT(!view() || !view()->isPainting()); |
| 1712 | 1728 |
| 1713 // FIXME: We should never enter here without a FrameView or with an inactive
document. | 1729 // FIXME: We should never enter here without a FrameView or with an inactive
document. |
| 1714 if (!isActive() || !view()) | 1730 if (!isActive() || !view()) |
| 1715 return; | 1731 return; |
| 1716 | 1732 |
| 1717 if (m_inStyleRecalc) | 1733 if (m_inStyleRecalc) |
| 1718 return; | 1734 return; |
| 1719 | 1735 |
| 1720 TRACE_EVENT0("webkit", "Document::recalcStyle"); | 1736 TRACE_EVENT0("webkit", "Document::recalcStyle"); |
| 1721 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "RecalcStyle"); | 1737 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "RecalcStyle"); |
| 1722 | 1738 |
| 1723 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalc
ulateStyle(this); | 1739 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalc
ulateStyle(this); |
| 1724 | 1740 |
| 1725 updateDistributionIfNeeded(); | 1741 updateDistributionIfNeeded(); |
| 1726 updateUseShadowTrees(); | 1742 updateUseShadowTrees(); |
| 1743 updateStyleInvalidationIfNeeded(); |
| 1727 | 1744 |
| 1728 if (m_evaluateMediaQueriesOnStyleRecalc) { | 1745 if (m_evaluateMediaQueriesOnStyleRecalc) { |
| 1729 m_evaluateMediaQueriesOnStyleRecalc = false; | 1746 m_evaluateMediaQueriesOnStyleRecalc = false; |
| 1730 evaluateMediaQueryList(); | 1747 evaluateMediaQueryList(); |
| 1731 } | 1748 } |
| 1732 | 1749 |
| 1733 // FIXME: We should update style on our ancestor chain before proceeding | 1750 // 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 | 1751 // 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 | 1752 // 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 | 1753 // resolves style (here) and then when we resolve style on the parent chain,
we may end up |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1819 void Document::updateStyleForNodeIfNeeded(Node* node) | 1836 void Document::updateStyleForNodeIfNeeded(Node* node) |
| 1820 { | 1837 { |
| 1821 if (!shouldCallRecalcStyleForDocument()) | 1838 if (!shouldCallRecalcStyleForDocument()) |
| 1822 return; | 1839 return; |
| 1823 | 1840 |
| 1824 // At this point, we know that we need to recalc some style on the document
in order to fully update styles. | 1841 // At this point, we know that we need to recalc some style on the document
in order to fully update styles. |
| 1825 // However, style on 'node' only needs to be recalculated if a global recomp
utation is needed, or a node on | 1842 // However, style on 'node' only needs to be recalculated if a global recomp
utation is needed, or a node on |
| 1826 // the path from 'node' to the root needs style recalc. | 1843 // the path from 'node' to the root needs style recalc. |
| 1827 | 1844 |
| 1828 // Global needed. | 1845 // Global needed. |
| 1829 bool needsRecalc = needsStyleRecalc() || childNeedsDistributionRecalc() || !
m_useElementsNeedingUpdate.isEmpty(); | 1846 bool needsRecalc = needsStyleRecalc() || childNeedsDistributionRecalc() || !
m_useElementsNeedingUpdate.isEmpty() || childNeedsStyleInvalidation(); |
| 1830 | 1847 |
| 1831 // On the path. | 1848 // On the path. |
| 1832 for (Node* ancestor = node; ancestor && !needsRecalc; ancestor = ancestor->p
arentOrShadowHostNode()) | 1849 for (Node* ancestor = node; ancestor && !needsRecalc; ancestor = ancestor->p
arentOrShadowHostNode()) |
| 1833 needsRecalc = ancestor->needsStyleRecalc(); | 1850 needsRecalc = ancestor->needsStyleRecalc(); |
| 1834 if (needsRecalc) | 1851 if (needsRecalc) |
| 1835 updateStyleIfNeeded(); | 1852 updateStyleIfNeeded(); |
| 1836 } | 1853 } |
| 1837 | 1854 |
| 1838 void Document::updateLayout() | 1855 void Document::updateLayout() |
| 1839 { | 1856 { |
| (...skipping 3526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5366 if (!page->focusController().isActive() || !page->focusController().isFocuse
d()) | 5383 if (!page->focusController().isActive() || !page->focusController().isFocuse
d()) |
| 5367 return false; | 5384 return false; |
| 5368 if (Frame* focusedFrame = page->focusController().focusedFrame()) { | 5385 if (Frame* focusedFrame = page->focusController().focusedFrame()) { |
| 5369 if (focusedFrame->tree().isDescendantOf(frame())) | 5386 if (focusedFrame->tree().isDescendantOf(frame())) |
| 5370 return true; | 5387 return true; |
| 5371 } | 5388 } |
| 5372 return false; | 5389 return false; |
| 5373 } | 5390 } |
| 5374 | 5391 |
| 5375 } // namespace WebCore | 5392 } // namespace WebCore |
| OLD | NEW |