📄 dom_nodeimpl.h
字号:
bool dispatchSubtreeModifiedEvent(); void handleLocalEvents(EventImpl *evt, bool useCapture); /** * Perform the default action for an event e.g. submitting a form */ virtual void defaultEventHandler(EventImpl *evt); virtual bool isReadOnly() { return false; } virtual bool childTypeAllowed( unsigned short /*type*/ ) { return false; } virtual unsigned long childNodeCount(); virtual NodeImpl *childNode(unsigned long index); NodeImpl *traverseNextNode(NodeImpl *stayWithin = 0); DocumentPtr *docPtr() const { return document; } virtual khtml::RenderObject *nextRenderer();private: DocumentPtr *document; friend class DocumentImpl;protected: khtml::RenderObject *m_render; bool m_complexText : 1; bool m_hasEvents : 1; bool m_hasId : 1; bool m_hasClass : 1; bool m_hasStyle : 1; bool m_pressed : 1; bool m_mouseInside : 1; bool m_attached : 1; bool m_changed : 1; bool m_specified : 1; // used in AttrImpl. Accessor functions there bool m_focused : 1; bool m_active : 1; // used in elementimpl. Defined here to save a few bytes in the data structures. bool has_tabindex : 1; short tabindex : 16; QList<RegisteredEventListener> *m_regdListeners;};// this class implements nodes, which can have a parent but no children:class NodeWParentImpl : public NodeImpl{public: NodeWParentImpl(DocumentPtr *doc); virtual ~NodeWParentImpl(); virtual NodeImpl *parentNode() const; virtual NodeImpl *previousSibling() const; virtual NodeImpl *nextSibling() const; // helper functions not being part of the DOM virtual void setParent(NodeImpl *parent); virtual bool deleteMe(); virtual void setPreviousSibling(NodeImpl *); virtual void setNextSibling(NodeImpl *); virtual unsigned long nodeIndex() const; virtual bool isReadOnly(); virtual khtml::RenderObject *nextRenderer(); virtual bool prepareMouseEvent( int x, int y, int _tx, int _ty, MouseEvent *ev);protected: NodeImpl *_parent; NodeImpl *_previous; NodeImpl *_next; // helper function; throws exception if modifying a readonly node bool checkReadOnly() const;};// this is the full Node Implementation with parents and children.class NodeBaseImpl : public NodeWParentImpl{public: NodeBaseImpl(DocumentPtr *doc); virtual ~NodeBaseImpl(); virtual NodeImpl *firstChild() const; virtual NodeImpl *lastChild() const; virtual NodeImpl *insertBefore ( NodeImpl *newChild, NodeImpl *refChild, int &exceptioncode ); virtual NodeImpl *replaceChild ( NodeImpl *newChild, NodeImpl *oldChild, int &exceptioncode ); virtual NodeImpl *removeChild ( NodeImpl *oldChild, int &exceptioncode ); virtual NodeImpl *appendChild ( NodeImpl *newChild, int &exceptioncode ); virtual bool hasChildNodes ( ) const; // not part of the DOM void removeChildren(); virtual void setFirstChild(NodeImpl *child); virtual void setLastChild(NodeImpl *child); virtual NodeImpl *addChild(NodeImpl *newChild); virtual void attach(); virtual void detach(); virtual void cloneChildNodes(NodeImpl *clone, int &exceptioncode); virtual void setStyle(khtml::RenderStyle *style); virtual khtml::RenderStyle *style() const { return m_style; } virtual QRect getRect() const; bool getUpperLeftCorner(int &xPos, int &yPos) const; bool getLowerRightCorner(int &xPos, int &yPos) const; virtual bool prepareMouseEvent( int x, int y, int _tx, int _ty, MouseEvent *ev); virtual void setFocus(bool=true); virtual void setActive(bool=true); virtual void applyChanges(bool top = true, bool force = true); virtual unsigned long childNodeCount(); virtual NodeImpl *childNode(unsigned long index);protected: NodeImpl *_first; NodeImpl *_last; khtml::RenderStyle *m_style; // helper functions for inserting children: // check for same source document: bool checkSameDocument( NodeImpl *newchild, int &exceptioncode ); // check for being (grand-..)father: bool checkNoOwner( NodeImpl *other, int &exceptioncode ); // check for being child: bool checkIsChild( NodeImpl *oldchild, int &exceptioncode ); // find out if a node is allowed to be our child virtual bool childAllowed( NodeImpl *newChild ); void dispatchChildInsertedEvents( NodeImpl *child, int &exceptioncode );};// --------------------------------------------------------------------------class Node;class NodeImpl;class NodeListImpl : public DomShared{public: virtual unsigned long length() const; virtual NodeImpl *item ( unsigned long index ) const;protected: // helper functions for searching all ElementImpls in a tree unsigned long recursiveLength(NodeImpl *start) const; NodeImpl *recursiveItem ( NodeImpl *start, unsigned long &offset ) const; virtual bool nodeMatches( NodeImpl *testNode ) const;};class ChildNodeListImpl : public NodeListImpl{public: ChildNodeListImpl( NodeImpl *n); virtual ~ChildNodeListImpl(); virtual unsigned long length() const; virtual NodeImpl *item ( unsigned long index ) const;protected: NodeImpl *refNode;};/** * NodeList which lists all Nodes in a document with a given tag name */class TagNodeListImpl : public NodeListImpl{public: TagNodeListImpl( NodeImpl *n, const DOMString &t ); virtual ~TagNodeListImpl(); virtual unsigned long length() const; virtual NodeImpl *item ( unsigned long index ) const;protected: virtual bool nodeMatches( NodeImpl *testNode ) const; NodeImpl *refNode; DOMString tagName; bool allElements;};/** * NodeList which lists all Nodes in a Element with a given "name=" tag */class NameNodeListImpl : public NodeListImpl{public: NameNodeListImpl( NodeImpl *doc, const DOMString &t ); virtual ~NameNodeListImpl(); virtual unsigned long length() const; virtual NodeImpl *item ( unsigned long index ) const;protected: virtual bool nodeMatches( NodeImpl *testNode ) const; NodeImpl *refNode; DOMString nodeName;};// Generic NamedNodeMap interface// Other classes implement this for more specific situations e.g. attributes// of an elemenetclass NamedNodeMapImpl : public DomShared{public: NamedNodeMapImpl(); virtual ~NamedNodeMapImpl(); virtual unsigned long length(int &exceptioncode) const = 0; virtual NodeImpl *getNamedItem ( const DOMString &name, int &exceptioncode ) const = 0; virtual Node setNamedItem ( const Node &arg, int &exceptioncode ) = 0; virtual Node removeNamedItem ( const DOMString &name, int &exceptioncode ) = 0; virtual NodeImpl *item ( unsigned long index, int &exceptioncode ) const = 0;};// Generic read-only NamedNodeMap implementation// You can add items using the internal function addItem()class GenericRONamedNodeMapImpl : public NamedNodeMapImpl{public: GenericRONamedNodeMapImpl(); virtual ~GenericRONamedNodeMapImpl(); virtual unsigned long length(int &exceptioncode) const; virtual NodeImpl *getNamedItem ( const DOMString &name, int &exceptioncode ) const; virtual Node setNamedItem ( const Node &arg, int &exceptioncode ); virtual Node removeNamedItem ( const DOMString &name, int &exceptioncode ); virtual NodeImpl *item ( unsigned long index, int &exceptioncode ) const; void addNode(NodeImpl *n);protected: QList<NodeImpl> *m_contents;};}; //namespace#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -