From da4c7e7ed675c3bf405668739c3012d140856109 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:34:42 +0200 Subject: Adding upstream version 126.0. Signed-off-by: Daniel Baumann --- dom/base/nsContentUtils.cpp | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'dom/base/nsContentUtils.cpp') 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) || @@ -3007,6 +3018,15 @@ nsIContent* nsContentUtils::GetCommonFlattenedTreeAncestorHelper( [](nsIContent* aContent) { return aContent->GetFlattenedTreeParent(); }); } +/* 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) { @@ -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 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(); } -- cgit v1.2.3