summaryrefslogtreecommitdiffstats
path: root/dom/base/nsContentUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/base/nsContentUtils.cpp')
-rw-r--r--dom/base/nsContentUtils.cpp41
1 files changed, 26 insertions, 15 deletions
diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
index d849b13927..c6f1687f73 100644
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -3027,13 +3027,15 @@ bool nsContentUtils::PositionIsBefore(nsINode* aNode1, nsINode* aNode2,
}
/* static */
-Maybe<int32_t> nsContentUtils::ComparePoints(
- const nsINode* aParent1, uint32_t aOffset1, const nsINode* aParent2,
- uint32_t aOffset2, ComparePointsCache* aParent1Cache) {
+Maybe<int32_t> nsContentUtils::ComparePoints(const nsINode* aParent1,
+ uint32_t aOffset1,
+ const nsINode* aParent2,
+ uint32_t aOffset2,
+ NodeIndexCache* aIndexCache) {
bool disconnected{false};
const int32_t order = ComparePoints_Deprecated(
- aParent1, aOffset1, aParent2, aOffset2, &disconnected, aParent1Cache);
+ aParent1, aOffset1, aParent2, aOffset2, &disconnected, aIndexCache);
if (disconnected) {
return Nothing();
}
@@ -3044,7 +3046,7 @@ Maybe<int32_t> nsContentUtils::ComparePoints(
/* static */
int32_t nsContentUtils::ComparePoints_Deprecated(
const nsINode* aParent1, uint32_t aOffset1, const nsINode* aParent2,
- uint32_t aOffset2, bool* aDisconnected, ComparePointsCache* aParent1Cache) {
+ uint32_t aOffset2, bool* aDisconnected, NodeIndexCache* aIndexCache) {
if (aParent1 == aParent2) {
return aOffset1 < aOffset2 ? -1 : aOffset1 > aOffset2 ? 1 : 0;
}
@@ -3089,10 +3091,15 @@ int32_t nsContentUtils::ComparePoints_Deprecated(
if (MOZ_UNLIKELY(child2->IsShadowRoot())) {
return 1;
}
- const Maybe<uint32_t> child1Index =
- aParent1Cache ? aParent1Cache->ComputeIndexOf(parent, child1)
- : parent->ComputeIndexOf(child1);
- const Maybe<uint32_t> child2Index = parent->ComputeIndexOf(child2);
+ Maybe<uint32_t> child1Index;
+ Maybe<uint32_t> child2Index;
+ if (aIndexCache) {
+ aIndexCache->ComputeIndicesOf(parent, child1, child2, child1Index,
+ child2Index);
+ } else {
+ child1Index = parent->ComputeIndexOf(child1);
+ child2Index = parent->ComputeIndexOf(child2);
+ }
if (MOZ_LIKELY(child1Index.isSome() && child2Index.isSome())) {
return *child1Index < *child2Index ? -1 : 1;
}
@@ -3110,7 +3117,9 @@ int32_t nsContentUtils::ComparePoints_Deprecated(
if (!pos1) {
const nsINode* child2 = parents2.ElementAt(--pos2);
- const Maybe<uint32_t> child2Index = parent->ComputeIndexOf(child2);
+ const Maybe<uint32_t> child2Index =
+ aIndexCache ? aIndexCache->ComputeIndexOf(parent, child2)
+ : parent->ComputeIndexOf(child2);
if (MOZ_UNLIKELY(NS_WARN_IF(child2Index.isNothing()))) {
return 1;
}
@@ -3119,8 +3128,8 @@ int32_t nsContentUtils::ComparePoints_Deprecated(
const nsINode* child1 = parents1.ElementAt(--pos1);
const Maybe<uint32_t> child1Index =
- aParent1Cache ? aParent1Cache->ComputeIndexOf(parent, child1)
- : parent->ComputeIndexOf(child1);
+ aIndexCache ? aIndexCache->ComputeIndexOf(parent, child1)
+ : parent->ComputeIndexOf(child1);
if (MOZ_UNLIKELY(NS_WARN_IF(child1Index.isNothing()))) {
return -1;
}
@@ -4004,7 +4013,8 @@ nsresult nsContentUtils::LoadImage(
int32_t aLoadFlags, const nsAString& initiatorType,
imgRequestProxy** aRequest, nsContentPolicyType aContentPolicyType,
bool aUseUrgentStartForChannel, bool aLinkPreload,
- uint64_t aEarlyHintPreloaderId) {
+ uint64_t aEarlyHintPreloaderId,
+ mozilla::dom::FetchPriority aFetchPriority) {
MOZ_ASSERT(aURI, "Must have a URI");
MOZ_ASSERT(aContext, "Must have a context");
MOZ_ASSERT(aLoadingDocument, "Must have a document");
@@ -4041,7 +4051,7 @@ nsresult nsContentUtils::LoadImage(
initiatorType, /* the load initiator */
aUseUrgentStartForChannel, /* urgent-start flag */
aLinkPreload, /* <link preload> initiator */
- aEarlyHintPreloaderId, aRequest);
+ aEarlyHintPreloaderId, aFetchPriority, aRequest);
}
// static
@@ -11426,6 +11436,7 @@ int32_t nsContentUtils::CompareTreePosition(const nsINode* aNode1,
nsIContent* nsContentUtils::AttachDeclarativeShadowRoot(nsIContent* aHost,
ShadowRootMode aMode,
+ bool aIsClonable,
bool aDelegatesFocus) {
RefPtr<Element> host = mozilla::dom::Element::FromNodeOrNull(aHost);
if (!host) {
@@ -11436,7 +11447,7 @@ nsIContent* nsContentUtils::AttachDeclarativeShadowRoot(nsIContent* aHost,
init.mMode = aMode;
init.mDelegatesFocus = aDelegatesFocus;
init.mSlotAssignment = SlotAssignmentMode::Named;
- init.mClonable = true;
+ init.mClonable = aIsClonable;
RefPtr shadowRoot = host->AttachShadow(init, IgnoreErrors(),
Element::ShadowRootDeclarative::Yes);