📄 node.h
字号:
Node* previousEditable() const; Node* nextEditable() const; RenderObject* renderer() const { return m_renderer; } RenderObject* nextRenderer(); RenderObject* previousRenderer(); void setRenderer(RenderObject* renderer) { m_renderer = renderer; } // Use these two methods with caution. RenderBox* renderBox() const; RenderBoxModelObject* renderBoxModelObject() const; void checkSetPrefix(const AtomicString& prefix, ExceptionCode&); bool isDescendantOf(const Node*) const; bool contains(const Node*) const; // These two methods are mutually exclusive. The former is used to do strict error-checking // when adding children via the public DOM API (e.g., appendChild()). The latter is called only when parsing, // to sanity-check against the DTD for error recovery. void checkAddChild(Node* newChild, ExceptionCode&); // Error-checking when adding via the DOM API virtual bool childAllowed(Node* newChild); // Error-checking during parsing that checks the DTD void checkReplaceChild(Node* newChild, Node* oldChild, ExceptionCode&); virtual bool canReplaceChild(Node* newChild, Node* oldChild); // Used to determine whether range offsets use characters or node indices. virtual bool offsetInCharacters() const; // Number of DOM 16-bit units contained in node. Note that rendered text length can be different - e.g. because of // css-transform:capitalize breaking up precomposed characters and ligatures. virtual int maxCharacterOffset() const; // FIXME: We should try to find a better location for these methods. virtual bool canSelectAll() const { return false; } virtual void selectAll() { } // Whether or not a selection can be started in this object virtual bool canStartSelection() const; // Getting points into and out of screen space FloatPoint convertToPage(const FloatPoint& p) const; FloatPoint convertFromPage(const FloatPoint& p) const; // ----------------------------------------------------------------------------- // Integration with rendering tree /** * Attaches this node to the rendering tree. This calculates the style to be applied to the node and creates an * appropriate RenderObject which will be inserted into the tree (except when the style has display: none). This * makes the node visible in the FrameView. */ virtual void attach(); /** * Detaches the node from the rendering tree, making it invisible in the rendered view. This method will remove * the node's rendering object from the rendering tree and delete it. */ virtual void detach(); virtual void willRemove(); void createRendererIfNeeded(); PassRefPtr<RenderStyle> styleForRenderer(); virtual bool rendererIsNeeded(RenderStyle*);#if ENABLE(SVG) virtual bool childShouldCreateRenderer(Node*) const { return true; }#endif virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); // Wrapper for nodes that don't have a renderer, but still cache the style (like HTMLOptionElement). RenderStyle* renderStyle() const; virtual void setRenderStyle(PassRefPtr<RenderStyle>); virtual RenderStyle* computedStyle(); // ----------------------------------------------------------------------------- // Notification of document structure changes /** * Notifies the node that it has been inserted into the document. This is called during document parsing, and also * when a node is added through the DOM methods insertBefore(), appendChild() or replaceChild(). Note that this only * happens when the node becomes part of the document tree, i.e. only when the document is actually an ancestor of * the node. The call happens _after_ the node has been added to the tree. * * This is similar to the DOMNodeInsertedIntoDocument DOM event, but does not require the overhead of event * dispatching. */ virtual void insertedIntoDocument(); /** * Notifies the node that it is no longer part of the document tree, i.e. when the document is no longer an ancestor * node. * * This is similar to the DOMNodeRemovedFromDocument DOM event, but does not require the overhead of event * dispatching, and is called _after_ the node is removed from the tree. */ virtual void removedFromDocument(); // These functions are called whenever you are connected or disconnected from a tree. That tree may be the main // document tree, or it could be another disconnected tree. Override these functions to do any work that depends // on connectedness to some ancestor (e.g., an ancestor <form> for example). virtual void insertedIntoTree(bool /*deep*/) { } virtual void removedFromTree(bool /*deep*/) { } /** * Notifies the node that it's list of children have changed (either by adding or removing child nodes), or a child * node that is of the type CDATA_SECTION_NODE, TEXT_NODE or COMMENT_NODE has changed its value. */ virtual void childrenChanged(bool /*changedByParser*/ = false, Node* /*beforeChange*/ = 0, Node* /*afterChange*/ = 0, int /*childCountDelta*/ = 0) { }#ifndef NDEBUG virtual void formatForDebugger(char* buffer, unsigned length) const; void showNode(const char* prefix = "") const; void showTreeForThis() const; void showTreeAndMark(const Node* markedNode1, const char* markedLabel1, const Node* markedNode2 = 0, const char* markedLabel2 = 0) const;#endif void registerDynamicNodeList(DynamicNodeList*); void unregisterDynamicNodeList(DynamicNodeList*); void notifyNodeListsChildrenChanged(); void notifyLocalNodeListsChildrenChanged(); void notifyNodeListsAttributeChanged(); void notifyLocalNodeListsAttributeChanged(); PassRefPtr<NodeList> getElementsByTagName(const String&); PassRefPtr<NodeList> getElementsByTagNameNS(const AtomicString& namespaceURI, const String& localName); PassRefPtr<NodeList> getElementsByName(const String& elementName); PassRefPtr<NodeList> getElementsByClassName(const String& classNames); PassRefPtr<Element> querySelector(const String& selectors, ExceptionCode&); PassRefPtr<NodeList> querySelectorAll(const String& selectors, ExceptionCode&); unsigned short compareDocumentPosition(Node*);protected: virtual void willMoveToNewOwnerDocument(); virtual void didMoveToNewOwnerDocument(); virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const { } void setTabIndexExplicitly(short); bool hasRareData() const { return m_hasRareData; } NodeRareData* rareData() const; NodeRareData* ensureRareData();public: virtual Node* toNode() { return this; } virtual ScriptExecutionContext* scriptExecutionContext() const; virtual void addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture); virtual void removeEventListener(const AtomicString& eventType, EventListener*, bool useCapture); virtual bool dispatchEvent(PassRefPtr<Event>, ExceptionCode&); void removeAllEventListeners() { if (hasRareData()) removeAllEventListenersSlowCase(); } void setInlineEventListenerForType(const AtomicString& eventType, PassRefPtr<EventListener>); void setInlineEventListenerForTypeAndAttribute(const AtomicString& eventType, Attribute*); void removeInlineEventListenerForType(const AtomicString& eventType); bool dispatchEventForType(const AtomicString& eventType, bool canBubble, bool cancelable); EventListener* inlineEventListenerForType(const AtomicString& eventType) const; bool dispatchSubtreeModifiedEvent(); void dispatchWindowEvent(PassRefPtr<Event>); void dispatchWindowEvent(const AtomicString& eventType, bool canBubble, bool cancelable); bool dispatchUIEvent(const AtomicString& eventType, int detail = 0, PassRefPtr<Event> underlyingEvent = 0); bool dispatchKeyEvent(const PlatformKeyboardEvent&); void dispatchWheelEvent(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 = false, Node* relatedTarget = 0, PassRefPtr<Event> underlyingEvent = 0); void dispatchSimulatedMouseEvent(const AtomicString& eventType, PassRefPtr<Event> underlyingEvent = 0); void dispatchSimulatedClick(PassRefPtr<Event> underlyingEvent, bool sendMouseEvents = false, bool showPressedLook = true); bool dispatchProgressEvent(const AtomicString &eventType, bool lengthComputableArg, unsigned loadedArg, unsigned totalArg); void dispatchStorageEvent(const AtomicString &eventType, const String& key, const String& oldValue, const String& newValue, Frame* source); bool dispatchWebKitAnimationEvent(const AtomicString& eventType, const String& animationName, double elapsedTime); bool dispatchWebKitTransitionEvent(const AtomicString& eventType, const String& propertyName, double elapsedTime); bool dispatchGenericEvent(PassRefPtr<Event>); virtual void handleLocalEvents(Event*, bool useCapture); virtual void dispatchFocusEvent(); virtual void dispatchBlurEvent(); /** * Perform the default action for an event e.g. submitting a form */ virtual void defaultEventHandler(Event*); /** * Used for disabled form elements; if true, prevents mouse events from being dispatched * to event listeners, and prevents DOMActivate events from being sent at all. */ virtual bool disabled() const; const RegisteredEventListenerVector& eventListeners() const; EventListener* onabort() const; void setOnabort(PassRefPtr<EventListener>); EventListener* onblur() const; void setOnblur(PassRefPtr<EventListener>); EventListener* onchange() const; void setOnchange(PassRefPtr<EventListener>); EventListener* onclick() const; void setOnclick(PassRefPtr<EventListener>); EventListener* oncontextmenu() const; void setOncontextmenu(PassRefPtr<EventListener>); EventListener* ondblclick() const; void setOndblclick(PassRefPtr<EventListener>); EventListener* onerror() const; void setOnerror(PassRefPtr<EventListener>); EventListener* onfocus() const; void setOnfocus(PassRefPtr<EventListener>); EventListener* oninput() const; void setOninput(PassRefPtr<EventListener>); EventListener* onkeydown() const; void setOnkeydown(PassRefPtr<EventListener>); EventListener* onkeypress() const; void setOnkeypress(PassRefPtr<EventListener>); EventListener* onkeyup() const; void setOnkeyup(PassRefPtr<EventListener>); EventListener* onload() const; void setOnload(PassRefPtr<EventListener>); EventListener* onmousedown() const; void setOnmousedown(PassRefPtr<EventListener>); EventListener* onmousemove() const; void setOnmousemove(PassRefPtr<EventListener>); EventListener* onmouseout() const; void setOnmouseout(PassRefPtr<EventListener>); EventListener* onmouseover() const; void setOnmouseover(PassRefPtr<EventListener>); EventListener* onmouseup() const; void setOnmouseup(PassRefPtr<EventListener>); EventListener* onmousewheel() const; void setOnmousewheel(PassRefPtr<EventListener>); EventListener* onbeforecut() const; void setOnbeforecut(PassRefPtr<EventListener>); EventListener* oncut() const; void setOncut(PassRefPtr<EventListener>); EventListener* onbeforecopy() const; void setOnbeforecopy(PassRefPtr<EventListener>); EventListener* oncopy() const; void setOncopy(PassRefPtr<EventListener>); EventListener* onbeforepaste() const; void setOnbeforepaste(PassRefPtr<EventListener>); EventListener* onpaste() const; void setOnpaste(PassRefPtr<EventListener>); EventListener* ondragenter() const; void setOndragenter(PassRefPtr<EventListener>); EventListener* ondragover() const; void setOndragover(PassRefPtr<EventListener>); EventListener* ondragleave() const; void setOndragleave(PassRefPtr<EventListener>); EventListener* ondrop() const; void setOndrop(PassRefPtr<EventListener>); EventListener* ondragstart() const; void setOndragstart(PassRefPtr<EventListener>); EventListener* ondrag() const; void setOndrag(PassRefPtr<EventListener>); EventListener* ondragend() const; void setOndragend(PassRefPtr<EventListener>); EventListener* onreset() const; void setOnreset(PassRefPtr<EventListener>); EventListener* onresize() const; void setOnresize(PassRefPtr<EventListener>); EventListener* onscroll() const; void setOnscroll(PassRefPtr<EventListener>); EventListener* onsearch() const; void setOnsearch(PassRefPtr<EventListener>); EventListener* onselect() const; void setOnselect(PassRefPtr<EventListener>); EventListener* onselectstart() const; void setOnselectstart(PassRefPtr<EventListener>); EventListener* onsubmit() const; void setOnsubmit(PassRefPtr<EventListener>); EventListener* onunload() const; void setOnunload(PassRefPtr<EventListener>); using TreeShared<Node>::ref; using TreeShared<Node>::deref; private: virtual void refEventTarget() { ref(); } virtual void derefEventTarget() { deref(); } void removeAllEventListenersSlowCase();private: virtual NodeRareData* createRareData(); Node* containerChildNode(unsigned index) const; unsigned containerChildNodeCount() const; Node* containerFirstChild() const; Node* containerLastChild() const; bool rareDataFocused() const; virtual RenderStyle* nonRendererRenderStyle() const; virtual const AtomicString& virtualPrefix() const; virtual const AtomicString& virtualLocalName() const; virtual const AtomicString& virtualNamespaceURI() const; Element* ancestorElement() const; void appendTextContent(bool convertBRsToNewlines, StringBuilder&) const; DocPtr<Document> m_document; Node* m_previous; Node* m_next; RenderObject* m_renderer; unsigned m_styleChange : 2; bool m_hasId : 1; bool m_hasClass : 1; bool m_attached : 1; bool m_hasChangedChild : 1; bool m_inDocument : 1; bool m_isLink : 1; bool m_active : 1; bool m_hovered : 1; bool m_inActiveChain : 1; bool m_inDetach : 1; bool m_inSubtreeMark : 1; bool m_hasRareData : 1; const bool m_isElement : 1; const bool m_isContainer : 1; const bool m_isText : 1;protected: // These bits are used by the Element derived class, pulled up here so they can // be stored in the same memory word as the Node bits above. bool m_parsingChildrenFinished : 1;#if ENABLE(SVG) mutable bool m_areSVGAttributesValid : 1;#endif // These bits are used by the StyledElement derived class, and live here for the // same reason as above. mutable bool m_isStyleAttributeValid : 1; mutable bool m_synchronizingStyleAttribute : 1;#if ENABLE(SVG) // This bit is used by the SVGElement derived class, and lives here for the same // reason as above. mutable bool m_synchronizingSVGAttributes : 1;#endif // 11 bits remaining};// Used in Node::addSubresourceAttributeURLs() and in addSubresourceStyleURLs()inline void addSubresourceURL(ListHashSet<KURL>& urls, const KURL& url){ if (!url.isNull()) urls.add(url);}} //namespace#ifndef NDEBUG// Outside the WebCore namespace for ease of invocation from gdb.void showTree(const WebCore::Node*);#endif#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -