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 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
30 #include "DeprecatedPtrList.h"
31 #include "DeprecatedValueList.h"
32 #include "DocumentMarker.h"
33 #include "HTMLCollection.h"
34 #include "HTMLFormElement.h"
35 #include "StringHash.h"
37 #include <wtf/HashCountedSet.h>
38 #include <wtf/ListHashSet.h>
46 class CSSStyleDeclaration;
47 class CSSStyleSelector;
50 class DOMImplementation;
52 class TextResourceDecoder;
54 class DocumentFragment;
58 class EntityReference;
65 class HTMLFormControlElementWithState;
66 class HTMLFormElement;
67 class HTMLHeadElement;
68 class HTMLImageLoader;
69 class HTMLInputElement;
73 class MouseEventWithHitTestResults;
79 class PlatformMouseEvent;
80 class ProcessingInstruction;
82 class RegisteredEventListener;
91 class XBLBindingManager;
95 class XPathExpression;
96 class XPathNSResolver;
100 struct DashboardRegionValue;
101 struct HitTestRequest;
104 class SVGDocumentExtensions;
107 typedef int ExceptionCode;
109 class FormElementKey {
111 FormElementKey(AtomicStringImpl* = 0, AtomicStringImpl* = 0);
113 FormElementKey(const FormElementKey&);
114 FormElementKey& operator=(const FormElementKey&);
115 AtomicStringImpl* name() const { return m_name; }
116 AtomicStringImpl* type() const { return m_type; }
120 AtomicStringImpl* m_name;
121 AtomicStringImpl* m_type;
124 inline bool operator==(const FormElementKey& a, const FormElementKey& b)
125 { return a.name() == b.name() && a.type() == b.type(); }
127 struct FormElementKeyHash {
128 static unsigned hash(const FormElementKey&);
129 static bool equal(const FormElementKey& a, const FormElementKey& b) { return a == b; }
132 struct FormElementKeyHashTraits : WTF::GenericHashTraits<FormElementKey> {
133 static FormElementKey deletedValue();
136 class Document : public ContainerNode {
138 Document(DOMImplementation*, Frame*);
141 virtual void removedLastRef();
143 // Nodes belonging to this document hold "self-only" references -
144 // these are enough to keep the document from being destroyed, but
145 // not enough to keep it from removing its children. This allows a
146 // node that outlives its document to still have a valid document
147 // pointer without introducing reference cycles
149 void selfOnlyRef() { ++m_selfOnlyRefCount; }
150 void selfOnlyDeref() {
151 --m_selfOnlyRefCount;
152 if (!m_selfOnlyRefCount && !refCount())
156 // DOM methods & attributes for Document
158 virtual DocumentType* doctype() const; // May return 0 for HTML documents
159 DocumentType* realDocType() const { return m_docType.get(); }
161 DOMImplementation* implementation() const;
162 virtual void childrenChanged();
163 Element* documentElement() const;
164 PassRefPtr<Element> createElement(const String& tagName, ExceptionCode&);
165 PassRefPtr<DocumentFragment> createDocumentFragment ();
166 PassRefPtr<Text> createTextNode(const String& data);
167 PassRefPtr<Comment> createComment(const String& data);
168 PassRefPtr<CDATASection> createCDATASection(const String& data, ExceptionCode&);
169 PassRefPtr<ProcessingInstruction> createProcessingInstruction(const String& target, const String& data, ExceptionCode&);
170 PassRefPtr<Attr> createAttribute(const String& name, ExceptionCode& ec) { return createAttributeNS(String(), name, ec); }
171 PassRefPtr<Attr> createAttributeNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode&);
172 PassRefPtr<EntityReference> createEntityReference(const String& name, ExceptionCode&);
173 PassRefPtr<Node> importNode(Node* importedNode, bool deep, ExceptionCode&);
174 virtual PassRefPtr<Element> createElementNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode&);
175 PassRefPtr<Element> createElement(const QualifiedName&, bool createdByParser, ExceptionCode& ec);
176 Element* getElementById(const AtomicString&) const;
178 Element* elementFromPoint(int x, int y) const;
179 String readyState() const;
180 String inputEncoding() const;
181 String defaultCharset() const;
183 String charset() const { return inputEncoding(); }
184 String characterSet() const { return inputEncoding(); }
186 void setCharset(const String&);
188 String xmlEncoding() const { return m_xmlEncoding; }
189 String xmlVersion() const { return m_xmlVersion; }
190 bool xmlStandalone() const { return m_xmlStandalone; }
192 void setXMLEncoding(const String& encoding) { m_xmlEncoding = encoding; } // read-only property, only to be set from XMLTokenizer
193 void setXMLVersion(const String&, ExceptionCode&);
194 void setXMLStandalone(bool, ExceptionCode&);
196 String documentURI() const;
197 void setDocumentURI(const String&);
199 virtual String baseURI() const;
201 PassRefPtr<Node> adoptNode(PassRefPtr<Node> source, ExceptionCode&);
203 PassRefPtr<NameNodeList> getElementsByName(const String& elementName);
205 // Actually part of JSHTMLDocument, but used for giving XML documents a window title as well
206 String title() const { return m_title; }
207 void setTitle(const String&, Element* titleElement = 0);
208 void removeTitle(Element* titleElement);
210 PassRefPtr<HTMLCollection> images();
211 PassRefPtr<HTMLCollection> embeds();
212 PassRefPtr<HTMLCollection> plugins(); // an alias for embeds() required for the JS DOM bindings.
213 PassRefPtr<HTMLCollection> applets();
214 PassRefPtr<HTMLCollection> links();
215 PassRefPtr<HTMLCollection> forms();
216 PassRefPtr<HTMLCollection> anchors();
217 PassRefPtr<HTMLCollection> all();
218 PassRefPtr<HTMLCollection> objects();
219 PassRefPtr<HTMLCollection> scripts();
220 PassRefPtr<HTMLCollection> windowNamedItems(const String& name);
221 PassRefPtr<HTMLCollection> documentNamedItems(const String& name);
223 HTMLCollection::CollectionInfo* collectionInfo(HTMLCollection::Type type)
225 if ((int)type < HTMLCollection::UnnamedCollectionTypes)
226 return m_collectionInfo + type;
230 HTMLCollection::CollectionInfo* nameCollectionInfo(HTMLCollection::Type type, const String& name);
232 // DOM methods overridden from parent classes
234 virtual String nodeName() const;
235 virtual NodeType nodeType() const;
237 // Other methods (not part of DOM)
238 virtual bool isDocumentNode() const { return true; }
239 virtual bool isHTMLDocument() const { return false; }
240 virtual bool isImageDocument() const { return false; }
242 virtual bool isSVGDocument() const { return false; }
244 virtual bool isPluginDocument() const { return false; }
246 CSSStyleSelector* styleSelector() const { return m_styleSelector; }
248 Element* getElementByAccessKey(const String& key) const;
251 * Updates the pending sheet count and then calls updateStyleSelector.
253 void stylesheetLoaded();
256 * This method returns true if all top-level stylesheets have loaded (including
257 * any @imports that they may be loading).
259 bool haveStylesheetsLoaded() const
261 return m_pendingStylesheets <= 0 || m_ignorePendingStylesheets
262 #if USE(LOW_BANDWIDTH_DISPLAY)
263 || m_inLowBandwidthDisplay
269 * Increments the number of pending sheets. The <link> elements
270 * invoke this to add themselves to the loading list.
272 void addPendingSheet() { m_pendingStylesheets++; }
274 bool gotoAnchorNeededAfterStylesheetsLoad() { return m_gotoAnchorNeededAfterStylesheetsLoad; }
275 void setGotoAnchorNeededAfterStylesheetsLoad(bool b) { m_gotoAnchorNeededAfterStylesheetsLoad = b; }
278 * Called when one or more stylesheets in the document may have been added, removed or changed.
280 * Creates a new style selector and assign it to this document. This is done by iterating through all nodes in
281 * document (or those before <BODY> in a HTML document), searching for stylesheets. Stylesheets can be contained in
282 * <LINK>, <STYLE> or <BODY> elements, as well as processing instructions (XML documents only). A list is
283 * constructed from these which is used to create the a new style selector which collates all of the stylesheets
284 * found and is used to calculate the derived styles for all rendering objects.
286 void updateStyleSelector();
288 void recalcStyleSelector();
290 bool usesDescendantRules() const { return m_usesDescendantRules; }
291 void setUsesDescendantRules(bool b) { m_usesDescendantRules = b; }
292 bool usesSiblingRules() const { return m_usesSiblingRules; }
293 void setUsesSiblingRules(bool b) { m_usesSiblingRules = b; }
294 bool usesFirstLineRules() const { return m_usesFirstLineRules; }
295 void setUsesFirstLineRules(bool b) { m_usesFirstLineRules = b; }
296 bool usesFirstLetterRules() const { return m_usesFirstLetterRules; }
297 void setUsesFirstLetterRules(bool b) { m_usesFirstLetterRules = b; }
299 // Machinery for saving and restoring state when you leave and then go back to a page.
300 void registerFormElementWithState(HTMLFormControlElementWithState* e) { m_formElementsWithState.add(e); }
301 void unregisterFormElementWithState(HTMLFormControlElementWithState* e) { m_formElementsWithState.remove(e); }
302 Vector<String> formElementsState() const;
303 void setStateForNewFormElements(const Vector<String>&);
304 bool hasStateForNewFormElements() const;
305 bool takeStateForFormElement(AtomicStringImpl* name, AtomicStringImpl* type, String& state);
307 FrameView* view() const; // can be NULL
308 Frame* frame() const; // can be NULL
309 Page* page() const; // can be NULL
310 Settings* settings() const; // can be NULL
312 PassRefPtr<Range> createRange();
314 PassRefPtr<NodeIterator> createNodeIterator(Node* root, unsigned whatToShow,
315 NodeFilter*, bool expandEntityReferences, ExceptionCode&);
317 PassRefPtr<TreeWalker> createTreeWalker(Node* root, unsigned whatToShow,
318 NodeFilter*, bool expandEntityReferences, ExceptionCode&);
320 // Special support for editing
321 PassRefPtr<CSSStyleDeclaration> createCSSStyleDeclaration();
322 PassRefPtr<EditingText> createEditingTextNode(const String&);
324 virtual void recalcStyle( StyleChange = NoChange );
325 static DeprecatedPtrList<Document>* changedDocuments;
326 virtual void updateRendering();
328 void updateLayoutIgnorePendingStylesheets();
329 static void updateDocumentsRendering();
330 DocLoader* docLoader() { return m_docLoader; }
332 virtual void attach();
333 virtual void detach();
335 RenderArena* renderArena() { return m_renderArena; }
337 AXObjectCache* axObjectCache() const;
339 // to get visually ordered hebrew and arabic pages right
340 void setVisuallyOrdered();
342 void updateSelection();
347 void implicitClose();
348 void cancelParsing();
350 void write(const String& text);
351 void write(const DeprecatedString &text);
352 void writeln(const String& text);
353 void finishParsing();
356 bool wellFormed() const { return m_wellFormed; }
358 DeprecatedString URL() const { return m_url.isEmpty() ? "about:blank" : m_url; }
359 void setURL(const DeprecatedString& url);
361 DeprecatedString baseURL() const { return m_baseURL.isEmpty() ? URL() : m_baseURL; }
362 void setBaseURL(const DeprecatedString& baseURL);
364 String baseTarget() const { return m_baseTarget; }
365 void setBaseTarget(const String& baseTarget) { m_baseTarget = baseTarget; }
367 DeprecatedString completeURL(const DeprecatedString &);
368 String completeURL(const String&);
370 // from cachedObjectClient
371 virtual void setCSSStyleSheet(const String& url, const String& charset, const String& sheetStr);
372 void setUserStyleSheet(const String& sheet);
373 const String& userStyleSheet() const { return m_usersheet; }
374 void setPrintStyleSheet(const String& sheet) { m_printSheet = sheet; }
375 const String& printStyleSheet() const { return m_printSheet; }
377 CSSStyleSheet* elementSheet();
378 virtual Tokenizer* createTokenizer();
379 Tokenizer* tokenizer() { return m_tokenizer; }
381 bool printing() const { return m_printing; }
382 void setPrinting(bool p) { m_printing = p; }
384 enum ParseMode { Compat, AlmostStrict, Strict };
386 virtual void determineParseMode(const String&);
387 void setParseMode(ParseMode m) { pMode = m; }
388 ParseMode parseMode() const { return pMode; }
390 bool inCompatMode() const { return pMode == Compat; }
391 bool inAlmostStrictMode() const { return pMode == AlmostStrict; }
392 bool inStrictMode() const { return pMode == Strict; }
394 enum HTMLMode { Html3, Html4, XHtml };
396 void setHTMLMode(HTMLMode m) { hMode = m; }
397 HTMLMode htmlMode() const { return hMode; }
399 void setParsing(bool);
400 bool parsing() const { return m_bParsing; }
401 int minimumLayoutDelay();
402 bool shouldScheduleLayout();
403 int elapsedTime() const;
405 void setTextColor(const Color& color) { m_textColor = color; }
406 Color textColor() const { return m_textColor; }
408 const Color& linkColor() const { return m_linkColor; }
409 const Color& visitedLinkColor() const { return m_visitedLinkColor; }
410 const Color& activeLinkColor() const { return m_activeLinkColor; }
411 void setLinkColor(const Color& c) { m_linkColor = c; }
412 void setVisitedLinkColor(const Color& c) { m_visitedLinkColor = c; }
413 void setActiveLinkColor(const Color& c) { m_activeLinkColor = c; }
414 void resetLinkColor();
415 void resetVisitedLinkColor();
416 void resetActiveLinkColor();
418 MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const IntPoint&, const PlatformMouseEvent&);
420 virtual bool childTypeAllowed(NodeType);
421 virtual PassRefPtr<Node> cloneNode(bool deep);
423 virtual bool canReplaceChild(Node* newChild, Node* oldChild);
425 StyleSheetList* styleSheets();
427 /* Newly proposed CSS3 mechanism for selecting alternate
428 stylesheets using the DOM. May be subject to change as
431 String preferredStylesheetSet() const;
432 String selectedStylesheetSet() const;
433 void setSelectedStylesheetSet(const String&);
435 bool setFocusedNode(PassRefPtr<Node>);
436 Node* focusedNode() const { return m_focusedNode.get(); }
438 void setHoverNode(PassRefPtr<Node>);
439 Node* hoverNode() const { return m_hoverNode.get(); }
441 void setActiveNode(PassRefPtr<Node>);
442 Node* activeNode() const { return m_activeNode.get(); }
444 void focusedNodeRemoved(Node*);
445 void hoveredNodeDetached(Node*);
446 void activeChainNodeDetached(Node*);
448 // Updates for :target (CSS3 selector).
449 void setCSSTarget(Node*);
450 Node* getCSSTarget() const;
452 void setDocumentChanged(bool);
454 void attachNodeIterator(NodeIterator*);
455 void detachNodeIterator(NodeIterator*);
456 void notifyBeforeNodeRemoval(Node*);
457 DOMWindow* defaultView() const;
458 PassRefPtr<Event> createEvent(const String& eventType, ExceptionCode&);
460 // keep track of what types of event listeners are registered, so we don't
461 // dispatch events unnecessarily
463 DOMSUBTREEMODIFIED_LISTENER = 0x01,
464 DOMNODEINSERTED_LISTENER = 0x02,
465 DOMNODEREMOVED_LISTENER = 0x04,
466 DOMNODEREMOVEDFROMDOCUMENT_LISTENER = 0x08,
467 DOMNODEINSERTEDINTODOCUMENT_LISTENER = 0x10,
468 DOMATTRMODIFIED_LISTENER = 0x20,
469 DOMCHARACTERDATAMODIFIED_LISTENER = 0x40,
470 OVERFLOWCHANGED_LISTENER = 0x80
473 bool hasListenerType(ListenerType listenerType) const { return (m_listenerTypes & listenerType); }
474 void addListenerType(ListenerType listenerType) { m_listenerTypes = m_listenerTypes | listenerType; }
476 CSSStyleDeclaration* getOverrideStyle(Element*, const String& pseudoElt);
478 virtual void defaultEventHandler(Event*);
479 void handleWindowEvent(Event*, bool useCapture);
480 void setHTMLWindowEventListener(const AtomicString &eventType, PassRefPtr<EventListener>);
481 EventListener* getHTMLWindowEventListener(const AtomicString &eventType);
482 void removeHTMLWindowEventListener(const AtomicString &eventType);
484 void setHTMLWindowEventListener(const AtomicString& eventType, Attribute*);
486 void addWindowEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture);
487 void removeWindowEventListener(const AtomicString& eventType, EventListener*, bool useCapture);
488 bool hasWindowEventListener(const AtomicString& eventType);
490 PassRefPtr<EventListener> createHTMLEventListener(const String& functionName, const String& code, Node*);
493 * Searches through the document, starting from fromNode, for the next selectable element that comes after fromNode.
494 * The order followed is as specified in section 17.11.1 of the HTML4 spec, which is elements with tab indexes
495 * first (from lowest to highest), and then elements without tab indexes (in document order).
497 * @param fromNode The node from which to start searching. The node after this will be focused. May be null.
499 * @return The focus node that comes after fromNode
501 * See http://www.w3.org/TR/html4/interact/forms.html#h-17.11.1
503 Node* nextFocusableNode(Node* start, KeyboardEvent*);
506 * Searches through the document, starting from fromNode, for the previous selectable element (that comes _before_)
507 * fromNode. The order followed is as specified in section 17.11.1 of the HTML4 spec, which is elements with tab
508 * indexes first (from lowest to highest), and then elements without tab indexes (in document order).
510 * @param fromNode The node from which to start searching. The node before this will be focused. May be null.
512 * @return The focus node that comes before fromNode
514 * See http://www.w3.org/TR/html4/interact/forms.html#h-17.11.1
516 Node* previousFocusableNode(Node* start, KeyboardEvent*);
518 int nodeAbsIndex(Node*);
519 Node* nodeWithAbsIndex(int absIndex);
522 * Handles a HTTP header equivalent set by a meta tag using <meta http-equiv="..." content="...">. This is called
523 * when a meta tag is encountered during document parsing, and also when a script dynamically changes or adds a meta
524 * tag. This enables scripts to use meta tags to perform refreshes and set expiry dates in addition to them being
525 * specified in a HTML file.
527 * @param equiv The http header name (value of the meta tag's "equiv" attribute)
528 * @param content The header value (value of the meta tag's "content" attribute)
530 void processHttpEquiv(const String& equiv, const String& content);
532 void dispatchImageLoadEventSoon(HTMLImageLoader*);
533 void dispatchImageLoadEventsNow();
534 void removeImage(HTMLImageLoader*);
536 // Returns the owning element in the parent document.
537 // Returns 0 if this is the top level document.
538 Element* ownerElement() const;
540 String referrer() const;
541 String domain() const;
542 void setDomain(const String& newDomain, bool force = false); // not part of the DOM
544 String policyBaseURL() const { return m_policyBaseURL; }
545 void setPolicyBaseURL(const String& s) { m_policyBaseURL = s; }
547 // The following implements the rule from HTML 4 for what valid names are.
548 // To get this right for all the XML cases, we probably have to improve this or move it
549 // and make it sensitive to the type of document.
550 static bool isValidName(const String&);
552 // The following breaks a qualified name into a prefix and a local name.
553 // It also does a validity check, and returns false if the qualified name is invalid
554 // (empty string or invalid characters).
555 static bool parseQualifiedName(const String& qualifiedName, String& prefix, String& localName);
557 void addElementById(const AtomicString& elementId, Element *element);
558 void removeElementById(const AtomicString& elementId, Element *element);
560 void addImageMap(HTMLMapElement*);
561 void removeImageMap(HTMLMapElement*);
562 HTMLMapElement* getImageMap(const String& URL) const;
565 HTMLHeadElement* head();
567 String toString() const;
569 bool execCommand(const String& command, bool userInterface = false, const String& value = String());
570 bool queryCommandEnabled(const String& command);
571 bool queryCommandIndeterm(const String& command);
572 bool queryCommandState(const String& command);
573 bool queryCommandSupported(const String& command);
574 String queryCommandValue(const String& command);
576 void addMarker(Range*, DocumentMarker::MarkerType, String description = String());
577 void addMarker(Node*, DocumentMarker);
578 void copyMarkers(Node *srcNode, unsigned startOffset, int length, Node *dstNode, int delta, DocumentMarker::MarkerType = DocumentMarker::AllMarkers);
579 void removeMarkers(Range*, DocumentMarker::MarkerType = DocumentMarker::AllMarkers);
580 void removeMarkers(Node*, unsigned startOffset, int length, DocumentMarker::MarkerType = DocumentMarker::AllMarkers);
581 void removeMarkers(DocumentMarker::MarkerType = DocumentMarker::AllMarkers);
582 void removeMarkers(Node*);
583 void repaintMarkers(DocumentMarker::MarkerType = DocumentMarker::AllMarkers);
584 void setRenderedRectForMarker(Node*, DocumentMarker, const IntRect&);
585 void invalidateRenderedRectsForMarkersInRect(const IntRect&);
586 void shiftMarkers(Node*, unsigned startOffset, int delta, DocumentMarker::MarkerType = DocumentMarker::AllMarkers);
588 DocumentMarker* markerContainingPoint(const IntPoint&, DocumentMarker::MarkerType = DocumentMarker::AllMarkers);
589 Vector<DocumentMarker> markersForNode(Node*);
590 Vector<IntRect> renderedRectsForMarkers(DocumentMarker::MarkerType = DocumentMarker::AllMarkers);
592 // designMode support
593 enum InheritedBool { off = false, on = true, inherit };
594 void setDesignMode(InheritedBool value);
595 InheritedBool getDesignMode() const;
596 bool inDesignMode() const;
598 Document* parentDocument() const;
599 Document* topDocument() const;
601 int docID() const { return m_docID; }
604 void applyXSLTransform(ProcessingInstruction* pi);
605 void setTransformSource(void* doc);
606 const void* transformSource() { return m_transformSource; }
607 PassRefPtr<Document> transformSourceDocument() { return m_transformSourceDocument; }
608 void setTransformSourceDocument(Document* doc) { m_transformSourceDocument = doc; }
613 XBLBindingManager* bindingManager() const { return m_bindingManager; }
616 void incDOMTreeVersion() { ++m_domtree_version; }
617 unsigned domTreeVersion() const { return m_domtree_version; }
619 void setDocType(PassRefPtr<DocumentType>);
621 void finishedParsing();
624 // XPathEvaluator methods
625 PassRefPtr<XPathExpression> createExpression(const String& expression,
626 XPathNSResolver* resolver,
628 PassRefPtr<XPathNSResolver> createNSResolver(Node *nodeResolver);
629 PassRefPtr<XPathResult> evaluate(const String& expression,
631 XPathNSResolver* resolver,
635 #endif // ENABLE(XPATH)
637 enum PendingSheetLayout { NoLayoutWithPendingSheets, DidLayoutWithPendingSheets, IgnoreLayoutWithPendingSheets };
639 bool didLayoutWithPendingStylesheets() const { return m_pendingSheetLayout == DidLayoutWithPendingSheets; }
642 void setIconURL(const String& iconURL, const String& type);
644 bool isAllowedToLoadLocalResources() const { return m_isAllowedToLoadLocalResources; }
646 void setUseSecureKeyboardEntryWhenActive(bool);
647 bool useSecureKeyboardEntryWhenActive() const;
649 #if USE(LOW_BANDWIDTH_DISPLAY)
650 void setDocLoader(DocLoader* loader) { m_docLoader = loader; }
651 bool inLowBandwidthDisplay() const { return m_inLowBandwidthDisplay; }
652 void setLowBandwidthDisplay(bool lowBandWidth) { m_inLowBandwidthDisplay = lowBandWidth; }
656 CSSStyleSelector* m_styleSelector;
657 bool m_didCalculateStyleSelector;
660 DocLoader* m_docLoader;
661 Tokenizer* m_tokenizer;
663 DeprecatedString m_url;
664 DeprecatedString m_baseURL;
667 RefPtr<DocumentType> m_docType;
668 RefPtr<DOMImplementation> m_implementation;
670 RefPtr<StyleSheet> m_sheet;
674 // Track the number of currently loading top-level stylesheets. Sheets
675 // loaded using the @import directive are not included in this count.
676 // We use this count of pending sheets to detect when we can begin attaching
678 int m_pendingStylesheets;
680 // But sometimes you need to ignore pending stylesheet count to
681 // force an immediate layout when requested by JS.
682 bool m_ignorePendingStylesheets;
684 // If we do ignore the pending stylesheet count, then we need to add a boolean
685 // to track that this happened so that we can do a full repaint when the stylesheets
686 // do eventually load.
687 PendingSheetLayout m_pendingSheetLayout;
689 RefPtr<CSSStyleSheet> m_elemSheet;
698 RefPtr<Node> m_focusedNode;
699 RefPtr<Node> m_hoverNode;
700 RefPtr<Node> m_activeNode;
701 mutable RefPtr<Element> m_documentElement;
703 unsigned m_domtree_version;
705 HashSet<NodeIterator*> m_nodeIterators;
707 unsigned short m_listenerTypes;
708 RefPtr<StyleSheetList> m_styleSheets;
710 typedef DeprecatedValueList<RefPtr<RegisteredEventListener> > RegisteredEventListenerList;
711 RegisteredEventListenerList m_windowEventListeners;
713 typedef HashMap<FormElementKey, Vector<String>, FormElementKeyHash, FormElementKeyHashTraits> FormElementStateMap;
714 ListHashSet<HTMLFormControlElementWithState*> m_formElementsWithState;
715 FormElementStateMap m_stateForNewFormElements;
717 HashSet<Element*> m_didRestorePageCallbackSet;
720 Color m_visitedLinkColor;
721 Color m_activeLinkColor;
723 String m_preferredStylesheetSet;
724 String m_selectedStylesheetSet;
727 bool visuallyOrdered;
730 bool m_inStyleRecalc;
731 bool m_closeAfterStyleRecalc;
732 bool m_usesDescendantRules;
733 bool m_usesSiblingRules;
734 bool m_usesFirstLineRules;
735 bool m_usesFirstLetterRules;
736 bool m_gotoAnchorNeededAfterStylesheetsLoad;
739 bool m_titleSetExplicitly;
740 RefPtr<Element> m_titleElement;
742 RenderArena* m_renderArena;
744 typedef std::pair<Vector<DocumentMarker>, Vector<IntRect> > MarkerMapVectorPair;
745 typedef HashMap<RefPtr<Node>, MarkerMapVectorPair*> MarkerMap;
748 mutable AXObjectCache* m_axObjectCache;
750 DeprecatedPtrList<HTMLImageLoader> m_imageLoadEventDispatchSoonList;
751 DeprecatedPtrList<HTMLImageLoader> m_imageLoadEventDispatchingList;
752 Timer<Document> m_imageLoadEventTimer;
756 bool m_processingLoadEvent;
758 bool m_overMinimumLayoutThreshold;
761 void* m_transformSource;
762 RefPtr<Document> m_transformSourceDocument;
766 XBLBindingManager* m_bindingManager; // The access point through which documents and elements communicate with XBL.
769 typedef HashMap<AtomicStringImpl*, HTMLMapElement*> ImageMapsByName;
770 ImageMapsByName m_imageMapsByName;
772 String m_policyBaseURL;
774 HashSet<Node*> m_disconnectedNodesWithEventListeners;
776 int m_docID; // A unique document identifier used for things like document-specific mapped attributes.
778 String m_xmlEncoding;
780 bool m_xmlStandalone;
784 void setInPageCache(bool flag);
786 // Elements can register themselves for the "didRestoreFromCache()" callback which will be
787 // called if the document is restored from the Page Cache
788 void registerForDidRestoreFromCacheCallback(Element*);
789 void unregisterForDidRestoreFromCacheCallback(Element*);
791 void didRestoreFromCache();
793 void secureFormAdded();
794 void secureFormRemoved();
795 bool hasSecureForm() const;
797 void setShouldCreateRenderers(bool);
798 bool shouldCreateRenderers();
800 void setDecoder(TextResourceDecoder*);
801 TextResourceDecoder* decoder() const { return m_decoder.get(); }
803 UChar backslashAsCurrencySymbol() const;
805 void setDashboardRegionsDirty(bool f) { m_dashboardRegionsDirty = f; }
806 bool dashboardRegionsDirty() const { return m_dashboardRegionsDirty; }
807 bool hasDashboardRegions () const { return m_hasDashboardRegions; }
808 void setHasDashboardRegions (bool f) { m_hasDashboardRegions = f; }
809 const Vector<DashboardRegionValue>& dashboardRegions() const;
810 void setDashboardRegions(const Vector<DashboardRegionValue>&);
812 void removeAllEventListenersFromAllNodes();
814 void registerDisconnectedNodeWithEventListeners(Node*);
815 void unregisterDisconnectedNodeWithEventListeners(Node*);
817 HTMLFormElement::CheckedRadioButtons& checkedRadioButtons() { return m_checkedRadioButtons; }
820 const SVGDocumentExtensions* svgExtensions();
821 SVGDocumentExtensions* accessSVGExtensions();
825 bool shouldBeAllowedToLoadLocalResources() const;
828 void removeAllDisconnectedNodeEventListeners();
829 void imageLoadEventTimerFired(Timer<Document>*);
831 JSEditor* jsEditor();
832 JSEditor* m_jsEditor;
834 mutable String m_domain;
835 RenderObject* m_savedRenderer;
838 RefPtr<TextResourceDecoder> m_decoder;
840 mutable HashMap<AtomicStringImpl*, Element*> m_elementsById;
841 mutable HashCountedSet<AtomicStringImpl*> m_duplicateIds;
843 mutable HashMap<StringImpl*, Element*, CaseInsensitiveHash<StringImpl*> > m_elementsByAccessKey;
845 InheritedBool m_designMode;
847 int m_selfOnlyRefCount;
849 HTMLFormElement::CheckedRadioButtons m_checkedRadioButtons;
851 HTMLCollection::CollectionInfo m_collectionInfo[HTMLCollection::UnnamedCollectionTypes];
852 HashMap<AtomicStringImpl*, HTMLCollection::CollectionInfo> m_nameCollectionInfo[HTMLCollection::CollectionTypes - HTMLCollection::UnnamedCollectionTypes];
855 RefPtr<XPathEvaluator> m_xpathEvaluator;
859 SVGDocumentExtensions* m_svgExtensions;
862 Vector<DashboardRegionValue> m_dashboardRegions;
863 bool m_hasDashboardRegions;
864 bool m_dashboardRegionsDirty;
866 mutable bool m_accessKeyMapValid;
867 bool m_createRenderers;
871 bool m_isAllowedToLoadLocalResources;
873 bool m_useSecureKeyboardEntryWhenActive;
875 #if USE(LOW_BANDWIDTH_DISPLAY)
876 bool m_inLowBandwidthDisplay;