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

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

Issue 889563002: Make RenderObject::style() return a const object (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated change after Doug's review. Created 5 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/dom/FirstLetterPseudoElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after
1627 reattachWhitespaceSiblingsIfNeeded(nextTextSibling); 1627 reattachWhitespaceSiblingsIfNeeded(nextTextSibling);
1628 } 1628 }
1629 1629
1630 StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) 1630 StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change)
1631 { 1631 {
1632 ASSERT(document().inStyleRecalc()); 1632 ASSERT(document().inStyleRecalc());
1633 ASSERT(!parentOrShadowHostNode()->needsStyleRecalc()); 1633 ASSERT(!parentOrShadowHostNode()->needsStyleRecalc());
1634 ASSERT(change >= Inherit || needsStyleRecalc()); 1634 ASSERT(change >= Inherit || needsStyleRecalc());
1635 ASSERT(parentLayoutStyle()); 1635 ASSERT(parentLayoutStyle());
1636 1636
1637 RefPtr<LayoutStyle> oldStyle = layoutStyle(); 1637 RefPtr<LayoutStyle> oldStyle = mutableLayoutStyle();
1638 RefPtr<LayoutStyle> newStyle = styleForRenderer(); 1638 RefPtr<LayoutStyle> newStyle = styleForRenderer();
1639 StyleRecalcChange localChange = LayoutStyle::stylePropagationDiff(oldStyle.g et(), newStyle.get()); 1639 StyleRecalcChange localChange = LayoutStyle::stylePropagationDiff(oldStyle.g et(), newStyle.get());
1640 1640
1641 ASSERT(newStyle); 1641 ASSERT(newStyle);
1642 1642
1643 if (localChange == Reattach) { 1643 if (localChange == Reattach) {
1644 AttachContext reattachContext; 1644 AttachContext reattachContext;
1645 reattachContext.resolvedStyle = newStyle.get(); 1645 reattachContext.resolvedStyle = newStyle.get();
1646 bool rendererWillChange = needsAttach() || renderer(); 1646 bool rendererWillChange = needsAttach() || renderer();
1647 reattach(reattachContext); 1647 reattach(reattachContext);
(...skipping 24 matching lines...) Expand all
1672 1672
1673 if (change > Inherit || localChange > Inherit) 1673 if (change > Inherit || localChange > Inherit)
1674 return max(localChange, change); 1674 return max(localChange, change);
1675 1675
1676 if (localChange < Inherit && (oldStyle->hasPseudoElementStyle() || newStyle- >hasPseudoElementStyle())) 1676 if (localChange < Inherit && (oldStyle->hasPseudoElementStyle() || newStyle- >hasPseudoElementStyle()))
1677 return UpdatePseudoElements; 1677 return UpdatePseudoElements;
1678 1678
1679 return localChange; 1679 return localChange;
1680 } 1680 }
1681 1681
1682 void Element::updateCallbackSelectors(LayoutStyle* oldStyle, LayoutStyle* newSty le) 1682 void Element::updateCallbackSelectors(const LayoutStyle* oldStyle, const LayoutS tyle* newStyle)
1683 { 1683 {
1684 Vector<String> emptyVector; 1684 Vector<String> emptyVector;
1685 const Vector<String>& oldCallbackSelectors = oldStyle ? oldStyle->callbackSe lectors() : emptyVector; 1685 const Vector<String>& oldCallbackSelectors = oldStyle ? oldStyle->callbackSe lectors() : emptyVector;
1686 const Vector<String>& newCallbackSelectors = newStyle ? newStyle->callbackSe lectors() : emptyVector; 1686 const Vector<String>& newCallbackSelectors = newStyle ? newStyle->callbackSe lectors() : emptyVector;
1687 if (oldCallbackSelectors.isEmpty() && newCallbackSelectors.isEmpty()) 1687 if (oldCallbackSelectors.isEmpty() && newCallbackSelectors.isEmpty())
1688 return; 1688 return;
1689 if (oldCallbackSelectors != newCallbackSelectors) 1689 if (oldCallbackSelectors != newCallbackSelectors)
1690 CSSSelectorWatch::from(document()).updateSelectorMatches(oldCallbackSele ctors, newCallbackSelectors); 1690 CSSSelectorWatch::from(document()).updateSelectorMatches(oldCallbackSele ctors, newCallbackSelectors);
1691 } 1691 }
1692 1692
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1823 case CDATA_SECTION_NODE: 1823 case CDATA_SECTION_NODE:
1824 return true; 1824 return true;
1825 default: 1825 default:
1826 break; 1826 break;
1827 } 1827 }
1828 return false; 1828 return false;
1829 } 1829 }
1830 1830
1831 void Element::checkForEmptyStyleChange() 1831 void Element::checkForEmptyStyleChange()
1832 { 1832 {
1833 LayoutStyle* style = layoutStyle(); 1833 const LayoutStyle* style = layoutStyle();
1834 1834
1835 if (!style && !styleAffectedByEmpty()) 1835 if (!style && !styleAffectedByEmpty())
1836 return; 1836 return;
1837 if (styleChangeType() >= SubtreeStyleChange) 1837 if (styleChangeType() >= SubtreeStyleChange)
1838 return; 1838 return;
1839 if (!inActiveDocument()) 1839 if (!inActiveDocument())
1840 return; 1840 return;
1841 if (!document().styleResolver()) 1841 if (!document().styleResolver())
1842 return; 1842 return;
1843 1843
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
2515 2515
2516 if (!inActiveDocument()) { 2516 if (!inActiveDocument()) {
2517 // FIXME: Try to do better than this. Ensure that styleForElement() work s for elements that are not in the 2517 // FIXME: Try to do better than this. Ensure that styleForElement() work s for elements that are not in the
2518 // document tree and figure out when to destroy the computed style for s uch elements. 2518 // document tree and figure out when to destroy the computed style for s uch elements.
2519 return nullptr; 2519 return nullptr;
2520 } 2520 }
2521 2521
2522 // FIXME: Find and use the renderer from the pseudo element instead of the a ctual element so that the 'length' 2522 // FIXME: Find and use the renderer from the pseudo element instead of the a ctual element so that the 'length'
2523 // properties, which are only known by the renderer because it did the layou t, will be correct and so that the 2523 // properties, which are only known by the renderer because it did the layou t, will be correct and so that the
2524 // values returned for the ":selection" pseudo-element will be correct. 2524 // values returned for the ":selection" pseudo-element will be correct.
2525 LayoutStyle* elementStyle = layoutStyle(); 2525 LayoutStyle* elementStyle = mutableLayoutStyle();
2526 if (!elementStyle) { 2526 if (!elementStyle) {
2527 ElementRareData& rareData = ensureElementRareData(); 2527 ElementRareData& rareData = ensureElementRareData();
2528 if (!rareData.computedStyle()) 2528 if (!rareData.computedStyle())
2529 rareData.setComputedStyle(document().styleForElementIgnoringPendingS tylesheets(this)); 2529 rareData.setComputedStyle(document().styleForElementIgnoringPendingS tylesheets(this));
2530 elementStyle = rareData.computedStyle(); 2530 elementStyle = rareData.computedStyle();
2531 } 2531 }
2532 2532
2533 if (!pseudoElementSpecifier) 2533 if (!pseudoElementSpecifier)
2534 return elementStyle; 2534 return elementStyle;
2535 2535
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2598 ASSERT(!needsStyleRecalc()); 2598 ASSERT(!needsStyleRecalc());
2599 PseudoElement* element = pseudoElement(pseudoId); 2599 PseudoElement* element = pseudoElement(pseudoId);
2600 2600
2601 if (element && (change == UpdatePseudoElements || element->shouldCallRecalcS tyle(change))) { 2601 if (element && (change == UpdatePseudoElements || element->shouldCallRecalcS tyle(change))) {
2602 if (pseudoId == FIRST_LETTER && updateFirstLetter(element)) 2602 if (pseudoId == FIRST_LETTER && updateFirstLetter(element))
2603 return; 2603 return;
2604 2604
2605 // Need to clear the cached style if the PseudoElement wants a recalc so it 2605 // Need to clear the cached style if the PseudoElement wants a recalc so it
2606 // computes a new style. 2606 // computes a new style.
2607 if (element->needsStyleRecalc()) 2607 if (element->needsStyleRecalc())
2608 renderer()->style()->removeCachedPseudoStyle(pseudoId); 2608 renderer()->mutableStyleRef().removeCachedPseudoStyle(pseudoId);
2609 2609
2610 // PseudoElement styles hang off their parent element's style so if we n eeded 2610 // PseudoElement styles hang off their parent element's style so if we n eeded
2611 // a style recalc we should Force one on the pseudo. 2611 // a style recalc we should Force one on the pseudo.
2612 // FIXME: We should figure out the right text sibling to pass. 2612 // FIXME: We should figure out the right text sibling to pass.
2613 element->recalcStyle(change == UpdatePseudoElements ? Force : change); 2613 element->recalcStyle(change == UpdatePseudoElements ? Force : change);
2614 2614
2615 // Wait until our parent is not displayed or pseudoElementRendererIsNeed ed 2615 // Wait until our parent is not displayed or pseudoElementRendererIsNeed ed
2616 // is false, otherwise we could continuously create and destroy PseudoEl ements 2616 // is false, otherwise we could continuously create and destroy PseudoEl ements
2617 // when LayoutObject::isChildAllowed on our parent returns false for the 2617 // when LayoutObject::isChildAllowed on our parent returns false for the
2618 // PseudoElement's renderer for each style recalc. 2618 // PseudoElement's renderer for each style recalc.
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
3370 { 3370 {
3371 #if ENABLE(OILPAN) 3371 #if ENABLE(OILPAN)
3372 if (hasRareData()) 3372 if (hasRareData())
3373 visitor->trace(elementRareData()); 3373 visitor->trace(elementRareData());
3374 visitor->trace(m_elementData); 3374 visitor->trace(m_elementData);
3375 #endif 3375 #endif
3376 ContainerNode::trace(visitor); 3376 ContainerNode::trace(visitor);
3377 } 3377 }
3378 3378
3379 } // namespace blink 3379 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/dom/FirstLetterPseudoElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698