gecko-dev/dom/html/nsHTMLDocument.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

225 строки
7.6 KiB
C
Исходник Обычный вид История

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
2012-05-21 15:12:37 +04:00
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
1998-04-14 00:24:54 +04:00
#ifndef nsHTMLDocument_h___
#define nsHTMLDocument_h___
#include "mozilla/Attributes.h"
#include "nsContentList.h"
#include "mozilla/dom/Document.h"
1998-04-14 00:24:54 +04:00
#include "nsIHTMLDocument.h"
#include "nsIHTMLCollection.h"
#include "nsIScriptElement.h"
#include "nsTArray.h"
#include "PLDHashTable.h"
#include "nsIHttpChannel.h"
#include "nsThreadUtils.h"
#include "mozilla/dom/HTMLSharedElement.h"
#include "mozilla/dom/BindingDeclarations.h"
class nsCommandManager;
class nsIURI;
class nsIDocShell;
class nsICachingChannel;
class nsILoadGroup;
1998-04-14 00:24:54 +04:00
namespace mozilla {
namespace dom {
class HTMLAllCollection;
template <typename T>
struct Nullable;
class WindowProxyHolder;
} // namespace dom
} // namespace mozilla
class nsHTMLDocument : public mozilla::dom::Document, public nsIHTMLDocument {
protected:
typedef mozilla::net::ReferrerPolicy ReferrerPolicy;
typedef mozilla::dom::Document Document;
typedef mozilla::Encoding Encoding;
template <typename T>
using NotNull = mozilla::NotNull<T>;
1998-04-14 00:24:54 +04:00
public:
using Document::GetPlugins;
using Document::SetDocumentURI;
nsHTMLDocument();
virtual nsresult Init() override;
1998-04-14 00:24:54 +04:00
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsHTMLDocument, Document)
// Document
virtual void Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) override;
virtual void ResetToURI(nsIURI* aURI, nsILoadGroup* aLoadGroup,
nsIPrincipal* aPrincipal,
nsIPrincipal* aStoragePrincipal) override;
virtual nsresult StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
nsILoadGroup* aLoadGroup,
nsISupports* aContainer,
nsIStreamListener** aDocListener,
bool aReset = true,
nsIContentSink* aSink = nullptr) override;
1998-04-14 00:24:54 +04:00
protected:
virtual bool UseWidthDeviceWidthFallbackViewport() const override;
public:
// nsIHTMLDocument
virtual Element* GetUnfocusedKeyEventTarget() override;
nsContentList* GetExistingForms() const { return mForms; }
mozilla::dom::HTMLAllCollection* All();
// Returns whether an object was found for aName.
bool ResolveName(JSContext* aCx, const nsAString& aName,
JS::MutableHandle<JS::Value> aRetval,
mozilla::ErrorResult& aError);
virtual void AddedForm() override;
virtual void RemovedForm() override;
virtual int32_t GetNumFormsSynchronous() override;
void SetIsXHTML(bool aXHTML) { mType = (aXHTML ? eXHTML : eHTML); }
virtual nsresult Clone(mozilla::dom::NodeInfo*,
nsINode** aResult) const override;
using mozilla::dom::DocumentOrShadowRoot::GetElementById;
virtual void DocAddSizeOfExcludingThis(
nsWindowSizes& aWindowSizes) const override;
// DocAddSizeOfIncludingThis is inherited from Document.
virtual bool WillIgnoreCharsetOverride() override;
// WebIDL API
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv The only manual changes here are to BindingUtils.h, BindingUtils.cpp, Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp, dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp, Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp, Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The rest of this diff was generated by running the following commands: find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g' find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g' find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g' find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g' find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g' find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
virtual JSObject* WrapNode(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
bool IsRegistrableDomainSuffixOfOrEqualTo(const nsAString& aHostSuffixString,
const nsACString& aOrigHost);
void NamedGetter(JSContext* cx, const nsAString& aName, bool& aFound,
JS::MutableHandle<JSObject*> aRetval,
mozilla::ErrorResult& rv) {
JS::Rooted<JS::Value> v(cx);
if ((aFound = ResolveName(cx, aName, &v, rv))) {
aRetval.set(v.toObjectOrNull());
}
}
void GetSupportedNames(nsTArray<nsString>& aNames);
void GetFgColor(nsAString& aFgColor);
void SetFgColor(const nsAString& aFgColor);
void GetLinkColor(nsAString& aLinkColor);
void SetLinkColor(const nsAString& aLinkColor);
void GetVlinkColor(nsAString& aAvlinkColor);
void SetVlinkColor(const nsAString& aVlinkColor);
void GetAlinkColor(nsAString& aAlinkColor);
void SetAlinkColor(const nsAString& aAlinkColor);
void GetBgColor(nsAString& aBgColor);
void SetBgColor(const nsAString& aBgColor);
void Clear() const {
// Deprecated
}
void CaptureEvents();
void ReleaseEvents();
// We're picking up GetLocation from Document
already_AddRefed<mozilla::dom::Location> GetLocation() const {
return Document::GetLocation();
}
static bool MatchFormControls(Element* aElement, int32_t aNamespaceID,
nsAtom* aAtom, void* aData);
void GetFormsAndFormControls(nsContentList** aFormList,
nsContentList** aFormControlList);
void UserInteractionForTesting();
protected:
~nsHTMLDocument();
nsresult GetBodySize(int32_t* aWidth, int32_t* aHeight);
nsIContent* MatchId(nsIContent* aContent, const nsAString& aId);
static void DocumentWriteTerminationFunc(nsISupports* aRef);
// A helper class to keep nsContentList objects alive for a short period of
// time. Note, when the final Release is called on an nsContentList object, it
// removes itself from MutationObserver list.
class ContentListHolder : public mozilla::Runnable {
public:
ContentListHolder(nsHTMLDocument* aDocument, nsContentList* aFormList,
nsContentList* aFormControlList)
: mozilla::Runnable("ContentListHolder"),
mDocument(aDocument),
mFormList(aFormList),
mFormControlList(aFormControlList) {}
~ContentListHolder() {
MOZ_ASSERT(!mDocument->mContentListHolder ||
mDocument->mContentListHolder == this);
mDocument->mContentListHolder = nullptr;
}
RefPtr<nsHTMLDocument> mDocument;
RefPtr<nsContentList> mFormList;
RefPtr<nsContentList> mFormControlList;
};
friend class ContentListHolder;
ContentListHolder* mContentListHolder;
Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat The bulk of this commit was generated with a script, executed at the top level of a typical source code checkout. The only non-machine-generated part was modifying MFBT's moz.build to reflect the new naming. CLOSED TREE makes big refactorings like this a piece of cake. # The main substitution. find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \ xargs perl -p -i -e ' s/nsRefPtr\.h/RefPtr\.h/g; # handle includes s/nsRefPtr ?</RefPtr</g; # handle declarations and variables ' # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h. perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h # Handle nsRefPtr.h itself, a couple places that define constructors # from nsRefPtr, and code generators specially. We do this here, rather # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename # things like nsRefPtrHashtable. perl -p -i -e 's/nsRefPtr/RefPtr/g' \ mfbt/nsRefPtr.h \ xpcom/glue/nsCOMPtr.h \ xpcom/base/OwningNonNull.h \ ipc/ipdl/ipdl/lower.py \ ipc/ipdl/ipdl/builtin.py \ dom/bindings/Codegen.py \ python/lldbutils/lldbutils/utils.py # In our indiscriminate substitution above, we renamed # nsRefPtrGetterAddRefs, the class behind getter_AddRefs. Fix that up. find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \ xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g' if [ -d .git ]; then git mv mfbt/nsRefPtr.h mfbt/RefPtr.h else hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h fi --HG-- rename : mfbt/nsRefPtr.h => mfbt/RefPtr.h
2015-10-18 08:24:48 +03:00
RefPtr<mozilla::dom::HTMLAllCollection> mAll;
/** # of forms in the document, synchronously set */
int32_t mNumForms;
static void TryHintCharset(nsIContentViewer* aContentViewer,
int32_t& aCharsetSource,
NotNull<const Encoding*>& aEncoding);
void TryUserForcedCharset(nsIContentViewer* aCv, nsIDocShell* aDocShell,
int32_t& aCharsetSource,
NotNull<const Encoding*>& aEncoding);
static void TryCacheCharset(nsICachingChannel* aCachingChannel,
int32_t& aCharsetSource,
NotNull<const Encoding*>& aEncoding);
void TryParentCharset(nsIDocShell* aDocShell, int32_t& charsetSource,
NotNull<const Encoding*>& aEncoding);
void TryTLD(int32_t& aCharsetSource, NotNull<const Encoding*>& aCharset);
static void TryFallback(int32_t& aCharsetSource,
NotNull<const Encoding*>& aEncoding);
// Load flags of the document's channel
uint32_t mLoadFlags;
bool mWarnedWidthHeight;
/**
* Set to true once we know that we are loading plain text content.
*/
bool mIsPlainText;
1998-04-14 00:24:54 +04:00
};
namespace mozilla {
namespace dom {
inline nsHTMLDocument* Document::AsHTMLDocument() {
MOZ_ASSERT(IsHTMLOrXHTML());
return static_cast<nsHTMLDocument*>(this);
}
} // namespace dom
} // namespace mozilla
#define NS_HTML_DOCUMENT_INTERFACE_TABLE_BEGIN(_class) \
NS_DOCUMENT_INTERFACE_TABLE_BEGIN(_class) \
NS_INTERFACE_TABLE_ENTRY(_class, nsIHTMLDocument)
1998-04-14 00:24:54 +04:00
#endif /* nsHTMLDocument_h___ */