2015-05-03 22:32:37 +03:00
|
|
|
/* -*- 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/. */
|
2011-07-23 13:45:38 +04:00
|
|
|
|
2013-02-08 16:20:11 +04:00
|
|
|
#include "mozilla/dom/HTMLSharedElement.h"
|
2019-05-31 17:33:33 +03:00
|
|
|
#include "mozilla/dom/BindContext.h"
|
2013-02-08 16:20:11 +04:00
|
|
|
#include "mozilla/dom/HTMLBaseElementBinding.h"
|
|
|
|
#include "mozilla/dom/HTMLDirectoryElementBinding.h"
|
|
|
|
#include "mozilla/dom/HTMLHeadElementBinding.h"
|
|
|
|
#include "mozilla/dom/HTMLHtmlElementBinding.h"
|
|
|
|
#include "mozilla/dom/HTMLParamElementBinding.h"
|
|
|
|
#include "mozilla/dom/HTMLQuoteElementBinding.h"
|
2011-08-11 17:29:50 +04:00
|
|
|
|
2018-08-04 00:16:04 +03:00
|
|
|
#include "mozilla/AsyncEventDispatcher.h"
|
2018-06-22 19:48:42 +03:00
|
|
|
#include "mozilla/MappedDeclarations.h"
|
2013-02-08 16:20:11 +04:00
|
|
|
#include "nsAttrValueInlines.h"
|
2001-10-26 13:31:32 +04:00
|
|
|
#include "nsStyleConsts.h"
|
2004-01-26 22:22:05 +03:00
|
|
|
#include "nsMappedAttributes.h"
|
2011-08-11 17:29:50 +04:00
|
|
|
#include "nsContentUtils.h"
|
2016-04-26 12:48:29 +03:00
|
|
|
#include "nsIContentSecurityPolicy.h"
|
2013-09-07 17:01:08 +04:00
|
|
|
#include "nsIURI.h"
|
2010-11-13 02:29:25 +03:00
|
|
|
|
2013-02-08 16:20:11 +04:00
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT(Shared)
|
2001-10-26 13:31:32 +04:00
|
|
|
|
2020-11-04 20:04:01 +03:00
|
|
|
namespace mozilla::dom {
|
2009-09-25 20:50:26 +04:00
|
|
|
|
2013-02-08 16:20:11 +04:00
|
|
|
extern nsAttrValue::EnumTable kListTypeTable[];
|
2001-10-26 13:31:32 +04:00
|
|
|
|
2020-02-20 19:19:15 +03:00
|
|
|
HTMLSharedElement::~HTMLSharedElement() = default;
|
2001-10-26 13:31:32 +04:00
|
|
|
|
2013-02-08 16:20:11 +04:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLSharedElement)
|
2001-10-26 13:31:32 +04:00
|
|
|
|
2013-02-08 16:20:11 +04:00
|
|
|
void HTMLSharedElement::GetHref(nsAString& aValue) {
|
2016-04-23 00:59:16 +03:00
|
|
|
MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::base),
|
|
|
|
"This should only get called for <base> elements");
|
2010-10-07 20:39:01 +04:00
|
|
|
nsAutoString href;
|
|
|
|
GetAttr(kNameSpaceID_None, nsGkAtoms::href, href);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* doc = OwnerDoc();
|
2011-10-18 15:19:44 +04:00
|
|
|
nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(uri), href, doc,
|
2016-04-23 00:59:16 +03:00
|
|
|
doc->GetFallbackBaseURI());
|
2011-10-18 15:19:44 +04:00
|
|
|
|
2010-10-07 20:39:01 +04:00
|
|
|
if (!uri) {
|
|
|
|
aValue = href;
|
2017-11-10 05:22:44 +03:00
|
|
|
return;
|
2010-10-07 20:39:01 +04:00
|
|
|
}
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString spec;
|
2010-10-07 20:39:01 +04:00
|
|
|
uri->GetSpec(spec);
|
|
|
|
CopyUTF8toUTF16(spec, aValue);
|
|
|
|
}
|
|
|
|
|
2018-08-04 00:16:04 +03:00
|
|
|
void HTMLSharedElement::DoneAddingChildren(bool aHaveNotified) {
|
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::head)) {
|
2019-01-02 16:05:23 +03:00
|
|
|
nsCOMPtr<Document> doc = GetUncomposedDoc();
|
2018-09-07 04:28:40 +03:00
|
|
|
if (doc) {
|
|
|
|
doc->OnL10nResourceContainerParsed();
|
|
|
|
}
|
|
|
|
|
2018-08-04 00:16:04 +03:00
|
|
|
RefPtr<AsyncEventDispatcher> asyncDispatcher =
|
|
|
|
new AsyncEventDispatcher(this, u"DOMHeadElementParsed"_ns,
|
|
|
|
CanBubble::eYes, ChromeOnlyDispatch::eYes);
|
|
|
|
// Always run async in order to avoid running script when the content
|
|
|
|
// sink isn't expecting it.
|
|
|
|
asyncDispatcher->PostDOMEvent();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-08 16:20:11 +04:00
|
|
|
bool HTMLSharedElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
2017-11-02 06:35:52 +03:00
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
2013-02-08 16:20:11 +04:00
|
|
|
nsAttrValue& aResult) {
|
2010-08-20 10:05:05 +04:00
|
|
|
if (aNamespaceID == kNameSpaceID_None && mNodeInfo->Equals(nsGkAtoms::dir)) {
|
|
|
|
if (aAttribute == nsGkAtoms::type) {
|
2013-01-04 21:02:14 +04:00
|
|
|
return aResult.ParseEnumValue(aValue, mozilla::dom::kListTypeTable,
|
|
|
|
false);
|
2004-03-04 05:06:28 +03:00
|
|
|
}
|
2010-08-20 10:05:05 +04:00
|
|
|
if (aAttribute == nsGkAtoms::start) {
|
|
|
|
return aResult.ParseIntWithBounds(aValue, 1);
|
2001-10-26 13:31:32 +04:00
|
|
|
}
|
2004-04-13 02:25:17 +04:00
|
|
|
}
|
2001-10-26 13:31:32 +04:00
|
|
|
|
2005-11-29 19:37:15 +03:00
|
|
|
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
2017-11-02 06:35:52 +03:00
|
|
|
aMaybeScriptedPrincipal, aResult);
|
2001-10-26 13:31:32 +04:00
|
|
|
}
|
|
|
|
|
2011-08-08 21:31:32 +04:00
|
|
|
static void DirectoryMapAttributesIntoRule(
|
|
|
|
const nsMappedAttributes* aAttributes, MappedDeclarations& aDecls) {
|
2018-06-22 19:48:42 +03:00
|
|
|
if (!aDecls.PropertyIsSet(eCSSProperty_list_style_type)) {
|
2018-03-29 04:39:07 +03:00
|
|
|
// type: enum
|
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::type);
|
|
|
|
if (value) {
|
|
|
|
if (value->Type() == nsAttrValue::eEnum) {
|
2018-06-22 19:48:42 +03:00
|
|
|
aDecls.SetKeywordValue(eCSSProperty_list_style_type,
|
|
|
|
value->GetEnumValue());
|
2018-03-29 04:39:07 +03:00
|
|
|
} else {
|
2018-06-22 19:48:42 +03:00
|
|
|
aDecls.SetKeywordValue(eCSSProperty_list_style_type,
|
|
|
|
NS_STYLE_LIST_STYLE_DISC);
|
2004-04-13 02:25:17 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-22 19:48:42 +03:00
|
|
|
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aDecls);
|
2001-10-26 13:31:32 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP_(bool)
|
2017-10-03 01:05:19 +03:00
|
|
|
HTMLSharedElement::IsAttributeMapped(const nsAtom* aAttribute) const {
|
2006-12-26 20:47:52 +03:00
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::dir)) {
|
2004-04-13 02:25:17 +04:00
|
|
|
static const MappedAttributeEntry attributes[] = {
|
2018-04-03 06:21:06 +03:00
|
|
|
{nsGkAtoms::type},
|
|
|
|
// { nsGkAtoms::compact }, // XXX
|
2012-07-30 18:20:58 +04:00
|
|
|
{nullptr}};
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2004-04-13 02:25:17 +04:00
|
|
|
static const MappedAttributeEntry* const map[] = {
|
|
|
|
attributes,
|
|
|
|
sCommonAttributeMap,
|
|
|
|
};
|
|
|
|
|
2011-12-18 14:09:27 +04:00
|
|
|
return FindAttributeDependence(aAttribute, map);
|
2001-10-26 13:31:32 +04:00
|
|
|
}
|
|
|
|
|
2004-02-26 00:04:50 +03:00
|
|
|
return nsGenericHTMLElement::IsAttributeMapped(aAttribute);
|
2001-10-26 13:31:32 +04:00
|
|
|
}
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
static void SetBaseURIUsingFirstBaseWithHref(Document* aDocument,
|
2011-01-14 18:34:39 +03:00
|
|
|
nsIContent* aMustMatch) {
|
2018-04-28 22:50:58 +03:00
|
|
|
MOZ_ASSERT(aDocument, "Need a document!");
|
2010-04-23 20:10:07 +04:00
|
|
|
|
2011-01-14 18:34:39 +03:00
|
|
|
for (nsIContent* child = aDocument->GetFirstChild(); child;
|
|
|
|
child = child->GetNextNode()) {
|
2015-03-03 14:08:59 +03:00
|
|
|
if (child->IsHTMLElement(nsGkAtoms::base) &&
|
2017-12-07 21:13:50 +03:00
|
|
|
child->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::href)) {
|
2010-04-23 20:10:07 +04:00
|
|
|
if (aMustMatch && child != aMustMatch) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-01-14 05:36:24 +03:00
|
|
|
// Resolve the <base> element's href relative to our document's
|
|
|
|
// fallback base URI.
|
2010-04-23 20:10:07 +04:00
|
|
|
nsAutoString href;
|
2017-12-07 21:13:50 +03:00
|
|
|
child->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::href, href);
|
2010-04-23 20:10:07 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> newBaseURI;
|
|
|
|
nsContentUtils::NewURIWithDocumentCharset(
|
2011-01-14 18:34:39 +03:00
|
|
|
getter_AddRefs(newBaseURI), href, aDocument,
|
2016-01-14 05:36:24 +03:00
|
|
|
aDocument->GetFallbackBaseURI());
|
2010-04-23 20:10:07 +04:00
|
|
|
|
2016-04-26 12:48:29 +03:00
|
|
|
// Check if CSP allows this base-uri
|
2019-05-22 02:14:27 +03:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsCOMPtr<nsIContentSecurityPolicy> csp = aDocument->GetCsp();
|
2016-04-26 12:48:29 +03:00
|
|
|
if (csp && newBaseURI) {
|
|
|
|
// base-uri is only enforced if explicitly defined in the
|
|
|
|
// policy - do *not* consult default-src, see:
|
|
|
|
// http://www.w3.org/TR/CSP2/#directive-default-src
|
|
|
|
bool cspPermitsBaseURI = true;
|
2018-10-23 09:17:13 +03:00
|
|
|
rv = csp->Permits(child->AsElement(), nullptr /* nsICSPEventListener */,
|
|
|
|
newBaseURI,
|
2018-07-10 18:40:21 +03:00
|
|
|
nsIContentSecurityPolicy::BASE_URI_DIRECTIVE, true,
|
2016-04-26 12:48:29 +03:00
|
|
|
&cspPermitsBaseURI);
|
|
|
|
if (NS_FAILED(rv) || !cspPermitsBaseURI) {
|
|
|
|
newBaseURI = nullptr;
|
|
|
|
}
|
2010-04-23 20:10:07 +04:00
|
|
|
}
|
2016-04-26 12:48:29 +03:00
|
|
|
aDocument->SetBaseURI(newBaseURI);
|
|
|
|
aDocument->SetChromeXHRDocBaseURI(nullptr);
|
2010-04-23 20:10:07 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
aDocument->SetBaseURI(nullptr);
|
2011-01-14 18:34:39 +03:00
|
|
|
}
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
static void SetBaseTargetUsingFirstBaseWithTarget(Document* aDocument,
|
2011-01-14 18:34:39 +03:00
|
|
|
nsIContent* aMustMatch) {
|
2018-04-28 22:50:58 +03:00
|
|
|
MOZ_ASSERT(aDocument, "Need a document!");
|
2011-01-14 18:34:39 +03:00
|
|
|
|
|
|
|
for (nsIContent* child = aDocument->GetFirstChild(); child;
|
|
|
|
child = child->GetNextNode()) {
|
2015-03-03 14:08:59 +03:00
|
|
|
if (child->IsHTMLElement(nsGkAtoms::base) &&
|
2017-12-07 21:13:50 +03:00
|
|
|
child->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::target)) {
|
2011-01-14 18:34:39 +03:00
|
|
|
if (aMustMatch && child != aMustMatch) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsString target;
|
2017-12-07 21:13:50 +03:00
|
|
|
child->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::target, target);
|
2011-01-14 18:34:39 +03:00
|
|
|
aDocument->SetBaseTarget(target);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-23 18:17:15 +03:00
|
|
|
aDocument->SetBaseTarget(u""_ns);
|
2010-04-23 20:10:07 +04:00
|
|
|
}
|
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
nsresult HTMLSharedElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
|
2017-06-07 20:28:20 +03:00
|
|
|
const nsAttrValue* aValue,
|
2017-10-10 00:33:38 +03:00
|
|
|
const nsAttrValue* aOldValue,
|
|
|
|
nsIPrincipal* aSubjectPrincipal,
|
|
|
|
bool aNotify) {
|
2017-06-07 20:28:20 +03:00
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
2011-01-14 18:34:39 +03:00
|
|
|
if (aName == nsGkAtoms::href) {
|
2017-06-07 20:28:20 +03:00
|
|
|
// If the href attribute of a <base> tag is changing, we may need to
|
|
|
|
// update the document's base URI, which will cause all the links on the
|
|
|
|
// page to be re-resolved given the new base.
|
|
|
|
// If the href is being unset (aValue is null), we will need to find a new
|
|
|
|
// <base>.
|
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::base) && IsInUncomposedDoc()) {
|
|
|
|
SetBaseURIUsingFirstBaseWithHref(GetUncomposedDoc(),
|
|
|
|
aValue ? this : nullptr);
|
|
|
|
}
|
2011-01-14 18:34:39 +03:00
|
|
|
} else if (aName == nsGkAtoms::target) {
|
2017-06-07 20:28:20 +03:00
|
|
|
// The target attribute is in pretty much the same situation as the href
|
|
|
|
// attribute, above.
|
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::base) && IsInUncomposedDoc()) {
|
|
|
|
SetBaseTargetUsingFirstBaseWithTarget(GetUncomposedDoc(),
|
|
|
|
aValue ? this : nullptr);
|
|
|
|
}
|
2011-01-14 18:34:39 +03:00
|
|
|
}
|
2009-09-25 20:50:26 +04:00
|
|
|
}
|
|
|
|
|
2017-06-07 20:28:20 +03:00
|
|
|
return nsGenericHTMLElement::AfterSetAttr(
|
2017-10-10 00:33:38 +03:00
|
|
|
aNamespaceID, aName, aValue, aOldValue, aSubjectPrincipal, aNotify);
|
2009-09-25 20:50:26 +04:00
|
|
|
}
|
|
|
|
|
Bug 1555216 - Change the signature of BindToTree to be (BindContext&, nsINode& aParentNode). r=bzbarsky
BindContext was going to have way more information at first, but then I realized
that most of the things I wanted to know were basically a flag away using the
parent node.
Still I think it's worth it, now experimenting with BindToTree will only mean
adding a field to a struct that's included from a couple cpp files, instead of a
massive pain.
I also think this is clearer, and doing this highlights quite a few
inconsistencies in our code which I've left untouched, but commented with
FIXMEs.
Steps are:
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsresult BindToTree(Document\* aDocument, nsIContent\* aParent,#nsresult BindToTree(BindContext\&, nsINode\& aParent)#g' $file; done
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's# nsIContent\* aBindingParent) override#override#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(Document\* aDocument, nsIContent\* aParent,#::BindToTree(BindContext\& aContext, nsINode\& aParent)#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsIContent\* aBindingParent)##g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(aDocument, aParent, aBindingParent)#::BindToTree(aContext, aParent)#g' $file; done
$ ./mach clang-format
Then manual fixups.
Depends on D32948
Differential Revision: https://phabricator.services.mozilla.com/D32949
2019-05-29 07:27:04 +03:00
|
|
|
nsresult HTMLSharedElement::BindToTree(BindContext& aContext,
|
|
|
|
nsINode& aParent) {
|
|
|
|
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
|
2010-04-23 20:10:07 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2009-09-25 20:50:26 +04:00
|
|
|
|
2011-01-14 18:34:39 +03:00
|
|
|
// The document stores a pointer to its base URI and base target, which we may
|
2009-09-25 20:50:26 +04:00
|
|
|
// need to update here.
|
Bug 1555216 - Change the signature of BindToTree to be (BindContext&, nsINode& aParentNode). r=bzbarsky
BindContext was going to have way more information at first, but then I realized
that most of the things I wanted to know were basically a flag away using the
parent node.
Still I think it's worth it, now experimenting with BindToTree will only mean
adding a field to a struct that's included from a couple cpp files, instead of a
massive pain.
I also think this is clearer, and doing this highlights quite a few
inconsistencies in our code which I've left untouched, but commented with
FIXMEs.
Steps are:
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsresult BindToTree(Document\* aDocument, nsIContent\* aParent,#nsresult BindToTree(BindContext\&, nsINode\& aParent)#g' $file; done
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's# nsIContent\* aBindingParent) override#override#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(Document\* aDocument, nsIContent\* aParent,#::BindToTree(BindContext\& aContext, nsINode\& aParent)#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsIContent\* aBindingParent)##g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(aDocument, aParent, aBindingParent)#::BindToTree(aContext, aParent)#g' $file; done
$ ./mach clang-format
Then manual fixups.
Depends on D32948
Differential Revision: https://phabricator.services.mozilla.com/D32949
2019-05-29 07:27:04 +03:00
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::base) && IsInUncomposedDoc()) {
|
2011-01-14 18:34:39 +03:00
|
|
|
if (HasAttr(kNameSpaceID_None, nsGkAtoms::href)) {
|
2019-05-31 17:33:33 +03:00
|
|
|
SetBaseURIUsingFirstBaseWithHref(&aContext.OwnerDoc(), this);
|
2011-01-14 18:34:39 +03:00
|
|
|
}
|
|
|
|
if (HasAttr(kNameSpaceID_None, nsGkAtoms::target)) {
|
2019-05-31 17:33:33 +03:00
|
|
|
SetBaseTargetUsingFirstBaseWithTarget(&aContext.OwnerDoc(), this);
|
2011-01-14 18:34:39 +03:00
|
|
|
}
|
2009-09-25 20:50:26 +04:00
|
|
|
}
|
|
|
|
|
2010-04-23 20:10:07 +04:00
|
|
|
return NS_OK;
|
2009-09-25 20:50:26 +04:00
|
|
|
}
|
|
|
|
|
2019-05-29 01:47:08 +03:00
|
|
|
void HTMLSharedElement::UnbindFromTree(bool aNullParent) {
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* doc = GetUncomposedDoc();
|
2009-09-25 20:50:26 +04:00
|
|
|
|
2019-05-29 01:47:08 +03:00
|
|
|
nsGenericHTMLElement::UnbindFromTree(aNullParent);
|
2009-09-25 20:50:26 +04:00
|
|
|
|
|
|
|
// If we're removing a <base> from a document, we may need to update the
|
2011-01-14 18:34:39 +03:00
|
|
|
// document's base URI and base target
|
|
|
|
if (doc && mNodeInfo->Equals(nsGkAtoms::base)) {
|
|
|
|
if (HasAttr(kNameSpaceID_None, nsGkAtoms::href)) {
|
2012-07-30 18:20:58 +04:00
|
|
|
SetBaseURIUsingFirstBaseWithHref(doc, nullptr);
|
2010-04-23 20:10:07 +04:00
|
|
|
}
|
2011-01-14 18:34:39 +03:00
|
|
|
if (HasAttr(kNameSpaceID_None, nsGkAtoms::target)) {
|
2012-07-30 18:20:58 +04:00
|
|
|
SetBaseTargetUsingFirstBaseWithTarget(doc, nullptr);
|
2010-04-23 20:10:07 +04:00
|
|
|
}
|
2009-09-25 20:50:26 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-08 16:20:11 +04:00
|
|
|
nsMapRuleToAttributesFunc HTMLSharedElement::GetAttributeMappingFunction()
|
|
|
|
const {
|
2011-08-08 21:31:32 +04:00
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::dir)) {
|
|
|
|
return &DirectoryMapAttributesIntoRule;
|
2004-04-13 02:25:17 +04:00
|
|
|
}
|
2005-01-12 22:45:38 +03:00
|
|
|
|
|
|
|
return nsGenericHTMLElement::GetAttributeMappingFunction();
|
2001-10-26 13:31:32 +04:00
|
|
|
}
|
2013-02-08 16:20:11 +04:00
|
|
|
|
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
|
|
|
JSObject* HTMLSharedElement::WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) {
|
2013-02-08 16:20:11 +04:00
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::param)) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return HTMLParamElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-02-08 16:20:11 +04:00
|
|
|
}
|
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::base)) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return HTMLBaseElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-02-08 16:20:11 +04:00
|
|
|
}
|
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::dir)) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return HTMLDirectoryElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-02-08 16:20:11 +04:00
|
|
|
}
|
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::q) ||
|
|
|
|
mNodeInfo->Equals(nsGkAtoms::blockquote)) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return HTMLQuoteElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-02-08 16:20:11 +04:00
|
|
|
}
|
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::head)) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return HTMLHeadElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-02-08 16:20:11 +04:00
|
|
|
}
|
|
|
|
MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::html));
|
2018-06-26 00:20:54 +03:00
|
|
|
return HTMLHtmlElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-02-08 16:20:11 +04:00
|
|
|
}
|
|
|
|
|
2020-11-04 20:04:01 +03:00
|
|
|
} // namespace mozilla::dom
|