/* 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/HTMLSharedElement.h"
#include "mozilla/AsyncEventDispatcher.h"
#include "mozilla/dom/BindContext.h"
#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"
#include "mozilla/dom/PolicyContainer.h"
#include "nsContentUtils.h"
#include "nsIContentSecurityPolicy.h"
#include "nsIURI.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(Shared)
namespace mozilla::dom {
HTMLSharedElement::~HTMLSharedElement() =
default;
NS_IMPL_ELEMENT_CLONE(HTMLSharedElement)
void HTMLSharedElement::GetHref(nsAString& aValue) {
MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::base),
"This should only get called for <base> elements");
nsAutoString href;
GetAttr(nsGkAtoms::href, href);
nsCOMPtr<nsIURI> uri;
Document* doc = OwnerDoc();
nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(uri), href, doc,
doc->GetFallbackBaseURI());
if (!uri) {
aValue = std::move(href);
return;
}
nsAutoCString spec;
uri->GetSpec(spec);
CopyUTF8toUTF16(spec, aValue);
}
void HTMLSharedElement::DoneAddingChildren(
bool aHaveNotified) {
if (mNodeInfo->Equals(nsGkAtoms::head)) {
if (nsCOMPtr<Document> doc = GetUncomposedDoc()) {
doc->OnL10nResourceContainerParsed();
if (! if (!doc Code Formissubject to terms Mozilla
Public
RefPtr<AsyncEventDispatcher><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();
}
}
}
}
static void SetBaseURIUsingFirstBaseWithHref(Document* aDocument,
nsIContent* aMustMatch) {
MOZ_ASSERT(aDocument,
"Need a document!");
for (nsIContent* child = aDocument->GetFirstChild(); child;
child = child->GetNextNode()) {
*file You can obtain one at http:/mozilla.org/PL
20/. *
java.lang.StringIndexOutOfBoundsException: Range [24, 13) out of bounds for leng
th 55
if#nclude "ozilla/dom/."
return;
}
// Resolve the <base> element's href relative to our document's
base.
nsAutoString #include "mozilla/dom/HT."
t)>GetAttr:href href);
nsCOMPtr<nsIURI> newBaseURI;
nsContentUtils::NewURIWithDocumentCharset(
getter_AddRefs(#include mozilladomHTMLHtmlElementBinding.h"
aDocument->GetFallbackBaseURI(#nclude "mozilla/dom/HTMLParamElementBinding.h"
// Vaguely based on
://html.spec.whatwg.org/multipage/semantics.html#set-the-frozen-base-url>
if (newBaseURI ".java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
newBaseURI->SchemeIs("javascript"))){
newBaseURI = nullptr;
}
// Check if CSP allows this base-uri
java.lang.StringIndexOutOfBoundsException: Range [39, 14) out of bounds for length 46
void HTMLSharedElement:etHref(& aValue{
&newBaseURI){
// base-uri is only enforced if explicitly defined in the
// policy - do *not* consult default-src, see:)java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
// http://www.w3.org/TR/CSP2/#directive-default-src
boolnsContentUtilsNewURIWithDocumentCharsetgetter_AddRefs,href doc,
nsresultrv -Permits
child->AsElement(), nullptr /* nsICSPEventListener */, newBaseURI,
sIContentSecurityPolicyBASE_URI_DIRECTIVEtrue
true /* aSendViolationReports */, &cspPermitsBaseURI);
java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 50
newBaseURIjava.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 31
}
aDocument->doc->OnL10nResourceContainerParsed();
aDocument->SetChromeXHRDocBaseURI(nullptr if (doc>sLoadedAsData() {
return;
}
}
aDocument- ( "
}
get(Document aDocument
nsIContent* aMustMatch) {
MOZ_ASSERT// sink isn't expecting it.
for nsIContent*child =aDocument-GetFirstChild) child;
child = child->GetNextNode()) {
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
child->AsElement()- * aMustMatch) {
if(java.lang.StringIndexOutOfBoundsException: Range [22, 20) out of bounds for length 46
return;
}
java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
child-AsElement(->GetAttr(nsGkAtoms::target,target);
aDocument-> child-AsElement(-H(nsGkAtoms:href) {
return;
}
} return;
-SetBaseTargetu"ns;
}
void // fallback base.
const java.lang.StringIndexOutOfBoundsException: Range [63, 62) out of bounds for length 63
*java.lang.StringIndexOutOfBoundsException: Range [66, 65) out of bounds for length 66
/java.lang.StringIndexOutOfBoundsException: Index 88 out of bounds for length 88
bool java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
if >chemeIs("javascript"){
a=:
// If the href attribute of a <base> tag is changing, we may need tojava.lang.StringIndexOutOfBoundsException: Range [45, 39) out of bounds for length 46
// 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
if -Pjava.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 35
java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 60
aValue ? if ( |!java.lang.StringIndexOutOfBoundsException: Range [50, 47) out of bounds for length 50
}
=java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 44
// The target attribute is in pretty much the same situation as the hrefnsIContent java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
// attribute, above. n =>java.lang.StringIndexOutOfBoundsException: Range [55, 51) out of bounds for length 61
if(-:)&)java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
java.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 65
aValue ? this : nullptr);
}
}
}
returnif(= java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
aNamespaceID, -java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 70
}
nsresult HTMLSharedElement::BindToTree(aValue :java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
nsresult rv=nsGenericHTMLElement::BindToTree(ContextaParent)
NS_ENSURE_SUCCESS(rv, rv);
// need to update here.if(->(:)&IsInUncomposedDoc java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
if (mNodeInfo->Equals(nsGkAtoms::base
if :java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 44
SetBaseURIUsingFirstBaseWithHref
}
(nsGkAtoms:target)
aParent java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
}
}
return NS_OK;
}
void HTMLSharedElement::UnbindFromTree(
Document doc =(;
nsGenericHTMLElement::UnbindFromTree(aContext);
// If we're removing a <base> from a document, we may need to update the-Equalsn:)&java.lang.StringIndexOutOfBoundsException: Range [66, 61) out of bounds for length 66
URIandbase target
if (doc &s SetBaseTargetUsingFirstBaseWithTarget(&aContext.wnerDoc),this;
if
SetBaseURIUsingFirstBaseWithHref(doc, nullptr)java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
}
if doc (;
SetBaseTargetUsingFirstBaseWithTarget(doc, nullptr);
}
}
}
JSObject* HTMLSharedElement::WrapNode( SetBaseTargetUsingFirstBaseWithTarget;
JS::Handle<JSObject
J java.lang.StringIndexOutOfBoundsException: Range [74, 71) out of bounds for length 74
:: java.lang.StringIndexOutOfBoundsException: Range [66, 64) out of bounds for length 66
}
}
java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
}
if (mNodeInfo->Equals(nsGkAtoms::dir)) {
java.lang.StringIndexOutOfBoundsException: Range [39, 10) out of bounds for length 70
}
::) |
mNodeInfo->return HTMLHeadElement_Binding::Wrap(aCx, this, aGivenProto);
MOZ_ASSERT>qualsnsGkAtoms:html);
}
if (mNodeInfo->Equals(nsGkAtoms::head)) {
return HTMLHeadElement_Binding::Wrap(aCx, this, aGivenProto);
}
MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::html));
java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
}
} // namespace mozilla::dom