import changes from `dev' branch of rmottola/Arctic-Fox:

- Bug 1213818 - Align document.title for SVG documents with HTML spec; r=bz (fb60e8c048)
- Bug 1234170 - WebSocket should check if the channel has been opened before send the 'close' notification to the WebSocketEventService, r=jduell (4bfd6f3f3f)
- Bug 1245261 - Use an atomic to safely access gcTriggerBytes; r=jonco (f9c80d47e1)
- Bug 1243001 part 1. Remove the dead WrappedWorkerRunnable class from Promise code. r=peterv (9f8c758723)
- Bug 1243001 part 2. Make Promise an empty [NoInterfaceObject] interface when SPIDERMONKEY_PROMISE is defined. r=peterv (6be034ee59)
- Bug 1243001 part 3. Turn off the IDL bits of PromiseDebugging when SPIDERMONKEY_PROMISE is defined. r=peterv (114241ddd6)
- Bug 1243001 part 4. Switch to using MaybeResolve/MaybeReject instead of ResolveInternal/RejectInternal for PromiseWorkerProxy. r=peterv (ca8faf02f8)
- Bug 1243114 - Convert PromiseCapability::mPromise to a rooted JSObject* instead of a rooted JS::Value. r=bz (e4c907e5c2)
- Bug 1243001 part 5. Get rid of most of the dom::Promise methods when SPIDERMONKEY_PROMISE is defined, and reimplement the rest in terms of SpiderMonkey Promise. r=peterv (693a61e5a2)
- Bug 1242054. Get rid of AbortablePromise, so we can move Promise into SpiderMonkey more easily. r=khuey (6a0200e625)
- Bug 1243001 part 6. Implement Promise::AppendNativeHandler in the SPIDERMONKEY_PROMISE world. r=peterv (7c3a6390f9)
- Bug 1243001 part 7. Stop wrappercaching dom::Promise when SPIDERMONKEY_PROMISE is defined. r=peterv (be1bd9b33f)
- Bug 1243001 part 8. Tell SpiderMonkey to put its promise jobs into the CycleCollectedJSRuntime job queue. r=peterv (192e6a551c)
- Bug 1156880 - Null check the prescontext in nsDOMWindowUtils::AdvanceTimeAndRefresh; r=mstange (11f1a39f22)
- Bug 1191597 part 1 - Add head.js and dummy page for browser chrome test. r=smaug (5257870dd3)
- Bug 1191597 part 2 - Convert fullscreen-esc-context-menu to a browser chrome test. r=smaug (e1c0fe84a4)
This commit is contained in:
2023-11-08 17:17:49 +08:00
parent 0ccb78c213
commit 3e34b8d21b
48 changed files with 1118 additions and 620 deletions
+68 -48
View File
@@ -7010,8 +7010,8 @@ nsIDocument::GetHtmlChildElement(nsIAtom* aTag)
return nullptr;
}
nsIContent*
nsDocument::GetTitleContent(uint32_t aNamespace)
Element*
nsDocument::GetTitleElement()
{
// mMayHaveTitleElement will have been set to true if any HTML or SVG
// <title> element has been bound to this document. So if it's false,
@@ -7021,19 +7021,26 @@ nsDocument::GetTitleContent(uint32_t aNamespace)
if (!mMayHaveTitleElement)
return nullptr;
Element* root = GetRootElement();
if (root && root->IsSVGElement(nsGkAtoms::svg)) {
// In SVG, the document's title must be a child
for (nsIContent* child = root->GetFirstChild();
child; child = child->GetNextSibling()) {
if (child->IsSVGElement(nsGkAtoms::title)) {
return child->AsElement();
}
}
return nullptr;
}
// We check the HTML namespace even for non-HTML documents, except SVG. This
// matches the spec and the behavior of all tested browsers.
RefPtr<nsContentList> list =
NS_GetContentList(this, aNamespace, NS_LITERAL_STRING("title"));
NS_GetContentList(this, kNameSpaceID_XHTML, NS_LITERAL_STRING("title"));
return list->Item(0, false);
}
nsIContent* first = list->Item(0, false);
void
nsDocument::GetTitleFromElement(uint32_t aNamespace, nsAString& aTitle)
{
nsIContent* title = GetTitleContent(aNamespace);
if (!title)
return;
nsContentUtils::GetNodeTextContent(title, false, aTitle);
return first ? first->AsElement() : nullptr;
}
NS_IMETHODIMP
@@ -7050,26 +7057,24 @@ nsDocument::GetTitle(nsString& aTitle)
{
aTitle.Truncate();
nsIContent *rootElement = GetRootElement();
if (!rootElement)
Element* rootElement = GetRootElement();
if (!rootElement) {
return;
}
nsAutoString tmp;
switch (rootElement->GetNameSpaceID()) {
#ifdef MOZ_XUL
case kNameSpaceID_XUL:
rootElement->GetAttr(kNameSpaceID_None, nsGkAtoms::title, tmp);
break;
if (rootElement->IsXULElement()) {
rootElement->GetAttr(kNameSpaceID_None, nsGkAtoms::title, tmp);
} else
#endif
case kNameSpaceID_SVG:
if (rootElement->IsSVGElement(nsGkAtoms::svg)) {
GetTitleFromElement(kNameSpaceID_SVG, tmp);
break;
} // else fall through
default:
GetTitleFromElement(kNameSpaceID_XHTML, tmp);
break;
{
Element* title = GetTitleElement();
if (!title) {
return;
}
nsContentUtils::GetNodeTextContent(title, false, tmp);
}
tmp.CompressWhitespace();
@@ -7079,41 +7084,56 @@ nsDocument::GetTitle(nsString& aTitle)
NS_IMETHODIMP
nsDocument::SetTitle(const nsAString& aTitle)
{
Element *rootElement = GetRootElement();
if (!rootElement)
Element* rootElement = GetRootElement();
if (!rootElement) {
return NS_OK;
switch (rootElement->GetNameSpaceID()) {
case kNameSpaceID_SVG:
return NS_OK; // SVG doesn't support setting a title
#ifdef MOZ_XUL
case kNameSpaceID_XUL:
return rootElement->SetAttr(kNameSpaceID_None, nsGkAtoms::title,
aTitle, true);
#endif
}
#ifdef MOZ_XUL
if (rootElement->IsXULElement()) {
return rootElement->SetAttr(kNameSpaceID_None, nsGkAtoms::title,
aTitle, true);
}
#endif
// Batch updates so that mutation events don't change "the title
// element" under us
mozAutoDocUpdate updateBatch(this, UPDATE_CONTENT_MODEL, true);
nsIContent* title = GetTitleContent(kNameSpaceID_XHTML);
if (!title) {
Element *head = GetHeadElement();
if (!head)
return NS_OK;
nsCOMPtr<Element> title = GetTitleElement();
if (rootElement->IsSVGElement(nsGkAtoms::svg)) {
if (!title) {
RefPtr<mozilla::dom::NodeInfo> titleInfo =
mNodeInfoManager->GetNodeInfo(nsGkAtoms::title, nullptr,
kNameSpaceID_SVG,
nsIDOMNode::ELEMENT_NODE);
NS_NewSVGElement(getter_AddRefs(title), titleInfo.forget(),
NOT_FROM_PARSER);
if (!title) {
return NS_OK;
}
rootElement->InsertChildAt(title, 0, true);
}
} else if (rootElement->IsHTMLElement()) {
if (!title) {
Element* head = GetHeadElement();
if (!head) {
return NS_OK;
}
{
RefPtr<mozilla::dom::NodeInfo> titleInfo;
titleInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::title, nullptr,
kNameSpaceID_XHTML,
nsIDOMNode::ELEMENT_NODE);
kNameSpaceID_XHTML,
nsIDOMNode::ELEMENT_NODE);
title = NS_NewHTMLTitleElement(titleInfo.forget());
if (!title)
if (!title) {
return NS_OK;
}
}
head->AppendChildTo(title, true);
head->AppendChildTo(title, true);
}
} else {
return NS_OK;
}
return nsContentUtils::SetNodeTextContent(title, aTitle, false);