| 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 Apple Inc. All rights reserv
ed. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 if (childCountDelta) | 274 if (childCountDelta) |
| 275 childrenChanged(false, prev.get(), next.get(), childCountDelta); | 275 childrenChanged(false, prev.get(), next.get(), childCountDelta); |
| 276 dispatchSubtreeModifiedEvent(); | 276 dispatchSubtreeModifiedEvent(); |
| 277 return true; | 277 return true; |
| 278 } | 278 } |
| 279 | 279 |
| 280 void ContainerNode::willRemove() | 280 void ContainerNode::willRemove() |
| 281 { | 281 { |
| 282 for (Node *n = m_firstChild; n != 0; n = n->nextSibling()) | 282 for (Node *n = m_firstChild; n != 0; n = n->nextSibling()) |
| 283 n->willRemove(); | 283 n->willRemove(); |
| 284 Node::willRemove(); | 284 EventTargetNode::willRemove(); |
| 285 } | 285 } |
| 286 | 286 |
| 287 static ExceptionCode willRemoveChild(Node *child) | 287 static ExceptionCode willRemoveChild(Node *child) |
| 288 { | 288 { |
| 289 ExceptionCode ec = 0; | 289 ExceptionCode ec = 0; |
| 290 | 290 |
| 291 // fire removed from document mutation events. | 291 // fire removed from document mutation events. |
| 292 dispatchChildRemovalEvents(child, ec); | 292 dispatchChildRemovalEvents(child, ec); |
| 293 if (ec) | 293 if (ec) |
| 294 return ec; | 294 return ec; |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 } | 563 } |
| 564 s_postAttachCallbackQueue->clear(); | 564 s_postAttachCallbackQueue->clear(); |
| 565 } | 565 } |
| 566 | 566 |
| 567 void ContainerNode::attach() | 567 void ContainerNode::attach() |
| 568 { | 568 { |
| 569 ++s_attachDepth; | 569 ++s_attachDepth; |
| 570 | 570 |
| 571 for (Node* child = m_firstChild; child; child = child->nextSibling()) | 571 for (Node* child = m_firstChild; child; child = child->nextSibling()) |
| 572 child->attach(); | 572 child->attach(); |
| 573 Node::attach(); | 573 EventTargetNode::attach(); |
| 574 | 574 |
| 575 if (s_attachDepth == 1 && s_postAttachCallbackQueue) | 575 if (s_attachDepth == 1 && s_postAttachCallbackQueue) |
| 576 dispatchPostAttachCallbacks(); | 576 dispatchPostAttachCallbacks(); |
| 577 --s_attachDepth; | 577 --s_attachDepth; |
| 578 } | 578 } |
| 579 | 579 |
| 580 void ContainerNode::detach() | 580 void ContainerNode::detach() |
| 581 { | 581 { |
| 582 for (Node* child = m_firstChild; child; child = child->nextSibling()) | 582 for (Node* child = m_firstChild; child; child = child->nextSibling()) |
| 583 child->detach(); | 583 child->detach(); |
| 584 setHasChangedChild(false); | 584 setHasChangedChild(false); |
| 585 Node::detach(); | 585 EventTargetNode::detach(); |
| 586 } | 586 } |
| 587 | 587 |
| 588 void ContainerNode::insertedIntoDocument() | 588 void ContainerNode::insertedIntoDocument() |
| 589 { | 589 { |
| 590 Node::insertedIntoDocument(); | 590 EventTargetNode::insertedIntoDocument(); |
| 591 insertedIntoTree(false); | 591 insertedIntoTree(false); |
| 592 for (Node* child = m_firstChild; child; child = child->nextSibling()) | 592 for (Node* child = m_firstChild; child; child = child->nextSibling()) |
| 593 child->insertedIntoDocument(); | 593 child->insertedIntoDocument(); |
| 594 } | 594 } |
| 595 | 595 |
| 596 void ContainerNode::removedFromDocument() | 596 void ContainerNode::removedFromDocument() |
| 597 { | 597 { |
| 598 Node::removedFromDocument(); | 598 EventTargetNode::removedFromDocument(); |
| 599 setInDocument(false); | 599 setInDocument(false); |
| 600 removedFromTree(false); | 600 removedFromTree(false); |
| 601 for (Node* child = m_firstChild; child; child = child->nextSibling()) | 601 for (Node* child = m_firstChild; child; child = child->nextSibling()) |
| 602 child->removedFromDocument(); | 602 child->removedFromDocument(); |
| 603 } | 603 } |
| 604 | 604 |
| 605 void ContainerNode::insertedIntoTree(bool deep) | 605 void ContainerNode::insertedIntoTree(bool deep) |
| 606 { | 606 { |
| 607 if (!deep) | 607 if (!deep) |
| 608 return; | 608 return; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 lowerRight.setY(max(upperLeft.y(), lowerRight.y())); | 768 lowerRight.setY(max(upperLeft.y(), lowerRight.y())); |
| 769 | 769 |
| 770 return enclosingIntRect(FloatRect(upperLeft, lowerRight - upperLeft)); | 770 return enclosingIntRect(FloatRect(upperLeft, lowerRight - upperLeft)); |
| 771 } | 771 } |
| 772 | 772 |
| 773 void ContainerNode::setFocus(bool received) | 773 void ContainerNode::setFocus(bool received) |
| 774 { | 774 { |
| 775 if (focused() == received) | 775 if (focused() == received) |
| 776 return; | 776 return; |
| 777 | 777 |
| 778 Node::setFocus(received); | 778 EventTargetNode::setFocus(received); |
| 779 | 779 |
| 780 // note that we need to recalc the style | 780 // note that we need to recalc the style |
| 781 setChanged(); | 781 setChanged(); |
| 782 } | 782 } |
| 783 | 783 |
| 784 void ContainerNode::setActive(bool down, bool pause) | 784 void ContainerNode::setActive(bool down, bool pause) |
| 785 { | 785 { |
| 786 if (down == active()) return; | 786 if (down == active()) return; |
| 787 | 787 |
| 788 Node::setActive(down); | 788 EventTargetNode::setActive(down); |
| 789 | 789 |
| 790 // note that we need to recalc the style | 790 // note that we need to recalc the style |
| 791 // FIXME: Move to Element | 791 // FIXME: Move to Element |
| 792 if (renderer()) { | 792 if (renderer()) { |
| 793 bool reactsToPress = renderer()->style()->affectedByActiveRules(); | 793 bool reactsToPress = renderer()->style()->affectedByActiveRules(); |
| 794 if (reactsToPress) | 794 if (reactsToPress) |
| 795 setChanged(); | 795 setChanged(); |
| 796 if (renderer() && renderer()->style()->hasAppearance()) { | 796 if (renderer() && renderer()->style()->hasAppearance()) { |
| 797 if (theme()->stateChanged(renderer(), PressedState)) | 797 if (theme()->stateChanged(renderer(), PressedState)) |
| 798 reactsToPress = true; | 798 reactsToPress = true; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 821 usleep(static_cast<useconds_t>(remainingTime * 1000000.0)); | 821 usleep(static_cast<useconds_t>(remainingTime * 1000000.0)); |
| 822 #endif | 822 #endif |
| 823 } | 823 } |
| 824 } | 824 } |
| 825 } | 825 } |
| 826 | 826 |
| 827 void ContainerNode::setHovered(bool over) | 827 void ContainerNode::setHovered(bool over) |
| 828 { | 828 { |
| 829 if (over == hovered()) return; | 829 if (over == hovered()) return; |
| 830 | 830 |
| 831 Node::setHovered(over); | 831 EventTargetNode::setHovered(over); |
| 832 | 832 |
| 833 // note that we need to recalc the style | 833 // note that we need to recalc the style |
| 834 // FIXME: Move to Element | 834 // FIXME: Move to Element |
| 835 if (renderer()) { | 835 if (renderer()) { |
| 836 if (renderer()->style()->affectedByHoverRules()) | 836 if (renderer()->style()->affectedByHoverRules()) |
| 837 setChanged(); | 837 setChanged(); |
| 838 if (renderer() && renderer()->style()->hasAppearance()) | 838 if (renderer() && renderer()->style()->hasAppearance()) |
| 839 theme()->stateChanged(renderer(), HoverState); | 839 theme()->stateChanged(renderer(), HoverState); |
| 840 } | 840 } |
| 841 } | 841 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 863 ASSERT(!eventDispatchForbidden()); | 863 ASSERT(!eventDispatchForbidden()); |
| 864 | 864 |
| 865 RefPtr<Node> c = child; | 865 RefPtr<Node> c = child; |
| 866 DocPtr<Document> doc = child->document(); | 866 DocPtr<Document> doc = child->document(); |
| 867 | 867 |
| 868 if (c->parentNode() && c->parentNode()->inDocument()) | 868 if (c->parentNode() && c->parentNode()->inDocument()) |
| 869 c->insertedIntoDocument(); | 869 c->insertedIntoDocument(); |
| 870 else | 870 else |
| 871 c->insertedIntoTree(true); | 871 c->insertedIntoTree(true); |
| 872 | 872 |
| 873 if (c->parentNode() && doc->hasListenerType(Document::DOMNODEINSERTED_LISTEN
ER)) { | 873 if (c->parentNode() && |
| 874 doc->hasListenerType(Document::DOMNODEINSERTED_LISTENER) && |
| 875 c->isEventTargetNode()) { |
| 874 ec = 0; | 876 ec = 0; |
| 875 c->dispatchEvent(MutationEvent::create(eventNames().DOMNodeInsertedEvent
, true, false, | 877 EventTargetNodeCast(c.get())->dispatchEvent(MutationEvent::create(eventN
ames().DOMNodeInsertedEvent, true, false, |
| 876 c->parentNode(), String(), String(), String(), 0), ec); | 878 c->parentNode(), String(), String(), String(), 0), ec); |
| 877 if (ec) | 879 if (ec) |
| 878 return; | 880 return; |
| 879 } | 881 } |
| 880 | 882 |
| 881 // dispatch the DOMNodeInsertedIntoDocument event to all descendants | 883 // dispatch the DOMNodeInsertedIntoDocument event to all descendants |
| 882 if (c->inDocument() && doc->hasListenerType(Document::DOMNODEINSERTEDINTODOC
UMENT_LISTENER)) | 884 if (c->inDocument() && doc->hasListenerType(Document::DOMNODEINSERTEDINTODOC
UMENT_LISTENER)) |
| 883 for (; c; c = c->traverseNextNode(child)) { | 885 for (; c; c = c->traverseNextNode(child)) { |
| 886 if (!c->isEventTargetNode()) |
| 887 continue; |
| 888 |
| 884 ec = 0; | 889 ec = 0; |
| 885 c->dispatchEvent(MutationEvent::create(eventNames().DOMNodeInsertedI
ntoDocumentEvent, false, false, | 890 EventTargetNodeCast(c.get())->dispatchEvent(MutationEvent::create(ev
entNames().DOMNodeInsertedIntoDocumentEvent, false, false, |
| 886 0, String(), String(), String(), 0), ec); | 891 0, String(), String(), String(), 0), ec); |
| 887 if (ec) | 892 if (ec) |
| 888 return; | 893 return; |
| 889 } | 894 } |
| 890 } | 895 } |
| 891 | 896 |
| 892 static void dispatchChildRemovalEvents(Node* child, ExceptionCode& ec) | 897 static void dispatchChildRemovalEvents(Node* child, ExceptionCode& ec) |
| 893 { | 898 { |
| 894 RefPtr<Node> c = child; | 899 RefPtr<Node> c = child; |
| 895 DocPtr<Document> doc = child->document(); | 900 DocPtr<Document> doc = child->document(); |
| 896 | 901 |
| 897 // update auxiliary doc info (e.g. iterators) to note that node is being rem
oved | 902 // update auxiliary doc info (e.g. iterators) to note that node is being rem
oved |
| 898 doc->nodeWillBeRemoved(child); | 903 doc->nodeWillBeRemoved(child); |
| 899 | 904 |
| 900 // dispatch pre-removal mutation events | 905 // dispatch pre-removal mutation events |
| 901 if (c->parentNode() && doc->hasListenerType(Document::DOMNODEREMOVED_LISTENE
R)) { | 906 if (c->parentNode() && |
| 907 doc->hasListenerType(Document::DOMNODEREMOVED_LISTENER) && |
| 908 c->isEventTargetNode()) { |
| 902 ec = 0; | 909 ec = 0; |
| 903 c->dispatchEvent(MutationEvent::create(eventNames().DOMNodeRemovedEvent,
true, false, | 910 EventTargetNodeCast(c.get())->dispatchEvent(MutationEvent::create(eventN
ames().DOMNodeRemovedEvent, true, false, |
| 904 c->parentNode(), String(), String(), String(), 0), ec); | 911 c->parentNode(), String(), String(), String(), 0), ec); |
| 905 if (ec) | 912 if (ec) |
| 906 return; | 913 return; |
| 907 } | 914 } |
| 908 | 915 |
| 909 // dispatch the DOMNodeRemovedFromDocument event to all descendants | 916 // dispatch the DOMNodeRemovedFromDocument event to all descendants |
| 910 if (c->inDocument() && doc->hasListenerType(Document::DOMNODEREMOVEDFROMDOCU
MENT_LISTENER)) | 917 if (c->inDocument() && doc->hasListenerType(Document::DOMNODEREMOVEDFROMDOCU
MENT_LISTENER)) |
| 911 for (; c; c = c->traverseNextNode(child)) { | 918 for (; c; c = c->traverseNextNode(child)) { |
| 919 if (!c->isEventTargetNode()) |
| 920 continue; |
| 912 ec = 0; | 921 ec = 0; |
| 913 c->dispatchEvent(MutationEvent::create(eventNames().DOMNodeRemovedFr
omDocumentEvent, false, false, | 922 EventTargetNodeCast(c.get())->dispatchEvent(MutationEvent::create(ev
entNames().DOMNodeRemovedFromDocumentEvent, false, false, |
| 914 0, String(), String(), String(), 0), ec); | 923 0, String(), String(), String(), 0), ec); |
| 915 if (ec) | 924 if (ec) |
| 916 return; | 925 return; |
| 917 } | 926 } |
| 918 } | 927 } |
| 919 | 928 |
| 920 } | 929 } |
| OLD | NEW |