mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
e8f234939e
- Bug 967494 - "Preference Composition/Spelling/Language is ignored, and changing spellcheck language in one composition window affects all open and new compositions" [r=ehsan] Bug 1157421 - Fix typo "suggesteed". r=ehsan (d48b61df9) - namespaces (c9e3edbf1) - Bug 1167409 - 3/4 - Change ScriptLoadRequeest::mLoading to mProgress. r=jandem (34377ba15) - Bug 1104732 - having deferred scripts shouldn't cause async scripts to delay domcontentloaded, r?smaug (f6b3a5ad9) - Bug 1138395 - Optimize nsDocument::mExpandoAndGeneration.expando out from the cc graphs when possible, r=mccr8 (d944130ab) - Bug 874838 - Make CreateElem return Element. r=khuey (ac65a35cf) - Bug 1194619 - fix comment r=dholbert (017a488a2) - Bug 1137494 - Change the type given to type validation check. r=jgilbert (05885cc7c) - Bug 1106138 - Remove the early unpremultiply in WebGLContext::SurfaceFromElementResultToImageSurface, and let the texel conversion code handle it instead. r=jgilbert (b8010b16b) - Bug 1185815 - Hoist generation increment. r=jgilbert (f6a276b5e) - Bug 1175931 - TexImageFromVideoElement uses GL_HALF_FLOAT if it does not support GL_HALF_FLOAT_OES which would be the case on non-ANGLE systems. Using GL_HALF_FLOAT_OES on a non OES system would result in an error when using TexImage2D. r=jgilbert (d692281f1) - Bug 1184534 - Add support for target size retrieval to GLX backend. r=jgilbert (0e5ba1f8e) - bug 1174705 - add GLContext::GetDefaultFramebuffer. r=jgilbert (99c0e70aa) - Bug 1179935, introduce complex viewport projections to Compositor, remove PrepareViewport; r=mstange (1753d65d3) - Bug 1184534 - Fetch viewport size from context in CompositorOGL, discard if changed during composition. r=nical (4f57bc4ed) - Bug 1187440 - Implement GLX shared surfaces on the OpenGL compositor. r=jgilbert,nical (4844e96ce) - Bug 1033375 - Nudge simple linear gradients with hard stops to half-pixel gradient. r=nical (331ddd4fa) - Bug 1185636 - Remove hard stop workaround for Cairo due to regressions. r=jrmuizel (ccefe7abc) - Bug 1177807 - Mark cairo surface dirty in ReleaseBits. r=jrmuizel (ae9d508b9) - Bug 1170390 - Detect 16bpp cairo xlib surface format. r=jrmuizel (25857ae30) - Bug 1019063 - Check for ::CreateDCW failing when printing. r=dvander (7f54ba8d2) - Bug 1170390 - Add gfxASurface::GetSurfaceFormat for retrieving precise surface format where necessary. r=jrmuizel (f70d11b29) - Bug 1155626 - Don't assume that Factory::GetD2D1Device returns a non-null device and add some gfxCriticalLog. r=Bas (0c896a368) - Bug 1182209 - Additional info with some critical errors. r=mchang CLOSED TREE (f4841baec)
275 lines
9.4 KiB
C++
275 lines
9.4 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: */
|
|
/* 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/. */
|
|
|
|
#include "mozilla/dom/DOMImplementation.h"
|
|
|
|
#include "mozilla/ContentEvents.h"
|
|
#include "mozilla/dom/DOMImplementationBinding.h"
|
|
#include "nsContentCreatorFunctions.h"
|
|
#include "nsContentUtils.h"
|
|
#include "nsDOMClassInfoID.h"
|
|
#include "nsIDOMDocument.h"
|
|
#include "DocumentType.h"
|
|
#include "nsTextNode.h"
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
// QueryInterface implementation for DOMImplementation
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMImplementation)
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMDOMImplementation)
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
NS_INTERFACE_MAP_END
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMImplementation, mOwner)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMImplementation)
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMImplementation)
|
|
|
|
JSObject*
|
|
DOMImplementation::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|
{
|
|
return DOMImplementationBinding::Wrap(aCx, this, aGivenProto);
|
|
}
|
|
|
|
bool
|
|
DOMImplementation::HasFeature(const nsAString& aFeature,
|
|
const nsAString& aVersion)
|
|
{
|
|
return nsContentUtils::InternalIsSupported(
|
|
static_cast<nsIDOMDOMImplementation*>(this),
|
|
aFeature, aVersion);
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
DOMImplementation::HasFeature(const nsAString& aFeature,
|
|
const nsAString& aVersion,
|
|
bool* aReturn)
|
|
{
|
|
*aReturn = HasFeature(aFeature, aVersion);
|
|
return NS_OK;
|
|
}
|
|
|
|
already_AddRefed<DocumentType>
|
|
DOMImplementation::CreateDocumentType(const nsAString& aQualifiedName,
|
|
const nsAString& aPublicId,
|
|
const nsAString& aSystemId,
|
|
ErrorResult& aRv)
|
|
{
|
|
if (!mOwner) {
|
|
aRv.Throw(NS_ERROR_UNEXPECTED);
|
|
return nullptr;
|
|
}
|
|
|
|
aRv = nsContentUtils::CheckQName(aQualifiedName);
|
|
if (aRv.Failed()) {
|
|
return nullptr;
|
|
}
|
|
|
|
nsCOMPtr<nsIAtom> name = do_GetAtom(aQualifiedName);
|
|
if (!name) {
|
|
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
|
return nullptr;
|
|
}
|
|
|
|
// Indicate that there is no internal subset (not just an empty one)
|
|
nsRefPtr<DocumentType> docType =
|
|
NS_NewDOMDocumentType(mOwner->NodeInfoManager(), name, aPublicId,
|
|
aSystemId, NullString(), aRv);
|
|
return docType.forget();
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
DOMImplementation::CreateDocumentType(const nsAString& aQualifiedName,
|
|
const nsAString& aPublicId,
|
|
const nsAString& aSystemId,
|
|
nsIDOMDocumentType** aReturn)
|
|
{
|
|
ErrorResult rv;
|
|
*aReturn =
|
|
CreateDocumentType(aQualifiedName, aPublicId, aSystemId, rv).take();
|
|
return rv.StealNSResult();
|
|
}
|
|
|
|
nsresult
|
|
DOMImplementation::CreateDocument(const nsAString& aNamespaceURI,
|
|
const nsAString& aQualifiedName,
|
|
nsIDOMDocumentType* aDoctype,
|
|
nsIDocument** aDocument,
|
|
nsIDOMDocument** aDOMDocument)
|
|
{
|
|
*aDocument = nullptr;
|
|
*aDOMDocument = nullptr;
|
|
|
|
nsresult rv;
|
|
if (!aQualifiedName.IsEmpty()) {
|
|
const nsAFlatString& qName = PromiseFlatString(aQualifiedName);
|
|
const char16_t *colon;
|
|
rv = nsContentUtils::CheckQName(qName, true, &colon);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
if (colon &&
|
|
(DOMStringIsNull(aNamespaceURI) ||
|
|
(Substring(qName.get(), colon).EqualsLiteral("xml") &&
|
|
!aNamespaceURI.EqualsLiteral("http://www.w3.org/XML/1998/namespace")))) {
|
|
return NS_ERROR_DOM_NAMESPACE_ERR;
|
|
}
|
|
}
|
|
|
|
nsCOMPtr<nsIGlobalObject> scriptHandlingObject =
|
|
do_QueryReferent(mScriptObject);
|
|
|
|
NS_ENSURE_STATE(!mScriptObject || scriptHandlingObject);
|
|
|
|
nsCOMPtr<nsIDOMDocument> document;
|
|
|
|
rv = NS_NewDOMDocument(getter_AddRefs(document),
|
|
aNamespaceURI, aQualifiedName, aDoctype,
|
|
mDocumentURI, mBaseURI,
|
|
mOwner->NodePrincipal(),
|
|
true, scriptHandlingObject,
|
|
DocumentFlavorLegacyGuess);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
// When DOMImplementation's createDocument method is invoked with
|
|
// namespace set to HTML Namespace use the registry of the associated
|
|
// document to the new instance.
|
|
nsCOMPtr<nsIDocument> doc = do_QueryInterface(document);
|
|
if (aNamespaceURI.EqualsLiteral("http://www.w3.org/1999/xhtml")) {
|
|
doc->UseRegistryFromDocument(mOwner);
|
|
}
|
|
|
|
doc->SetReadyStateInternal(nsIDocument::READYSTATE_COMPLETE);
|
|
|
|
doc.forget(aDocument);
|
|
document.forget(aDOMDocument);
|
|
return NS_OK;
|
|
}
|
|
|
|
already_AddRefed<nsIDocument>
|
|
DOMImplementation::CreateDocument(const nsAString& aNamespaceURI,
|
|
const nsAString& aQualifiedName,
|
|
nsIDOMDocumentType* aDoctype,
|
|
ErrorResult& aRv)
|
|
{
|
|
nsCOMPtr<nsIDocument> document;
|
|
nsCOMPtr<nsIDOMDocument> domDocument;
|
|
aRv = CreateDocument(aNamespaceURI, aQualifiedName, aDoctype,
|
|
getter_AddRefs(document), getter_AddRefs(domDocument));
|
|
return document.forget();
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
DOMImplementation::CreateDocument(const nsAString& aNamespaceURI,
|
|
const nsAString& aQualifiedName,
|
|
nsIDOMDocumentType* aDoctype,
|
|
nsIDOMDocument** aReturn)
|
|
{
|
|
nsCOMPtr<nsIDocument> document;
|
|
return CreateDocument(aNamespaceURI, aQualifiedName, aDoctype,
|
|
getter_AddRefs(document), aReturn);
|
|
}
|
|
|
|
nsresult
|
|
DOMImplementation::CreateHTMLDocument(const nsAString& aTitle,
|
|
nsIDocument** aDocument,
|
|
nsIDOMDocument** aDOMDocument)
|
|
{
|
|
*aDocument = nullptr;
|
|
*aDOMDocument = nullptr;
|
|
|
|
NS_ENSURE_STATE(mOwner);
|
|
|
|
nsCOMPtr<nsIDOMDocumentType> doctype;
|
|
// Indicate that there is no internal subset (not just an empty one)
|
|
nsresult rv = NS_NewDOMDocumentType(getter_AddRefs(doctype),
|
|
mOwner->NodeInfoManager(),
|
|
nsGkAtoms::html, // aName
|
|
EmptyString(), // aPublicId
|
|
EmptyString(), // aSystemId
|
|
NullString()); // aInternalSubset
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
nsCOMPtr<nsIGlobalObject> scriptHandlingObject =
|
|
do_QueryReferent(mScriptObject);
|
|
|
|
NS_ENSURE_STATE(!mScriptObject || scriptHandlingObject);
|
|
|
|
nsCOMPtr<nsIDOMDocument> document;
|
|
rv = NS_NewDOMDocument(getter_AddRefs(document),
|
|
EmptyString(), EmptyString(),
|
|
doctype, mDocumentURI, mBaseURI,
|
|
mOwner->NodePrincipal(),
|
|
true, scriptHandlingObject,
|
|
DocumentFlavorLegacyGuess);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
nsCOMPtr<nsIDocument> doc = do_QueryInterface(document);
|
|
|
|
nsCOMPtr<Element> root = doc->CreateElem(NS_LITERAL_STRING("html"), nullptr,
|
|
kNameSpaceID_XHTML);
|
|
rv = doc->AppendChildTo(root, false);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
nsCOMPtr<Element> head = doc->CreateElem(NS_LITERAL_STRING("head"), nullptr,
|
|
kNameSpaceID_XHTML);
|
|
rv = root->AppendChildTo(head, false);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
if (!DOMStringIsNull(aTitle)) {
|
|
nsCOMPtr<Element> title = doc->CreateElem(NS_LITERAL_STRING("title"),
|
|
nullptr, kNameSpaceID_XHTML);
|
|
rv = head->AppendChildTo(title, false);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
nsRefPtr<nsTextNode> titleText = new nsTextNode(doc->NodeInfoManager());
|
|
rv = titleText->SetText(aTitle, false);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
rv = title->AppendChildTo(titleText, false);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
}
|
|
|
|
nsCOMPtr<Element> body = doc->CreateElem(NS_LITERAL_STRING("body"), nullptr,
|
|
kNameSpaceID_XHTML);
|
|
rv = root->AppendChildTo(body, false);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
// When the createHTMLDocument method is invoked,
|
|
// use the registry of the associated document to the new instance.
|
|
doc->UseRegistryFromDocument(mOwner);
|
|
|
|
doc->SetReadyStateInternal(nsIDocument::READYSTATE_COMPLETE);
|
|
|
|
doc.forget(aDocument);
|
|
document.forget(aDOMDocument);
|
|
return NS_OK;
|
|
}
|
|
|
|
already_AddRefed<nsIDocument>
|
|
DOMImplementation::CreateHTMLDocument(const Optional<nsAString>& aTitle,
|
|
ErrorResult& aRv)
|
|
{
|
|
nsCOMPtr<nsIDocument> document;
|
|
nsCOMPtr<nsIDOMDocument> domDocument;
|
|
aRv = CreateHTMLDocument(aTitle.WasPassed() ? aTitle.Value()
|
|
: NullString(),
|
|
getter_AddRefs(document),
|
|
getter_AddRefs(domDocument));
|
|
return document.forget();
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
DOMImplementation::CreateHTMLDocument(const nsAString& aTitle,
|
|
nsIDOMDocument** aReturn)
|
|
{
|
|
nsCOMPtr<nsIDocument> document;
|
|
return CreateHTMLDocument(aTitle, getter_AddRefs(document), aReturn);
|
|
}
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|