| 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 Apple Inc. All rights reserved. |
| 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. |
| 11 * | 11 * |
| 12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
| 16 * | 16 * |
| 17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
| 18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
| 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
| 21 * | 21 * |
| 22 */ | 22 */ |
| 23 | 23 |
| 24 #ifndef Node_h | 24 #ifndef Node_h |
| 25 #define Node_h | 25 #define Node_h |
| 26 | 26 |
| 27 #include "DocPtr.h" | 27 #include "DocPtr.h" |
| 28 #include "EventTarget.h" | |
| 29 #include "KURLHash.h" | 28 #include "KURLHash.h" |
| 30 #include "PlatformString.h" | 29 #include "PlatformString.h" |
| 31 #include "TreeShared.h" | 30 #include "TreeShared.h" |
| 32 #include <wtf/Assertions.h> | 31 #include <wtf/Assertions.h> |
| 33 #include <wtf/ListHashSet.h> | 32 #include <wtf/ListHashSet.h> |
| 34 #include <wtf/OwnPtr.h> | 33 #include <wtf/OwnPtr.h> |
| 35 #include <wtf/PassRefPtr.h> | 34 #include <wtf/PassRefPtr.h> |
| 36 | 35 |
| 37 namespace WebCore { | 36 namespace WebCore { |
| 38 | 37 |
| 39 class AtomicString; | 38 class AtomicString; |
| 40 class Attribute; | |
| 41 class ContainerNode; | 39 class ContainerNode; |
| 42 class Document; | 40 class Document; |
| 43 class DynamicNodeList; | 41 class DynamicNodeList; |
| 44 class Element; | 42 class Element; |
| 45 class Event; | 43 class Event; |
| 46 class EventListener; | 44 class EventListener; |
| 47 class Frame; | |
| 48 class IntRect; | 45 class IntRect; |
| 49 class KeyboardEvent; | 46 class KeyboardEvent; |
| 50 class NSResolver; | 47 class NSResolver; |
| 51 class NamedAttrMap; | 48 class NamedAttrMap; |
| 52 class NodeList; | 49 class NodeList; |
| 53 class NodeRareData; | 50 class NodeRareData; |
| 54 class PlatformKeyboardEvent; | 51 class PlatformKeyboardEvent; |
| 55 class PlatformMouseEvent; | 52 class PlatformMouseEvent; |
| 56 class PlatformWheelEvent; | 53 class PlatformWheelEvent; |
| 57 class QualifiedName; | 54 class QualifiedName; |
| 58 class RegisteredEventListener; | |
| 59 class RenderArena; | 55 class RenderArena; |
| 60 class RenderBox; | 56 class RenderBox; |
| 61 class RenderObject; | 57 class RenderObject; |
| 62 class RenderStyle; | 58 class RenderStyle; |
| 63 class StringBuilder; | 59 class StringBuilder; |
| 64 | 60 |
| 65 typedef int ExceptionCode; | 61 typedef int ExceptionCode; |
| 66 | 62 |
| 67 typedef Vector<RefPtr<RegisteredEventListener> > RegisteredEventListenerVector; | |
| 68 | |
| 69 enum StyleChangeType { NoStyleChange, InlineStyleChange, FullStyleChange, Animat
ionStyleChange }; | 63 enum StyleChangeType { NoStyleChange, InlineStyleChange, FullStyleChange, Animat
ionStyleChange }; |
| 70 | 64 |
| 71 const unsigned short DOCUMENT_POSITION_EQUIVALENT = 0x00; | 65 const unsigned short DOCUMENT_POSITION_EQUIVALENT = 0x00; |
| 72 const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01; | 66 const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01; |
| 73 const unsigned short DOCUMENT_POSITION_PRECEDING = 0x02; | 67 const unsigned short DOCUMENT_POSITION_PRECEDING = 0x02; |
| 74 const unsigned short DOCUMENT_POSITION_FOLLOWING = 0x04; | 68 const unsigned short DOCUMENT_POSITION_FOLLOWING = 0x04; |
| 75 const unsigned short DOCUMENT_POSITION_CONTAINS = 0x08; | 69 const unsigned short DOCUMENT_POSITION_CONTAINS = 0x08; |
| 76 const unsigned short DOCUMENT_POSITION_CONTAINED_BY = 0x10; | 70 const unsigned short DOCUMENT_POSITION_CONTAINED_BY = 0x10; |
| 77 const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; | 71 const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; |
| 78 | 72 |
| 79 // this class implements nodes, which can have a parent but no children: | 73 // this class implements nodes, which can have a parent but no children: |
| 80 class Node : public EventTarget, public TreeShared<Node> { | 74 class Node : public TreeShared<Node> { |
| 81 friend class Document; | 75 friend class Document; |
| 82 public: | 76 public: |
| 83 enum NodeType { | 77 enum NodeType { |
| 84 ELEMENT_NODE = 1, | 78 ELEMENT_NODE = 1, |
| 85 ATTRIBUTE_NODE = 2, | 79 ATTRIBUTE_NODE = 2, |
| 86 TEXT_NODE = 3, | 80 TEXT_NODE = 3, |
| 87 CDATA_SECTION_NODE = 4, | 81 CDATA_SECTION_NODE = 4, |
| 88 ENTITY_REFERENCE_NODE = 5, | 82 ENTITY_REFERENCE_NODE = 5, |
| 89 ENTITY_NODE = 6, | 83 ENTITY_NODE = 6, |
| 90 PROCESSING_INSTRUCTION_NODE = 7, | 84 PROCESSING_INSTRUCTION_NODE = 7, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 #else | 173 #else |
| 180 static bool isWMLElement() { return false; } | 174 static bool isWMLElement() { return false; } |
| 181 #endif | 175 #endif |
| 182 | 176 |
| 183 virtual bool isStyledElement() const { return false; } | 177 virtual bool isStyledElement() const { return false; } |
| 184 virtual bool isFrameOwnerElement() const { return false; } | 178 virtual bool isFrameOwnerElement() const { return false; } |
| 185 virtual bool isAttributeNode() const { return false; } | 179 virtual bool isAttributeNode() const { return false; } |
| 186 virtual bool isCommentNode() const { return false; } | 180 virtual bool isCommentNode() const { return false; } |
| 187 virtual bool isCharacterDataNode() const { return false; } | 181 virtual bool isCharacterDataNode() const { return false; } |
| 188 bool isDocumentNode() const; | 182 bool isDocumentNode() const; |
| 183 virtual bool isEventTargetNode() const { return false; } |
| 189 virtual bool isShadowNode() const { return false; } | 184 virtual bool isShadowNode() const { return false; } |
| 190 virtual Node* shadowParentNode() { return 0; } | 185 virtual Node* shadowParentNode() { return 0; } |
| 191 Node* shadowAncestorNode(); | 186 Node* shadowAncestorNode(); |
| 192 Node* shadowTreeRootNode(); | 187 Node* shadowTreeRootNode(); |
| 193 bool isInShadowTree(); | 188 bool isInShadowTree(); |
| 194 | 189 |
| 195 // The node's parent for the purpose of event capture and bubbling. | 190 // The node's parent for the purpose of event capture and bubbling. |
| 196 virtual ContainerNode* eventParentNode(); | 191 virtual ContainerNode* eventParentNode(); |
| 197 | 192 |
| 198 bool isBlockFlow() const; | 193 bool isBlockFlow() const; |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 PassRefPtr<NodeList> getElementsByTagNameNS(const AtomicString& namespaceURI
, const String& localName); | 482 PassRefPtr<NodeList> getElementsByTagNameNS(const AtomicString& namespaceURI
, const String& localName); |
| 488 PassRefPtr<NodeList> getElementsByName(const String& elementName); | 483 PassRefPtr<NodeList> getElementsByName(const String& elementName); |
| 489 PassRefPtr<NodeList> getElementsByClassName(const String& classNames); | 484 PassRefPtr<NodeList> getElementsByClassName(const String& classNames); |
| 490 | 485 |
| 491 PassRefPtr<Element> querySelector(const String& selectors, ExceptionCode&); | 486 PassRefPtr<Element> querySelector(const String& selectors, ExceptionCode&); |
| 492 PassRefPtr<NodeList> querySelectorAll(const String& selectors, ExceptionCode
&); | 487 PassRefPtr<NodeList> querySelectorAll(const String& selectors, ExceptionCode
&); |
| 493 | 488 |
| 494 unsigned short compareDocumentPosition(Node*); | 489 unsigned short compareDocumentPosition(Node*); |
| 495 | 490 |
| 496 protected: | 491 protected: |
| 497 virtual void willMoveToNewOwnerDocument(); | 492 virtual void willMoveToNewOwnerDocument() { } |
| 498 virtual void didMoveToNewOwnerDocument(); | 493 virtual void didMoveToNewOwnerDocument() { } |
| 499 | 494 |
| 500 virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const { } | 495 virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const { } |
| 501 void setTabIndexExplicitly(short); | 496 void setTabIndexExplicitly(short); |
| 502 | 497 |
| 503 bool hasRareData() const { return m_hasRareData; } | 498 bool hasRareData() const { return m_hasRareData; } |
| 504 | 499 |
| 505 NodeRareData* rareData() const; | 500 NodeRareData* rareData() const; |
| 506 NodeRareData* ensureRareData(); | 501 NodeRareData* ensureRareData(); |
| 507 | 502 |
| 508 public: | |
| 509 virtual Node* toNode() { return this; } | |
| 510 | |
| 511 virtual ScriptExecutionContext* scriptExecutionContext() const; | |
| 512 | |
| 513 virtual void addEventListener(const AtomicString& eventType, PassRefPtr<Even
tListener>, bool useCapture); | |
| 514 virtual void removeEventListener(const AtomicString& eventType, EventListene
r*, bool useCapture); | |
| 515 virtual bool dispatchEvent(PassRefPtr<Event>, ExceptionCode&); | |
| 516 void removeAllEventListeners() { if (hasRareData()) removeAllEventListenersS
lowCase(); } | |
| 517 | |
| 518 void setInlineEventListenerForType(const AtomicString& eventType, PassRefPtr
<EventListener>); | |
| 519 void setInlineEventListenerForTypeAndAttribute(const AtomicString& eventType
, Attribute*); | |
| 520 void removeInlineEventListenerForType(const AtomicString& eventType); | |
| 521 bool dispatchEventForType(const AtomicString& eventType, bool canBubble, boo
l cancelable); | |
| 522 EventListener* inlineEventListenerForType(const AtomicString& eventType) con
st; | |
| 523 | |
| 524 bool dispatchSubtreeModifiedEvent(); | |
| 525 void dispatchWindowEvent(PassRefPtr<Event>); | |
| 526 void dispatchWindowEvent(const AtomicString& eventType, bool canBubble, bool
cancelable); | |
| 527 bool dispatchUIEvent(const AtomicString& eventType, int detail = 0, PassRefP
tr<Event> underlyingEvent = 0); | |
| 528 bool dispatchKeyEvent(const PlatformKeyboardEvent&); | |
| 529 void dispatchWheelEvent(PlatformWheelEvent&); | |
| 530 bool dispatchMouseEvent(const PlatformMouseEvent&, const AtomicString& event
Type, | |
| 531 int clickCount = 0, Node* relatedTarget = 0); | |
| 532 bool dispatchMouseEvent(const AtomicString& eventType, int button, int click
Count, | |
| 533 int pageX, int pageY, int screenX, int screenY, | |
| 534 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, | |
| 535 bool isSimulated = false, Node* relatedTarget = 0, PassRefPtr<Event> und
erlyingEvent = 0); | |
| 536 void dispatchSimulatedMouseEvent(const AtomicString& eventType, PassRefPtr<E
vent> underlyingEvent = 0); | |
| 537 void dispatchSimulatedClick(PassRefPtr<Event> underlyingEvent, bool sendMous
eEvents = false, bool showPressedLook = true); | |
| 538 bool dispatchProgressEvent(const AtomicString &eventType, bool lengthComputa
bleArg, unsigned loadedArg, unsigned totalArg); | |
| 539 void dispatchStorageEvent(const AtomicString &eventType, const String& key,
const String& oldValue, const String& newValue, Frame* source); | |
| 540 bool dispatchWebKitAnimationEvent(const AtomicString& eventType, const Strin
g& animationName, double elapsedTime); | |
| 541 bool dispatchWebKitTransitionEvent(const AtomicString& eventType, const Stri
ng& propertyName, double elapsedTime); | |
| 542 bool dispatchGenericEvent(PassRefPtr<Event>); | |
| 543 | |
| 544 virtual void handleLocalEvents(Event*, bool useCapture); | |
| 545 | |
| 546 virtual void dispatchFocusEvent(); | |
| 547 virtual void dispatchBlurEvent(); | |
| 548 | |
| 549 /** | |
| 550 * Perform the default action for an event e.g. submitting a form | |
| 551 */ | |
| 552 virtual void defaultEventHandler(Event*); | |
| 553 | |
| 554 /** | |
| 555 * Used for disabled form elements; if true, prevents mouse events from bein
g dispatched | |
| 556 * to event listeners, and prevents DOMActivate events from being sent at al
l. | |
| 557 */ | |
| 558 virtual bool disabled() const; | |
| 559 | |
| 560 const RegisteredEventListenerVector& eventListeners() const; | |
| 561 | |
| 562 EventListener* onabort() const; | |
| 563 void setOnabort(PassRefPtr<EventListener>); | |
| 564 EventListener* onblur() const; | |
| 565 void setOnblur(PassRefPtr<EventListener>); | |
| 566 EventListener* onchange() const; | |
| 567 void setOnchange(PassRefPtr<EventListener>); | |
| 568 EventListener* onclick() const; | |
| 569 void setOnclick(PassRefPtr<EventListener>); | |
| 570 EventListener* oncontextmenu() const; | |
| 571 void setOncontextmenu(PassRefPtr<EventListener>); | |
| 572 EventListener* ondblclick() const; | |
| 573 void setOndblclick(PassRefPtr<EventListener>); | |
| 574 EventListener* onerror() const; | |
| 575 void setOnerror(PassRefPtr<EventListener>); | |
| 576 EventListener* onfocus() const; | |
| 577 void setOnfocus(PassRefPtr<EventListener>); | |
| 578 EventListener* oninput() const; | |
| 579 void setOninput(PassRefPtr<EventListener>); | |
| 580 EventListener* onkeydown() const; | |
| 581 void setOnkeydown(PassRefPtr<EventListener>); | |
| 582 EventListener* onkeypress() const; | |
| 583 void setOnkeypress(PassRefPtr<EventListener>); | |
| 584 EventListener* onkeyup() const; | |
| 585 void setOnkeyup(PassRefPtr<EventListener>); | |
| 586 EventListener* onload() const; | |
| 587 void setOnload(PassRefPtr<EventListener>); | |
| 588 EventListener* onmousedown() const; | |
| 589 void setOnmousedown(PassRefPtr<EventListener>); | |
| 590 EventListener* onmousemove() const; | |
| 591 void setOnmousemove(PassRefPtr<EventListener>); | |
| 592 EventListener* onmouseout() const; | |
| 593 void setOnmouseout(PassRefPtr<EventListener>); | |
| 594 EventListener* onmouseover() const; | |
| 595 void setOnmouseover(PassRefPtr<EventListener>); | |
| 596 EventListener* onmouseup() const; | |
| 597 void setOnmouseup(PassRefPtr<EventListener>); | |
| 598 EventListener* onmousewheel() const; | |
| 599 void setOnmousewheel(PassRefPtr<EventListener>); | |
| 600 EventListener* onbeforecut() const; | |
| 601 void setOnbeforecut(PassRefPtr<EventListener>); | |
| 602 EventListener* oncut() const; | |
| 603 void setOncut(PassRefPtr<EventListener>); | |
| 604 EventListener* onbeforecopy() const; | |
| 605 void setOnbeforecopy(PassRefPtr<EventListener>); | |
| 606 EventListener* oncopy() const; | |
| 607 void setOncopy(PassRefPtr<EventListener>); | |
| 608 EventListener* onbeforepaste() const; | |
| 609 void setOnbeforepaste(PassRefPtr<EventListener>); | |
| 610 EventListener* onpaste() const; | |
| 611 void setOnpaste(PassRefPtr<EventListener>); | |
| 612 EventListener* ondragenter() const; | |
| 613 void setOndragenter(PassRefPtr<EventListener>); | |
| 614 EventListener* ondragover() const; | |
| 615 void setOndragover(PassRefPtr<EventListener>); | |
| 616 EventListener* ondragleave() const; | |
| 617 void setOndragleave(PassRefPtr<EventListener>); | |
| 618 EventListener* ondrop() const; | |
| 619 void setOndrop(PassRefPtr<EventListener>); | |
| 620 EventListener* ondragstart() const; | |
| 621 void setOndragstart(PassRefPtr<EventListener>); | |
| 622 EventListener* ondrag() const; | |
| 623 void setOndrag(PassRefPtr<EventListener>); | |
| 624 EventListener* ondragend() const; | |
| 625 void setOndragend(PassRefPtr<EventListener>); | |
| 626 EventListener* onreset() const; | |
| 627 void setOnreset(PassRefPtr<EventListener>); | |
| 628 EventListener* onresize() const; | |
| 629 void setOnresize(PassRefPtr<EventListener>); | |
| 630 EventListener* onscroll() const; | |
| 631 void setOnscroll(PassRefPtr<EventListener>); | |
| 632 EventListener* onsearch() const; | |
| 633 void setOnsearch(PassRefPtr<EventListener>); | |
| 634 EventListener* onselect() const; | |
| 635 void setOnselect(PassRefPtr<EventListener>); | |
| 636 EventListener* onselectstart() const; | |
| 637 void setOnselectstart(PassRefPtr<EventListener>); | |
| 638 EventListener* onsubmit() const; | |
| 639 void setOnsubmit(PassRefPtr<EventListener>); | |
| 640 EventListener* onunload() const; | |
| 641 void setOnunload(PassRefPtr<EventListener>); | |
| 642 | |
| 643 using TreeShared<Node>::ref; | |
| 644 using TreeShared<Node>::deref; | |
| 645 | |
| 646 private: | |
| 647 virtual void refEventTarget() { ref(); } | |
| 648 virtual void derefEventTarget() { deref(); } | |
| 649 | |
| 650 void removeAllEventListenersSlowCase(); | |
| 651 | |
| 652 private: | 503 private: |
| 653 virtual NodeRareData* createRareData(); | 504 virtual NodeRareData* createRareData(); |
| 654 Node* containerChildNode(unsigned index) const; | 505 Node* containerChildNode(unsigned index) const; |
| 655 unsigned containerChildNodeCount() const; | 506 unsigned containerChildNodeCount() const; |
| 656 Node* containerFirstChild() const; | 507 Node* containerFirstChild() const; |
| 657 Node* containerLastChild() const; | 508 Node* containerLastChild() const; |
| 658 bool rareDataFocused() const; | 509 bool rareDataFocused() const; |
| 659 | 510 |
| 660 virtual RenderStyle* nonRendererRenderStyle() const; | 511 virtual RenderStyle* nonRendererRenderStyle() const; |
| 661 | 512 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 | 571 |
| 721 } //namespace | 572 } //namespace |
| 722 | 573 |
| 723 #ifndef NDEBUG | 574 #ifndef NDEBUG |
| 724 // Outside the WebCore namespace for ease of invocation from gdb. | 575 // Outside the WebCore namespace for ease of invocation from gdb. |
| 725 void showTree(const WebCore::Node*); | 576 void showTree(const WebCore::Node*); |
| 726 #endif | 577 #endif |
| 727 | 578 |
| 728 #endif | 579 #endif |
| 729 | 580 |
| OLD | NEW |