Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim: set ts=2 sw=2 et tw=80: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | /* |
michael@0 | 8 | * Base class for all our document implementations. |
michael@0 | 9 | */ |
michael@0 | 10 | |
michael@0 | 11 | #ifndef nsDocument_h___ |
michael@0 | 12 | #define nsDocument_h___ |
michael@0 | 13 | |
michael@0 | 14 | #include "nsIDocument.h" |
michael@0 | 15 | |
michael@0 | 16 | #include "nsCOMPtr.h" |
michael@0 | 17 | #include "nsAutoPtr.h" |
michael@0 | 18 | #include "nsCRT.h" |
michael@0 | 19 | #include "nsWeakReference.h" |
michael@0 | 20 | #include "nsWeakPtr.h" |
michael@0 | 21 | #include "nsVoidArray.h" |
michael@0 | 22 | #include "nsTArray.h" |
michael@0 | 23 | #include "nsIDOMXMLDocument.h" |
michael@0 | 24 | #include "nsIDOMDocumentXBL.h" |
michael@0 | 25 | #include "nsStubDocumentObserver.h" |
michael@0 | 26 | #include "nsIScriptGlobalObject.h" |
michael@0 | 27 | #include "nsIContent.h" |
michael@0 | 28 | #include "nsIPrincipal.h" |
michael@0 | 29 | #include "nsIParser.h" |
michael@0 | 30 | #include "nsBindingManager.h" |
michael@0 | 31 | #include "nsINodeInfo.h" |
michael@0 | 32 | #include "nsInterfaceHashtable.h" |
michael@0 | 33 | #include "nsJSThingHashtable.h" |
michael@0 | 34 | #include "nsIBoxObject.h" |
michael@0 | 35 | #include "nsPIBoxObject.h" |
michael@0 | 36 | #include "nsIScriptObjectPrincipal.h" |
michael@0 | 37 | #include "nsIURI.h" |
michael@0 | 38 | #include "nsScriptLoader.h" |
michael@0 | 39 | #include "nsIRadioGroupContainer.h" |
michael@0 | 40 | #include "nsILayoutHistoryState.h" |
michael@0 | 41 | #include "nsIRequest.h" |
michael@0 | 42 | #include "nsILoadGroup.h" |
michael@0 | 43 | #include "nsTObserverArray.h" |
michael@0 | 44 | #include "nsStubMutationObserver.h" |
michael@0 | 45 | #include "nsIChannel.h" |
michael@0 | 46 | #include "nsCycleCollectionParticipant.h" |
michael@0 | 47 | #include "nsContentList.h" |
michael@0 | 48 | #include "nsGkAtoms.h" |
michael@0 | 49 | #include "nsIApplicationCache.h" |
michael@0 | 50 | #include "nsIApplicationCacheContainer.h" |
michael@0 | 51 | #include "nsStyleSet.h" |
michael@0 | 52 | #include "pldhash.h" |
michael@0 | 53 | #include "nsAttrAndChildArray.h" |
michael@0 | 54 | #include "nsDOMAttributeMap.h" |
michael@0 | 55 | #include "nsIContentViewer.h" |
michael@0 | 56 | #include "nsIDOMXPathNSResolver.h" |
michael@0 | 57 | #include "nsIInterfaceRequestor.h" |
michael@0 | 58 | #include "nsILoadContext.h" |
michael@0 | 59 | #include "nsIProgressEventSink.h" |
michael@0 | 60 | #include "nsISecurityEventSink.h" |
michael@0 | 61 | #include "nsIChannelEventSink.h" |
michael@0 | 62 | #include "imgIRequest.h" |
michael@0 | 63 | #include "mozilla/EventListenerManager.h" |
michael@0 | 64 | #include "mozilla/EventStates.h" |
michael@0 | 65 | #include "mozilla/MemoryReporting.h" |
michael@0 | 66 | #include "mozilla/dom/DOMImplementation.h" |
michael@0 | 67 | #include "mozilla/dom/StyleSheetList.h" |
michael@0 | 68 | #include "nsIDOMTouchEvent.h" |
michael@0 | 69 | #include "nsDataHashtable.h" |
michael@0 | 70 | #include "mozilla/TimeStamp.h" |
michael@0 | 71 | #include "mozilla/Attributes.h" |
michael@0 | 72 | #include "nsIDOMXPathEvaluator.h" |
michael@0 | 73 | #include "jsfriendapi.h" |
michael@0 | 74 | |
michael@0 | 75 | #define XML_DECLARATION_BITS_DECLARATION_EXISTS (1 << 0) |
michael@0 | 76 | #define XML_DECLARATION_BITS_ENCODING_EXISTS (1 << 1) |
michael@0 | 77 | #define XML_DECLARATION_BITS_STANDALONE_EXISTS (1 << 2) |
michael@0 | 78 | #define XML_DECLARATION_BITS_STANDALONE_YES (1 << 3) |
michael@0 | 79 | |
michael@0 | 80 | |
michael@0 | 81 | class nsDOMStyleSheetSetList; |
michael@0 | 82 | class nsIOutputStream; |
michael@0 | 83 | class nsDocument; |
michael@0 | 84 | class nsIDTD; |
michael@0 | 85 | class nsIRadioVisitor; |
michael@0 | 86 | class nsIFormControl; |
michael@0 | 87 | struct nsRadioGroupStruct; |
michael@0 | 88 | class nsOnloadBlocker; |
michael@0 | 89 | class nsUnblockOnloadEvent; |
michael@0 | 90 | class nsChildContentList; |
michael@0 | 91 | class nsHTMLStyleSheet; |
michael@0 | 92 | class nsHTMLCSSStyleSheet; |
michael@0 | 93 | class nsDOMNavigationTiming; |
michael@0 | 94 | class nsWindowSizes; |
michael@0 | 95 | class nsHtml5TreeOpExecutor; |
michael@0 | 96 | class nsDocumentOnStack; |
michael@0 | 97 | class nsPointerLockPermissionRequest; |
michael@0 | 98 | class nsISecurityConsoleMessage; |
michael@0 | 99 | |
michael@0 | 100 | namespace mozilla { |
michael@0 | 101 | class EventChainPreVisitor; |
michael@0 | 102 | namespace dom { |
michael@0 | 103 | class UndoManager; |
michael@0 | 104 | class LifecycleCallbacks; |
michael@0 | 105 | class CallbackFunction; |
michael@0 | 106 | } |
michael@0 | 107 | } |
michael@0 | 108 | |
michael@0 | 109 | /** |
michael@0 | 110 | * Right now our identifier map entries contain information for 'name' |
michael@0 | 111 | * and 'id' mappings of a given string. This is so that |
michael@0 | 112 | * nsHTMLDocument::ResolveName only has to do one hash lookup instead |
michael@0 | 113 | * of two. It's not clear whether this still matters for performance. |
michael@0 | 114 | * |
michael@0 | 115 | * We also store the document.all result list here. This is mainly so that |
michael@0 | 116 | * when all elements with the given ID are removed and we remove |
michael@0 | 117 | * the ID's nsIdentifierMapEntry, the document.all result is released too. |
michael@0 | 118 | * Perhaps the document.all results should have their own hashtable |
michael@0 | 119 | * in nsHTMLDocument. |
michael@0 | 120 | */ |
michael@0 | 121 | class nsIdentifierMapEntry : public nsStringHashKey |
michael@0 | 122 | { |
michael@0 | 123 | public: |
michael@0 | 124 | typedef mozilla::dom::Element Element; |
michael@0 | 125 | |
michael@0 | 126 | nsIdentifierMapEntry(const nsAString& aKey) : |
michael@0 | 127 | nsStringHashKey(&aKey), mNameContentList(nullptr) |
michael@0 | 128 | { |
michael@0 | 129 | } |
michael@0 | 130 | nsIdentifierMapEntry(const nsAString *aKey) : |
michael@0 | 131 | nsStringHashKey(aKey), mNameContentList(nullptr) |
michael@0 | 132 | { |
michael@0 | 133 | } |
michael@0 | 134 | nsIdentifierMapEntry(const nsIdentifierMapEntry& aOther) : |
michael@0 | 135 | nsStringHashKey(&aOther.GetKey()) |
michael@0 | 136 | { |
michael@0 | 137 | NS_ERROR("Should never be called"); |
michael@0 | 138 | } |
michael@0 | 139 | ~nsIdentifierMapEntry(); |
michael@0 | 140 | |
michael@0 | 141 | void AddNameElement(nsINode* aDocument, Element* aElement); |
michael@0 | 142 | void RemoveNameElement(Element* aElement); |
michael@0 | 143 | bool IsEmpty(); |
michael@0 | 144 | nsBaseContentList* GetNameContentList() { |
michael@0 | 145 | return mNameContentList; |
michael@0 | 146 | } |
michael@0 | 147 | bool HasNameElement() const { |
michael@0 | 148 | return mNameContentList && mNameContentList->Length() != 0; |
michael@0 | 149 | } |
michael@0 | 150 | |
michael@0 | 151 | /** |
michael@0 | 152 | * Returns the element if we know the element associated with this |
michael@0 | 153 | * id. Otherwise returns null. |
michael@0 | 154 | */ |
michael@0 | 155 | Element* GetIdElement(); |
michael@0 | 156 | /** |
michael@0 | 157 | * Returns the list of all elements associated with this id. |
michael@0 | 158 | */ |
michael@0 | 159 | const nsSmallVoidArray* GetIdElements() const { |
michael@0 | 160 | return &mIdContentList; |
michael@0 | 161 | } |
michael@0 | 162 | /** |
michael@0 | 163 | * If this entry has a non-null image element set (using SetImageElement), |
michael@0 | 164 | * the image element will be returned, otherwise the same as GetIdElement(). |
michael@0 | 165 | */ |
michael@0 | 166 | Element* GetImageIdElement(); |
michael@0 | 167 | /** |
michael@0 | 168 | * Append all the elements with this id to aElements |
michael@0 | 169 | */ |
michael@0 | 170 | void AppendAllIdContent(nsCOMArray<nsIContent>* aElements); |
michael@0 | 171 | /** |
michael@0 | 172 | * This can fire ID change callbacks. |
michael@0 | 173 | * @return true if the content could be added, false if we failed due |
michael@0 | 174 | * to OOM. |
michael@0 | 175 | */ |
michael@0 | 176 | bool AddIdElement(Element* aElement); |
michael@0 | 177 | /** |
michael@0 | 178 | * This can fire ID change callbacks. |
michael@0 | 179 | */ |
michael@0 | 180 | void RemoveIdElement(Element* aElement); |
michael@0 | 181 | /** |
michael@0 | 182 | * Set the image element override for this ID. This will be returned by |
michael@0 | 183 | * GetIdElement(true) if non-null. |
michael@0 | 184 | */ |
michael@0 | 185 | void SetImageElement(Element* aElement); |
michael@0 | 186 | bool HasIdElementExposedAsHTMLDocumentProperty(); |
michael@0 | 187 | |
michael@0 | 188 | bool HasContentChangeCallback() { return mChangeCallbacks != nullptr; } |
michael@0 | 189 | void AddContentChangeCallback(nsIDocument::IDTargetObserver aCallback, |
michael@0 | 190 | void* aData, bool aForImage); |
michael@0 | 191 | void RemoveContentChangeCallback(nsIDocument::IDTargetObserver aCallback, |
michael@0 | 192 | void* aData, bool aForImage); |
michael@0 | 193 | |
michael@0 | 194 | void Traverse(nsCycleCollectionTraversalCallback* aCallback); |
michael@0 | 195 | |
michael@0 | 196 | struct ChangeCallback { |
michael@0 | 197 | nsIDocument::IDTargetObserver mCallback; |
michael@0 | 198 | void* mData; |
michael@0 | 199 | bool mForImage; |
michael@0 | 200 | }; |
michael@0 | 201 | |
michael@0 | 202 | struct ChangeCallbackEntry : public PLDHashEntryHdr { |
michael@0 | 203 | typedef const ChangeCallback KeyType; |
michael@0 | 204 | typedef const ChangeCallback* KeyTypePointer; |
michael@0 | 205 | |
michael@0 | 206 | ChangeCallbackEntry(const ChangeCallback* key) : |
michael@0 | 207 | mKey(*key) { } |
michael@0 | 208 | ChangeCallbackEntry(const ChangeCallbackEntry& toCopy) : |
michael@0 | 209 | mKey(toCopy.mKey) { } |
michael@0 | 210 | |
michael@0 | 211 | KeyType GetKey() const { return mKey; } |
michael@0 | 212 | bool KeyEquals(KeyTypePointer aKey) const { |
michael@0 | 213 | return aKey->mCallback == mKey.mCallback && |
michael@0 | 214 | aKey->mData == mKey.mData && |
michael@0 | 215 | aKey->mForImage == mKey.mForImage; |
michael@0 | 216 | } |
michael@0 | 217 | |
michael@0 | 218 | static KeyTypePointer KeyToPointer(KeyType& aKey) { return &aKey; } |
michael@0 | 219 | static PLDHashNumber HashKey(KeyTypePointer aKey) |
michael@0 | 220 | { |
michael@0 | 221 | return mozilla::HashGeneric(aKey->mCallback, aKey->mData); |
michael@0 | 222 | } |
michael@0 | 223 | enum { ALLOW_MEMMOVE = true }; |
michael@0 | 224 | |
michael@0 | 225 | ChangeCallback mKey; |
michael@0 | 226 | }; |
michael@0 | 227 | |
michael@0 | 228 | static size_t SizeOfExcludingThis(nsIdentifierMapEntry* aEntry, |
michael@0 | 229 | mozilla::MallocSizeOf aMallocSizeOf, |
michael@0 | 230 | void* aArg); |
michael@0 | 231 | |
michael@0 | 232 | private: |
michael@0 | 233 | void FireChangeCallbacks(Element* aOldElement, Element* aNewElement, |
michael@0 | 234 | bool aImageOnly = false); |
michael@0 | 235 | |
michael@0 | 236 | // empty if there are no elements with this ID. |
michael@0 | 237 | // The elements are stored as weak pointers. |
michael@0 | 238 | nsSmallVoidArray mIdContentList; |
michael@0 | 239 | nsRefPtr<nsBaseContentList> mNameContentList; |
michael@0 | 240 | nsAutoPtr<nsTHashtable<ChangeCallbackEntry> > mChangeCallbacks; |
michael@0 | 241 | nsRefPtr<Element> mImageElement; |
michael@0 | 242 | }; |
michael@0 | 243 | |
michael@0 | 244 | namespace mozilla { |
michael@0 | 245 | namespace dom { |
michael@0 | 246 | |
michael@0 | 247 | class CustomElementHashKey : public PLDHashEntryHdr |
michael@0 | 248 | { |
michael@0 | 249 | public: |
michael@0 | 250 | typedef CustomElementHashKey *KeyType; |
michael@0 | 251 | typedef const CustomElementHashKey *KeyTypePointer; |
michael@0 | 252 | |
michael@0 | 253 | CustomElementHashKey(int32_t aNamespaceID, nsIAtom *aAtom) |
michael@0 | 254 | : mNamespaceID(aNamespaceID), |
michael@0 | 255 | mAtom(aAtom) |
michael@0 | 256 | {} |
michael@0 | 257 | CustomElementHashKey(const CustomElementHashKey *aKey) |
michael@0 | 258 | : mNamespaceID(aKey->mNamespaceID), |
michael@0 | 259 | mAtom(aKey->mAtom) |
michael@0 | 260 | {} |
michael@0 | 261 | ~CustomElementHashKey() |
michael@0 | 262 | {} |
michael@0 | 263 | |
michael@0 | 264 | KeyType GetKey() const { return const_cast<KeyType>(this); } |
michael@0 | 265 | bool KeyEquals(const KeyTypePointer aKey) const |
michael@0 | 266 | { |
michael@0 | 267 | MOZ_ASSERT(mNamespaceID != kNameSpaceID_Unknown, |
michael@0 | 268 | "This equals method is not transitive, nor symmetric. " |
michael@0 | 269 | "A key with a namespace of kNamespaceID_Unknown should " |
michael@0 | 270 | "not be stored in a hashtable."); |
michael@0 | 271 | return (kNameSpaceID_Unknown == aKey->mNamespaceID || |
michael@0 | 272 | mNamespaceID == aKey->mNamespaceID) && |
michael@0 | 273 | aKey->mAtom == mAtom; |
michael@0 | 274 | } |
michael@0 | 275 | |
michael@0 | 276 | static KeyTypePointer KeyToPointer(KeyType aKey) { return aKey; } |
michael@0 | 277 | static PLDHashNumber HashKey(const KeyTypePointer aKey) |
michael@0 | 278 | { |
michael@0 | 279 | return aKey->mAtom->hash(); |
michael@0 | 280 | } |
michael@0 | 281 | enum { ALLOW_MEMMOVE = true }; |
michael@0 | 282 | |
michael@0 | 283 | private: |
michael@0 | 284 | int32_t mNamespaceID; |
michael@0 | 285 | nsCOMPtr<nsIAtom> mAtom; |
michael@0 | 286 | }; |
michael@0 | 287 | |
michael@0 | 288 | struct LifecycleCallbackArgs |
michael@0 | 289 | { |
michael@0 | 290 | nsString name; |
michael@0 | 291 | nsString oldValue; |
michael@0 | 292 | nsString newValue; |
michael@0 | 293 | }; |
michael@0 | 294 | |
michael@0 | 295 | struct CustomElementData; |
michael@0 | 296 | |
michael@0 | 297 | class CustomElementCallback |
michael@0 | 298 | { |
michael@0 | 299 | public: |
michael@0 | 300 | CustomElementCallback(Element* aThisObject, |
michael@0 | 301 | nsIDocument::ElementCallbackType aCallbackType, |
michael@0 | 302 | mozilla::dom::CallbackFunction* aCallback, |
michael@0 | 303 | CustomElementData* aOwnerData); |
michael@0 | 304 | void Traverse(nsCycleCollectionTraversalCallback& aCb) const; |
michael@0 | 305 | void Call(); |
michael@0 | 306 | void SetArgs(LifecycleCallbackArgs& aArgs) |
michael@0 | 307 | { |
michael@0 | 308 | MOZ_ASSERT(mType == nsIDocument::eAttributeChanged, |
michael@0 | 309 | "Arguments are only used by attribute changed callback."); |
michael@0 | 310 | mArgs = aArgs; |
michael@0 | 311 | } |
michael@0 | 312 | |
michael@0 | 313 | private: |
michael@0 | 314 | // The this value to use for invocation of the callback. |
michael@0 | 315 | nsRefPtr<mozilla::dom::Element> mThisObject; |
michael@0 | 316 | nsRefPtr<mozilla::dom::CallbackFunction> mCallback; |
michael@0 | 317 | // The type of callback (eCreated, eAttached, etc.) |
michael@0 | 318 | nsIDocument::ElementCallbackType mType; |
michael@0 | 319 | // Arguments to be passed to the callback, |
michael@0 | 320 | // used by the attribute changed callback. |
michael@0 | 321 | LifecycleCallbackArgs mArgs; |
michael@0 | 322 | // CustomElementData that contains this callback in the |
michael@0 | 323 | // callback queue. |
michael@0 | 324 | CustomElementData* mOwnerData; |
michael@0 | 325 | }; |
michael@0 | 326 | |
michael@0 | 327 | // Each custom element has an associated callback queue and an element is |
michael@0 | 328 | // being created flag. |
michael@0 | 329 | struct CustomElementData |
michael@0 | 330 | { |
michael@0 | 331 | CustomElementData(nsIAtom* aType); |
michael@0 | 332 | // Objects in this array are transient and empty after each microtask |
michael@0 | 333 | // checkpoint. |
michael@0 | 334 | nsTArray<nsAutoPtr<CustomElementCallback>> mCallbackQueue; |
michael@0 | 335 | // Custom element type, for <button is="x-button"> or <x-button> |
michael@0 | 336 | // this would be x-button. |
michael@0 | 337 | nsCOMPtr<nsIAtom> mType; |
michael@0 | 338 | // The callback that is next to be processed upon calling RunCallbackQueue. |
michael@0 | 339 | int32_t mCurrentCallback; |
michael@0 | 340 | // Element is being created flag as described in the custom elements spec. |
michael@0 | 341 | bool mElementIsBeingCreated; |
michael@0 | 342 | // Flag to determine if the created callback has been invoked, thus it |
michael@0 | 343 | // determines if other callbacks can be enqueued. |
michael@0 | 344 | bool mCreatedCallbackInvoked; |
michael@0 | 345 | // The microtask level associated with the callbacks in the callback queue, |
michael@0 | 346 | // it is used to determine if a new queue needs to be pushed onto the |
michael@0 | 347 | // processing stack. |
michael@0 | 348 | int32_t mAssociatedMicroTask; |
michael@0 | 349 | |
michael@0 | 350 | // Empties the callback queue. |
michael@0 | 351 | void RunCallbackQueue(); |
michael@0 | 352 | }; |
michael@0 | 353 | |
michael@0 | 354 | // The required information for a custom element as defined in: |
michael@0 | 355 | // https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/custom/index.html |
michael@0 | 356 | struct CustomElementDefinition |
michael@0 | 357 | { |
michael@0 | 358 | CustomElementDefinition(JSObject* aPrototype, |
michael@0 | 359 | nsIAtom* aType, |
michael@0 | 360 | nsIAtom* aLocalName, |
michael@0 | 361 | mozilla::dom::LifecycleCallbacks* aCallbacks, |
michael@0 | 362 | uint32_t aNamespaceID, |
michael@0 | 363 | uint32_t aDocOrder); |
michael@0 | 364 | |
michael@0 | 365 | // The prototype to use for new custom elements of this type. |
michael@0 | 366 | JS::Heap<JSObject *> mPrototype; |
michael@0 | 367 | |
michael@0 | 368 | // The type (name) for this custom element. |
michael@0 | 369 | nsCOMPtr<nsIAtom> mType; |
michael@0 | 370 | |
michael@0 | 371 | // The localname to (e.g. <button is=type> -- this would be button). |
michael@0 | 372 | nsCOMPtr<nsIAtom> mLocalName; |
michael@0 | 373 | |
michael@0 | 374 | // The lifecycle callbacks to call for this custom element. |
michael@0 | 375 | nsAutoPtr<mozilla::dom::LifecycleCallbacks> mCallbacks; |
michael@0 | 376 | |
michael@0 | 377 | // Whether we're currently calling the created callback for a custom element |
michael@0 | 378 | // of this type. |
michael@0 | 379 | bool mElementIsBeingCreated; |
michael@0 | 380 | |
michael@0 | 381 | // Element namespace. |
michael@0 | 382 | int32_t mNamespaceID; |
michael@0 | 383 | |
michael@0 | 384 | // The document custom element order. |
michael@0 | 385 | uint32_t mDocOrder; |
michael@0 | 386 | }; |
michael@0 | 387 | |
michael@0 | 388 | class Registry : public nsISupports |
michael@0 | 389 | { |
michael@0 | 390 | public: |
michael@0 | 391 | friend class ::nsDocument; |
michael@0 | 392 | |
michael@0 | 393 | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
michael@0 | 394 | NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Registry) |
michael@0 | 395 | |
michael@0 | 396 | Registry(); |
michael@0 | 397 | virtual ~Registry(); |
michael@0 | 398 | |
michael@0 | 399 | protected: |
michael@0 | 400 | typedef nsClassHashtable<mozilla::dom::CustomElementHashKey, |
michael@0 | 401 | mozilla::dom::CustomElementDefinition> |
michael@0 | 402 | DefinitionMap; |
michael@0 | 403 | typedef nsClassHashtable<mozilla::dom::CustomElementHashKey, |
michael@0 | 404 | nsTArray<nsRefPtr<mozilla::dom::Element>>> |
michael@0 | 405 | CandidateMap; |
michael@0 | 406 | |
michael@0 | 407 | // Hashtable for custom element definitions in web components. |
michael@0 | 408 | // Custom prototypes are in the document's compartment. |
michael@0 | 409 | DefinitionMap mCustomDefinitions; |
michael@0 | 410 | |
michael@0 | 411 | // The "upgrade candidates map" from the web components spec. Maps from a |
michael@0 | 412 | // namespace id and local name to a list of elements to upgrade if that |
michael@0 | 413 | // element is registered as a custom element. |
michael@0 | 414 | CandidateMap mCandidatesMap; |
michael@0 | 415 | }; |
michael@0 | 416 | |
michael@0 | 417 | } // namespace dom |
michael@0 | 418 | } // namespace mozilla |
michael@0 | 419 | |
michael@0 | 420 | class nsDocHeaderData |
michael@0 | 421 | { |
michael@0 | 422 | public: |
michael@0 | 423 | nsDocHeaderData(nsIAtom* aField, const nsAString& aData) |
michael@0 | 424 | : mField(aField), mData(aData), mNext(nullptr) |
michael@0 | 425 | { |
michael@0 | 426 | } |
michael@0 | 427 | |
michael@0 | 428 | ~nsDocHeaderData(void) |
michael@0 | 429 | { |
michael@0 | 430 | delete mNext; |
michael@0 | 431 | } |
michael@0 | 432 | |
michael@0 | 433 | nsCOMPtr<nsIAtom> mField; |
michael@0 | 434 | nsString mData; |
michael@0 | 435 | nsDocHeaderData* mNext; |
michael@0 | 436 | }; |
michael@0 | 437 | |
michael@0 | 438 | class nsDOMStyleSheetList : public mozilla::dom::StyleSheetList, |
michael@0 | 439 | public nsStubDocumentObserver |
michael@0 | 440 | { |
michael@0 | 441 | public: |
michael@0 | 442 | nsDOMStyleSheetList(nsIDocument *aDocument); |
michael@0 | 443 | virtual ~nsDOMStyleSheetList(); |
michael@0 | 444 | |
michael@0 | 445 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 446 | |
michael@0 | 447 | // nsIDocumentObserver |
michael@0 | 448 | NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETADDED |
michael@0 | 449 | NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETREMOVED |
michael@0 | 450 | |
michael@0 | 451 | // nsIMutationObserver |
michael@0 | 452 | NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED |
michael@0 | 453 | |
michael@0 | 454 | virtual nsINode* GetParentObject() const MOZ_OVERRIDE |
michael@0 | 455 | { |
michael@0 | 456 | return mDocument; |
michael@0 | 457 | } |
michael@0 | 458 | |
michael@0 | 459 | virtual uint32_t Length() MOZ_OVERRIDE; |
michael@0 | 460 | virtual nsCSSStyleSheet* IndexedGetter(uint32_t aIndex, bool& aFound) MOZ_OVERRIDE; |
michael@0 | 461 | |
michael@0 | 462 | protected: |
michael@0 | 463 | int32_t mLength; |
michael@0 | 464 | nsIDocument* mDocument; |
michael@0 | 465 | }; |
michael@0 | 466 | |
michael@0 | 467 | class nsOnloadBlocker MOZ_FINAL : public nsIRequest |
michael@0 | 468 | { |
michael@0 | 469 | public: |
michael@0 | 470 | nsOnloadBlocker() {} |
michael@0 | 471 | |
michael@0 | 472 | NS_DECL_ISUPPORTS |
michael@0 | 473 | NS_DECL_NSIREQUEST |
michael@0 | 474 | |
michael@0 | 475 | private: |
michael@0 | 476 | ~nsOnloadBlocker() {} |
michael@0 | 477 | }; |
michael@0 | 478 | |
michael@0 | 479 | class nsExternalResourceMap |
michael@0 | 480 | { |
michael@0 | 481 | public: |
michael@0 | 482 | typedef nsIDocument::ExternalResourceLoad ExternalResourceLoad; |
michael@0 | 483 | nsExternalResourceMap(); |
michael@0 | 484 | |
michael@0 | 485 | /** |
michael@0 | 486 | * Request an external resource document. This does exactly what |
michael@0 | 487 | * nsIDocument::RequestExternalResource is documented to do. |
michael@0 | 488 | */ |
michael@0 | 489 | nsIDocument* RequestResource(nsIURI* aURI, |
michael@0 | 490 | nsINode* aRequestingNode, |
michael@0 | 491 | nsDocument* aDisplayDocument, |
michael@0 | 492 | ExternalResourceLoad** aPendingLoad); |
michael@0 | 493 | |
michael@0 | 494 | /** |
michael@0 | 495 | * Enumerate the resource documents. See |
michael@0 | 496 | * nsIDocument::EnumerateExternalResources. |
michael@0 | 497 | */ |
michael@0 | 498 | void EnumerateResources(nsIDocument::nsSubDocEnumFunc aCallback, void* aData); |
michael@0 | 499 | |
michael@0 | 500 | /** |
michael@0 | 501 | * Traverse ourselves for cycle-collection |
michael@0 | 502 | */ |
michael@0 | 503 | void Traverse(nsCycleCollectionTraversalCallback* aCallback) const; |
michael@0 | 504 | |
michael@0 | 505 | /** |
michael@0 | 506 | * Shut ourselves down (used for cycle-collection unlink), as well |
michael@0 | 507 | * as for document destruction. |
michael@0 | 508 | */ |
michael@0 | 509 | void Shutdown() |
michael@0 | 510 | { |
michael@0 | 511 | mPendingLoads.Clear(); |
michael@0 | 512 | mMap.Clear(); |
michael@0 | 513 | mHaveShutDown = true; |
michael@0 | 514 | } |
michael@0 | 515 | |
michael@0 | 516 | bool HaveShutDown() const |
michael@0 | 517 | { |
michael@0 | 518 | return mHaveShutDown; |
michael@0 | 519 | } |
michael@0 | 520 | |
michael@0 | 521 | // Needs to be public so we can traverse them sanely |
michael@0 | 522 | struct ExternalResource |
michael@0 | 523 | { |
michael@0 | 524 | ~ExternalResource(); |
michael@0 | 525 | nsCOMPtr<nsIDocument> mDocument; |
michael@0 | 526 | nsCOMPtr<nsIContentViewer> mViewer; |
michael@0 | 527 | nsCOMPtr<nsILoadGroup> mLoadGroup; |
michael@0 | 528 | }; |
michael@0 | 529 | |
michael@0 | 530 | // Hide all our viewers |
michael@0 | 531 | void HideViewers(); |
michael@0 | 532 | |
michael@0 | 533 | // Show all our viewers |
michael@0 | 534 | void ShowViewers(); |
michael@0 | 535 | |
michael@0 | 536 | protected: |
michael@0 | 537 | class PendingLoad : public ExternalResourceLoad, |
michael@0 | 538 | public nsIStreamListener |
michael@0 | 539 | { |
michael@0 | 540 | public: |
michael@0 | 541 | PendingLoad(nsDocument* aDisplayDocument) : |
michael@0 | 542 | mDisplayDocument(aDisplayDocument) |
michael@0 | 543 | {} |
michael@0 | 544 | |
michael@0 | 545 | NS_DECL_ISUPPORTS |
michael@0 | 546 | NS_DECL_NSISTREAMLISTENER |
michael@0 | 547 | NS_DECL_NSIREQUESTOBSERVER |
michael@0 | 548 | |
michael@0 | 549 | /** |
michael@0 | 550 | * Start aURI loading. This will perform the necessary security checks and |
michael@0 | 551 | * so forth. |
michael@0 | 552 | */ |
michael@0 | 553 | nsresult StartLoad(nsIURI* aURI, nsINode* aRequestingNode); |
michael@0 | 554 | |
michael@0 | 555 | /** |
michael@0 | 556 | * Set up an nsIContentViewer based on aRequest. This is guaranteed to |
michael@0 | 557 | * put null in *aViewer and *aLoadGroup on all failures. |
michael@0 | 558 | */ |
michael@0 | 559 | nsresult SetupViewer(nsIRequest* aRequest, nsIContentViewer** aViewer, |
michael@0 | 560 | nsILoadGroup** aLoadGroup); |
michael@0 | 561 | |
michael@0 | 562 | private: |
michael@0 | 563 | nsRefPtr<nsDocument> mDisplayDocument; |
michael@0 | 564 | nsCOMPtr<nsIStreamListener> mTargetListener; |
michael@0 | 565 | nsCOMPtr<nsIURI> mURI; |
michael@0 | 566 | }; |
michael@0 | 567 | friend class PendingLoad; |
michael@0 | 568 | |
michael@0 | 569 | class LoadgroupCallbacks MOZ_FINAL : public nsIInterfaceRequestor |
michael@0 | 570 | { |
michael@0 | 571 | public: |
michael@0 | 572 | LoadgroupCallbacks(nsIInterfaceRequestor* aOtherCallbacks) |
michael@0 | 573 | : mCallbacks(aOtherCallbacks) |
michael@0 | 574 | {} |
michael@0 | 575 | NS_DECL_ISUPPORTS |
michael@0 | 576 | NS_DECL_NSIINTERFACEREQUESTOR |
michael@0 | 577 | private: |
michael@0 | 578 | // The only reason it's safe to hold a strong ref here without leaking is |
michael@0 | 579 | // that the notificationCallbacks on a loadgroup aren't the docshell itself |
michael@0 | 580 | // but a shim that holds a weak reference to the docshell. |
michael@0 | 581 | nsCOMPtr<nsIInterfaceRequestor> mCallbacks; |
michael@0 | 582 | |
michael@0 | 583 | // Use shims for interfaces that docshell implements directly so that we |
michael@0 | 584 | // don't hand out references to the docshell. The shims should all allow |
michael@0 | 585 | // getInterface back on us, but other than that each one should only |
michael@0 | 586 | // implement one interface. |
michael@0 | 587 | |
michael@0 | 588 | // XXXbz I wish we could just derive the _allcaps thing from _i |
michael@0 | 589 | #define DECL_SHIM(_i, _allcaps) \ |
michael@0 | 590 | class _i##Shim MOZ_FINAL : public nsIInterfaceRequestor, \ |
michael@0 | 591 | public _i \ |
michael@0 | 592 | { \ |
michael@0 | 593 | public: \ |
michael@0 | 594 | _i##Shim(nsIInterfaceRequestor* aIfreq, _i* aRealPtr) \ |
michael@0 | 595 | : mIfReq(aIfreq), mRealPtr(aRealPtr) \ |
michael@0 | 596 | { \ |
michael@0 | 597 | NS_ASSERTION(mIfReq, "Expected non-null here"); \ |
michael@0 | 598 | NS_ASSERTION(mRealPtr, "Expected non-null here"); \ |
michael@0 | 599 | } \ |
michael@0 | 600 | NS_DECL_ISUPPORTS \ |
michael@0 | 601 | NS_FORWARD_NSIINTERFACEREQUESTOR(mIfReq->) \ |
michael@0 | 602 | NS_FORWARD_##_allcaps(mRealPtr->) \ |
michael@0 | 603 | private: \ |
michael@0 | 604 | nsCOMPtr<nsIInterfaceRequestor> mIfReq; \ |
michael@0 | 605 | nsCOMPtr<_i> mRealPtr; \ |
michael@0 | 606 | }; |
michael@0 | 607 | |
michael@0 | 608 | DECL_SHIM(nsILoadContext, NSILOADCONTEXT) |
michael@0 | 609 | DECL_SHIM(nsIProgressEventSink, NSIPROGRESSEVENTSINK) |
michael@0 | 610 | DECL_SHIM(nsIChannelEventSink, NSICHANNELEVENTSINK) |
michael@0 | 611 | DECL_SHIM(nsISecurityEventSink, NSISECURITYEVENTSINK) |
michael@0 | 612 | DECL_SHIM(nsIApplicationCacheContainer, NSIAPPLICATIONCACHECONTAINER) |
michael@0 | 613 | #undef DECL_SHIM |
michael@0 | 614 | }; |
michael@0 | 615 | |
michael@0 | 616 | /** |
michael@0 | 617 | * Add an ExternalResource for aURI. aViewer and aLoadGroup might be null |
michael@0 | 618 | * when this is called if the URI didn't result in an XML document. This |
michael@0 | 619 | * function makes sure to remove the pending load for aURI, if any, from our |
michael@0 | 620 | * hashtable, and to notify its observers, if any. |
michael@0 | 621 | */ |
michael@0 | 622 | nsresult AddExternalResource(nsIURI* aURI, nsIContentViewer* aViewer, |
michael@0 | 623 | nsILoadGroup* aLoadGroup, |
michael@0 | 624 | nsIDocument* aDisplayDocument); |
michael@0 | 625 | |
michael@0 | 626 | nsClassHashtable<nsURIHashKey, ExternalResource> mMap; |
michael@0 | 627 | nsRefPtrHashtable<nsURIHashKey, PendingLoad> mPendingLoads; |
michael@0 | 628 | bool mHaveShutDown; |
michael@0 | 629 | }; |
michael@0 | 630 | |
michael@0 | 631 | class CSPErrorQueue |
michael@0 | 632 | { |
michael@0 | 633 | public: |
michael@0 | 634 | /** |
michael@0 | 635 | * Note this was designed to be passed string literals. If you give it |
michael@0 | 636 | * a dynamically allocated string, it is your responsibility to make sure |
michael@0 | 637 | * it never dies and is properly freed! |
michael@0 | 638 | */ |
michael@0 | 639 | void Add(const char* aMessageName); |
michael@0 | 640 | void Flush(nsIDocument* aDocument); |
michael@0 | 641 | |
michael@0 | 642 | CSPErrorQueue() |
michael@0 | 643 | { |
michael@0 | 644 | } |
michael@0 | 645 | |
michael@0 | 646 | ~CSPErrorQueue() |
michael@0 | 647 | { |
michael@0 | 648 | } |
michael@0 | 649 | |
michael@0 | 650 | private: |
michael@0 | 651 | nsAutoTArray<const char*,5> mErrors; |
michael@0 | 652 | }; |
michael@0 | 653 | |
michael@0 | 654 | // Base class for our document implementations. |
michael@0 | 655 | // |
michael@0 | 656 | // Note that this class *implements* nsIDOMXMLDocument, but it's not |
michael@0 | 657 | // really an nsIDOMXMLDocument. The reason for implementing |
michael@0 | 658 | // nsIDOMXMLDocument on this class is to avoid having to duplicate all |
michael@0 | 659 | // its inherited methods on document classes that *are* |
michael@0 | 660 | // nsIDOMXMLDocument's. nsDocument's QI should *not* claim to support |
michael@0 | 661 | // nsIDOMXMLDocument unless someone writes a real implementation of |
michael@0 | 662 | // the interface. |
michael@0 | 663 | class nsDocument : public nsIDocument, |
michael@0 | 664 | public nsIDOMXMLDocument, // inherits nsIDOMDocument |
michael@0 | 665 | public nsIDOMDocumentXBL, |
michael@0 | 666 | public nsSupportsWeakReference, |
michael@0 | 667 | public nsIScriptObjectPrincipal, |
michael@0 | 668 | public nsIRadioGroupContainer, |
michael@0 | 669 | public nsIApplicationCacheContainer, |
michael@0 | 670 | public nsStubMutationObserver, |
michael@0 | 671 | public nsIObserver, |
michael@0 | 672 | public nsIDOMXPathEvaluator |
michael@0 | 673 | { |
michael@0 | 674 | public: |
michael@0 | 675 | typedef mozilla::dom::Element Element; |
michael@0 | 676 | using nsIDocument::GetElementsByTagName; |
michael@0 | 677 | |
michael@0 | 678 | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
michael@0 | 679 | |
michael@0 | 680 | NS_DECL_SIZEOF_EXCLUDING_THIS |
michael@0 | 681 | |
michael@0 | 682 | virtual void Reset(nsIChannel *aChannel, nsILoadGroup *aLoadGroup) MOZ_OVERRIDE; |
michael@0 | 683 | virtual void ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup, |
michael@0 | 684 | nsIPrincipal* aPrincipal) MOZ_OVERRIDE; |
michael@0 | 685 | |
michael@0 | 686 | // StartDocumentLoad is pure virtual so that subclasses must override it. |
michael@0 | 687 | // The nsDocument StartDocumentLoad does some setup, but does NOT set |
michael@0 | 688 | // *aDocListener; this is the job of subclasses. |
michael@0 | 689 | virtual nsresult StartDocumentLoad(const char* aCommand, |
michael@0 | 690 | nsIChannel* aChannel, |
michael@0 | 691 | nsILoadGroup* aLoadGroup, |
michael@0 | 692 | nsISupports* aContainer, |
michael@0 | 693 | nsIStreamListener **aDocListener, |
michael@0 | 694 | bool aReset = true, |
michael@0 | 695 | nsIContentSink* aContentSink = nullptr) MOZ_OVERRIDE = 0; |
michael@0 | 696 | |
michael@0 | 697 | virtual void StopDocumentLoad() MOZ_OVERRIDE; |
michael@0 | 698 | |
michael@0 | 699 | virtual void NotifyPossibleTitleChange(bool aBoundTitleElement) MOZ_OVERRIDE; |
michael@0 | 700 | |
michael@0 | 701 | virtual void SetDocumentURI(nsIURI* aURI) MOZ_OVERRIDE; |
michael@0 | 702 | |
michael@0 | 703 | virtual void SetChromeXHRDocURI(nsIURI* aURI) MOZ_OVERRIDE; |
michael@0 | 704 | |
michael@0 | 705 | virtual void SetChromeXHRDocBaseURI(nsIURI* aURI) MOZ_OVERRIDE; |
michael@0 | 706 | |
michael@0 | 707 | /** |
michael@0 | 708 | * Set the principal responsible for this document. |
michael@0 | 709 | */ |
michael@0 | 710 | virtual void SetPrincipal(nsIPrincipal *aPrincipal) MOZ_OVERRIDE; |
michael@0 | 711 | |
michael@0 | 712 | /** |
michael@0 | 713 | * Get the Content-Type of this document. |
michael@0 | 714 | */ |
michael@0 | 715 | // NS_IMETHOD GetContentType(nsAString& aContentType); |
michael@0 | 716 | // Already declared in nsIDOMDocument |
michael@0 | 717 | |
michael@0 | 718 | /** |
michael@0 | 719 | * Set the Content-Type of this document. |
michael@0 | 720 | */ |
michael@0 | 721 | virtual void SetContentType(const nsAString& aContentType) MOZ_OVERRIDE; |
michael@0 | 722 | |
michael@0 | 723 | virtual nsresult SetBaseURI(nsIURI* aURI) MOZ_OVERRIDE; |
michael@0 | 724 | |
michael@0 | 725 | /** |
michael@0 | 726 | * Get/Set the base target of a link in a document. |
michael@0 | 727 | */ |
michael@0 | 728 | virtual void GetBaseTarget(nsAString &aBaseTarget) MOZ_OVERRIDE; |
michael@0 | 729 | |
michael@0 | 730 | /** |
michael@0 | 731 | * Return a standard name for the document's character set. This will |
michael@0 | 732 | * trigger a startDocumentLoad if necessary to answer the question. |
michael@0 | 733 | */ |
michael@0 | 734 | virtual void SetDocumentCharacterSet(const nsACString& aCharSetID) MOZ_OVERRIDE; |
michael@0 | 735 | |
michael@0 | 736 | /** |
michael@0 | 737 | * Add an observer that gets notified whenever the charset changes. |
michael@0 | 738 | */ |
michael@0 | 739 | virtual nsresult AddCharSetObserver(nsIObserver* aObserver) MOZ_OVERRIDE; |
michael@0 | 740 | |
michael@0 | 741 | /** |
michael@0 | 742 | * Remove a charset observer. |
michael@0 | 743 | */ |
michael@0 | 744 | virtual void RemoveCharSetObserver(nsIObserver* aObserver) MOZ_OVERRIDE; |
michael@0 | 745 | |
michael@0 | 746 | virtual Element* AddIDTargetObserver(nsIAtom* aID, IDTargetObserver aObserver, |
michael@0 | 747 | void* aData, bool aForImage) MOZ_OVERRIDE; |
michael@0 | 748 | virtual void RemoveIDTargetObserver(nsIAtom* aID, IDTargetObserver aObserver, |
michael@0 | 749 | void* aData, bool aForImage) MOZ_OVERRIDE; |
michael@0 | 750 | |
michael@0 | 751 | /** |
michael@0 | 752 | * Access HTTP header data (this may also get set from other sources, like |
michael@0 | 753 | * HTML META tags). |
michael@0 | 754 | */ |
michael@0 | 755 | virtual void GetHeaderData(nsIAtom* aHeaderField, nsAString& aData) const MOZ_OVERRIDE; |
michael@0 | 756 | virtual void SetHeaderData(nsIAtom* aheaderField, |
michael@0 | 757 | const nsAString& aData) MOZ_OVERRIDE; |
michael@0 | 758 | |
michael@0 | 759 | /** |
michael@0 | 760 | * Create a new presentation shell that will use aContext for |
michael@0 | 761 | * its presentation context (presentation contexts <b>must not</b> be |
michael@0 | 762 | * shared among multiple presentation shells). |
michael@0 | 763 | */ |
michael@0 | 764 | virtual already_AddRefed<nsIPresShell> CreateShell(nsPresContext* aContext, |
michael@0 | 765 | nsViewManager* aViewManager, |
michael@0 | 766 | nsStyleSet* aStyleSet) MOZ_OVERRIDE; |
michael@0 | 767 | virtual void DeleteShell() MOZ_OVERRIDE; |
michael@0 | 768 | |
michael@0 | 769 | virtual nsresult GetAllowPlugins(bool* aAllowPlugins) MOZ_OVERRIDE; |
michael@0 | 770 | |
michael@0 | 771 | virtual already_AddRefed<mozilla::dom::UndoManager> GetUndoManager() MOZ_OVERRIDE; |
michael@0 | 772 | |
michael@0 | 773 | virtual nsresult SetSubDocumentFor(Element* aContent, |
michael@0 | 774 | nsIDocument* aSubDoc) MOZ_OVERRIDE; |
michael@0 | 775 | virtual nsIDocument* GetSubDocumentFor(nsIContent* aContent) const MOZ_OVERRIDE; |
michael@0 | 776 | virtual Element* FindContentForSubDocument(nsIDocument *aDocument) const MOZ_OVERRIDE; |
michael@0 | 777 | virtual Element* GetRootElementInternal() const MOZ_OVERRIDE; |
michael@0 | 778 | |
michael@0 | 779 | /** |
michael@0 | 780 | * Get the style sheets owned by this document. |
michael@0 | 781 | * These are ordered, highest priority last |
michael@0 | 782 | */ |
michael@0 | 783 | virtual int32_t GetNumberOfStyleSheets() const MOZ_OVERRIDE; |
michael@0 | 784 | virtual nsIStyleSheet* GetStyleSheetAt(int32_t aIndex) const MOZ_OVERRIDE; |
michael@0 | 785 | virtual int32_t GetIndexOfStyleSheet(nsIStyleSheet* aSheet) const MOZ_OVERRIDE; |
michael@0 | 786 | virtual void AddStyleSheet(nsIStyleSheet* aSheet) MOZ_OVERRIDE; |
michael@0 | 787 | virtual void RemoveStyleSheet(nsIStyleSheet* aSheet) MOZ_OVERRIDE; |
michael@0 | 788 | |
michael@0 | 789 | virtual void UpdateStyleSheets(nsCOMArray<nsIStyleSheet>& aOldSheets, |
michael@0 | 790 | nsCOMArray<nsIStyleSheet>& aNewSheets) MOZ_OVERRIDE; |
michael@0 | 791 | virtual void AddStyleSheetToStyleSets(nsIStyleSheet* aSheet); |
michael@0 | 792 | virtual void RemoveStyleSheetFromStyleSets(nsIStyleSheet* aSheet); |
michael@0 | 793 | |
michael@0 | 794 | virtual void InsertStyleSheetAt(nsIStyleSheet* aSheet, int32_t aIndex) MOZ_OVERRIDE; |
michael@0 | 795 | virtual void SetStyleSheetApplicableState(nsIStyleSheet* aSheet, |
michael@0 | 796 | bool aApplicable) MOZ_OVERRIDE; |
michael@0 | 797 | |
michael@0 | 798 | virtual int32_t GetNumberOfCatalogStyleSheets() const MOZ_OVERRIDE; |
michael@0 | 799 | virtual nsIStyleSheet* GetCatalogStyleSheetAt(int32_t aIndex) const MOZ_OVERRIDE; |
michael@0 | 800 | virtual void AddCatalogStyleSheet(nsCSSStyleSheet* aSheet) MOZ_OVERRIDE; |
michael@0 | 801 | virtual void EnsureCatalogStyleSheet(const char *aStyleSheetURI) MOZ_OVERRIDE; |
michael@0 | 802 | |
michael@0 | 803 | virtual nsresult LoadAdditionalStyleSheet(additionalSheetType aType, nsIURI* aSheetURI) MOZ_OVERRIDE; |
michael@0 | 804 | virtual void RemoveAdditionalStyleSheet(additionalSheetType aType, nsIURI* sheetURI) MOZ_OVERRIDE; |
michael@0 | 805 | virtual nsIStyleSheet* FirstAdditionalAuthorSheet() MOZ_OVERRIDE; |
michael@0 | 806 | |
michael@0 | 807 | virtual nsIChannel* GetChannel() const MOZ_OVERRIDE { |
michael@0 | 808 | return mChannel; |
michael@0 | 809 | } |
michael@0 | 810 | |
michael@0 | 811 | virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject) MOZ_OVERRIDE; |
michael@0 | 812 | |
michael@0 | 813 | virtual void SetScriptHandlingObject(nsIScriptGlobalObject* aScriptObject) MOZ_OVERRIDE; |
michael@0 | 814 | |
michael@0 | 815 | virtual nsIGlobalObject* GetScopeObject() const MOZ_OVERRIDE; |
michael@0 | 816 | void SetScopeObject(nsIGlobalObject* aGlobal) MOZ_OVERRIDE; |
michael@0 | 817 | /** |
michael@0 | 818 | * Get the script loader for this document |
michael@0 | 819 | */ |
michael@0 | 820 | virtual nsScriptLoader* ScriptLoader() MOZ_OVERRIDE; |
michael@0 | 821 | |
michael@0 | 822 | /** |
michael@0 | 823 | * Add/Remove an element to the document's id and name hashes |
michael@0 | 824 | */ |
michael@0 | 825 | virtual void AddToIdTable(Element* aElement, nsIAtom* aId) MOZ_OVERRIDE; |
michael@0 | 826 | virtual void RemoveFromIdTable(Element* aElement, nsIAtom* aId) MOZ_OVERRIDE; |
michael@0 | 827 | virtual void AddToNameTable(Element* aElement, nsIAtom* aName) MOZ_OVERRIDE; |
michael@0 | 828 | virtual void RemoveFromNameTable(Element* aElement, nsIAtom* aName) MOZ_OVERRIDE; |
michael@0 | 829 | |
michael@0 | 830 | /** |
michael@0 | 831 | * Add a new observer of document change notifications. Whenever |
michael@0 | 832 | * content is changed, appended, inserted or removed the observers are |
michael@0 | 833 | * informed. |
michael@0 | 834 | */ |
michael@0 | 835 | virtual void AddObserver(nsIDocumentObserver* aObserver) MOZ_OVERRIDE; |
michael@0 | 836 | |
michael@0 | 837 | /** |
michael@0 | 838 | * Remove an observer of document change notifications. This will |
michael@0 | 839 | * return false if the observer cannot be found. |
michael@0 | 840 | */ |
michael@0 | 841 | virtual bool RemoveObserver(nsIDocumentObserver* aObserver) MOZ_OVERRIDE; |
michael@0 | 842 | |
michael@0 | 843 | // Observation hooks used to propagate notifications to document |
michael@0 | 844 | // observers. |
michael@0 | 845 | virtual void BeginUpdate(nsUpdateType aUpdateType) MOZ_OVERRIDE; |
michael@0 | 846 | virtual void EndUpdate(nsUpdateType aUpdateType) MOZ_OVERRIDE; |
michael@0 | 847 | virtual void BeginLoad() MOZ_OVERRIDE; |
michael@0 | 848 | virtual void EndLoad() MOZ_OVERRIDE; |
michael@0 | 849 | |
michael@0 | 850 | virtual void SetReadyStateInternal(ReadyState rs) MOZ_OVERRIDE; |
michael@0 | 851 | |
michael@0 | 852 | virtual void ContentStateChanged(nsIContent* aContent, |
michael@0 | 853 | mozilla::EventStates aStateMask) |
michael@0 | 854 | MOZ_OVERRIDE; |
michael@0 | 855 | virtual void DocumentStatesChanged( |
michael@0 | 856 | mozilla::EventStates aStateMask) MOZ_OVERRIDE; |
michael@0 | 857 | |
michael@0 | 858 | virtual void StyleRuleChanged(nsIStyleSheet* aStyleSheet, |
michael@0 | 859 | nsIStyleRule* aOldStyleRule, |
michael@0 | 860 | nsIStyleRule* aNewStyleRule) MOZ_OVERRIDE; |
michael@0 | 861 | virtual void StyleRuleAdded(nsIStyleSheet* aStyleSheet, |
michael@0 | 862 | nsIStyleRule* aStyleRule) MOZ_OVERRIDE; |
michael@0 | 863 | virtual void StyleRuleRemoved(nsIStyleSheet* aStyleSheet, |
michael@0 | 864 | nsIStyleRule* aStyleRule) MOZ_OVERRIDE; |
michael@0 | 865 | |
michael@0 | 866 | virtual void FlushPendingNotifications(mozFlushType aType) MOZ_OVERRIDE; |
michael@0 | 867 | virtual void FlushExternalResources(mozFlushType aType) MOZ_OVERRIDE; |
michael@0 | 868 | virtual void SetXMLDeclaration(const char16_t *aVersion, |
michael@0 | 869 | const char16_t *aEncoding, |
michael@0 | 870 | const int32_t aStandalone) MOZ_OVERRIDE; |
michael@0 | 871 | virtual void GetXMLDeclaration(nsAString& aVersion, |
michael@0 | 872 | nsAString& aEncoding, |
michael@0 | 873 | nsAString& Standalone) MOZ_OVERRIDE; |
michael@0 | 874 | virtual bool IsScriptEnabled() MOZ_OVERRIDE; |
michael@0 | 875 | |
michael@0 | 876 | virtual void OnPageShow(bool aPersisted, mozilla::dom::EventTarget* aDispatchStartTarget) MOZ_OVERRIDE; |
michael@0 | 877 | virtual void OnPageHide(bool aPersisted, mozilla::dom::EventTarget* aDispatchStartTarget) MOZ_OVERRIDE; |
michael@0 | 878 | |
michael@0 | 879 | virtual void WillDispatchMutationEvent(nsINode* aTarget) MOZ_OVERRIDE; |
michael@0 | 880 | virtual void MutationEventDispatched(nsINode* aTarget) MOZ_OVERRIDE; |
michael@0 | 881 | |
michael@0 | 882 | // nsINode |
michael@0 | 883 | virtual bool IsNodeOfType(uint32_t aFlags) const MOZ_OVERRIDE; |
michael@0 | 884 | virtual nsIContent *GetChildAt(uint32_t aIndex) const MOZ_OVERRIDE; |
michael@0 | 885 | virtual nsIContent * const * GetChildArray(uint32_t* aChildCount) const MOZ_OVERRIDE; |
michael@0 | 886 | virtual int32_t IndexOf(const nsINode* aPossibleChild) const MOZ_OVERRIDE; |
michael@0 | 887 | virtual uint32_t GetChildCount() const MOZ_OVERRIDE; |
michael@0 | 888 | virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex, |
michael@0 | 889 | bool aNotify) MOZ_OVERRIDE; |
michael@0 | 890 | virtual nsresult AppendChildTo(nsIContent* aKid, bool aNotify); |
michael@0 | 891 | virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) MOZ_OVERRIDE; |
michael@0 | 892 | virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE |
michael@0 | 893 | { |
michael@0 | 894 | return NS_ERROR_NOT_IMPLEMENTED; |
michael@0 | 895 | } |
michael@0 | 896 | |
michael@0 | 897 | // nsIRadioGroupContainer |
michael@0 | 898 | NS_IMETHOD WalkRadioGroup(const nsAString& aName, |
michael@0 | 899 | nsIRadioVisitor* aVisitor, |
michael@0 | 900 | bool aFlushContent) MOZ_OVERRIDE; |
michael@0 | 901 | virtual void |
michael@0 | 902 | SetCurrentRadioButton(const nsAString& aName, |
michael@0 | 903 | mozilla::dom::HTMLInputElement* aRadio) MOZ_OVERRIDE; |
michael@0 | 904 | virtual mozilla::dom::HTMLInputElement* |
michael@0 | 905 | GetCurrentRadioButton(const nsAString& aName) MOZ_OVERRIDE; |
michael@0 | 906 | NS_IMETHOD |
michael@0 | 907 | GetNextRadioButton(const nsAString& aName, |
michael@0 | 908 | const bool aPrevious, |
michael@0 | 909 | mozilla::dom::HTMLInputElement* aFocusedRadio, |
michael@0 | 910 | mozilla::dom::HTMLInputElement** aRadioOut) MOZ_OVERRIDE; |
michael@0 | 911 | virtual void AddToRadioGroup(const nsAString& aName, |
michael@0 | 912 | nsIFormControl* aRadio) MOZ_OVERRIDE; |
michael@0 | 913 | virtual void RemoveFromRadioGroup(const nsAString& aName, |
michael@0 | 914 | nsIFormControl* aRadio) MOZ_OVERRIDE; |
michael@0 | 915 | virtual uint32_t GetRequiredRadioCount(const nsAString& aName) const MOZ_OVERRIDE; |
michael@0 | 916 | virtual void RadioRequiredChanged(const nsAString& aName, |
michael@0 | 917 | nsIFormControl* aRadio) MOZ_OVERRIDE; |
michael@0 | 918 | virtual bool GetValueMissingState(const nsAString& aName) const MOZ_OVERRIDE; |
michael@0 | 919 | virtual void SetValueMissingState(const nsAString& aName, bool aValue) MOZ_OVERRIDE; |
michael@0 | 920 | |
michael@0 | 921 | // for radio group |
michael@0 | 922 | nsRadioGroupStruct* GetRadioGroup(const nsAString& aName) const; |
michael@0 | 923 | nsRadioGroupStruct* GetOrCreateRadioGroup(const nsAString& aName); |
michael@0 | 924 | |
michael@0 | 925 | virtual nsViewportInfo GetViewportInfo(const mozilla::ScreenIntSize& aDisplaySize) MOZ_OVERRIDE; |
michael@0 | 926 | |
michael@0 | 927 | private: |
michael@0 | 928 | nsRadioGroupStruct* GetRadioGroupInternal(const nsAString& aName) const; |
michael@0 | 929 | void SendToConsole(nsCOMArray<nsISecurityConsoleMessage>& aMessages); |
michael@0 | 930 | |
michael@0 | 931 | public: |
michael@0 | 932 | // nsIDOMNode |
michael@0 | 933 | NS_FORWARD_NSIDOMNODE_TO_NSINODE_OVERRIDABLE |
michael@0 | 934 | |
michael@0 | 935 | // nsIDOMDocument |
michael@0 | 936 | NS_DECL_NSIDOMDOCUMENT |
michael@0 | 937 | |
michael@0 | 938 | // nsIDOMXMLDocument |
michael@0 | 939 | NS_DECL_NSIDOMXMLDOCUMENT |
michael@0 | 940 | |
michael@0 | 941 | // nsIDOMDocumentXBL |
michael@0 | 942 | NS_DECL_NSIDOMDOCUMENTXBL |
michael@0 | 943 | |
michael@0 | 944 | // nsIDOMEventTarget |
michael@0 | 945 | virtual nsresult PreHandleEvent( |
michael@0 | 946 | mozilla::EventChainPreVisitor& aVisitor) MOZ_OVERRIDE; |
michael@0 | 947 | virtual mozilla::EventListenerManager* |
michael@0 | 948 | GetOrCreateListenerManager() MOZ_OVERRIDE; |
michael@0 | 949 | virtual mozilla::EventListenerManager* |
michael@0 | 950 | GetExistingListenerManager() const MOZ_OVERRIDE; |
michael@0 | 951 | |
michael@0 | 952 | // nsIScriptObjectPrincipal |
michael@0 | 953 | virtual nsIPrincipal* GetPrincipal() MOZ_OVERRIDE; |
michael@0 | 954 | |
michael@0 | 955 | // nsIApplicationCacheContainer |
michael@0 | 956 | NS_DECL_NSIAPPLICATIONCACHECONTAINER |
michael@0 | 957 | |
michael@0 | 958 | // nsIObserver |
michael@0 | 959 | NS_DECL_NSIOBSERVER |
michael@0 | 960 | |
michael@0 | 961 | NS_DECL_NSIDOMXPATHEVALUATOR |
michael@0 | 962 | |
michael@0 | 963 | virtual nsresult Init(); |
michael@0 | 964 | |
michael@0 | 965 | virtual nsresult CreateElem(const nsAString& aName, nsIAtom *aPrefix, |
michael@0 | 966 | int32_t aNamespaceID, |
michael@0 | 967 | nsIContent **aResult) MOZ_OVERRIDE; |
michael@0 | 968 | |
michael@0 | 969 | virtual NS_HIDDEN_(void) Sanitize(); |
michael@0 | 970 | |
michael@0 | 971 | virtual NS_HIDDEN_(void) EnumerateSubDocuments(nsSubDocEnumFunc aCallback, |
michael@0 | 972 | void *aData); |
michael@0 | 973 | |
michael@0 | 974 | virtual NS_HIDDEN_(bool) CanSavePresentation(nsIRequest *aNewRequest); |
michael@0 | 975 | virtual NS_HIDDEN_(void) Destroy(); |
michael@0 | 976 | virtual NS_HIDDEN_(void) RemovedFromDocShell(); |
michael@0 | 977 | virtual NS_HIDDEN_(already_AddRefed<nsILayoutHistoryState>) GetLayoutHistoryState() const; |
michael@0 | 978 | |
michael@0 | 979 | virtual NS_HIDDEN_(void) BlockOnload(); |
michael@0 | 980 | virtual NS_HIDDEN_(void) UnblockOnload(bool aFireSync); |
michael@0 | 981 | |
michael@0 | 982 | virtual NS_HIDDEN_(void) AddStyleRelevantLink(mozilla::dom::Link* aLink); |
michael@0 | 983 | virtual NS_HIDDEN_(void) ForgetLink(mozilla::dom::Link* aLink); |
michael@0 | 984 | |
michael@0 | 985 | NS_HIDDEN_(void) ClearBoxObjectFor(nsIContent* aContent); |
michael@0 | 986 | already_AddRefed<nsIBoxObject> GetBoxObjectFor(mozilla::dom::Element* aElement, |
michael@0 | 987 | mozilla::ErrorResult& aRv) MOZ_OVERRIDE; |
michael@0 | 988 | |
michael@0 | 989 | virtual NS_HIDDEN_(Element*) |
michael@0 | 990 | GetAnonymousElementByAttribute(nsIContent* aElement, |
michael@0 | 991 | nsIAtom* aAttrName, |
michael@0 | 992 | const nsAString& aAttrValue) const; |
michael@0 | 993 | |
michael@0 | 994 | virtual NS_HIDDEN_(Element*) ElementFromPointHelper(float aX, float aY, |
michael@0 | 995 | bool aIgnoreRootScrollFrame, |
michael@0 | 996 | bool aFlushLayout); |
michael@0 | 997 | |
michael@0 | 998 | virtual NS_HIDDEN_(nsresult) NodesFromRectHelper(float aX, float aY, |
michael@0 | 999 | float aTopSize, float aRightSize, |
michael@0 | 1000 | float aBottomSize, float aLeftSize, |
michael@0 | 1001 | bool aIgnoreRootScrollFrame, |
michael@0 | 1002 | bool aFlushLayout, |
michael@0 | 1003 | nsIDOMNodeList** aReturn); |
michael@0 | 1004 | |
michael@0 | 1005 | virtual NS_HIDDEN_(void) FlushSkinBindings(); |
michael@0 | 1006 | |
michael@0 | 1007 | virtual NS_HIDDEN_(nsresult) InitializeFrameLoader(nsFrameLoader* aLoader); |
michael@0 | 1008 | virtual NS_HIDDEN_(nsresult) FinalizeFrameLoader(nsFrameLoader* aLoader); |
michael@0 | 1009 | virtual NS_HIDDEN_(void) TryCancelFrameLoaderInitialization(nsIDocShell* aShell); |
michael@0 | 1010 | virtual NS_HIDDEN_(bool) FrameLoaderScheduledToBeFinalized(nsIDocShell* aShell); |
michael@0 | 1011 | virtual NS_HIDDEN_(nsIDocument*) |
michael@0 | 1012 | RequestExternalResource(nsIURI* aURI, |
michael@0 | 1013 | nsINode* aRequestingNode, |
michael@0 | 1014 | ExternalResourceLoad** aPendingLoad); |
michael@0 | 1015 | virtual NS_HIDDEN_(void) |
michael@0 | 1016 | EnumerateExternalResources(nsSubDocEnumFunc aCallback, void* aData); |
michael@0 | 1017 | |
michael@0 | 1018 | nsTArray<nsCString> mHostObjectURIs; |
michael@0 | 1019 | |
michael@0 | 1020 | // Returns our (lazily-initialized) animation controller. |
michael@0 | 1021 | // If HasAnimationController is true, this is guaranteed to return non-null. |
michael@0 | 1022 | nsSMILAnimationController* GetAnimationController() MOZ_OVERRIDE; |
michael@0 | 1023 | |
michael@0 | 1024 | void SetImagesNeedAnimating(bool aAnimating) MOZ_OVERRIDE; |
michael@0 | 1025 | |
michael@0 | 1026 | virtual void SuppressEventHandling(SuppressionType aWhat, |
michael@0 | 1027 | uint32_t aIncrease) MOZ_OVERRIDE; |
michael@0 | 1028 | |
michael@0 | 1029 | virtual void UnsuppressEventHandlingAndFireEvents(SuppressionType aWhat, |
michael@0 | 1030 | bool aFireEvents) MOZ_OVERRIDE; |
michael@0 | 1031 | |
michael@0 | 1032 | void DecreaseEventSuppression() { |
michael@0 | 1033 | MOZ_ASSERT(mEventsSuppressed); |
michael@0 | 1034 | --mEventsSuppressed; |
michael@0 | 1035 | MaybeRescheduleAnimationFrameNotifications(); |
michael@0 | 1036 | } |
michael@0 | 1037 | |
michael@0 | 1038 | void ResumeAnimations() { |
michael@0 | 1039 | MOZ_ASSERT(mAnimationsPaused); |
michael@0 | 1040 | --mAnimationsPaused; |
michael@0 | 1041 | MaybeRescheduleAnimationFrameNotifications(); |
michael@0 | 1042 | } |
michael@0 | 1043 | |
michael@0 | 1044 | virtual nsIDocument* GetTemplateContentsOwner() MOZ_OVERRIDE; |
michael@0 | 1045 | |
michael@0 | 1046 | NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsDocument, |
michael@0 | 1047 | nsIDocument) |
michael@0 | 1048 | |
michael@0 | 1049 | void DoNotifyPossibleTitleChange(); |
michael@0 | 1050 | |
michael@0 | 1051 | nsExternalResourceMap& ExternalResourceMap() |
michael@0 | 1052 | { |
michael@0 | 1053 | return mExternalResourceMap; |
michael@0 | 1054 | } |
michael@0 | 1055 | |
michael@0 | 1056 | void SetLoadedAsData(bool aLoadedAsData) { mLoadedAsData = aLoadedAsData; } |
michael@0 | 1057 | void SetLoadedAsInteractiveData(bool aLoadedAsInteractiveData) |
michael@0 | 1058 | { |
michael@0 | 1059 | mLoadedAsInteractiveData = aLoadedAsInteractiveData; |
michael@0 | 1060 | } |
michael@0 | 1061 | |
michael@0 | 1062 | nsresult CloneDocHelper(nsDocument* clone) const; |
michael@0 | 1063 | |
michael@0 | 1064 | void MaybeInitializeFinalizeFrameLoaders(); |
michael@0 | 1065 | |
michael@0 | 1066 | void MaybeEndOutermostXBLUpdate(); |
michael@0 | 1067 | |
michael@0 | 1068 | virtual void MaybePreLoadImage(nsIURI* uri, |
michael@0 | 1069 | const nsAString &aCrossOriginAttr) MOZ_OVERRIDE; |
michael@0 | 1070 | |
michael@0 | 1071 | virtual void PreloadStyle(nsIURI* uri, const nsAString& charset, |
michael@0 | 1072 | const nsAString& aCrossOriginAttr) MOZ_OVERRIDE; |
michael@0 | 1073 | |
michael@0 | 1074 | virtual nsresult LoadChromeSheetSync(nsIURI* uri, bool isAgentSheet, |
michael@0 | 1075 | nsCSSStyleSheet** sheet) MOZ_OVERRIDE; |
michael@0 | 1076 | |
michael@0 | 1077 | virtual nsISupports* GetCurrentContentSink() MOZ_OVERRIDE; |
michael@0 | 1078 | |
michael@0 | 1079 | virtual mozilla::EventStates GetDocumentState() MOZ_OVERRIDE; |
michael@0 | 1080 | |
michael@0 | 1081 | virtual void RegisterHostObjectUri(const nsACString& aUri) MOZ_OVERRIDE; |
michael@0 | 1082 | virtual void UnregisterHostObjectUri(const nsACString& aUri) MOZ_OVERRIDE; |
michael@0 | 1083 | |
michael@0 | 1084 | // Only BlockOnload should call this! |
michael@0 | 1085 | void AsyncBlockOnload(); |
michael@0 | 1086 | |
michael@0 | 1087 | virtual void SetScrollToRef(nsIURI *aDocumentURI) MOZ_OVERRIDE; |
michael@0 | 1088 | virtual void ScrollToRef() MOZ_OVERRIDE; |
michael@0 | 1089 | virtual void ResetScrolledToRefAlready() MOZ_OVERRIDE; |
michael@0 | 1090 | virtual void SetChangeScrollPosWhenScrollingToRef(bool aValue) MOZ_OVERRIDE; |
michael@0 | 1091 | |
michael@0 | 1092 | virtual Element *GetElementById(const nsAString& aElementId) MOZ_OVERRIDE; |
michael@0 | 1093 | virtual const nsSmallVoidArray* GetAllElementsForId(const nsAString& aElementId) const MOZ_OVERRIDE; |
michael@0 | 1094 | |
michael@0 | 1095 | virtual Element *LookupImageElement(const nsAString& aElementId) MOZ_OVERRIDE; |
michael@0 | 1096 | virtual void MozSetImageElement(const nsAString& aImageElementId, |
michael@0 | 1097 | Element* aElement) MOZ_OVERRIDE; |
michael@0 | 1098 | |
michael@0 | 1099 | virtual NS_HIDDEN_(nsresult) AddImage(imgIRequest* aImage); |
michael@0 | 1100 | virtual NS_HIDDEN_(nsresult) RemoveImage(imgIRequest* aImage, uint32_t aFlags); |
michael@0 | 1101 | virtual NS_HIDDEN_(nsresult) SetImageLockingState(bool aLocked); |
michael@0 | 1102 | |
michael@0 | 1103 | // AddPlugin adds a plugin-related element to mPlugins when the element is |
michael@0 | 1104 | // added to the tree. |
michael@0 | 1105 | virtual nsresult AddPlugin(nsIObjectLoadingContent* aPlugin) MOZ_OVERRIDE; |
michael@0 | 1106 | // RemovePlugin removes a plugin-related element to mPlugins when the |
michael@0 | 1107 | // element is removed from the tree. |
michael@0 | 1108 | virtual void RemovePlugin(nsIObjectLoadingContent* aPlugin) MOZ_OVERRIDE; |
michael@0 | 1109 | // GetPlugins returns the plugin-related elements from |
michael@0 | 1110 | // the frame and any subframes. |
michael@0 | 1111 | virtual void GetPlugins(nsTArray<nsIObjectLoadingContent*>& aPlugins) MOZ_OVERRIDE; |
michael@0 | 1112 | |
michael@0 | 1113 | virtual nsresult GetStateObject(nsIVariant** aResult) MOZ_OVERRIDE; |
michael@0 | 1114 | |
michael@0 | 1115 | virtual nsDOMNavigationTiming* GetNavigationTiming() const MOZ_OVERRIDE; |
michael@0 | 1116 | virtual nsresult SetNavigationTiming(nsDOMNavigationTiming* aTiming) MOZ_OVERRIDE; |
michael@0 | 1117 | |
michael@0 | 1118 | virtual Element* FindImageMap(const nsAString& aNormalizedMapName) MOZ_OVERRIDE; |
michael@0 | 1119 | |
michael@0 | 1120 | virtual Element* GetFullScreenElement() MOZ_OVERRIDE; |
michael@0 | 1121 | virtual void AsyncRequestFullScreen(Element* aElement) MOZ_OVERRIDE; |
michael@0 | 1122 | virtual void RestorePreviousFullScreenState() MOZ_OVERRIDE; |
michael@0 | 1123 | virtual bool IsFullscreenLeaf() MOZ_OVERRIDE; |
michael@0 | 1124 | virtual bool IsFullScreenDoc() MOZ_OVERRIDE; |
michael@0 | 1125 | virtual void SetApprovedForFullscreen(bool aIsApproved) MOZ_OVERRIDE; |
michael@0 | 1126 | virtual nsresult RemoteFrameFullscreenChanged(nsIDOMElement* aFrameElement, |
michael@0 | 1127 | const nsAString& aNewOrigin) MOZ_OVERRIDE; |
michael@0 | 1128 | |
michael@0 | 1129 | virtual nsresult RemoteFrameFullscreenReverted() MOZ_OVERRIDE; |
michael@0 | 1130 | virtual nsIDocument* GetFullscreenRoot() MOZ_OVERRIDE; |
michael@0 | 1131 | virtual void SetFullscreenRoot(nsIDocument* aRoot) MOZ_OVERRIDE; |
michael@0 | 1132 | |
michael@0 | 1133 | static void ExitFullscreen(nsIDocument* aDoc); |
michael@0 | 1134 | |
michael@0 | 1135 | // This is called asynchronously by nsIDocument::AsyncRequestFullScreen() |
michael@0 | 1136 | // to move this document into full-screen mode if allowed. aWasCallerChrome |
michael@0 | 1137 | // should be true when nsIDocument::AsyncRequestFullScreen() was called |
michael@0 | 1138 | // by chrome code. aNotifyOnOriginChange denotes whether we should send a |
michael@0 | 1139 | // fullscreen-origin-change notification if requesting fullscreen in this |
michael@0 | 1140 | // document causes the origin which is fullscreen to change. We may want to |
michael@0 | 1141 | // *not* send this notification if we're calling RequestFullscreen() as part |
michael@0 | 1142 | // of a continuation of a request in a subdocument, whereupon the caller will |
michael@0 | 1143 | // need to send the notification with the origin of the document which |
michael@0 | 1144 | // originally requested fullscreen, not *this* document's origin. |
michael@0 | 1145 | void RequestFullScreen(Element* aElement, |
michael@0 | 1146 | bool aWasCallerChrome, |
michael@0 | 1147 | bool aNotifyOnOriginChange); |
michael@0 | 1148 | |
michael@0 | 1149 | // Removes all elements from the full-screen stack, removing full-scren |
michael@0 | 1150 | // styles from the top element in the stack. |
michael@0 | 1151 | void CleanupFullscreenState(); |
michael@0 | 1152 | |
michael@0 | 1153 | // Add/remove "fullscreen-approved" observer service notification listener. |
michael@0 | 1154 | // Chrome sends us a notification when fullscreen is approved for a |
michael@0 | 1155 | // document, with the notification subject as the document that was approved. |
michael@0 | 1156 | // We maintain this listener while in fullscreen mode. |
michael@0 | 1157 | nsresult AddFullscreenApprovedObserver(); |
michael@0 | 1158 | nsresult RemoveFullscreenApprovedObserver(); |
michael@0 | 1159 | |
michael@0 | 1160 | // Pushes aElement onto the full-screen stack, and removes full-screen styles |
michael@0 | 1161 | // from the former full-screen stack top, and its ancestors, and applies the |
michael@0 | 1162 | // styles to aElement. aElement becomes the new "full-screen element". |
michael@0 | 1163 | bool FullScreenStackPush(Element* aElement); |
michael@0 | 1164 | |
michael@0 | 1165 | // Remove the top element from the full-screen stack. Removes the full-screen |
michael@0 | 1166 | // styles from the former top element, and applies them to the new top |
michael@0 | 1167 | // element, if there is one. |
michael@0 | 1168 | void FullScreenStackPop(); |
michael@0 | 1169 | |
michael@0 | 1170 | // Returns the top element from the full-screen stack. |
michael@0 | 1171 | Element* FullScreenStackTop(); |
michael@0 | 1172 | |
michael@0 | 1173 | // DOM-exposed fullscreen API |
michael@0 | 1174 | virtual bool MozFullScreenEnabled() MOZ_OVERRIDE; |
michael@0 | 1175 | virtual Element* GetMozFullScreenElement(mozilla::ErrorResult& rv) MOZ_OVERRIDE; |
michael@0 | 1176 | |
michael@0 | 1177 | void RequestPointerLock(Element* aElement) MOZ_OVERRIDE; |
michael@0 | 1178 | bool ShouldLockPointer(Element* aElement, Element* aCurrentLock, |
michael@0 | 1179 | bool aNoFocusCheck = false); |
michael@0 | 1180 | bool SetPointerLock(Element* aElement, int aCursorStyle); |
michael@0 | 1181 | static void UnlockPointer(nsIDocument* aDoc = nullptr); |
michael@0 | 1182 | |
michael@0 | 1183 | // This method may fire a DOM event; if it does so it will happen |
michael@0 | 1184 | // synchronously. |
michael@0 | 1185 | void UpdateVisibilityState(); |
michael@0 | 1186 | // Posts an event to call UpdateVisibilityState |
michael@0 | 1187 | virtual void PostVisibilityUpdateEvent() MOZ_OVERRIDE; |
michael@0 | 1188 | |
michael@0 | 1189 | virtual void DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const MOZ_OVERRIDE; |
michael@0 | 1190 | // DocAddSizeOfIncludingThis is inherited from nsIDocument. |
michael@0 | 1191 | |
michael@0 | 1192 | virtual nsIDOMNode* AsDOMNode() MOZ_OVERRIDE { return this; } |
michael@0 | 1193 | |
michael@0 | 1194 | virtual void EnqueueLifecycleCallback(nsIDocument::ElementCallbackType aType, |
michael@0 | 1195 | Element* aCustomElement, |
michael@0 | 1196 | mozilla::dom::LifecycleCallbackArgs* aArgs = nullptr, |
michael@0 | 1197 | mozilla::dom::CustomElementDefinition* aDefinition = nullptr) MOZ_OVERRIDE; |
michael@0 | 1198 | |
michael@0 | 1199 | static void ProcessTopElementQueue(bool aIsBaseQueue = false); |
michael@0 | 1200 | |
michael@0 | 1201 | void GetCustomPrototype(int32_t aNamespaceID, |
michael@0 | 1202 | nsIAtom* aAtom, |
michael@0 | 1203 | JS::MutableHandle<JSObject*> prototype) |
michael@0 | 1204 | { |
michael@0 | 1205 | if (!mRegistry) { |
michael@0 | 1206 | prototype.set(nullptr); |
michael@0 | 1207 | return; |
michael@0 | 1208 | } |
michael@0 | 1209 | |
michael@0 | 1210 | mozilla::dom::CustomElementHashKey key(aNamespaceID, aAtom); |
michael@0 | 1211 | mozilla::dom::CustomElementDefinition* definition; |
michael@0 | 1212 | if (mRegistry->mCustomDefinitions.Get(&key, &definition)) { |
michael@0 | 1213 | prototype.set(definition->mPrototype); |
michael@0 | 1214 | } else { |
michael@0 | 1215 | prototype.set(nullptr); |
michael@0 | 1216 | } |
michael@0 | 1217 | } |
michael@0 | 1218 | |
michael@0 | 1219 | static bool RegisterEnabled(); |
michael@0 | 1220 | |
michael@0 | 1221 | virtual nsresult RegisterUnresolvedElement(mozilla::dom::Element* aElement, |
michael@0 | 1222 | nsIAtom* aTypeName = nullptr) MOZ_OVERRIDE; |
michael@0 | 1223 | |
michael@0 | 1224 | // WebIDL bits |
michael@0 | 1225 | virtual mozilla::dom::DOMImplementation* |
michael@0 | 1226 | GetImplementation(mozilla::ErrorResult& rv) MOZ_OVERRIDE; |
michael@0 | 1227 | virtual void |
michael@0 | 1228 | RegisterElement(JSContext* aCx, const nsAString& aName, |
michael@0 | 1229 | const mozilla::dom::ElementRegistrationOptions& aOptions, |
michael@0 | 1230 | JS::MutableHandle<JSObject*> aRetval, |
michael@0 | 1231 | mozilla::ErrorResult& rv) MOZ_OVERRIDE; |
michael@0 | 1232 | virtual mozilla::dom::StyleSheetList* StyleSheets() MOZ_OVERRIDE; |
michael@0 | 1233 | virtual void SetSelectedStyleSheetSet(const nsAString& aSheetSet) MOZ_OVERRIDE; |
michael@0 | 1234 | virtual void GetLastStyleSheetSet(nsString& aSheetSet) MOZ_OVERRIDE; |
michael@0 | 1235 | virtual mozilla::dom::DOMStringList* StyleSheetSets() MOZ_OVERRIDE; |
michael@0 | 1236 | virtual void EnableStyleSheetsForSet(const nsAString& aSheetSet) MOZ_OVERRIDE; |
michael@0 | 1237 | using nsIDocument::CreateElement; |
michael@0 | 1238 | using nsIDocument::CreateElementNS; |
michael@0 | 1239 | virtual already_AddRefed<Element> CreateElement(const nsAString& aTagName, |
michael@0 | 1240 | const nsAString& aTypeExtension, |
michael@0 | 1241 | mozilla::ErrorResult& rv) MOZ_OVERRIDE; |
michael@0 | 1242 | virtual already_AddRefed<Element> CreateElementNS(const nsAString& aNamespaceURI, |
michael@0 | 1243 | const nsAString& aQualifiedName, |
michael@0 | 1244 | const nsAString& aTypeExtension, |
michael@0 | 1245 | mozilla::ErrorResult& rv) MOZ_OVERRIDE; |
michael@0 | 1246 | virtual void UseRegistryFromDocument(nsIDocument* aDocument) MOZ_OVERRIDE; |
michael@0 | 1247 | |
michael@0 | 1248 | virtual void UnblockDOMContentLoaded() MOZ_OVERRIDE; |
michael@0 | 1249 | |
michael@0 | 1250 | protected: |
michael@0 | 1251 | friend class nsNodeUtils; |
michael@0 | 1252 | friend class nsDocumentOnStack; |
michael@0 | 1253 | |
michael@0 | 1254 | void IncreaseStackRefCnt() |
michael@0 | 1255 | { |
michael@0 | 1256 | ++mStackRefCnt; |
michael@0 | 1257 | } |
michael@0 | 1258 | |
michael@0 | 1259 | void DecreaseStackRefCnt() |
michael@0 | 1260 | { |
michael@0 | 1261 | if (--mStackRefCnt == 0 && mNeedsReleaseAfterStackRefCntRelease) { |
michael@0 | 1262 | mNeedsReleaseAfterStackRefCntRelease = false; |
michael@0 | 1263 | NS_RELEASE_THIS(); |
michael@0 | 1264 | } |
michael@0 | 1265 | } |
michael@0 | 1266 | |
michael@0 | 1267 | // Returns true if a request for DOM full-screen is currently enabled in |
michael@0 | 1268 | // this document. This returns true if there are no windowed plugins in this |
michael@0 | 1269 | // doc tree, and if the document is visible, and if the api is not |
michael@0 | 1270 | // disabled by pref. aIsCallerChrome must contain the return value of |
michael@0 | 1271 | // nsContentUtils::IsCallerChrome() from the context we're checking. |
michael@0 | 1272 | // If aLogFailure is true, an appropriate warning message is logged to the |
michael@0 | 1273 | // console, and a "mozfullscreenerror" event is dispatched to this document. |
michael@0 | 1274 | bool IsFullScreenEnabled(bool aIsCallerChrome, bool aLogFailure); |
michael@0 | 1275 | |
michael@0 | 1276 | /** |
michael@0 | 1277 | * Check that aId is not empty and log a message to the console |
michael@0 | 1278 | * service if it is. |
michael@0 | 1279 | * @returns true if aId looks correct, false otherwise. |
michael@0 | 1280 | */ |
michael@0 | 1281 | inline bool CheckGetElementByIdArg(const nsAString& aId) |
michael@0 | 1282 | { |
michael@0 | 1283 | if (aId.IsEmpty()) { |
michael@0 | 1284 | ReportEmptyGetElementByIdArg(); |
michael@0 | 1285 | return false; |
michael@0 | 1286 | } |
michael@0 | 1287 | return true; |
michael@0 | 1288 | } |
michael@0 | 1289 | |
michael@0 | 1290 | void ReportEmptyGetElementByIdArg(); |
michael@0 | 1291 | |
michael@0 | 1292 | void DispatchContentLoadedEvents(); |
michael@0 | 1293 | |
michael@0 | 1294 | void RetrieveRelevantHeaders(nsIChannel *aChannel); |
michael@0 | 1295 | |
michael@0 | 1296 | void TryChannelCharset(nsIChannel *aChannel, |
michael@0 | 1297 | int32_t& aCharsetSource, |
michael@0 | 1298 | nsACString& aCharset, |
michael@0 | 1299 | nsHtml5TreeOpExecutor* aExecutor); |
michael@0 | 1300 | |
michael@0 | 1301 | // Call this before the document does something that will unbind all content. |
michael@0 | 1302 | // That will stop us from doing a lot of work as each element is removed. |
michael@0 | 1303 | void DestroyElementMaps(); |
michael@0 | 1304 | |
michael@0 | 1305 | // Refreshes the hrefs of all the links in the document. |
michael@0 | 1306 | void RefreshLinkHrefs(); |
michael@0 | 1307 | |
michael@0 | 1308 | nsIContent* GetFirstBaseNodeWithHref(); |
michael@0 | 1309 | nsresult SetFirstBaseNodeWithHref(nsIContent *node); |
michael@0 | 1310 | |
michael@0 | 1311 | // Get the first <title> element with the given IsNodeOfType type, or |
michael@0 | 1312 | // return null if there isn't one |
michael@0 | 1313 | nsIContent* GetTitleContent(uint32_t aNodeType); |
michael@0 | 1314 | // Find the first "title" element in the given IsNodeOfType type and |
michael@0 | 1315 | // append the concatenation of its text node children to aTitle. Do |
michael@0 | 1316 | // nothing if there is no such element. |
michael@0 | 1317 | void GetTitleFromElement(uint32_t aNodeType, nsAString& aTitle); |
michael@0 | 1318 | public: |
michael@0 | 1319 | // Get our title |
michael@0 | 1320 | virtual void GetTitle(nsString& aTitle) MOZ_OVERRIDE; |
michael@0 | 1321 | // Set our title |
michael@0 | 1322 | virtual void SetTitle(const nsAString& aTitle, mozilla::ErrorResult& rv) MOZ_OVERRIDE; |
michael@0 | 1323 | |
michael@0 | 1324 | static void XPCOMShutdown(); |
michael@0 | 1325 | |
michael@0 | 1326 | bool mIsTopLevelContentDocument:1; |
michael@0 | 1327 | |
michael@0 | 1328 | bool IsTopLevelContentDocument(); |
michael@0 | 1329 | |
michael@0 | 1330 | void SetIsTopLevelContentDocument(bool aIsTopLevelContentDocument); |
michael@0 | 1331 | |
michael@0 | 1332 | js::ExpandoAndGeneration mExpandoAndGeneration; |
michael@0 | 1333 | |
michael@0 | 1334 | protected: |
michael@0 | 1335 | already_AddRefed<nsIPresShell> doCreateShell(nsPresContext* aContext, |
michael@0 | 1336 | nsViewManager* aViewManager, |
michael@0 | 1337 | nsStyleSet* aStyleSet, |
michael@0 | 1338 | nsCompatibility aCompatMode); |
michael@0 | 1339 | |
michael@0 | 1340 | void RemoveDocStyleSheetsFromStyleSets(); |
michael@0 | 1341 | void RemoveStyleSheetsFromStyleSets(nsCOMArray<nsIStyleSheet>& aSheets, |
michael@0 | 1342 | nsStyleSet::sheetType aType); |
michael@0 | 1343 | void ResetStylesheetsToURI(nsIURI* aURI); |
michael@0 | 1344 | void FillStyleSet(nsStyleSet* aStyleSet); |
michael@0 | 1345 | |
michael@0 | 1346 | // Return whether all the presshells for this document are safe to flush |
michael@0 | 1347 | bool IsSafeToFlush() const; |
michael@0 | 1348 | |
michael@0 | 1349 | void DispatchPageTransition(mozilla::dom::EventTarget* aDispatchTarget, |
michael@0 | 1350 | const nsAString& aType, |
michael@0 | 1351 | bool aPersisted); |
michael@0 | 1352 | |
michael@0 | 1353 | virtual nsPIDOMWindow *GetWindowInternal() const MOZ_OVERRIDE; |
michael@0 | 1354 | virtual nsIScriptGlobalObject* GetScriptHandlingObjectInternal() const MOZ_OVERRIDE; |
michael@0 | 1355 | virtual bool InternalAllowXULXBL() MOZ_OVERRIDE; |
michael@0 | 1356 | |
michael@0 | 1357 | #define NS_DOCUMENT_NOTIFY_OBSERVERS(func_, params_) \ |
michael@0 | 1358 | NS_OBSERVER_ARRAY_NOTIFY_XPCOM_OBSERVERS(mObservers, nsIDocumentObserver, \ |
michael@0 | 1359 | func_, params_); |
michael@0 | 1360 | |
michael@0 | 1361 | #ifdef DEBUG |
michael@0 | 1362 | void VerifyRootContentState(); |
michael@0 | 1363 | #endif |
michael@0 | 1364 | |
michael@0 | 1365 | nsDocument(const char* aContentType); |
michael@0 | 1366 | virtual ~nsDocument(); |
michael@0 | 1367 | |
michael@0 | 1368 | void EnsureOnloadBlocker(); |
michael@0 | 1369 | |
michael@0 | 1370 | void NotifyStyleSheetApplicableStateChanged(); |
michael@0 | 1371 | |
michael@0 | 1372 | nsTArray<nsIObserver*> mCharSetObservers; |
michael@0 | 1373 | |
michael@0 | 1374 | PLDHashTable *mSubDocuments; |
michael@0 | 1375 | |
michael@0 | 1376 | // Array of owning references to all children |
michael@0 | 1377 | nsAttrAndChildArray mChildren; |
michael@0 | 1378 | |
michael@0 | 1379 | // Pointer to our parser if we're currently in the process of being |
michael@0 | 1380 | // parsed into. |
michael@0 | 1381 | nsCOMPtr<nsIParser> mParser; |
michael@0 | 1382 | |
michael@0 | 1383 | // Weak reference to our sink for in case we no longer have a parser. This |
michael@0 | 1384 | // will allow us to flush out any pending stuff from the sink even if |
michael@0 | 1385 | // EndLoad() has already happened. |
michael@0 | 1386 | nsWeakPtr mWeakSink; |
michael@0 | 1387 | |
michael@0 | 1388 | nsCOMArray<nsIStyleSheet> mStyleSheets; |
michael@0 | 1389 | nsCOMArray<nsIStyleSheet> mCatalogSheets; |
michael@0 | 1390 | nsCOMArray<nsIStyleSheet> mAdditionalSheets[SheetTypeCount]; |
michael@0 | 1391 | |
michael@0 | 1392 | // Array of observers |
michael@0 | 1393 | nsTObserverArray<nsIDocumentObserver*> mObservers; |
michael@0 | 1394 | |
michael@0 | 1395 | // Weak reference to the scope object (aka the script global object) |
michael@0 | 1396 | // that, unlike mScriptGlobalObject, is never unset once set. This |
michael@0 | 1397 | // is a weak reference to avoid leaks due to circular references. |
michael@0 | 1398 | nsWeakPtr mScopeObject; |
michael@0 | 1399 | |
michael@0 | 1400 | // Stack of full-screen elements. When we request full-screen we push the |
michael@0 | 1401 | // full-screen element onto this stack, and when we cancel full-screen we |
michael@0 | 1402 | // pop one off this stack, restoring the previous full-screen state |
michael@0 | 1403 | nsTArray<nsWeakPtr> mFullScreenStack; |
michael@0 | 1404 | |
michael@0 | 1405 | // The root of the doc tree in which this document is in. This is only |
michael@0 | 1406 | // non-null when this document is in fullscreen mode. |
michael@0 | 1407 | nsWeakPtr mFullscreenRoot; |
michael@0 | 1408 | |
michael@0 | 1409 | private: |
michael@0 | 1410 | // Array representing the processing stack in the custom elements |
michael@0 | 1411 | // specification. The processing stack is conceptually a stack of |
michael@0 | 1412 | // element queues. Each queue is represented by a sequence of |
michael@0 | 1413 | // CustomElementData in this array, separated by nullptr that |
michael@0 | 1414 | // represent the boundaries of the items in the stack. The first |
michael@0 | 1415 | // queue in the stack is the base element queue. |
michael@0 | 1416 | static mozilla::Maybe<nsTArray<mozilla::dom::CustomElementData*>> sProcessingStack; |
michael@0 | 1417 | |
michael@0 | 1418 | // Flag to prevent re-entrance into base element queue as described in the |
michael@0 | 1419 | // custom elements speicification. |
michael@0 | 1420 | static bool sProcessingBaseElementQueue; |
michael@0 | 1421 | |
michael@0 | 1422 | static bool CustomElementConstructor(JSContext* aCx, unsigned aArgc, JS::Value* aVp); |
michael@0 | 1423 | |
michael@0 | 1424 | public: |
michael@0 | 1425 | static void ProcessBaseElementQueue(); |
michael@0 | 1426 | |
michael@0 | 1427 | // Modify the prototype and "is" attribute of newly created custom elements. |
michael@0 | 1428 | virtual void SwizzleCustomElement(Element* aElement, |
michael@0 | 1429 | const nsAString& aTypeExtension, |
michael@0 | 1430 | uint32_t aNamespaceID, |
michael@0 | 1431 | mozilla::ErrorResult& rv); |
michael@0 | 1432 | |
michael@0 | 1433 | static bool IsRegisterElementEnabled(JSContext* aCx, JSObject* aObject); |
michael@0 | 1434 | |
michael@0 | 1435 | // The "registry" from the web components spec. |
michael@0 | 1436 | nsRefPtr<mozilla::dom::Registry> mRegistry; |
michael@0 | 1437 | |
michael@0 | 1438 | nsRefPtr<mozilla::EventListenerManager> mListenerManager; |
michael@0 | 1439 | nsRefPtr<mozilla::dom::StyleSheetList> mDOMStyleSheets; |
michael@0 | 1440 | nsRefPtr<nsDOMStyleSheetSetList> mStyleSheetSetList; |
michael@0 | 1441 | nsRefPtr<nsScriptLoader> mScriptLoader; |
michael@0 | 1442 | nsDocHeaderData* mHeaderData; |
michael@0 | 1443 | /* mIdentifierMap works as follows for IDs: |
michael@0 | 1444 | * 1) Attribute changes affect the table immediately (removing and adding |
michael@0 | 1445 | * entries as needed). |
michael@0 | 1446 | * 2) Removals from the DOM affect the table immediately |
michael@0 | 1447 | * 3) Additions to the DOM always update existing entries for names, and add |
michael@0 | 1448 | * new ones for IDs. |
michael@0 | 1449 | */ |
michael@0 | 1450 | nsTHashtable<nsIdentifierMapEntry> mIdentifierMap; |
michael@0 | 1451 | |
michael@0 | 1452 | nsClassHashtable<nsStringHashKey, nsRadioGroupStruct> mRadioGroups; |
michael@0 | 1453 | |
michael@0 | 1454 | // Recorded time of change to 'loading' state. |
michael@0 | 1455 | mozilla::TimeStamp mLoadingTimeStamp; |
michael@0 | 1456 | |
michael@0 | 1457 | // True if the document has been detached from its content viewer. |
michael@0 | 1458 | bool mIsGoingAway:1; |
michael@0 | 1459 | // True if the document is being destroyed. |
michael@0 | 1460 | bool mInDestructor:1; |
michael@0 | 1461 | |
michael@0 | 1462 | // True if this document has ever had an HTML or SVG <title> element |
michael@0 | 1463 | // bound to it |
michael@0 | 1464 | bool mMayHaveTitleElement:1; |
michael@0 | 1465 | |
michael@0 | 1466 | bool mHasWarnedAboutBoxObjects:1; |
michael@0 | 1467 | |
michael@0 | 1468 | bool mDelayFrameLoaderInitialization:1; |
michael@0 | 1469 | |
michael@0 | 1470 | bool mSynchronousDOMContentLoaded:1; |
michael@0 | 1471 | |
michael@0 | 1472 | bool mInXBLUpdate:1; |
michael@0 | 1473 | |
michael@0 | 1474 | // Whether we're currently holding a lock on all of our images. |
michael@0 | 1475 | bool mLockingImages:1; |
michael@0 | 1476 | |
michael@0 | 1477 | // Whether we currently require our images to animate |
michael@0 | 1478 | bool mAnimatingImages:1; |
michael@0 | 1479 | |
michael@0 | 1480 | // Whether we're currently under a FlushPendingNotifications call to |
michael@0 | 1481 | // our presshell. This is used to handle flush reentry correctly. |
michael@0 | 1482 | bool mInFlush:1; |
michael@0 | 1483 | |
michael@0 | 1484 | // Parser aborted. True if the parser of this document was forcibly |
michael@0 | 1485 | // terminated instead of letting it finish at its own pace. |
michael@0 | 1486 | bool mParserAborted:1; |
michael@0 | 1487 | |
michael@0 | 1488 | // Whether this document has been approved for fullscreen, either by explicit |
michael@0 | 1489 | // approval via the fullscreen-approval UI, or because it received |
michael@0 | 1490 | // approval because its document's host already had the "fullscreen" |
michael@0 | 1491 | // permission granted when the document requested fullscreen. |
michael@0 | 1492 | // |
michael@0 | 1493 | // Note if a document's principal doesn't have a host, the permission manager |
michael@0 | 1494 | // can't store permissions for it, so we can only manage approval using this |
michael@0 | 1495 | // flag. |
michael@0 | 1496 | // |
michael@0 | 1497 | // Note we must track this separately from the "fullscreen" permission, |
michael@0 | 1498 | // so that pending pointer lock requests can determine whether documents |
michael@0 | 1499 | // whose principal doesn't have a host (i.e. those which can't store |
michael@0 | 1500 | // permissions in the permission manager) have been approved for fullscreen. |
michael@0 | 1501 | bool mIsApprovedForFullscreen:1; |
michael@0 | 1502 | |
michael@0 | 1503 | // Whether this document has a fullscreen approved observer. Only documents |
michael@0 | 1504 | // which request fullscreen and which don't have a pre-existing approval for |
michael@0 | 1505 | // fullscreen will have an observer. |
michael@0 | 1506 | bool mHasFullscreenApprovedObserver:1; |
michael@0 | 1507 | |
michael@0 | 1508 | friend class nsPointerLockPermissionRequest; |
michael@0 | 1509 | friend class nsCallRequestFullScreen; |
michael@0 | 1510 | // When set, trying to lock the pointer doesn't require permission from the |
michael@0 | 1511 | // user. |
michael@0 | 1512 | bool mAllowRelocking:1; |
michael@0 | 1513 | |
michael@0 | 1514 | bool mAsyncFullscreenPending:1; |
michael@0 | 1515 | |
michael@0 | 1516 | // Keeps track of whether we have a pending |
michael@0 | 1517 | // 'style-sheet-applicable-state-changed' notification. |
michael@0 | 1518 | bool mSSApplicableStateNotificationPending:1; |
michael@0 | 1519 | |
michael@0 | 1520 | uint32_t mCancelledPointerLockRequests; |
michael@0 | 1521 | |
michael@0 | 1522 | uint8_t mXMLDeclarationBits; |
michael@0 | 1523 | |
michael@0 | 1524 | nsInterfaceHashtable<nsPtrHashKey<nsIContent>, nsPIBoxObject> *mBoxObjectTable; |
michael@0 | 1525 | |
michael@0 | 1526 | // A document "without a browsing context" that owns the content of |
michael@0 | 1527 | // HTMLTemplateElement. |
michael@0 | 1528 | nsCOMPtr<nsIDocument> mTemplateContentsOwner; |
michael@0 | 1529 | |
michael@0 | 1530 | // Our update nesting level |
michael@0 | 1531 | uint32_t mUpdateNestLevel; |
michael@0 | 1532 | |
michael@0 | 1533 | // The application cache that this document is associated with, if |
michael@0 | 1534 | // any. This can change during the lifetime of the document. |
michael@0 | 1535 | nsCOMPtr<nsIApplicationCache> mApplicationCache; |
michael@0 | 1536 | |
michael@0 | 1537 | nsCOMPtr<nsIContent> mFirstBaseNodeWithHref; |
michael@0 | 1538 | |
michael@0 | 1539 | mozilla::EventStates mDocumentState; |
michael@0 | 1540 | mozilla::EventStates mGotDocumentState; |
michael@0 | 1541 | |
michael@0 | 1542 | nsRefPtr<nsDOMNavigationTiming> mTiming; |
michael@0 | 1543 | private: |
michael@0 | 1544 | friend class nsUnblockOnloadEvent; |
michael@0 | 1545 | // Recomputes the visibility state but doesn't set the new value. |
michael@0 | 1546 | mozilla::dom::VisibilityState GetVisibilityState() const; |
michael@0 | 1547 | void NotifyStyleSheetAdded(nsIStyleSheet* aSheet, bool aDocumentSheet); |
michael@0 | 1548 | void NotifyStyleSheetRemoved(nsIStyleSheet* aSheet, bool aDocumentSheet); |
michael@0 | 1549 | |
michael@0 | 1550 | void PostUnblockOnloadEvent(); |
michael@0 | 1551 | void DoUnblockOnload(); |
michael@0 | 1552 | |
michael@0 | 1553 | nsresult CheckFrameOptions(); |
michael@0 | 1554 | nsresult InitCSP(nsIChannel* aChannel); |
michael@0 | 1555 | |
michael@0 | 1556 | void FlushCSPWebConsoleErrorQueue() |
michael@0 | 1557 | { |
michael@0 | 1558 | mCSPWebConsoleErrorQueue.Flush(this); |
michael@0 | 1559 | } |
michael@0 | 1560 | |
michael@0 | 1561 | /** |
michael@0 | 1562 | * Find the (non-anonymous) content in this document for aFrame. It will |
michael@0 | 1563 | * be aFrame's content node if that content is in this document and not |
michael@0 | 1564 | * anonymous. Otherwise, when aFrame is in a subdocument, we use the frame |
michael@0 | 1565 | * element containing the subdocument containing aFrame, and/or find the |
michael@0 | 1566 | * nearest non-anonymous ancestor in this document. |
michael@0 | 1567 | * Returns null if there is no such element. |
michael@0 | 1568 | */ |
michael@0 | 1569 | nsIContent* GetContentInThisDocument(nsIFrame* aFrame) const; |
michael@0 | 1570 | |
michael@0 | 1571 | // Just like EnableStyleSheetsForSet, but doesn't check whether |
michael@0 | 1572 | // aSheetSet is null and allows the caller to control whether to set |
michael@0 | 1573 | // aSheetSet as the preferred set in the CSSLoader. |
michael@0 | 1574 | void EnableStyleSheetsForSetInternal(const nsAString& aSheetSet, |
michael@0 | 1575 | bool aUpdateCSSLoader); |
michael@0 | 1576 | |
michael@0 | 1577 | // Revoke any pending notifications due to mozRequestAnimationFrame calls |
michael@0 | 1578 | void RevokeAnimationFrameNotifications(); |
michael@0 | 1579 | // Reschedule any notifications we need to handle |
michael@0 | 1580 | // mozRequestAnimationFrame, if it's OK to do so. |
michael@0 | 1581 | void MaybeRescheduleAnimationFrameNotifications(); |
michael@0 | 1582 | |
michael@0 | 1583 | // These are not implemented and not supported. |
michael@0 | 1584 | nsDocument(const nsDocument& aOther); |
michael@0 | 1585 | nsDocument& operator=(const nsDocument& aOther); |
michael@0 | 1586 | |
michael@0 | 1587 | // The layout history state that should be used by nodes in this |
michael@0 | 1588 | // document. We only actually store a pointer to it when: |
michael@0 | 1589 | // 1) We have no script global object. |
michael@0 | 1590 | // 2) We haven't had Destroy() called on us yet. |
michael@0 | 1591 | nsCOMPtr<nsILayoutHistoryState> mLayoutHistoryState; |
michael@0 | 1592 | |
michael@0 | 1593 | // Currently active onload blockers |
michael@0 | 1594 | uint32_t mOnloadBlockCount; |
michael@0 | 1595 | // Onload blockers which haven't been activated yet |
michael@0 | 1596 | uint32_t mAsyncOnloadBlockCount; |
michael@0 | 1597 | nsCOMPtr<nsIRequest> mOnloadBlocker; |
michael@0 | 1598 | |
michael@0 | 1599 | // A hashtable of styled links keyed by address pointer. |
michael@0 | 1600 | nsTHashtable<nsPtrHashKey<mozilla::dom::Link> > mStyledLinks; |
michael@0 | 1601 | #ifdef DEBUG |
michael@0 | 1602 | // Indicates whether mStyledLinks was cleared or not. This is used to track |
michael@0 | 1603 | // state so we can provide useful assertions to consumers of ForgetLink and |
michael@0 | 1604 | // AddStyleRelevantLink. |
michael@0 | 1605 | bool mStyledLinksCleared; |
michael@0 | 1606 | #endif |
michael@0 | 1607 | |
michael@0 | 1608 | // Member to store out last-selected stylesheet set. |
michael@0 | 1609 | nsString mLastStyleSheetSet; |
michael@0 | 1610 | |
michael@0 | 1611 | nsTArray<nsRefPtr<nsFrameLoader> > mInitializableFrameLoaders; |
michael@0 | 1612 | nsTArray<nsRefPtr<nsFrameLoader> > mFinalizableFrameLoaders; |
michael@0 | 1613 | nsRefPtr<nsRunnableMethod<nsDocument> > mFrameLoaderRunner; |
michael@0 | 1614 | |
michael@0 | 1615 | nsRevocableEventPtr<nsRunnableMethod<nsDocument, void, false> > |
michael@0 | 1616 | mPendingTitleChangeEvent; |
michael@0 | 1617 | |
michael@0 | 1618 | nsExternalResourceMap mExternalResourceMap; |
michael@0 | 1619 | |
michael@0 | 1620 | // All images in process of being preloaded |
michael@0 | 1621 | nsCOMArray<imgIRequest> mPreloadingImages; |
michael@0 | 1622 | |
michael@0 | 1623 | nsRefPtr<mozilla::dom::DOMImplementation> mDOMImplementation; |
michael@0 | 1624 | |
michael@0 | 1625 | nsRefPtr<nsContentList> mImageMaps; |
michael@0 | 1626 | |
michael@0 | 1627 | nsCString mScrollToRef; |
michael@0 | 1628 | uint8_t mScrolledToRefAlready : 1; |
michael@0 | 1629 | uint8_t mChangeScrollPosWhenScrollingToRef : 1; |
michael@0 | 1630 | |
michael@0 | 1631 | // Tracking for images in the document. |
michael@0 | 1632 | nsDataHashtable< nsPtrHashKey<imgIRequest>, uint32_t> mImageTracker; |
michael@0 | 1633 | |
michael@0 | 1634 | // Tracking for plugins in the document. |
michael@0 | 1635 | nsTHashtable< nsPtrHashKey<nsIObjectLoadingContent> > mPlugins; |
michael@0 | 1636 | |
michael@0 | 1637 | nsRefPtr<mozilla::dom::UndoManager> mUndoManager; |
michael@0 | 1638 | |
michael@0 | 1639 | enum ViewportType { |
michael@0 | 1640 | DisplayWidthHeight, |
michael@0 | 1641 | DisplayWidthHeightNoZoom, |
michael@0 | 1642 | Specified, |
michael@0 | 1643 | Unknown |
michael@0 | 1644 | }; |
michael@0 | 1645 | |
michael@0 | 1646 | ViewportType mViewportType; |
michael@0 | 1647 | |
michael@0 | 1648 | // These member variables cache information about the viewport so we don't have to |
michael@0 | 1649 | // recalculate it each time. |
michael@0 | 1650 | bool mValidWidth, mValidHeight; |
michael@0 | 1651 | mozilla::LayoutDeviceToScreenScale mScaleMinFloat; |
michael@0 | 1652 | mozilla::LayoutDeviceToScreenScale mScaleMaxFloat; |
michael@0 | 1653 | mozilla::LayoutDeviceToScreenScale mScaleFloat; |
michael@0 | 1654 | mozilla::CSSToLayoutDeviceScale mPixelRatio; |
michael@0 | 1655 | bool mAutoSize, mAllowZoom, mAllowDoubleTapZoom, mValidScaleFloat, mValidMaxScale, mScaleStrEmpty, mWidthStrEmpty; |
michael@0 | 1656 | mozilla::CSSIntSize mViewportSize; |
michael@0 | 1657 | |
michael@0 | 1658 | nsrefcnt mStackRefCnt; |
michael@0 | 1659 | bool mNeedsReleaseAfterStackRefCntRelease; |
michael@0 | 1660 | |
michael@0 | 1661 | CSPErrorQueue mCSPWebConsoleErrorQueue; |
michael@0 | 1662 | |
michael@0 | 1663 | #ifdef DEBUG |
michael@0 | 1664 | protected: |
michael@0 | 1665 | bool mWillReparent; |
michael@0 | 1666 | #endif |
michael@0 | 1667 | }; |
michael@0 | 1668 | |
michael@0 | 1669 | class nsDocumentOnStack |
michael@0 | 1670 | { |
michael@0 | 1671 | public: |
michael@0 | 1672 | nsDocumentOnStack(nsDocument* aDoc) : mDoc(aDoc) |
michael@0 | 1673 | { |
michael@0 | 1674 | mDoc->IncreaseStackRefCnt(); |
michael@0 | 1675 | } |
michael@0 | 1676 | ~nsDocumentOnStack() |
michael@0 | 1677 | { |
michael@0 | 1678 | mDoc->DecreaseStackRefCnt(); |
michael@0 | 1679 | } |
michael@0 | 1680 | private: |
michael@0 | 1681 | nsDocument* mDoc; |
michael@0 | 1682 | }; |
michael@0 | 1683 | |
michael@0 | 1684 | #endif /* nsDocument_h___ */ |