Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: third_party/WebKit/Source/core/dom/Element.cpp

Issue 2117143003: Add a fast-path for independent inherited properties (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@computedstyle_cleanup_rename_final_member_fields
Patch Set: Added useful sizeof check comment Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1690 matching lines...) Expand 10 before | Expand all | Expand 10 after
1701 void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling) 1701 void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling)
1702 { 1702 {
1703 DCHECK(document().inStyleRecalc()); 1703 DCHECK(document().inStyleRecalc());
1704 DCHECK(!document().lifecycle().inDetach()); 1704 DCHECK(!document().lifecycle().inDetach());
1705 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc()); 1705 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc());
1706 DCHECK(inActiveDocument()); 1706 DCHECK(inActiveDocument());
1707 1707
1708 if (hasCustomStyleCallbacks()) 1708 if (hasCustomStyleCallbacks())
1709 willRecalcStyle(change); 1709 willRecalcStyle(change);
1710 1710
1711 if (change >= Inherit || needsStyleRecalc()) { 1711 if (change >= IndependentInherit || needsStyleRecalc()) {
1712 if (hasRareData()) { 1712 if (hasRareData()) {
1713 ElementRareData* data = elementRareData(); 1713 ElementRareData* data = elementRareData();
1714 data->clearComputedStyle(); 1714 if (change != IndependentInherit)
1715 data->clearComputedStyle();
1715 1716
1716 if (change >= Inherit) { 1717 if (change >= IndependentInherit) {
1717 if (ElementAnimations* elementAnimations = data->elementAnimatio ns()) 1718 if (ElementAnimations* elementAnimations = data->elementAnimatio ns())
1718 elementAnimations->setAnimationStyleChange(false); 1719 elementAnimations->setAnimationStyleChange(false);
1719 } 1720 }
1720 } 1721 }
1721 if (parentComputedStyle()) 1722 if (parentComputedStyle())
1722 change = recalcOwnStyle(change); 1723 change = recalcOwnStyle(change);
1723 clearNeedsStyleRecalc(); 1724 clearNeedsStyleRecalc();
1724 } 1725 }
1725 1726
1726 // If we reattached we don't need to recalc the style of our descendants any more. 1727 // If we reattached we don't need to recalc the style of our descendants any more.
(...skipping 23 matching lines...) Expand all
1750 clearChildNeedsStyleRecalc(); 1751 clearChildNeedsStyleRecalc();
1751 } 1752 }
1752 1753
1753 if (hasCustomStyleCallbacks()) 1754 if (hasCustomStyleCallbacks())
1754 didRecalcStyle(change); 1755 didRecalcStyle(change);
1755 1756
1756 if (change == Reattach) 1757 if (change == Reattach)
1757 reattachWhitespaceSiblingsIfNeeded(nextTextSibling); 1758 reattachWhitespaceSiblingsIfNeeded(nextTextSibling);
1758 } 1759 }
1759 1760
1761 bool Element::canPropagateInheritedProperties(StyleRecalcChange change)
1762 {
1763 return change == IndependentInherit
esprehn 2016/07/19 03:46:26 if (change != ...) return false; if (!parentComp
sashab 2016/07/19 06:32:38 Nice :) Thanks, done
1764 && !needsStyleRecalc()
1765 && computedStyle()
esprehn 2016/07/19 03:46:26 computedStyle() contains a bunch of branches, you
sashab 2016/07/19 06:32:38 Yup nice, thanks
1766 && parentComputedStyle()
1767 && !computedStyle()->animations()
1768 && !computedStyle()->transitions()
1769 && !hasAnimations();
1770 }
1771
1760 StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) 1772 StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change)
1761 { 1773 {
1762 DCHECK(document().inStyleRecalc()); 1774 DCHECK(document().inStyleRecalc());
1763 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc()); 1775 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc());
1764 DCHECK(change >= Inherit || needsStyleRecalc()); 1776 DCHECK(change >= IndependentInherit || needsStyleRecalc());
1765 DCHECK(parentComputedStyle()); 1777 DCHECK(parentComputedStyle());
1766 1778
1767 RefPtr<ComputedStyle> oldStyle = mutableComputedStyle(); 1779 RefPtr<ComputedStyle> oldStyle = mutableComputedStyle();
1768 RefPtr<ComputedStyle> newStyle = styleForLayoutObject(); 1780 RefPtr<ComputedStyle> newStyle;
1781
1782 // When propagating inherited changes, we don't need to do a full style reca lc
1783 // if the only changed properties are independent. In this case, we can simp ly
1784 // set these directly on the ComputedStyle object.
1785 if (canPropagateInheritedProperties(change)) {
1786 newStyle = ComputedStyle::clone(*computedStyle());
Timothy Loh 2016/07/19 01:29:32 clone(oldStyle)?
sashab 2016/07/19 03:31:35 Done
esprehn 2016/07/19 03:46:26 yeah, don't call computedStyle() repeatedly it's g
1787 ComputedStyle::propagateIndependentInheritedProperties(*parentComputedSt yle(), *newStyle);
esprehn 2016/07/19 03:46:26 parentComputedStyle() isn't free, I think you want
sashab 2016/07/19 06:32:38 Nice!! Done. Had to pass newStyle because its use
1788 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), independentInher itedStylesPropagated, 1);
1789 } else {
1790 newStyle = styleForLayoutObject();
1791 }
1769 DCHECK(newStyle); 1792 DCHECK(newStyle);
1770 1793
1771 StyleRecalcChange localChange = ComputedStyle::stylePropagationDiff(oldStyle .get(), newStyle.get()); 1794 StyleRecalcChange localChange = ComputedStyle::stylePropagationDiff(oldStyle .get(), newStyle.get());
esprehn 2016/07/19 03:46:26 do we even need to run any of this now if we took
sashab 2016/07/19 06:32:38 That's a good question. I've left it this way now
1772 if (localChange == NoChange) { 1795 if (localChange == NoChange) {
1773 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged, 1); 1796 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged, 1);
1774 } else { 1797 } else {
1775 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1 ); 1798 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1 );
1776 } 1799 }
1777 1800
1778 if (localChange == Reattach) { 1801 if (localChange == Reattach) {
1779 // TODO(nainar): Remove the style parameter being passed into buildOwnLa yout(). 1802 // TODO(nainar): Remove the style parameter being passed into buildOwnLa yout().
1780 // ComputedStyle will now be stored on Node and accessed in buildOwnLayo ut() 1803 // ComputedStyle will now be stored on Node and accessed in buildOwnLayo ut()
1781 // using mutableComputedStyle(). 1804 // using mutableComputedStyle().
(...skipping 16 matching lines...) Expand all
1798 layoutObject->setStyleInternal(newStyle.get()); 1821 layoutObject->setStyleInternal(newStyle.get());
1799 } 1822 }
1800 } 1823 }
1801 1824
1802 if (getStyleChangeType() >= SubtreeStyleChange) 1825 if (getStyleChangeType() >= SubtreeStyleChange)
1803 return Force; 1826 return Force;
1804 1827
1805 if (change > Inherit || localChange > Inherit) 1828 if (change > Inherit || localChange > Inherit)
1806 return max(localChange, change); 1829 return max(localChange, change);
1807 1830
1808 if (localChange < Inherit) { 1831 if (localChange < IndependentInherit) {
1809 if (oldStyle->hasChildDependentFlags()) { 1832 if (oldStyle->hasChildDependentFlags()) {
1810 if (childNeedsStyleRecalc()) 1833 if (childNeedsStyleRecalc())
1811 return Inherit; 1834 return Inherit;
1812 newStyle->copyChildDependentFlagsFrom(*oldStyle); 1835 newStyle->copyChildDependentFlagsFrom(*oldStyle);
1813 } 1836 }
1814 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle ()) 1837 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle ())
1815 return UpdatePseudoElements; 1838 return UpdatePseudoElements;
1816 } 1839 }
1817 1840
1818 return localChange; 1841 return localChange;
(...skipping 1924 matching lines...) Expand 10 before | Expand all | Expand 10 after
3743 3766
3744 DEFINE_TRACE_WRAPPERS(Element) 3767 DEFINE_TRACE_WRAPPERS(Element)
3745 { 3768 {
3746 if (hasRareData()) { 3769 if (hasRareData()) {
3747 visitor->traceWrappers(elementRareData()); 3770 visitor->traceWrappers(elementRareData());
3748 } 3771 }
3749 ContainerNode::traceWrappers(visitor); 3772 ContainerNode::traceWrappers(visitor);
3750 } 3773 }
3751 3774
3752 } // namespace blink 3775 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698