• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
4  *           (C) 2001 Dirk Mueller (mueller@kde.org)
5  * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
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
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  *
22  */
23 
24 #ifndef Node_h
25 #define Node_h
26 
27 #include "DocPtr.h"
28 #include "KURLHash.h"
29 #include "PlatformString.h"
30 #include "TreeShared.h"
31 #include <wtf/Assertions.h>
32 #include <wtf/ListHashSet.h>
33 #include <wtf/OwnPtr.h>
34 #include <wtf/PassRefPtr.h>
35 
36 namespace WebCore {
37 
38 class AtomicString;
39 class ContainerNode;
40 class Document;
41 class DynamicNodeList;
42 class Element;
43 class Event;
44 class EventListener;
45 class IntRect;
46 class KeyboardEvent;
47 class NSResolver;
48 class NamedAttrMap;
49 class NodeList;
50 class PlatformKeyboardEvent;
51 class PlatformMouseEvent;
52 class PlatformWheelEvent;
53 class QualifiedName;
54 class RenderArena;
55 class RenderBox;
56 class RenderObject;
57 class RenderStyle;
58 class StringBuilder;
59 class NodeRareData;
60 
61 typedef int ExceptionCode;
62 
63 enum StyleChangeType { NoStyleChange, InlineStyleChange, FullStyleChange, AnimationStyleChange };
64 
65 const unsigned short DOCUMENT_POSITION_EQUIVALENT = 0x00;
66 const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01;
67 const unsigned short DOCUMENT_POSITION_PRECEDING = 0x02;
68 const unsigned short DOCUMENT_POSITION_FOLLOWING = 0x04;
69 const unsigned short DOCUMENT_POSITION_CONTAINS = 0x08;
70 const unsigned short DOCUMENT_POSITION_CONTAINED_BY = 0x10;
71 const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20;
72 
73 // this class implements nodes, which can have a parent but no children:
74 class Node : public TreeShared<Node> {
75     friend class Document;
76 public:
77     enum NodeType {
78         ELEMENT_NODE = 1,
79         ATTRIBUTE_NODE = 2,
80         TEXT_NODE = 3,
81         CDATA_SECTION_NODE = 4,
82         ENTITY_REFERENCE_NODE = 5,
83         ENTITY_NODE = 6,
84         PROCESSING_INSTRUCTION_NODE = 7,
85         COMMENT_NODE = 8,
86         DOCUMENT_NODE = 9,
87         DOCUMENT_TYPE_NODE = 10,
88         DOCUMENT_FRAGMENT_NODE = 11,
89         NOTATION_NODE = 12,
90         XPATH_NAMESPACE_NODE = 13
91     };
92 
93     static bool isSupported(const String& feature, const String& version);
94 
95     static void startIgnoringLeaks();
96     static void stopIgnoringLeaks();
97 
98     static void dumpStatistics();
99 
100     enum StyleChange { NoChange, NoInherit, Inherit, Detach, Force };
101     static StyleChange diff(RenderStyle*, RenderStyle*);
102 
103     Node(Document*, bool isElement = false, bool isContainer = false, bool isText = false);
104     virtual ~Node();
105 
106     // DOM methods & attributes for Node
107 
108     bool hasTagName(const QualifiedName&) const;
109     virtual String nodeName() const = 0;
110     virtual String nodeValue() const;
111     virtual void setNodeValue(const String&, ExceptionCode&);
112     virtual NodeType nodeType() const = 0;
parentNode()113     Node* parentNode() const { return parent(); }
114     Element* parentElement() const;
previousSibling()115     Node* previousSibling() const { return m_previous; }
nextSibling()116     Node* nextSibling() const { return m_next; }
117     PassRefPtr<NodeList> childNodes();
firstChild()118     Node* firstChild() const { return isContainerNode() ? containerFirstChild() : 0; }
lastChild()119     Node* lastChild() const { return isContainerNode() ? containerLastChild() : 0; }
120     bool hasAttributes() const;
121     NamedAttrMap* attributes() const;
122 
123     virtual KURL baseURI() const;
124 
125     void getSubresourceURLs(ListHashSet<KURL>&) const;
126 
127     // These should all actually return a node, but this is only important for language bindings,
128     // which will already know and hold a ref on the right node to return. Returning bool allows
129     // these methods to be more efficient since they don't need to return a ref
130     virtual bool insertBefore(PassRefPtr<Node> newChild, Node* refChild, ExceptionCode&, bool shouldLazyAttach = false);
131     virtual bool replaceChild(PassRefPtr<Node> newChild, Node* oldChild, ExceptionCode&, bool shouldLazyAttach = false);
132     virtual bool removeChild(Node* child, ExceptionCode&);
133     virtual bool appendChild(PassRefPtr<Node> newChild, ExceptionCode&, bool shouldLazyAttach = false);
134 
135     void remove(ExceptionCode&);
hasChildNodes()136     bool hasChildNodes() const { return firstChild(); }
137     virtual PassRefPtr<Node> cloneNode(bool deep) = 0;
localName()138     const AtomicString& localName() const { return virtualLocalName(); }
namespaceURI()139     const AtomicString& namespaceURI() const { return virtualNamespaceURI(); }
prefix()140     const AtomicString& prefix() const { return virtualPrefix(); }
141     virtual void setPrefix(const AtomicString&, ExceptionCode&);
142     void normalize();
143 
isSameNode(Node * other)144     bool isSameNode(Node* other) const { return this == other; }
145     bool isEqualNode(Node*) const;
146     bool isDefaultNamespace(const AtomicString& namespaceURI) const;
147     String lookupPrefix(const AtomicString& namespaceURI) const;
148     String lookupNamespaceURI(const String& prefix) const;
149     String lookupNamespacePrefix(const AtomicString& namespaceURI, const Element* originalElement) const;
150 
151     String textContent(bool convertBRsToNewlines = false) const;
152     void setTextContent(const String&, ExceptionCode&);
153 
154     Node* lastDescendant() const;
155     Node* firstDescendant() const;
156 
157     // Other methods (not part of DOM)
158 
isElementNode()159     bool isElementNode() const { return m_isElement; }
isContainerNode()160     bool isContainerNode() const { return m_isContainer; }
isTextNode()161     bool isTextNode() const { return m_isText; }
162 
isHTMLElement()163     virtual bool isHTMLElement() const { return false; }
164 
165 #if ENABLE(SVG)
isSVGElement()166     virtual bool isSVGElement() const { return false; }
167 #else
isSVGElement()168     static bool isSVGElement() { return false; }
169 #endif
170 
171 #if ENABLE(WML)
isWMLElement()172     virtual bool isWMLElement() const { return false; }
173 #else
isWMLElement()174     static bool isWMLElement() { return false; }
175 #endif
176 
isStyledElement()177     virtual bool isStyledElement() const { return false; }
isFrameOwnerElement()178     virtual bool isFrameOwnerElement() const { return false; }
isAttributeNode()179     virtual bool isAttributeNode() const { return false; }
isCommentNode()180     virtual bool isCommentNode() const { return false; }
isCharacterDataNode()181     virtual bool isCharacterDataNode() const { return false; }
182     bool isDocumentNode() const;
isEventTargetNode()183     virtual bool isEventTargetNode() const { return false; }
isShadowNode()184     virtual bool isShadowNode() const { return false; }
shadowParentNode()185     virtual Node* shadowParentNode() { return 0; }
186     Node* shadowAncestorNode();
187     Node* shadowTreeRootNode();
188     bool isInShadowTree();
189 
190     // The node's parent for the purpose of event capture and bubbling.
191     virtual ContainerNode* eventParentNode();
192 
193     bool isBlockFlow() const;
194     bool isBlockFlowOrBlockTable() const;
195 
196     // These low-level calls give the caller responsibility for maintaining the integrity of the tree.
setPreviousSibling(Node * previous)197     void setPreviousSibling(Node* previous) { m_previous = previous; }
setNextSibling(Node * next)198     void setNextSibling(Node* next) { m_next = next; }
199 
200     // FIXME: These two functions belong in editing -- "atomic node" is an editing concept.
201     Node* previousNodeConsideringAtomicNodes() const;
202     Node* nextNodeConsideringAtomicNodes() const;
203 
204     /** (Not part of the official DOM)
205      * Returns the next leaf node.
206      *
207      * Using this function delivers leaf nodes as if the whole DOM tree were a linear chain of its leaf nodes.
208      * @return next leaf node or 0 if there are no more.
209      */
210     Node* nextLeafNode() const;
211 
212     /** (Not part of the official DOM)
213      * Returns the previous leaf node.
214      *
215      * Using this function delivers leaf nodes as if the whole DOM tree were a linear chain of its leaf nodes.
216      * @return previous leaf node or 0 if there are no more.
217      */
218     Node* previousLeafNode() const;
219 
220     bool isEditableBlock() const;
221 
222     // enclosingBlockFlowElement() is deprecated.  Use enclosingBlock instead.
223     Element* enclosingBlockFlowElement() const;
224 
225     Element* enclosingInlineElement() const;
226     Element* rootEditableElement() const;
227 
228     bool inSameContainingBlockFlowElement(Node*);
229 
230     // Used by the parser. Checks against the DTD, unlike DOM operations like appendChild().
231     // Also does not dispatch DOM mutation events.
232     // Returns the appropriate container node for future insertions as you parse, or 0 for failure.
233     virtual ContainerNode* addChild(PassRefPtr<Node>);
234 
235     // Called by the parser when this element's close tag is reached,
236     // signalling that all child tags have been parsed and added.
237     // This is needed for <applet> and <object> elements, which can't lay themselves out
238     // until they know all of their nested <param>s. [Radar 3603191, 4040848].
239     // Also used for script elements and some SVG elements for similar purposes,
240     // but making parsing a special case in this respect should be avoided if possible.
finishParsingChildren()241     virtual void finishParsingChildren() { }
beginParsingChildren()242     virtual void beginParsingChildren() { }
243 
244     // Called by the frame right before dispatching an unloadEvent. [Radar 4532113]
245     // This is needed for HTMLInputElements to tell the frame that it is done editing
246     // (sends textFieldDidEndEditing notification)
aboutToUnload()247     virtual void aboutToUnload() { }
248 
249     // For <link> and <style> elements.
sheetLoaded()250     virtual bool sheetLoaded() { return true; }
251 
hasID()252     bool hasID() const { return m_hasId; }
hasClass()253     bool hasClass() const { return m_hasClass; }
active()254     bool active() const { return m_active; }
inActiveChain()255     bool inActiveChain() const { return m_inActiveChain; }
inDetach()256     bool inDetach() const { return m_inDetach; }
hovered()257     bool hovered() const { return m_hovered; }
focused()258     bool focused() const { return hasRareData() ? rareDataFocused() : false; }
attached()259     bool attached() const { return m_attached; }
260     void setAttached(bool b = true) { m_attached = b; }
changed()261     bool changed() const { return m_styleChange != NoStyleChange; }
styleChangeType()262     StyleChangeType styleChangeType() const { return static_cast<StyleChangeType>(m_styleChange); }
hasChangedChild()263     bool hasChangedChild() const { return m_hasChangedChild; }
isLink()264     bool isLink() const { return m_isLink; }
265     void setHasID(bool b = true) { m_hasId = b; }
266     void setHasClass(bool b = true) { m_hasClass = b; }
267     void setHasChangedChild( bool b = true ) { m_hasChangedChild = b; }
268     void setInDocument(bool b = true) { m_inDocument = b; }
269     void setInActiveChain(bool b = true) { m_inActiveChain = b; }
270     void setChanged(StyleChangeType changeType = FullStyleChange);
271     void setIsLink(bool b = true) { m_isLink = b; }
272 
inSubtreeMark()273     bool inSubtreeMark() const { return m_inSubtreeMark; }
274     void setInSubtreeMark(bool b = true) { m_inSubtreeMark = b; }
275 
276     void lazyAttach();
277     virtual bool canLazyAttach();
278 
279     virtual void setFocus(bool b = true);
280     virtual void setActive(bool b = true, bool /*pause*/ = false) { m_active = b; }
281     virtual void setHovered(bool b = true) { m_hovered = b; }
282 
283     virtual short tabIndex() const;
284 
285     /**
286      * Whether this node can receive the keyboard focus.
287      */
supportsFocus()288     virtual bool supportsFocus() const { return isFocusable(); }
289     virtual bool isFocusable() const;
290     virtual bool isKeyboardFocusable(KeyboardEvent*) const;
291     virtual bool isMouseFocusable() const;
292 
isAutofilled()293     virtual bool isAutofilled() const { return false; }
isControl()294     virtual bool isControl() const { return false; } // Eventually the notion of what is a control will be extensible.
isEnabled()295     virtual bool isEnabled() const { return true; }
isChecked()296     virtual bool isChecked() const { return false; }
isIndeterminate()297     virtual bool isIndeterminate() const { return false; }
isReadOnlyControl()298     virtual bool isReadOnlyControl() const { return false; }
isTextControl()299     virtual bool isTextControl() const { return false; }
300 
301     virtual bool isContentEditable() const;
302     virtual bool isContentRichlyEditable() const;
303     virtual bool shouldUseInputMethod() const;
304     virtual IntRect getRect() const;
305 
306     virtual void recalcStyle(StyleChange = NoChange) { }
307 
308     unsigned nodeIndex() const;
309 
310     // Returns the DOM ownerDocument attribute. This method never returns NULL, except in the case
311     // of (1) a Document node or (2) a DocumentType node that is not used with any Document yet.
312     virtual Document* ownerDocument() const;
313 
314     // Returns the document associated with this node. This method never returns NULL, except in the case
315     // of a DocumentType node that is not used with any Document yet. A Document node returns itself.
document()316     Document* document() const
317     {
318         ASSERT(this);
319         ASSERT(m_document || nodeType() == DOCUMENT_TYPE_NODE && !inDocument());
320         return m_document.get();
321     }
322     void setDocument(Document*);
323 
324     // Returns true if this node is associated with a document and is in its associated document's
325     // node tree, false otherwise.
inDocument()326     bool inDocument() const
327     {
328         ASSERT(m_document || !m_inDocument);
329         return m_inDocument;
330     }
331 
isReadOnlyNode()332     bool isReadOnlyNode() const { return nodeType() == ENTITY_REFERENCE_NODE; }
childTypeAllowed(NodeType)333     virtual bool childTypeAllowed(NodeType) { return false; }
childNodeCount()334     unsigned childNodeCount() const { return isContainerNode() ? containerChildNodeCount() : 0; }
childNode(unsigned index)335     Node* childNode(unsigned index) const { return isContainerNode() ? containerChildNode(index) : 0; }
336 
337     /**
338      * Does a pre-order traversal of the tree to find the node next node after this one. This uses the same order that
339      * the tags appear in the source file.
340      *
341      * @param stayWithin If not null, the traversal will stop once the specified node is reached. This can be used to
342      * restrict traversal to a particular sub-tree.
343      *
344      * @return The next node, in document order
345      *
346      * see @ref traversePreviousNode()
347      */
348     Node* traverseNextNode(const Node* stayWithin = 0) const;
349 
350     // Like traverseNextNode, but skips children and starts with the next sibling.
351     Node* traverseNextSibling(const Node* stayWithin = 0) const;
352 
353     /**
354      * Does a reverse pre-order traversal to find the node that comes before the current one in document order
355      *
356      * see @ref traverseNextNode()
357      */
358     Node* traversePreviousNode(const Node * stayWithin = 0) const;
359 
360     // Like traverseNextNode, but visits parents after their children.
361     Node* traverseNextNodePostOrder() const;
362 
363     // Like traversePreviousNode, but visits parents before their children.
364     Node* traversePreviousNodePostOrder(const Node *stayWithin = 0) const;
365     Node* traversePreviousSiblingPostOrder(const Node *stayWithin = 0) const;
366 
367     /**
368      * Finds previous or next editable leaf node.
369      */
370     Node* previousEditable() const;
371     Node* nextEditable() const;
372 
renderer()373     RenderObject* renderer() const { return m_renderer; }
374     RenderObject* nextRenderer();
375     RenderObject* previousRenderer();
setRenderer(RenderObject * renderer)376     void setRenderer(RenderObject* renderer) { m_renderer = renderer; }
377 
378     // Use with caution. Does no type checking.  Mostly a convenience method for shadow nodes of form controls, where we know exactly
379     // what kind of renderer we made.
380     RenderBox* renderBox() const;
381 
382     void checkSetPrefix(const AtomicString& prefix, ExceptionCode&);
383     bool isDescendantOf(const Node*) const;
384     bool contains(const Node*) const;
385 
386     // These two methods are mutually exclusive.  The former is used to do strict error-checking
387     // when adding children via the public DOM API (e.g., appendChild()).  The latter is called only when parsing,
388     // to sanity-check against the DTD for error recovery.
389     void checkAddChild(Node* newChild, ExceptionCode&); // Error-checking when adding via the DOM API
390     virtual bool childAllowed(Node* newChild);          // Error-checking during parsing that checks the DTD
391 
392     void checkReplaceChild(Node* newChild, Node* oldChild, ExceptionCode&);
393     virtual bool canReplaceChild(Node* newChild, Node* oldChild);
394 
395     // Used to determine whether range offsets use characters or node indices.
396     virtual bool offsetInCharacters() const;
397     // Number of DOM 16-bit units contained in node. Note that rendered text length can be different - e.g. because of
398     // css-transform:capitalize breaking up precomposed characters and ligatures.
399     virtual int maxCharacterOffset() const;
400 
401     // FIXME: We should try to find a better location for these methods.
canSelectAll()402     virtual bool canSelectAll() const { return false; }
selectAll()403     virtual void selectAll() { }
404 
405     // Whether or not a selection can be started in this object
406     virtual bool canStartSelection() const;
407 
408     // -----------------------------------------------------------------------------
409     // Integration with rendering tree
410 
411     /**
412      * Attaches this node to the rendering tree. This calculates the style to be applied to the node and creates an
413      * appropriate RenderObject which will be inserted into the tree (except when the style has display: none). This
414      * makes the node visible in the FrameView.
415      */
416     virtual void attach();
417 
418     /**
419      * Detaches the node from the rendering tree, making it invisible in the rendered view. This method will remove
420      * the node's rendering object from the rendering tree and delete it.
421      */
422     virtual void detach();
423 
424     virtual void willRemove();
425     void createRendererIfNeeded();
426     PassRefPtr<RenderStyle> styleForRenderer();
427     virtual bool rendererIsNeeded(RenderStyle*);
428 #if ENABLE(SVG)
childShouldCreateRenderer(Node *)429     virtual bool childShouldCreateRenderer(Node*) const { return true; }
430 #endif
431     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
432 
433     // Wrapper for nodes that don't have a renderer, but still cache the style (like HTMLOptionElement).
434     RenderStyle* renderStyle() const;
435     virtual void setRenderStyle(PassRefPtr<RenderStyle>);
436 
437     virtual RenderStyle* computedStyle();
438 
439     // -----------------------------------------------------------------------------
440     // Notification of document structure changes
441 
442     /**
443      * Notifies the node that it has been inserted into the document. This is called during document parsing, and also
444      * when a node is added through the DOM methods insertBefore(), appendChild() or replaceChild(). Note that this only
445      * happens when the node becomes part of the document tree, i.e. only when the document is actually an ancestor of
446      * the node. The call happens _after_ the node has been added to the tree.
447      *
448      * This is similar to the DOMNodeInsertedIntoDocument DOM event, but does not require the overhead of event
449      * dispatching.
450      */
451     virtual void insertedIntoDocument();
452 
453     /**
454      * Notifies the node that it is no longer part of the document tree, i.e. when the document is no longer an ancestor
455      * node.
456      *
457      * This is similar to the DOMNodeRemovedFromDocument DOM event, but does not require the overhead of event
458      * dispatching, and is called _after_ the node is removed from the tree.
459      */
460     virtual void removedFromDocument();
461 
462     // These functions are called whenever you are connected or disconnected from a tree.  That tree may be the main
463     // document tree, or it could be another disconnected tree.  Override these functions to do any work that depends
464     // on connectedness to some ancestor (e.g., an ancestor <form> for example).
insertedIntoTree(bool)465     virtual void insertedIntoTree(bool /*deep*/) { }
removedFromTree(bool)466     virtual void removedFromTree(bool /*deep*/) { }
467 
468     /**
469      * Notifies the node that it's list of children have changed (either by adding or removing child nodes), or a child
470      * node that is of the type CDATA_SECTION_NODE, TEXT_NODE or COMMENT_NODE has changed its value.
471      */
472     virtual void childrenChanged(bool /*changedByParser*/ = false, Node* /*beforeChange*/ = 0, Node* /*afterChange*/ = 0, int /*childCountDelta*/ = 0) { }
473 
474 #if !defined(NDEBUG) || defined(ANDROID_DOM_LOGGING)
475     virtual void formatForDebugger(char* buffer, unsigned length) const;
476 
477     void showNode(const char* prefix = "") const;
478     void showTreeForThis() const;
479     void showTreeAndMark(const Node* markedNode1, const char* markedLabel1, const Node* markedNode2 = 0, const char* markedLabel2 = 0) const;
480 #endif
481 
482     void registerDynamicNodeList(DynamicNodeList*);
483     void unregisterDynamicNodeList(DynamicNodeList*);
484     void notifyNodeListsChildrenChanged();
485     void notifyLocalNodeListsChildrenChanged();
486     void notifyNodeListsAttributeChanged();
487     void notifyLocalNodeListsAttributeChanged();
488 
489     PassRefPtr<NodeList> getElementsByTagName(const String&);
490     PassRefPtr<NodeList> getElementsByTagNameNS(const AtomicString& namespaceURI, const String& localName);
491     PassRefPtr<NodeList> getElementsByName(const String& elementName);
492     PassRefPtr<NodeList> getElementsByClassName(const String& classNames);
493 
494     PassRefPtr<Element> querySelector(const String& selectors, ExceptionCode&);
495     PassRefPtr<NodeList> querySelectorAll(const String& selectors, ExceptionCode&);
496 
497     unsigned short compareDocumentPosition(Node*);
498 
499 #ifdef ANDROID_INSTRUMENT
500     // Overridden to prevent the normal new from being called.
501     void* operator new(size_t) throw();
502 
503     // Overridden to prevent the normal delete from being called.
504     void operator delete(void*, size_t);
505 
506     static size_t reportDOMNodesSize();
507 #endif
508 
509 protected:
willMoveToNewOwnerDocument()510     virtual void willMoveToNewOwnerDocument() { }
didMoveToNewOwnerDocument()511     virtual void didMoveToNewOwnerDocument() { }
512 
addSubresourceAttributeURLs(ListHashSet<KURL> &)513     virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const { }
514     void setTabIndexExplicitly(short);
515 
hasRareData()516     bool hasRareData() const { return m_hasRareData; }
517 
518     NodeRareData* rareData() const;
519     NodeRareData* ensureRareData();
520 
521 private:
522     virtual NodeRareData* createRareData();
523     Node* containerChildNode(unsigned index) const;
524     unsigned containerChildNodeCount() const;
525     Node* containerFirstChild() const;
526     Node* containerLastChild() const;
527     bool rareDataFocused() const;
528 
529     virtual RenderStyle* nonRendererRenderStyle() const;
530 
531     virtual const AtomicString& virtualPrefix() const;
532     virtual const AtomicString& virtualLocalName() const;
533     virtual const AtomicString& virtualNamespaceURI() const;
534 
535     Element* ancestorElement() const;
536 
537     void appendTextContent(bool convertBRsToNewlines, StringBuilder&) const;
538 
539     DocPtr<Document> m_document;
540     Node* m_previous;
541     Node* m_next;
542     RenderObject* m_renderer;
543 
544     unsigned m_styleChange : 2;
545     bool m_hasId : 1;
546     bool m_hasClass : 1;
547     bool m_attached : 1;
548     bool m_hasChangedChild : 1;
549     bool m_inDocument : 1;
550     bool m_isLink : 1;
551     bool m_active : 1;
552     bool m_hovered : 1;
553     bool m_inActiveChain : 1;
554     bool m_inDetach : 1;
555     bool m_inSubtreeMark : 1;
556     bool m_hasRareData : 1;
557     const bool m_isElement : 1;
558     const bool m_isContainer : 1;
559     const bool m_isText : 1;
560 
561 protected:
562     // These bits are used by the Element derived class, pulled up here so they can
563     // be stored in the same memory word as the Node bits above.
564     bool m_parsingChildrenFinished : 1;
565 #if ENABLE(SVG)
566     mutable bool m_areSVGAttributesValid : 1;
567 #endif
568 
569     // These bits are used by the StyledElement derived class, and live here for the
570     // same reason as above.
571     mutable bool m_isStyleAttributeValid : 1;
572     mutable bool m_synchronizingStyleAttribute : 1;
573 
574 #if ENABLE(SVG)
575     // This bit is used by the SVGElement derived class, and lives here for the same
576     // reason as above.
577     mutable bool m_synchronizingSVGAttributes : 1;
578 #endif
579 
580     // 11 bits remaining
581 };
582 
583 // Used in Node::addSubresourceAttributeURLs() and in addSubresourceStyleURLs()
addSubresourceURL(ListHashSet<KURL> & urls,const KURL & url)584 inline void addSubresourceURL(ListHashSet<KURL>& urls, const KURL& url)
585 {
586     if (!url.isNull())
587         urls.add(url);
588 }
589 
590 } //namespace
591 
592 #ifndef NDEBUG
593 // Outside the WebCore namespace for ease of invocation from gdb.
594 void showTree(const WebCore::Node*);
595 #endif
596 
597 #endif
598