]> git.saurik.com Git - iphone-api.git/blob - WebCore/Document.h
Add support for new WinterBoard Settings features.
[iphone-api.git] / WebCore / Document.h
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 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
18 *
19 * You should have received a copy of the GNU Library General Public License
20 * along with this library; see the file COPYING.LIB. If not, write to
21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
23 *
24 */
25
26 #ifndef Document_h
27 #define Document_h
28
29 #include "Attr.h"
30 #include "Color.h"
31 #include "DocumentMarker.h"
32 #include "HTMLCollection.h"
33 #include "HTMLFormElement.h"
34 #include "ScriptExecutionContext.h"
35 #include "StringHash.h"
36 #include "TextResourceDecoder.h"
37 #include "Timer.h"
38 #include <wtf/HashCountedSet.h>
39 #include <wtf/ListHashSet.h>
40
41 #include "RenderStyle.h"
42
43 // FIXME: We should move Mac off of the old Frame-based user stylesheet loading
44 // code and onto the new code in Page. We can't do that until the code in Page
45 // supports non-file: URLs, however.
46 #if PLATFORM(MAC) || PLATFORM(QT)
47 #define FRAME_LOADS_USER_STYLESHEET 1
48 #else
49 #define FRAME_LOADS_USER_STYLESHEET 0
50 #endif
51
52 namespace WebCore {
53
54 class AXObjectCache;
55 class Attr;
56 class Attribute;
57 class CDATASection;
58 class CachedCSSStyleSheet;
59 class CanvasRenderingContext2D;
60 class CharacterData;
61 class CSSStyleDeclaration;
62 class CSSStyleSelector;
63 class CSSStyleSheet;
64 class Comment;
65 class Database;
66 class DOMImplementation;
67 class DOMSelection;
68 class DOMTimer;
69 class DOMWindow;
70 class DatabaseThread;
71 class DocLoader;
72 class DocumentFragment;
73 class DocumentType;
74 class EditingText;
75 class Element;
76 class EntityReference;
77 class Event;
78 class EventListener;
79 class FormControlElementWithState;
80 class Frame;
81 class FrameView;
82 class HTMLCanvasElement;
83 class HTMLDocument;
84 class HTMLElement;
85 class HTMLFormElement;
86 class HTMLHeadElement;
87 class HTMLInputElement;
88 class HTMLMapElement;
89 class ImageLoader;
90 class IntPoint;
91 class JSNode;
92 class MouseEventWithHitTestResults;
93 class NodeFilter;
94 class NodeIterator;
95 class Page;
96 class PlatformMouseEvent;
97 class ProcessingInstruction;
98 class Range;
99 class RegisteredEventListener;
100 class RenderArena;
101 class RenderView;
102 class SecurityOrigin;
103 class Settings;
104 class StyleSheet;
105 class StyleSheetList;
106 class Text;
107 class TextResourceDecoder;
108 class Tokenizer;
109 class TreeWalker;
110 class XMLHttpRequest;
111
112 #if ENABLE(SVG)
113 class SVGDocumentExtensions;
114 #endif
115
116 #if ENABLE(XBL)
117 class XBLBindingManager;
118 #endif
119
120 #if ENABLE(XPATH)
121 class XPathEvaluator;
122 class XPathExpression;
123 class XPathNSResolver;
124 class XPathResult;
125 #endif
126
127 #if ENABLE(DASHBOARD_SUPPORT)
128 struct DashboardRegionValue;
129 #endif
130 struct HitTestRequest;
131
132 #if ENABLE(TOUCH_EVENTS)
133 #include "DocumentIPhoneForward.h"
134 #endif
135
136 typedef int ExceptionCode;
137
138 class CachedImage;
139 extern const int cLayoutScheduleThreshold;
140
141 class FormElementKey {
142 public:
143 FormElementKey(AtomicStringImpl* = 0, AtomicStringImpl* = 0);
144 ~FormElementKey();
145 FormElementKey(const FormElementKey&);
146 FormElementKey& operator=(const FormElementKey&);
147
148 AtomicStringImpl* name() const { return m_name; }
149 AtomicStringImpl* type() const { return m_type; }
150
151 // Hash table deleted values, which are only constructed and never copied or destroyed.
152 FormElementKey(WTF::HashTableDeletedValueType) : m_name(hashTableDeletedValue()) { }
153 bool isHashTableDeletedValue() const { return m_name == hashTableDeletedValue(); }
154
155 private:
156 void ref() const;
157 void deref() const;
158
159 static AtomicStringImpl* hashTableDeletedValue() { return reinterpret_cast<AtomicStringImpl*>(-1); }
160
161 AtomicStringImpl* m_name;
162 AtomicStringImpl* m_type;
163 };
164
165 inline bool operator==(const FormElementKey& a, const FormElementKey& b)
166 {
167 return a.name() == b.name() && a.type() == b.type();
168 }
169
170 struct FormElementKeyHash {
171 static unsigned hash(const FormElementKey&);
172 static bool equal(const FormElementKey& a, const FormElementKey& b) { return a == b; }
173 static const bool safeToCompareToEmptyOrDeleted = true;
174 };
175
176 struct FormElementKeyHashTraits : WTF::GenericHashTraits<FormElementKey> {
177 static void constructDeletedValue(FormElementKey& slot) { new (&slot) FormElementKey(WTF::HashTableDeletedValue); }
178 static bool isDeletedValue(const FormElementKey& value) { return value.isHashTableDeletedValue(); }
179 };
180
181 class TextAutoSizingKey {
182 public:
183 TextAutoSizingKey();
184 TextAutoSizingKey(RenderStyle*, Document*);
185 ~TextAutoSizingKey();
186 TextAutoSizingKey(const TextAutoSizingKey&);
187 TextAutoSizingKey& operator=(const TextAutoSizingKey&);
188 Document* doc() const { return m_doc; }
189 RenderStyle* style() const { return m_style; }
190 inline bool isValidDoc() const { return m_doc && m_doc != deletedKeyDoc(); }
191 inline bool isValidStyle() const { return m_style && m_style != deletedKeyStyle(); }
192 static Document* deletedKeyDoc() { return (Document*) -1; }
193 static RenderStyle* deletedKeyStyle() { return (RenderStyle*) -1; }
194 private:
195 void ref() const;
196 void deref() const;
197 RenderStyle *m_style;
198 Document *m_doc;
199 };
200
201 inline bool operator==(const TextAutoSizingKey& a, const TextAutoSizingKey& b)
202 {
203 if (a.isValidStyle() && b.isValidStyle())
204 return a.style()->equalForTextAutosizing(b.style());
205 return a.style() == b.style();
206 }
207
208 struct TextAutoSizingHash {
209 static unsigned hash(const TextAutoSizingKey&k) { return k.style()->hashForTextAutosizing(); }
210 static bool equal(const TextAutoSizingKey& a, const TextAutoSizingKey& b) { return a == b; }
211 static const bool safeToCompareToEmptyOrDeleted = true;
212 };
213
214 struct TextAutoSizingTraits : WTF::GenericHashTraits<TextAutoSizingKey> {
215 static const bool emptyValueIsZero = true;
216 static void constructDeletedValue(TextAutoSizingKey& slot);
217 static bool isDeletedValue(const TextAutoSizingKey& value);
218 };
219
220 class TextAutoSizingValue : public RefCounted<TextAutoSizingValue>{
221 public:
222 static PassRefPtr<TextAutoSizingValue> create()
223 {
224 return adoptRef(new TextAutoSizingValue());
225 }
226
227 void addNode(Node *node, float size);
228 bool adjustNodeSizes ();
229 int numNodes () const;
230 void reset();
231
232 private:
233 TextAutoSizingValue() { }
234
235 HashSet<RefPtr<Node> > m_autoSizedNodes;
236 };
237
238 struct ViewportArguments
239 {
240 ViewportArguments() :initialScale(-1), minimumScale(-1), maximumScale(-1), width(-1), height(-1), userScalable(-1) { }
241
242 float initialScale;
243 float minimumScale;
244 float maximumScale;
245 float width;
246 float height;
247
248 float userScalable;
249
250 bool hasCustomArgument() const { return initialScale != -1 || minimumScale != -1 || maximumScale != -1 || width != -1 || height != -1 || userScalable != -1; }
251 };
252
253 class Document : public ContainerNode, public ScriptExecutionContext {
254 public:
255 static PassRefPtr<Document> create(Frame* frame)
256 {
257 return new Document(frame, false);
258 }
259 static PassRefPtr<Document> createXHTML(Frame* frame)
260 {
261 return new Document(frame, true);
262 }
263 virtual ~Document();
264
265 virtual bool isDocument() const { return true; }
266
267 using ContainerNode::ref;
268 using ContainerNode::deref;
269 virtual void removedLastRef();
270
271 // Nodes belonging to this document hold "self-only" references -
272 // these are enough to keep the document from being destroyed, but
273 // not enough to keep it from removing its children. This allows a
274 // node that outlives its document to still have a valid document
275 // pointer without introducing reference cycles
276
277 void selfOnlyRef()
278 {
279 ASSERT(!m_deletionHasBegun);
280 ++m_selfOnlyRefCount;
281 }
282 void selfOnlyDeref()
283 {
284 ASSERT(!m_deletionHasBegun);
285 --m_selfOnlyRefCount;
286 if (!m_selfOnlyRefCount && !refCount()) {
287 #ifndef NDEBUG
288 m_deletionHasBegun = true;
289 #endif
290 delete this;
291 }
292 }
293
294 // DOM methods & attributes for Document
295
296 DocumentType* doctype() const { return m_docType.get(); }
297
298 DOMImplementation* implementation() const;
299 virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
300
301 Element* documentElement() const
302 {
303 if (!m_documentElement)
304 cacheDocumentElement();
305 return m_documentElement.get();
306 }
307
308 virtual PassRefPtr<Element> createElement(const AtomicString& tagName, ExceptionCode&);
309 PassRefPtr<DocumentFragment> createDocumentFragment ();
310 PassRefPtr<Text> createTextNode(const String& data);
311 PassRefPtr<Comment> createComment(const String& data);
312 PassRefPtr<CDATASection> createCDATASection(const String& data, ExceptionCode&);
313 PassRefPtr<ProcessingInstruction> createProcessingInstruction(const String& target, const String& data, ExceptionCode&);
314 PassRefPtr<Attr> createAttribute(const String& name, ExceptionCode& ec) { return createAttributeNS(String(), name, ec, true); }
315 PassRefPtr<Attr> createAttributeNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode&, bool shouldIgnoreNamespaceChecks = false);
316 PassRefPtr<EntityReference> createEntityReference(const String& name, ExceptionCode&);
317 PassRefPtr<Node> importNode(Node* importedNode, bool deep, ExceptionCode&);
318 virtual PassRefPtr<Element> createElementNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode&);
319 PassRefPtr<Element> createElement(const QualifiedName&, bool createdByParser, ExceptionCode& ec);
320 Element* getElementById(const AtomicString&) const;
321 bool hasElementWithId(AtomicStringImpl* id) const;
322 bool containsMultipleElementsWithId(const AtomicString& elementId) { return m_duplicateIds.contains(elementId.impl()); }
323
324 Element* elementFromPoint(int x, int y) const;
325 String readyState() const;
326 String inputEncoding() const;
327 String defaultCharset() const;
328
329 String charset() const { return inputEncoding(); }
330 String characterSet() const { return inputEncoding(); }
331
332 void setCharset(const String&);
333
334 String contentLanguage() const { return m_contentLanguage; }
335 void setContentLanguage(const String& lang) { m_contentLanguage = lang; }
336
337 String xmlEncoding() const { return m_xmlEncoding; }
338 String xmlVersion() const { return m_xmlVersion; }
339 bool xmlStandalone() const { return m_xmlStandalone; }
340
341 void setXMLEncoding(const String& encoding) { m_xmlEncoding = encoding; } // read-only property, only to be set from XMLTokenizer
342 void setXMLVersion(const String&, ExceptionCode&);
343 void setXMLStandalone(bool, ExceptionCode&);
344
345 String documentURI() const { return m_documentURI; }
346 void setDocumentURI(const String&);
347
348 virtual KURL baseURI() const;
349
350 PassRefPtr<Node> adoptNode(PassRefPtr<Node> source, ExceptionCode&);
351
352 PassRefPtr<HTMLCollection> images();
353 PassRefPtr<HTMLCollection> embeds();
354 PassRefPtr<HTMLCollection> plugins(); // an alias for embeds() required for the JS DOM bindings.
355 PassRefPtr<HTMLCollection> applets();
356 PassRefPtr<HTMLCollection> links();
357 PassRefPtr<HTMLCollection> forms();
358 PassRefPtr<HTMLCollection> anchors();
359 PassRefPtr<HTMLCollection> all();
360 PassRefPtr<HTMLCollection> objects();
361 PassRefPtr<HTMLCollection> scripts();
362 PassRefPtr<HTMLCollection> windowNamedItems(const String& name);
363 PassRefPtr<HTMLCollection> documentNamedItems(const String& name);
364
365 // Find first anchor with the given name.
366 // First searches for an element with the given ID, but if that fails, then looks
367 // for an anchor with the given name. ID matching is always case sensitive, but
368 // Anchor name matching is case sensitive in strict mode and not case sensitive in
369 // quirks mode for historical compatibility reasons.
370 Element* findAnchor(const String& name);
371
372 HTMLCollection::CollectionInfo* collectionInfo(HTMLCollection::Type type)
373 {
374 ASSERT(type >= HTMLCollection::FirstUnnamedDocumentCachedType);
375 unsigned index = type - HTMLCollection::FirstUnnamedDocumentCachedType;
376 ASSERT(index < HTMLCollection::NumUnnamedDocumentCachedTypes);
377 return &m_collectionInfo[index];
378 }
379
380 HTMLCollection::CollectionInfo* nameCollectionInfo(HTMLCollection::Type, const AtomicString& name);
381
382 // DOM methods overridden from parent classes
383
384 virtual String nodeName() const;
385 virtual NodeType nodeType() const;
386
387 // Other methods (not part of DOM)
388 virtual bool isHTMLDocument() const { return false; }
389 virtual bool isImageDocument() const { return false; }
390 #if ENABLE(SVG)
391 virtual bool isSVGDocument() const { return false; }
392 #endif
393 virtual bool isPluginDocument() const { return false; }
394 virtual bool isMediaDocument() const { return false; }
395 #if ENABLE(WML)
396 virtual bool isWMLDocument() const { return false; }
397 #endif
398
399 CSSStyleSelector* styleSelector() const { return m_styleSelector; }
400
401 Element* getElementByAccessKey(const String& key) const;
402
403 /**
404 * Updates the pending sheet count and then calls updateStyleSelector.
405 */
406 void removePendingSheet();
407
408 /**
409 * This method returns true if all top-level stylesheets have loaded (including
410 * any @imports that they may be loading).
411 */
412 bool haveStylesheetsLoaded() const
413 {
414 return m_pendingStylesheets <= 0 || m_ignorePendingStylesheets
415 #if USE(LOW_BANDWIDTH_DISPLAY)
416 || m_inLowBandwidthDisplay
417 #endif
418 ;
419 }
420
421 /**
422 * Increments the number of pending sheets. The <link> elements
423 * invoke this to add themselves to the loading list.
424 */
425 void addPendingSheet() { m_pendingStylesheets++; }
426
427 void addStyleSheetCandidateNode(Node*, bool createdByParser);
428 void removeStyleSheetCandidateNode(Node*);
429
430 bool gotoAnchorNeededAfterStylesheetsLoad() { return m_gotoAnchorNeededAfterStylesheetsLoad; }
431 void setGotoAnchorNeededAfterStylesheetsLoad(bool b) { m_gotoAnchorNeededAfterStylesheetsLoad = b; }
432
433 /**
434 * Called when one or more stylesheets in the document may have been added, removed or changed.
435 *
436 * Creates a new style selector and assign it to this document. This is done by iterating through all nodes in
437 * document (or those before <BODY> in a HTML document), searching for stylesheets. Stylesheets can be contained in
438 * <LINK>, <STYLE> or <BODY> elements, as well as processing instructions (XML documents only). A list is
439 * constructed from these which is used to create the a new style selector which collates all of the stylesheets
440 * found and is used to calculate the derived styles for all rendering objects.
441 */
442 void updateStyleSelector();
443
444 void recalcStyleSelector();
445
446 bool usesDescendantRules() const { return m_usesDescendantRules; }
447 void setUsesDescendantRules(bool b) { m_usesDescendantRules = b; }
448 bool usesSiblingRules() const { return m_usesSiblingRules; }
449 void setUsesSiblingRules(bool b) { m_usesSiblingRules = b; }
450 bool usesFirstLineRules() const { return m_usesFirstLineRules; }
451 void setUsesFirstLineRules(bool b) { m_usesFirstLineRules = b; }
452 bool usesFirstLetterRules() const { return m_usesFirstLetterRules; }
453 void setUsesFirstLetterRules(bool b) { m_usesFirstLetterRules = b; }
454 bool usesBeforeAfterRules() const { return m_usesBeforeAfterRules; }
455 void setUsesBeforeAfterRules(bool b) { m_usesBeforeAfterRules = b; }
456
457 // Machinery for saving and restoring state when you leave and then go back to a page.
458 void registerFormElementWithState(FormControlElementWithState* e) { m_formElementsWithState.add(e); }
459 void unregisterFormElementWithState(FormControlElementWithState* e) { m_formElementsWithState.remove(e); }
460 Vector<String> formElementsState() const;
461 unsigned formElementsCharacterCount() const;
462 void addAutoCorrectMarker(const Range *range, const String& word, const String& correction);
463 void setStateForNewFormElements(const Vector<String>&);
464 bool hasStateForNewFormElements() const;
465 bool takeStateForFormElement(AtomicStringImpl* name, AtomicStringImpl* type, String& state);
466
467 FrameView* view() const; // can be NULL
468 Frame* frame() const { return m_frame; } // can be NULL
469 Page* page() const; // can be NULL
470 Settings* settings() const; // can be NULL
471
472 PassRefPtr<Range> createRange();
473
474 PassRefPtr<NodeIterator> createNodeIterator(Node* root, unsigned whatToShow,
475 PassRefPtr<NodeFilter>, bool expandEntityReferences, ExceptionCode&);
476
477 PassRefPtr<TreeWalker> createTreeWalker(Node* root, unsigned whatToShow,
478 PassRefPtr<NodeFilter>, bool expandEntityReferences, ExceptionCode&);
479
480 // Special support for editing
481 PassRefPtr<CSSStyleDeclaration> createCSSStyleDeclaration();
482 PassRefPtr<EditingText> createEditingTextNode(const String&);
483
484 virtual void recalcStyle( StyleChange = NoChange );
485 virtual void updateRendering();
486 void updateLayout();
487 void updateLayoutIgnorePendingStylesheets();
488 static void updateDocumentsRendering();
489 DocLoader* docLoader() { return m_docLoader; }
490
491 virtual void attach();
492 virtual void detach();
493 // Override ScriptExecutionContext methods to do additional work
494 void suspendActiveDOMObjects();
495 void resumeActiveDOMObjects();
496 void stopActiveDOMObjects();
497
498 RenderArena* renderArena() { return m_renderArena; }
499
500 RenderView* renderView() const;
501
502 void clearAXObjectCache();
503 AXObjectCache* axObjectCache() const;
504
505 // to get visually ordered hebrew and arabic pages right
506 void setVisuallyOrdered();
507
508 void open(Document* ownerDocument = 0);
509 void implicitOpen();
510 void close();
511 void implicitClose();
512 void cancelParsing();
513
514 void write(const String& text, Document* ownerDocument = 0);
515 void writeln(const String& text, Document* ownerDocument = 0);
516 void finishParsing();
517 void clear();
518
519 bool wellFormed() const { return m_wellFormed; }
520
521 const KURL& url() const { return m_url; }
522 void setURL(const KURL&);
523
524 const KURL& baseURL() const { return m_baseURL; }
525 // Setting the BaseElementURL will change the baseURL.
526 void setBaseElementURL(const KURL&);
527
528 const String& baseTarget() const { return m_baseTarget; }
529 // Setting the BaseElementTarget will change the baseTarget.
530 void setBaseElementTarget(const String& baseTarget) { m_baseTarget = baseTarget; }
531
532 KURL completeURL(const String&) const;
533
534 // from cachedObjectClient
535 virtual void setCSSStyleSheet(const String& url, const String& charset, const CachedCSSStyleSheet*);
536
537 #if FRAME_LOADS_USER_STYLESHEET
538 void setUserStyleSheet(const String& sheet);
539 #endif
540
541 String userStyleSheet() const;
542
543 CSSStyleSheet* elementSheet();
544 CSSStyleSheet* mappedElementSheet();
545 virtual Tokenizer* createTokenizer();
546 Tokenizer* tokenizer() { return m_tokenizer; }
547
548 bool printing() const { return m_printing; }
549 void setPrinting(bool p) { m_printing = p; }
550
551 enum ParseMode { Compat, AlmostStrict, Strict };
552
553 private:
554 virtual void determineParseMode() {}
555
556 public:
557 void setParseMode(ParseMode m) { m_parseMode = m; }
558 ParseMode parseMode() const { return m_parseMode; }
559
560 bool inCompatMode() const { return m_parseMode == Compat; }
561 bool inAlmostStrictMode() const { return m_parseMode == AlmostStrict; }
562 bool inStrictMode() const { return m_parseMode == Strict; }
563
564 void setParsing(bool);
565 bool parsing() const { return m_bParsing; }
566 int minimumLayoutDelay();
567 bool shouldScheduleLayout();
568 int elapsedTime() const;
569
570 void setTextColor(const Color& color) { m_textColor = color; }
571 Color textColor() const { return m_textColor; }
572
573 const Color& linkColor() const { return m_linkColor; }
574 const Color& visitedLinkColor() const { return m_visitedLinkColor; }
575 const Color& activeLinkColor() const { return m_activeLinkColor; }
576 void setLinkColor(const Color& c) { m_linkColor = c; }
577 void setVisitedLinkColor(const Color& c) { m_visitedLinkColor = c; }
578 void setActiveLinkColor(const Color& c) { m_activeLinkColor = c; }
579 void resetLinkColor();
580 void resetVisitedLinkColor();
581 void resetActiveLinkColor();
582
583 MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const IntPoint&, const PlatformMouseEvent&);
584
585 virtual bool childTypeAllowed(NodeType);
586 virtual PassRefPtr<Node> cloneNode(bool deep);
587
588 virtual bool canReplaceChild(Node* newChild, Node* oldChild);
589
590 StyleSheetList* styleSheets();
591
592 /* Newly proposed CSS3 mechanism for selecting alternate
593 stylesheets using the DOM. May be subject to change as
594 spec matures. - dwh
595 */
596 String preferredStylesheetSet() const;
597 String selectedStylesheetSet() const;
598 void setSelectedStylesheetSet(const String&);
599
600 bool setFocusedNode(PassRefPtr<Node>);
601 Node* focusedNode() const { return m_focusedNode.get(); }
602
603 // The m_ignoreAutofocus flag specifies whether or not the document has been changed by the user enough
604 // for WebCore to ignore the autofocus attribute on any form controls
605 bool ignoreAutofocus() const { return m_ignoreAutofocus; };
606 void setIgnoreAutofocus(bool shouldIgnore = true) { m_ignoreAutofocus = shouldIgnore; };
607
608 void setHoverNode(PassRefPtr<Node>);
609 Node* hoverNode() const { return m_hoverNode.get(); }
610
611 void setActiveNode(PassRefPtr<Node>);
612 Node* activeNode() const { return m_activeNode.get(); }
613
614 void focusedNodeRemoved();
615 void removeFocusedNodeOfSubtree(Node*, bool amongChildrenOnly = false);
616 void hoveredNodeDetached(Node*);
617 void activeChainNodeDetached(Node*);
618
619 // Updates for :target (CSS3 selector).
620 void setCSSTarget(Node*);
621 Node* getCSSTarget() const;
622
623 void setDocumentChanged(bool);
624
625 void attachNodeIterator(NodeIterator*);
626 void detachNodeIterator(NodeIterator*);
627
628 void attachRange(Range*);
629 void detachRange(Range*);
630
631 void nodeChildrenChanged(ContainerNode*);
632 void nodeWillBeRemoved(Node*);
633
634 void textInserted(Node*, unsigned offset, unsigned length);
635 void textRemoved(Node*, unsigned offset, unsigned length);
636 void textNodesMerged(Text* oldNode, unsigned offset);
637 void textNodeSplit(Text* oldNode);
638
639 DOMWindow* defaultView() const { return domWindow(); }
640 DOMWindow* domWindow() const;
641
642 PassRefPtr<Event> createEvent(const String& eventType, ExceptionCode&);
643
644 // keep track of what types of event listeners are registered, so we don't
645 // dispatch events unnecessarily
646 enum ListenerType {
647 DOMSUBTREEMODIFIED_LISTENER = 0x01,
648 DOMNODEINSERTED_LISTENER = 0x02,
649 DOMNODEREMOVED_LISTENER = 0x04,
650 DOMNODEREMOVEDFROMDOCUMENT_LISTENER = 0x08,
651 DOMNODEINSERTEDINTODOCUMENT_LISTENER = 0x10,
652 DOMATTRMODIFIED_LISTENER = 0x20,
653 DOMCHARACTERDATAMODIFIED_LISTENER = 0x40,
654 OVERFLOWCHANGED_LISTENER = 0x80,
655 ANIMATIONEND_LISTENER = 0x100,
656 ANIMATIONSTART_LISTENER = 0x200,
657 ANIMATIONITERATION_LISTENER = 0x400,
658 TRANSITIONEND_LISTENER = 0x800
659 };
660
661 bool hasListenerType(ListenerType listenerType) const { return (m_listenerTypes & listenerType); }
662 void addListenerType(ListenerType listenerType) { m_listenerTypes = m_listenerTypes | listenerType; }
663 void addListenerTypeIfNeeded(const AtomicString& eventType);
664
665 CSSStyleDeclaration* getOverrideStyle(Element*, const String& pseudoElt);
666
667 void handleWindowEvent(Event*, bool useCapture);
668 void setWindowInlineEventListenerForType(const AtomicString& eventType, PassRefPtr<EventListener>);
669 EventListener* windowInlineEventListenerForType(const AtomicString& eventType);
670 void removeWindowInlineEventListenerForType(const AtomicString& eventType);
671
672 void setWindowInlineEventListenerForTypeAndAttribute(const AtomicString& eventType, Attribute*);
673
674 void addWindowEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture);
675 void removeWindowEventListener(const AtomicString& eventType, EventListener*, bool useCapture);
676 bool hasWindowEventListener(const AtomicString& eventType);
677
678 void addPendingFrameUnloadEventCount();
679 void removePendingFrameUnloadEventCount();
680 void addPendingFrameBeforeUnloadEventCount();
681 void removePendingFrameBeforeUnloadEventCount();
682
683 PassRefPtr<EventListener> createEventListener(const String& functionName, const String& code, Node*);
684
685 /**
686 * Searches through the document, starting from fromNode, for the next selectable element that comes after fromNode.
687 * The order followed is as specified in section 17.11.1 of the HTML4 spec, which is elements with tab indexes
688 * first (from lowest to highest), and then elements without tab indexes (in document order).
689 *
690 * @param fromNode The node from which to start searching. The node after this will be focused. May be null.
691 *
692 * @return The focus node that comes after fromNode
693 *
694 * See http://www.w3.org/TR/html4/interact/forms.html#h-17.11.1
695 */
696 Node* nextFocusableNode(Node* start, KeyboardEvent*);
697
698 /**
699 * Searches through the document, starting from fromNode, for the previous selectable element (that comes _before_)
700 * fromNode. The order followed is as specified in section 17.11.1 of the HTML4 spec, which is elements with tab
701 * indexes first (from lowest to highest), and then elements without tab indexes (in document order).
702 *
703 * @param fromNode The node from which to start searching. The node before this will be focused. May be null.
704 *
705 * @return The focus node that comes before fromNode
706 *
707 * See http://www.w3.org/TR/html4/interact/forms.html#h-17.11.1
708 */
709 Node* previousFocusableNode(Node* start, KeyboardEvent*);
710
711 int nodeAbsIndex(Node*);
712 Node* nodeWithAbsIndex(int absIndex);
713
714 /**
715 * Handles a HTTP header equivalent set by a meta tag using <meta http-equiv="..." content="...">. This is called
716 * when a meta tag is encountered during document parsing, and also when a script dynamically changes or adds a meta
717 * tag. This enables scripts to use meta tags to perform refreshes and set expiry dates in addition to them being
718 * specified in a HTML file.
719 *
720 * @param equiv The http header name (value of the meta tag's "equiv" attribute)
721 * @param content The header value (value of the meta tag's "content" attribute)
722 */
723 void processHttpEquiv(const String& equiv, const String& content);
724 void processArguments(const String & features, void *userData, void (*argumentsCallback)(const String& keyString, const String& valueString, Document * aDocument, void* userData));
725 void processViewport(const String & features);
726 void processFormatDetection(const String & features);
727
728 void dispatchImageLoadEventSoon(ImageLoader*);
729 void dispatchImageLoadEventsNow();
730 void removeImage(ImageLoader*);
731
732 // Returns the owning element in the parent document.
733 // Returns 0 if this is the top level document.
734 Element* ownerElement() const;
735
736 String title() const { return m_title; }
737 void setTitle(const String&, Element* titleElement = 0);
738 void removeTitle(Element* titleElement);
739
740 String cookie() const;
741 void setCookie(const String&);
742
743 String referrer() const;
744
745 String domain() const;
746 void setDomain(const String& newDomain);
747
748 String lastModified() const;
749
750 const KURL& cookieURL() const { return m_cookieURL; }
751
752 const KURL& policyBaseURL() const { return m_policyBaseURL; }
753 void setPolicyBaseURL(const KURL& url) { m_policyBaseURL = url; }
754
755 // The following implements the rule from HTML 4 for what valid names are.
756 // To get this right for all the XML cases, we probably have to improve this or move it
757 // and make it sensitive to the type of document.
758 static bool isValidName(const String&);
759
760 // The following breaks a qualified name into a prefix and a local name.
761 // It also does a validity check, and returns false if the qualified name
762 // is invalid. It also sets ExceptionCode when name is invalid.
763 static bool parseQualifiedName(const String& qualifiedName, String& prefix, String& localName, ExceptionCode&);
764
765 // Checks to make sure prefix and namespace do not conflict (per DOM Core 3)
766 static bool hasPrefixNamespaceMismatch(const QualifiedName&);
767
768 void addElementById(const AtomicString& elementId, Element *element);
769 void removeElementById(const AtomicString& elementId, Element *element);
770
771 void addImageMap(HTMLMapElement*);
772 void removeImageMap(HTMLMapElement*);
773 HTMLMapElement* getImageMap(const String& url) const;
774
775 HTMLElement* body();
776 void setBody(PassRefPtr<HTMLElement>, ExceptionCode&);
777
778 HTMLHeadElement* head();
779
780 bool execCommand(const String& command, bool userInterface = false, const String& value = String());
781 bool queryCommandEnabled(const String& command);
782 bool queryCommandIndeterm(const String& command);
783 bool queryCommandState(const String& command);
784 bool queryCommandSupported(const String& command);
785 String queryCommandValue(const String& command);
786
787 void addMarker(Range*, DocumentMarker::MarkerType, String description = String());
788 void addMarker(Node*, DocumentMarker);
789 void copyMarkers(Node *srcNode, unsigned startOffset, int length, Node *dstNode, int delta, DocumentMarker::MarkerType = DocumentMarker::AllMarkers);
790 void removeMarkers(Range*, DocumentMarker::MarkerType = DocumentMarker::AllMarkers);
791 void removeMarkers(Node*, unsigned startOffset, int length, DocumentMarker::MarkerType = DocumentMarker::AllMarkers);
792 void removeMarkers(DocumentMarker::MarkerType = DocumentMarker::AllMarkers);
793 void removeMarkers(Node*);
794 void repaintMarkers(DocumentMarker::MarkerType = DocumentMarker::AllMarkers);
795 void setRenderedRectForMarker(Node*, DocumentMarker, const IntRect&);
796 void invalidateRenderedRectsForMarkersInRect(const IntRect&);
797 void shiftMarkers(Node*, unsigned startOffset, int delta, DocumentMarker::MarkerType = DocumentMarker::AllMarkers);
798
799 DocumentMarker* markerContainingPoint(const IntPoint&, DocumentMarker::MarkerType = DocumentMarker::AllMarkers);
800 Vector<DocumentMarker> markersForNode(Node*);
801 Vector<IntRect> renderedRectsForMarkers(DocumentMarker::MarkerType = DocumentMarker::AllMarkers);
802
803 // designMode support
804 enum InheritedBool { off = false, on = true, inherit };
805 void setDesignMode(InheritedBool value);
806 InheritedBool getDesignMode() const;
807 bool inDesignMode() const;
808
809 Document* parentDocument() const;
810 Document* topDocument() const;
811
812 int docID() const { return m_docID; }
813
814 #if ENABLE(XSLT)
815 void applyXSLTransform(ProcessingInstruction* pi);
816 void setTransformSource(void* doc);
817 const void* transformSource() { return m_transformSource; }
818 PassRefPtr<Document> transformSourceDocument() { return m_transformSourceDocument; }
819 void setTransformSourceDocument(Document* doc) { m_transformSourceDocument = doc; }
820 #endif
821
822 #if ENABLE(XBL)
823 // XBL methods
824 XBLBindingManager* bindingManager() const { return m_bindingManager; }
825 #endif
826
827 void incDOMTreeVersion() { ++m_domtree_version; }
828 unsigned domTreeVersion() const { return m_domtree_version; }
829
830 void setDocType(PassRefPtr<DocumentType>);
831
832 virtual void finishedParsing();
833
834 #if ENABLE(XPATH)
835 // XPathEvaluator methods
836 PassRefPtr<XPathExpression> createExpression(const String& expression,
837 XPathNSResolver* resolver,
838 ExceptionCode& ec);
839 PassRefPtr<XPathNSResolver> createNSResolver(Node *nodeResolver);
840 PassRefPtr<XPathResult> evaluate(const String& expression,
841 Node* contextNode,
842 XPathNSResolver* resolver,
843 unsigned short type,
844 XPathResult* result,
845 ExceptionCode& ec);
846 #endif // ENABLE(XPATH)
847
848 enum PendingSheetLayout { NoLayoutWithPendingSheets, DidLayoutWithPendingSheets, IgnoreLayoutWithPendingSheets };
849
850 bool didLayoutWithPendingStylesheets() const { return m_pendingSheetLayout == DidLayoutWithPendingSheets; }
851
852 void setHasNodesWithPlaceholderStyle() { m_hasNodesWithPlaceholderStyle = true; }
853
854 const String& iconURL() const { return m_iconURL; }
855 void setIconURL(const String& iconURL, const String& type);
856
857 void setUseSecureKeyboardEntryWhenActive(bool);
858 bool useSecureKeyboardEntryWhenActive() const;
859
860 #if USE(LOW_BANDWIDTH_DISPLAY)
861 void setDocLoader(DocLoader* loader) { m_docLoader = loader; }
862 bool inLowBandwidthDisplay() const { return m_inLowBandwidthDisplay; }
863 void setLowBandwidthDisplay(bool lowBandWidth) { m_inLowBandwidthDisplay = lowBandWidth; }
864 #endif
865
866 void addNodeListCache() { ++m_numNodeListCaches; }
867 void removeNodeListCache() { ASSERT(m_numNodeListCaches > 0); --m_numNodeListCaches; }
868 bool hasNodeListCaches() const { return m_numNodeListCaches; }
869
870 void updateFocusAppearanceSoon();
871 void cancelFocusAppearanceUpdate();
872
873 // FF method for accessing the selection added for compatability.
874 DOMSelection* getSelection() const;
875
876 // Extension for manipulating canvas drawing contexts for use in CSS
877 CanvasRenderingContext2D* getCSSCanvasContext(const String& type, const String& name, int width, int height);
878 HTMLCanvasElement* getCSSCanvasElement(const String& name);
879
880 bool isDNSPrefetchEnabled() const { return m_isDNSPrefetchEnabled; }
881 void initDNSPrefetch();
882 void parseDNSPrefetchControlHeader(const String&);
883
884 virtual void reportException(const String& errorMessage, int lineNumber, const String& sourceURL);
885 virtual void addMessage(MessageDestination, MessageSource, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL);
886 virtual void resourceRetrievedByXMLHttpRequest(unsigned long identifier, const ScriptString& sourceString);
887 virtual void postTask(PassRefPtr<Task>); // Executes the task on context's thread asynchronously.
888
889 void addTimeout(int timeoutId, DOMTimer*);
890 void removeTimeout(int timeoutId);
891 DOMTimer* findTimeout(int timeoutId);
892
893 #if ENABLE(TOUCH_EVENTS)
894 #include "DocumentIPhone.h"
895 #endif
896
897 protected:
898 Document(Frame*, bool isXHTML);
899
900 private:
901 virtual void refScriptExecutionContext() { ref(); }
902 virtual void derefScriptExecutionContext() { deref(); }
903
904 virtual const KURL& virtualURL() const; // Same as url(), but needed for ScriptExecutionContext to implement it without a performance loss for direct calls.
905 virtual KURL virtualCompleteURL(const String&) const; // Same as completeURL() for the same reason as above.
906
907 CSSStyleSelector* m_styleSelector;
908 bool m_didCalculateStyleSelector;
909
910 Frame* m_frame;
911 DocLoader* m_docLoader;
912 Tokenizer* m_tokenizer;
913 bool m_wellFormed;
914
915 // Document URLs.
916 KURL m_url; // Document.URL: The URL from which this document was retrieved.
917 KURL m_baseURL; // Node.baseURI: The URL to use when resolving relative URLs.
918 KURL m_baseElementURL; // The URL set by the <base> element.
919 KURL m_cookieURL; // The URL to use for cookie access.
920 KURL m_policyBaseURL; // The policy URL for third-party cookie blocking.
921
922 // Document.documentURI:
923 // Although URL-like, Document.documentURI can actually be set to any
924 // string by content. Document.documentURI affects m_baseURL unless the
925 // document contains a <base> element, in which case the <base> element
926 // takes precedence.
927 String m_documentURI;
928
929 String m_baseTarget;
930
931 RefPtr<DocumentType> m_docType;
932 mutable RefPtr<DOMImplementation> m_implementation;
933
934 RefPtr<StyleSheet> m_sheet;
935 #if FRAME_LOADS_USER_STYLESHEET
936 String m_usersheet;
937 #endif
938
939 // Track the number of currently loading top-level stylesheets. Sheets
940 // loaded using the @import directive are not included in this count.
941 // We use this count of pending sheets to detect when we can begin attaching
942 // elements.
943 int m_pendingStylesheets;
944
945 // But sometimes you need to ignore pending stylesheet count to
946 // force an immediate layout when requested by JS.
947 bool m_ignorePendingStylesheets;
948
949 // If we do ignore the pending stylesheet count, then we need to add a boolean
950 // to track that this happened so that we can do a full repaint when the stylesheets
951 // do eventually load.
952 PendingSheetLayout m_pendingSheetLayout;
953
954 bool m_hasNodesWithPlaceholderStyle;
955
956 RefPtr<CSSStyleSheet> m_elemSheet;
957 RefPtr<CSSStyleSheet> m_mappedElementSheet;
958
959 bool m_printing;
960
961 bool m_ignoreAutofocus;
962
963 ParseMode m_parseMode;
964
965 Color m_textColor;
966
967 RefPtr<Node> m_focusedNode;
968 RefPtr<Node> m_hoverNode;
969 RefPtr<Node> m_activeNode;
970 mutable RefPtr<Element> m_documentElement;
971
972 unsigned m_domtree_version;
973
974 HashSet<NodeIterator*> m_nodeIterators;
975 HashSet<Range*> m_ranges;
976
977 unsigned short m_listenerTypes;
978
979 RefPtr<StyleSheetList> m_styleSheets; // All of the stylesheets that are currently in effect for our media type and stylesheet set.
980 ListHashSet<Node*> m_styleSheetCandidateNodes; // All of the nodes that could potentially provide stylesheets to the document (<link>, <style>, <?xml-stylesheet>)
981
982 RegisteredEventListenerVector m_windowEventListeners;
983
984 typedef HashMap<FormElementKey, Vector<String>, FormElementKeyHash, FormElementKeyHashTraits> FormElementStateMap;
985 ListHashSet<FormControlElementWithState*> m_formElementsWithState;
986 FormElementStateMap m_stateForNewFormElements;
987
988 Color m_linkColor;
989 Color m_visitedLinkColor;
990 Color m_activeLinkColor;
991
992 String m_preferredStylesheetSet;
993 String m_selectedStylesheetSet;
994
995 bool m_loadingSheet;
996 bool visuallyOrdered;
997 bool m_bParsing;
998 bool m_docChanged;
999 bool m_inStyleRecalc;
1000 bool m_closeAfterStyleRecalc;
1001 bool m_usesDescendantRules;
1002 bool m_usesSiblingRules;
1003 bool m_usesFirstLineRules;
1004 bool m_usesFirstLetterRules;
1005 bool m_usesBeforeAfterRules;
1006 bool m_gotoAnchorNeededAfterStylesheetsLoad;
1007 bool m_isDNSPrefetchEnabled;
1008 bool m_haveExplicitlyDisabledDNSPrefetch;
1009 bool m_frameElementsShouldIgnoreScrolling;
1010
1011 String m_title;
1012 bool m_titleSetExplicitly;
1013 RefPtr<Element> m_titleElement;
1014
1015 RenderArena* m_renderArena;
1016
1017 typedef std::pair<Vector<DocumentMarker>, Vector<IntRect> > MarkerMapVectorPair;
1018 typedef HashMap<RefPtr<Node>, MarkerMapVectorPair*> MarkerMap;
1019 MarkerMap m_markers;
1020
1021 mutable AXObjectCache* m_axObjectCache;
1022
1023 Vector<ImageLoader*> m_imageLoadEventDispatchSoonList;
1024 Vector<ImageLoader*> m_imageLoadEventDispatchingList;
1025 Timer<Document> m_imageLoadEventTimer;
1026
1027 Timer<Document> m_updateFocusAppearanceTimer;
1028
1029 Node* m_cssTarget;
1030
1031 bool m_processingLoadEvent;
1032 double m_startTime;
1033 bool m_overMinimumLayoutThreshold;
1034
1035 #if ENABLE(XSLT)
1036 void* m_transformSource;
1037 RefPtr<Document> m_transformSourceDocument;
1038 #endif
1039
1040 #if ENABLE(XBL)
1041 XBLBindingManager* m_bindingManager; // The access point through which documents and elements communicate with XBL.
1042 #endif
1043
1044 typedef HashMap<AtomicStringImpl*, HTMLMapElement*> ImageMapsByName;
1045 ImageMapsByName m_imageMapsByName;
1046
1047 HashSet<Node*> m_disconnectedNodesWithEventListeners;
1048
1049 int m_docID; // A unique document identifier used for things like document-specific mapped attributes.
1050
1051 String m_xmlEncoding;
1052 String m_xmlVersion;
1053 bool m_xmlStandalone;
1054
1055 String m_contentLanguage;
1056
1057 public:
1058 bool inPageCache() const { return m_inPageCache; }
1059 void setInPageCache(bool flag);
1060
1061 // Elements can register themselves for the "documentWillBecomeInactive()" and
1062 // "documentDidBecomeActive()" callbacks
1063 void registerForDocumentActivationCallbacks(Element*);
1064 void unregisterForDocumentActivationCallbacks(Element*);
1065 void documentWillBecomeInactive();
1066 void documentDidBecomeActive();
1067
1068 void registerForMediaVolumeCallbacks(Element*);
1069 void unregisterForMediaVolumeCallbacks(Element*);
1070 void mediaVolumeDidChange();
1071
1072 void setShouldCreateRenderers(bool);
1073 bool shouldCreateRenderers();
1074
1075 void setDecoder(PassRefPtr<TextResourceDecoder>);
1076 TextResourceDecoder* decoder() const { return m_decoder.get(); }
1077
1078 String displayStringModifiedByEncoding(const String& str) const {
1079 if (m_decoder)
1080 return m_decoder->encoding().displayString(str.impl());
1081 return str;
1082 }
1083 PassRefPtr<StringImpl> displayStringModifiedByEncoding(PassRefPtr<StringImpl> str) const {
1084 if (m_decoder)
1085 return m_decoder->encoding().displayString(str);
1086 return str;
1087 }
1088 void displayBufferModifiedByEncoding(UChar* buffer, unsigned len) const {
1089 if (m_decoder)
1090 m_decoder->encoding().displayBuffer(buffer, len);
1091 }
1092
1093 // Quirk for the benefit of Apple's Dictionary application.
1094 void setFrameElementsShouldIgnoreScrolling(bool ignore) { m_frameElementsShouldIgnoreScrolling = ignore; }
1095 bool frameElementsShouldIgnoreScrolling() const { return m_frameElementsShouldIgnoreScrolling; }
1096
1097 #if ENABLE(DASHBOARD_SUPPORT)
1098 void setDashboardRegionsDirty(bool f) { m_dashboardRegionsDirty = f; }
1099 bool dashboardRegionsDirty() const { return m_dashboardRegionsDirty; }
1100 bool hasDashboardRegions () const { return m_hasDashboardRegions; }
1101 void setHasDashboardRegions (bool f) { m_hasDashboardRegions = f; }
1102 const Vector<DashboardRegionValue>& dashboardRegions() const;
1103 void setDashboardRegions(const Vector<DashboardRegionValue>&);
1104 #endif
1105
1106 void removeAllEventListenersFromAllNodes();
1107
1108 void registerDisconnectedNodeWithEventListeners(Node*);
1109 void unregisterDisconnectedNodeWithEventListeners(Node*);
1110
1111 HTMLFormElement::CheckedRadioButtons& checkedRadioButtons() { return m_checkedRadioButtons; }
1112
1113 #if ENABLE(SVG)
1114 const SVGDocumentExtensions* svgExtensions();
1115 SVGDocumentExtensions* accessSVGExtensions();
1116 #endif
1117
1118 void initSecurityContext();
1119
1120 // Explicitly override the security origin for this document.
1121 // Note: It is dangerous to change the security origin of a document
1122 // that already contains content.
1123 void setSecurityOrigin(SecurityOrigin*);
1124
1125 bool processingLoadEvent() const { return m_processingLoadEvent; }
1126
1127 #if ENABLE(DATABASE)
1128 void addOpenDatabase(Database*);
1129 void removeOpenDatabase(Database*);
1130 DatabaseThread* databaseThread(); // Creates the thread as needed, but not if it has been already terminated.
1131 void setHasOpenDatabases() { m_hasOpenDatabases = true; }
1132 bool hasOpenDatabases() { return m_hasOpenDatabases; }
1133 void stopDatabases();
1134 #endif
1135
1136 void setUsingGeolocation(bool f) { m_usingGeolocation = f; }
1137 bool usingGeolocation() const { return m_usingGeolocation; };
1138
1139 #if ENABLE(WML)
1140 void resetWMLPageState();
1141 #endif
1142
1143 protected:
1144 void clearXMLVersion() { m_xmlVersion = String(); }
1145
1146 private:
1147 void updateTitle();
1148 void removeAllDisconnectedNodeEventListeners();
1149 void imageLoadEventTimerFired(Timer<Document>*);
1150 void updateFocusAppearanceTimerFired(Timer<Document>*);
1151 void updateBaseURL();
1152
1153 void cacheDocumentElement() const;
1154
1155 RenderObject* m_savedRenderer;
1156 int m_secureForms;
1157
1158 RefPtr<TextResourceDecoder> m_decoder;
1159
1160 // We maintain the invariant that m_duplicateIds is the count of all elements with a given ID
1161 // excluding the one referenced in m_elementsById, if any. This means it one less than the total count
1162 // when the first node with a given ID is cached, otherwise the same as the total count.
1163 mutable HashMap<AtomicStringImpl*, Element*> m_elementsById;
1164 mutable HashCountedSet<AtomicStringImpl*> m_duplicateIds;
1165
1166 mutable HashMap<StringImpl*, Element*, CaseFoldingHash> m_elementsByAccessKey;
1167
1168 InheritedBool m_designMode;
1169
1170 int m_selfOnlyRefCount;
1171
1172 HTMLFormElement::CheckedRadioButtons m_checkedRadioButtons;
1173
1174 typedef HashMap<AtomicStringImpl*, HTMLCollection::CollectionInfo*> NamedCollectionMap;
1175 HTMLCollection::CollectionInfo m_collectionInfo[HTMLCollection::NumUnnamedDocumentCachedTypes];
1176 NamedCollectionMap m_nameCollectionInfo[HTMLCollection::NumNamedDocumentCachedTypes];
1177
1178 #if ENABLE(XPATH)
1179 RefPtr<XPathEvaluator> m_xpathEvaluator;
1180 #endif
1181
1182 #if ENABLE(SVG)
1183 OwnPtr<SVGDocumentExtensions> m_svgExtensions;
1184 #endif
1185
1186 #if ENABLE(DASHBOARD_SUPPORT)
1187 Vector<DashboardRegionValue> m_dashboardRegions;
1188 bool m_hasDashboardRegions;
1189 bool m_dashboardRegionsDirty;
1190 #endif
1191
1192 HashMap<String, RefPtr<HTMLCanvasElement> > m_cssCanvasElements;
1193
1194 mutable bool m_accessKeyMapValid;
1195 bool m_createRenderers;
1196 bool m_inPageCache;
1197 String m_iconURL;
1198
1199 HashSet<Element*> m_documentActivationCallbackElements;
1200 HashSet<Element*> m_mediaVolumeCallbackElements;
1201
1202 bool m_useSecureKeyboardEntryWhenActive;
1203
1204 bool m_isXHTML;
1205
1206 unsigned m_numNodeListCaches;
1207
1208 public:
1209 typedef HashMap<WebCore::Node*, JSNode*> JSWrapperCache;
1210 JSWrapperCache& wrapperCache() { return m_wrapperCache; }
1211 private:
1212 JSWrapperCache m_wrapperCache;
1213
1214 #if ENABLE(DATABASE)
1215 RefPtr<DatabaseThread> m_databaseThread;
1216 bool m_hasOpenDatabases; // This never changes back to false, even as the database thread is closed.
1217 typedef HashSet<Database*> DatabaseSet;
1218 OwnPtr<DatabaseSet> m_openDatabaseSet;
1219 #endif
1220
1221 bool m_usingGeolocation;
1222
1223 #if USE(LOW_BANDWIDTH_DISPLAY)
1224 bool m_inLowBandwidthDisplay;
1225 #endif
1226
1227 typedef HashMap<int, DOMTimer*> TimeoutsMap;
1228 TimeoutsMap m_timeouts;
1229
1230 public:
1231 void addAutoSizingNode (Node *node, float size);
1232 void validateAutoSizingNodes ();
1233 void resetAutoSizingNodes();
1234
1235 void incrementScrollEventListenersCount();
1236 void decrementScrollEventListenersCount();
1237
1238 void incrementTotalImageDataSize(CachedImage* image);
1239 void decrementTotalImageDataSize(CachedImage* image);
1240 unsigned long totalImageDataSize();
1241
1242 void incrementAnimatedImageDataCount(unsigned count);
1243 unsigned long animatedImageDataCount();
1244 private:
1245 typedef HashMap<TextAutoSizingKey, RefPtr<TextAutoSizingValue>, TextAutoSizingHash, TextAutoSizingTraits> TextAutoSizingMap;
1246 TextAutoSizingMap m_textAutoSizedNodes;
1247
1248 unsigned m_scrollEventListenerCount;
1249
1250 HashCountedSet<CachedImage*> m_documentImages;
1251
1252 unsigned long m_totalImageDataSize;
1253 unsigned long m_animatedImageDataCount;
1254 };
1255
1256 inline bool Document::hasElementWithId(AtomicStringImpl* id) const
1257 {
1258 ASSERT(id);
1259 return m_elementsById.contains(id) || m_duplicateIds.contains(id);
1260 }
1261
1262 inline bool Node::isDocumentNode() const
1263 {
1264 return this == m_document.get();
1265 }
1266
1267 } // namespace WebCore
1268
1269 #endif // Document_h