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

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

Issue 2001453002: Set ComputedStyle on Node and use that in buildOwnLayout() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@storage
Patch Set: 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 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 560
561 // TODO(esprehn): This should use updateStyleAndLayoutIgnorePendingStyleshee tsForNode. 561 // TODO(esprehn): This should use updateStyleAndLayoutIgnorePendingStyleshee tsForNode.
562 document().updateStyleAndLayoutIgnorePendingStylesheets(); 562 document().updateStyleAndLayoutIgnorePendingStylesheets();
563 563
564 LayoutBox* boxToScroll = nullptr; 564 LayoutBox* boxToScroll = nullptr;
565 565
566 // We should only ever scroll the effective root scroller this way when the 566 // We should only ever scroll the effective root scroller this way when the
567 // page removes the default applyScroll (ViewportScrollCallback). 567 // page removes the default applyScroll (ViewportScrollCallback).
568 if (document().effectiveRootScroller() == this) 568 if (document().effectiveRootScroller() == this)
569 boxToScroll = document().layoutView(); 569 boxToScroll = document().layoutView();
570 else if (layoutObject()) 570 else if (hasLayoutObject())
571 boxToScroll = toLayoutBox(layoutObject()); 571 boxToScroll = toLayoutBox(layoutObject());
572 572
573 if (!boxToScroll) 573 if (!boxToScroll)
574 return; 574 return;
575 575
576 ScrollResult result = 576 ScrollResult result =
577 LayoutBoxItem(boxToScroll).enclosingBox().scroll( 577 LayoutBoxItem(boxToScroll).enclosingBox().scroll(
578 ScrollGranularity(static_cast<int>(scrollState.deltaGranularity())), 578 ScrollGranularity(static_cast<int>(scrollState.deltaGranularity())),
579 delta); 579 delta);
580 580
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1762 DCHECK(newStyle); 1762 DCHECK(newStyle);
1763 1763
1764 StyleRecalcChange localChange = ComputedStyle::stylePropagationDiff(oldStyle .get(), newStyle.get()); 1764 StyleRecalcChange localChange = ComputedStyle::stylePropagationDiff(oldStyle .get(), newStyle.get());
1765 if (localChange == NoChange) { 1765 if (localChange == NoChange) {
1766 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged, 1); 1766 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged, 1);
1767 } else { 1767 } else {
1768 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1 ); 1768 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1 );
1769 } 1769 }
1770 1770
1771 if (localChange == Reattach) { 1771 if (localChange == Reattach) {
1772 AttachContext reattachContext; 1772 setComputedStyle(newStyle);
1773 reattachContext.resolvedStyle = newStyle.get(); 1773 return buildOwnLayout();
sashab 2016/07/04 07:57:12 A suggestion that might make this a little easier
nainar 2016/07/05 00:26:55 In progress update: Made a new CL with the mechani
1774 bool layoutObjectWillChange = needsAttach() || layoutObject();
1775 reattach(reattachContext);
1776 if (layoutObjectWillChange || layoutObject())
1777 return Reattach;
1778 return ReattachNoLayoutObject;
1779 } 1774 }
1780 1775
1781 DCHECK(oldStyle); 1776 DCHECK(oldStyle);
1782 1777
1783 if (localChange != NoChange) 1778 if (localChange != NoChange)
1784 updateCallbackSelectors(oldStyle.get(), newStyle.get()); 1779 updateCallbackSelectors(oldStyle.get(), newStyle.get());
1785 1780
1786 if (LayoutObject* layoutObject = this->layoutObject()) { 1781 if (LayoutObject* layoutObject = this->layoutObject()) {
1787 if (localChange != NoChange || pseudoStyleCacheIsInvalid(oldStyle.get(), newStyle.get()) || svgFilterNeedsLayerUpdate()) { 1782 if (localChange != NoChange || pseudoStyleCacheIsInvalid(oldStyle.get(), newStyle.get()) || svgFilterNeedsLayerUpdate()) {
1788 layoutObject->setStyle(newStyle.get()); 1783 layoutObject->setStyle(newStyle.get());
(...skipping 18 matching lines...) Expand all
1807 return Inherit; 1802 return Inherit;
1808 newStyle->copyChildDependentFlagsFrom(*oldStyle); 1803 newStyle->copyChildDependentFlagsFrom(*oldStyle);
1809 } 1804 }
1810 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle ()) 1805 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle ())
1811 return UpdatePseudoElements; 1806 return UpdatePseudoElements;
1812 } 1807 }
1813 1808
1814 return localChange; 1809 return localChange;
1815 } 1810 }
1816 1811
1812 StyleRecalcChange Element::buildOwnLayout()
1813 {
1814 AttachContext reattachContext;
1815 reattachContext.resolvedStyle = mutableComputedStyle();
1816 bool layoutObjectWillChange = needsAttach() || hasLayoutObject();
1817 reattach(reattachContext);
1818 if (layoutObjectWillChange || hasLayoutObject())
1819 return Reattach;
1820 return ReattachNoLayoutObject;
1821 }
1822
1817 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle, const Compu tedStyle* newStyle) 1823 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle, const Compu tedStyle* newStyle)
1818 { 1824 {
1819 Vector<String> emptyVector; 1825 Vector<String> emptyVector;
1820 const Vector<String>& oldCallbackSelectors = oldStyle ? oldStyle->callbackSe lectors() : emptyVector; 1826 const Vector<String>& oldCallbackSelectors = oldStyle ? oldStyle->callbackSe lectors() : emptyVector;
1821 const Vector<String>& newCallbackSelectors = newStyle ? newStyle->callbackSe lectors() : emptyVector; 1827 const Vector<String>& newCallbackSelectors = newStyle ? newStyle->callbackSe lectors() : emptyVector;
1822 if (oldCallbackSelectors.isEmpty() && newCallbackSelectors.isEmpty()) 1828 if (oldCallbackSelectors.isEmpty() && newCallbackSelectors.isEmpty())
1823 return; 1829 return;
1824 if (oldCallbackSelectors != newCallbackSelectors) 1830 if (oldCallbackSelectors != newCallbackSelectors)
1825 CSSSelectorWatch::from(document()).updateSelectorMatches(oldCallbackSele ctors, newCallbackSelectors); 1831 CSSSelectorWatch::from(document()).updateSelectorMatches(oldCallbackSele ctors, newCallbackSelectors);
1826 } 1832 }
(...skipping 1901 matching lines...) Expand 10 before | Expand all | Expand 10 after
3728 3734
3729 DEFINE_TRACE_WRAPPERS(Element) 3735 DEFINE_TRACE_WRAPPERS(Element)
3730 { 3736 {
3731 if (hasRareData()) { 3737 if (hasRareData()) {
3732 visitor->traceWrappers(elementRareData()); 3738 visitor->traceWrappers(elementRareData());
3733 } 3739 }
3734 ContainerNode::traceWrappers(visitor); 3740 ContainerNode::traceWrappers(visitor);
3735 } 3741 }
3736 3742
3737 } // namespace blink 3743 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698