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

10631 Коммитов

Автор SHA1 Сообщение Дата
Masayuki Nakano b5ce8cc8c4 Bug 1720436 - Make `test_bug408231.html` specify default `font-familiy` explicitly r=m_kato
It checks default `font-family` with editing commands, but it depends on the
system locale. ("serif" vs. "sans-serif").  So, its `<body>` should be styled
as `font-family: serif` for consistent behavior in any environment.

Differential Revision: https://phabricator.services.mozilla.com/D119871
2021-07-15 10:46:55 +00:00
Masayuki Nakano 04b41051dd Bug 1665550 - part 4: Make `EventStateManager` update `mGestureDownFrameOwner` when anonymous nodes in `<input>` or `<textarea>` are replaced r=smaug
`EventStateManager` gives up to track gesture to start a drag if mouse down
content which is stored in `mGestureDownFrameOwner` gets lost its primary frame.

When user tries to start to drag selected text in `<input>` or `<textarea>`
element, mouse down content is an anonymous node in `TextControlElement`. So,
if a reflow occurs after `mousedown` event, the anonymous `<div>` element
is replaced with new one and `EventStateManager` gives up to track it.

Therefore, this patch makes `EventStateManager` do similar things as
`nsBaseDragService`.  When `nsTextControlFrame` notifies of remove/add
the anonymous nodes, `EventStateManager` tries to keep tracking gesture with
a new anonymous node.

Differential Revision: https://phabricator.services.mozilla.com/D119488
2021-07-14 01:20:20 +00:00
Masayuki Nakano a171e12db6 Bug 1665550 - part 3: Make `nsTextControlFrame` set the source node and selection of drag session to new ones when it's reframed r=smaug
When `nsTextControlFrame` is reframed, `TextEditor`, anonymous `<div>`, its
`Text` and the independent `Selection`s are deleted temporarily and recreated
them.

If users are dragging text in `<input>` or `<textarea>`, the drag session's
source node is set to the anonymous text node in the element and the selection
is set to the independent selection.  So, if the element is reframed during a
drag, the source node is disconnected from the document and `EndDragSession`
failed to dispatch `eDragEnd` event.

Therefore, this patch makes `nsTextControlFrame` replaces the source node and
selection when it's recreated and only when the drag session's original source
node was in the text control element.  For checking which text control had the
anonymous text node, this patch makes `nsTextControlFrame` replaces source
node with the `<input>` or `<textarea>` element when the frame is destroyed.

Differential Revision: https://phabricator.services.mozilla.com/D119487
2021-07-14 01:20:19 +00:00
Masayuki Nakano e577d75b11 Bug 1665550 - part 2: Rewrite `test_dragdrop.html` with IIEF r=m_kato
With IIEF, we can guarantee each test block isolated.  So, without declaring
semi-global variables a lot for all tests, developers can comment out every
tests to debug only one thing.

Differential Revision: https://phabricator.services.mozilla.com/D119486
2021-07-14 01:20:19 +00:00
Masayuki Nakano 0324a4e4ef Bug 1665550 - part 1: Make `test_dragdrop.html` handle exception from synthesizePlainDragAndDrop r=m_kato
When the test is timed out, there is a JS error which is thrown by
`synthesizePlainDragAndDrop`.  So, first, make the test handle exception
with `try-catch` and assert the error.

Differential Revision: https://phabricator.services.mozilla.com/D119485
2021-07-14 01:20:18 +00:00
Masayuki Nakano 886c96059e Bug 1718924 - part 18: Move some blocks which work with `TextServicesDocument::mOffsetTable` into new separated methods r=m_kato
Depends on D119164

Differential Revision: https://phabricator.services.mozilla.com/D119165
2021-07-13 11:19:22 +00:00
Masayuki Nakano 1fbcf183f9 Bug 1718924 - part 17: Move `TextServicesDocument::mSelectionStartOffsetInTexInBlock` and `TextServicesDocument::mSelectionEndOffsetInTextInBlock` into `OffsetEntryTable` r=m_kato
Depends on D119163

Differential Revision: https://phabricator.services.mozilla.com/D119164
2021-07-13 11:09:57 +00:00
Masayuki Nakano abfa8fead9 Bug 1718924 - part 16: Move `TextServicesDocument::RemoveInvalidOffsetEntries()` to `OffsetEntry` r=m_kato
Depends on D119162

Differential Revision: https://phabricator.services.mozilla.com/D119163
2021-07-13 11:03:56 +00:00
Masayuki Nakano d3e59b2f42 Bug 1718924 - part 15: Move `TextServicesDocument::mSelStartIndex` and `TextServicesDocument::mSelEndIndex` into `OffsetEntryArray` r=m_kato
They are indices of `OffsetEntryArray`. Therefore, they should be managed in it.

Depends on D119161

Differential Revision: https://phabricator.services.mozilla.com/D119162
2021-07-13 10:57:48 +00:00
Masayuki Nakano 987147357a Bug 1718924 - part 14: Move `TextServicesDocument::SplitOffsetEntry` to `OffsetEntryArray` r=m_kato
Depends on D119160

Differential Revision: https://phabricator.services.mozilla.com/D119161
2021-07-13 10:51:46 +00:00
Masayuki Nakano f4d6fde8cd Bug 1718924 - part 13: Move `TextServicesDocument::NodeHasOffsetEntry()` into `OffsetEntryArray` r=m_kato
Depends on D119159

Differential Revision: https://phabricator.services.mozilla.com/D119160
2021-07-13 10:46:40 +00:00
Masayuki Nakano 5f44d6166c Bug 1718924 - part 12: Move `TextServicesDocument::FindWordBounds()` to `OffsetEntryArray` r=m_kato
Depends on D119158

Differential Revision: https://phabricator.services.mozilla.com/D119159
2021-07-13 10:19:40 +00:00
Masayuki Nakano e2aec22fef Bug 1718924 - part 11: Create custom class of `nsTArray<UniquePtr<OffsetEntry>>` r=m_kato
There are some methods in `TextServicesDocument` which work only with
`TextServicesDocument::mOffsetTable`.  Once we move such methods to custom
class of `nsTArray<UniquePtr<OffsetEntry>>`, we can make `TextServicesDocument`
simpler.

Depends on D119157

Differential Revision: https://phabricator.services.mozilla.com/D119158
2021-07-13 10:11:06 +00:00
Masayuki Nakano 3169bc5de5 Bug 1720252 - Get rid of "dom.input_events.beforeinput.enabled" from tests r=smaug
`beforeinput` event was shipped and it won't be disabled for avoiding confusion
of web developers. So, we can drop the pref setting of
"dom.input_events.beforeinput.enabled" in our tests.

Depends on D119716

Differential Revision: https://phabricator.services.mozilla.com/D119729
2021-07-13 10:02:12 +00:00
Masayuki Nakano afce03d9c7 Bug 1718924 - part 10: Make all `OffsetEntry` instances unique pointers r=m_kato
Now, it stores `dom::Text` with `OwningNonNull`.  So, once it's leaked, it
wastes a lot of memory spaces.  Therefore, we should make `mOffsetTable`
store `UniquePtr<OffsetEntry>` instead of `OffsetEntry*`.

Depends on D119156

Differential Revision: https://phabricator.services.mozilla.com/D119157
2021-07-13 09:55:59 +00:00
Masayuki Nakano b8ea33dddf Bug 1718924 - part 9: Rename `TextServicesDocument::mSel(Start|End)Offset` r=m_kato
Now, the meaning of `OffsetEntry` is clear.  Therefore, this patch adds comment
explaining the class and its members.

Then, the meaning of `TextServicesDocument::mSelStartOffset` and
`TextServicesDocument::mSelEndOffset` becomes clearer since they are used to
create `OffsetEntry` instances.  Therefore, this patch renames them.

Depends on D119155

Differential Revision: https://phabricator.services.mozilla.com/D119156
2021-07-13 09:42:34 +00:00
Masayuki Nakano 9ccb5fd526 Bug 1718924 - part 8: Add `OffsetEntry::OffsetInTextInBlockIsInRangeOrEndOffset()` r=m_kato
Depends on D119154

Differential Revision: https://phabricator.services.mozilla.com/D119155
2021-07-13 09:06:04 +00:00
Masayuki Nakano 36c6e61f3c Bug 1718924 - part 7: Add `OffsetEntry::EndOffsetInTextInBlock()` r=m_kato
Depends on D119153

Differential Revision: https://phabricator.services.mozilla.com/D119154
2021-07-13 08:49:47 +00:00
Masayuki Nakano 91272b59bb Bug 1718924 - part 6: Rename `OffsetEntry::mStrOffset` to `mOffsetInTextInBlock` r=m_kato
Depends on D119152

Differential Revision: https://phabricator.services.mozilla.com/D119153
2021-07-13 08:42:01 +00:00
Masayuki Nakano d1c80af6c8 Bug 1718924 - part 5: Add `OffsetEntry::OffsetInTextNodeIsInRangeOrEndOffset()` r=m_kato
Depends on D119151

Differential Revision: https://phabricator.services.mozilla.com/D119152
2021-07-13 08:42:00 +00:00
Masayuki Nakano 84f8568e67 Bug 1718924 - part 4: Add `OffsetEntry::EndOffsetInTextNode()` r=m_kato
Depends on D119150

Differential Revision: https://phabricator.services.mozilla.com/D119151
2021-07-13 08:35:32 +00:00
Masayuki Nakano 59ed2fb43b Bug 1718924 - part 3: Rename `OffsetEntry::mNodeOffset` to `mOffsetInTextNode` r=m_kato
Depends on D119149

Differential Revision: https://phabricator.services.mozilla.com/D119150
2021-07-13 08:20:13 +00:00
Masayuki Nakano f7a5d2ebbe Bug 1718924 - part 2: Change `OffsetEntry::mNode` to `OwningNonNull<Text>` r=m_kato
Now, `mNode` is always a text node, and it may store across "can run script"
boundaries.  So, it should be `OwningNonNull<Text>`.

Depends on D119148

Differential Revision: https://phabricator.services.mozilla.com/D119149
2021-07-13 08:20:13 +00:00
Masayuki Nakano bbfaac5e36 Bug 1718924 - part 1: Get rid of `TextServicesDocument::IsTextNode()` and use `AsText()` if it's safe r=m_kato
It seems that it treats mainly a text node in various places, but it's not
guaranteed by any variable declarations.  So, first of all, I'd like to make
it clearer.

`TextServicesDocument::IsTextNode()` isn't necessary because `nsINode::IsText()`
is enough useful.  And `AsText()` should be zero cost at runtime.  So, in blocks
which guarantee specific content node is a text node, this patch appends
`AsText()` for making the code clearer.

Differential Revision: https://phabricator.services.mozilla.com/D119148
2021-07-13 08:13:11 +00:00
Masayuki Nakano b94d2d1076 Bug 1719669 - Fix the reverse loop in `SelectionState::SaveSelection()` r=m_kato
The crash is caused by the infinite loop to delete unnecessary ranges.
The `i` is always equals or larger than `0` due to unsigned.  So, if
`Selection::RangeCount()` is `0`, `i` can be `UINT32_MAX`.

Instead, we can use `nsTArray<RefPtr<RangeItem>>::TruncateLength()`.

Differential Revision: https://phabricator.services.mozilla.com/D119564
2021-07-12 07:52:32 +00:00
Masayuki Nakano a81636618b Bug 1719387 - Make `test_bug795418-2.html` request `text/unicode` flavor in the headless mode r=smaug
Until fixing bug 1686012, clipboard in the headless mode does not support
"text/html" flavor.  Therefore, the `waitForClipboard` in the test does not
get expected value as `aData` in the first callback.

So, it should request `text/unicode` in the headless mode.

Depends on D119483

Differential Revision: https://phabricator.services.mozilla.com/D119484
2021-07-12 03:55:21 +00:00
Masayuki Nakano f9bedeed22 Bug 1719387 - Make `HTMLEditor::HandleInsertText()` allow to insert text outside `<body>` in XHTML document r=m_kato
With the change of bug 1716863, it retrieves editing host, but it's `nullptr`
if there is no `<body>` element in XHTML document.  The root cause should be
fixed in bug 1697989, but for now, we should allow it only in XHTML document
for safer regression fix.

Differential Revision: https://phabricator.services.mozilla.com/D119483
2021-07-12 03:55:21 +00:00
Masayuki Nakano 5dd777bdc1 Bug 1716863 - Make `HTMLEditor::HandleInsertText()` climb up the tree when `Selection` is in elements which cannot have text nodes r=m_kato
In most cases, it's called with selection range which is collapsed in a text
node, but otherwise, the selection may be in an element which cannot have
text nodes.  Therefore, before handling the insertion, it should look for
ancestor element which can have text nodes.

Note that this patch makes inserting text immediately before an inclusive
ancestor element whose parent can have a text node.  However, both Blink and
WebKit ignores if there are invisible/empty inline nodes.  So, even with
this patch, Gecko keeps failing in some tests of the WPT.  It should be handled
in a follow up bug because doing it requires complicated code.

Differential Revision: https://phabricator.services.mozilla.com/D119065
2021-07-06 04:55:28 +00:00
Masayuki Nakano 637a88b524 Bug 1718815 - part 4: Move `EditorBase::AppendNodeToSelectionAsRange()` and `EditorBase::ClearSelection()` to `HTMLEditor` r=m_kato
Depends on D119003

Differential Revision: https://phabricator.services.mozilla.com/D119004
2021-07-02 08:23:46 +00:00
Masayuki Nakano 46d18deed5 Bug 1718815 - part 3: Move `EditorBase::AutoTransactionBatch` to `HTMLEditor` r=m_kato
I guess that this class is replaced with `AutoPlaceholderBatch`, and both of
them are followed by its instances.  However, I don't want to change the
behavior in this bug.  Therefore, this patch just moves it into `HTMLEditor`.

Depends on D119002

Differential Revision: https://phabricator.services.mozilla.com/D119003
2021-07-02 08:23:45 +00:00
Masayuki Nakano a68528b057 Bug 1718815 - part 2: Move `EditorBase::AutoSelectionRestorer` and `EditorBase` methods called only by it to `HTMLEditor` r=m_kato
Unfortunately, marking its constructor and destructor as `MOZ_CAN_RUN_SCRIPT`,
`Maybe<AutoSelectionRestorer>::reset()` and
`Maybe<AutoSelectionRestorer>::emplace()` cause bustage.  Therefore, this patch
just mark them as `MOZ_CAN_RUN_SCRIPT_BOUNDARY`.

Note that `EditorBase::SavedSelectionRef()` cannot be moved to `HTMLEditor`
because `mEditActionData` is a private member of `EditorBase`.

Depends on D119001

Differential Revision: https://phabricator.services.mozilla.com/D119002
2021-07-02 08:23:45 +00:00
Masayuki Nakano 7ac37b46ec Bug 1718815 - part 1: Move `EditorBase::AddTransactionListener()` and `EditorBase::RemoveTransactionListener()` to `HTMLEditor` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D119001
2021-07-02 08:23:44 +00:00
Masayuki Nakano 1fc0882ecc Bug 1718607 - Make `TextServicesDocument` use `uint32_t` for offset in DOM node r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D118955
2021-06-30 09:07:35 +00:00
Masayuki Nakano 347bc5719a Bug 1714914 - Make editor classes treat offset in parent node as uint32_t r=m_kato
It should be treated as `uint32_t` since DOM API does so.  However, there are
some exceptions:

* Result of `nsINode::ComputeIndexOf()`
* Result of `nsAString` methods

They return `-1` as not found, and anyway, they cannot treat large integer
than `INT32_MAX`.  Therefore, this patch does not touch around them.

Differential Revision: https://phabricator.services.mozilla.com/D118933
2021-06-30 07:07:28 +00:00
Masayuki Nakano f8426533d4 Bug 1717178 - part 8: Get rid of `nsIEditor.doTransaction()` because of unused r=m_kato
Depends on D118803

Differential Revision: https://phabricator.services.mozilla.com/D118805
2021-06-28 12:08:51 +00:00
Masayuki Nakano 917dc274f8 Bug 1717178 - part 7: Get rid of `nsIEditor::AddEditorObserver()` and `nsIEditorObserver` interface because of unused r=m_kato
Depends on D118802

Differential Revision: https://phabricator.services.mozilla.com/D118803
2021-06-28 12:08:51 +00:00
Masayuki Nakano 5017e990c8 Bug 1717178 - part 6: Get rid of `nsIHTMLEditor.setCaretAfterElement()` because of unused r=m_kato
Depends on D118801

Differential Revision: https://phabricator.services.mozilla.com/D118802
2021-06-28 12:08:51 +00:00
Masayuki Nakano 3e099ba376 Bug 1717178 - part 5: Get rid of `nsIHTMLEditor.pasteNoFormatting()` because of unused r=m_kato
Depends on D118800

Differential Revision: https://phabricator.services.mozilla.com/D118801
2021-06-28 12:08:50 +00:00
Masayuki Nakano bc454f8841 Bug 1717178 - part 4: Get rid of `nsIHTMLEditor.getInlineProperty()` because of unused r=m_kato
Only `test_bug1140105.html` is its user, but it can be replaced with
`getInlinePropertyWithAttrValue()` since they do exactly same things:
https://searchfox.org/mozilla-central/rev/fc95c6ad297d9d257f05599d01741503f3f57326/editor/libeditor/HTMLStyleEditor.cpp#1685-1687,1719-1721

Depends on D118799

Differential Revision: https://phabricator.services.mozilla.com/D118800
2021-06-28 12:08:50 +00:00
Masayuki Nakano 4ac1a649ab Bug 1717178 - part 3: Get rid of `nsIHTMLObjectResizer.refreshResizers()` because of unused r=m_kato
Depends on D118798

Differential Revision: https://phabricator.services.mozilla.com/D118799
2021-06-28 12:08:49 +00:00
Masayuki Nakano ab7d00e972 Bug 1717178 - part 2: Get rid of `nsIHTMLAbsPosEditor.refreshGrabber()` because of unused r=m_kato
Depends on D118797

Differential Revision: https://phabricator.services.mozilla.com/D118798
2021-06-28 12:08:49 +00:00
Masayuki Nakano 807bae35f4 Bug 1717178 - part 1: Get rid of `nsIHTMLInlineTableEditor.refreshInlineTableEditingUI()` because of unused r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D118797
2021-06-28 12:08:49 +00:00
Masayuki Nakano ca0a51ea08 Bug 1716408 - Make enable `test_cut_copy_password.html` in all cases r=m_kato
The fix of bug 1676702 made the test stable.  So, let's try to enable it in
any environment.

Depends on D118758

Differential Revision: https://phabricator.services.mozilla.com/D118759
2021-06-28 06:31:08 +00:00
Masayuki Nakano 0b53199bb0 Bug 1676702 - part 3: Make `TextControlState` store unmasked range while it does not have `TextEditor` r=m_kato
`TextControlState` is alive during reframing, but `TextEditor` is not so.
Therefore, `TextControlState` should take the `PasswordMaskData` before
`TextEditor` is destroyed.  And if `TextEditor` is recreated, and the value
hasn't been modified, unmasked range should be restored in the new editor.

Depends on D118757

Differential Revision: https://phabricator.services.mozilla.com/D118758
2021-06-28 04:37:54 +00:00
Masayuki Nakano 63d372da2f Bug 1676702 - part 2: Make `TextControlState` initialize `TextEditor` with `PasswordMaskData` r=m_kato
During a `TextControlState` alive, `PasswordMaskData` should be alive too.
Otherwise, we cannot keep unmasked range at reframing.

Depends on D118756

Differential Revision: https://phabricator.services.mozilla.com/D118757
2021-06-28 04:37:54 +00:00
Masayuki Nakano 30130a49c1 Bug 1676702 - part 1: Make `TextEditor` store password masking data in a struct r=m_kato
The intermittent failure is caused by unexpected global reflow during the test.
If `<input type="password">` is reframed, `TextEditor` instance is recreated.
Then, the unmasked range of the editor stored by `TextEditor` is also lost.
Therefore, unmasked range is randomly lost by unexpected reflow.

If the global reflow is occurred by font list update etc which are not expected
by users, unmasked password field is unexpectedly masked.  So, this is a real
bug of `TextEditor`.

So, unmasked range needs to be stored outside `TextEditor` for making its
lifetime longer than `TextEditor`.  For doing it, first, `TextEditor` should
access password mask data via a pointer to a struct.  Then, fortunately,
we need to allocate it only when the `TextEditor` is a password editor.

Depends on D118755

Differential Revision: https://phabricator.services.mozilla.com/D118756
2021-06-28 04:37:53 +00:00
Masayuki Nakano 8927b994ea Bug 1676702 - part 0: Add automated tests for keeping unmasked range during reflows r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D118755
2021-06-28 04:37:53 +00:00
Masayuki Nakano 88b5b85325 Bug 1717749: Drop `MOZ_ASSERT` check for `nsIEditor.eEditorMailMask` r=m_kato
In my understanding at fixing bug 1717156, `nsIEditor.eEditorMailMask` won't be
set to `TextEditor` instance.  However for making consistent **spellchecker**
behavior on email composer, subject editor is also set this flag.  So, we need
to drop the check in `SetFlags` and IsMailEditor.

Differential Revision: https://phabricator.services.mozilla.com/D118561
2021-06-23 23:01:48 +00:00
Masayuki Nakano dcc8404a03 Bug 1717156 - part 7: Revert the change of the debug `printf` in `TextEditor.cpp` r=m_kato
I forgot to revert this before landing.

Differential Revision: https://phabricator.services.mozilla.com/D118447
2021-06-22 10:33:44 +00:00
Masayuki Nakano 3485a15088 Bug 1717156 - part 6: Get rid of `nsIEditor::eEditorDontEchoPassword` r=m_kato
It's used only by password field, i.e., only by `TextEditor`, and used
temporarily.  Additionally, there is some space in `TextEditor`.  So, we
can get rid of it, and make `TextEditor` store it directly.

Note that this allows to skip expensive `nsIEditor::SetFlags()` calls by
`AutoRestoreEditorState`.  This may improve setting `<input>.value` performance.

Differential Revision: https://phabricator.services.mozilla.com/D118266
2021-06-22 00:18:08 +00:00