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 Peter Kelly (pmk@post.com) | 4 * (C) 2001 Peter Kelly (pmk@post.com) |
5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
6 * (C) 2007 David Smith (catfish.man@gmail.com) | 6 * (C) 2007 David Smith (catfish.man@gmail.com) |
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. | 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. |
8 * (C) 2007 Eric Seidel (eric@webkit.org) | 8 * (C) 2007 Eric Seidel (eric@webkit.org) |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 1692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1703 void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling) | 1703 void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling) |
1704 { | 1704 { |
1705 DCHECK(document().inStyleRecalc()); | 1705 DCHECK(document().inStyleRecalc()); |
1706 DCHECK(!document().lifecycle().inDetach()); | 1706 DCHECK(!document().lifecycle().inDetach()); |
1707 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc()); | 1707 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc()); |
1708 DCHECK(inActiveDocument()); | 1708 DCHECK(inActiveDocument()); |
1709 | 1709 |
1710 if (hasCustomStyleCallbacks()) | 1710 if (hasCustomStyleCallbacks()) |
1711 willRecalcStyle(change); | 1711 willRecalcStyle(change); |
1712 | 1712 |
1713 if (change >= Inherit || needsStyleRecalc()) { | 1713 if (change >= IndependentInherit || needsStyleRecalc()) { |
1714 if (hasRareData()) { | 1714 if (hasRareData()) { |
1715 ElementRareData* data = elementRareData(); | 1715 ElementRareData* data = elementRareData(); |
1716 data->clearComputedStyle(); | 1716 if (change != IndependentInherit) |
| 1717 data->clearComputedStyle(); |
1717 | 1718 |
1718 if (change >= Inherit) { | 1719 if (change >= IndependentInherit) { |
1719 if (ElementAnimations* elementAnimations = data->elementAnimatio
ns()) | 1720 if (ElementAnimations* elementAnimations = data->elementAnimatio
ns()) |
1720 elementAnimations->setAnimationStyleChange(false); | 1721 elementAnimations->setAnimationStyleChange(false); |
1721 } | 1722 } |
1722 } | 1723 } |
1723 if (parentComputedStyle()) | 1724 if (parentComputedStyle()) |
1724 change = recalcOwnStyle(change); | 1725 change = recalcOwnStyle(change); |
1725 clearNeedsStyleRecalc(); | 1726 clearNeedsStyleRecalc(); |
1726 } | 1727 } |
1727 | 1728 |
1728 // If we reattached we don't need to recalc the style of our descendants any
more. | 1729 // If we reattached we don't need to recalc the style of our descendants any
more. |
(...skipping 23 matching lines...) Expand all Loading... |
1752 clearChildNeedsStyleRecalc(); | 1753 clearChildNeedsStyleRecalc(); |
1753 } | 1754 } |
1754 | 1755 |
1755 if (hasCustomStyleCallbacks()) | 1756 if (hasCustomStyleCallbacks()) |
1756 didRecalcStyle(change); | 1757 didRecalcStyle(change); |
1757 | 1758 |
1758 if (change == Reattach) | 1759 if (change == Reattach) |
1759 reattachWhitespaceSiblingsIfNeeded(nextTextSibling); | 1760 reattachWhitespaceSiblingsIfNeeded(nextTextSibling); |
1760 } | 1761 } |
1761 | 1762 |
| 1763 PassRefPtr<ComputedStyle> Element::propagateInheritedProperties(StyleRecalcChang
e change) |
| 1764 { |
| 1765 if (change != IndependentInherit) |
| 1766 return nullptr; |
| 1767 if (needsStyleRecalc()) |
| 1768 return nullptr; |
| 1769 if (hasAnimations()) |
| 1770 return nullptr; |
| 1771 const ComputedStyle* parentStyle = parentComputedStyle(); |
| 1772 DCHECK(parentStyle); |
| 1773 const ComputedStyle* style = computedStyle(); |
| 1774 if (!style || style->animations() || style->transitions()) |
| 1775 return nullptr; |
| 1776 RefPtr<ComputedStyle> newStyle = ComputedStyle::clone(*style); |
| 1777 newStyle->propagateIndependentInheritedProperties(*parentStyle); |
| 1778 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), independentInherited
StylesPropagated, 1); |
| 1779 return newStyle; |
| 1780 } |
| 1781 |
1762 StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) | 1782 StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) |
1763 { | 1783 { |
1764 DCHECK(document().inStyleRecalc()); | 1784 DCHECK(document().inStyleRecalc()); |
1765 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc()); | 1785 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc()); |
1766 DCHECK(change >= Inherit || needsStyleRecalc()); | 1786 DCHECK(change >= IndependentInherit || needsStyleRecalc()); |
1767 DCHECK(parentComputedStyle()); | 1787 DCHECK(parentComputedStyle()); |
1768 | 1788 |
1769 RefPtr<ComputedStyle> oldStyle = mutableComputedStyle(); | 1789 RefPtr<ComputedStyle> oldStyle = mutableComputedStyle(); |
1770 RefPtr<ComputedStyle> newStyle = styleForLayoutObject(); | 1790 |
| 1791 // When propagating inherited changes, we don't need to do a full style reca
lc |
| 1792 // if the only changed properties are independent. In this case, we can simp
ly |
| 1793 // set these directly on the ComputedStyle object. |
| 1794 RefPtr<ComputedStyle> newStyle = propagateInheritedProperties(change); |
| 1795 if (!newStyle) |
| 1796 newStyle = styleForLayoutObject(); |
1771 DCHECK(newStyle); | 1797 DCHECK(newStyle); |
1772 | 1798 |
1773 StyleRecalcChange localChange = ComputedStyle::stylePropagationDiff(oldStyle
.get(), newStyle.get()); | 1799 StyleRecalcChange localChange = ComputedStyle::stylePropagationDiff(oldStyle
.get(), newStyle.get()); |
1774 if (localChange == NoChange) { | 1800 if (localChange == NoChange) { |
1775 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged,
1); | 1801 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged,
1); |
1776 } else { | 1802 } else { |
1777 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1
); | 1803 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1
); |
1778 } | 1804 } |
1779 | 1805 |
1780 if (localChange == Reattach) { | 1806 if (localChange == Reattach) { |
(...skipping 19 matching lines...) Expand all Loading... |
1800 layoutObject->setStyleInternal(newStyle.get()); | 1826 layoutObject->setStyleInternal(newStyle.get()); |
1801 } | 1827 } |
1802 } | 1828 } |
1803 | 1829 |
1804 if (getStyleChangeType() >= SubtreeStyleChange) | 1830 if (getStyleChangeType() >= SubtreeStyleChange) |
1805 return Force; | 1831 return Force; |
1806 | 1832 |
1807 if (change > Inherit || localChange > Inherit) | 1833 if (change > Inherit || localChange > Inherit) |
1808 return max(localChange, change); | 1834 return max(localChange, change); |
1809 | 1835 |
1810 if (localChange < Inherit) { | 1836 if (localChange < IndependentInherit) { |
1811 if (oldStyle->hasChildDependentFlags()) { | 1837 if (oldStyle->hasChildDependentFlags()) { |
1812 if (childNeedsStyleRecalc()) | 1838 if (childNeedsStyleRecalc()) |
1813 return Inherit; | 1839 return Inherit; |
1814 newStyle->copyChildDependentFlagsFrom(*oldStyle); | 1840 newStyle->copyChildDependentFlagsFrom(*oldStyle); |
1815 } | 1841 } |
1816 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle
()) | 1842 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle
()) |
1817 return UpdatePseudoElements; | 1843 return UpdatePseudoElements; |
1818 } | 1844 } |
1819 | 1845 |
1820 return localChange; | 1846 return localChange; |
(...skipping 1948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3769 | 3795 |
3770 DEFINE_TRACE_WRAPPERS(Element) | 3796 DEFINE_TRACE_WRAPPERS(Element) |
3771 { | 3797 { |
3772 if (hasRareData()) { | 3798 if (hasRareData()) { |
3773 visitor->traceWrappers(elementRareData()); | 3799 visitor->traceWrappers(elementRareData()); |
3774 } | 3800 } |
3775 ContainerNode::traceWrappers(visitor); | 3801 ContainerNode::traceWrappers(visitor); |
3776 } | 3802 } |
3777 | 3803 |
3778 } // namespace blink | 3804 } // namespace blink |
OLD | NEW |