Bug 1930050 - Make AutoRangeArray check the container type r=m_kato, a=dmeehan

Differential Revision: https://phabricator.services.mozilla.com/D228624
This commit is contained in:
Masayuki Nakano 2024-11-13 08:17:03 +00:00
parent d177494855
commit 86ae9bb8ab
3 changed files with 23 additions and 0 deletions

View file

@ -665,6 +665,7 @@ GetPointAtFirstContentOfLineOrParentHTMLBlockIfFirstContentOfBlock(
// If we're formatting a block, we should reformat first ancestor format
// block.
if (aEditSubAction == EditSubAction::eFormatBlockForHTMLCommand &&
point.IsContainerElement() &&
HTMLEditUtils::IsFormatElementForFormatBlockCommand(
*point.ContainerAs<Element>())) {
point.Set(point.GetContainer());
@ -836,6 +837,7 @@ static EditorDOMPoint GetPointAfterFollowingLineBreakOrAtFollowingHTMLBlock(
// If we're formatting a block, we should reformat first ancestor format
// block.
if (aEditSubAction == EditSubAction::eFormatBlockForHTMLCommand &&
point.IsContainerElement() &&
HTMLEditUtils::IsFormatElementForFormatBlockCommand(
*point.ContainerAs<Element>())) {
point.SetAfter(point.GetContainer());

View file

@ -278,6 +278,11 @@ class EditorDOMPointBase final {
return mParent && mParent->IsInNativeAnonymousSubtree();
}
/**
* Returns true if the container node is an element node.
*/
bool IsContainerElement() const { return mParent && mParent->IsElement(); }
/**
* IsContainerHTMLElement() returns true if the container node is an HTML
* element node and its node name is aTag.

View file

@ -0,0 +1,16 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script>
"use strict";
document.addEventListener("DOMContentLoaded", () => {
document.documentElement.contentEditable = "true";
document.execCommand("formatBlock", false, "h3");
}, {once: true});
</script>
</head>
<body>
text
<!-- no-final-newline -->