Commit Graph
19 Commits
Author SHA1 Message Date
serge-sans-paille 20546b3e3c Bug 2038252 - Work around conflicting define in rpcndr.h in libeditor r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D299386
2026-05-10 20:10:48 +00:00
Sylvestre Ledru 9f5cc05eee Bug 2023419 - Remove Emacs/Vim modelines from editor/ r=masayuki
replaced by .editorconfig
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D287844
2026-03-16 12:52:41 +00:00
Masayuki Nakano 1c1025a6e6 Bug 1814337 - Fix bugs at applying multiple styles to collapsed Selection r=m_kato
There are 3 bugs.

One is, `PendingStyles::TakeAllPreservedStyles` returns styles in reversed order
of setting styles, this unexpected order causes that `<font>` element is placed
innermost instead of outermost, thus, background color may be applied to shorter
area than text.  Unfortunately, Chrome applies the style in fixed order, but
using same order as setting the styles is reasonable for us because we use
same code to apply multiple styles once.

Another is, `AutoInlineStyleSetter` extends the range to apply new style to
parents even if the given point is not in start or end of the first container.
Current code works fine if there is only one text node in an inline element,
but after un-setting a style, text nodes may be keep split.  And also when we
apply new style, we create an empty text node for a placeholder of new text,
therefore, the range may be extended from the empty text node to before/after
its previous/next text node.  Note that the latter case needs to work with
invisible things more, but this bug needs to be fixed ASAP due to the dead line,
and invisible things not so appear in inline elements.  Therefore, it's okay
to leave it.

The other is, the delete handlers do not clear the cached styles (cached when
`HTMLEditor` starts handling it).  If it's caused by a `Backspace` key press
in start of a block, `HTMLEditor` caches the style at caret (right paragraph),
then, collapse `Selection` to end of the ex-left block where may have different
style, then, when user types new text there, the cached style is applied into
to the new text **too**.  Therefore, if `Selection` was collapsed and handling
a `Backspace` key press, the cached styles should be forgotten.

Depends on D168640

Differential Revision: https://phabricator.services.mozilla.com/D168865
2023-02-07 14:52:02 +00:00
Masayuki Nakano b785efe281 Bug 1808906 - Make the style editor handle <font> at last when there are multiple preserved styles r=m_kato
Height of inline elements are considered with current `font-size` and
`line-height`.  Therefore, if content in inline elements are taller, the
`background-color` does not fill the bigger content background entirely.
For solving this issue, Chrome handles styles of `<font>` element as
outer-most style.  This is reasonable approach, let's follow this.

For solving this issue, we can change the order of `PreservedStyle`s at setting
the preserved styles.  Then, `SetInlinePropertiesAsSubAction` is called with
reversed order and apply later style first and applies newer styles to all
content in an element which is previously inserted.  Therefore, the `<font>`
element styles should be last elements of `PendingStyles::mPreservingStyles`.

When applying new style, our style editor does not reuse existing `<font>`
element, and this causes writing WPT harder.  Therefore, this patch also changes
the applying range of `<font>` style to wrapping existing `<font>` element if
and only if its content is entirely selected.

Unfortunately, this approach cannot get exactly same result as Chrome because we
insert outer-most `<font>` element first, then, try to apply `background-color`,
at this moment, our style editor applies the style to the previously inserted
`<font>` element instead of creating new `<span>` element.  This behavior is
required for compatibility in the other cases.  Additionally, changing only this
behavior requires a lot of method changes to specify how to handle it.  However,
this incompatible behavior may not cause any problems in web apps in the wild.
Therefore, this patch does not solve this incompatible issue.  I think that once
we get a bug report caused by this difference, we should redesign how to set
multiple inline styles once.

Differential Revision: https://phabricator.services.mozilla.com/D166617
2023-01-17 23:46:58 +00:00
Marian-Vasile Laza 30127aeb18 Backed out changeset cb55480eb7ff (bug 1808906) for causing wpt failures on multitest.html. CLOSED TREE 2023-01-17 13:00:33 +02:00
Masayuki Nakano f18e2bfef5 Bug 1808906 - Make the style editor handle <font> at last when there are multiple preserved styles r=m_kato
Height of inline elements are considered with current `font-size` and
`line-height`.  Therefore, if content in inline elements are taller, the
`background-color` does not fill the bigger content background entirely.
For solving this issue, Chrome handles styles of `<font>` element as
outer-most style.  This is reasonable approach, let's follow this.

For solving this issue, we can change the order of `PreservedStyle`s at setting
the preserved styles.  Then, `SetInlinePropertiesAsSubAction` is called with
reversed order and apply later style first and applies newer styles to all
content in an element which is previously inserted.  Therefore, the `<font>`
element styles should be last elements of `PendingStyles::mPreservingStyles`.

When applying new style, our style editor does not reuse existing `<font>`
element, and this causes writing WPT harder.  Therefore, this patch also changes
the applying range of `<font>` style to wrapping existing `<font>` element if
and only if its content is entirely selected.

Unfortunately, this approach cannot get exactly same result as Chrome because we
insert outer-most `<font>` element first, then, try to apply `background-color`,
at this moment, our style editor applies the style to the previously inserted
`<font>` element instead of creating new `<span>` element.  This behavior is
required for compatibility in the other cases.  Additionally, changing only this
behavior requires a lot of method changes to specify how to handle it.  However,
this incompatible behavior may not cause any problems in web apps in the wild.
Therefore, this patch does not solve this incompatible issue.  I think that once
we get a bug report caused by this difference, we should redesign how to set
multiple inline styles once.

Differential Revision: https://phabricator.services.mozilla.com/D166617
2023-01-17 05:44:08 +00:00
Masayuki Nakano d75253ccaa Bug 1807829 - Make HTMLEditor::CreateStyleForInsertText use same logic as HTMLEditor::SetInlinePropertiesAsSubAction to apply new style r=m_kato
The problem in Yahoo mail is, when you apply new font size to:
```
<div><font size="7">{}<br></font></div>
```

then, when you type text, you'll get:
```
<div><font size="7"><font size="4">abc<br></font></font></div>
```

because `HTMLEditor::CreateStyleForInsertText` does not check ancestors to
apply new style to empty text node which is created by the method for
placeholder.  Of course, the other browsers update the existing
`<font size="7">` instead and we should follow it.

However, there are 3 problems:
1. Our editor may adjust insertion point to nearest editable text node if caret
in empty inline elements.
2. Our editor supports increase/decrease font size which have been removed from
`Document.execCommand`, but Thunderbird keeps using it, and that's implemented
with an independent method.
3. Our style editor code does not support applying style to collapsed selection.

Therefore, this patch does:
1. keep create empty text node to apply new style at specific point.
2. give up to use new path if there is preserved font size increment/decrement.
3. separate `HTMLEditor::SetInlinePropertiesAsSubAction` and add new path for
applying style to collapsed range.

Then, `HTMLEditor::CreateStyleForInsertText` can use
`HTMLEditor::SetInlinePropertiesAsSubAction` which supports handling new styles
with existing ancestors.

Differential Revision: https://phabricator.services.mozilla.com/D166416
2023-01-17 05:26:14 +00:00
Cosmin Sabou 874a4583b0 Backed out changeset dfd4ec691465 (bug 1807829) for causing bp-hybrid bustages on HTMLEditUtils.h. CLOSED TREE 2023-01-17 03:44:41 +02:00
Sandor Molnar 2454027ce5 Backed out changeset 649e12877126 (bug 1808906) for causing bp-hybrid bustages. 2023-01-17 03:18:05 +02:00
Masayuki Nakano 06a160716d Bug 1808906 - Make the style editor handle <font> at last when there are multiple preserved styles r=m_kato
Height of inline elements are considered with current `font-size` and
`line-height`.  Therefore, if content in inline elements are taller, the
`background-color` does not fill the bigger content background entirely.
For solving this issue, Chrome handles styles of `<font>` element as
outer-most style.  This is reasonable approach, let's follow this.

For solving this issue, we can change the order of `PreservedStyle`s at setting
the preserved styles.  Then, `SetInlinePropertiesAsSubAction` is called with
reversed order and apply later style first and applies newer styles to all
content in an element which is previously inserted.  Therefore, the `<font>`
element styles should be last elements of `PendingStyles::mPreservingStyles`.

When applying new style, our style editor does not reuse existing `<font>`
element, and this causes writing WPT harder.  Therefore, this patch also changes
the applying range of `<font>` style to wrapping existing `<font>` element if
and only if its content is entirely selected.

Unfortunately, this approach cannot get exactly same result as Chrome because we
insert outer-most `<font>` element first, then, try to apply `background-color`,
at this moment, our style editor applies the style to the previously inserted
`<font>` element instead of creating new `<span>` element.  This behavior is
required for compatibility in the other cases.  Additionally, changing only this
behavior requires a lot of method changes to specify how to handle it.  However,
this incompatible behavior may not cause any problems in web apps in the wild.
Therefore, this patch does not solve this incompatible issue.  I think that once
we get a bug report caused by this difference, we should redesign how to set
multiple inline styles once.

Depends on D166416

Differential Revision: https://phabricator.services.mozilla.com/D166617
2023-01-16 23:59:45 +00:00
Masayuki Nakano 11d6e9bc6d Bug 1807829 - Make HTMLEditor::CreateStyleForInsertText use same logic as HTMLEditor::SetInlinePropertiesAsSubAction to apply new style r=m_kato
The problem in Yahoo mail is, when you apply new font size to:
```
<div><font size="7">{}<br></font></div>
```

then, when you type text, you'll get:
```
<div><font size="7"><font size="4">abc<br></font></font></div>
```

because `HTMLEditor::CreateStyleForInsertText` does not check ancestors to
apply new style to empty text node which is created by the method for
placeholder.  Of course, the other browsers update the existing
`<font size="7">` instead and we should follow it.

However, there are 3 problems:
1. Our editor may adjust insertion point to nearest editable text node if caret
in empty inline elements.
2. Our editor supports increase/decrease font size which have been removed from
`Document.execCommand`, but Thunderbird keeps using it, and that's implemented
with an independent method.
3. Our style editor code does not support applying style to collapsed selection.

Therefore, this patch does:
1. keep create empty text node to apply new style at specific point.
2. give up to use new path if there is preserved font size increment/decrement.
3. separate `HTMLEditor::SetInlinePropertiesAsSubAction` and add new path for
applying style to collapsed range.

Then, `HTMLEditor::CreateStyleForInsertText` can use
`HTMLEditor::SetInlinePropertiesAsSubAction` which supports handling new styles
with existing ancestors.

Differential Revision: https://phabricator.services.mozilla.com/D166416
2023-01-16 23:42:27 +00:00
Andrew McCreight 188ac80e29 Bug 1805931, part 2 - Automated removal of uses of ROOT and UNROOT CC macros. r=smaug
As of the prior patch, these are no longer needed. I removed
these with a script, then ran clang-format on the files, then
manually reverted a few unrelated changed from the formatter.

Differential Revision: https://phabricator.services.mozilla.com/D164829
2022-12-15 19:45:01 +00:00
Masayuki Nakano 2c93609e80 Bug 1801028 - part 8: Make HTMLEditor::SetInlinePropertyOnNode and HTMLEditor::SetInlinePropertyOnNodeImpl take EditorInlineStyleAndValue r=m_kato
They are called each other. Therefore, this patch changes them once.

Depends on D162507

Differential Revision: https://phabricator.services.mozilla.com/D162508
2022-11-25 05:20:49 +00:00
Masayuki Nakano a52e6adf9a Bug 1801028 - part 4: Make HTMLEditor::ClearStyleAt take EditorInlineStyle r=m_kato
Depends on D162503

Differential Revision: https://phabricator.services.mozilla.com/D162504
2022-11-25 02:15:51 +00:00
Masayuki Nakano a8f6e15d50 Bug 1801028 - part 3: Make HTMLEditor::GetInlinePropertyBase take EditorInlineStyle r=m_kato
Depends on D162502

Differential Revision: https://phabricator.services.mozilla.com/D162503
2022-11-25 00:54:55 +00:00
Andrew McCreight 3f5dddd6cd Bug 1794811, part 1 - Include nsISupports.h instead of nsISupportsBase.h. r=necko-reviewers,nika,valentin
nsISupports.h includes nsISupportsBase.h, so it should be equivalent.

In the next patch, I'm changing things so that nsISupports is defined in
nsISupports.h instead of nsISupportsBase.h, and deleting the latter, so
this change will be needed anyways. I'm guessing people were using IWYU
or something like that.

Differential Revision: https://phabricator.services.mozilla.com/D159169
2022-10-17 16:09:22 +00:00
Masayuki Nakano 0b074382f7 Bug 1793694 - part 3: Move definitions of JoinNodesDirection and SplitNodeDirection into a new exposed header file r=m_kato
They are used in public inline methods of `HTMLEditor`.  Therefore, they should
be defined in an exposed header file without other internal use things for the
editor module.  Then, we can stop exposing `HTMLEditHelpers.h`.

Depends on D158632

Differential Revision: https://phabricator.services.mozilla.com/D158633
2022-10-12 02:44:18 +00:00
Masayuki Nakano 4b66b7255f Bug 1784192 - part 10: Make PendingStyles::GetTypeInState() return an enum class instead of taking 2 bool out parameters r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D155319
2022-08-26 03:31:26 +00:00
Masayuki Nakano a31e91fc29 Bug 1784192 - part 9: Rename TypeInState to PendingStyles r=m_kato
Additionally,
* `PropItem` -> `PendingStyle`
* `StyleCache` -> `PendingStyleCache`
* `AutoStyleCacheArray` -> `AutoPendingStyleCacheArray`

And finally, `PendingStyle` (formally `PropItem`) is changed to `class` and
its members are encapsuled.

Differential Revision: https://phabricator.services.mozilla.com/D155318
2022-08-26 03:31:26 +00:00