Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 21df1f7

Browse files
committed
Merge inbound to mozilla-central. a=merge
2 parents b34b6de + 18e9f3b commit 21df1f7

30 files changed

Lines changed: 285 additions & 132 deletions

accessible/base/nsAccessibilityService.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,12 +1396,13 @@ nsAccessibilityService::CreateAccessibleByFrameType(nsIFrame* aFrame,
13961396

13971397
if (table) {
13981398
nsIContent* parentContent =
1399-
aContent->GetParentOrHostNode()->AsContent();
1399+
aContent->GetParentOrShadowHostNode()->AsContent();
14001400
nsIFrame* parentFrame = nullptr;
14011401
if (parentContent) {
14021402
parentFrame = parentContent->GetPrimaryFrame();
14031403
if (!parentFrame || !parentFrame->IsTableWrapperFrame()) {
1404-
parentContent = parentContent->GetParentOrHostNode()->AsContent();
1404+
parentContent =
1405+
parentContent->GetParentOrShadowHostNode()->AsContent();
14051406
if (parentContent) {
14061407
parentFrame = parentContent->GetPrimaryFrame();
14071408
}

browser/base/content/test/general/browser_blockHPKP.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function test() {
4343
Services.prefs.clearUserPref(kpkpEnforcementPref);
4444
Services.prefs.clearUserPref(khpkpPinninEnablePref);
4545
let uri = Services.io.newURI("https://" + kPinningDomain);
46-
gSSService.removeState(Ci.nsISiteSecurityService.HEADER_HPKP, uri, 0);
46+
gSSService.resetState(Ci.nsISiteSecurityService.HEADER_HPKP, uri, 0);
4747
});
4848
whenNewTabLoaded(window, loadPinningPage);
4949
}

browser/base/content/test/general/browser_star_hsts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ add_task(async function test_star_redirect() {
1414
let sss = Cc["@mozilla.org/ssservice;1"].getService(
1515
Ci.nsISiteSecurityService
1616
);
17-
sss.removeState(
17+
sss.resetState(
1818
Ci.nsISiteSecurityService.HEADER_HSTS,
1919
NetUtil.newURI("http://example.com/"),
2020
0

devtools/shared/webconsole/test/test_network_security-hpkp.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
.getService(Ci.nsIIOService);
5555
for (let {url} of TEST_CASES) {
5656
let uri = gIOService.newURI(url);
57-
gSSService.removeState(Ci.nsISiteSecurityService.HEADER_HPKP, uri, 0);
57+
gSSService.resetState(Ci.nsISiteSecurityService.HEADER_HPKP, uri, 0);
5858
}
5959
});
6060

devtools/shared/webconsole/test/test_network_security-hsts.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
.getService(Ci.nsIIOService);
4949

5050
let uri = gIOService.newURI(TEST_CASES[0].url);
51-
gSSService.removeState(Ci.nsISiteSecurityService.HEADER_HSTS, uri, 0);
51+
gSSService.resetState(Ci.nsISiteSecurityService.HEADER_HSTS, uri, 0);
5252
});
5353

5454
info("Test detection of HTTP Strict Transport Security.");

dom/base/FragmentOrElement.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ static nsINode* FindChromeAccessOnlySubtreeOwner(nsINode* aNode) {
759759
aNode = aNode->GetParentNode();
760760
}
761761

762-
return aNode ? aNode->GetParentOrHostNode() : nullptr;
762+
return aNode ? aNode->GetParentOrShadowHostNode() : nullptr;
763763
}
764764

765765
already_AddRefed<nsINode> FindChromeAccessOnlySubtreeOwner(
@@ -990,8 +990,8 @@ void nsIContent::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
990990
// dispatching event to Window object in a content page and
991991
// propagating the event to a chrome Element.
992992
if (targetInKnownToBeHandledScope &&
993-
nsContentUtils::ContentIsShadowIncludingDescendantOf(
994-
this, targetInKnownToBeHandledScope->SubtreeRoot())) {
993+
IsShadowIncludingInclusiveDescendantOf(
994+
targetInKnownToBeHandledScope->SubtreeRoot())) {
995995
// Part of step 11.4.
996996
// "If target's root is a shadow-including inclusive ancestor of
997997
// parent, then"

dom/base/nsContentUtils.cpp

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,32 +2200,6 @@ bool nsContentUtils::ContentIsHostIncludingDescendantOf(
22002200
return false;
22012201
}
22022202

2203-
bool nsContentUtils::ContentIsShadowIncludingDescendantOf(
2204-
const nsINode* aPossibleDescendant, const nsINode* aPossibleAncestor) {
2205-
MOZ_ASSERT(aPossibleDescendant, "The possible descendant is null!");
2206-
MOZ_ASSERT(aPossibleAncestor, "The possible ancestor is null!");
2207-
2208-
if (aPossibleAncestor == aPossibleDescendant->GetComposedDoc()) {
2209-
return true;
2210-
}
2211-
2212-
do {
2213-
if (aPossibleDescendant == aPossibleAncestor) {
2214-
return true;
2215-
}
2216-
2217-
if (aPossibleDescendant->NodeType() == nsINode::DOCUMENT_FRAGMENT_NODE) {
2218-
ShadowRoot* shadowRoot =
2219-
ShadowRoot::FromNode(const_cast<nsINode*>(aPossibleDescendant));
2220-
aPossibleDescendant = shadowRoot ? shadowRoot->GetHost() : nullptr;
2221-
} else {
2222-
aPossibleDescendant = aPossibleDescendant->GetParentNode();
2223-
}
2224-
} while (aPossibleDescendant);
2225-
2226-
return false;
2227-
}
2228-
22292203
// static
22302204
bool nsContentUtils::ContentIsCrossDocDescendantOf(nsINode* aPossibleDescendant,
22312205
nsINode* aPossibleAncestor) {
@@ -2285,7 +2259,7 @@ nsINode* nsContentUtils::Retarget(nsINode* aTargetA, nsINode* aTargetB) {
22852259
}
22862260

22872261
// or A's root is a shadow-including inclusive ancestor of B...
2288-
if (nsContentUtils::ContentIsShadowIncludingDescendantOf(aTargetB, root)) {
2262+
if (aTargetB->IsShadowIncludingInclusiveDescendantOf(root)) {
22892263
// ...then return A.
22902264
return aTargetA;
22912265
}

dom/base/nsContentUtils.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -344,13 +344,6 @@ class nsContentUtils {
344344
static bool ContentIsHostIncludingDescendantOf(
345345
const nsINode* aPossibleDescendant, const nsINode* aPossibleAncestor);
346346

347-
/**
348-
* Similar to above, but does special case only ShadowRoot,
349-
* not HTMLTemplateElement.
350-
*/
351-
static bool ContentIsShadowIncludingDescendantOf(
352-
const nsINode* aPossibleDescendant, const nsINode* aPossibleAncestor);
353-
354347
/**
355348
* Similar to nsINode::IsInclusiveDescendantOf except it crosses document
356349
* boundaries, this function uses ancestor/descendant relations in the

dom/base/nsINode.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,26 @@ bool nsINode::IsInclusiveDescendantOf(const nsINode* aNode) const {
131131
return false;
132132
}
133133

134+
bool nsINode::IsShadowIncludingInclusiveDescendantOf(
135+
const nsINode* aNode) const {
136+
MOZ_ASSERT(aNode, "The node is nullptr.");
137+
138+
if (this->GetComposedDoc() == aNode) {
139+
return true;
140+
}
141+
142+
const nsINode* node = this;
143+
do {
144+
if (node == aNode) {
145+
return true;
146+
}
147+
148+
node = node->GetParentOrShadowHostNode();
149+
} while (node);
150+
151+
return false;
152+
}
153+
134154
nsINode::nsSlots::nsSlots() : mWeakReference(nullptr) {}
135155

136156
nsINode::nsSlots::~nsSlots() {
@@ -261,7 +281,7 @@ nsINode* nsINode::GetRootNode(const GetRootNodeOptions& aOptions) {
261281
return SubtreeRoot();
262282
}
263283

264-
nsINode* nsINode::GetParentOrHostNode() const {
284+
nsINode* nsINode::GetParentOrShadowHostNode() const {
265285
if (mParent) {
266286
return mParent;
267287
}

dom/base/nsINode.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,13 @@ class nsINode : public mozilla::dom::EventTarget {
424424
*/
425425
bool IsInclusiveDescendantOf(const nsINode* aNode) const;
426426

427+
/**
428+
* https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-descendant
429+
*
430+
* @param aNode must not be nullptr.
431+
*/
432+
bool IsShadowIncludingInclusiveDescendantOf(const nsINode* aNode) const;
433+
427434
/**
428435
* Return this node as a document fragment. Asserts IsDocumentFragment().
429436
*
@@ -884,11 +891,7 @@ class nsINode : public mozilla::dom::EventTarget {
884891
*/
885892
nsINode* GetParentNode() const { return mParent; }
886893

887-
/**
888-
* This is similar to above, but in case 'this' is ShadowRoot, we return its
889-
* host element.
890-
*/
891-
nsINode* GetParentOrHostNode() const;
894+
nsINode* GetParentOrShadowHostNode() const;
892895

893896
enum FlattenedParentType { eNotForStyle, eForStyle };
894897

0 commit comments

Comments
 (0)