diff options
Diffstat (limited to 'Source/WebCore/dom/Node.h')
-rw-r--r-- | Source/WebCore/dom/Node.h | 86 |
1 files changed, 44 insertions, 42 deletions
diff --git a/Source/WebCore/dom/Node.h b/Source/WebCore/dom/Node.h index 7ef7e80..1fe30ad 100644 --- a/Source/WebCore/dom/Node.h +++ b/Source/WebCore/dom/Node.h @@ -53,6 +53,7 @@ class EventContext; class EventListener; class FloatPoint; class Frame; +class InputElement; class IntRect; class KeyboardEvent; class NSResolver; @@ -70,7 +71,11 @@ class RenderBox; class RenderBoxModelObject; class RenderObject; class RenderStyle; +#if ENABLE(SVG) +class SVGUseElement; +#endif class TagNodeList; +class TreeScope; typedef int ExceptionCode; @@ -86,13 +91,10 @@ enum StyleChangeType { SyntheticStyleChange = 3 << nodeStyleChangeShift }; -enum EventDispatchBehavior { - RetargetEvent, - StayInsideShadowDOM -}; - class Node : public EventTarget, public TreeShared<ContainerNode>, public ScriptWrappable { friend class Document; + friend class TreeScope; + public: enum NodeType { ELEMENT_NODE = 1, @@ -192,6 +194,10 @@ public: bool isHTMLElement() const { return getFlag(IsHTMLFlag); } bool isSVGElement() const { return getFlag(IsSVGFlag); } + virtual bool isSVGShadowRoot() const { return false; } +#if ENABLE(SVG) + SVGUseElement* svgShadowHost() const; +#endif #if ENABLE(WML) virtual bool isWMLElement() const { return false; } @@ -200,6 +206,7 @@ public: #endif virtual bool isMediaControlElement() const { return false; } + virtual bool isMediaControls() const { return false; } bool isStyledElement() const { return getFlag(IsStyledElementFlag); } virtual bool isFrameOwnerElement() const { return false; } virtual bool isAttributeNode() const { return false; } @@ -207,12 +214,16 @@ public: virtual bool isCharacterDataNode() const { return false; } bool isDocumentNode() const; bool isShadowRoot() const { return getFlag(IsShadowRootFlag); } + // FIXME: Remove this when all shadow roots are ShadowRoots. + virtual bool isShadowBoundary() const { return false; } + virtual bool canHaveLightChildRendererWithShadow() const { return false; } + Node* shadowAncestorNode(); Node* shadowTreeRootNode(); bool isInShadowTree(); - // Node's parent or shadow tree host. + // Node's parent, shadow tree host, or SVG use. ContainerNode* parentOrHostNode() const; - // Use when it's guaranteed to that shadowHost is 0. + // Use when it's guaranteed to that shadowHost is 0 and svgShadowHost is 0. ContainerNode* parentNodeGuaranteedHostFree() const; Element* shadowHost() const; @@ -224,9 +235,6 @@ public: // Returns the enclosing event parent node (or self) that, when clicked, would trigger a navigation. Node* enclosingLinkEventParentOrSelf(); - // Node ancestors when concerned about event flow. - void getEventAncestors(Vector<EventContext>& ancestors, EventTarget*, EventDispatchBehavior = RetargetEvent); - bool isBlockFlow() const; bool isBlockFlowOrBlockTable() const; @@ -326,8 +334,10 @@ public: virtual bool isKeyboardFocusable(KeyboardEvent*) const; virtual bool isMouseFocusable() const; - virtual bool isContentEditable() const; - virtual bool isContentRichlyEditable() const; + bool isContentEditable() const; + + bool rendererIsEditable() const { return rendererIsEditable(Editable); } + bool rendererIsRichlyEditable() const { return rendererIsEditable(RichlyEditable); } virtual bool shouldUseInputMethod() const; virtual IntRect getRect() const; IntRect renderRect(bool* isReplaced); @@ -354,12 +364,14 @@ public: return m_document; } - // Do not use this method to change the document of a node until after the node has been - // removed from its previous document. - void setDocument(Document*); + TreeScope* treeScope() const; + + // Do not use this method to change the scope of a node until after the node has been + // removed from its previous scope. Do not use to change documents. + void setTreeScope(TreeScope*); // Used by the basic DOM methods (e.g., appendChild()). - void setDocumentRecursively(Document*); + void setTreeScopeRecursively(TreeScope*); // Returns true if this node is associated with a document and is in its associated document's // node tree, false otherwise. @@ -370,7 +382,7 @@ public: } bool isReadOnlyNode() const { return nodeType() == ENTITY_REFERENCE_NODE; } - virtual bool childTypeAllowed(NodeType) { return false; } + virtual bool childTypeAllowed(NodeType) const { return false; } unsigned childNodeCount() const; Node* childNode(unsigned index) const; @@ -449,6 +461,7 @@ public: virtual bool rendererIsNeeded(RenderStyle*); virtual bool childShouldCreateRenderer(Node*) const { return true; } virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); + ContainerNode* parentNodeForRenderingAndStyle() const; // Wrapper for nodes that don't have a renderer, but still cache the style (like HTMLOptionElement). RenderStyle* renderStyle() const; @@ -529,6 +542,8 @@ public: virtual Node* toNode() { return this; } + virtual InputElement* toInputElement(); + virtual ScriptExecutionContext* scriptExecutionContext() const; virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture); @@ -543,25 +558,19 @@ public: bool dispatchEvent(PassRefPtr<Event>); void dispatchScopedEvent(PassRefPtr<Event>); - bool dispatchGenericEvent(PassRefPtr<Event>); virtual void handleLocalEvents(Event*); void dispatchSubtreeModifiedEvent(); void dispatchUIEvent(const AtomicString& eventType, int detail, PassRefPtr<Event> underlyingEvent); bool dispatchKeyEvent(const PlatformKeyboardEvent&); - void dispatchWheelEvent(PlatformWheelEvent&); + bool dispatchWheelEvent(const PlatformWheelEvent&); bool dispatchMouseEvent(const PlatformMouseEvent&, const AtomicString& eventType, int clickCount = 0, Node* relatedTarget = 0); - bool dispatchMouseEvent(const AtomicString& eventType, int button, int clickCount, - int pageX, int pageY, int screenX, int screenY, - bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, - bool isSimulated, Node* relatedTarget, PassRefPtr<Event> underlyingEvent); - void dispatchSimulatedMouseEvent(const AtomicString& eventType, PassRefPtr<Event> underlyingEvent); void dispatchSimulatedClick(PassRefPtr<Event> underlyingEvent, bool sendMouseEvents = false, bool showPressedLook = true); virtual void dispatchFocusEvent(); virtual void dispatchBlurEvent(); - virtual void dispatchChangeEvents(); - virtual void dispatchInputEvents(); + virtual void dispatchChangeEvent(); + virtual void dispatchInputEvent(); // Perform the default action for an event. virtual void defaultEventHandler(Event*); @@ -576,17 +585,6 @@ public: virtual EventTargetData* eventTargetData(); virtual EventTargetData* ensureEventTargetData(); -#if USE(JSC) - void markCachedNodeLists(JSC::MarkStack& markStack, JSC::JSGlobalData& globalData) - { - // NodeLists may be present. If so, they need to be marked. - if (!hasRareData()) - return; - - markCachedNodeListsSlow(markStack, globalData); - } -#endif - private: enum NodeFlags { IsTextFlag = 1, @@ -651,6 +649,11 @@ protected: }; Node(Document*, ConstructionType); + // Do not use this method to change the document of a node until after the node has been + // removed from its previous document. + void setDocument(Document*); + void setDocumentRecursively(Document*); + virtual void willMoveToNewOwnerDocument(); virtual void didMoveToNewOwnerDocument(); @@ -664,9 +667,8 @@ protected: NodeRareData* ensureRareData(); private: -#if USE(JSC) - void markCachedNodeListsSlow(JSC::MarkStack&, JSC::JSGlobalData&); -#endif + enum EditableLevel { Editable, RichlyEditable }; + bool rendererIsEditable(EditableLevel) const; void setStyleChange(StyleChangeType); @@ -738,7 +740,7 @@ inline void addSubresourceURL(ListHashSet<KURL>& urls, const KURL& url) inline ContainerNode* Node::parentNode() const { - return getFlag(IsShadowRootFlag) ? 0 : parent(); + return getFlag(IsShadowRootFlag) || isSVGShadowRoot() ? 0 : parent(); } inline ContainerNode* Node::parentOrHostNode() const @@ -748,7 +750,7 @@ inline ContainerNode* Node::parentOrHostNode() const inline ContainerNode* Node::parentNodeGuaranteedHostFree() const { - ASSERT(!getFlag(IsShadowRootFlag)); + ASSERT(!getFlag(IsShadowRootFlag) && !isSVGShadowRoot()); return parentOrHostNode(); } |