| 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 >= IndependentInherit || needsStyleRecalc()) { | 1713 if (change >= Inherit || needsStyleRecalc()) { |
| 1714 if (hasRareData()) { | 1714 if (hasRareData()) { |
| 1715 ElementRareData* data = elementRareData(); | 1715 ElementRareData* data = elementRareData(); |
| 1716 if (change != IndependentInherit) | 1716 data->clearComputedStyle(); |
| 1717 data->clearComputedStyle(); | |
| 1718 | 1717 |
| 1719 if (change >= IndependentInherit) { | 1718 if (change >= Inherit) { |
| 1720 if (ElementAnimations* elementAnimations = data->elementAnimatio
ns()) | 1719 if (ElementAnimations* elementAnimations = data->elementAnimatio
ns()) |
| 1721 elementAnimations->setAnimationStyleChange(false); | 1720 elementAnimations->setAnimationStyleChange(false); |
| 1722 } | 1721 } |
| 1723 } | 1722 } |
| 1724 if (parentComputedStyle()) | 1723 if (parentComputedStyle()) |
| 1725 change = recalcOwnStyle(change); | 1724 change = recalcOwnStyle(change); |
| 1726 clearNeedsStyleRecalc(); | 1725 clearNeedsStyleRecalc(); |
| 1727 } | 1726 } |
| 1728 | 1727 |
| 1729 // If we reattached we don't need to recalc the style of our descendants any
more. | 1728 // If we reattached we don't need to recalc the style of our descendants any
more. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1753 clearChildNeedsStyleRecalc(); | 1752 clearChildNeedsStyleRecalc(); |
| 1754 } | 1753 } |
| 1755 | 1754 |
| 1756 if (hasCustomStyleCallbacks()) | 1755 if (hasCustomStyleCallbacks()) |
| 1757 didRecalcStyle(change); | 1756 didRecalcStyle(change); |
| 1758 | 1757 |
| 1759 if (change == Reattach) | 1758 if (change == Reattach) |
| 1760 reattachWhitespaceSiblingsIfNeeded(nextTextSibling); | 1759 reattachWhitespaceSiblingsIfNeeded(nextTextSibling); |
| 1761 } | 1760 } |
| 1762 | 1761 |
| 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 | |
| 1782 StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) | 1762 StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) |
| 1783 { | 1763 { |
| 1784 DCHECK(document().inStyleRecalc()); | 1764 DCHECK(document().inStyleRecalc()); |
| 1785 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc()); | 1765 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc()); |
| 1786 DCHECK(change >= IndependentInherit || needsStyleRecalc()); | 1766 DCHECK(change >= Inherit || needsStyleRecalc()); |
| 1787 DCHECK(parentComputedStyle()); | 1767 DCHECK(parentComputedStyle()); |
| 1788 | 1768 |
| 1789 RefPtr<ComputedStyle> oldStyle = mutableComputedStyle(); | 1769 RefPtr<ComputedStyle> oldStyle = mutableComputedStyle(); |
| 1790 | 1770 RefPtr<ComputedStyle> newStyle = styleForLayoutObject(); |
| 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(); | |
| 1797 DCHECK(newStyle); | 1771 DCHECK(newStyle); |
| 1798 | 1772 |
| 1799 StyleRecalcChange localChange = ComputedStyle::stylePropagationDiff(oldStyle
.get(), newStyle.get()); | 1773 StyleRecalcChange localChange = ComputedStyle::stylePropagationDiff(oldStyle
.get(), newStyle.get()); |
| 1800 if (localChange == NoChange) { | 1774 if (localChange == NoChange) { |
| 1801 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged,
1); | 1775 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged,
1); |
| 1802 } else { | 1776 } else { |
| 1803 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1
); | 1777 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1
); |
| 1804 } | 1778 } |
| 1805 | 1779 |
| 1806 if (localChange == Reattach) { | 1780 if (localChange == Reattach) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1826 layoutObject->setStyleInternal(newStyle.get()); | 1800 layoutObject->setStyleInternal(newStyle.get()); |
| 1827 } | 1801 } |
| 1828 } | 1802 } |
| 1829 | 1803 |
| 1830 if (getStyleChangeType() >= SubtreeStyleChange) | 1804 if (getStyleChangeType() >= SubtreeStyleChange) |
| 1831 return Force; | 1805 return Force; |
| 1832 | 1806 |
| 1833 if (change > Inherit || localChange > Inherit) | 1807 if (change > Inherit || localChange > Inherit) |
| 1834 return max(localChange, change); | 1808 return max(localChange, change); |
| 1835 | 1809 |
| 1836 if (localChange < IndependentInherit) { | 1810 if (localChange < Inherit) { |
| 1837 if (oldStyle->hasChildDependentFlags()) { | 1811 if (oldStyle->hasChildDependentFlags()) { |
| 1838 if (childNeedsStyleRecalc()) | 1812 if (childNeedsStyleRecalc()) |
| 1839 return Inherit; | 1813 return Inherit; |
| 1840 newStyle->copyChildDependentFlagsFrom(*oldStyle); | 1814 newStyle->copyChildDependentFlagsFrom(*oldStyle); |
| 1841 } | 1815 } |
| 1842 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle
()) | 1816 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle
()) |
| 1843 return UpdatePseudoElements; | 1817 return UpdatePseudoElements; |
| 1844 } | 1818 } |
| 1845 | 1819 |
| 1846 return localChange; | 1820 return localChange; |
| (...skipping 1948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3795 | 3769 |
| 3796 DEFINE_TRACE_WRAPPERS(Element) | 3770 DEFINE_TRACE_WRAPPERS(Element) |
| 3797 { | 3771 { |
| 3798 if (hasRareData()) { | 3772 if (hasRareData()) { |
| 3799 visitor->traceWrappers(elementRareData()); | 3773 visitor->traceWrappers(elementRareData()); |
| 3800 } | 3774 } |
| 3801 ContainerNode::traceWrappers(visitor); | 3775 ContainerNode::traceWrappers(visitor); |
| 3802 } | 3776 } |
| 3803 | 3777 |
| 3804 } // namespace blink | 3778 } // namespace blink |
| OLD | NEW |