Make AutoInlineStyleSetter::OnHandled()
never set point in aContent
if it's not a container
When HTMLEditor::InsertLinkAroundSelectionAsAction()
calls
HTMLEditor::SetInlinePropertiesAsSubAction()
, it adds 2 elements to the array.
One is for _moz_dirty
attribute and the other is for href
attribute because
InsertTagCommand::DoCommandParam()
uses
HTMLEditor::CreateElementWithDefaults()
.
Then, HTMLEditor::SetInlinePropertiesAsSubAction()
wraps the <img>
into
<a _moz_dirty="">
with calling AutoInlineStyleSetter::ApplyStyle()
. Then,
it calls OnHandle()
with the <img>
and it collapse the applied range into
the <img>
. Therefore, when SetInlinePropertiesAsSubAction()
handles href
,
there is only collapsed range and it just puts the style into the cache for
applying the style when the user types new text.
So, first, OnHandle()
should not set the boundary points of the applied range
into non-container node. And also InsertLinkAroundSelectionAsAction()
should
ignore _moz_dirty
attribute because if it's truly required,
AutoInlineStyleSetter
should set the attribute to every new element.
Note that this causes new failure in editing/run/fontname.html?1001-200
,
but it was accidentally passed. The case is, queryCommandValue("fontname")
result after calling execCommand("fontname", false, "sans-serif")
for
foo<tt>{<br></tt>}bar
. The result of the DOM tree is
foo<tt><font face="sans-serif"><br></font></tt>bar
and Selection
was
collapsed in the <br>
before, but with this patch, the <br>
is selected.
Therefore, the result is changed but similar cases in the tests fail too. So I
believe that it accidentally passed with odd Selection
.
Differential Revision: https://phabricator.services.mozilla.com/D219127
bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1906559
gecko-commit: 7a33d5e7176b0e3c64ecc86e62a6df58624f2436
gecko-reviewers: m_kato