OLD | NEW |
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 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1435 // is needed, but for now just assume a layout will be required.
The diff code | 1435 // is needed, but for now just assume a layout will be required.
The diff code |
1436 // in RenderObject::setStyle would need to be factored out so th
at it could be reused. | 1436 // in RenderObject::setStyle would need to be factored out so th
at it could be reused. |
1437 renderer()->setNeedsLayoutAndPrefWidthsRecalc(); | 1437 renderer()->setNeedsLayoutAndPrefWidthsRecalc(); |
1438 } | 1438 } |
1439 return true; | 1439 return true; |
1440 } | 1440 } |
1441 } | 1441 } |
1442 return false; | 1442 return false; |
1443 } | 1443 } |
1444 | 1444 |
1445 PassRefPtr<RenderStyle> Element::styleForRenderer(int childIndex) | 1445 PassRefPtr<RenderStyle> Element::styleForRenderer() |
1446 { | 1446 { |
1447 if (hasCustomStyleCallbacks()) { | 1447 if (hasCustomStyleCallbacks()) { |
1448 if (RefPtr<RenderStyle> style = customStyleForRenderer()) | 1448 if (RefPtr<RenderStyle> style = customStyleForRenderer()) |
1449 return style.release(); | 1449 return style.release(); |
1450 } | 1450 } |
1451 | 1451 |
1452 return originalStyleForRenderer(childIndex); | 1452 return originalStyleForRenderer(); |
1453 } | 1453 } |
1454 | 1454 |
1455 PassRefPtr<RenderStyle> Element::originalStyleForRenderer(int childIndex) | 1455 PassRefPtr<RenderStyle> Element::originalStyleForRenderer() |
1456 { | 1456 { |
1457 return document()->styleResolver()->styleForElement(this, childIndex); | 1457 return document()->styleResolver()->styleForElement(this); |
1458 } | 1458 } |
1459 | 1459 |
1460 bool Element::recalcStyle(StyleChange change, int childIndex) | 1460 bool Element::recalcStyle(StyleChange change) |
1461 { | 1461 { |
1462 ASSERT(document()->inStyleRecalc()); | 1462 ASSERT(document()->inStyleRecalc()); |
1463 | 1463 |
1464 if (hasCustomStyleCallbacks()) | 1464 if (hasCustomStyleCallbacks()) |
1465 willRecalcStyle(change); | 1465 willRecalcStyle(change); |
1466 | 1466 |
1467 // Ref currentStyle in case it would otherwise be deleted when setting the n
ew style in the renderer. | 1467 // Ref currentStyle in case it would otherwise be deleted when setting the n
ew style in the renderer. |
1468 RefPtr<RenderStyle> currentStyle(renderStyle()); | 1468 RefPtr<RenderStyle> currentStyle(renderStyle()); |
1469 bool hasParentStyle = parentNodeForRenderingAndStyle() ? static_cast<bool>(p
arentNodeForRenderingAndStyle()->renderStyle()) : false; | 1469 bool hasParentStyle = parentNodeForRenderingAndStyle() ? static_cast<bool>(p
arentNodeForRenderingAndStyle()->renderStyle()) : false; |
1470 bool hasDirectAdjacentRules = childrenAffectedByDirectAdjacentRules(); | 1470 bool hasDirectAdjacentRules = childrenAffectedByDirectAdjacentRules(); |
1471 bool hasIndirectAdjacentRules = childrenAffectedByForwardPositionalRules(); | 1471 bool hasIndirectAdjacentRules = childrenAffectedByForwardPositionalRules(); |
1472 | 1472 |
1473 if ((change > NoChange || needsStyleRecalc())) { | 1473 if ((change > NoChange || needsStyleRecalc())) { |
1474 if (hasRareData()) | 1474 if (hasRareData()) |
1475 elementRareData()->resetComputedStyle(); | 1475 elementRareData()->resetComputedStyle(); |
1476 } | 1476 } |
1477 if (hasParentStyle && (change >= Inherit || needsStyleRecalc())) { | 1477 if (hasParentStyle && (change >= Inherit || needsStyleRecalc())) { |
1478 StyleChange localChange = Detach; | 1478 StyleChange localChange = Detach; |
1479 RefPtr<RenderStyle> newStyle; | 1479 RefPtr<RenderStyle> newStyle; |
1480 if (currentStyle) { | 1480 if (currentStyle) { |
1481 // FIXME: This still recalcs style twice when changing display types
, but saves | 1481 // FIXME: This still recalcs style twice when changing display types
, but saves |
1482 // us from recalcing twice when going from none -> anything else whi
ch is more | 1482 // us from recalcing twice when going from none -> anything else whi
ch is more |
1483 // common, especially during lazy attach. | 1483 // common, especially during lazy attach. |
1484 newStyle = styleForRenderer(childIndex); | 1484 newStyle = styleForRenderer(); |
1485 localChange = Node::diff(currentStyle.get(), newStyle.get(), documen
t()); | 1485 localChange = Node::diff(currentStyle.get(), newStyle.get(), documen
t()); |
1486 } else if (attached() && isActiveInsertionPoint(this)) { | 1486 } else if (attached() && isActiveInsertionPoint(this)) { |
1487 // Active InsertionPoints will never have renderers so there's no re
ason to | 1487 // Active InsertionPoints will never have renderers so there's no re
ason to |
1488 // reattach them repeatedly once they're already attached. | 1488 // reattach them repeatedly once they're already attached. |
1489 localChange = change; | 1489 localChange = change; |
1490 } | 1490 } |
1491 if (localChange == Detach) { | 1491 if (localChange == Detach) { |
1492 AttachContext reattachContext; | 1492 AttachContext reattachContext; |
1493 reattachContext.resolvedStyle = newStyle.get(); | 1493 reattachContext.resolvedStyle = newStyle.get(); |
1494 reattach(reattachContext); | 1494 reattach(reattachContext); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1541 updatePseudoElement(BEFORE, change); | 1541 updatePseudoElement(BEFORE, change); |
1542 | 1542 |
1543 // FIXME: This check is good enough for :hover + foo, but it is not good eno
ugh for :hover + foo + bar. | 1543 // FIXME: This check is good enough for :hover + foo, but it is not good eno
ugh for :hover + foo + bar. |
1544 // For now we will just worry about the common case, since it's a lot tricki
er to get the second case right | 1544 // For now we will just worry about the common case, since it's a lot tricki
er to get the second case right |
1545 // without doing way too much re-resolution. | 1545 // without doing way too much re-resolution. |
1546 bool forceCheckOfNextElementSibling = false; | 1546 bool forceCheckOfNextElementSibling = false; |
1547 bool forceCheckOfAnyElementSibling = false; | 1547 bool forceCheckOfAnyElementSibling = false; |
1548 int indexForChild = 1; | 1548 int indexForChild = 1; |
1549 if (hasDirectAdjacentRules || hasIndirectAdjacentRules) { | 1549 if (hasDirectAdjacentRules || hasIndirectAdjacentRules) { |
1550 for (Node *child = firstChild(); child; child = child->nextSibling()) { | 1550 for (Node *child = firstChild(); child; child = child->nextSibling()) { |
1551 ++indexForChild; | |
1552 if (!child->isElementNode()) | 1551 if (!child->isElementNode()) |
1553 continue; | 1552 continue; |
1554 Element* element = toElement(child); | 1553 Element* element = toElement(child); |
1555 bool childRulesChanged = element->needsStyleRecalc() && element->sty
leChangeType() == SubtreeStyleChange; | 1554 bool childRulesChanged = element->needsStyleRecalc() && element->sty
leChangeType() == SubtreeStyleChange; |
1556 if (forceCheckOfNextElementSibling || forceCheckOfAnyElementSibling) | 1555 if (forceCheckOfNextElementSibling || forceCheckOfAnyElementSibling) |
1557 element->setNeedsStyleRecalc(); | 1556 element->setNeedsStyleRecalc(); |
1558 forceCheckOfNextElementSibling = childRulesChanged && hasDirectAdjac
entRules; | 1557 forceCheckOfNextElementSibling = childRulesChanged && hasDirectAdjac
entRules; |
1559 forceCheckOfAnyElementSibling = forceCheckOfAnyElementSibling || (ch
ildRulesChanged && hasIndirectAdjacentRules); | 1558 forceCheckOfAnyElementSibling = forceCheckOfAnyElementSibling || (ch
ildRulesChanged && hasIndirectAdjacentRules); |
1560 } | 1559 } |
1561 } | 1560 } |
1562 // FIXME: Reversing the loop we call recalcStyle avoids an N^2 walk through
the DOM to find the next renderer | 1561 // FIXME: Reversing the loop we call recalcStyle avoids an N^2 walk through
the DOM to find the next renderer |
1563 // to insert before. The logic in NodeRenderingContext should be improved to
make this unnecessary. | 1562 // to insert before. The logic in NodeRenderingContext should be improved to
make this unnecessary. |
1564 for (Node *child = lastChild(); child; child = child->previousSibling()) { | 1563 for (Node *child = lastChild(); child; child = child->previousSibling()) { |
1565 indexForChild = max(--indexForChild, 0); | |
1566 bool didReattach = false; | 1564 bool didReattach = false; |
1567 | 1565 |
1568 if (child->isTextNode()) { | 1566 if (child->isTextNode()) { |
1569 didReattach = toText(child)->recalcTextStyle(change); | 1567 didReattach = toText(child)->recalcTextStyle(change); |
1570 } else if (child->isElementNode()) { | 1568 } else if (child->isElementNode()) { |
1571 Element* element = toElement(child); | 1569 Element* element = toElement(child); |
1572 | 1570 |
1573 if (shouldRecalcStyle(change, element)) { | 1571 if (shouldRecalcStyle(change, element)) { |
1574 parentPusher.push(); | 1572 parentPusher.push(); |
1575 didReattach = element->recalcStyle(change, indexForChild); | 1573 didReattach = element->recalcStyle(change); |
1576 } | 1574 } |
1577 } | 1575 } |
1578 | 1576 |
1579 if (didReattach) | 1577 if (didReattach) |
1580 child->reattachWhitespaceSiblings(); | 1578 child->reattachWhitespaceSiblings(); |
1581 } | 1579 } |
1582 | 1580 |
1583 if (shouldRecalcStyle(change, this)) | 1581 if (shouldRecalcStyle(change, this)) |
1584 updatePseudoElement(AFTER, change); | 1582 updatePseudoElement(AFTER, change); |
1585 | 1583 |
(...skipping 2067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3653 return 0; | 3651 return 0; |
3654 } | 3652 } |
3655 | 3653 |
3656 Attribute* UniqueElementData::attributeItem(unsigned index) | 3654 Attribute* UniqueElementData::attributeItem(unsigned index) |
3657 { | 3655 { |
3658 ASSERT_WITH_SECURITY_IMPLICATION(index < length()); | 3656 ASSERT_WITH_SECURITY_IMPLICATION(index < length()); |
3659 return &m_attributeVector.at(index); | 3657 return &m_attributeVector.at(index); |
3660 } | 3658 } |
3661 | 3659 |
3662 } // namespace WebCore | 3660 } // namespace WebCore |
OLD | NEW |