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"
|
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
|
|
|
|
2013-02-08 16:20:11 +04:00
|
|
|
#include "nsAttrValueInlines.h"
|
2001-10-26 13:31:32 +04:00
|
|
|
#include "nsStyleConsts.h"
|
2004-07-20 10:11:27 +04:00
|
|
|
#include "nsRuleData.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
|
|
|
|
2013-01-04 21:02:14 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace 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
|
|
|
|
2013-02-08 16:20:11 +04:00
|
|
|
HTMLSharedElement::~HTMLSharedElement()
|
2001-10-26 13:31:32 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-02-08 16:20:11 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(HTMLSharedElement, Element)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(HTMLSharedElement, Element)
|
2010-01-12 16:08:43 +03:00
|
|
|
|
2013-02-08 16:20:11 +04:00
|
|
|
// QueryInterface implementation for HTMLSharedElement
|
2013-05-21 17:38:15 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN(HTMLSharedElement)
|
2001-10-26 13:31:32 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLBaseElement, base)
|
2004-04-13 02:25:17 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLDirectoryElement, dir)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLQuoteElement, q)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLQuoteElement, blockquote)
|
2010-04-19 23:06:00 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLHeadElement, head)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLHtmlElement, html)
|
2013-08-08 00:23:08 +04:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsGenericHTMLElement)
|
2001-10-26 13:31:32 +04:00
|
|
|
|
2004-05-19 00:58:12 +04:00
|
|
|
|
2013-02-08 16:20:11 +04:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLSharedElement)
|
2001-10-26 13:31:32 +04:00
|
|
|
|
2004-04-13 02:25:17 +04:00
|
|
|
// nsIDOMHTMLQuoteElement
|
2013-02-08 16:20:11 +04:00
|
|
|
NS_IMPL_URI_ATTR(HTMLSharedElement, Cite, cite)
|
2004-04-13 02:25:17 +04:00
|
|
|
|
2010-04-19 23:06:00 +04:00
|
|
|
// nsIDOMHTMLHeadElement
|
2011-06-18 13:01:57 +04:00
|
|
|
// Empty
|
2001-10-26 13:31:32 +04:00
|
|
|
|
2010-04-19 23:06:00 +04:00
|
|
|
// nsIDOMHTMLHtmlElement
|
2013-02-08 16:20:11 +04:00
|
|
|
NS_IMPL_STRING_ATTR(HTMLSharedElement, Version, version)
|
2010-04-19 23:06:00 +04:00
|
|
|
|
2001-10-26 13:31:32 +04:00
|
|
|
// nsIDOMHTMLBaseElement
|
2013-02-08 16:20:11 +04:00
|
|
|
NS_IMPL_STRING_ATTR(HTMLSharedElement, Target, target)
|
|
|
|
|
2010-10-07 20:39:01 +04:00
|
|
|
NS_IMETHODIMP
|
2013-02-08 16:20:11 +04:00
|
|
|
HTMLSharedElement::GetHref(nsAString& aValue)
|
2010-10-07 20:39:01 +04:00
|
|
|
{
|
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;
|
2011-10-18 14:53:36 +04:00
|
|
|
nsIDocument* doc = OwnerDoc();
|
2011-10-18 15:19:44 +04:00
|
|
|
nsContentUtils::NewURIWithDocumentCharset(
|
2016-04-23 00:59:16 +03:00
|
|
|
getter_AddRefs(uri), href, doc, doc->GetFallbackBaseURI());
|
2011-10-18 15:19:44 +04:00
|
|
|
|
2010-10-07 20:39:01 +04:00
|
|
|
if (!uri) {
|
|
|
|
aValue = href;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString spec;
|
2010-10-07 20:39:01 +04:00
|
|
|
uri->GetSpec(spec);
|
|
|
|
CopyUTF8toUTF16(spec, aValue);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2013-02-08 16:20:11 +04:00
|
|
|
|
2010-10-07 20:39:01 +04:00
|
|
|
NS_IMETHODIMP
|
2013-02-08 16:20:11 +04:00
|
|
|
HTMLSharedElement::SetHref(const nsAString& aValue)
|
2010-10-07 20:39:01 +04:00
|
|
|
{
|
|
|
|
return SetAttrHelper(nsGkAtoms::href, aValue);
|
|
|
|
}
|
|
|
|
|
2001-10-26 13:31:32 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2013-02-08 16:20:11 +04:00
|
|
|
HTMLSharedElement::ParseAttribute(int32_t aNamespaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult)
|
2001-10-26 13:31:32 +04:00
|
|
|
{
|
2010-08-20 10:05:05 +04:00
|
|
|
if (aNamespaceID == kNameSpaceID_None &&
|
2011-08-08 21:31:32 +04:00
|
|
|
mNodeInfo->Equals(nsGkAtoms::dir)) {
|
2010-08-20 10:05:05 +04:00
|
|
|
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,
|
|
|
|
aResult);
|
2001-10-26 13:31:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-08-08 21:31:32 +04:00
|
|
|
DirectoryMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
2004-04-13 02:25:17 +04:00
|
|
|
nsRuleData* aData)
|
2001-10-26 13:31:32 +04:00
|
|
|
{
|
2007-10-09 01:58:22 +04:00
|
|
|
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(List)) {
|
2011-03-18 06:14:31 +03:00
|
|
|
nsCSSValue* listStyleType = aData->ValueForListStyleType();
|
|
|
|
if (listStyleType->GetUnit() == eCSSUnit_Null) {
|
2004-04-13 02:25:17 +04:00
|
|
|
// type: enum
|
2006-12-26 20:47:52 +03:00
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::type);
|
2004-04-13 20:45:59 +04:00
|
|
|
if (value) {
|
2005-09-21 23:14:30 +04:00
|
|
|
if (value->Type() == nsAttrValue::eEnum) {
|
2011-03-18 06:14:31 +03:00
|
|
|
listStyleType->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
|
2005-09-21 23:14:30 +04:00
|
|
|
} else {
|
2011-03-18 06:14:31 +03:00
|
|
|
listStyleType->SetIntValue(NS_STYLE_LIST_STYLE_DISC, eCSSUnit_Enumerated);
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
2004-04-13 02:25:17 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-10-26 13:31:32 +04:00
|
|
|
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP_(bool)
|
2013-02-08 16:20:11 +04:00
|
|
|
HTMLSharedElement::IsAttributeMapped(const nsIAtom* aAttribute) const
|
2001-10-26 13:31:32 +04:00
|
|
|
{
|
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[] = {
|
2006-12-26 20:47:52 +03:00
|
|
|
{ &nsGkAtoms::type },
|
|
|
|
// { &nsGkAtoms::compact }, // XXX
|
2012-07-30 18:20:58 +04:00
|
|
|
{ nullptr}
|
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
|
|
|
}
|
|
|
|
|
2011-01-14 18:34:39 +03:00
|
|
|
static void
|
|
|
|
SetBaseURIUsingFirstBaseWithHref(nsIDocument* aDocument, nsIContent* aMustMatch)
|
2010-04-23 20:10:07 +04:00
|
|
|
{
|
2011-01-14 18:34:39 +03:00
|
|
|
NS_PRECONDITION(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) &&
|
2010-04-23 20:10:07 +04:00
|
|
|
child->HasAttr(kNameSpaceID_None, nsGkAtoms::href)) {
|
|
|
|
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;
|
|
|
|
child->GetAttr(kNameSpaceID_None, nsGkAtoms::href, href);
|
|
|
|
|
|
|
|
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
|
|
|
|
nsCOMPtr<nsIContentSecurityPolicy> csp;
|
|
|
|
nsresult rv = aDocument->NodePrincipal()->GetCsp(getter_AddRefs(csp));
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "Getting CSP Failed");
|
|
|
|
// For all the different error cases we assign a nullptr to
|
|
|
|
// newBaseURI, so we basically call aDocument->SetBaseURI(nullptr);
|
2010-04-23 20:10:07 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
2016-04-26 12:48:29 +03:00
|
|
|
newBaseURI = nullptr;
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
rv = csp->Permits(newBaseURI, nsIContentSecurityPolicy::BASE_URI_DIRECTIVE,
|
|
|
|
true, &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
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
SetBaseTargetUsingFirstBaseWithTarget(nsIDocument* aDocument,
|
|
|
|
nsIContent* aMustMatch)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aDocument, "Need a document!");
|
|
|
|
|
|
|
|
for (nsIContent* child = aDocument->GetFirstChild(); child;
|
|
|
|
child = child->GetNextNode()) {
|
2015-03-03 14:08:59 +03:00
|
|
|
if (child->IsHTMLElement(nsGkAtoms::base) &&
|
2011-01-14 18:34:39 +03:00
|
|
|
child->HasAttr(kNameSpaceID_None, nsGkAtoms::target)) {
|
|
|
|
if (aMustMatch && child != aMustMatch) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsString target;
|
|
|
|
child->GetAttr(kNameSpaceID_None, nsGkAtoms::target, target);
|
|
|
|
aDocument->SetBaseTarget(target);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
aDocument->SetBaseTarget(EmptyString());
|
2010-04-23 20:10:07 +04:00
|
|
|
}
|
|
|
|
|
2009-09-25 20:50:26 +04:00
|
|
|
nsresult
|
2013-02-08 16:20:11 +04:00
|
|
|
HTMLSharedElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
|
|
|
nsIAtom* aPrefix, const nsAString& aValue,
|
|
|
|
bool aNotify)
|
2009-09-25 20:50:26 +04:00
|
|
|
{
|
2011-11-16 11:50:19 +04:00
|
|
|
nsresult rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix,
|
|
|
|
aValue, aNotify);
|
2010-04-23 20:10:07 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2009-09-25 20:50:26 +04: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
|
2011-01-14 18:34:39 +03:00
|
|
|
// re-resolved given the new base. If the target attribute is changing, we
|
|
|
|
// similarly need to change the base target.
|
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::base) &&
|
2009-09-25 20:50:26 +04:00
|
|
|
aNameSpaceID == kNameSpaceID_None &&
|
2016-03-31 13:58:25 +03:00
|
|
|
IsInUncomposedDoc()) {
|
2011-01-14 18:34:39 +03:00
|
|
|
if (aName == nsGkAtoms::href) {
|
2014-10-02 23:07:24 +04:00
|
|
|
SetBaseURIUsingFirstBaseWithHref(GetUncomposedDoc(), this);
|
2011-01-14 18:34:39 +03:00
|
|
|
} else if (aName == nsGkAtoms::target) {
|
2014-10-02 23:07:24 +04:00
|
|
|
SetBaseTargetUsingFirstBaseWithTarget(GetUncomposedDoc(), 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
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2013-02-08 16:20:11 +04:00
|
|
|
HTMLSharedElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
|
|
|
bool aNotify)
|
2009-09-25 20:50:26 +04:00
|
|
|
{
|
|
|
|
nsresult rv = nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aName, aNotify);
|
2010-04-23 20:10:07 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2009-09-25 20:50:26 +04:00
|
|
|
|
|
|
|
// If we're the first <base> with an href and our href attribute is being
|
|
|
|
// unset, then we're no longer the first <base> with an href, and we need to
|
2011-01-14 18:34:39 +03:00
|
|
|
// find the new one. Similar for target.
|
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::base) &&
|
2009-09-25 20:50:26 +04:00
|
|
|
aNameSpaceID == kNameSpaceID_None &&
|
2016-03-31 13:58:25 +03:00
|
|
|
IsInUncomposedDoc()) {
|
2011-01-14 18:34:39 +03:00
|
|
|
if (aName == nsGkAtoms::href) {
|
2014-10-02 23:07:24 +04:00
|
|
|
SetBaseURIUsingFirstBaseWithHref(GetUncomposedDoc(), nullptr);
|
2011-01-14 18:34:39 +03:00
|
|
|
} else if (aName == nsGkAtoms::target) {
|
2014-10-02 23:07:24 +04:00
|
|
|
SetBaseTargetUsingFirstBaseWithTarget(GetUncomposedDoc(), nullptr);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2013-02-08 16:20:11 +04:00
|
|
|
HTMLSharedElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
|
|
|
bool aCompileEventHandlers)
|
2009-09-25 20:50:26 +04:00
|
|
|
{
|
|
|
|
nsresult rv = nsGenericHTMLElement::BindToTree(aDocument, aParent,
|
|
|
|
aBindingParent,
|
|
|
|
aCompileEventHandlers);
|
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.
|
2011-01-14 18:34:39 +03:00
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::base) &&
|
|
|
|
aDocument) {
|
|
|
|
if (HasAttr(kNameSpaceID_None, nsGkAtoms::href)) {
|
|
|
|
SetBaseURIUsingFirstBaseWithHref(aDocument, this);
|
|
|
|
}
|
|
|
|
if (HasAttr(kNameSpaceID_None, nsGkAtoms::target)) {
|
|
|
|
SetBaseTargetUsingFirstBaseWithTarget(aDocument, this);
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-02-08 16:20:11 +04:00
|
|
|
HTMLSharedElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
2009-09-25 20:50:26 +04:00
|
|
|
{
|
2014-10-02 23:07:24 +04:00
|
|
|
nsIDocument* doc = GetUncomposedDoc();
|
2009-09-25 20:50:26 +04:00
|
|
|
|
|
|
|
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
|
|
|
|
|
|
|
|
// 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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-12 22:45:38 +03:00
|
|
|
nsMapRuleToAttributesFunc
|
2013-02-08 16:20:11 +04:00
|
|
|
HTMLSharedElement::GetAttributeMappingFunction() const
|
2001-10-26 13:31:32 +04:00
|
|
|
{
|
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
|
|
|
|
2013-02-08 16:20:11 +04:00
|
|
|
JSObject*
|
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
|
|
|
HTMLSharedElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-02-08 16:20:11 +04:00
|
|
|
{
|
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::param)) {
|
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
|
|
|
return HTMLParamElementBinding::Wrap(aCx, this, aGivenProto);
|
2013-02-08 16:20:11 +04:00
|
|
|
}
|
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::base)) {
|
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
|
|
|
return HTMLBaseElementBinding::Wrap(aCx, this, aGivenProto);
|
2013-02-08 16:20:11 +04:00
|
|
|
}
|
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::dir)) {
|
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
|
|
|
return HTMLDirectoryElementBinding::Wrap(aCx, this, aGivenProto);
|
2013-02-08 16:20:11 +04:00
|
|
|
}
|
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::q) ||
|
|
|
|
mNodeInfo->Equals(nsGkAtoms::blockquote)) {
|
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
|
|
|
return HTMLQuoteElementBinding::Wrap(aCx, this, aGivenProto);
|
2013-02-08 16:20:11 +04:00
|
|
|
}
|
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::head)) {
|
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
|
|
|
return HTMLHeadElementBinding::Wrap(aCx, this, aGivenProto);
|
2013-02-08 16:20:11 +04:00
|
|
|
}
|
|
|
|
MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::html));
|
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
|
|
|
return HTMLHtmlElementBinding::Wrap(aCx, this, aGivenProto);
|
2013-02-08 16:20:11 +04:00
|
|
|
}
|
|
|
|
|
2013-02-08 16:20:11 +04:00
|
|
|
} // namespace dom
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace mozilla
|