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.cpp30
1 files changed, 26 insertions, 4 deletions
diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
index c6f1687f73..d2c863bd65 100644
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -1767,6 +1767,17 @@ bool nsContentUtils::IsAlphanumericOrSymbol(uint32_t aChar) {
cat == nsUGenCategory::kSymbol;
}
+// static
+bool nsContentUtils::IsHyphen(uint32_t aChar) {
+ // Characters treated as hyphens for the purpose of "emergency" breaking
+ // when the content would otherwise overflow.
+ return aChar == uint32_t('-') || // HYPHEN-MINUS
+ aChar == 0x2010 || // HYPHEN
+ aChar == 0x2012 || // FIGURE DASH
+ aChar == 0x2013 || // EN DASH
+ aChar == 0x058A; // ARMENIAN HYPHEN
+}
+
/* static */
bool nsContentUtils::IsHTMLWhitespace(char16_t aChar) {
return aChar == char16_t(0x0009) || aChar == char16_t(0x000A) ||
@@ -3008,6 +3019,15 @@ nsIContent* nsContentUtils::GetCommonFlattenedTreeAncestorHelper(
}
/* static */
+nsIContent* nsContentUtils::GetCommonFlattenedTreeAncestorForSelection(
+ nsIContent* aContent1, nsIContent* aContent2) {
+ return GetCommonAncestorInternal(
+ aContent1, aContent2, [](nsIContent* aContent) {
+ return aContent->GetFlattenedTreeParentNodeForSelection();
+ });
+}
+
+/* static */
Element* nsContentUtils::GetCommonFlattenedTreeAncestorForStyle(
Element* aElement1, Element* aElement2) {
return GetCommonAncestorInternal(aElement1, aElement2, [](Element* aElement) {
@@ -11341,7 +11361,7 @@ int32_t nsContentUtils::CompareTreePosition(const nsINode* aNode1,
MOZ_ASSERT(aNode1, "aNode1 must not be null");
MOZ_ASSERT(aNode2, "aNode2 must not be null");
- if (MOZ_UNLIKELY(NS_WARN_IF(aNode1 == aNode2))) {
+ if (NS_WARN_IF(aNode1 == aNode2)) {
return 0;
}
@@ -11439,7 +11459,8 @@ nsIContent* nsContentUtils::AttachDeclarativeShadowRoot(nsIContent* aHost,
bool aIsClonable,
bool aDelegatesFocus) {
RefPtr<Element> host = mozilla::dom::Element::FromNodeOrNull(aHost);
- if (!host) {
+ if (!host || host->GetShadowRoot()) {
+ // https://html.spec.whatwg.org/#parsing-main-inhead:shadow-host
return nullptr;
}
@@ -11449,9 +11470,10 @@ nsIContent* nsContentUtils::AttachDeclarativeShadowRoot(nsIContent* aHost,
init.mSlotAssignment = SlotAssignmentMode::Named;
init.mClonable = aIsClonable;
- RefPtr shadowRoot = host->AttachShadow(init, IgnoreErrors(),
- Element::ShadowRootDeclarative::Yes);
+ RefPtr shadowRoot = host->AttachShadow(init, IgnoreErrors());
if (shadowRoot) {
+ shadowRoot->SetIsDeclarative(
+ nsGenericHTMLFormControlElement::ShadowRootDeclarative::Yes);
// https://html.spec.whatwg.org/#parsing-main-inhead:available-to-element-internals
shadowRoot->SetAvailableToElementInternals();
}