Граф коммитов

11389 Коммитов

Автор SHA1 Сообщение Дата
Emilio Cobos Álvarez 641fa20731 Bug 1825825 - Simplify NAC setup. r=smaug
Make all UA widgets also NAC.

Keep the UA widget flag but break at anonymous subtree boundaries, so
that only nodes inside the UA widget directly (and not NAC from those)
get the flag.

This is important because two callers depend on this difference:

 * The style system, since we still want to match content rules from
   stylesheets in the UA widget. We also match user rules, which is a
   bit sketchy, but that was the previous behavior, will file a
   follow-up for that.

 * The reflector code, since we want the scope for UA widgets to not
   include the NAC nodes inside that UA widget. nsINode::IsInUAWidget
   got it wrong.

After this patch, ChromeOnlyAccess is equivalent to
IsInNativeAnonymousSubtree, so we should probably unify the naming.
That's left for a follow-up patch because I don't have a strong
preference.

Differential Revision: https://phabricator.services.mozilla.com/D174310
2023-04-05 09:19:15 +00:00
Makoto Kato cda1a13b1c Bug 1819109 - Remove snav.enabled. r=masayuki,geckoview-reviewers,emilio,owlish
Although we have removed Spatial navigation by bug 1341737, we still touch
`snav.enabled`. Let's remove it.

Differential Revision: https://phabricator.services.mozilla.com/D172390
2023-03-22 02:40:53 +00:00
Masayuki Nakano 050517a46f Bug 1810663 - Add Gecko specific command to enable new join/split node direction r=smaug,m_kato
This API is temporarily available and useful for web app developers who want to
stop supporting Gecko specific join/split direction handling as soon as possible
and who do not want Mozilla block their release schedule by rescheduling of
shipping the new behavior.  Additionally, adding this command allows web apps
detects whether Gecko supports the new behavior and whether it's enabled.

On the other hand, We don't want to ship opt-out API because it's hard to keep
maintaining the legacy behavior specific paths.  Therefore, the command does
nothing if web app calls
`Document.execCommand("enableCompatibleJoinSplitDirection", false "false")` if
the new behavior is enabled by default.

Differential Revision: https://phabricator.services.mozilla.com/D172351
2023-03-21 23:58:04 +00:00
Kershaw Chang 5e58575e28 Bug 1809843 - Skip Failed tests, r=necko-reviewers,extension-reviewers,credential-management-reviewers,valentin,sgalich,robwu
Differential Revision: https://phabricator.services.mozilla.com/D171842
2023-03-21 09:09:58 +00:00
Masayuki Nakano e5f024930b Bug 1820972 - Make `nsBaseDragService::FireDragEventAtSource` update `mSourceNode` if it's disconnected while `HTMLEditor` deletes selection caused by a drag operation r=edgar
The source node is typically a text node, and it may be editable by
`contenteditable` or `designMode`.  In that case, the source node may be removed
during the DnD session even without tricky JS code.  In this case, Blink and
WebKit updates the source node to dispatch `dragend` to the editing host.
This behavior does not conform to the standardized DnD behavior, however,
this is reasonable for editor apps which want to listen to events in editing
host or window/document for footprint and/or performance reason.  Therefore,
we should follow their behavior.

Differential Revision: https://phabricator.services.mozilla.com/D172091
2023-03-16 06:37:18 +00:00
Masayuki Nakano 60979a1af3 Bug 1820905 - Make `HTMLEditor::SplitNodeWithTransaction` return `NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE` if split nodes have been removed from the DOM tree r=m_kato
If one of them are removed from the DOM tree, it's hard to keep handling it
since we have both split direction paths.  Therefore, let's just return error
but not throw new exception in the case.

Differential Revision: https://phabricator.services.mozilla.com/D172205
2023-03-13 18:31:00 +00:00
Masayuki Nakano f56e91369e Bug 1820448 - Make `RangeUpdater::SelAdjSplitNode` handle insertion better r=m_kato
The root cause of this bug is, we tried to compute new offset with offset at
the new node.  However, as explained in the inline comments, it should compute
the offset with the right node offset in the new mode.  Therefore, it needs
to handle it by itself instead of just calling `SelAdjInsertNode`.

Differential Revision: https://phabricator.services.mozilla.com/D171965
2023-03-13 18:30:04 +00:00
Marian-Vasile Laza ee72efd1e9 Backed out 5 changesets (bug 1809843) for causing Cargo related build bustages. CLOSED TREE
Backed out changeset 5c494680f448 (bug 1809843)
Backed out changeset 02742b38edab (bug 1809843)
Backed out changeset 2b9b32ca8294 (bug 1809843)
Backed out changeset 56631cb02ae6 (bug 1809843)
Backed out changeset 37e35a60a71f (bug 1809843)
2023-03-13 13:53:26 +02:00
Kershaw Chang a60df34ad0 Bug 1809843 - Skip Failed tests, r=necko-reviewers,extension-reviewers,credential-management-reviewers,valentin,sgalich,robwu
Differential Revision: https://phabricator.services.mozilla.com/D171842
2023-03-13 11:12:33 +00:00
Masayuki Nakano b68e3ef35e Bug 1820449 - Make `WhiteSpaceVisibilityKeeper` verify tracking point of start of right joining node after flushing the tracker r=m_kato
In the legacy mode, right node is not removed from the DOM tree, therefore,
this bug was hidden.  However, after enabling the new mode, the point will
be out of the document.  Therefore, the check will cause
`NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE` error and the joining code stops handling
the deletion.

Differential Revision: https://phabricator.services.mozilla.com/D171822
2023-03-10 02:39:26 +00:00
Tiaan Louw c8476cb106 Bug 1817641 - Convert RGBA to AbsoluteColor for computed/animated/resolved CSS colors r=emilio
Computed color values will not be in the correct format, closer to the
one specified by the author.  This also means that colors accross the
code are stored now as AbsoluteColor or StyleAbsoluteColor.  This allows
color space/gamut information to be available for use.

Some animation related test failures had to be changed, because colors
now has greater precision.  Animated a color now causes a lot more
animation updates, which was not initially expected.  See the bug for
discussion.

Differential Revision: https://phabricator.services.mozilla.com/D171021
2023-03-07 11:28:15 +00:00
Mark Banner 9bbd275235 Bug 1820593 - Convert AsyncSpellCheckTestHelper to an ES module. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D171748
2023-03-07 09:40:39 +00:00
Masayuki Nakano 31b7027bb9 Bug 1818339 - Make `AutoRangeArray` set `mAnchorFocusRange` correctly r=m_kato
There are some paths which do not set `mAnchorFocusRange` correctly.
Therefore, even if its `RangeCount()` returns 1 or larger,
`GetAnchorFocusRange()` may return `nullptr`.

Differential Revision: https://phabricator.services.mozilla.com/D171045
2023-02-28 00:46:17 +00:00
Masayuki Nakano 3b390e1249 Bug 1817127 - Make `HTMLEditUtils::ContentIsInert` check `nsStyleUI::IsInert` instead of climbing up the tree r=emilio
However, we still need to climbing up the tree when
`nsIFrame::GetPrimaryFrame()` returns `nullptr`.

`<span inert style="display:none">` cases fail in Chrome. It must be caused by
their editor's `Selection` normalization result, but I think that it's wrong
behavior because `Selection` is a DOM API and the range is `inert`ed element.
Therefore, it's odd to change the behavior from the style.

Differential Revision: https://phabricator.services.mozilla.com/D170164
2023-02-23 15:08:30 +00:00
Masayuki Nakano 806244c866 Bug 1815827 - part 6: Get rid of `editor.use_div_for_default_newlines` pref r=m_kato
Depends on D169764

Differential Revision: https://phabricator.services.mozilla.com/D169765
2023-02-21 22:54:26 +00:00
Masayuki Nakano 05f8285a93 Bug 1815827 - part 5: Get rid of `editor.resizing.preserve_ratio` pref r=m_kato
Depends on D169763

Differential Revision: https://phabricator.services.mozilla.com/D169764
2023-02-21 22:54:26 +00:00
Masayuki Nakano 2c9a95743d Bug 1815827 - part 4: Get rid of `editor.positioning.offset` pref r=m_kato
Depends on D169762

Differential Revision: https://phabricator.services.mozilla.com/D169763
2023-02-21 22:54:25 +00:00
Masayuki Nakano 893c30b69c Bug 1815827 - part 3: Get rid of `editor.initialize_element_before_connect` pref r=m_kato
Depends on D169761

Differential Revision: https://phabricator.services.mozilla.com/D169762
2023-02-21 22:54:25 +00:00
Masayuki Nakano b29a944ac4 Bug 1815827 - part 2: Get rid of `editor.hr_element.allow_to_delete_from_following_line` pref r=m_kato
Depends on D169760

Differential Revision: https://phabricator.services.mozilla.com/D169761
2023-02-21 22:54:25 +00:00
Masayuki Nakano 3fa7da3abb Bug 1815827 - part 1: Get rid of `editor.css.default_length_unit` pref r=m_kato
Depends on D169759

Differential Revision: https://phabricator.services.mozilla.com/D169760
2023-02-21 22:54:24 +00:00
Jan-Niklas Jaeschke 2243494a74 Bug 1810403: Allow `nsRange`s to be in multiple `Selection`s. r=masayuki
The Custom Highlight API allows a use case where a `Range` of a `Highlight`
is also used as `Selection`. Due to the decision to use the `Selection` mechanism
to display `Highlight`s, a `Range` can be part of several `Selection`s.
Since the `Range` has a pointer to its associated `Selection`
to notify about changes, this must be adapted to allow several `Selections`.

As a tradeoff of performance and memory usage, the `Selection`s are stored
as `mozilla::LinkedList`. A helper class `mozilla::SelectionListWrapper`
was implemented to allow `Selection`s to be in multiple of these lists
and without having to be derived from `LinkedListElement<T>`.

To simplify usage of the list, the use case  "does this range belong to Selection x?"
is wrapped into the convenience method`IsInSelection(Selection&)`;
The method previously named like this was renamed to `IsInAnySelection()`
to be named more precisely.

Registering and unregistering of the closest common inclusive ancestor
of the `Range` is done when the first `Selection` is registered and
the last `Selection` is unregistered.

Differential Revision: https://phabricator.services.mozilla.com/D169597
2023-02-21 12:25:28 +00:00
Masayuki Nakano c9f870645d Bug 1815639 - part 12: Make `AutoDeleteRangesHandler::HandleDeleteHRElement()` stop touching `Selection` r=m_kato
Depends on D169757

Differential Revision: https://phabricator.services.mozilla.com/D169758
2023-02-21 11:19:10 +00:00
Masayuki Nakano 74f7cdb361 Bug 1815639 - part 11: Make `AutoDeleteRangesHandler::HandleDeleteAtomicContent` stop touching `Selection` directly r=m_kato
Depends on D169756

Differential Revision: https://phabricator.services.mozilla.com/D169757
2023-02-21 11:11:42 +00:00
Masayuki Nakano 8f518a5dfe Bug 1815639 - part 10: Make `AutoDeleteRangesHandler::HandleDeleteCollapsedSelectionAtVisibleChar` stop touching `Selection` directly r=m_kato
Depends on D169755

Differential Revision: https://phabricator.services.mozilla.com/D169756
2023-02-21 11:04:05 +00:00
Masayuki Nakano 695da959d9 Bug 1815639 - part 9: Make `AutoDeleteRangesHandler::HandleDeleteCollapsedSelectionAtWhiteSpaces` stop touching `Selection` directly r=m_kato
Depends on D169754

Differential Revision: https://phabricator.services.mozilla.com/D169755
2023-02-21 10:51:14 +00:00
Masayuki Nakano 39598d7624 Bug 1815639 - part 8: Make `HTMLEditor::InsertBRElementIfHardLineIsEmptyAndEndsWithBlockBoundary` stop touching `Selection` directly r=m_kato
Depends on D169753

Differential Revision: https://phabricator.services.mozilla.com/D169754
2023-02-21 10:45:10 +00:00
Masayuki Nakano 5885f9eaa8 Bug 1815639 - part 7: Make `WhiteSpaceVisibilityKeeper::DeleteContentNodeAndJoinTextNodesAroundIt` stop touching `Selection` directly r=m_kato
Depends on D169752

Differential Revision: https://phabricator.services.mozilla.com/D169753
2023-02-21 10:38:26 +00:00
Masayuki Nakano 95cc0ff327 Bug 1815639 - part 6: Make `DeletePreviousWhiteSpace` and `DeleteInclusiveNextWhiteSpace` of `WhiteSpaceVisibilityKeeper` stop touching `Selection` directly r=m_kato
Depends on D169751

Differential Revision: https://phabricator.services.mozilla.com/D169752
2023-02-21 10:22:08 +00:00
Masayuki Nakano fb45899c39 Bug 1815639 - part 5: Make `WhiteSpaceVisibilityKeeper::ReplaceText` stop touching `Selection` directly r=m_kato
Depends on D169750

Differential Revision: https://phabricator.services.mozilla.com/D169751
2023-02-21 09:41:11 +00:00
Masayuki Nakano 389decf989 Bug 1815639 - part 4: Make `AutoDeleteRangesHandler::HandleDeleteAroundCollapsedRanges` stop touching `Selection` directly r=m_kato
Depends on D169749

Differential Revision: https://phabricator.services.mozilla.com/D169750
2023-02-21 09:23:55 +00:00
Masayuki Nakano e9ec95c8ea Bug 1815639 - part 3: Make `WhiteSpaceVisibilityKeeper::MakeSureToKeepVisibleStateOfWhiteSpacesAroundDeletingRange` stop touching `Selection` directly r=m_kato
Depends on D169748

Differential Revision: https://phabricator.services.mozilla.com/D169749
2023-02-21 09:18:26 +00:00
Masayuki Nakano e03a3dbc90 Bug 1815639 - part 2: Make `WhiteSpaceVisibilityKeeper::DeleteInvisibleASCIIWhiteSpaces` stop touching `Selection` directly r=m_kato
Depends on D169747

Differential Revision: https://phabricator.services.mozilla.com/D169748
2023-02-21 08:29:48 +00:00
Masayuki Nakano d99c927e45 Bug 1815639 - part 1: Make `HTMLEditor::DeleteTextAndTextNodesWithTransaction` stop touching `Selection` directly r=m_kato
Depends on D169746

Differential Revision: https://phabricator.services.mozilla.com/D169747
2023-02-21 08:19:56 +00:00
Masayuki Nakano 48306992dd Bug 1812493 - Make the test wait for "load" of iframe if it's not yet ended r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D170029
2023-02-17 15:35:04 +00:00
Masayuki Nakano 6daaabe189 Bug 1815383 - part 3: Make `ReplaceTextTransaction::DoTransaction` stop updating `Selection` directly r=m_kato
And also this changes `HTMLEditor::ReplaceTextWithTransaction` which is the only
user of `ReplaceTextTransaction`.

Depends on D169745

Differential Revision: https://phabricator.services.mozilla.com/D169746
2023-02-17 09:42:31 +00:00
Masayuki Nakano e75ea6a30f Bug 1815383 - part 2: Make `InsertText` and `ReplaceText` of `WhiteSpaceVisibilityKeeper` return `InsertTextResult` r=m_kato
Depends on D169744

Differential Revision: https://phabricator.services.mozilla.com/D169745
2023-02-17 08:48:13 +00:00
Masayuki Nakano b1b8ae7fb7 Bug 1815383 - part 1: Make `InsertTextTransaction::DoTransaction` stop updating `Selection` directly r=m_kato
And also this patch makes its only user,
`EditorBase::InsertTextIntoTextNodeWithTransaction`, and its only caller,
`EditorBase::InsertTextWithTransaction`, return `InsertTextResult` for
returning both end of inserted text and caret point suggestion.  Note that
if it's for IME composition, `CompositionTransaction` needs to update
`Selection` directly.  Therefore, caret point may be unset under composition
to updating `Selection` to wrong point (it seems that
`TextEditor::HandleInsertText` can be simplified later because of this change).

Depends on D169044

Differential Revision: https://phabricator.services.mozilla.com/D169744
2023-02-17 08:25:24 +00:00
Olli Pettay 21d3624930 Bug 1816312, try to avoid creating Range objects in some common cases when spellchecker is disabled for contentEditable, r=masayuki
This is not very optimimal, but tracking spellchecking state in DOM tree is tricky because of multiple contentEditables and possibility to set spellcheck true/false anywhere etc.
At least this helps with the testcase quite a bit.

Differential Revision: https://phabricator.services.mozilla.com/D169870
2023-02-16 11:48:13 +00:00
Masayuki Nakano cc43626912 Bug 1810902 - Make `HTMLEditUtils::GetRangeSelectingAllContentInAllListItems` return correct range r=m_kato
`AutoDeleteRangesHandler::Run` shrink the range not to delete list item if
the list is not empty.  However, due to the bug of
`HTMLEditUtils::GetRangeSelectingAllContentInAllListItems`, it may get empty
range (in the testcase, first the only `<li>` element is the list has empty
text node as first child, and the range is collapsed into it).  Therefore,
`AutoDeleteRangesHandler::Run` gives up to delete the list items, but does not
update the `Selection`.  Therefore, from the caller point of view, `Selection`
is unexpectedly not collapsed even after deleting `Selection`.

Therefore, this patch also makes `AutoDeleteRangeHandler::Run` collapse
`Selection` if it gives up to delete something.

Differential Revision: https://phabricator.services.mozilla.com/D169044
2023-02-15 23:00:12 +00:00
Masayuki Nakano bfb8a73f52 Bug 1797247 - part 6: Make `AutoDeleteRangesHandler::FallbackToDeleteRangesWithTransaction` stop touching `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D169043
2023-02-15 22:53:12 +00:00
Masayuki Nakano c2c61ff76b Bug 1797247 - part 5: Make `EditorBase::DeleteTextWithTransaction` and `HTMLEditor::DeleteTextWithTransaction` stop touching `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D169042
2023-02-15 22:46:42 +00:00
Masayuki Nakano 9fc0118afc Bug 1797247 - part 4: Make `EditorBase::DeleteRangesWithTransaction` not touch `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D169041
2023-02-15 22:40:14 +00:00
Masayuki Nakano f99f4540be Bug 1797247 - part 3: Make `EditorBase::DeleteRangesWithTransaction` do post-processing without `Selection` r=m_kato
Due to the loose error checks, this patch changes the behavior in edge cases.
E.g., if there is a case that `Selection` is extended by some unexpected JS
listeners/observers, the result may be different.  However, it must be not a
problem because normal web apps should handle it later.

Differential Revision: https://phabricator.services.mozilla.com/D169040
2023-02-15 22:31:09 +00:00
Masayuki Nakano b8589fff01 Bug 1797247 - part 2: Make `DeleteTextTransaction::DoTransaction` and `DeleteRangeTransaction::DoTransaction` stop updating `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D169039
2023-02-15 22:23:34 +00:00
Masayuki Nakano 2c93600238 Bug 1797247 - part 1: Add delete transaction classes to use build time type checks r=m_kato
First, `EditorBase::CreateTransactionForDeleteSelection` returns an instance of
`EditAggregateTransaction`. It's a base class of `PlaceholderTransaction` and
`DeleteRangeTransaction` but it's also a concrete class.  However, it's too
generic.  Therefore, this patch creates `DeleteMultipleRangesTransaction` which
is a simple sub-class of it, and makes `EditAggregateTransaction` be an abstract
class.  Then, add `AddChild` methods to each concrete class to restrict the
type of child transactions.

Next, `DeleteRangeTransaction` contains only `DeleteNodeTransaction` and
`DeleteTextTransaction`.  Therefore, once they have a common base class,
we can check the type easier.  Therefore, this patch also adds
`DeleteContentTransactionBase` and
`EditorBase::CreateTransactionForCollapsedRange` becomes clearer what it
returns.

With these changes, `DeleteRangeTransaction` obviously contains only
`DeleteContentTransactionBase`, `DeleteMultipleRangesTransaction` contains only
`DeleteRangeTransaction`, `DeleteNodeTransaction` and `DeleteTextTransaction`.
And they are guaranteed at build time (at least from outside the classes).
***
fix

Differential Revision: https://phabricator.services.mozilla.com/D169038
2023-02-15 22:17:17 +00:00
Masayuki Nakano 5b5580f50e Bug 1816039 - Make `HTMLEditor` handle selection ranges which starts from or ends in `<foo inert>` r=m_kato
According to the WPTs and their result in the other browsers, we should:
* do not work with a range anchored from a node in an element which has `inert`.
* collapse the range first when it ends at a node in an element which has `inert`.

See new WPT for the detail.

Note that `inert` with `contenteditable` must not be so major cases.  Therefore,
this patch does not fix the edge cases like the `nsFrameSelection` use cases
and replacing `Selection` cases of the other edit commands/operations.

Depends on D169037

Differential Revision: https://phabricator.services.mozilla.com/D169743
2023-02-15 22:06:31 +00:00
Masayuki Nakano 596489c6c2 Bug 1814074 - Make `AutoDeleteRangesHandler::ExtendOrShrinkRangeToDelete` consider whether all list items are selected more carefully r=m_kato
It currently check range boundaries are start/end of a list element.  However,
there are a lot of cases.  E.g., selection can starts and/or ends inner
position due to invisible white-spaces and sub-lists.

The expectations of the new tests are based on Chrome's result.  However,
unfortunately, the joining result of sub-lists is different from Chrome.
Therefore, they fail.  (Gecko makes each list element has one list item.)

Differential Revision: https://phabricator.services.mozilla.com/D169037
2023-02-14 03:05:48 +00:00
Masayuki Nakano 8fff5403c8 Bug 1809129 - part 5: Make `AutoListElementCreator` copy attributes at replacing block elements r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D168871
2023-02-14 02:51:32 +00:00
Masayuki Nakano 74993d63c8 Bug 1809129 - part 3: Make `HTMLEditor::AutoListElementCreator` handle `<p>` same as `<div>` r=m_kato
`AutoListElementCreator::HandleChildParagraphElement` assumes that `<p>` never
has block children, but it's wrong because web apps can put any element under
any element with DOM API.   Therefore, we should handle `<p>` in
`HandleChildDivElement` too.

Then, it causes new failures at:
* Handling first `<p>` met before creating first list element
* Handling empty `<p>` element

These failures have not been detected with `<div>` yet because there are only
tests for `<p>`.  Therefore, these failures also existing bugs of the `<div>`
handler.  For solving these issues, we need to create a list element with an
empty list item or only an empty list item element before unwrapping `<div>`
(and `<p>`).  Then, unwrapped inline elements correctly moved to new list item
elements.  Additionally, it needs not to reuse previous list item element which
accepted inline contents outside `<div>` (and `<p>`) for keeping the line break
caused by the `<div>`.

For adding duplication the lambda method code of new calls of
`HTMLEditor::CreateAndInsertElement`, this patch creates shared static methods.

Differential Revision: https://phabricator.services.mozilla.com/D168869
2023-02-14 02:51:32 +00:00
Masayuki Nakano 9784a7e4b4 Bug 1809129 - part 2-2: Split `AutoListElementCreator::WrapContentNodesIntoNewListElements` r=m_kato
This patch moves each chunk of the `for` loop code to a new method and moves
all over the `for` loop code into `HandleChildContent` for making it possible
to call it recursively in `HandleChildDivElement` to avoid touching the array.

For sharing the state of `for` loop, this patch creates `AutoHandlingState`
in `AutListElementCreator` and make the new handlers take it and update them
if necessary.  This approach makes it clearer that which method is a handler
in the `for` loop, and makes it safer to break the loop outside with updating
members.

Differential Revision: https://phabricator.services.mozilla.com/D168868
2023-02-14 00:52:20 +00:00