| 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 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
| 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 if (!node->isElementNode()) | 611 if (!node->isElementNode()) |
| 612 return nullptr; | 612 return nullptr; |
| 613 if (ElementShadow* shadow = toElement(node)->shadow()) | 613 if (ElementShadow* shadow = toElement(node)->shadow()) |
| 614 return shadow->oldestShadowRoot(); | 614 return shadow->oldestShadowRoot(); |
| 615 return nullptr; | 615 return nullptr; |
| 616 } | 616 } |
| 617 #endif | 617 #endif |
| 618 | 618 |
| 619 Node& Node::shadowIncludingRoot() const | 619 Node& Node::shadowIncludingRoot() const |
| 620 { | 620 { |
| 621 if (inDocument()) | 621 if (inShadowIncludingDocument()) |
| 622 return document(); | 622 return document(); |
| 623 Node* root = const_cast<Node*>(this); | 623 Node* root = const_cast<Node*>(this); |
| 624 while (Node* host = root->shadowHost()) | 624 while (Node* host = root->shadowHost()) |
| 625 root = host; | 625 root = host; |
| 626 while (Node* ancestor = root->parentNode()) | 626 while (Node* ancestor = root->parentNode()) |
| 627 root = ancestor; | 627 root = ancestor; |
| 628 ASSERT(!root->shadowHost()); | 628 ASSERT(!root->shadowHost()); |
| 629 return *root; | 629 return *root; |
| 630 } | 630 } |
| 631 | 631 |
| 632 #if ENABLE(ASSERT) | 632 #if ENABLE(ASSERT) |
| 633 bool Node::needsDistributionRecalc() const | 633 bool Node::needsDistributionRecalc() const |
| 634 { | 634 { |
| 635 return shadowIncludingRoot().childNeedsDistributionRecalc(); | 635 return shadowIncludingRoot().childNeedsDistributionRecalc(); |
| 636 } | 636 } |
| 637 #endif | 637 #endif |
| 638 | 638 |
| 639 void Node::updateDistribution() | 639 void Node::updateDistribution() |
| 640 { | 640 { |
| 641 // Extra early out to avoid spamming traces. | 641 // Extra early out to avoid spamming traces. |
| 642 if (inDocument() && !document().childNeedsDistributionRecalc()) | 642 if (inShadowIncludingDocument() && !document().childNeedsDistributionRecalc(
)) |
| 643 return; | 643 return; |
| 644 TRACE_EVENT0("blink", "Node::updateDistribution"); | 644 TRACE_EVENT0("blink", "Node::updateDistribution"); |
| 645 ScriptForbiddenScope forbidScript; | 645 ScriptForbiddenScope forbidScript; |
| 646 Node& root = shadowIncludingRoot(); | 646 Node& root = shadowIncludingRoot(); |
| 647 if (root.childNeedsDistributionRecalc()) | 647 if (root.childNeedsDistributionRecalc()) |
| 648 root.recalcDistribution(); | 648 root.recalcDistribution(); |
| 649 } | 649 } |
| 650 | 650 |
| 651 void Node::recalcDistribution() | 651 void Node::recalcDistribution() |
| 652 { | 652 { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 { | 687 { |
| 688 ScriptForbiddenScope forbidScriptDuringRawIteration; | 688 ScriptForbiddenScope forbidScriptDuringRawIteration; |
| 689 for (Node* node = parentOrShadowHostNode(); node && !node->childNeedsStyleIn
validation(); node = node->parentOrShadowHostNode()) | 689 for (Node* node = parentOrShadowHostNode(); node && !node->childNeedsStyleIn
validation(); node = node->parentOrShadowHostNode()) |
| 690 node->setChildNeedsStyleInvalidation(); | 690 node->setChildNeedsStyleInvalidation(); |
| 691 document().scheduleLayoutTreeUpdateIfNeeded(); | 691 document().scheduleLayoutTreeUpdateIfNeeded(); |
| 692 } | 692 } |
| 693 | 693 |
| 694 void Node::markAncestorsWithChildNeedsDistributionRecalc() | 694 void Node::markAncestorsWithChildNeedsDistributionRecalc() |
| 695 { | 695 { |
| 696 ScriptForbiddenScope forbidScriptDuringRawIteration; | 696 ScriptForbiddenScope forbidScriptDuringRawIteration; |
| 697 if (RuntimeEnabledFeatures::shadowDOMV1Enabled() && inDocument() && !documen
t().childNeedsDistributionRecalc()) { | 697 if (RuntimeEnabledFeatures::shadowDOMV1Enabled() && inShadowIncludingDocumen
t() && !document().childNeedsDistributionRecalc()) { |
| 698 // TODO(hayato): Support a non-document composed tree. | 698 // TODO(hayato): Support a non-document composed tree. |
| 699 // TODO(hayato): Enqueue a task only if a 'slotchange' event listner is
registered in the document composed tree. | 699 // TODO(hayato): Enqueue a task only if a 'slotchange' event listner is
registered in the document composed tree. |
| 700 Microtask::enqueueMicrotask(WTF::bind(&Document::updateDistribution, Raw
Ptr<Document>(&document()))); | 700 Microtask::enqueueMicrotask(WTF::bind(&Document::updateDistribution, Raw
Ptr<Document>(&document()))); |
| 701 } | 701 } |
| 702 for (Node* node = this; node && !node->childNeedsDistributionRecalc(); node
= node->parentOrShadowHostNode()) | 702 for (Node* node = this; node && !node->childNeedsDistributionRecalc(); node
= node->parentOrShadowHostNode()) |
| 703 node->setChildNeedsDistributionRecalc(); | 703 node->setChildNeedsDistributionRecalc(); |
| 704 document().scheduleLayoutTreeUpdateIfNeeded(); | 704 document().scheduleLayoutTreeUpdateIfNeeded(); |
| 705 } | 705 } |
| 706 | 706 |
| 707 inline void Node::setStyleChange(StyleChangeType changeType) | 707 inline void Node::setStyleChange(StyleChangeType changeType) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 m_nodeFlags &= ~StyleChangeMask; | 745 m_nodeFlags &= ~StyleChangeMask; |
| 746 | 746 |
| 747 clearSVGFilterNeedsLayerUpdate(); | 747 clearSVGFilterNeedsLayerUpdate(); |
| 748 | 748 |
| 749 if (isElementNode() && hasRareData()) | 749 if (isElementNode() && hasRareData()) |
| 750 toElement(*this).setAnimationStyleChange(false); | 750 toElement(*this).setAnimationStyleChange(false); |
| 751 } | 751 } |
| 752 | 752 |
| 753 bool Node::inActiveDocument() const | 753 bool Node::inActiveDocument() const |
| 754 { | 754 { |
| 755 return inDocument() && document().isActive(); | 755 return inShadowIncludingDocument() && document().isActive(); |
| 756 } | 756 } |
| 757 | 757 |
| 758 Node* Node::focusDelegate() | 758 Node* Node::focusDelegate() |
| 759 { | 759 { |
| 760 return this; | 760 return this; |
| 761 } | 761 } |
| 762 | 762 |
| 763 bool Node::shouldHaveFocusAppearance() const | 763 bool Node::shouldHaveFocusAppearance() const |
| 764 { | 764 { |
| 765 ASSERT(focused()); | 765 ASSERT(focused()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 789 } | 789 } |
| 790 | 790 |
| 791 void Node::clearNodeLists() | 791 void Node::clearNodeLists() |
| 792 { | 792 { |
| 793 rareData()->clearNodeLists(); | 793 rareData()->clearNodeLists(); |
| 794 } | 794 } |
| 795 | 795 |
| 796 bool Node::isDescendantOf(const Node *other) const | 796 bool Node::isDescendantOf(const Node *other) const |
| 797 { | 797 { |
| 798 // Return true if other is an ancestor of this, otherwise false | 798 // Return true if other is an ancestor of this, otherwise false |
| 799 if (!other || !other->hasChildren() || inDocument() != other->inDocument()) | 799 if (!other || !other->hasChildren() || inShadowIncludingDocument() != other-
>inShadowIncludingDocument()) |
| 800 return false; | 800 return false; |
| 801 if (other->treeScope() != treeScope()) | 801 if (other->treeScope() != treeScope()) |
| 802 return false; | 802 return false; |
| 803 if (other->isTreeScope()) | 803 if (other->isTreeScope()) |
| 804 return !isTreeScope(); | 804 return !isTreeScope(); |
| 805 for (const ContainerNode* n = parentNode(); n; n = n->parentNode()) { | 805 for (const ContainerNode* n = parentNode(); n; n = n->parentNode()) { |
| 806 if (n == other) | 806 if (n == other) |
| 807 return true; | 807 return true; |
| 808 } | 808 } |
| 809 return false; | 809 return false; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 820 { | 820 { |
| 821 if (!node) | 821 if (!node) |
| 822 return false; | 822 return false; |
| 823 | 823 |
| 824 if (this == node) | 824 if (this == node) |
| 825 return true; | 825 return true; |
| 826 | 826 |
| 827 if (document() != node->document()) | 827 if (document() != node->document()) |
| 828 return false; | 828 return false; |
| 829 | 829 |
| 830 if (inDocument() != node->inDocument()) | 830 if (inShadowIncludingDocument() != node->inShadowIncludingDocument()) |
| 831 return false; | 831 return false; |
| 832 | 832 |
| 833 bool hasChildren = isContainerNode() && toContainerNode(this)->hasChildren()
; | 833 bool hasChildren = isContainerNode() && toContainerNode(this)->hasChildren()
; |
| 834 bool hasShadow = isElementNode() && toElement(this)->shadow(); | 834 bool hasShadow = isElementNode() && toElement(this)->shadow(); |
| 835 if (!hasChildren && !hasShadow) | 835 if (!hasChildren && !hasShadow) |
| 836 return false; | 836 return false; |
| 837 | 837 |
| 838 for (; node; node = node->shadowHost()) { | 838 for (; node; node = node->shadowHost()) { |
| 839 if (treeScope() == node->treeScope()) | 839 if (treeScope() == node->treeScope()) |
| 840 return contains(node); | 840 return contains(node); |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1409 if (attr2->getQualifiedName() == attr.name()) | 1409 if (attr2->getQualifiedName() == attr.name()) |
| 1410 return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSI
TION_PRECEDING; | 1410 return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSI
TION_PRECEDING; |
| 1411 } | 1411 } |
| 1412 | 1412 |
| 1413 ASSERT_NOT_REACHED(); | 1413 ASSERT_NOT_REACHED(); |
| 1414 return DOCUMENT_POSITION_DISCONNECTED; | 1414 return DOCUMENT_POSITION_DISCONNECTED; |
| 1415 } | 1415 } |
| 1416 | 1416 |
| 1417 // If one node is in the document and the other is not, we must be disconnec
ted. | 1417 // If one node is in the document and the other is not, we must be disconnec
ted. |
| 1418 // If the nodes have different owning documents, they must be disconnected.
Note that we avoid | 1418 // If the nodes have different owning documents, they must be disconnected.
Note that we avoid |
| 1419 // comparing Attr nodes here, since they return false from inDocument() all
the time (which seems like a bug). | 1419 // comparing Attr nodes here, since they return false from inShadowIncluding
Document() all the time (which seems like a bug). |
| 1420 if (start1->inDocument() != start2->inDocument() || (treatment == TreatShado
wTreesAsDisconnected && start1->treeScope() != start2->treeScope())) { | 1420 if (start1->inShadowIncludingDocument() != start2->inShadowIncludingDocument
() || (treatment == TreatShadowTreesAsDisconnected && start1->treeScope() != sta
rt2->treeScope())) { |
| 1421 unsigned short direction = (this > otherNode) ? DOCUMENT_POSITION_PRECED
ING : DOCUMENT_POSITION_FOLLOWING; | 1421 unsigned short direction = (this > otherNode) ? DOCUMENT_POSITION_PRECED
ING : DOCUMENT_POSITION_FOLLOWING; |
| 1422 return DOCUMENT_POSITION_DISCONNECTED | DOCUMENT_POSITION_IMPLEMENTATION
_SPECIFIC | direction; | 1422 return DOCUMENT_POSITION_DISCONNECTED | DOCUMENT_POSITION_IMPLEMENTATION
_SPECIFIC | direction; |
| 1423 } | 1423 } |
| 1424 | 1424 |
| 1425 // We need to find a common ancestor container, and then compare the indices
of the two immediate children. | 1425 // We need to find a common ancestor container, and then compare the indices
of the two immediate children. |
| 1426 const Node* current; | 1426 const Node* current; |
| 1427 for (current = start1; current; current = current->parentOrShadowHostNode()) | 1427 for (current = start1; current; current = current->parentOrShadowHostNode()) |
| 1428 chain1.append(current); | 1428 chain1.append(current); |
| 1429 for (current = start2; current; current = current->parentOrShadowHostNode()) | 1429 for (current = start2; current; current = current->parentOrShadowHostNode()) |
| 1430 chain2.append(current); | 1430 chain2.append(current); |
| (...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2447 | 2447 |
| 2448 void showNodePath(const blink::Node* node) | 2448 void showNodePath(const blink::Node* node) |
| 2449 { | 2449 { |
| 2450 if (node) | 2450 if (node) |
| 2451 node->showNodePathForThis(); | 2451 node->showNodePathForThis(); |
| 2452 else | 2452 else |
| 2453 fprintf(stderr, "Cannot showNodePath for (nil)\n"); | 2453 fprintf(stderr, "Cannot showNodePath for (nil)\n"); |
| 2454 } | 2454 } |
| 2455 | 2455 |
| 2456 #endif | 2456 #endif |
| OLD | NEW |