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

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

Issue 1962953002: Storage of ComputedStyle separate from LayoutObject. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed ComputedStyle from ElementRareData Created 4 years, 6 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 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 } 1510 }
1511 1511
1512 void Element::attach(const AttachContext& context) 1512 void Element::attach(const AttachContext& context)
1513 { 1513 {
1514 DCHECK(document().inStyleRecalc()); 1514 DCHECK(document().inStyleRecalc());
1515 1515
1516 // We've already been through detach when doing an attach, but we might 1516 // We've already been through detach when doing an attach, but we might
1517 // need to clear any state that's been added since then. 1517 // need to clear any state that's been added since then.
1518 if (hasRareData() && getStyleChangeType() == NeedsReattachStyleChange) { 1518 if (hasRareData() && getStyleChangeType() == NeedsReattachStyleChange) {
1519 ElementRareData* data = elementRareData(); 1519 ElementRareData* data = elementRareData();
1520 data->clearComputedStyle(); 1520 data->setComputedStyle(nullptr);
1521 } 1521 }
1522 1522
1523 if (!isSlotOrActiveInsertionPoint()) 1523 if (!isSlotOrActiveInsertionPoint())
1524 LayoutTreeBuilderForElement(*this, context.resolvedStyle).createLayoutOb jectIfNeeded(); 1524 LayoutTreeBuilderForElement(*this, context.resolvedStyle).createLayoutOb jectIfNeeded();
1525 1525
1526 addCallbackSelectors(); 1526 addCallbackSelectors();
1527 1527
1528 if (hasRareData() && !layoutObject()) { 1528 if (hasRareData() && !layoutObject()) {
1529 if (ElementAnimations* elementAnimations = elementRareData()->elementAni mations()) { 1529 if (ElementAnimations* elementAnimations = elementRareData()->elementAni mations()) {
1530 elementAnimations->cssAnimations().cancel(); 1530 elementAnimations->cssAnimations().cancel();
(...skipping 25 matching lines...) Expand all
1556 { 1556 {
1557 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; 1557 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates;
1558 cancelFocusAppearanceUpdate(); 1558 cancelFocusAppearanceUpdate();
1559 removeCallbackSelectors(); 1559 removeCallbackSelectors();
1560 if (hasRareData()) { 1560 if (hasRareData()) {
1561 ElementRareData* data = elementRareData(); 1561 ElementRareData* data = elementRareData();
1562 data->clearPseudoElements(); 1562 data->clearPseudoElements();
1563 1563
1564 // attach() will clear the computed style for us when inside recalcStyle . 1564 // attach() will clear the computed style for us when inside recalcStyle .
1565 if (!document().inStyleRecalc()) 1565 if (!document().inStyleRecalc())
1566 data->clearComputedStyle(); 1566 data->setComputedStyle(nullptr);
1567 1567
1568 if (ElementAnimations* elementAnimations = data->elementAnimations()) { 1568 if (ElementAnimations* elementAnimations = data->elementAnimations()) {
1569 if (context.performingReattach) { 1569 if (context.performingReattach) {
1570 // FIXME: We call detach from within style recalc, so compositin gState is not up to date. 1570 // FIXME: We call detach from within style recalc, so compositin gState is not up to date.
1571 // https://code.google.com/p/chromium/issues/detail?id=339847 1571 // https://code.google.com/p/chromium/issues/detail?id=339847
1572 DisableCompositingQueryAsserts disabler; 1572 DisableCompositingQueryAsserts disabler;
1573 1573
1574 // FIXME: restart compositor animations rather than pull back to the main thread 1574 // FIXME: restart compositor animations rather than pull back to the main thread
1575 elementAnimations->restartAnimationOnCompositor(); 1575 elementAnimations->restartAnimationOnCompositor();
1576 } else { 1576 } else {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 DCHECK(!document().lifecycle().inDetach()); 1681 DCHECK(!document().lifecycle().inDetach());
1682 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc()); 1682 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc());
1683 DCHECK(inActiveDocument()); 1683 DCHECK(inActiveDocument());
1684 1684
1685 if (hasCustomStyleCallbacks()) 1685 if (hasCustomStyleCallbacks())
1686 willRecalcStyle(change); 1686 willRecalcStyle(change);
1687 1687
1688 if (change >= Inherit || needsStyleRecalc()) { 1688 if (change >= Inherit || needsStyleRecalc()) {
1689 if (hasRareData()) { 1689 if (hasRareData()) {
1690 ElementRareData* data = elementRareData(); 1690 ElementRareData* data = elementRareData();
1691 data->clearComputedStyle(); 1691 data->setComputedStyle(nullptr);
1692 1692
1693 if (change >= Inherit) { 1693 if (change >= Inherit) {
1694 if (ElementAnimations* elementAnimations = data->elementAnimatio ns()) 1694 if (ElementAnimations* elementAnimations = data->elementAnimatio ns())
1695 elementAnimations->setAnimationStyleChange(false); 1695 elementAnimations->setAnimationStyleChange(false);
1696 } 1696 }
1697 } 1697 }
1698 if (parentComputedStyle()) 1698 if (parentComputedStyle())
1699 change = recalcOwnStyle(change); 1699 change = recalcOwnStyle(change);
1700 clearNeedsStyleRecalc(); 1700 clearNeedsStyleRecalc();
1701 } 1701 }
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after
2784 // document tree and figure out when to destroy the computed style for s uch elements. 2784 // document tree and figure out when to destroy the computed style for s uch elements.
2785 return nullptr; 2785 return nullptr;
2786 } 2786 }
2787 2787
2788 // FIXME: Find and use the layoutObject from the pseudo element instead of t he actual element so that the 'length' 2788 // FIXME: Find and use the layoutObject from the pseudo element instead of t he actual element so that the 'length'
2789 // properties, which are only known by the layoutObject because it did the l ayout, will be correct and so that the 2789 // properties, which are only known by the layoutObject because it did the l ayout, will be correct and so that the
2790 // values returned for the ":selection" pseudo-element will be correct. 2790 // values returned for the ":selection" pseudo-element will be correct.
2791 ComputedStyle* elementStyle = mutableComputedStyle(); 2791 ComputedStyle* elementStyle = mutableComputedStyle();
2792 if (!elementStyle) { 2792 if (!elementStyle) {
2793 ElementRareData& rareData = ensureElementRareData(); 2793 ElementRareData& rareData = ensureElementRareData();
2794 if (!rareData.ensureComputedStyle()) 2794 if (!rareData.computedStyle())
2795 rareData.setComputedStyle(document().styleForElementIgnoringPendingS tylesheets(this)); 2795 rareData.setComputedStyle(document().styleForElementIgnoringPendingS tylesheets(this));
2796 elementStyle = rareData.ensureComputedStyle(); 2796 elementStyle = rareData.computedStyle();
2797 } 2797 }
2798 2798
2799 if (!pseudoElementSpecifier) 2799 if (!pseudoElementSpecifier)
2800 return elementStyle; 2800 return elementStyle;
2801 2801
2802 if (ComputedStyle* pseudoElementStyle = elementStyle->getCachedPseudoStyle(p seudoElementSpecifier)) 2802 if (ComputedStyle* pseudoElementStyle = elementStyle->getCachedPseudoStyle(p seudoElementSpecifier))
2803 return pseudoElementStyle; 2803 return pseudoElementStyle;
2804 2804
2805 RefPtr<ComputedStyle> result = document().ensureStyleResolver().pseudoStyleF orElement(this, PseudoStyleRequest(pseudoElementSpecifier, PseudoStyleRequest::F orComputedStyle), elementStyle); 2805 RefPtr<ComputedStyle> result = document().ensureStyleResolver().pseudoStyleF orElement(this, PseudoStyleRequest(pseudoElementSpecifier, PseudoStyleRequest::F orComputedStyle), elementStyle);
2806 DCHECK(result); 2806 DCHECK(result);
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after
3704 3704
3705 DEFINE_TRACE_WRAPPERS(Element) 3705 DEFINE_TRACE_WRAPPERS(Element)
3706 { 3706 {
3707 if (hasRareData()) { 3707 if (hasRareData()) {
3708 visitor->traceWrappers(elementRareData()); 3708 visitor->traceWrappers(elementRareData());
3709 } 3709 }
3710 ContainerNode::traceWrappers(visitor); 3710 ContainerNode::traceWrappers(visitor);
3711 } 3711 }
3712 3712
3713 } // namespace blink 3713 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698