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

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

Issue 548693002: Share recalcChildStyle between Element and ShadowRoot. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add back parent scope for ShadowRoot. Created 6 years, 3 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/shadow/ShadowRoot.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 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 activeAnimations->setAnimationStyleChange(false); 1485 activeAnimations->setAnimationStyleChange(false);
1486 } 1486 }
1487 } 1487 }
1488 if (parentRenderStyle()) 1488 if (parentRenderStyle())
1489 change = recalcOwnStyle(change); 1489 change = recalcOwnStyle(change);
1490 clearNeedsStyleRecalc(); 1490 clearNeedsStyleRecalc();
1491 } 1491 }
1492 1492
1493 // If we reattached we don't need to recalc the style of our descendants any more. 1493 // If we reattached we don't need to recalc the style of our descendants any more.
1494 if ((change >= UpdatePseudoElements && change < Reattach) || childNeedsStyle Recalc()) { 1494 if ((change >= UpdatePseudoElements && change < Reattach) || childNeedsStyle Recalc()) {
1495 recalcChildStyle(change); 1495 StyleResolverParentScope parentScope(*this);
1496
1497 updatePseudoElement(BEFORE, change);
1498
1499 if (change > UpdatePseudoElements || childNeedsStyleRecalc()) {
1500 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->old erShadowRoot()) {
1501 if (root->shouldCallRecalcStyle(change))
1502 root->recalcStyle(change);
1503 }
1504 recalcChildStyle(change);
1505 }
1506
1507 updatePseudoElement(AFTER, change);
1508 updatePseudoElement(BACKDROP, change);
1509
1496 clearChildNeedsStyleRecalc(); 1510 clearChildNeedsStyleRecalc();
1497 } 1511 }
1498 1512
1499 if (hasCustomStyleCallbacks()) 1513 if (hasCustomStyleCallbacks())
1500 didRecalcStyle(change); 1514 didRecalcStyle(change);
1501 1515
1502 if (change == Reattach) 1516 if (change == Reattach)
1503 reattachWhitespaceSiblings(nextTextSibling); 1517 reattachWhitespaceSiblings(nextTextSibling);
1504 } 1518 }
1505 1519
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 1562
1549 if (change > Inherit || localChange > Inherit) 1563 if (change > Inherit || localChange > Inherit)
1550 return max(localChange, change); 1564 return max(localChange, change);
1551 1565
1552 if (localChange < Inherit && (oldStyle->hasPseudoElementStyle() || newStyle- >hasPseudoElementStyle())) 1566 if (localChange < Inherit && (oldStyle->hasPseudoElementStyle() || newStyle- >hasPseudoElementStyle()))
1553 return UpdatePseudoElements; 1567 return UpdatePseudoElements;
1554 1568
1555 return localChange; 1569 return localChange;
1556 } 1570 }
1557 1571
1558 void Element::recalcChildStyle(StyleRecalcChange change)
1559 {
1560 ASSERT(document().inStyleRecalc());
1561 ASSERT(change >= UpdatePseudoElements || childNeedsStyleRecalc());
1562 ASSERT(!needsStyleRecalc());
1563
1564 StyleResolverParentScope parentScope(*this);
1565
1566 updatePseudoElement(BEFORE, change);
1567
1568 if (change > UpdatePseudoElements || childNeedsStyleRecalc()) {
1569 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderSh adowRoot()) {
1570 if (root->shouldCallRecalcStyle(change))
1571 root->recalcStyle(change);
1572 }
1573 }
1574
1575 if (change < Force && hasRareData() && childNeedsStyleRecalc())
1576 checkForChildrenAdjacentRuleChanges();
1577
1578 if (change > UpdatePseudoElements || childNeedsStyleRecalc()) {
1579 // This loop is deliberately backwards because we use insertBefore in th e rendering tree, and want to avoid
1580 // a potentially n^2 loop to find the insertion point while resolving st yle. Having us start from the last
1581 // child and work our way back means in the common case, we'll find the insertion point in O(1) time.
1582 // See crbug.com/288225
1583 StyleResolver& styleResolver = document().ensureStyleResolver();
1584 Text* lastTextNode = 0;
1585 for (Node* child = lastChild(); child; child = child->previousSibling()) {
1586 if (child->isTextNode()) {
1587 toText(child)->recalcTextStyle(change, lastTextNode);
1588 lastTextNode = toText(child);
1589 } else if (child->isElementNode()) {
1590 Element* element = toElement(child);
1591 if (element->shouldCallRecalcStyle(change))
1592 element->recalcStyle(change, lastTextNode);
1593 else if (element->supportsStyleSharing())
1594 styleResolver.addToStyleSharingList(*element);
1595 if (element->renderer())
1596 lastTextNode = 0;
1597 }
1598 }
1599 }
1600
1601 updatePseudoElement(AFTER, change);
1602 updatePseudoElement(BACKDROP, change);
1603 }
1604
1605 void Element::updateCallbackSelectors(RenderStyle* oldStyle, RenderStyle* newSty le) 1572 void Element::updateCallbackSelectors(RenderStyle* oldStyle, RenderStyle* newSty le)
1606 { 1573 {
1607 Vector<String> emptyVector; 1574 Vector<String> emptyVector;
1608 const Vector<String>& oldCallbackSelectors = oldStyle ? oldStyle->callbackSe lectors() : emptyVector; 1575 const Vector<String>& oldCallbackSelectors = oldStyle ? oldStyle->callbackSe lectors() : emptyVector;
1609 const Vector<String>& newCallbackSelectors = newStyle ? newStyle->callbackSe lectors() : emptyVector; 1576 const Vector<String>& newCallbackSelectors = newStyle ? newStyle->callbackSe lectors() : emptyVector;
1610 if (oldCallbackSelectors.isEmpty() && newCallbackSelectors.isEmpty()) 1577 if (oldCallbackSelectors.isEmpty() && newCallbackSelectors.isEmpty())
1611 return; 1578 return;
1612 if (oldCallbackSelectors != newCallbackSelectors) 1579 if (oldCallbackSelectors != newCallbackSelectors)
1613 CSSSelectorWatch::from(document()).updateSelectorMatches(oldCallbackSele ctors, newCallbackSelectors); 1580 CSSSelectorWatch::from(document()).updateSelectorMatches(oldCallbackSele ctors, newCallbackSelectors);
1614 } 1581 }
(...skipping 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after
3262 { 3229 {
3263 #if ENABLE(OILPAN) 3230 #if ENABLE(OILPAN)
3264 if (hasRareData()) 3231 if (hasRareData())
3265 visitor->trace(elementRareData()); 3232 visitor->trace(elementRareData());
3266 visitor->trace(m_elementData); 3233 visitor->trace(m_elementData);
3267 #endif 3234 #endif
3268 ContainerNode::trace(visitor); 3235 ContainerNode::trace(visitor);
3269 } 3236 }
3270 3237
3271 } // namespace blink 3238 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/dom/shadow/ShadowRoot.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698