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 1510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1521 { | 1521 { |
1522 if (!root) { | 1522 if (!root) { |
1523 exceptionState.throwDOMException(NotSupportedError, "The provided node i s invalid."); | 1523 exceptionState.throwDOMException(NotSupportedError, "The provided node i s invalid."); |
1524 return 0; | 1524 return 0; |
1525 } | 1525 } |
1526 return TreeWalker::create(root, whatToShow, filter); | 1526 return TreeWalker::create(root, whatToShow, filter); |
1527 } | 1527 } |
1528 | 1528 |
1529 bool Document::shouldCallRecalcStyleForDocument() | 1529 bool Document::shouldCallRecalcStyleForDocument() |
1530 { | 1530 { |
1531 return needsStyleRecalc() || childNeedsStyleRecalc() || childNeedsDistributi onRecalc() || !m_useElementsNeedingUpdate.isEmpty(); | 1531 return needsStyleRecalc() || childNeedsStyleRecalc() || childNeedsDistributi onRecalc() || !m_useElementsNeedingUpdate.isEmpty() || childNeedsStyleInvalidati on(); |
1532 } | 1532 } |
1533 | 1533 |
1534 void Document::scheduleStyleRecalc() | 1534 void Document::scheduleStyleRecalc() |
1535 { | 1535 { |
1536 if (!isActive()) | 1536 if (!isActive()) |
1537 return; | 1537 return; |
1538 | 1538 |
1539 if (m_styleRecalcTimer.isActive() || !shouldScheduleLayout()) | 1539 if (m_styleRecalcTimer.isActive() || !shouldScheduleLayout()) |
1540 return; | 1540 return; |
1541 | 1541 |
(...skipping 21 matching lines...) Expand all Loading... | |
1563 } | 1563 } |
1564 | 1564 |
1565 void Document::updateDistributionIfNeeded() | 1565 void Document::updateDistributionIfNeeded() |
1566 { | 1566 { |
1567 if (!childNeedsDistributionRecalc()) | 1567 if (!childNeedsDistributionRecalc()) |
1568 return; | 1568 return; |
1569 TRACE_EVENT0("webkit", "Document::recalcDistribution"); | 1569 TRACE_EVENT0("webkit", "Document::recalcDistribution"); |
1570 recalcDistribution(); | 1570 recalcDistribution(); |
1571 } | 1571 } |
1572 | 1572 |
1573 void Document::updateNeedsStyleRecalcStateIfNeeded() | |
1574 { | |
1575 if (!childNeedsStyleInvalidation()) | |
1576 return; | |
1577 TRACE_EVENT0("webkit", "Document::computeNeedsStyleRecalcState"); | |
1578 if (!styleResolver()) { | |
esprehn
2014/01/28 00:11:34
This isn't right, the resolver can get thrown away
chrishtr
2014/01/28 01:11:55
Added FIXME.
| |
1579 clearChildNeedsStyleInvalidation(); | |
1580 return; | |
1581 } | |
1582 | |
1583 styleResolver()->ensureRuleFeatureSet().computeStyleInvalidation(this); | |
esprehn
2014/01/28 00:11:34
This can't work, the resolver can get thrown away.
chrishtr
2014/01/28 01:11:55
Added FIXME.
| |
1584 } | |
1585 | |
1573 void Document::updateDistributionForNodeIfNeeded(Node* node) | 1586 void Document::updateDistributionForNodeIfNeeded(Node* node) |
1574 { | 1587 { |
1575 if (node->inDocument()) { | 1588 if (node->inDocument()) { |
1576 updateDistributionIfNeeded(); | 1589 updateDistributionIfNeeded(); |
1577 return; | 1590 return; |
1578 } | 1591 } |
1579 Node* root = node; | 1592 Node* root = node; |
1580 while (Node* host = root->shadowHost()) | 1593 while (Node* host = root->shadowHost()) |
1581 root = host; | 1594 root = host; |
1582 while (Node* ancestor = root->parentOrShadowHostNode()) | 1595 while (Node* ancestor = root->parentOrShadowHostNode()) |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1651 body->setNeedsStyleRecalc(); | 1664 body->setNeedsStyleRecalc(); |
1652 } | 1665 } |
1653 } | 1666 } |
1654 | 1667 |
1655 if (RenderStyle* style = documentElement()->renderStyle()) { | 1668 if (RenderStyle* style = documentElement()->renderStyle()) { |
1656 if (style->direction() != rootDirection || style->writingMode() != rootW ritingMode) | 1669 if (style->direction() != rootDirection || style->writingMode() != rootW ritingMode) |
1657 documentElement()->setNeedsStyleRecalc(); | 1670 documentElement()->setNeedsStyleRecalc(); |
1658 } | 1671 } |
1659 } | 1672 } |
1660 | 1673 |
1674 // FIXME: need a better name than recalcStyle. It's performing style invalidatio n, style recalc, and distribution. | |
1661 void Document::recalcStyle(StyleRecalcChange change) | 1675 void Document::recalcStyle(StyleRecalcChange change) |
1662 { | 1676 { |
1663 // we should not enter style recalc while painting | 1677 // we should not enter style recalc while painting |
1664 RELEASE_ASSERT(!view() || !view()->isPainting()); | 1678 RELEASE_ASSERT(!view() || !view()->isPainting()); |
1665 | 1679 |
1666 // FIXME: We should never enter here without a FrameView or with an inactive document. | 1680 // FIXME: We should never enter here without a FrameView or with an inactive document. |
1667 if (!isActive() || !view()) | 1681 if (!isActive() || !view()) |
1668 return; | 1682 return; |
1669 | 1683 |
1670 if (m_inStyleRecalc) | 1684 if (m_inStyleRecalc) |
1671 return; | 1685 return; |
1672 | 1686 |
1673 TRACE_EVENT0("webkit", "Document::recalcStyle"); | 1687 TRACE_EVENT0("webkit", "Document::recalcStyle"); |
1674 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "RecalcStyle"); | 1688 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "RecalcStyle"); |
1675 | 1689 |
1676 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalc ulateStyle(this); | 1690 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalc ulateStyle(this); |
1677 | 1691 |
1692 updateNeedsStyleRecalcStateIfNeeded(); | |
esprehn
2014/01/28 00:11:34
This should be the last of these three steps, the
chrishtr
2014/01/28 01:11:55
Done.
| |
1678 updateDistributionIfNeeded(); | 1693 updateDistributionIfNeeded(); |
1679 updateUseShadowTrees(); | 1694 updateUseShadowTrees(); |
1680 | 1695 |
1681 if (m_evaluateMediaQueriesOnStyleRecalc) { | 1696 if (m_evaluateMediaQueriesOnStyleRecalc) { |
1682 m_evaluateMediaQueriesOnStyleRecalc = false; | 1697 m_evaluateMediaQueriesOnStyleRecalc = false; |
1683 evaluateMediaQueryList(); | 1698 evaluateMediaQueryList(); |
1684 } | 1699 } |
1685 | 1700 |
1686 // FIXME: We should update style on our ancestor chain before proceeding | 1701 // FIXME: We should update style on our ancestor chain before proceeding |
1687 // however doing so currently causes several tests to crash, as Frame::setDo cument calls Document::attach | 1702 // however doing so currently causes several tests to crash, as Frame::setDo cument calls Document::attach |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1772 void Document::updateStyleForNodeIfNeeded(Node* node) | 1787 void Document::updateStyleForNodeIfNeeded(Node* node) |
1773 { | 1788 { |
1774 if (!shouldCallRecalcStyleForDocument()) | 1789 if (!shouldCallRecalcStyleForDocument()) |
1775 return; | 1790 return; |
1776 | 1791 |
1777 // At this point, we know that we need to recalc some style on the document in order to fully update styles. | 1792 // At this point, we know that we need to recalc some style on the document in order to fully update styles. |
1778 // However, style on 'node' only needs to be recalculated if a global recomp utation is needed, or a node on | 1793 // However, style on 'node' only needs to be recalculated if a global recomp utation is needed, or a node on |
1779 // the path from 'node' to the root needs style recalc. | 1794 // the path from 'node' to the root needs style recalc. |
1780 | 1795 |
1781 // Global needed. | 1796 // Global needed. |
1782 bool needsRecalc = needsStyleRecalc() || childNeedsDistributionRecalc() || ! m_useElementsNeedingUpdate.isEmpty(); | 1797 bool needsRecalc = needsStyleRecalc() || childNeedsDistributionRecalc() || ! m_useElementsNeedingUpdate.isEmpty() || childNeedsStyleInvalidation(); |
1783 | 1798 |
1784 // On the path. | 1799 // On the path. |
1785 for (Node* ancestor = node; ancestor && !needsRecalc; ancestor = ancestor->p arentOrShadowHostNode()) | 1800 for (Node* ancestor = node; ancestor && !needsRecalc; ancestor = ancestor->p arentOrShadowHostNode()) |
1786 needsRecalc = ancestor->needsStyleRecalc(); | 1801 needsRecalc = ancestor->needsStyleRecalc(); |
1787 if (needsRecalc) | 1802 if (needsRecalc) |
1788 updateStyleIfNeeded(); | 1803 updateStyleIfNeeded(); |
1789 } | 1804 } |
1790 | 1805 |
1791 void Document::updateLayout() | 1806 void Document::updateLayout() |
1792 { | 1807 { |
(...skipping 3526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5319 if (!page->focusController().isActive() || !page->focusController().isFocuse d()) | 5334 if (!page->focusController().isActive() || !page->focusController().isFocuse d()) |
5320 return false; | 5335 return false; |
5321 if (Frame* focusedFrame = page->focusController().focusedFrame()) { | 5336 if (Frame* focusedFrame = page->focusController().focusedFrame()) { |
5322 if (focusedFrame->tree().isDescendantOf(frame())) | 5337 if (focusedFrame->tree().isDescendantOf(frame())) |
5323 return true; | 5338 return true; |
5324 } | 5339 } |
5325 return false; | 5340 return false; |
5326 } | 5341 } |
5327 | 5342 |
5328 } // namespace WebCore | 5343 } // namespace WebCore |
OLD | NEW |