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