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

223 Коммитов

Автор SHA1 Сообщение Дата
Mirko Brodesser b880ce0b21 Bug 1634663: part 2) Declare callers of `GetRangeAt` around `EditorBase` `const`. r=masayuki
Depends on D73444

Differential Revision: https://phabricator.services.mozilla.com/D73445
2020-05-02 23:44:46 +00:00
Masayuki Nakano 6d98bd00c0 Bug 1540037 - part 6: Move `TextEditor::DeleteSelectionAndCreateElement()` and `TextEditor::DeleteSelectionAndPrepareToCreateNode()` to `HTMLEditor` r=m_kato
Both of them are used only by `HTMLEditor` so that we can move them to
`HTMLEditor`.

Differential Revision: https://phabricator.services.mozilla.com/D72830
2020-04-30 09:54:55 +00:00
Masayuki Nakano 94a85cde62 Bug 1540037 - part 4: Move `EditorBase::SplitNodeDeepWithTransaction()` to `HTMLEditor` r=m_kato
It's only used by `HTMLEditor` so that we can move it.

Differential Revision: https://phabricator.services.mozilla.com/D72826
2020-04-30 07:29:27 +00:00
Botond Ballo ffdcf19a50 Bug 1633014 - Fix non-unified build errors in editor/. r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D72470
2020-04-27 03:36:57 +00:00
Masayuki Nakano 6cbea10c99 Bug 1632724 - part 1: Move common methods for handling delete selection to `EditorBase` r=m_kato
`DeleteSelection*()` are members of `TextEditor`, but they are also used by
`HTMLEditor`.  Therefore, they and pref cache members for them should be
in `EditorBase` too.

Depends on D71911

Differential Revision: https://phabricator.services.mozilla.com/D72290
2020-04-24 14:55:09 +00:00
Masayuki Nakano 29b0030c60 Bug 1627175 - part 9: Move `HTMLEditor::GetBlock()` and `HTMLEditor::GetBlockNodeParent()` to `HTMLEditUtils` r=m_kato
This patch also names the former to `GetInclusiveAncestorBlockElement()` and
the latter to `GetAncestorBlockElement()` for consistency with modern DOM
API names.

Depends on D70882

Differential Revision: https://phabricator.services.mozilla.com/D70883
2020-04-16 14:19:18 +00:00
Masayuki Nakano 1ee4f00529 Bug 1627175 - part 8: Move `EditorBase::IsContainer()` to `HTMLEditUtils` r=m_kato
It's a virtual method which always returns true if `TextEditor`.  Therefore,
we can move it into `HTMLEditUtils` and we can make the only caller of
`EditorBase` check `IsTextEditor()` instead.

Depends on D70880

Differential Revision: https://phabricator.services.mozilla.com/D70882
2020-04-16 10:32:26 +00:00
Masayuki Nakano 8b3995f814 Bug 1627175 - part 4: Get rid of `EditorBase::IsText()` r=m_kato
A lot of editor code refers `nsINode::IsText()` directly so that we don't
need to keep the too simple editor API anymore.

Depends on D70876

Differential Revision: https://phabricator.services.mozilla.com/D70877

--HG--
extra : moz-landing-system : lando
2020-04-15 16:05:30 +00:00
Masayuki Nakano 7ae8033ee1 Bug 1627175 - part 1: Move `HTMLEditor::IsBlockNode()` into `HTMLEditUtils` r=m_kato
`HTMLEditor::IsBlockNode()` is a virtual method derived from
`EditorBase::IsBlockNode()`.  For the performance, `EditorBase`'s one just
return false for text node and `<br>` element.  However, these check cost
is really cheap in these days.  Therefore, we can make `TextEditor` also
use rich API.

This patch moves `HTMLEditor::NodeIsBlockStatic()` and
`HTMLEditor::NodeIsInlineStatic()` to `HTMLEditUtils`, and removes the wrapper
of the fommer, `HTMLEditor::IsBlockNode()` and `WSRunScanner::IsBlockNode()`.

Differential Revision: https://phabricator.services.mozilla.com/D70874

--HG--
extra : moz-landing-system : lando
2020-04-15 13:55:36 +00:00
Masayuki Nakano 80c22749bc Bug 1625755 - Make `HTMLEditor::DoInsertHTMLWithContext()` check whether inserted content stays at expected point before modifying next insertion point r=m_kato
I'm still not sure how the crash occurs especially on Thunderbird.  However,
it could be possible if `pointToInsert` is modified with an orphan node (i.e.,
when `pointToInsert.GetContainer()` returns `nullptr`).  Therefore, this patch
makes it check whether the inserted node stays at expected position or not,
and if it's not, make it keep inserting next content nodes to previous position
because it must look like odd that inserting to different position.

Differential Revision: https://phabricator.services.mozilla.com/D69154

--HG--
extra : moz-landing-system : lando
2020-04-02 14:03:14 +00:00
Simon Giesecke d3deabac64 Bug 1613363 - Maybe<T> should preserve trivial copy-constructability and destructability of T. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D68173

--HG--
extra : moz-landing-system : lando
2020-03-27 14:22:51 +00:00
Emilio Cobos Álvarez 04828e3a4a Bug 253870 - Make disabled form controls selectable. r=masayuki,MarcoZ
This rejiggers a bit the way selection focus is handled so that focusing a
disabled form control with the mouse handles selection properly, and hides the
document selection and so on.

This matches the behavior of other browsers as far as I can tell.

Given now readonly and disabled editors behave the same, we can simplify a bit
the surrounding editor code.

Differential Revision: https://phabricator.services.mozilla.com/D66464

--HG--
extra : moz-landing-system : lando
2020-03-19 13:18:16 +00:00
Masayuki Nakano 1f9bbb50d0 Bug 1620504 - part 22-5: Clean up warnings in HTMLEditorDataTransfer.cpp r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D66984

--HG--
extra : moz-landing-system : lando
2020-03-19 07:38:19 +00:00
Sean Feng 8af0b53201 Bug 1377999 - Make DocumentFragment to adapt the DOMArena changes r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D57707

--HG--
extra : moz-landing-system : lando
2020-03-17 14:53:46 +00:00
Mihai Alexandru Michis 58bc354025 Backed out changeset 9eeee9ec66d9 (bug 253870) for causing failures in browser_bug1261299.js
CLOSED TREE
2020-03-16 22:32:41 +02:00
Emilio Cobos Álvarez 9f28f89085 Bug 253870 - Make disabled form controls selectable. r=masayuki,MarcoZ
This rejiggers a bit the way selection focus is handled so that focusing a
disabled form control with the mouse handles selection properly, and hides the
document selection and so on.

This matches the behavior of other browsers as far as I can tell.

Given now readonly and disabled editors behave the same, we can simplify a bit
the surrounding editor code.

Differential Revision: https://phabricator.services.mozilla.com/D66464

--HG--
extra : moz-landing-system : lando
2020-03-16 17:41:07 +00:00
Boris Zbarsky c6c4a83796 Bug 1535530. Fix can-run-script analysis to not mishandle on-stack refs to RefPtrs. r=andi,masayuki
The key here is to test the type of the variable declaration for being a
smartptr type, instead of testing the type of the variable _use_.

Differential Revision: https://phabricator.services.mozilla.com/D65581

--HG--
extra : moz-landing-system : lando
2020-03-06 09:57:45 +00:00
Masayuki Nakano 3b631553d3 Bug 1618089 - part 4: Make `WSRunObject` instantiators guarantee `WSRunObject::mHTMLEditor` lifetime r=m_kato
Some script run methods of `WSRunObject` guarantee the lifetime of its
`mHTMLEditor`.  However, they should be guaranteed by the instantiators
(all of them are `HTMLEditor`).

Differential Revision: https://phabricator.services.mozilla.com/D64334

--HG--
extra : moz-landing-system : lando
2020-03-02 07:35:37 +00:00
Masayuki Nakano b93a2782a0 Bug 1618089 - part 1: Redsign `EditorDOMPointBase` with template methods r=m_kato
Some methods of `EditorDOMPointBase` assumes the container node type is
`nsINode`.  However, it's not good for reuse.  Therefore, this patch makes
most methods of them be template methods.

Differential Revision: https://phabricator.services.mozilla.com/D64331

--HG--
extra : moz-landing-system : lando
2020-03-02 07:33:23 +00:00
Masayuki Nakano 4ef76b0f91 Bug 1616257 - part 4: Use content of `WSScanResult` instead of reason content of `WSRunScanner` if they are same r=m_kato
When `WSScanResult::ReachedCurrentBlockBoundary()` returns true, reached content
of backward scan result is same as the scanner's `GetStartReasonContent()` and
reached content of forward scan result is same as the scanner's
`GetEndReasonContent()`.  For making code in the blocks of
`if (foo.ReachedCurrentBlockBoundary())` easier to understand, we should use
the result's content.

Differential Revision: https://phabricator.services.mozilla.com/D63615

--HG--
extra : moz-landing-system : lando
2020-02-25 12:12:30 +00:00
Masayuki Nakano f5407e4219 Bug 1616257 - part 3: Make `WSRunScanner::NextVisibleNode()` and `WSRunScanner::PriorVisibleNode()` return stack only class instance which storing the visible node as `nsIContent` r=m_kato
They are really messy because they take a lot of out parameters, and these
out parameter meaning is really unclear.  Therefore, they should return
a stack only class instance which explain the meaning with getter methods.
And also it should store the result node as `nsIContent`.

And also this patch adds static methods for them for their users which don't
need `WSRunScanner` instance.

Differential Revision: https://phabricator.services.mozilla.com/D63613

--HG--
extra : moz-landing-system : lando
2020-02-25 12:10:04 +00:00
Masayuki Nakano 6382dae45f Bug 1616257 - part 2: Change `mStartReasonNode` and `mEndReasonNode` to `nsIContent` r=m_kato
Now, all setter guarantee that they are subclass instances of `nsIContent`.

Differential Revision: https://phabricator.services.mozilla.com/D63612

--HG--
extra : moz-landing-system : lando
2020-02-25 09:31:18 +00:00
Masayuki Nakano 1110bedb45 Bug 1613830 - Add `nsINode::GetAsElementOrParentElement()` r=smaug
This patch assumes that only element node can have content node.  I.e., we
won't hit the following `MOZ_ASSERT`:

```
Element* element = nullptr;
nsIContent* content = aContent;
while (content) {
  if (content->IsElement()) {
    element = content->AsElement();
    break;
  }
  content = content->GetParent();
}
MOZ_ASSERT(!content || content == element || content->GetParent() == element);
```

Differential Revision: https://phabricator.services.mozilla.com/D63308

--HG--
extra : moz-landing-system : lando
2020-02-21 02:47:05 +00:00
Makoto Kato 1aadd31886 Bug 1359404 - Make IsEmptyNode infaillible. r=masayuki
IsEmptyNode won't return error if parameter is not null. So we shouldn't use
nserror for return value and use assertion to check parameter.

Differential Revision: https://phabricator.services.mozilla.com/D63124

--HG--
extra : moz-landing-system : lando
2020-02-19 05:37:13 +00:00
Masayuki Nakano 58a034fe7d Bug 1588688 - part 8: Make `HTMLEditor::DoInsertHTMLWithContext()` and its helper methods use array of `nsIContent` rather than `nsINode` r=m_kato
Finally, this patch makes `HTMLEditor::DoInsertHTMLWithContext()` stop using
array of `nsINode`.

Differential Revision: https://phabricator.services.mozilla.com/D61984

--HG--
extra : moz-landing-system : lando
2020-02-14 07:16:27 +00:00
Masayuki Nakano 839d86eece Bug 1588688 - part 7-10: Make `ReplaceOrphanedStructure()` call `CollectListAndTableRelatedElementsAt()` by itself r=m_kato
For guaranteeing the meaning of `aArrayOfListAndTableRelatedElements`,
`ReplaceOrphanedStructure()` should call
`CollectListAndTableRelatedElementsAt()` by itself rather than taking as
a parameter.

Then, what it does becomes a little bit clearer.  Therefore, this patch renames
`ReplaceOrphanedStructure()` to `EnsureBeginsOrEndsWithValidContent()` and
`DiscoverPartialListsAndTables()` to `GetMostAncestorListOrTableElement()`,
and adds a lot of comments.

As far as I've tested by my hand, the behavior is not changed even though
it's really buggy in some cases.  We should fix them after writing automated
tests in another bug.

Differential Revision: https://phabricator.services.mozilla.com/D61983

--HG--
extra : moz-landing-system : lando
2020-02-14 05:40:37 +00:00
Masayuki Nakano d389b66f9c Bug 1588688 - part 7-9: Make `ReplaceOrphanedStructure()` call `DiscoverPartialListsAndTables()` by itself r=m_kato
For guaranteeing the meaning of list or `<table>` element in
`ReplaceOrphanedStructure()`, it should call `DiscoverPartialListsAndTables()`.
Then, their meaning becomes clearer than coming from its parameter.

Differential Revision: https://phabricator.services.mozilla.com/D61982

--HG--
extra : moz-landing-system : lando
2020-02-14 03:27:16 +00:00
Masayuki Nakano 7656ed2a64 Bug 1588688 - part 7-8: Encapsulate the first and last node fixer into a stack only class r=m_kato
In these patches, we know that there are a lot of helper methods to fix node
list which is created by `SubtreeContentIterator` and will be inserted into
the editor's DOM tree, and they are not used by other places.  So, we can
encapsulate them into a stack only class for making their usage clearer.

Differential Revision: https://phabricator.services.mozilla.com/D61981

--HG--
extra : moz-landing-system : lando
2020-02-14 02:59:32 +00:00
Masayuki Nakano 55963fc5b9 Bug 1588688 - part 7-7: Clean up `HTMLEditor::ReplaceOrphanedStructure()` r=m_kato
Unfortunately, even with this cleaning up, I don't understand what it does
because existing comment and what actually it does seem different.

Differential Revision: https://phabricator.services.mozilla.com/D61980

--HG--
extra : moz-landing-system : lando
2020-02-13 09:06:44 +00:00
Masayuki Nakano 784573927c Bug 1588688 - part 7-6: Clean up `HTMLEditor::DiscoverPartialListsAndTables()` r=m_kato
`HTMLEditor::DiscoverPartialListsAndTables()` can be static and we can make
its definition simpler.  However, due to the odd logic, I'm still not sure
what it does.  I'll update it after cleaning up its result user,
`HTMLEditor::ReplaceOrphanedStructure()`.

Differential Revision: https://phabricator.services.mozilla.com/D61979

--HG--
extra : moz-landing-system : lando
2020-02-13 08:42:22 +00:00
Masayuki Nakano 817ac3e98e Bug 1588688 - part 7-5: Clean up `HTMLEditor::CreateListOfNodesToPaste()` r=m_kato
`HTMLEditor::CreateListOfNodesToPaste()` can be static and it does not need to
take `DocumentFragment` as an argument if the range is always specified.
For avoiding 2 input path to specify a range, we should make it take only
range boundaries and array of nodes to return the collected nodes.

Differential Revision: https://phabricator.services.mozilla.com/D61978

--HG--
extra : moz-landing-system : lando
2020-02-13 04:49:43 +00:00
Masayuki Nakano 3887f29cbc Bug 1588688 - part 7-4: Clean up `HTMLEditor::GetListAndTableParents()` r=m_kato
It can be a static method and does not make sense taking array of nodes as
input argument because it refers only first or last node of the array.

Differential Revision: https://phabricator.services.mozilla.com/D61977

--HG--
extra : moz-landing-system : lando
2020-02-13 02:56:25 +00:00
Masayuki Nakano 58164b1ddf Bug 1588688 - part 7-3: Clean up `HTMLEditor::ScanForTableStructure()` r=m_kato
The name does not explain what it does.  Additionally, it should be same style
as `HTMLEditor::IsReplaceableListElement()` for making it easier to understand.

Differential Revision: https://phabricator.services.mozilla.com/D61976

--HG--
extra : moz-landing-system : lando
2020-02-13 02:55:53 +00:00
Masayuki Nakano 12ce2b955c Bug 1588688 - part 7-2: Pick list element handling part of `HTMLEditor::ScanForListAndTableStructure()` up r=m_kato
`HTMLEditor::ScanForListAndTableStructure()` is complicated because it has
2 modes, one is for handling list element, the other is for handling table
element.  This patch splits them as 2 methods.

Differential Revision: https://phabricator.services.mozilla.com/D61975

--HG--
extra : moz-landing-system : lando
2020-02-13 02:55:20 +00:00
Masayuki Nakano 382f61920c Bug 1588688 - part 7-1: Sort out `HTMLEditor::ScanForListAndTableStructure()` r=m_kato
Helper methods of `HTMLEditor::DoInsertHTMLWithContext()` which uses array of
`nsINode` is really messy and we can make them simpler.  This is first
preparation of a series of refactoring patches of them.

Differential Revision: https://phabricator.services.mozilla.com/D61974

--HG--
extra : moz-landing-system : lando
2020-02-13 02:54:47 +00:00
Simon Giesecke b50347f917 Bug 1611415 - Prefer using std::move over forget. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D60980

--HG--
extra : moz-landing-system : lando
2020-02-13 14:38:48 +00:00
shindli 91aa0518dd Backed out changeset 0c982bc69cb3 (bug 1611415) for causing build bustages in /builds/worker/workspace/build/src/obj-firefox/dist/include/nsCOMPtr CLOSED TREE 2020-02-12 20:13:29 +02:00
Simon Giesecke f604a47fa5 Bug 1611415 - Applied FixItHints from mozilla-non-std-move. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D60980

--HG--
extra : moz-landing-system : lando
2020-02-12 17:24:41 +00:00
Masayuki Nakano fc9618eabb Bug 1588688 - part 1: Remove `TrivialFunctor` and `BRNodeFunctor` for `DOMIterator` r=m_kato
`TrivialFunctor` returns always true for `DOMIterator::AppendList()`.  That
means that `DOMIterator` appends all nodes which are listed up by
`ContentIterator`.  So, it's reasonable to make `DOMIterator` have
`AppendAllNodesToArray()` because it's more self-documented and faster.

Additionally, `BRNodeFunctor` always returns true when nodes with which
`HTMLBRElement::FromNode()` returns non-nullptr.  So, we can make
`AppendAllNodesToArray()` a template class which just checks whether
every nodes are specific node type.

Differential Revision: https://phabricator.services.mozilla.com/D61968

--HG--
extra : moz-landing-system : lando
2020-02-11 06:52:32 +00:00
Masayuki Nakano 7c8295ee19 Bug 1609629 - Make `HTMLEditor::BlobReader` handle `DataTransfer` correctly r=smaug
When file is dropped on `contenteditable` element, the data is `BlobImpl`
instance in e10s mode.  Then, editor tries to insert asynchronously with its
`BlobReader`.  However, currently, `BlobReader` does not have a reference of
`DataTransfer` object for setting `beforeinput` event and `input` event.
Therefore, when you drop file into `contenteditable` element on debug build,
you see hitting `MOZ_ASSERT` because of unexpected null `DataTransfer` object.

This patch makes it store `DataTransfer` object for both `beforeinput` event
and `input` event, and dispatch `beforeinput` event only when it hasn't been
dispatched yet (i.e., not dispatched before it's created).  The case shouldn't
occur, but let's have the fallback path in release builds for avoiding
inconvenience of our users.

Differential Revision: https://phabricator.services.mozilla.com/D60238

--HG--
extra : moz-landing-system : lando
2020-01-20 01:41:55 +00:00
Masayuki Nakano 90cd2122dd Bug 970802 - part 5: Make `AutoEditActionDataSetter` created method dispatch "beforeinput" event r=smaug,m_kato
`AutoEditActionDataSetter` is created in the stack when editor's public method
is called and that guarantees lifetime of global objects in editor such as
editor itself, selection controller, etc.

The dispatcher of `beforeinput` event returns `NS_ERROR_EDITOR_ACTION_CANCELED`
if an event is actually dispatched but canceled.  The reason why it's an error
is, editor code must stop handling anything when any methods return error.
So, returning an error code is reasonable in editor module.  But when it's
filtered by `EditorBase::ToGenericNSResult()` at return statement of public
methods, it's converted to `NS_SUCCESS_DOM_NO_OPERATION`.  This avoids throwing
new exception, but editor class users in C++ can distinguish whether each edit
action is canceled or handled.  The reason why we should not throw new
exception from XPCOM API is, without taking care of each caller may break some
our UI (especially for avoiding to break comm-central).  Therefore, this patch
does not make XPCOM methods return error code when `beforeinput` event is
canceled.

In most cases, immediately after creating `AutoEditActionDataSetter` is good
timing to dispatch `beforeinput` event since editor has not touched the DOM
yet.  If `beforeinput` requires `data` or `dataTransfer`, methods need to
dispatch `beforeinput` event after that.  Alhtough this is not a good thing
from point of view of consistency of the code.  However, I have no better
idea.

Note 1: Our implementation does NOT conform to the spec about event order
between `keypress` and `beforeinput` (dispatching `beforeinput` event after
`keypress` event).  However, we follow all other browsers' behavior so that it
must be safe and the spec should be updated for backward compatibility.
Spec issue: https://github.com/w3c/uievents/issues/220

Note 2: Our implementation does NOT conform to the spec about event order
between `compositionupdate` and `beforeinput`.  Our behavior is same as
Safari, but different from Chrome.  This might cause web-compat issues.
However, our behavior does make sense from point of view of consistency of
event spec.  Additionally, at both `compositionupdate` and `beforeinput`,
composition string in editor has not been modified yet.  Therefore, this
may not cause web-compat issues (and I hope so).
Spec issue: https://github.com/w3c/input-events/issues/49

Note that this patch makes editor detect bugs that `beforeinput` event hasn't
been handled yet when it dispatches `input` event or modifying `data` and
`dataTransfer` value are modified after dispatching `beforeinput` event with
`MOZ_ASSERT`s.

Differential Revision: https://phabricator.services.mozilla.com/D58127

--HG--
extra : moz-landing-system : lando
2020-01-14 07:18:51 +00:00
Razvan Maries 0df75c8122 Backed out 5 changesets (bug 970802) for xpcshell perma fails. CLOSED TREE
Backed out changeset 5511edd700f7 (bug 970802)
Backed out changeset 1fb9cf2264b6 (bug 970802)
Backed out changeset 6b185296c742 (bug 970802)
Backed out changeset ce6853e64ed6 (bug 970802)
Backed out changeset aa9bd45c09b1 (bug 970802)
2020-01-14 04:41:15 +02:00
Masayuki Nakano 00f4c31bb7 Bug 970802 - part 5: Make `AutoEditActionDataSetter` created method dispatch "beforeinput" event r=smaug,m_kato
`AutoEditActionDataSetter` is created in the stack when editor's public method
is called and that guarantees lifetime of global objects in editor such as
editor itself, selection controller, etc.

The dispatcher of `beforeinput` event returns `NS_ERROR_EDITOR_ACTION_CANCELED`
if an event is actually dispatched but canceled.  The reason why it's an error
is, editor code must stop handling anything when any methods return error.
So, returning an error code is reasonable in editor module.  But when it's
filtered by `EditorBase::ToGenericNSResult()` at return statement of public
methods, it's converted to `NS_SUCCESS_DOM_NO_OPERATION`.  This avoids throwing
new exception, but editor class users in C++ can distinguish whether each edit
action is canceled or handled.  The reason why we should not throw new
exception from XPCOM API is, without taking care of each caller may break some
our UI (especially for avoiding to break comm-central).  Therefore, this patch
does not make XPCOM methods return error code when `beforeinput` event is
canceled.

In most cases, immediately after creating `AutoEditActionDataSetter` is good
timing to dispatch `beforeinput` event since editor has not touched the DOM
yet.  If `beforeinput` requires `data` or `dataTransfer`, methods need to
dispatch `beforeinput` event after that.  Alhtough this is not a good thing
from point of view of consistency of the code.  However, I have no better
idea.

Note 1: Our implementation does NOT conform to the spec about event order
between `keypress` and `beforeinput` (dispatching `beforeinput` event after
`keypress` event).  However, we follow all other browsers' behavior so that it
must be safe and the spec should be updated for backward compatibility.
Spec issue: https://github.com/w3c/uievents/issues/220

Note 2: Our implementation does NOT conform to the spec about event order
between `compositionupdate` and `beforeinput`.  Our behavior is same as
Safari, but different from Chrome.  This might cause web-compat issues.
However, our behavior does make sense from point of view of consistency of
event spec.  Additionally, at both `compositionupdate` and `beforeinput`,
composition string in editor has not been modified yet.  Therefore, this
may not cause web-compat issues (and I hope so).
Spec issue: https://github.com/w3c/input-events/issues/49

Note that this patch makes editor detect bugs that `beforeinput` event hasn't
been handled yet when it dispatches `input` event or modifying `data` and
`dataTransfer` value are modified after dispatching `beforeinput` event with
`MOZ_ASSERT`s.

Differential Revision: https://phabricator.services.mozilla.com/D58127

--HG--
extra : moz-landing-system : lando
2020-01-14 01:09:45 +00:00
Masayuki Nakano 70ff2e9875 Bug 1597829 - part 2: Make `TextEditor::OnDrop()` move focus before inserting dropped content r=m_kato
Chrome moves focus to dropped element or editing host containing dropped
element, but we don't do it.  For compatibility with Chrome, it's better to
follow their behavior.  Additionally, this fixes 2 issues.  One is, when
dropping something into non-focused contenteditable element, we've failed to
initialize selection from `TextEditor::PrepareToInsertContent()` because
`pointToInsert` is outside of selection limiter if another editing host
has focus.  The other is, when same case, we've failed to insert dropped
content because edit action handlers of `HTMLEditor` check whether editing
position is in active editing host.

Finally, this patch makes `TextEditor::OnDrop()` cancels to dispatch "input"
event if it fails something before trying to insert dropped content.  Without
this change, `EditorBase::DispatchInputEvent()` tries to dispatch without
proper `data` or `dataTransfer` and that hits `MOZ_ASSERT` in `nsContentUtils`.

Additionally, this fixes an existing bug which `HTMLEditor` may insert `\r`
as-is if it comes from paste or drop.  Otherwise, we need complicated `todo_is`
paths in `test_dragdrop.html`.

Differential Revision: https://phabricator.services.mozilla.com/D57447

--HG--
extra : moz-landing-system : lando
2019-12-21 12:28:56 +00:00
Gabriele Svelto 69790bc62e Bug 1600545 - Remove useless inclusions of header files generated from IDL files in accessible/, browser/, caps/, chrome/, devtools/, docshell/, editor/, extensions/, gfx/, hal/, image/, intl/, ipc/, js/, layout/, and media/ r=Ehsan
The inclusions were removed with the following very crude script and the
resulting breakage was fixed up by hand. The manual fixups did either
revert the changes done by the script, replace a generic header with a more
specific one or replace a header with a forward declaration.

find . -name "*.idl" | grep -v web-platform | grep -v third_party | while read path; do
    interfaces=$(grep "^\(class\|interface\).*:.*" "$path" | cut -d' ' -f2)
    if [ -n "$interfaces" ]; then
        if [[ "$interfaces" == *$'\n'* ]]; then
          regexp="\("
          for i in $interfaces; do regexp="$regexp$i\|"; done
          regexp="${regexp%%\\\|}\)"
        else
          regexp="$interfaces"
        fi
        interface=$(basename "$path")
        rg -l "#include.*${interface%%.idl}.h" . | while read path2; do
            hits=$(grep -v "#include.*${interface%%.idl}.h" "$path2" | grep -c "$regexp" )
            if [ $hits -eq 0 ]; then
                echo "Removing ${interface} from ${path2}"
                grep -v "#include.*${interface%%.idl}.h" "$path2" > "$path2".tmp
                mv -f "$path2".tmp "$path2"
            fi
        done
    fi
done

Differential Revision: https://phabricator.services.mozilla.com/D55443

--HG--
extra : moz-landing-system : lando
2019-12-06 09:16:44 +00:00
Masayuki Nakano a1a0330433 Bug 1593920 - Clean up `HTMLEditor::TabInTable()` with taking `WidgetKeyboardEvent*` and returning `EditActionResult` r=m_kato
With making it take `WidgetKeyboardEvent*`, it won't need to return "handled"
state.  However, when we implement `beforeinput` event, it needs to return
"canceled" state.  Therefore, it should return `EditActionResult`.

Differential Revision: https://phabricator.services.mozilla.com/D51953

--HG--
extra : moz-landing-system : lando
2019-11-07 02:59:51 +00:00
Masayuki Nakano abdf9727f5 Bug 1582215 - Make `HTMLEditor::DoInsertHTMLWithContext()` compute new insertion point before removing unnecessary `<li>` elements r=m_kato
When inserting `<li>` elements into `<ul>`, `<ol>` or `<li>` element,
`HTMLEditor::DoInsertHTMLWithContext()` removes unnecessary empty `<li>`
elements at insertion point.  At this time, we've computed next insertion
point with removed `<li>` element.  Therefore, insertion point goes out
from the DOM tree.  This patch makes it compute new insertion point before
removing each empty `<li>` element.

Additionally, this patch adds some WPT data for testing this case.  I verified
that Chrome passes the new tests too.

Differential Revision: https://phabricator.services.mozilla.com/D49394

--HG--
extra : moz-landing-system : lando
2019-10-17 09:17:14 +00:00
Masayuki Nakano 470b292007 Bug 1566795 - part 1: Clean up `HTMLEditor::ClearStyle()`, `HTMLEditor::SplitStyleAbovePoint()` and their callers r=m_kato
Both method take a DOM point with `nsCOMPtr<nsINode>*` and `int32_t*`.
This makes each caller complicated.  Instead, we should use stack only class
to return both `EditorDOMPoint` and `nsresult`.  I name it `EditResult`.

Additionally, this fixes a bug of `HTMLeditor::SplitStyleAboveRange()`.  That
is not tracking new selection start point while it splits elements at end
of given range.  This is detected by the debug assertion in
`ToRawRangeBoundary()` (i.e., this fix is required to pass some tests).

Differential Revision: https://phabricator.services.mozilla.com/D47858

--HG--
extra : moz-landing-system : lando
2019-10-07 00:55:02 +00:00
Masayuki Nakano 58f9c64190 Bug 1581034 - part 2: Get rid of `TextEditUtils::IsBreak()` and `TextEditUtils` itself r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D45811

--HG--
extra : moz-landing-system : lando
2019-09-18 12:37:14 +00:00
Masayuki Nakano 4f5eae49b0 Bug 1581034 - part 1: Get rid of `TextEditUtils::IsBody()` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D45810

--HG--
extra : moz-landing-system : lando
2019-09-18 10:29:01 +00:00