36 Commits
Author SHA1 Message Date
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 cec7115214 Bug 1996500 - part 2: Make WSRunScanner ignore empty inline containers by default r=m_kato
In the most cases, the scanner users should ignore empty inline
containers so that the behavior should be the default behavior.
Then, the options becomes clearer what the callers can expect.

Differential Revision: https://phabricator.services.mozilla.com/D284963
2026-03-04 06:59:49 +00:00
Masayuki Nakano d670a975c9 Bug 1996500 - part 1: Make HTMLEditUtils have APIs for handling unnecessary line breaks r=m_kato
Perhaps, we should stop using "visible" from the API names because
some API users use the methods while modifying the DOM.  Therefore, the
new APIs explain the position of a line break or whether it's
significant or unnecessary from the layout point of view.

This patch adds API to check a line break position which may return
following/preceding block boundary's element and to scan following
block boundary with ignoring unnecessary line break which is done in
some places with calling
`WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary()` twice.

Additionally, making the extant internal API mainly `HTMLEditUtils`
use the new API to do the correct handling.

Note that this makes `HTMLEditUtils::GetLeafNodeType` return `Ignore`
if the caller does not want invisible things and the node is in
`display:none` element.  This change is required to keep passing some
tests whose editing host is `display:inline` and it's followed by
invisible text like `<script>`.

Differential Revision: https://phabricator.services.mozilla.com/D284962
2026-03-04 06:59:46 +00:00
Masayuki Nakano 4fa12d7518 Bug 2009323 - part 1: Make RangeBoundaryBase have some factory methods which take only a child node r=jjaschke,dom-core
`RangeBoundaryBase` allows to be initialized with invalid data for
allowing the users to use it as a validator.  However, this is bad,
and now it supports 2 tree kinds.  So, the users need to be familiar
with the relation of a child node and its parent and its offset when
they use `TreeKind::Flat`.  For making it easier to use, this patch
adds some new factory methods which automatically computes proper
parent/offset for a node with the `TreeKind`.

Differential Revision: https://phabricator.services.mozilla.com/D279306
2026-01-25 23:20:51 +00:00
agoloman 83e701e107 Revert "Bug 2009323 - part 2: Make RangeBoundaryBase disallow invalid DOM point at creation when pointing to a child node r=jjaschke,dom-core" for causing conflicts when backing out Bug 2009323.
This reverts commit 5728aae19d.

Revert "Bug 2009323 - part 1: Make `RangeBoundaryBase` have some factory methods which take only a child node r=jjaschke,dom-core"

This reverts commit 41c5bea4d5.
2026-01-23 14:51:12 +00:00
Masayuki Nakano 41c5bea4d5 Bug 2009323 - part 1: Make RangeBoundaryBase have some factory methods which take only a child node r=jjaschke,dom-core
`RangeBoundaryBase` allows to be initialized with invalid data for
allowing the users to use it as a validator.  However, this is bad,
and now it supports 2 tree kinds.  So, the users need to be familiar
with the relation of a child node and its parent and its offset when
they use `TreeKind::Flat`.  For making it easier to use, this patch
adds some new factory methods which automatically computes proper
parent/offset for a node with the `TreeKind`.

Differential Revision: https://phabricator.services.mozilla.com/D279306
2026-01-23 05:14:49 +00:00
Masayuki Nakano 1afcba4cc6 Bug 1998077 - part 3: Add new options to ignore empty/invisible leaf nodes r=m_kato
This adds some options which ignore some types of inline elements.

For example, `IgnoreAnyEmptyInlineContainers` is useful to scan previous
or next editable point because Chrome ignores empty inline elements when
deleting from next to an inline element.

`IgnoreInvisibleInlineVoidElements` is useful to scan invisible line
break from end of a block or checking a line break is invisible because
visible inline element makes a line after the last line break. E.g.,
```html
<div>ABC<br><span></span></div>
```
This shows only one line. However,
```html
<div>ABC<br><span style="border:1px solid"></span></div>
```
This shows 2 lines in the `<div>`.

Additionally, renaming the existing `LeafNodeType` values for making
them easier to understand.

Differential Revision: https://phabricator.services.mozilla.com/D277520
2026-01-13 05:27:41 +00:00
Masayuki Nakano d9e52c123e Bug 1998077 - part 2: Add WSType::EmptyInlineContainerElement r=m_kato
An empty inline container element such as `<span></span>` has 2
meanings, if it's visible with specified style, e.g., has non-zero
padding, it should be treated like a replaced element like `<img>`.
However, if it's invisible, it should be treated as `Comment` or
empty `Text`.  Therefore, the scanner users need a special handling for
them in some cases.  So, it should be identified with the new `WSType`.

Unfortunately, neither
`HTMLEditUtils::IsInclusiveAncestorCSSDisplayNone` nor
`HTMLEditUtils::IsVisibleElementEvenIfLeafNode` is testable within
GTest because it does not have layout information.

Differential Revision: https://phabricator.services.mozilla.com/D277519
2026-01-13 05:27:38 +00:00
Sandor Molnar b77ea8700f Revert "Bug 1998077 - part 7: Reimplement HTMLEditUtils::GetInclusiveDeepestFirstChildWhichHasOneChild with LeafNodeOptions r=m_kato" for causing build bustages @ WSRunScanner.cpp
This reverts commit 5ccf392dce.

Revert "Bug 1998077 - part 6: Reimplement `HTMLEditUtils::Get(First|Last)Child()` and `HTMLEditUtils::Get(Next|Previous)Sibling()` with `LeafNodeOptions` r=m_kato"

This reverts commit 12eb928cb5.

Revert "Bug 1998077 - part 5: Replace the remaining `HTMLEditUtils::Get(Next|Previous)Content()` with new ones based on `Get(Next|Previous)LeafNodeOr(Next|Previous)BlockElement()` r=m_kato"

This reverts commit 58b4243d10.

Revert "Bug 1998077 - part 4: Replace some callers of `HTMLEditUtils::Get(Next|Previous)Content()` with `HTMLEditUtils::Get(Next|Previous)LeafContentOr(Next|Previous)BlockElement()` r=m_kato"

This reverts commit dd46967eb4.

Revert "Bug 1998077 - part 3: Add new options to ignore empty/invisible leaf nodes r=m_kato"

This reverts commit ca50a4a628.

Revert "Bug 1998077 - part 2: Add `WSType::EmptyInlineContainerElement` r=m_kato"

This reverts commit 4a5d93d631.

Revert "Bug 1998077 - part 1: Make `HTMLEditUtils::IsVisibleElementEvenIfLeafNode` work better if primary frame is available r=m_kato"

This reverts commit b42dc9d35f.
2026-01-07 06:15:59 +00:00
Masayuki Nakano ca50a4a628 Bug 1998077 - part 3: Add new options to ignore empty/invisible leaf nodes r=m_kato
This adds some options which ignore some types of inline elements.

For example, `IgnoreAnyEmptyInlineContainers` is useful to scan previous
or next editable point because Chrome ignores empty inline elements when
deleting from next to an inline element.

`IgnoreInvisibleInlineVoidElements` is useful to scan invisible line
break from end of a block or checking a line break is invisible because
visible inline element makes a line after the last line break. E.g.,
```html
<div>ABC<br><span></span></div>
```
This shows only one line. However,
```html
<div>ABC<br><span style="border:1px solid"></span></div>
```
This shows 2 lines in the `<div>`.

Additionally, renaming the existing `LeafNodeType` values for making
them easier to understand.

Differential Revision: https://phabricator.services.mozilla.com/D277520
2026-01-07 01:12:46 +00:00
Masayuki Nakano 4a5d93d631 Bug 1998077 - part 2: Add WSType::EmptyInlineContainerElement r=m_kato
An empty inline container element such as `<span></span>` has 2
meanings, if it's visible with specified style, e.g., has non-zero
padding, it should be treated like a replaced element like `<img>`.
However, if it's invisible, it should be treated as `Comment` or
empty `Text`.  Therefore, the scanner users need a special handling for
them in some cases.  So, it should be identified with the new `WSType`.

Unfortunately, neither
`HTMLEditUtils::IsInclusiveAncestorCSSDisplayNone` nor
`HTMLEditUtils::IsVisibleElementEvenIfLeafNode` is testable within
GTest because it does not have layout information.

Differential Revision: https://phabricator.services.mozilla.com/D277519
2026-01-07 01:12:43 +00:00
Masayuki Nakano 59dac6a3e4 Bug 1996758 - Make WSRunScanner and HTMLEditUtils return Comment within optional behavior r=m_kato
They should stop at a `Comment` node or treat `Command` as "visible"
node only when:
- The caller wants to handle only with current or adjacent `Text` node
- The caller wants to list all invisible nodes until the first visible thing

In other words, most users must want to ignore `Comment` nodes.
Therefore, their default behavior should be so but they should treat
`Comment` nodes in an optional mode.

Differential Revision: https://phabricator.services.mozilla.com/D270461
2025-11-05 06:34:33 +00:00
Masayuki Nakano 6983335537 Bug 1996501 - part 2: Make WSRunScanner take an EnumSet instead of a set of Scan and BlockInlineCheck r=m_kato
It's not required explicitly to specify
`BlockInlineCheck::UseComputedDisplayStyle` and
`BlockInlineCheck::UseComputedDisplayOutsideStyle` to `WSRunScanner`
too.  And it should take an `EnumSet` for making it easier to maintain
the class in the future.

Differential Revision: https://phabricator.services.mozilla.com/D270117
2025-10-31 05:05:10 +00:00
Masayuki Nakano 94124bfa08 Bug 1996501 - part 1: Make TextFragmentData refer proper display value for the scanning direction r=m_kato
In theory, scanning from outside to inside, i.e., checking a sibling
or a child, `display-outside` should be used to check whether the
element is a block or an inline. Similarly, scanning from inside to
outside, i.e., checking a parent, `display-inside` should be used to
check whether the element is a block or an inline.

`HTMLEditUtils`'s related methods are low API, but `WSRunScanner` is
higher API.  Therefore, I think `WSRunScanner` should work with the
theory.

This patch makes the internal scanner of `WSRunScanner`,
`TextFragmentData`, take only whether refer HTML default style or CSS
style and consider itself whether use
`BlockInlineCheck::UseComputedDisplayOutsideStyle` or
`BlockInlineCheck::UseComputedDisplayStyle`.

So, this patch should fix some edge case bugs of
`display: inline-block`.  However, unfortunately, there is not enough
tests for that.

Differential Revision: https://phabricator.services.mozilla.com/D270116
2025-10-31 05:05:07 +00:00
Jan-Niklas Jaeschke 0151e67615 Bug 1949053, part 2 - Rename nsTextFragment to mozilla::dom::CharacterDataBuffer. r=masayuki
This patch updates all occurrences of the type `nsTextFragment` into its new name, `mozilla::dom::CharacterDataBuffer`.
It also updates the includes, including sorting.

Differential Revision: https://phabricator.services.mozilla.com/D259867
2025-08-06 08:48:01 +00:00
Masayuki Nakano 997bf4b02b Bug 1976608 - Make WSRunScanner::Scan*VisibleNodeOrBlockBoundary ignore Comments r=m_kato
They are internal APIs to return next/previous visible thing or
a padding `<br>` element.  However, when they reach a `Comment`, they
don't skip it and return it as a special content.  `Comment` is always
invisible so that they should skip such invisible nodes.

Differential Revision: https://phabricator.services.mozilla.com/D257125
2025-07-14 23:39:37 +00:00
Masayuki Nakano 7369030c9e Bug 1949969 - Fix the early return of WSRunScanner::GetFirstVisiblePoint r=m_kato
It's obviously wrong, but I don't find how to make us hit here with the
traditional white-space normalizer, but this will cause new failure once
applying the patches for bug 1940377.  Therefore, this does not have a new
test, but it'll be tested by extant tests soon.

Differential Revision: https://phabricator.services.mozilla.com/D239270
2025-02-26 05:57:18 +00:00
Masayuki Nakano 085a371a0c Bug 1943656 - Make TextFragmentData::BoundaryData::ScanCollapsibleWhiteSpace(End|Start)From treat the ancestor limiter is a block when display: inline-block r=m_kato
Chromium considers whether an element is block or inline with `display-outside`.
Therefore, they treat `inline-block` is an inline element.  For following the
behavior, we use `BlockInlineCheck::UseComputedDisplayOutsideStyle` in many
places.  However, if `WSRunScanner` works for considering a collapsible
white-space visibility, it needs to treat `inline-block` as a block only when
it's an ancestor.

In the reported case, the editing host is `inline-block`.  So, `WSRunScanner`
reached the ancestor limiter if scanning only editable nodes.  To fix this bug,
this changes the behavior only when the scanner reached the ancestor limiter.

In the future, we need to change the scanner methods of `HTMLEditUtils`
use the new inline methods.

Differential Revision: https://phabricator.services.mozilla.com/D235530
2025-01-28 11:11:13 +00:00
Masayuki Nakano 6538e13b56 Bug 1926483 - part 5: Fix some assertion failures which assume WSRunScanner works only with editable nodes r=m_kato
Depends on D233794

Differential Revision: https://phabricator.services.mozilla.com/D234648
2025-01-24 05:00:48 +00:00
Masayuki Nakano 649fa91881 Bug 1926483 - part 3: Make various WSRunScanner static methods take WSRunScanner::Scan and ancestor limiter r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D233793
2025-01-24 05:00:48 +00:00
Masayuki Nakano 395226db0c Bug 1926483 - part 1: Make WSRunScanner instance free from editing host r=m_kato
If it scans starting from a editable point, it does not require the editing
host as an ancestor limiter.  Therefore, some users can be free from editing
host.

Differential Revision: https://phabricator.services.mozilla.com/D233791
2025-01-24 05:00:47 +00:00
Butkovits Atila 173aee505b Backed out 5 changesets (bug 1926483) for causing failures at WSRunScanner.h. CLOSED TREE
Backed out changeset fa4c36cef1c5 (bug 1926483)
Backed out changeset 24bdcd7af3e0 (bug 1926483)
Backed out changeset 1df51ca968f8 (bug 1926483)
Backed out changeset 7aceecb585e4 (bug 1926483)
Backed out changeset 41b040b374a2 (bug 1926483)
2025-01-23 07:35:22 +02:00
Masayuki Nakano 2ddc3752c6 Bug 1926483 - part 5: Fix some assertion failures which assume WSRunScanner works only with editable nodes r=m_kato
Depends on D233794

Differential Revision: https://phabricator.services.mozilla.com/D234648
2025-01-23 05:01:57 +00:00
Masayuki Nakano 3558629798 Bug 1926483 - part 3: Make various WSRunScanner static methods take WSRunScanner::Scan and ancestor limiter r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D233793
2025-01-23 05:01:56 +00:00
Masayuki Nakano d36ef81488 Bug 1926483 - part 1: Make WSRunScanner instance free from editing host r=m_kato
If it scans starting from a editable point, it does not require the editing
host as an ancestor limiter.  Therefore, some users can be free from editing
host.

Differential Revision: https://phabricator.services.mozilla.com/D233791
2025-01-23 05:01:56 +00:00
Masayuki Nakano c6b4e944ef Bug 1939220 - part 6: Make TextFragmentData free from the editing host r=m_kato
It stores the editing host. However, its role is scan the DOM from a point in
a block containing the point.  Therefore, it can know which node is editing
host when it scans without computing the editing host.  So, it does not need
to be specified the editing host.

Then, it can scan non-editable DOM too.  Therefore, this extends some utility
methods of `HTMLEditUtils` which are used by `TextFragmentData` and
`BoundaryData`.

Differential Revision: https://phabricator.services.mozilla.com/D232937
2025-01-20 08:03:59 +00:00
Masayuki Nakano 0e10d664fc Bug 1939220 - part 5: Make TextFragmentData::Get(EndOf|First)CollapsibleASCIIWhiteSpaces possible to scan non-editable text too r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D232936
2025-01-20 08:03:59 +00:00
Masayuki Nakano 693817ee11 Bug 1939220 - part 4: Make TextFragmentData::Get(InclusiveNext|Previous)EditableCharPoint possible to scan non-editable text too r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D232935
2025-01-20 08:03:58 +00:00
Masayuki Nakano 5b0da1a66e Bug 1939220 - part 2: Split WSRunScanner.cpp to define the methods of the nested classes r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D232933
2025-01-20 08:03:57 +00:00
Masayuki Nakano 771489d350 Bug 1939220 - part 1: Split WSRunObject files for WSRunScanner and WhiteSpaceVisibilityKeeper r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D232932
2025-01-20 08:03:57 +00:00
Sandor Molnar 11ae540bbc Backed out 6 changesets (bug 1939220) for causing build bustages CLOSED TREE
Backed out changeset b15602e6fbf5 (bug 1939220)
Backed out changeset 129d2cd2e11e (bug 1939220)
Backed out changeset b663c3b349f0 (bug 1939220)
Backed out changeset cbd9e4f12bd2 (bug 1939220)
Backed out changeset 81260f9e6677 (bug 1939220)
Backed out changeset f33e7201796d (bug 1939220)
2025-01-20 05:02:53 +02:00
Masayuki Nakano 6fd78fc633 Bug 1939220 - part 6: Make TextFragmentData free from the editing host r=m_kato
It stores the editing host. However, its role is scan the DOM from a point in
a block containing the point.  Therefore, it can know which node is editing
host when it scans without computing the editing host.  So, it does not need
to be specified the editing host.

Then, it can scan non-editable DOM too.  Therefore, this extends some utility
methods of `HTMLEditUtils` which are used by `TextFragmentData` and
`BoundaryData`.

Differential Revision: https://phabricator.services.mozilla.com/D232937
2025-01-19 23:35:36 +00:00
Masayuki Nakano 9242ecc01e Bug 1939220 - part 5: Make TextFragmentData::Get(EndOf|First)CollapsibleASCIIWhiteSpaces possible to scan non-editable text too r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D232936
2025-01-19 23:35:36 +00:00
Masayuki Nakano 9c1b22c086 Bug 1939220 - part 4: Make TextFragmentData::Get(InclusiveNext|Previous)EditableCharPoint possible to scan non-editable text too r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D232935
2025-01-19 23:35:36 +00:00
Masayuki Nakano bdebf6b629 Bug 1939220 - part 2: Split WSRunScanner.cpp to define the methods of the nested classes r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D232933
2025-01-19 23:35:35 +00:00
Masayuki Nakano 0537c53049 Bug 1939220 - part 1: Split WSRunObject files for WSRunScanner and WhiteSpaceVisibilityKeeper r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D232932
2025-01-19 23:35:34 +00:00