Commit Graph

9667 Commits

Author SHA1 Message Date
Masayuki Nakano
9eca50461b Bug 1540043 - part 3: Remove nsIPlaintextEditor interface r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D61350

--HG--
extra : moz-landing-system : lando
2020-02-01 04:38:13 +00:00
Masayuki Nakano
56d2a88c44 Bug 1609860 - Make AutoStyleCacheArray cache only applied styles r=m_kato
Currently, `AutoStyleCacheArray` has style information of all 19 styles.
However, its element type, `StyleCache` has `nsString` instance.  Therefore,
the initializing cost is not reasonable since in most cases most of the
`StyleCache` instances are not used actually.

This patch makes `HTMLEditor::GetInlineStyles()` append elements only for
applied styles and `HTMLEditor::ReapplyCachedStyles()` look for current
value from an instance with new `IndexOf()` method.  Therefore, this patch
may make slower if a lot of styles are applied.  However, we can expect that
it's rare case.

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

--HG--
extra : moz-landing-system : lando
2020-01-31 07:14:42 +00:00
Masayuki Nakano
083d7d9809 Bug 1612085 - part 3: Remove dirty hack of Selection::mCachedRange r=smaug
Previously, I added `Selection::mCachedRange` to save allocation cost of
`nsRange`.  However, with the previous patch, we don't need the hack anymore
since ranges removed by `Selection::RemoveAllRanges()` are always kept in
the global cache of `nsRange`.  Therefore, we can remove the ugly hack right
now.

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

--HG--
extra : moz-landing-system : lando
2020-01-30 12:44:33 +00:00
Masayuki Nakano
450b71f763 Bug 1612085 - part 1: Hide constructor of nsRange r=smaug
`nsRange` instances are allocated a lot in the heap especially by editor and
spellchecker.  The allocation cost is too bad for benchmarks.  Therefore,
we should reuse released instances as far as possible.  For managing it in
static factory methods of `nsRange`, we need to hide `nsRange` constructor.

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

--HG--
extra : moz-landing-system : lando
2020-01-30 13:23:35 +00:00
Masayuki Nakano
f506f1f653 Bug 1611751 - Remove unused scriptable methods of nsIHTMLEditor, nsIEditorStyleSheets and nsITableEditor r=m_kato
* `nsIHTMLEditor.removeAllInlineProperties`
* `nsIHTMLEditor.increaseFontSize`
* `nsIHTMLEditor.decreaseFontSize`
* `nsIHTMLEditor.setParagraphFormat`
* `nsIHTMLEditor.getBackgroundColorState`
* `nsIHTMLEditor.indent`
* `nsIHTMLEditor.align`
* `nsIEditorStyleSheets.replaceOverrideStyleSheet`
* `nsITableEditor.selectBlockOfCells`

These methods are not used by any Gecko products including comm-central and
BlueGriffon so that we should remove them.  Note that only
`HTMLEditor::GetBackgroundColorState()` is used internally so that we need to
keep it as a public method of `HTMLEditor`.

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

--HG--
extra : moz-landing-system : lando
2020-01-30 08:50:41 +00:00
Masayuki Nakano
ec2a667824 Bug 1611895 - Make EditorEventListener::DragOverOrDrop() check whether the result of DragEvent::GetRangeParentContentAndOffset() returned nullptr or not r=smaug
`DragEvent::GetRangeParentContentAndOffset()` may return `nullptr`.  Previously,
it was checked and returned `NS_ERROR_FAILURE` before landing bug 1610264.

This patch adds the null check which was accidentally removed.

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

--HG--
extra : moz-landing-system : lando
2020-01-29 10:36:32 +00:00
Masayuki Nakano
4101b26261 Bug 1610264 - part 2: Make synthesizePlainDragAndDrop() stop dispatching drop event if dragover event listener sets drop effect to none r=smaug
`drop` event shouldn't be fired when drop target does not accept the data
at last `dragover` handling.

This patch makes `synthesizePlainDragAndDrop()` stop dispatching `drop` event
if last `dragover` event's `dataTransfer.dropEffect` is `none`.  In strictly
speaking, it should refer `nsIDragSession::canDrop`.  However, the value is
unstable only on Linux.  The reason must be that only GTK widget manages
`canDrop` state by itself.  Therefore, this patch directly uses the
`dataTransfer.dropEffect` value instead.

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

--HG--
extra : moz-landing-system : lando
2020-01-24 07:43:20 +00:00
Masayuki Nakano
7d3ca06add Bug 1610264 - part 1: Make EditorEventListener consume dragenter, dragover and drop events if the drop target is managed by it r=smaug
Currently, editor does not consume `dragenter`, `dragover` nor `drop` event if
`EditorEventListener::CanDrop()` returns false.  Then,
`EventStateManager::PostHandleEvent()` does not modify current drag session
with given drop effect value.  Therefore, it does not make sense that
`EditorEventListener` modifies modify drop effect of `DragEvent::mDataTransfer`
only with calling `Event::StopPropagation()`.

This patch makes `EditorEventListener` consume `eDragEnter`, `eDragOver` and
`eDrop` events unless drop target is not managed by the editor (i.e., when
drop target is non-editable nodes in HTML editor, or the editor is a part of
`<input type="file">`).

Then, `EditorEventListenr::DragOver()` and `EditorEventListener::Drop()`
become really similar.  Therefore, this patch also merges them.  Their
differences are only:

* Only `Drop()` calls `CleanupDragDropCaret()` first.
* The main purpose code (calling `TextEditor::OnDrop()` from `Drop()` and
  modifying drop effect and caret from `DragOver()`)

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

--HG--
extra : moz-landing-system : lando
2020-01-24 20:10:25 +00:00
Emilio Cobos Álvarez
a25126cd0d Bug 1611181 - Make direction use an enum class. r=boris
Differential Revision: https://phabricator.services.mozilla.com/D60857

--HG--
extra : moz-landing-system : lando
2020-01-24 11:46:14 +00:00
Masayuki Nakano
b1bf7e0db4 Bug 1540043 - part 1: Move all constants and methods of nsIPlaintextEditor to nsIEditor and make nsIPlaintextEditor inherit nsIEditor r=m_kato
For preparing to remove `nsIPlaintextEditor` interface, this patch moves
all of them to `nsIEditor`, but for avoiding bustage in comm-central, makes
`nsIPlaintextEditor` inherit `nsIEditor` for now (i.e., even with this patch,
script can access old `nsIPlaintextEditor` members with the interface.

In C++ code, this patch moves `SetWrapColumn()`, `InsertTextAsAction()`,
`InsertTextAsSubAction()` and `InsertLineBreakAsSubAction()` because
they do common things between `TextEditor` and `HTMLEditor`.  On the other
hand, this does not move `TextEditor::GetTextLength()` because it's designed
only for `TextEditor`.

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

--HG--
rename : editor/libeditor/tests/test_nsIPlaintextEditor_insertLineBreak.html => editor/libeditor/tests/test_nsIEditor_insertLineBreak.html
extra : moz-landing-system : lando
2020-01-24 08:33:42 +00:00
Masayuki Nakano
d48b18fa27 Bug 1610750 - Get rid of unused nsIEditor methods r=m_kato
* getAttributeValue
* cloneAttribute
* splitNode
* joinNodes
* markNodeDirty
* removeEditorObserver

are not used from script.  Therefore, we can get rid of them from `nsIEditor`.

However, `EditorBase::GetAttributeValue()` is referred by
`HTMLEditor::CopyCellBackgroundColor()` and it's just a wrapper of
`Element::GetAttr()`.  Therefore, this patch makes
`HTMLEditor::CopyCellBackgroundColor()` use `Element::GetAttr()` directly.

And also `EditorBase::MarkNodeDirty()` is used from some friend classes.
Therefore, this patch redesigns it as `MarkElementDirty()` and make all of
them check whether the method call destroys the editor.

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

--HG--
extra : moz-landing-system : lando
2020-01-23 12:27:00 +00:00
Mark Banner
e0c4808608 Bug 1609998 - Enable ESLint for non-third party files in editor/libeditor/tests/browserscope/. r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D60305

--HG--
extra : moz-landing-system : lando
2020-01-21 20:46:49 +00:00
Mihai Alexandru Michis
2dab66d06e Backed out 9 changesets (bug 1607172, bug 1609998, bug 1608799) for causing xpcshell failures in test_parser.js
CLOSED TREE

Backed out changeset 7753083b67dd (bug 1609998)
Backed out changeset e6f5aac734ab (bug 1608799)
Backed out changeset 90ea35966b73 (bug 1608799)
Backed out changeset 6fafa451b3f9 (bug 1608799)
Backed out changeset e07a4aea2ae1 (bug 1608799)
Backed out changeset d69d6dfdccad (bug 1607172)
Backed out changeset 93023b1b6153 (bug 1607172)
Backed out changeset 99ce7a56080e (bug 1607172)
Backed out changeset 20aa5934c785 (bug 1607172)
2020-01-21 21:44:03 +02:00
Mark Banner
07db0a7e2b Bug 1609998 - Enable ESLint for non-third party files in editor/libeditor/tests/browserscope/. r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D60305

--HG--
extra : moz-landing-system : lando
2020-01-21 17:00:48 +00:00
Masayuki Nakano
6ea35a12b9 Bug 1606232 - Make nsIHTMLEditor::GetSelectedElement() check whether the found element is followed by <br> element deeper r=m_kato
Current `nsIHTMLEditor::GetSelectedElement()` just checks whether the
found element is followed by `<br>` element or not.  However, following
element may start with `<br>` element and if there is end of the range,
`PostContentIterator` does not list up the `<br>` element.

Therefore, it should check whether the found element is followed by
`<br>` element which is starts the next sibling element too.

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

--HG--
extra : moz-landing-system : lando
2020-01-21 08:16:03 +00:00
Sylvestre Ledru
187e9bafaf Bug 1519636 - Automatically reformat recent changes using clang-format r=Ehsan
# ignore-this-changeset

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

--HG--
extra : moz-landing-system : lando
2020-01-21 09:51:27 +00:00
Emilio Cobos Álvarez
256c124f94 Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:

This was done by applying:

```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
         from subprocess import Popen, PIPE, check_output, CalledProcessError

         diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
-        args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+        args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']

         if not output_file:
             args.append("-i")
```

Then running `./mach clang-format -c <commit-hash>`

Then undoing that patch.

Then running check_spidermonkey_style.py --fixup

Then running `./mach clang-format`

I had to fix four things:

 * I needed to move <utility> back down in GuardObjects.h because I was hitting
   obscure problems with our system include wrappers like this:

0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94              ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94     MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94                                ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)

   Which I really didn't feel like digging into.

 * I had to restore the order of TrustOverrideUtils.h and related files in nss
   because the .inc files depend on TrustOverrideUtils.h being included earlier.

 * I had to add a missing include to RollingNumber.h

 * Also had to partially restore include order in JsepSessionImpl.cpp to avoid
   some -WError issues due to some static inline functions being defined in a
   header but not used in the rest of the compilation unit.

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

--HG--
extra : moz-landing-system : lando
2020-01-20 16:19:48 +00:00
Emilio Cobos Álvarez
aa3a695712 Bug 1609996 - Remove mozilla/Move.h. r=froydnj
rg -l 'mozilla/Move.h' | xargs sed -i 's/#include "mozilla\/Move.h"/#include <utility>/g'

Further manual fixups and cleanups to the include order incoming.

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

--HG--
extra : moz-landing-system : lando
2020-01-20 16:18:20 +00:00
Masayuki Nakano
25e931d406 Bug 1609603 - Optimize the callers of DataTransfer::GetTypes() r=smaug
In C++ code, `DataTransfer::GetTypes()` are used for checking whether the
`DataTransfer` instance has specific type `DataTransferItem` or not.  Therefore,
it does not make sense to retrieve all item types nor compare some types
looking for with the retrieved item types.

This patch adds `DataTransfer::HasType()` and `DataTransfer::HasFile()` for
the current C++ users.  They don't take `CallerType` since all C++ users use
`GetTypes()` as `CallertType::System`.  And they just call a corresponding
method of `DataTransferItemList`.

Then, `DataTransferItemList` methods compares given type with every items
simply.

Note that this patch moves `DataTransfer::GetTypes()` to `DataTransferItemList`
too because new methods and `GetTypes()` should be maintained at every logic
changes.

The reason why there is no `DataTransfer::HasAnyOfTypes()` method is,
`DataTransfer.h` cannot include `DataTransferItemList.h` due to their
dependency but parameter pack requires inline methods.

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

--HG--
extra : moz-landing-system : lando
2020-01-20 09:46:48 +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
Zibi Braniecki
4fb4f2f900 Bug 1609585 - Migrate all possible uses from AppLocalesAsLangTag(s) to AppLocale(s)AsBCP47. r=marionette-reviewers,jfkthame,whimboo
Differential Revision: https://phabricator.services.mozilla.com/D60096

--HG--
extra : moz-landing-system : lando
2020-01-17 19:29:09 +00:00
Masayuki Nakano
487e463bb5 Bug 1543315 - part 21: Mark PresShell::DidCauseReflow() as MOZ_CAN_RUN_SCRIPT r=smaug
It removes a script blocker.  Therefore, although it depends on the caller
whether it causes running script or not.  However, we should mark it as
`MOZ_CAN_RUN_SCRIPT` for safer code.

It's called only by the destructor of `nsAutoCauseReflowNotifier`.  Therefore,
this patch also marks its constructor as `MOZ_CAN_RUN_SCRIPT` for making
each creator method marked as `MOZ_CAN_RUN_SCRIPT` or
`MOZ_CAN_RUN_SCRIPT_BOUNDARY`.

Most of the creators is mutation listener methods.  However, `PresShell`
does nothing after destroying `nsAutoCauseReflowNotifier`.  Therefore,
this patch does not change the callers in MutationObserver.cpp to use
`RefPtr<PresShell>` at calling them because changing it may cause performance
regression.

Perhaps, we should create another methods of `WillCauseReflow()` and
`DidCauseReflow()` to avoid unnecessary `MOZ_CAN_RUN_SCRIPT` marking.
However, I'm not sure whether most callers may run script or not because
of outside of my knowledge.

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

--HG--
extra : moz-landing-system : lando
2020-01-17 10:00:28 +00:00
Masayuki Nakano
527b3ff65b Bug 1609338 - Optimize usage and implementation of UIEvent::GetRangeParent() and UIEvent::RangeOffset() r=smaug
`UIEvent::GetRangeParent()` retrieves `nsIContent` instance but it needs to
return `already_AddRefed<nsINode>` because of a WebIDL method.  However,
`nsIContent` is better type in C++ code.  Therefore, this patch renames it
to `UIEvent::GetRangeParentContent()` and makes new `UIEvent::GetRangeParent()`
and just call it.

Additionally, some callers call `UIEvent::RangeOffset()` too, but that means
that they compute same things twice because both of them use
`nsLayoutUtils::GetContainerAndOffsetAtEvent()` with same input arguments.
Thus, `UIEvent::GetRangeParentContent()` should also return offset with optional
out argument.  (Note that this does not make `RangeOffset()` use
`GetRangeParentContent()` because using out parameter for range parent causes
unnecessary computation cost for `RangeOffset()`.)

Therefore, finally, `UIEvent::GetRangeParentContent()` becomes also an alias of
raw method `UIEvent::GetRangeParentContentAndOffset()` which also returns offset
with out argument.

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

--HG--
extra : moz-landing-system : lando
2020-01-17 01:23:12 +00:00
Emilio Cobos Álvarez
fff6c9e1ac Bug 981248 - Rewrite <input type=number> to avoid an anonymous input. r=masayuki,surkov,jwatt,ntim,jfkthame,smaug
Instead, subclass nsTextControlFrame. This simplifies the code and avoids
correctness issues.

I kept the localization functionality though it is not spec compliant. But I
filed a bug to remove it in a followup.

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

--HG--
extra : moz-landing-system : lando
2020-01-14 19:01:05 +00:00
Mihai Alexandru Michis
0d01c60c37 Backed out 2 changesets (bug 981248) for causing multiple failures.
CLOSED TREE

Backed out changeset 7a96708cc8b7 (bug 981248)
Backed out changeset 1eace7bd28d9 (bug 981248)
2020-01-14 19:28:17 +02:00
Emilio Cobos Álvarez
da2e4ef888 Bug 981248 - Rewrite <input type=number> to avoid an anonymous input. r=masayuki,surkov,jwatt,ntim,jfkthame,smaug
Instead, subclass nsTextControlFrame. This simplifies the code and avoids
correctness issues.

I kept the localization functionality though it is not spec compliant. But I
filed a bug to remove it in a followup.

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

--HG--
extra : moz-landing-system : lando
2020-01-14 15:05:22 +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
Masayuki Nakano
4d302443ce Bug 970802 - part 3: Implement beforeinput event dispatcher and add onbeforeinput event handler attribute r=smaug
This patch makes `nsContentUtils::DispatchInputEvent()` dispatch `beforeinput`
event too.  And also adds `onbeforeinput` event handler which is really
important for feature detection (although Chrome has not implemented this
attribute yet: https://bugs.chromium.org/p/chromium/issues/detail?id=947408).

However, we don't implement `InputEvent.getTargetRanges()` in this bug and
implementing `beforeinput` event may hit bugs of some web apps.  Therefore,
this patch disables `beforeinput` event by default even in Nightly channel.

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

--HG--
extra : moz-landing-system : lando
2020-01-14 07:15:45 +00:00
Masayuki Nakano
66ca57899f Bug 970802 - part 2: HTML editor command classes shouldn't handle edit actions multiple times r=m_kato
Some HTML editor command classes call `*AsAction()` methods multiple times.
That causes that user needs multiple undo/redo for a command and one command
causes multiple "input" events.  For both compatibility with the other
browsers and making "beforeinput" cancelable, they should call `*AsAction()`
once.  Instead, `HTMLEditor` should handle related element deletion.

This patch makes `HTMLEditor::RemoveInlinePropertyInternal()` remove multiple
elements if its caller allows, and `HTMLEditor::SetInlinePropertyAsAction()`
call `RemoveInlinePropertyInternal()` in some cases.

According to comm-central and BlueGriffon, we can make
`HTMLEditor::RemoveInlineProperty()` also removes the related methods
automatically because comm-central does same thing from script and BlueGriffon
does not use this.  However, we cannot do that for
`HTMLEditor::SetInlineProperty()` because BlueGriffon may call it with any
HTML5 elements and does not expect removing elements in same block at that
time.  If we needed to reduce the overhead of comm-central, we could change
only `RemoveInlineProperty()`, but it would make these APIs behavior
inconsistent.

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

--HG--
extra : moz-landing-system : lando
2020-01-14 07:14:55 +00:00
Masayuki Nakano
0bf0eeeaa0 Bug 970802 - part 1: Add beforeinput event tests into existing mochitests r=smaug
This patch adds a lot of `beforeinput` event tests into existing mochitests
which test `input` events.  But this does not add tests of canceling
`beforeinput` event because it requires really complicated path until
implementing `beforeinput` actually.

Note that `beforeinput` event is not fired with `Document.execCommand()`.
Therefore, this patch does not add WPT for testing `beforeinput` event.
And unfortunately, WPT cannot test most cases of the new tests.

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

--HG--
extra : moz-landing-system : lando
2020-01-14 07:14:50 +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
81d47ee6d5 Bug 970802 - part 3: Implement beforeinput event dispatcher and add onbeforeinput event handler attribute r=smaug
This patch makes `nsContentUtils::DispatchInputEvent()` dispatch `beforeinput`
event too.  And also adds `onbeforeinput` event handler which is really
important for feature detection (although Chrome has not implemented this
attribute yet: https://bugs.chromium.org/p/chromium/issues/detail?id=947408).

However, we don't implement `InputEvent.getTargetRanges()` in this bug and
implementing `beforeinput` event may hit bugs of some web apps.  Therefore,
this patch disables `beforeinput` event by default even in Nightly channel.

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

--HG--
extra : moz-landing-system : lando
2020-01-08 09:23:40 +00:00
Masayuki Nakano
ad13198667 Bug 970802 - part 2: HTML editor command classes shouldn't handle edit actions multiple times r=m_kato
Some HTML editor command classes call `*AsAction()` methods multiple times.
That causes that user needs multiple undo/redo for a command and one command
causes multiple "input" events.  For both compatibility with the other
browsers and making "beforeinput" cancelable, they should call `*AsAction()`
once.  Instead, `HTMLEditor` should handle related element deletion.

This patch makes `HTMLEditor::RemoveInlinePropertyInternal()` remove multiple
elements if its caller allows, and `HTMLEditor::SetInlinePropertyAsAction()`
call `RemoveInlinePropertyInternal()` in some cases.

According to comm-central and BlueGriffon, we can make
`HTMLEditor::RemoveInlineProperty()` also removes the related methods
automatically because comm-central does same thing from script and BlueGriffon
does not use this.  However, we cannot do that for
`HTMLEditor::SetInlineProperty()` because BlueGriffon may call it with any
HTML5 elements and does not expect removing elements in same block at that
time.  If we needed to reduce the overhead of comm-central, we could change
only `RemoveInlineProperty()`, but it would make these APIs behavior
inconsistent.

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

--HG--
extra : moz-landing-system : lando
2020-01-08 09:22:52 +00:00
Masayuki Nakano
583465bce4 Bug 970802 - part 1: Add beforeinput event tests into existing mochitests r=smaug
This patch adds a lot of `beforeinput` event tests into existing mochitests
which test `input` events.  But this does not add tests of canceling
`beforeinput` event because it requires really complicated path until
implementing `beforeinput` actually.

Note that `beforeinput` event is not fired with `Document.execCommand()`.
Therefore, this patch does not add WPT for testing `beforeinput` event.
And unfortunately, WPT cannot test most cases of the new tests.

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

--HG--
extra : moz-landing-system : lando
2020-01-08 09:22:50 +00:00
Mirko Brodesser
efd738af5b Bug 1608071: part 2) Rename nsContentUtils::GetCommonAncestor and related methods. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D59319

--HG--
extra : moz-landing-system : lando
2020-01-13 10:29:44 +00:00
Tetsuharu OHZEKI
5a71331210 Bug 1597456 - Fix uses of nsIDocShellTreeItem in mozilla::TextEditor::IsSafeToInsertData. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D59445

--HG--
extra : moz-landing-system : lando
2020-01-10 22:16:53 +00:00
Mirko Brodesser
629b1f630b Bug 1600267: part 15) Call ComparePoints instead of ComparePoints_Deprecated in TextServicesDocument. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D58913

--HG--
extra : moz-landing-system : lando
2020-01-08 10:22:19 +00:00
Mirko Brodesser
5675fea9e5 Bug 1600267: part 14) Call ComparePoints instead of ComparePoints_Deprecated in WSRunScanner. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D58912

--HG--
extra : moz-landing-system : lando
2020-01-08 09:49:11 +00:00
Mirko Brodesser
7410ac5cd6 Bug 1600267: part 13) Call ComparePoints instead of ComparePoints_Deprecated in HTMLEditor. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D58911

--HG--
extra : moz-landing-system : lando
2020-01-08 09:49:11 +00:00
Emilio Cobos Álvarez
86a70df5d7 Bug 1607006 - Remove utf-16 versions of nsCSSProps::LookupProperty* and ServoCSSParser::ComputeColor. r=bzbarsky
Now that we have UTF8String in the WebIDL, we can remove quite a few of the
conversions. Do that, and lift the remaining string conversions up as needed.

Also deindent Servo_ComputeColor while touching it.

Most of the remaining copies are because either bug 1606994, or because they're
WebIDL attributes that we still need to serialize back as UTF-16 (bug 1606995).

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

--HG--
extra : moz-landing-system : lando
2020-01-08 01:21:30 +00:00
Mirko Brodesser
2059daa251 Bug 1600267: part 12) Call ComparePoints instead of ComparePoints_Deprecated in EditorBase. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D57968

--HG--
extra : moz-landing-system : lando
2020-01-06 14:49:39 +00:00
Andreea Pavel
e0ae4d9cc7 No bug - fix typo to have a commit to triggering commit ingestion again. CLOSED TREE 2020-01-06 14:37:39 +02:00
Emilio Cobos Álvarez
bc36653df5 Bug 1449861 - Use UTF8String for some CSSOM APIs. r=bzbarsky
In particular, the ones where we transcode unconditionally atm (property names
and such).

There are others like cssText getters and setters which are a bit harder,
because I either need to rewrite all our serialization code to work with UTF8
(which is fine, but a lot of work), or teach webidl to have a setter that takes
UTF8String as input but returns DOMString as output (which is at best hacky).

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

--HG--
extra : moz-landing-system : lando
2020-01-04 10:36:49 +00:00
Jonathan Kingston
27ca040dfd Bug 1606774 - Change GetAttribute to GetAttr where possible r=baku
Differential Revision: https://phabricator.services.mozilla.com/D58585

--HG--
extra : moz-landing-system : lando
2020-01-03 23:40:53 +00:00
Masayuki Nakano
d695382c5e Bug 1599947 - Make test_password_per_word_operation.html compute click position from editor root element rect and its text node rect r=smaug
test_password_per_word_operation.html uses magic number to consider
click point in `<input>` element.  However, that causes permanent
failure on Ubuntu 18.04.  Ideally, the click positions should be
computed dynamically.  Therefore, this patch makes it use rect of
anonymous `<div>` element and rect of its child text node which can
be computed with `Range.getBoundingClientRect()`.

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

--HG--
extra : moz-landing-system : lando
2019-12-27 15:49:36 +00:00
Masayuki Nakano
ca4a57799a Bug 1599944 - Make SimpleTest.waitForClipboard() and SimpleTest.promiseClipboardChange() relax to compare clipboard data with expected string r=smaug
Most tests which use these APIs don't want to distinguish difference of
linebreaks (i.e., CRLF vs. CR vs. LF).  And also most tests don't want to
check prefix and postfix of HTML data in clipboard on Windows.

Therefore, this patch makes them compare clipboard data with expected string
smarter.  Every linebreak in clipboard data are treated as LF.  Expected
HTML data is wrapped with `<html>`, `<body>` and comment nodes only on
Windows at comparing with clipboard data.

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

--HG--
extra : moz-landing-system : lando
2019-12-27 14:02:35 +00:00
Makoto Kato
7f0a5ff25e Bug 1602526 - Part 2. Add test r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D58091

--HG--
extra : moz-landing-system : lando
2019-12-26 03:34:51 +00:00
Emma Malysz
be8bd71702 Bug 1601110, remove handling and references to vnd.mozilla.xul+xml r=bzbarsky
Differential Revision: https://phabricator.services.mozilla.com/D57567

--HG--
extra : moz-landing-system : lando
2019-12-23 23:02:05 +00:00
Masayuki Nakano
36606b82d3 Bug 1597829 - part 3: Make TextEditor::OnDrop() use another editor which is drag source editor to remove selection r=m_kato
User can move DnD between different 2 editors.  Then, deleting selection in
drag source editor should be handled by the drag source editor rather than
drop target editor.  Therefore, `TextEditor::OnDrop()` should look for
editor instance for drag source node and call is "deleteByDrag" handler.

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

--HG--
extra : moz-landing-system : lando
2019-12-21 12:30:17 +00:00