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

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

Issue 77863002: Update styleRecalc so that it traverses shadow insertion points in 2 pass algorithms (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Make styleRecalc traverse shadow trees in 2 pass algorithm Created 7 years 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
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 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 1500
1501 return originalStyleForRenderer(); 1501 return originalStyleForRenderer();
1502 } 1502 }
1503 1503
1504 PassRefPtr<RenderStyle> Element::originalStyleForRenderer() 1504 PassRefPtr<RenderStyle> Element::originalStyleForRenderer()
1505 { 1505 {
1506 ASSERT(document().inStyleRecalc()); 1506 ASSERT(document().inStyleRecalc());
1507 return document().ensureStyleResolver().styleForElement(this); 1507 return document().ensureStyleResolver().styleForElement(this);
1508 } 1508 }
1509 1509
1510 void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling) 1510 void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling, Inser tionPoint* shadowInsertionPoint)
1511 { 1511 {
1512 ASSERT(document().inStyleRecalc()); 1512 ASSERT(document().inStyleRecalc());
1513 ASSERT(!parentOrShadowHostNode()->needsStyleRecalc()); 1513 ASSERT(!parentOrShadowHostNode()->needsStyleRecalc());
1514 1514
1515 if (hasCustomStyleCallbacks()) 1515 if (hasCustomStyleCallbacks())
1516 willRecalcStyle(change); 1516 willRecalcStyle(change);
1517 1517
1518 if (change >= Inherit || needsStyleRecalc()) { 1518 if (change >= Inherit || needsStyleRecalc()) {
1519 if (hasRareData()) { 1519 if (hasRareData()) {
1520 ElementRareData* data = elementRareData(); 1520 ElementRareData* data = elementRareData();
1521 data->resetStyleState(); 1521 data->resetStyleState();
1522 data->clearComputedStyle(); 1522 data->clearComputedStyle();
1523 } 1523 }
1524 if (parentRenderStyle()) 1524 if (parentRenderStyle())
1525 change = recalcOwnStyle(change); 1525 change = recalcOwnStyle(change);
1526 clearNeedsStyleRecalc(); 1526 clearNeedsStyleRecalc();
1527 } 1527 }
1528 1528
1529 // If we reattached we don't need to recalc the style of our descendants any more. 1529 if (this != shadowInsertionPoint) {
1530 if ((change >= Inherit && change < Reattach) || childNeedsStyleRecalc()) 1530 // If we reattached we don't need to recalc the style of our descendants anymore.
1531 recalcChildStyle(change); 1531 if ((change >= Inherit && change < Reattach) || childNeedsStyleRecalc())
1532 clearChildNeedsStyleRecalc(); 1532 recalcChildStyle(change, shadowInsertionPoint);
1533 clearChildNeedsStyleRecalc();
1534 }
1533 1535
1534 if (hasCustomStyleCallbacks()) 1536 if (hasCustomStyleCallbacks())
1535 didRecalcStyle(change); 1537 didRecalcStyle(change);
1536 1538
1537 if (change == Reattach) 1539 if (change == Reattach)
1538 reattachWhitespaceSiblings(nextTextSibling); 1540 reattachWhitespaceSiblings(nextTextSibling);
1539 } 1541 }
1540 1542
1541 StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) 1543 StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change)
1542 { 1544 {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 document().ensureStyleResolver().invalidateMatchedPropertiesCache(); 1590 document().ensureStyleResolver().invalidateMatchedPropertiesCache();
1589 return Force; 1591 return Force;
1590 } 1592 }
1591 1593
1592 if (styleChangeType() >= SubtreeStyleChange) 1594 if (styleChangeType() >= SubtreeStyleChange)
1593 return Force; 1595 return Force;
1594 1596
1595 return max(localChange, change); 1597 return max(localChange, change);
1596 } 1598 }
1597 1599
1598 void Element::recalcChildStyle(StyleRecalcChange change) 1600 void Element::recalcChildStyle(StyleRecalcChange change, InsertionPoint* shadowI nsertionPoint)
1599 { 1601 {
1600 ASSERT(document().inStyleRecalc()); 1602 ASSERT(document().inStyleRecalc());
1601 ASSERT(change >= Inherit || childNeedsStyleRecalc()); 1603 ASSERT(change >= Inherit || childNeedsStyleRecalc());
1602 ASSERT(!needsStyleRecalc()); 1604 ASSERT(!needsStyleRecalc());
1603 1605
1604 StyleResolverParentPusher parentPusher(*this); 1606 StyleResolverParentPusher parentPusher(*this);
1605 1607
1606 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow Root()) { 1608 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow Root()) {
1607 if (shouldRecalcStyle(change, root)) { 1609 if (shouldRecalcStyle(change, root)) {
1608 parentPusher.push(); 1610 parentPusher.push();
1609 root->recalcStyle(change); 1611 root->recalcStyle(change);
1610 } 1612 }
1611 } 1613 }
1612 1614
1615 for (ShadowRoot* root = oldestShadowRoot(); root; root = root->youngerShadow Root()) {
1616 if (InsertionPoint* insertionPoint = root->shadowInsertionPoint()) {
1617 if ((change >= Inherit && change < Reattach) || insertionPoint->chil dNeedsStyleRecalc())
esprehn 2013/12/11 09:53:27 if (shouldRecalcStyle(change, insertionPoint)) We
1618 insertionPoint->recalcChildStyle(change, 0);
esprehn 2013/12/11 09:53:27 This doesn't work, the bloom filter is wrong at th
1619 insertionPoint->clearChildNeedsStyleRecalc();
esprehn 2013/12/11 09:53:27 If you make the above change this goes away.
1620 }
1621 }
1622
1613 if (shouldRecalcStyle(change, this)) 1623 if (shouldRecalcStyle(change, this))
1614 updatePseudoElement(BEFORE, change); 1624 updatePseudoElement(BEFORE, change);
1615 1625
1616 if (change < Force && hasRareData() && childNeedsStyleRecalc()) 1626 if (change < Force && hasRareData() && childNeedsStyleRecalc())
1617 checkForChildrenAdjacentRuleChanges(); 1627 checkForChildrenAdjacentRuleChanges();
1618 1628
1619 // This loop is deliberately backwards because we use insertBefore in the re ndering tree, and want to avoid 1629 // This loop is deliberately backwards because we use insertBefore in the re ndering tree, and want to avoid
1620 // a potentially n^2 loop to find the insertion point while resolving style. Having us start from the last 1630 // a potentially n^2 loop to find the insertion point while resolving style. Having us start from the last
1621 // child and work our way back means in the common case, we'll find the inse rtion point in O(1) time. 1631 // child and work our way back means in the common case, we'll find the inse rtion point in O(1) time.
1622 // See crbug.com/288225 1632 // See crbug.com/288225
1623 StyleResolver& styleResolver = document().ensureStyleResolver(); 1633 StyleResolver& styleResolver = document().ensureStyleResolver();
1624 Text* lastTextNode = 0; 1634 Text* lastTextNode = 0;
1625 for (Node* child = lastChild(); child; child = child->previousSibling()) { 1635 for (Node* child = lastChild(); child; child = child->previousSibling()) {
1626 if (child->isTextNode()) { 1636 if (child->isTextNode()) {
1627 toText(child)->recalcTextStyle(change, lastTextNode); 1637 toText(child)->recalcTextStyle(change, lastTextNode);
1628 lastTextNode = toText(child); 1638 lastTextNode = toText(child);
1629 } else if (child->isElementNode()) { 1639 } else if (child->isElementNode()) {
1630 Element* element = toElement(child); 1640 Element* element = toElement(child);
1631 if (shouldRecalcStyle(change, element)) { 1641 if (shouldRecalcStyle(change, element)) {
1632 parentPusher.push(); 1642 parentPusher.push();
1633 element->recalcStyle(change, lastTextNode); 1643 element->recalcStyle(change, lastTextNode, shadowInsertionPoint) ;
1634 } else if (element->supportsStyleSharing()) { 1644 } else if (element->supportsStyleSharing()) {
1635 styleResolver.addToStyleSharingList(*element); 1645 styleResolver.addToStyleSharingList(*element);
1636 } 1646 }
1637 if (element->renderer()) 1647 if (element->renderer())
1638 lastTextNode = 0; 1648 lastTextNode = 0;
1639 } 1649 }
1640 } 1650 }
1641 1651
1642 if (shouldRecalcStyle(change, this)) { 1652 if (shouldRecalcStyle(change, this)) {
1643 updatePseudoElement(AFTER, change); 1653 updatePseudoElement(AFTER, change);
(...skipping 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after
3536 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems 3546 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems
3537 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405 3547 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405
3538 if (hasTagName(optionTag) || hasTagName(optgroupTag)) 3548 if (hasTagName(optionTag) || hasTagName(optgroupTag))
3539 return false; 3549 return false;
3540 if (FullscreenElementStack::isActiveFullScreenElement(this)) 3550 if (FullscreenElementStack::isActiveFullScreenElement(this))
3541 return false; 3551 return false;
3542 return true; 3552 return true;
3543 } 3553 }
3544 3554
3545 } // namespace WebCore 3555 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698