diff options
Diffstat (limited to 'WebCore/dom/Document.h')
-rw-r--r-- | WebCore/dom/Document.h | 339 |
1 files changed, 186 insertions, 153 deletions
diff --git a/WebCore/dom/Document.h b/WebCore/dom/Document.h index fc4dc7e..fc2eea0 100644 --- a/WebCore/dom/Document.h +++ b/WebCore/dom/Document.h @@ -33,18 +33,12 @@ #include "CollectionType.h" #include "Color.h" #include "DocumentMarker.h" +#include "Page.h" #include "ScriptExecutionContext.h" #include "Timer.h" #include <wtf/HashCountedSet.h> - -// FIXME: We should move Mac off of the old Frame-based user stylesheet loading -// code and onto the new code in Page. We can't do that until the code in Page -// supports non-file: URLs, however. -#if PLATFORM(MAC) || PLATFORM(QT) -#define FRAME_LOADS_USER_STYLESHEET 1 -#else -#define FRAME_LOADS_USER_STYLESHEET 0 -#endif +#include <wtf/OwnPtr.h> +#include <wtf/PassOwnPtr.h> namespace WebCore { @@ -53,7 +47,7 @@ namespace WebCore { class CDATASection; class CachedCSSStyleSheet; class CachedScript; - class CanvasRenderingContext2D; + class CanvasRenderingContext; class CharacterData; class CSSStyleDeclaration; class CSSStyleSelector; @@ -83,12 +77,12 @@ namespace WebCore { class HTMLHeadElement; class HTMLInputElement; class HTMLMapElement; + class InspectorTimelineAgent; class IntPoint; class JSNode; class MouseEventWithHitTestResults; class NodeFilter; class NodeIterator; - class Page; class PlatformMouseEvent; class ProcessingInstruction; class Range; @@ -111,6 +105,10 @@ namespace WebCore { class SVGDocumentExtensions; #endif +#if ENABLE(XSLT) + class TransformSource; +#endif + #if ENABLE(XBL) class XBLBindingManager; #endif @@ -172,19 +170,16 @@ class Document : public ContainerNode, public ScriptExecutionContext { public: static PassRefPtr<Document> create(Frame* frame) { - return new Document(frame, false); + return adoptRef(new Document(frame, false)); } static PassRefPtr<Document> createXHTML(Frame* frame) { - return new Document(frame, true); + return adoptRef(new Document(frame, true)); } virtual ~Document(); - virtual bool isDocument() const { return true; } - using ContainerNode::ref; using ContainerNode::deref; - virtual void removedLastRef(); // Nodes belonging to this document hold "self-only" references - // these are enough to keep the document from being destroyed, but @@ -211,10 +206,52 @@ public: // DOM methods & attributes for Document + DEFINE_ATTRIBUTE_EVENT_LISTENER(abort); + DEFINE_ATTRIBUTE_EVENT_LISTENER(change); + DEFINE_ATTRIBUTE_EVENT_LISTENER(click); + DEFINE_ATTRIBUTE_EVENT_LISTENER(contextmenu); + DEFINE_ATTRIBUTE_EVENT_LISTENER(dblclick); + DEFINE_ATTRIBUTE_EVENT_LISTENER(dragenter); + DEFINE_ATTRIBUTE_EVENT_LISTENER(dragover); + DEFINE_ATTRIBUTE_EVENT_LISTENER(dragleave); + DEFINE_ATTRIBUTE_EVENT_LISTENER(drop); + DEFINE_ATTRIBUTE_EVENT_LISTENER(dragstart); + DEFINE_ATTRIBUTE_EVENT_LISTENER(drag); + DEFINE_ATTRIBUTE_EVENT_LISTENER(dragend); + DEFINE_ATTRIBUTE_EVENT_LISTENER(input); + DEFINE_ATTRIBUTE_EVENT_LISTENER(invalid); + DEFINE_ATTRIBUTE_EVENT_LISTENER(keydown); + DEFINE_ATTRIBUTE_EVENT_LISTENER(keypress); + DEFINE_ATTRIBUTE_EVENT_LISTENER(keyup); + DEFINE_ATTRIBUTE_EVENT_LISTENER(mousedown); + DEFINE_ATTRIBUTE_EVENT_LISTENER(mousemove); + DEFINE_ATTRIBUTE_EVENT_LISTENER(mouseout); + DEFINE_ATTRIBUTE_EVENT_LISTENER(mouseover); + DEFINE_ATTRIBUTE_EVENT_LISTENER(mouseup); + DEFINE_ATTRIBUTE_EVENT_LISTENER(mousewheel); + DEFINE_ATTRIBUTE_EVENT_LISTENER(scroll); + DEFINE_ATTRIBUTE_EVENT_LISTENER(select); + DEFINE_ATTRIBUTE_EVENT_LISTENER(submit); + + DEFINE_ATTRIBUTE_EVENT_LISTENER(blur); + DEFINE_ATTRIBUTE_EVENT_LISTENER(error); + DEFINE_ATTRIBUTE_EVENT_LISTENER(focus); + DEFINE_ATTRIBUTE_EVENT_LISTENER(load); + + // WebKit extensions + DEFINE_ATTRIBUTE_EVENT_LISTENER(beforecut); + DEFINE_ATTRIBUTE_EVENT_LISTENER(cut); + DEFINE_ATTRIBUTE_EVENT_LISTENER(beforecopy); + DEFINE_ATTRIBUTE_EVENT_LISTENER(copy); + DEFINE_ATTRIBUTE_EVENT_LISTENER(beforepaste); + DEFINE_ATTRIBUTE_EVENT_LISTENER(paste); + DEFINE_ATTRIBUTE_EVENT_LISTENER(reset); + DEFINE_ATTRIBUTE_EVENT_LISTENER(search); + DEFINE_ATTRIBUTE_EVENT_LISTENER(selectstart); + DocumentType* doctype() const { return m_docType.get(); } DOMImplementation* implementation() const; - virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); Element* documentElement() const { @@ -240,6 +277,8 @@ public: bool containsMultipleElementsWithId(const AtomicString& elementId) { return m_duplicateIds.contains(elementId.impl()); } Element* elementFromPoint(int x, int y) const; + PassRefPtr<Range> caretRangeFromPoint(int x, int y); + String readyState() const; String defaultCharset() const; @@ -299,11 +338,6 @@ public: CollectionCache* nameCollectionInfo(CollectionType, const AtomicString& name); - // DOM methods overridden from parent classes - - virtual String nodeName() const; - virtual NodeType nodeType() const; - // Other methods (not part of DOM) virtual bool isHTMLDocument() const { return false; } virtual bool isImageDocument() const { return false; } @@ -392,6 +426,9 @@ public: Frame* frame() const { return m_frame; } // can be NULL Page* page() const; // can be NULL Settings* settings() const; // can be NULL +#if ENABLE(INSPECTOR) + InspectorTimelineAgent* inspectorTimelineAgent() const; // can be NULL +#endif PassRefPtr<Range> createRange(); @@ -455,17 +492,15 @@ public: virtual String userAgent(const KURL&) const; - // from cachedObjectClient - virtual void setCSSStyleSheet(const String& url, const String& charset, const CachedCSSStyleSheet*); - -#if FRAME_LOADS_USER_STYLESHEET - void setUserStyleSheet(const String& sheet); -#endif + CSSStyleSheet* pageUserSheet(); + void clearPageUserSheet(); - String userStyleSheet() const; + const Vector<RefPtr<CSSStyleSheet> >* pageGroupUserSheets() const; + void clearPageGroupUserSheets(); CSSStyleSheet* elementSheet(); CSSStyleSheet* mappedElementSheet(); + virtual Tokenizer* createTokenizer(); Tokenizer* tokenizer() { return m_tokenizer; } @@ -474,10 +509,6 @@ public: enum ParseMode { Compat, AlmostStrict, Strict }; -private: - virtual void determineParseMode() {} - -public: void setParseMode(ParseMode m) { m_parseMode = m; } ParseMode parseMode() const { return m_parseMode; } @@ -506,11 +537,6 @@ public: MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const IntPoint&, const PlatformMouseEvent&); - virtual bool childTypeAllowed(NodeType); - virtual PassRefPtr<Node> cloneNode(bool deep); - - virtual bool canReplaceChild(Node* newChild, Node* oldChild); - StyleSheetList* styleSheets(); /* Newly proposed CSS3 mechanism for selecting alternate @@ -570,9 +596,8 @@ public: // Helper functions for forwarding DOMWindow event related tasks to the DOMWindow if it exists. void setWindowAttributeEventListener(const AtomicString& eventType, PassRefPtr<EventListener>); EventListener* getWindowAttributeEventListener(const AtomicString& eventType); - void dispatchWindowEvent(PassRefPtr<Event>); - void dispatchWindowEvent(const AtomicString& eventType, bool canBubbleArg, bool cancelableArg); - void dispatchLoadEvent(); + void dispatchWindowEvent(PassRefPtr<Event>, PassRefPtr<EventTarget> = 0); + void dispatchWindowLoadEvent(); PassRefPtr<Event> createEvent(const String& eventType, ExceptionCode&); @@ -661,7 +686,7 @@ public: String referrer() const; String domain() const; - void setDomain(const String& newDomain); + void setDomain(const String& newDomain, ExceptionCode&); String lastModified() const; @@ -735,10 +760,11 @@ public: #if ENABLE(XSLT) void applyXSLTransform(ProcessingInstruction* pi); - void setTransformSource(void* doc); - const void* transformSource() { return m_transformSource; } PassRefPtr<Document> transformSourceDocument() { return m_transformSourceDocument; } void setTransformSourceDocument(Document* doc) { m_transformSourceDocument = doc; } + + void setTransformSource(PassOwnPtr<TransformSource>); + TransformSource* transformSource() const { return m_transformSource.get(); } #endif #if ENABLE(XBL) @@ -751,8 +777,6 @@ public: void setDocType(PassRefPtr<DocumentType>); - virtual void finishedParsing(); - #if ENABLE(XPATH) // XPathEvaluator methods PassRefPtr<XPathExpression> createExpression(const String& expression, @@ -785,7 +809,7 @@ public: void updateFocusAppearanceSoon(); void cancelFocusAppearanceUpdate(); - + #ifdef ANDROID_MOBILE void setExtraLayoutDelay(int delay) { mExtraLayoutDelay = delay; } int extraLayoutDelay() { return mExtraLayoutDelay; } @@ -795,11 +819,10 @@ public: DOMSelection* getSelection() const; // Extension for manipulating canvas drawing contexts for use in CSS - CanvasRenderingContext2D* getCSSCanvasContext(const String& type, const String& name, int width, int height); + CanvasRenderingContext* getCSSCanvasContext(const String& type, const String& name, int width, int height); HTMLCanvasElement* getCSSCanvasElement(const String& name); bool isDNSPrefetchEnabled() const { return m_isDNSPrefetchEnabled; } - void initDNSPrefetch(); void parseDNSPrefetchControlHeader(const String&); virtual void reportException(const String& errorMessage, int lineNumber, const String& sourceURL); @@ -808,10 +831,92 @@ public: virtual void scriptImported(unsigned long, const String&); virtual void postTask(PassRefPtr<Task>); // Executes the task on context's thread asynchronously. + typedef HashMap<WebCore::Node*, JSNode*> JSWrapperCache; + JSWrapperCache& wrapperCache() { return m_wrapperCache; } + + virtual void finishedParsing(); + + bool inPageCache() const { return m_inPageCache; } + void setInPageCache(bool flag); + + // Elements can register themselves for the "documentWillBecomeInactive()" and + // "documentDidBecomeActive()" callbacks + void registerForDocumentActivationCallbacks(Element*); + void unregisterForDocumentActivationCallbacks(Element*); + void documentWillBecomeInactive(); + void documentDidBecomeActive(); + + void registerForMediaVolumeCallbacks(Element*); + void unregisterForMediaVolumeCallbacks(Element*); + void mediaVolumeDidChange(); + + void setShouldCreateRenderers(bool); + bool shouldCreateRenderers(); + + void setDecoder(PassRefPtr<TextResourceDecoder>); + TextResourceDecoder* decoder() const { return m_decoder.get(); } + + String displayStringModifiedByEncoding(const String&) const; + PassRefPtr<StringImpl> displayStringModifiedByEncoding(PassRefPtr<StringImpl>) const; + void displayBufferModifiedByEncoding(UChar* buffer, unsigned len) const; + + // Quirk for the benefit of Apple's Dictionary application. + void setFrameElementsShouldIgnoreScrolling(bool ignore) { m_frameElementsShouldIgnoreScrolling = ignore; } + bool frameElementsShouldIgnoreScrolling() const { return m_frameElementsShouldIgnoreScrolling; } + +#if ENABLE(DASHBOARD_SUPPORT) + void setDashboardRegionsDirty(bool f) { m_dashboardRegionsDirty = f; } + bool dashboardRegionsDirty() const { return m_dashboardRegionsDirty; } + bool hasDashboardRegions () const { return m_hasDashboardRegions; } + void setHasDashboardRegions(bool f) { m_hasDashboardRegions = f; } + const Vector<DashboardRegionValue>& dashboardRegions() const; + void setDashboardRegions(const Vector<DashboardRegionValue>&); +#endif + + virtual void removeAllEventListeners(); + + CheckedRadioButtons& checkedRadioButtons() { return m_checkedRadioButtons; } + +#if ENABLE(SVG) + const SVGDocumentExtensions* svgExtensions(); + SVGDocumentExtensions* accessSVGExtensions(); +#endif + + void initSecurityContext(); + + // Explicitly override the security origin for this document. + // Note: It is dangerous to change the security origin of a document + // that already contains content. + void setSecurityOrigin(SecurityOrigin*); + + bool processingLoadEvent() const { return m_processingLoadEvent; } + +#if ENABLE(DATABASE) + void addOpenDatabase(Database*); + void removeOpenDatabase(Database*); + DatabaseThread* databaseThread(); // Creates the thread as needed, but not if it has been already terminated. + void setHasOpenDatabases() { m_hasOpenDatabases = true; } + bool hasOpenDatabases() { return m_hasOpenDatabases; } + void stopDatabases(); +#endif + + void setUsingGeolocation(bool f) { m_usingGeolocation = f; } + bool usingGeolocation() const { return m_usingGeolocation; }; + +#if ENABLE(WML) + void setContainsWMLContent(bool value) { m_containsWMLContent = value; } + bool containsWMLContent() const { return m_containsWMLContent; } + + void resetWMLPageState(); + void initializeWMLPageState(); +#endif + protected: Document(Frame*, bool isXHTML); - void setStyleSelector(CSSStyleSelector* styleSelector) { m_styleSelector = styleSelector; } + void setStyleSelector(CSSStyleSelector* styleSelector) { m_styleSelector = styleSelector; } + + void clearXMLVersion() { m_xmlVersion = String(); } #if ENABLE(TOUCH_EVENTS) // Android public: @@ -826,16 +931,36 @@ private: #endif // ENABLE(TOUCH_EVENTS) private: + virtual bool isDocument() const { return true; } + virtual void removedLastRef(); + virtual void determineParseMode() { } + + virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); + + virtual String nodeName() const; + virtual NodeType nodeType() const; + virtual bool childTypeAllowed(NodeType); + virtual PassRefPtr<Node> cloneNode(bool deep); + virtual bool canReplaceChild(Node* newChild, Node* oldChild); + virtual void refScriptExecutionContext() { ref(); } virtual void derefScriptExecutionContext() { deref(); } virtual const KURL& virtualURL() const; // Same as url(), but needed for ScriptExecutionContext to implement it without a performance loss for direct calls. virtual KURL virtualCompleteURL(const String&) const; // Same as completeURL() for the same reason as above. + void initDNSPrefetch(); + String encoding() const; void executeScriptSoonTimerFired(Timer<Document>*); + void updateTitle(); + void updateFocusAppearanceTimerFired(Timer<Document>*); + void updateBaseURL(); + + void cacheDocumentElement() const; + CSSStyleSelector* m_styleSelector; bool m_didCalculateStyleSelector; @@ -863,11 +988,6 @@ private: RefPtr<DocumentType> m_docType; mutable RefPtr<DOMImplementation> m_implementation; - RefPtr<StyleSheet> m_sheet; -#if FRAME_LOADS_USER_STYLESHEET - String m_usersheet; -#endif - // Track the number of currently loading top-level stylesheets. Sheets // loaded using the @import directive are not included in this count. // We use this count of pending sheets to detect when we can begin attaching @@ -887,6 +1007,9 @@ private: RefPtr<CSSStyleSheet> m_elemSheet; RefPtr<CSSStyleSheet> m_mappedElementSheet; + RefPtr<CSSStyleSheet> m_pageUserSheet; + mutable OwnPtr<Vector<RefPtr<CSSStyleSheet> > > m_pageGroupUserSheets; + mutable bool m_pageGroupUserSheetCacheValid; bool m_printing; @@ -963,7 +1086,7 @@ private: Timer<Document> m_executeScriptSoonTimer; #if ENABLE(XSLT) - void* m_transformSource; + OwnPtr<TransformSource> m_transformSource; RefPtr<Document> m_transformSourceDocument; #endif @@ -974,8 +1097,6 @@ private: typedef HashMap<AtomicStringImpl*, HTMLMapElement*> ImageMapsByName; ImageMapsByName m_imageMapsByName; - HashSet<Node*> m_disconnectedNodesWithEventListeners; - int m_docID; // A unique document identifier used for things like document-specific mapped attributes. String m_xmlEncoding; @@ -988,96 +1109,6 @@ private: bool m_shouldProcessNoScriptElement; #endif -public: - bool inPageCache() const { return m_inPageCache; } - void setInPageCache(bool flag); - - // Elements can register themselves for the "documentWillBecomeInactive()" and - // "documentDidBecomeActive()" callbacks - void registerForDocumentActivationCallbacks(Element*); - void unregisterForDocumentActivationCallbacks(Element*); - void documentWillBecomeInactive(); - void documentDidBecomeActive(); - - void registerForMediaVolumeCallbacks(Element*); - void unregisterForMediaVolumeCallbacks(Element*); - void mediaVolumeDidChange(); - - void setShouldCreateRenderers(bool); - bool shouldCreateRenderers(); - - void setDecoder(PassRefPtr<TextResourceDecoder>); - TextResourceDecoder* decoder() const { return m_decoder.get(); } - - String displayStringModifiedByEncoding(const String&) const; - PassRefPtr<StringImpl> displayStringModifiedByEncoding(PassRefPtr<StringImpl>) const; - void displayBufferModifiedByEncoding(UChar* buffer, unsigned len) const; - - // Quirk for the benefit of Apple's Dictionary application. - void setFrameElementsShouldIgnoreScrolling(bool ignore) { m_frameElementsShouldIgnoreScrolling = ignore; } - bool frameElementsShouldIgnoreScrolling() const { return m_frameElementsShouldIgnoreScrolling; } - -#if ENABLE(DASHBOARD_SUPPORT) - void setDashboardRegionsDirty(bool f) { m_dashboardRegionsDirty = f; } - bool dashboardRegionsDirty() const { return m_dashboardRegionsDirty; } - bool hasDashboardRegions () const { return m_hasDashboardRegions; } - void setHasDashboardRegions(bool f) { m_hasDashboardRegions = f; } - const Vector<DashboardRegionValue>& dashboardRegions() const; - void setDashboardRegions(const Vector<DashboardRegionValue>&); -#endif - - void removeAllEventListeners(); - - void registerDisconnectedNodeWithEventListeners(Node*); - void unregisterDisconnectedNodeWithEventListeners(Node*); - - CheckedRadioButtons& checkedRadioButtons() { return m_checkedRadioButtons; } - -#if ENABLE(SVG) - const SVGDocumentExtensions* svgExtensions(); - SVGDocumentExtensions* accessSVGExtensions(); -#endif - - void initSecurityContext(); - - // Explicitly override the security origin for this document. - // Note: It is dangerous to change the security origin of a document - // that already contains content. - void setSecurityOrigin(SecurityOrigin*); - - bool processingLoadEvent() const { return m_processingLoadEvent; } - -#if ENABLE(DATABASE) - void addOpenDatabase(Database*); - void removeOpenDatabase(Database*); - DatabaseThread* databaseThread(); // Creates the thread as needed, but not if it has been already terminated. - void setHasOpenDatabases() { m_hasOpenDatabases = true; } - bool hasOpenDatabases() { return m_hasOpenDatabases; } - void stopDatabases(); -#endif - - void setUsingGeolocation(bool f) { m_usingGeolocation = f; } - bool usingGeolocation() const { return m_usingGeolocation; }; - -#if ENABLE(WML) - void setContainsWMLContent(bool value) { m_containsWMLContent = value; } - bool containsWMLContent() const { return m_containsWMLContent; } - - void resetWMLPageState(); - void initializeWMLPageState(); -#endif - -protected: - void clearXMLVersion() { m_xmlVersion = String(); } - -private: - void updateTitle(); - void removeAllDisconnectedNodeEventListeners(); - void updateFocusAppearanceTimerFired(Timer<Document>*); - void updateBaseURL(); - - void cacheDocumentElement() const; - RenderObject* m_savedRenderer; int m_secureForms; @@ -1131,10 +1162,6 @@ private: unsigned m_numNodeListCaches; -public: - typedef HashMap<WebCore::Node*, JSNode*> JSWrapperCache; - JSWrapperCache& wrapperCache() { return m_wrapperCache; } -private: JSWrapperCache m_wrapperCache; #if ENABLE(DATABASE) @@ -1163,9 +1190,15 @@ inline bool Document::hasElementWithId(AtomicStringImpl* id) const inline bool Node::isDocumentNode() const { - return this == m_document.get(); + return this == m_document; } +#if ENABLE(INSPECTOR) +inline InspectorTimelineAgent* Document::inspectorTimelineAgent() const { + return page() ? page()->inspectorTimelineAgent() : 0; +} +#endif + } // namespace WebCore #endif // Document_h |