| 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 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1696 void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling) | 1696 void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling) |
| 1697 { | 1697 { |
| 1698 DCHECK(document().inStyleRecalc()); | 1698 DCHECK(document().inStyleRecalc()); |
| 1699 DCHECK(!document().lifecycle().inDetach()); | 1699 DCHECK(!document().lifecycle().inDetach()); |
| 1700 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc()); | 1700 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc()); |
| 1701 DCHECK(inActiveDocument()); | 1701 DCHECK(inActiveDocument()); |
| 1702 | 1702 |
| 1703 if (hasCustomStyleCallbacks()) | 1703 if (hasCustomStyleCallbacks()) |
| 1704 willRecalcStyle(change); | 1704 willRecalcStyle(change); |
| 1705 | 1705 |
| 1706 if (change >= Inherit || needsStyleRecalc()) { | 1706 if (change >= IndependentInherit || needsStyleRecalc()) { |
| 1707 if (hasRareData()) { | 1707 if (hasRareData()) { |
| 1708 ElementRareData* data = elementRareData(); | 1708 ElementRareData* data = elementRareData(); |
| 1709 data->clearComputedStyle(); | 1709 if (change != IndependentInherit) |
| 1710 data->clearComputedStyle(); |
| 1710 | 1711 |
| 1711 if (change >= Inherit) { | 1712 if (change >= IndependentInherit) { |
| 1712 if (ElementAnimations* elementAnimations = data->elementAnimatio
ns()) | 1713 if (ElementAnimations* elementAnimations = data->elementAnimatio
ns()) |
| 1713 elementAnimations->setAnimationStyleChange(false); | 1714 elementAnimations->setAnimationStyleChange(false); |
| 1714 } | 1715 } |
| 1715 } | 1716 } |
| 1716 if (parentComputedStyle()) | 1717 if (parentComputedStyle()) |
| 1717 change = recalcOwnStyle(change); | 1718 change = recalcOwnStyle(change); |
| 1718 clearNeedsStyleRecalc(); | 1719 clearNeedsStyleRecalc(); |
| 1719 } | 1720 } |
| 1720 | 1721 |
| 1721 // If we reattached we don't need to recalc the style of our descendants any
more. | 1722 // If we reattached we don't need to recalc the style of our descendants any
more. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1745 clearChildNeedsStyleRecalc(); | 1746 clearChildNeedsStyleRecalc(); |
| 1746 } | 1747 } |
| 1747 | 1748 |
| 1748 if (hasCustomStyleCallbacks()) | 1749 if (hasCustomStyleCallbacks()) |
| 1749 didRecalcStyle(change); | 1750 didRecalcStyle(change); |
| 1750 | 1751 |
| 1751 if (change == Reattach) | 1752 if (change == Reattach) |
| 1752 reattachWhitespaceSiblingsIfNeeded(nextTextSibling); | 1753 reattachWhitespaceSiblingsIfNeeded(nextTextSibling); |
| 1753 } | 1754 } |
| 1754 | 1755 |
| 1756 bool Element::canPropagateInheritedProperties(StyleRecalcChange change) |
| 1757 { |
| 1758 return change == IndependentInherit |
| 1759 && !needsStyleRecalc() |
| 1760 && computedStyle() |
| 1761 && parentComputedStyle() |
| 1762 && !computedStyle()->animations() |
| 1763 && !computedStyle()->transitions() |
| 1764 && !hasAnimations(); |
| 1765 } |
| 1766 |
| 1755 StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) | 1767 StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) |
| 1756 { | 1768 { |
| 1757 DCHECK(document().inStyleRecalc()); | 1769 DCHECK(document().inStyleRecalc()); |
| 1758 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc()); | 1770 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc()); |
| 1759 DCHECK(change >= Inherit || needsStyleRecalc()); | 1771 DCHECK(change >= IndependentInherit || needsStyleRecalc()); |
| 1760 DCHECK(parentComputedStyle()); | 1772 DCHECK(parentComputedStyle()); |
| 1761 | 1773 |
| 1762 RefPtr<ComputedStyle> oldStyle = mutableComputedStyle(); | 1774 RefPtr<ComputedStyle> oldStyle = mutableComputedStyle(); |
| 1763 RefPtr<ComputedStyle> newStyle = styleForLayoutObject(); | 1775 RefPtr<ComputedStyle> newStyle; |
| 1776 |
| 1777 // When propagating inherited changes, we don't need to do a full style reca
lc |
| 1778 // if the only changed properties are independent. In this case, we can simp
ly |
| 1779 // set these directly on the ComputedStyle object. |
| 1780 if (canPropagateInheritedProperties(change)) { |
| 1781 newStyle = ComputedStyle::clone(*computedStyle()); |
| 1782 ComputedStyle::propagateIndependentInheritedProperties(*parentComputedSt
yle(), *newStyle); |
| 1783 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), independentInher
itedStylesPropagated, 1); |
| 1784 } else { |
| 1785 newStyle = styleForLayoutObject(); |
| 1786 } |
| 1764 DCHECK(newStyle); | 1787 DCHECK(newStyle); |
| 1765 | 1788 |
| 1766 StyleRecalcChange localChange = ComputedStyle::stylePropagationDiff(oldStyle
.get(), newStyle.get()); | 1789 StyleRecalcChange localChange = ComputedStyle::stylePropagationDiff(oldStyle
.get(), newStyle.get()); |
| 1767 if (localChange == NoChange) { | 1790 if (localChange == NoChange) { |
| 1768 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged,
1); | 1791 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged,
1); |
| 1769 } else { | 1792 } else { |
| 1770 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1
); | 1793 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1
); |
| 1771 } | 1794 } |
| 1772 | 1795 |
| 1773 if (localChange == Reattach) { | 1796 if (localChange == Reattach) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1793 layoutObject->setStyleInternal(newStyle.get()); | 1816 layoutObject->setStyleInternal(newStyle.get()); |
| 1794 } | 1817 } |
| 1795 } | 1818 } |
| 1796 | 1819 |
| 1797 if (getStyleChangeType() >= SubtreeStyleChange) | 1820 if (getStyleChangeType() >= SubtreeStyleChange) |
| 1798 return Force; | 1821 return Force; |
| 1799 | 1822 |
| 1800 if (change > Inherit || localChange > Inherit) | 1823 if (change > Inherit || localChange > Inherit) |
| 1801 return max(localChange, change); | 1824 return max(localChange, change); |
| 1802 | 1825 |
| 1803 if (localChange < Inherit) { | 1826 if (localChange < IndependentInherit) { |
| 1804 if (oldStyle->hasChildDependentFlags()) { | 1827 if (oldStyle->hasChildDependentFlags()) { |
| 1805 if (childNeedsStyleRecalc()) | 1828 if (childNeedsStyleRecalc()) |
| 1806 return Inherit; | 1829 return Inherit; |
| 1807 newStyle->copyChildDependentFlagsFrom(*oldStyle); | 1830 newStyle->copyChildDependentFlagsFrom(*oldStyle); |
| 1808 } | 1831 } |
| 1809 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle
()) | 1832 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle
()) |
| 1810 return UpdatePseudoElements; | 1833 return UpdatePseudoElements; |
| 1811 } | 1834 } |
| 1812 | 1835 |
| 1813 return localChange; | 1836 return localChange; |
| (...skipping 1924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3738 | 3761 |
| 3739 DEFINE_TRACE_WRAPPERS(Element) | 3762 DEFINE_TRACE_WRAPPERS(Element) |
| 3740 { | 3763 { |
| 3741 if (hasRareData()) { | 3764 if (hasRareData()) { |
| 3742 visitor->traceWrappers(elementRareData()); | 3765 visitor->traceWrappers(elementRareData()); |
| 3743 } | 3766 } |
| 3744 ContainerNode::traceWrappers(visitor); | 3767 ContainerNode::traceWrappers(visitor); |
| 3745 } | 3768 } |
| 3746 | 3769 |
| 3747 } // namespace blink | 3770 } // namespace blink |
| OLD | NEW |