Commit Graph

9980 Commits

Author SHA1 Message Date
Narcis Beleuzu
66477aeb36 Backed out changeset 20f1bb2d5bd2 (bug 1623562) for bc failures. CLOSED TREE 2020-03-20 05:42:41 +02:00
Masayuki Nakano
74a2dd84e9 Bug 1620504 - part 22-8: Clean up warnings in HTMLStyleEditor.cpp r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D67130

--HG--
extra : moz-landing-system : lando
2020-03-19 12:48:42 +00:00
Dan Glastonbury
d15761b621 Bug 1623562 - Refactor allowPlugins to use BrowsingContext. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D67428

--HG--
extra : moz-landing-system : lando
2020-03-20 02:16:12 +00:00
Masayuki Nakano
5c3bb8caf1 Bug 1620504 - part 22-7: Clean up warnings in HTMLInlineTableEditor.cpp r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D66986

--HG--
extra : moz-landing-system : lando
2020-03-19 12:29: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
5de3c1b41d Bug 1620504 - part 22-6: Clean up warnings in HTMLEditorObjectResizer.cpp r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D66985

--HG--
extra : moz-landing-system : lando
2020-03-19 11:38:42 +00:00
Mirko Brodesser
c602e0e0d7 Bug 1623333: part 4) Assert Selection's type is eNormal in relevant methods accessing mFrameSelection. r=smaug
Helps to determine which methods of `nsFrameSelection` are intended to
be called only for the `eNormal` Selection.

Driven by the idea that state of `nsFrameSelection` relevant only for
the `eNormal` Selection should later move to a `NormalSelection` class.

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

--HG--
extra : moz-landing-system : lando
2020-03-19 11:08:58 +00:00
Mirko Brodesser
1c4dcdbce9 Bug 1623333: part 3) Assert EditorBase::SelectionRefPtr has type eNormal. r=masayuki
Simplifies reasoning about it.

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

--HG--
extra : moz-landing-system : lando
2020-03-19 10:40:10 +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
Masayuki Nakano
d7d4de3f48 Bug 1620504 - part 22-4: Clean up warnings in HTMLEditSubActionHandler.cpp r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D66983

--HG--
extra : moz-landing-system : lando
2020-03-19 04:23:31 +00:00
Kagami Sascha Rosylight
90a7b434c7 Bug 1542521 - Join blocks with empty elements in between r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D67076

--HG--
extra : moz-landing-system : lando
2020-03-18 15:42:05 +00:00
Masayuki Nakano
6de9c5bcef Bug 1620504 - part 22-3: Clean up warnings in HTMLAnonymousNodeEditor.cpp r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D66981

--HG--
extra : moz-landing-system : lando
2020-03-18 12:43:40 +00:00
Masayuki Nakano
ba0909ed8b Bug 1620504 - part 22-2: Clean up warnings in HTMLAbsPositionEditor.cpp r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D66980

--HG--
extra : moz-landing-system : lando
2020-03-18 06:06:22 +00:00
Emilio Cobos Álvarez
664a546418 Bug 1618260 - Fix number input so that it honors overflow-clip-box-block. r=mats
This never worked, but it's more visible with the new form controls which have
more padding.

Make the anonymous div and co a pseudo-element, so that they inherit from the
<input> properly in all cases. This works for non-number inputs because the
editor root is a direct child of the <input>, but it doesn't for number inputs
because there's a flex wrapper in between.

This way overflow-clip-box: inherit does what we want. Reset the padding in the
inline direction, as the padding for <input type=number> applies to the arrow
boxes as well, and thus we'd double-apply it.

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

--HG--
extra : moz-landing-system : lando
2020-03-18 09:21:44 +00:00
Masayuki Nakano
87dc9fcfe5 Bug 1620504 - part 22-1: Clean up warnings in HTMLEditor.cpp and HTMLEditor.h r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D66979

--HG--
extra : moz-landing-system : lando
2020-03-18 02:02:17 +00:00
Masayuki Nakano
9c977f38b7 Bug 1620504 - part 21: Clean up warnings in TextEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D66852

--HG--
extra : moz-landing-system : lando
2020-03-18 01:14:42 +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
Makoto Kato
3399b1e3a5 Bug 1621827 - Skip spellchecker reftests on Android. r=masayuki
Actually GeckoView turns off spellchekcer, so it is unnecessary to run reftests
for spellchecker on GeckoView.

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

--HG--
extra : moz-landing-system : lando
2020-03-12 09:37:25 +00:00
Masayuki Nakano
0913d9141d Bug 1620504 - part 20: Clean up warnings in SelectionState and related classes r=m_kato
This changes a lot of arguments from pointer to reference.

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

--HG--
extra : moz-landing-system : lando
2020-03-16 09:57:58 +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
Emilio Cobos Álvarez
a490bfb50c Bug 1620778 - Fix interaction of up/down keys with autocomplete and <input type=number>. r=masayuki,smaug
Differential Revision: https://phabricator.services.mozilla.com/D66011

--HG--
extra : moz-landing-system : lando
2020-03-16 15:50:31 +00:00
Ciure Andrei
032b6f7c89 Backed out 2 changesets (bug 1620778) for causing test_autocomplete_mac_caret.xhtml failures
Backed out changeset 66f97d1cf94a (bug 1620778)
Backed out changeset eda75d901f4c (bug 1620778)
2020-03-15 16:04:36 +02:00
Emilio Cobos Álvarez
749ef068e9 Bug 1620778 - Fix interaction of up/down keys with autocomplete and <input type=number>. r=masayuki,smaug
Differential Revision: https://phabricator.services.mozilla.com/D66011

--HG--
extra : moz-landing-system : lando
2020-03-15 12:11:09 +00:00
Masayuki Nakano
53e6bfdbf2 Bug 1620504 - part 19: Clean up warnings in WSRunScanner and WSRunObject r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D66227

--HG--
extra : moz-landing-system : lando
2020-03-14 00:03:31 +00:00
Mirko Brodesser
ec9cb4d8ef Bug 1622199: annotate Selection::AddRangeAndSelectFramesAndNotifyListeners with MOZ_CAN_RUN_SCRIPT. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D66759

--HG--
extra : moz-landing-system : lando
2020-03-13 15:46:13 +00:00
Masayuki Nakano
03baeb9f3d Bug 1620504 - part 18: Clean up warnings in SplitNodeTransaction r=m_kato
Depends on D66179

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

--HG--
extra : moz-landing-system : lando
2020-03-11 06:13:26 +00:00
Masayuki Nakano
476081f03e Bug 1620504 - part 17: Clean up warnings in PlaceholderTransaction r=m_kato
Additionally, this makes some `nsIAbsorbingTransaction` methods infallible for
reducing unnecessary warnings.

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

--HG--
extra : moz-landing-system : lando
2020-03-11 02:11:52 +00:00
Masayuki Nakano
5343ffcff8 Bug 1620504 - part 16: Clean up warnings in JoinNodeTransaction r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D66178

--HG--
extra : moz-landing-system : lando
2020-03-10 14:20:22 +00:00
Masayuki Nakano
b4e1588a17 Bug 1620504 - part 15: Clean up warnings in InsertTextTransaction r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D66177

--HG--
extra : moz-landing-system : lando
2020-03-10 14:23:48 +00:00
Masayuki Nakano
605bafef7b Bug 1620504 - part 14: Clean up warnings in InsertNodeTransaction r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D66176

--HG--
extra : moz-landing-system : lando
2020-03-10 14:17:53 +00:00
Masayuki Nakano
8371d74f49 Bug 1620504 - part 13: Clean up warnings in editor/txmgr r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D66175

--HG--
extra : moz-landing-system : lando
2020-03-10 13:59:36 +00:00
Masayuki Nakano
9c836ea324 Bug 1620504 - part 12: Clean up warnings in EditorEventListener r=m_kato
Depends on D65877

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

--HG--
extra : moz-landing-system : lando
2020-03-10 07:54:29 +00:00
Ehsan Akhgari
a96ff3afcf Bug 848644 - Add a crashtest based on the test case for the bug
Differential Revision: https://phabricator.services.mozilla.com/D66256

--HG--
extra : moz-landing-system : lando
2020-03-10 16:43:26 +00:00
Ehsan Akhgari
e23c47bb28 Bug 745494 - Add a crashtest based on the test case for the bug
Differential Revision: https://phabricator.services.mozilla.com/D66254

--HG--
extra : moz-landing-system : lando
2020-03-10 16:28:57 +00:00
Masayuki Nakano
96f81476ca Bug 1620504 - part 11: Clean up warnings in editor command classes r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D65877

--HG--
extra : moz-landing-system : lando
2020-03-10 04:34:15 +00:00
Masayuki Nakano
0e68df00a5 Bug 1620504 - part 10: Clean up warnings in EditorBase r=m_kato
Depends on D65875

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

--HG--
extra : moz-landing-system : lando
2020-03-09 14:57:24 +00:00
Masayuki Nakano
be4d995f31 Bug 1620504 - part 9: Clean up warnings in EditAggregateTransaction r=m_kato
This also changes `mChildren` to array of `OwningNonNull` for removing
unnecessary `nullptr` checks.

Depends on D65874

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

--HG--
extra : moz-landing-system : lando
2020-03-09 14:57:24 +00:00
Bogdan Tara
db31d5b274 Backed out changeset 00ab51ea2723 (bug 1620778) for test_autocomplete_mac_caret.xhtml failures CLOSED TREE 2020-03-10 12:24:48 +02:00
Emilio Cobos Álvarez
49598c22ee Bug 1620778 - Fix interaction of up/down keys with autocomplete and <input type=number>. r=masayuki,smaug
Differential Revision: https://phabricator.services.mozilla.com/D66011

--HG--
extra : moz-landing-system : lando
2020-03-10 02:44:44 +00:00
Masayuki Nakano
9af3340409 Bug 1620504 - part 8: Clean up warnings in DeleteTextTransaction r=m_kato
Depends on D65873

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

--HG--
extra : moz-landing-system : lando
2020-03-09 14:57:24 +00:00
Masayuki Nakano
994ae78613 Bug 1620504 - part 7: Clean up warnings in DeleteRangeTransaction r=m_kato
Depends on D65872

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

--HG--
extra : moz-landing-system : lando
2020-03-09 14:57:23 +00:00
Masayuki Nakano
32ad653b14 Bug 1620504 - part 6: Clean up warnings in DeleteNodeTransaction r=m_kato
Depends on D65871

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

--HG--
extra : moz-landing-system : lando
2020-03-09 14:57:23 +00:00
Masayuki Nakano
09bb52cb18 Bug 1620504 - part 5: Clean up warnings in ChangeAttributeTransaction r=m_kato
Depends on D65870

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

--HG--
extra : moz-landing-system : lando
2020-03-09 14:57:23 +00:00
Masayuki Nakano
20296adfc3 Bug 1620504 - part 4: Clean up warnings in CreateElementTransaction r=m_kato
Depends on D65869

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

--HG--
extra : moz-landing-system : lando
2020-03-09 04:53:55 +00:00
Masayuki Nakano
c1fc16a11b Bug 1620504 - part 3: Clean up warnings in CompositionTransaction r=m_kato
Depends on D65867

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

--HG--
extra : moz-landing-system : lando
2020-03-09 07:14:19 +00:00
Masayuki Nakano
c6ab66e5b6 Bug 1620504 - part 2: Clean up warnings in ChangeStyleTransaction r=m_kato
Depends on D65866

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

--HG--
extra : moz-landing-system : lando
2020-03-09 03:15:02 +00:00
Masayuki Nakano
9748db36aa Bug 1620504 - part 1: Clean up warnings in CSSEditUtils r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D65866

--HG--
extra : moz-landing-system : lando
2020-03-09 01:58:24 +00:00
Masayuki Nakano
7bd48e79b8 Bug 1618906 - Make HTMLEditor stop handling anything if container of a range in Selection is not a content node r=m_kato
It's valid thing that a container of a `Range` of `Selection` is not a content
node.  Actually, it can be a `Document` node.  But it's illegal case for
editor.  So, if `HTMLEditor` meets such case, it does not need to do anything.

This patch makes that if `HTMLEditor` meets the situation at very first time
of public edit action method, it returns "OK" for avoiding new exception case.
Otherwise, i.e., it's an XPCOM API or meeting such situation after a DOM
mutation, returns error.

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

--HG--
extra : moz-landing-system : lando
2020-03-05 04:39:35 +00:00
Mark Banner
15cfe23b88 Bug 1620542 - Automatically fix ESLint errors in .eslintrc.js files. r=mossop
# ignore-this-changeset

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

--HG--
extra : moz-landing-system : lando
2020-03-07 10:09:44 +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
85a0bd9a61 Bug 1620135 - Clean up trivial constructor and destructor under libeditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D65448

--HG--
extra : moz-landing-system : lando
2020-03-06 04:38:25 +00:00
Mirko Brodesser
4be580237d Bug 1619617: part 1) Annotate RemoveRangeAndUnselectFramesAndNotifyListeners with MOZ_CAN_RUN_SCRIPT. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D65511

--HG--
extra : moz-landing-system : lando
2020-03-06 12:03:23 +00:00
Coroiu Cristina
e3e3fb9577 Backed out changeset 97a8f04641de (bug 1618906) on request by masayuki 2020-03-05 06:36:44 +02:00
Masayuki Nakano
ed016cbd72 Bug 1618906 - Make HTMLEditor stop handling anything if container of a range in Selection is not a content node r=m_kato
It's valid thing that a container of a `Range` of `Selection` is not a content
node.  Actually, it can be a `Document` node.  But it's illegal case for
editor.  So, if `HTMLEditor` meets such case, it does not need to do anything.

This patch makes that if `HTMLEditor` meets the situation at very first time
of public edit action method, it returns "OK" for avoiding new exception case.
Otherwise, i.e., it's an XPCOM API or meeting such situation after a DOM
mutation, returns error.

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

--HG--
extra : moz-landing-system : lando
2020-03-04 09:14:44 +00:00
Simon Giesecke
dd65843b46 Bug 1613985 - Use default for equivalent-to-default constructors/destructors in editor. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D65287

--HG--
extra : moz-landing-system : lando
2020-03-04 09:10:03 +00:00
Masayuki Nakano
9a2dc9a516 Bug 1619647 - Make WSRunObject::ReplacePreviousNBSPIfUnnecessary() check IsEndOfContainer() before calling IsCharNBSP() r=m_kato
I forgot to add this check only here. (I also checked again for all similar
methods' callers.)  So, if the point is end of a text node (i.e., offset equals
its length), `IsCharNBSP()` refers wrong address.

I cannot find a way to reproduce this crash, therefore, this patch does not
have new crashtest.

(Additionally, this corrects the misspell in the method name.)

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

--HG--
extra : moz-landing-system : lando
2020-03-04 08:15:15 +00:00
Masayuki Nakano
8bdbe3afd6 Bug 1619852 - Fix the mistake in HTMLEditor::HandleDeleteCollapsedSelectionAtTextNode() r=m_kato
The check was written with `NS_ASSERTION`, but I realized that it's possible
case with mutation event listeners.  Therefore, I changed it to `if` and
`return`, but I forgot to revert the sign of inequality.

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

--HG--
extra : moz-landing-system : lando
2020-03-04 06:22:23 +00:00
Masayuki Nakano
dace885161 Bug 1449831 - part 4: Add automated tests for InputEvent.getTargetRanges() r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D64731

--HG--
extra : moz-landing-system : lando
2020-03-03 03:41:16 +00:00
Masayuki Nakano
f5af8613ec Bug 1449831 - part 3: Make editor set target ranges of beforeinput event if the editor instance is an HTMLEditor r=smaug
In most cases, `InputEvent.getTargetRange()` of `beforeinput` event should
return `Selection` ranges at dispatching the event.

This patch also handles special cases.
* composition change - target range should be the previous composition string
  which will be replaced with new composition string.
* replace text - target range should be the replace range.  This is used by
  spellchecker.
* drop - target range should be the drop point.

However, the other exception is not handled by this patch.  That is, deletions.
The target range(s) should be the range(s) which will be removed.  In most
cases, they also matches selection ranges, but may be extended to:
* surrogate pair boundary
* grapheme cluster boundary like complex emoji
* word/line deletion deletion
* `Backspace` or `Delete` from collapsed selection
* to end of unnecessary whitespaces

For supporting these cases, we need to separate
`HTMLEditor::HandleDeleteSelection()` and its helper methods and helper class
to range computation part and modifying the DOM tree part.  Of course, it
requires big changes and `InputEvent.getTargetRanges()` may be important for
feature detection of `beforeinput` event so that we should put off the big
changes to bug 1618457.

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

--HG--
extra : moz-landing-system : lando
2020-03-03 03:39:26 +00:00
Masayuki Nakano
0af4f88f9d Bug 1449831 - part 2: Make InputEventOptions be able to take target ranges r=smaug
`InputEventOptions` should be able to take target ranges for `beforeinput`
event.  However, it requires to include `StaticRange.h` from `nsContentUtils.h`
even though most `nsContentUtils.h` users don't need it.  Therefore, this patch
moves it from `nsContentUtils.h` to new header file.

And makes `nsContentUtils::DispatchInputEvent()` moves the target ranges
from `InputEventOptions` to `InternalEditorInputEvent`.

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

--HG--
extra : moz-landing-system : lando
2020-03-03 03:38:43 +00:00
Masayuki Nakano
3406e1e208 Bug 1618089 - part 8: Make WSRunObject::PrepareToDeleteRange() take 2 pointers of EditorDOMPoint r=m_kato
Note that the input can be `EditorDOMPointInText`, but modified range may start
and/or end with different container.  Therefore, it needs to take
`EditorDOMPoint` rather than `EditorDOMPointInText`.

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

--HG--
extra : moz-landing-system : lando
2020-03-03 04:35:26 +00:00
Masayuki Nakano
c5eeb32fe1 Bug 1618089 - part 7: Make some related methods use EditorDOMPointInText for arguments or result r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D64338

--HG--
extra : moz-landing-system : lando
2020-03-03 01:15:38 +00:00
Masayuki Nakano
8ca8aa8311 Bug 1618089 - part 6: Get rid of WSRunScanner::WSPoint r=m_kato
With adding new type, `EditorDOMPointInText` whose container is
`RefPtr<dom::Text>`, we can replace `WSRunScanner::WSPoint` and make
`WSRunScanner` and `WSRunObject` can use its various API.  Then, this
patch adds a lot of `NS_ASSERTION`s which can detect existing bugs.

Note that it may look like redundant that `EditorDOMPointInText::IsChar*()`
requires `EditorDOMPointInText::IsEndOfContainer()` check before that.
However, this makes what the callers check clearer.

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

--HG--
extra : moz-landing-system : lando
2020-03-02 10:08:59 +00:00
Masayuki Nakano
2d12d4abab Bug 1618089 - part 5: Make WSRunObject::GetASCIIShitespacesBounds() return 2 EditorDOMPoints r=m_kato
Before changing `WSPoint` to `EditorDOMPointBase`, we need to change some
methods which are helped by the methods returning `WSPoint`.

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

--HG--
extra : moz-landing-system : lando
2020-03-02 07:35:49 +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
febc3dd7e5 Bug 1618089 - part 3: Rename WSRunScanner::Get(Previous|Next)CharPoint(const WSPoint&) to WSRunScanner::Get(Previous|Next)CharPointFromPointInText() r=m_kato
For making it easier to review the following patches, rename the overloads
of `WSRunScanner::Get(Previous|Next)CharPoint()` which take `WSPoint`.

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

--HG--
extra : moz-landing-system : lando
2020-03-02 07:35:34 +00:00
Masayuki Nakano
abaebf7909 Bug 1618089 - part 2: Rename WSRunScanner::Get(Next|Previous)CharPointInternal() to WSRunScanner::LookFor(Next|Previous)CharPointWithinAllTextNodes() r=m_kato
They are fallback methods when the container of given point is not a text node
in `WSRunScanner::mNodeArray`, and then, looks for a text node for the given
point.

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

--HG--
extra : moz-landing-system : lando
2020-03-02 07:33:56 +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
38171fabc5 Bug 1616257 - part 5: Make WSRunObject stop keeping HTMLEditor as a friend class r=m_kato
With the preceding patches, `HTMLEditor` mostly does not need to be a friend of
`WSRunObject`.

This patch stops it, and adding some self-documented methods for checking
`mStartReason` and `mEndReason`, and also adding self-documented alternative
methods of `GetStartReasonContent()` and `GetEndReasonContent()`.

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

--HG--
extra : moz-landing-system : lando
2020-02-25 23:19:45 +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
ca9705cc2b Bug 1616257 - part 1: Redesign WSRunScanner::GetWSBoundingParent() r=m_kato
Its result has 4 meanings:

1. an editable block element for container of `mScanStartPoint`.
2. a topmost inline editable content for container of `mScanStartPoint` if there
is no editable block parent.
3. container of `mScanStartPoint` if it's a block (either editable or
non-editable).
4. container of `mScanStartPoint` if its parent is not editable and a inline
content.

#1, #2 and editable case of #3 make sense because the results are topmost
editable content in current context.  On the other hand, non-editable case
of #3 and #4 are caused by unexpected wrong fallback code.

So, let's make it always returns the content in the former meaning and if
the caller needs the latter one, they should use the container by themselves.
Therefore, for making what's the start of the search, this patch also makes
new method take start content instead of hiding `mScanStartPoint` from the
callers.

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

--HG--
extra : moz-landing-system : lando
2020-02-25 08:58:43 +00:00
Kris Maglione
c31aa68fb4 Bug 1535617: Part 2 - Clear weak references for most cycle collected objects on unlink. r=mccr8
This covers most cycle collected objects which support weak references, but
not the ones which inherit from a cycle collected class and don't do any cycle
collection on their own.

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

--HG--
extra : moz-landing-system : lando
2020-02-25 19:44:39 +00:00
Masayuki Nakano
5f656bfdd1 Bug 1616539 - Make TextEditor::OnDrop() compare newly focused element with active editing host r=m_kato
Currently, it checks whether proper element gets focus as expected with
`nsFocusManager::GetFocusedElement()`, but it returns globally focused element.
I.e., it may return different document's element or `nullptr` if application
itself is inactive.

The purpose of the focus check is, `HTMLEditor` can modify contents only in
active editing host.  Therefore, comparing with
`HTMLEditor::GetActiveEditingHost()` is better and simpler for here.

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

--HG--
extra : moz-landing-system : lando
2020-02-25 01:28:01 +00:00
Sylvestre Ledru
ca6530131a Bug 1519636 - Reformat recent changes to the Google coding style r=Ehsan,kvark
# ignore-this-changeset

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

--HG--
extra : moz-landing-system : lando
2020-02-24 15:33:38 +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
Simon Giesecke
9350e6b741 Bug 1613985 - Use MOZ_COUNTED_DEFAULT_CTOR_*/MOZ_COUNTED_DTOR_* macros. r=froydnj
This removes the need for explicit #ifdef NS_BUILD_REFCNT_LOGGING without
introducing user-defined destructors when it is not defined.

Also, some uses of virtual for declaring destructors are replaced by the
appropriate override declaration through these changes.

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

--HG--
extra : moz-landing-system : lando
2020-02-20 11:40:14 +00:00
Dorel Luca
d5f9df8ee1 Backed out 2 changesets (bug 1613985) for Build bustage on Windows2012. CLOSED TREE
Backed out changeset fd177b40b561 (bug 1613985)
Backed out changeset fb6d62b7f28d (bug 1613985)
2020-02-19 22:22:41 +02:00
Simon Giesecke
59b23375c0 Bug 1613985 - Use MOZ_COUNTED_DEFAULT_CTOR_*/MOZ_COUNTED_DTOR_* macros. r=froydnj
This removes the need for explicit #ifdef NS_BUILD_REFCNT_LOGGING without
introducing user-defined destructors when it is not defined.

Also, some uses of virtual for declaring destructors are replaced by the
appropriate override declaration through these changes.

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

--HG--
extra : moz-landing-system : lando
2020-02-19 18:05:38 +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
Mirko Brodesser
f170973369 Bug 1615581: part 1) Rename TableSelection to TableSelectionMode. r=jfkthame
See part 2) why this is necessary.

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

--HG--
extra : moz-landing-system : lando
2020-02-18 12:28:45 +00:00
Masayuki Nakano
a5deb4a2c5 Bug 1611374 - Disallow nested Document.execCommand() calls in Nightly and early Beta r=smaug
Chrome does not allow nested `Document.execCommand()` calls:
https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/core/editing/commands/document_exec_command.cc;l=75;drc=301e5d079a1b4c29c5b17574d0470e6db7370acc

On the other hand, Safari (and Firefox) allows it.  However, it's worthwhile to
follow Chrome's behavior.

This patch makes `Document::ExecCommand()` return `false` when it's called
while running another `Document::ExecCommand()` call on Nightly and early Beta.
This is exactly same behavior, and we should watch broken web apps reports
for a while before riding this on the train.

And this patch sets the pref to `true` when all crash tests under
`editor/libeditor/crashtests` which depend on nested calls of `execCommand` run
since same things may be reproducible with other DOM APIs.

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

--HG--
extra : moz-landing-system : lando
2020-02-15 19:17:00 +00:00
Masayuki Nakano
fe30c6ad87 Bug 1601532 - Make test_bug1332876.html synthesizes on <span> element in the <iframe> rather than on the <iframe> r=smaug
The timeout is caused by that `iframe.contentWindow` may not receive `click`
event (as far as I've tested, neither `mousedown` nor `mouseup` is fired in
that case) when synthesizing a mouse click over the `<iframe>` element with
parent window.  However, if it synthesizes mouse click with `<span>` element
in the `<iframe>` and `iframe.contentWindow`, `click` event is always fired.

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

--HG--
extra : moz-landing-system : lando
2020-02-16 14:54:11 +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
6725ec2b0e Bug 1601585 - Add a WPT to test selection in a contenteditable element with changing designMode r=smaug
We should port `editor/libeditor/tests/test_bug622371.html` to WPT.  It was
written for compatibility issue with CKEditor 9 years ago and Gecko and
Blink behave as exactly same.  Only Safari normalize the selection into the
end of the text node, but Safari also does not change selection at turning
on/off `designMode` too.  Therefore, all browser engines have implicit
agreement at least that selection shouldn't be changed at changing
`designMode`.

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

--HG--
extra : moz-landing-system : lando
2020-02-15 08:18:20 +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
Masayuki Nakano
ed10bfc397 Bug 1588688 - part 6: Make HTMLEditor::CollapseAdjacentTextNodes() use array of dom::Text rather than nsINode r=m_kato
`HTMLEditor::CollapseAdjacentTextNodes()` collects editable text nodes first so
that the array can be array of `dom::Text`.  Additionally, using
`DOMSubtreeIterator` instead of `ContentSubtreeIterator` makes the code easier
to understand.

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

--HG--
extra : moz-landing-system : lando
2020-02-13 02:54:45 +00:00
Masayuki Nakano
a25e33d6f2 Bug 1588688 - part 5: Make HTMLEditor::HandleDeleteNonCollapsedSelection() use array of nsIContent instead of nsINode r=m_kato
Same as the previous patch, the content iterator won't return non-`nsIContent`
node.  Therefore, `HTMLEditor::HandleDeleteNonCollapsedSelection()` can treat
it with array of `nsIContent`.

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

--HG--
extra : moz-landing-system : lando
2020-02-12 05:56:32 +00:00
Masayuki Nakano
1fb4eedd2a Bug 1588688 - part 4: Make HTMLEditor::RemoveEmptyNodesIn() use array of nsIContent rather than nsINode r=m_kato
The content iterators always return `nsIContent` even though the result of
`GetCurrentNode()` is `nsINode*`.  Therefore, we can make
`HTMLEditor::RemoveEmptyNodesIn()` use array of `nsIContent` instead of
array of `nsINode`.

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

--HG--
extra : moz-landing-system : lando
2020-02-12 05:53:34 +00:00
Masayuki Nakano
20807215a4 Bug 1588688 - part 3: Make HTMLEditor::CollectEditTargetNodes() and its users use array of nsIContent rather than nsINode r=m_kato
Unless editor needs to treat document node, all nodes are sub-class of
`nsIContent`.  Therefore, we can make `HTMLEditor::CollectEditTargetNodes()`
return array of `nsIContent` instead of array of `nsINode`.

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

--HG--
extra : moz-landing-system : lando
2020-02-12 05:52:30 +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
4ac984054a Bug 1588688 - part 2: Remove UniqueFunctor and EmptyEditableFunctor r=m_kato
This patch creates `DOMIterator::AppendNodesToArray()` which takes pointer to
a functor and removes `DOMIterator::AppendList()`.  This allows callers to use
lambda rather than the remaining functors, `UniqueFunctor` and
`EmptyEditableFunctor`, which are used only once.  Therefore, writing them as
lambda makes the callers easier to understand.  Finally, we can remove those
functor classes' base class, `BoolDomIterFunctor` too.

Note that this patch avoids using `std::function` even though if we'd use it
as functor, we could make each lambda can capture variables and each lambda
does not need to convert to point of a function with `+` operator explicitly.
The reason is, `std::function` is too slow if `AppendNodesToArray()` is called
in a hot path.

Depends on D61968

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

--HG--
extra : moz-landing-system : lando
2020-02-11 23:29:59 +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
e388597a7d Bug 1611360 - part 2: Change test_bug1151186.html to mochitest-plain r=smaug
Now, we have `SpecialPowers` to use `DOMWindowUtils`.  Therefore,
`test_bug1151186.html` can be a mochitest-plain and it's better since the
test checks behavior on web apps.

Depends on D62396

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

--HG--
rename : widget/tests/test_bug1151186.html => editor/libeditor/tests/test_bug1151186.html
extra : moz-landing-system : lando
2020-02-11 11:47:03 +00:00
Emilio Cobos Álvarez
e5463ecf7f Bug 1614718 - Add two missing includes to unbust thunderbird.
Differential Revision: https://phabricator.services.mozilla.com/D62474

--HG--
extra : moz-landing-system : lando
2020-02-11 19:18:45 +00:00
Masayuki Nakano
6bdd4b260e Bug 1612477 - part 2: Remove nsIDocumentStateListener.NotifyDocumentCreated() r=m_kato
There is no meaningful listener of this so that we can get rid of it.

Depends on D61357

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

--HG--
extra : moz-landing-system : lando
2020-02-04 06:19:55 +00:00
Masayuki Nakano
cc2af30635 Bug 1612477 - part 1: Make ComposerCommandsUpdater not inherit nsIDocumentStateListener r=m_kato
This patch makes `EditorBase::NotifyDocumentListeners()` notify
`ComposerCommandsUpdater` via `HTMLEditor::mComposerCommandsUpdater` directly.
Therefore, `ComposerCommandsUpdater` can stop inheriting
`nsIDocumentStateListener`.

Note that this patch also makes `ComposerCommandsUpdater::UpdateCommandGroup()`
not take `nsAString` as its parameter because inlinning the
`nsIDocumentStateListener` requires `ComposerCommandsUpdater.h` to include
`nsAString.h`, but it's redundant and `UpdateCommandGroup()` just compares
it with literal strings.  Therefore, using `enum class` for specifying command
group is faster.

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

--HG--
extra : moz-landing-system : lando
2020-02-03 07:35:44 +00:00
Emilio Cobos Álvarez
873a349556 Bug 1611701 - Tweak NODE_IS_EDITABLE flag handling for NAC so that it works consistently for <input type=number>. r=bzbarsky,masayuki,whimboo
I thought this would fix <input type=number style="user-select: none">, but
turns out it doesn't.

<input type=number> doesn't have the editor root as a root of the anonymous
subtree, so the current hack wouldn't work, as the anon root wouldn't have the
editable flag. So tweak the code a bit to handle stuff in a simpler way than
setting the flags after the fact, and set the NAC-root flag earlier to avoid
the mOuterWrapper->AppendChildTo(root) call forgetting about root's flags.

I had to tweak one AccessibleCaret test, but that's because it uses <textarea>
with user-select: none, and our behavior there is not particularly sane. It just
happened to work because that test-case also had a bunch of contenteditable
elements, and we stop matching this rule:

  https://searchfox.org/mozilla-central/rev/220a3bd6063fcbe5ca50e88dcabdc7dee0aca448/layout/style/contenteditable.css#22

Because the anonymous div now properly matches :-moz-read-write, which made the
rule apply and the test work. See comment 4 of this bug.

I'll fix this stuff up and add some tests for our behavior here in bug 1611699.

I refactored the dragdrop tests to cover more input types, but I ended up not
being able to use them because they're dependent on the content.

Instead I added an extra test and changed the refactor so that it applies to
<input type=search>, as there's layout work going on in bug 558594, and it'd be
unfortunate to regress this there too.

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

--HG--
extra : moz-landing-system : lando
2020-02-06 22:15:19 +00:00
Emilio Cobos Álvarez
69c87f6cb2 Bug 1613349 - Rename nsINode::DeleteProperty to RemoveProperty. r=smaug
And the related methods as well.

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

--HG--
extra : moz-landing-system : lando
2020-02-06 16:06:49 +00:00
Boris Zbarsky
c8713bf40a Bug 1612444. Improve some error messages for exceptions in layout. r=emilio
I used ThrowNotSupportedError for the not-implemented case.

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

--HG--
extra : moz-landing-system : lando
2020-02-03 20:35:54 +00:00
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
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
Masayuki Nakano
f38bb2c653 Bug 1597829 - part 1: Make EditorEventListener handle dropEffect r=m_kato
Currently, any default drop effect is "move" on editable content even when
the editor cannot remove the source element (e.g., outside of any editing host).
The drop effect is initialized by `nsContentUtils::SetDataTransferInEvent()`
which is called when `EditorEventListener::CanDrop()` and it returns true.
However, it requires unnecessary cost if we make `nsContentUtils` check
whether the dragging element is removable.  Therefore, we should make
`EditorEventListener` overwrites it with checking whether the source node is
editable or not.

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

--HG--
extra : moz-landing-system : lando
2019-12-21 12:28:13 +00:00
Masayuki Nakano
c5f1483368 Bug 1603074 - part 2: make test_dragdrop.html use synthesizePlainDragAndDrop() r=smaug
The test uses `synthesizeDrop()` etc.  However, the testing data does not match
with actual data when users do same thing in some cases.  Therefore, we should
rewrite it with `synthesizePlainDragAndDrop()`.

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

--HG--
extra : moz-landing-system : lando
2019-12-21 12:27:40 +00:00
Chris Peterson
406763af7f Bug 1570499 - Part 1: Replace MOZ_FALLTHROUGH macro with C++17's [[fallthrough]] attribute. r=froydnj
This changeset is a simple find and replace of `MOZ_FALLTHROUGH` and `[[fallthrough]]`.

Unfortunately, the MOZ_FALLTHROUGH_ASSERT macro (to assert on case fallthrough in debug builds) is still necessary after switching from [[clang::fallthrough]] to [[fallthrough]] because:

* MOZ_ASSERT(false) followed by [[fallthrough]] triggers a -Wunreachable-code warning in DEBUG builds
* but MOZ_ASSERT(false) without [[fallthrough]] triggers a -Wimplicit-fallthrough warning in NDEBUG builds.

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

--HG--
extra : moz-landing-system : lando
2019-12-20 07:16:43 +00:00
Mirko Brodesser
e51df4cb8e Bug 1600267: part 4) Call ComparePoints instead of ComparePoints_Deprecated in FilteredContentIterator. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D55298

--HG--
extra : moz-landing-system : lando
2019-12-19 13:27:35 +00:00
Mirko Brodesser
b8bb35cc69 Bug 1600267: part 1) Rename nsContentUtils::ComparePoints to ComparePoints_Deprecated. r=smaug
In a follow-up commit a new `ComparePoints` method with cleaner
arguments and return value will be added.

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

--HG--
extra : moz-landing-system : lando
2019-12-19 13:27:08 +00:00
Mirko Brodesser
1b964c5f36 Bug 1587433: part 7.5) Adapt callers of RangeBoundaryBase::Offset(). r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D54495

--HG--
extra : moz-landing-system : lando
2019-12-16 11:31:46 +00:00
Mirko Brodesser
691e0fbcae Bug 1587433: part 7.3) Adapt callers of RangeBoundaryBase::Offset(). r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D54493

--HG--
extra : moz-landing-system : lando
2019-12-16 11:31:50 +00:00
Csoregi Natalia
2bfeaf7cb5 Backed out 11 changesets (bug 1587433) for bustages on RangeBoundary.h. CLOSED TREE
Backed out changeset 18f8d61039b0 (bug 1587433)
Backed out changeset 69ad70a4f85e (bug 1587433)
Backed out changeset 79ec11ba7fde (bug 1587433)
Backed out changeset f8a7e23843b8 (bug 1587433)
Backed out changeset f9255884980f (bug 1587433)
Backed out changeset 50a798e664a1 (bug 1587433)
Backed out changeset b225586edea6 (bug 1587433)
Backed out changeset b1d9e55ece86 (bug 1587433)
Backed out changeset 7ebbcb2da488 (bug 1587433)
Backed out changeset 4032df295a67 (bug 1587433)
Backed out changeset 0e1577031add (bug 1587433)
2019-12-16 13:25:51 +02:00
Mirko Brodesser
2f58cffcb0 Bug 1587433: part 7.5) Adapt callers of RangeBoundaryBase::Offset(). r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D54495

--HG--
extra : moz-landing-system : lando
2019-12-11 12:26:10 +00:00
Mirko Brodesser
ed769e29cd Bug 1587433: part 7.3) Adapt callers of RangeBoundaryBase::Offset(). r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D54493

--HG--
extra : moz-landing-system : lando
2019-12-16 11:04:01 +00:00
Kris Maglione
94e3b0bd8d Bug 1596918: Part 3a - Scripted rewrite of most ContentTask.spawn calls to SpecialPowers.spawn calls. r=mccr8,remote-protocol-reviewers,ato
This is generally pretty straightforward, and rewrites nearly all calls. It
skips the ones that it can detect using frame script globals like
`sendAsyncMessage`, though.

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

--HG--
extra : moz-landing-system : lando
2019-12-13 20:36:16 +00:00
Makoto Kato
a7de55108c Bug 1596516 - NodeIsBlockStatic should return false for non-element. r=masayuki
`HTMLEditor::NodeIsBlockStatic` and `nsHTMLElement::IsBlock` doesn't check whether element is real `Element`.  So we should add more check whether element or not.

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

--HG--
extra : moz-landing-system : lando
2019-12-11 12:40:47 +00:00
shindli
91924fedc7 Backed out 9 changesets (bug 1596918) for causing mochitest permafailures in toolkit/content/tests/chrome/test_findbar_events.xhtml CLOSED TREE
Backed out changeset 45a1c42118f2 (bug 1596918)
Backed out changeset db09910ffa56 (bug 1596918)
Backed out changeset 5c9d9f141c10 (bug 1596918)
Backed out changeset 6a135670d603 (bug 1596918)
Backed out changeset 3a0184e0df72 (bug 1596918)
Backed out changeset 2f0036486823 (bug 1596918)
Backed out changeset a770c6d08d52 (bug 1596918)
Backed out changeset ef062eb7a6ee (bug 1596918)
Backed out changeset a6ea596e98db (bug 1596918)
2019-12-11 03:09:26 +02:00
Kris Maglione
16a9b29848 Bug 1596918: Part 3a - Scripted rewrite of most ContentTask.spawn calls to SpecialPowers.spawn calls. r=mccr8,remote-protocol-reviewers,ato
This is generally pretty straightforward, and rewrites nearly all calls. It
skips the ones that it can detect using frame script globals like
`sendAsyncMessage`, though.

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

--HG--
extra : moz-landing-system : lando
2019-12-10 23:07:13 +00:00
Noemi Erli
82d41a33b2 Backed out 9 changesets (bug 1596918) for causing multiple browser-chrome failures
Backed out changeset 415007efd8c9 (bug 1596918)
Backed out changeset 011eb5ce927b (bug 1596918)
Backed out changeset e5fd3ee22ea1 (bug 1596918)
Backed out changeset 0bca4de31d40 (bug 1596918)
Backed out changeset 11ec4393f23d (bug 1596918)
Backed out changeset c5404a7c286d (bug 1596918)
Backed out changeset 7e9304405a46 (bug 1596918)
Backed out changeset fa0f0aeabf99 (bug 1596918)
Backed out changeset de196b077000 (bug 1596918)
2019-12-07 22:26:43 +02:00
Kris Maglione
910eab35d2 Bug 1596918: Part 3a - Scripted rewrite of most ContentTask.spawn calls to SpecialPowers.spawn calls. r=mccr8,remote-protocol-reviewers,ato
This is generally pretty straightforward, and rewrites nearly all calls. It
skips the ones that it can detect using frame script globals like
`sendAsyncMessage`, though.

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

--HG--
extra : moz-landing-system : lando
2019-12-07 19:11:58 +00:00
Daniel Varga
84a601a6d4 Backed out 17 changesets (bug 1596918) for multiple browser-chrome and dev-tools failures. On a CLOSED TREE
Backed out changeset ab87d2c1afae (bug 1596918)
Backed out changeset 775f3b06a687 (bug 1596918)
Backed out changeset 67cc63ef5d7f (bug 1596918)
Backed out changeset 7d290bcd2067 (bug 1596918)
Backed out changeset 048db9f4db7c (bug 1596918)
Backed out changeset 96a79d2ba614 (bug 1596918)
Backed out changeset be770d112dd8 (bug 1596918)
Backed out changeset 302c8ab8391c (bug 1596918)
Backed out changeset 44ef8f20732e (bug 1596918)
Backed out changeset 38c11ebfb8ff (bug 1596918)
Backed out changeset b586fc081374 (bug 1596918)
Backed out changeset 12283166716f (bug 1596918)
Backed out changeset 99b0421015d8 (bug 1596918)
Backed out changeset 97ec49dbbbf3 (bug 1596918)
Backed out changeset ec79478f58f1 (bug 1596918)
Backed out changeset c6d356833bb8 (bug 1596918)
Backed out changeset 5ef6026806c8 (bug 1596918)
2019-12-07 03:12:07 +02:00
Kris Maglione
20da940e14 Bug 1596918: Part 3a - Scripted rewrite of most ContentTask.spawn calls to SpecialPowers.spawn calls. r=mccr8,remote-protocol-reviewers,ato
This is generally pretty straightforward, and rewrites nearly all calls. It
skips the ones that it can detect using frame script globals like
`sendAsyncMessage`, though.

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

--HG--
extra : moz-landing-system : lando
2019-12-06 22:14:14 +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
Julian Descottes
81e34d9437 Bug 1600333 - Remove all tags = clipboard from the codebase r=gbrown
Differential Revision: https://phabricator.services.mozilla.com/D55305

--HG--
extra : moz-landing-system : lando
2019-12-05 11:07:10 +00:00
Emilio Cobos Álvarez
3c12d374bc Bug 1600362 - Cleanup IntersectionObserver. r=smaug
Initially this was going to be a simple cleanup: Remove some useless namespaces
here and there and so on, remove `using` statements from the header and so on.

But unfortunately, DOMIntersectionObserver.h (which is included in Element.h,
unnecessarily) ended up exposing `Element` unnamespaced to a lot of code, so I
had to fix that.

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

--HG--
extra : moz-landing-system : lando
2019-11-29 20:39:36 +00:00
Emilio Cobos Álvarez
3abaf523d8 Bug 1599843 - nsCommandManager::CommandStatusChanged is infallible. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D54980

--HG--
extra : moz-landing-system : lando
2019-11-28 02:22:29 +00:00
Masayuki Nakano
b91249c508 Bug 1599318 - TextEditor shouldn't put \r into its anonymous text node r=m_kato
Starting from bug 1597679, `HTMLTextAreaElement::GetValueInternal()` stops
converting `\r\n` and `\r` with `\n` because it may be in hot path and the scan
cost of `\r` in `nsContentUtils::PlatformToDOMLineBreaks()` is redundant in
most cases.

However, there are still some paths to input `\r`.  This patch makes them
call `nsContentUtils::PlatformToDOMLineBreaks()` if they have not done it.

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

--HG--
extra : moz-landing-system : lando
2019-11-28 05:51:41 +00:00
Sylvestre Ledru
8d2f0d1b1f Bug 1519636 - Reformat recent changes to the Google coding style r=Ehsan
# ignore-this-changeset

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

--HG--
extra : moz-landing-system : lando
2019-11-26 14:35:02 +00:00
jeffin143
2293551763 Bug 1598539 : convert NS_STYLE_IME_MODE_* to an enum class in nsStyleConsts.h r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D54255

--HG--
extra : moz-landing-system : lando
2019-11-25 15:41:18 +00:00
Masayuki Nakano
4d856eb67e Bug 1598327 - part 2: Make TopLevelEditSubActionData::mCachedInlineStyle create only in HTMLEditor r=m_kato
The initialization cost of `AutoStyleCacheArray` is still expensive and it's
used only by `HTMLEditor`.  Therefore, we should make it `Maybe` and construct
it only when the editor is an `HTMLEditor`.

Depends on D54253

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

--HG--
extra : moz-landing-system : lando
2019-11-23 01:12:33 +00:00
Masayuki Nakano
b07bd373e8 Bug 1598327 - part 1: Make AutoStyleCacheArray initialize itself with initialization list r=m_kato
Calling `AppendElement()` a lot causes the constructor appearing in profile.
`AutoTArray` has a constructor taking initialization list.  Let's use it.

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

--HG--
extra : moz-landing-system : lando
2019-11-23 01:12:35 +00:00
Masayuki Nakano
20699e2189 Bug 1597679 - part 2: Make nsITextControlElement inherit nsGenericHTMLFormElementWithState r=smaug
Sub classes of `nsITextControlElement` are only `HTMLInputElement` and
`HTMLTextAreaElement`. And both base class is
`nsGenericHTMLFormElementWithState`.  Therefore, we can make
`nsITextControlElement` inherit `nsGenericHTMLFormElementWithState` and
make `HTMLInputElement` and `HTMLTextAreaElement` inherit
`nsITextControlElement`.  Then, we can get rid of a lot of QI between
`nsINode`/`nsIContent`/`Element` and `nsITextControlElement` (and note that
some of them in a hot path).

Additionally, this patch renames `nsITextControlElement` to
`mozilla::TextControlElement`.

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

--HG--
rename : dom/html/nsITextControlElement.h => dom/html/TextControlElement.h
extra : moz-landing-system : lando
2019-11-25 06:35:15 +00:00
Coroiu Cristina
84bf2b6d25 Backed out 3 changesets (bug 1597679) for Android debug build bustage at build/src/dom/base/nsContentAreaDragDrop.cpp
Backed out changeset 6a73b58e0db4 (bug 1597679)
Backed out changeset 90a172eff2de (bug 1597679)
Backed out changeset d4a156cf28ff (bug 1597679)

--HG--
rename : dom/html/TextControlElement.h => dom/html/nsITextControlElement.h
2019-11-24 09:02:53 +02:00
Masayuki Nakano
eea1784f2d Bug 1597679 - part 2: Make nsITextControlElement inherit nsGenericHTMLFormElementWithState r=smaug
Sub classes of `nsITextControlElement` are only `HTMLInputElement` and
`HTMLTextAreaElement`. And both base class is
`nsGenericHTMLFormElementWithState`.  Therefore, we can make
`nsITextControlElement` inherit `nsGenericHTMLFormElementWithState` and
make `HTMLInputElement` and `HTMLTextAreaElement` inherit
`nsITextControlElement`.  Then, we can get rid of a lot of QI between
`nsINode`/`nsIContent`/`Element` and `nsITextControlElement` (and note that
some of them in a hot path).

Additionally, this patch renames `nsITextControlElement` to
`mozilla::TextControlElement`.

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

--HG--
rename : dom/html/nsITextControlElement.h => dom/html/TextControlElement.h
extra : moz-landing-system : lando
2019-11-24 05:38:02 +00:00
Cosmin Sabou
f2a93e6f4d Backed out 2 changesets (bug 1598327) for browser chrome failures on browser_bug399606.js
Backed out changeset c2996e694ada (bug 1598327)
Backed out changeset fd1c9515bd8b (bug 1598327)
2019-11-23 02:52:20 +02:00
Noemi Erli
92d932148c Backed out changeset 8cdae49ab472 (bug 1598539) for causing build bustages in EditorBase.cpp CLOSED TREE 2019-11-22 22:04:00 +02:00
Masayuki Nakano
f846ab4ab6 Bug 1598327 - part 2: Make TopLevelEditSubActionData::mCachedInlineStyle create only in HTMLEditor r=m_kato
The initialization cost of `AutoStyleCacheArray` is still expensive and it's
used only by `HTMLEditor`.  Therefore, we should make it `Maybe` and construct
it only when the editor is an `HTMLEditor`.

Depends on D54253

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

--HG--
extra : moz-landing-system : lando
2019-11-22 15:02:57 +00:00
Masayuki Nakano
1ecc9bd28e Bug 1598327 - part 1: Make AutoStyleCacheArray initialize itself with initialization list r=m_kato
Calling `AppendElement()` a lot causes the constructor appearing in profile.
`AutoTArray` has a constructor taking initialization list.  Let's use it.

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

--HG--
extra : moz-landing-system : lando
2019-11-22 16:11:10 +00:00
jeffin143
058d24f2df Bug 1598539 : convert NS_STYLE_IME_MODE_* to an enum class in nsStyleConsts.h r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D54255

--HG--
extra : moz-landing-system : lando
2019-11-22 13:33:59 +00:00
Hiroyuki Ikezoe
49285c5161 Bug 1598225 - Call restoreNormalRefresh before closing window. r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D54197

--HG--
extra : moz-landing-system : lando
2019-11-22 01:35:03 +00:00
Makoto Kato
d6c4b79621 Bug 1595425 - Don't flush layout when setting empty string on Chrome. r=masayuki
This is a regression by bug 1568996. Although editor uses nsFrameSelection to
move caret, if frame is dirty, nsFrameSelection returns error.
So by bug 1568996, we flush layout before calling nsFrameSelection. But we
should stop flushing layout when we don't use nsFrameSelection.

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

--HG--
extra : moz-landing-system : lando
2019-11-20 05:09:18 +00:00
Emma Malysz
ce9c72d88e Bug 1597752, rename .xul files in editor/ to .xhtml r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D53844

--HG--
rename : editor/composer/test/test_bug434998.xul => editor/composer/test/test_bug434998.xhtml
rename : editor/libeditor/tests/test_bug1386222.xul => editor/libeditor/tests/test_bug1386222.xhtml
rename : editor/libeditor/tests/test_bug1397412.xul => editor/libeditor/tests/test_bug1397412.xhtml
rename : editor/libeditor/tests/test_bug489202.xul => editor/libeditor/tests/test_bug489202.xhtml
rename : editor/libeditor/tests/test_bug599983.xul => editor/libeditor/tests/test_bug599983.xhtml
rename : editor/libeditor/tests/test_bug607584.xul => editor/libeditor/tests/test_bug607584.xhtml
rename : editor/libeditor/tests/test_bug616590.xul => editor/libeditor/tests/test_bug616590.xhtml
rename : editor/libeditor/tests/test_bug780908.xul => editor/libeditor/tests/test_bug780908.xhtml
rename : editor/libeditor/tests/test_cut_copy_delete_command_enabled.xul => editor/libeditor/tests/test_cut_copy_delete_command_enabled.xhtml
rename : editor/libeditor/tests/test_pasteImgTextarea.xul => editor/libeditor/tests/test_pasteImgTextarea.xhtml
rename : editor/reftests/xul/empty-ref.xul => editor/reftests/xul/empty-ref.xhtml
rename : editor/reftests/xul/emptytextbox-4.xul => editor/reftests/xul/emptytextbox-4.xhtml
rename : editor/reftests/xul/emptytextbox-ref.xul => editor/reftests/xul/emptytextbox-ref.xhtml
extra : moz-landing-system : lando
2019-11-19 23:40:10 +00:00
Emilio Cobos Álvarez
ef510c0de3 Bug 1596768 - Remove GetBindingParent usage in editor. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D53199

--HG--
extra : moz-landing-system : lando
2019-11-15 17:44:11 +00:00
Mirko Brodesser
1ae8f1b996 Bug 1591417: part 4) Adapt InsertTextIntoTextNodeWithTransaction to pass adjusted range to TopLevelEditSubActionDataRef.DidInsertText. r=masayuki
Otherwise, an invalid `EditorRawDOMPoint` was constructed by a test.

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

--HG--
extra : moz-landing-system : lando
2019-11-13 09:16:06 +00:00
Mirko Brodesser
c4342625ea Bug 1591417: part 2) Rename HasMutationEventListeners to MaybeHasMutationEventListeners. r=masayuki
After removing all mutation event listeners, the corresponding method
still returns `true`, so the new name is more accurate.

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

--HG--
extra : moz-landing-system : lando
2019-11-12 15:20:20 +00:00
Mirko Brodesser
e5f7410403 Bug 1591417: part 1) Assert EditorDOMPointBase::ToRawRangeBoundary() uses valid offset. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D52341

--HG--
extra : moz-landing-system : lando
2019-11-12 15:20:13 +00:00
Sebastian Hengst
0341151d63 Bug 1594981 - update Core::DOM* and Core::Storage* bugzilla product and component meta data in moz.build files after reorganization in bug 1594717. r=annevk
Differential Revision: https://phabricator.services.mozilla.com/D52345

--HG--
extra : moz-landing-system : lando
2019-11-08 12:17:57 +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
129b58687c Bug 1588745 - part 6: Post processing of setting value with TextEditor should be done before dispatching "input" event r=Ehsan
Currently, "input" event is fired when the `AutoScriptBlocker` in `SetValue()`
is deleted.  So, for keeping same behavior, the post processing after calling
`TextEditor` methods should be done before editor dispatches "input" event.

Fortunately, `TextInputListener::OnEditActionHandled()` is a good chance to
do that.  Therefore, this patch makes it notify `TextControlState` and
`AutoTextControlHandlingState`.

Note that ideally, each method of `TextEditor` should return
`NS_ERROR_OUT_OF_MEMORY` coming from
`AutoTextControlHandlingState::OnEditActionHandled()`.  However, it requires
a lot of changes in editor classes, and the case is really rare since editor
does not use fallible allocation.  Therefore, it must be okay to crash in
editor if `OnEditActionHandled()` returns `NS_ERROR_OUT_OF_MEMORY`.

Depends on D51395

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

--HG--
extra : moz-landing-system : lando
2019-11-03 02:50:00 +00:00
Edgar Chen
acd2114113 Bug 1580491 - Use Element::HasNonEmptyAttr in various places; r=bzbarsky
This was done by reviewing the results of
https://searchfox.org/mozilla-central/search?q=%2F*GetAttr%5C(.%2B(%26%26%7C%5C%7C%5C%7C)&case=true&regexp=true
one by one and replacing them with Element::HasNonEmptyAttr if possible.

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

--HG--
extra : moz-landing-system : lando
2019-11-01 15:24:25 +00:00
Emilio Cobos Álvarez
630c46a466 Bug 1591297 - Fix/remove a couple sanitizer tests now that we don't parse -moz-binding. r=hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D50590

--HG--
extra : moz-landing-system : lando
2019-10-29 08:32:06 +00:00
Alex Henrie
74cc0f4dce Bug 1591490 - Use the NS_IS_SURROGATE_PAIR macro everywhere. r=Ehsan
Differential Revision: https://phabricator.services.mozilla.com/D50697

--HG--
extra : moz-landing-system : lando
2019-10-27 05:05:51 +00:00
Makoto Kato
67ecac7a24 Bug 1453190 - Don't get editing session during destroying docshell. r=masayuki
When closing window / documnet, if content modifies an element that has
contenteditable via unload event, it hits assertion in
`nsDocShell::EnsureEditorData` due to destroying document. So we should
return error before getting editing session.

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

--HG--
extra : moz-landing-system : lando
2019-10-25 10:23:31 +00:00
Emilio Cobos Álvarez
6d8c0d26b1 Bug 1582398 - Remove user-select: all for editable labels. r=masayuki
This seems to go back to our initial contenteditable implementation, and I don't
think there's a reason <label> should work differently from anything else.

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

--HG--
extra : moz-landing-system : lando
2019-10-23 09:30:03 +00:00
Mirko Brodesser
e1b9454134 Bug 1587716: change RangeBoundaryBase's offset argument to uint32_t. r=smaug
`uint32_t`, because `nsRange::ComparePoints` requires it -- by webidl
interface -- to be unsigned long.

Moreover it makes `RangeBoundaryBase`'s interface cleaner, because it
already exposes the offset as a `uint32_t`.

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

--HG--
extra : moz-landing-system : lando
2019-10-23 08:22:36 +00:00
Mats Palmgren
6aadfc8aaf Bug 1587141 part 2 - Make execCommand("indent") ignore whitespace when looking for sibling list element. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D48587

--HG--
extra : moz-landing-system : lando
2019-10-14 17:11:00 +00:00
Mats Palmgren
c506e40d11 Bug 1587141 part 1 - Share some common code between Handle[CSS|HTML]IndentAtSelectionInternal (idempotent patch). r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D48586

--HG--
extra : moz-landing-system : lando
2019-10-15 04:36:26 +00:00
Geoff Brown
32490358c2 Bug 1585119 - Re-enable many more mochitests on Android; r=geckoview-reviewers,snorp
Most of these tests have been disabled for a long time; they run well
in the current test environment.
I intend to enable still more mochitests in a future patch.

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

--HG--
extra : moz-landing-system : lando
2019-10-18 14:35:20 +00:00
Valentin Gosu
8a48b05801 Bug 1413203 - The css for about:networking is not loading in Android r=Gijs
* Make about:networking work on mobile
* I used the aboutMemory.css file as a guide for doing this
* The mobile CSS does not include the common.css, since that doesn't seem to work. But at least now the interfaces is functional. We should make it look nice in a follow-up.

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

--HG--
extra : moz-landing-system : lando
2019-10-18 12:01:56 +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
Geoff Brown
c906073cd5 Bug 1585119 - Re-enable many mochitests on android; r=geckoview-reviewers,snorp
Most of these tests have been disabled for a long time; they run well
in the current test environment.
With the additional tests running, task times increase; I have added one
more test chunk for android mochitest-plain.
These tests were identified from a random sampling of mochitest manifests;
I intend to enable more mochitests in future patches.

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

--HG--
extra : moz-landing-system : lando
2019-10-15 15:07:09 +00:00
Mirko Brodesser
b761e516f6 Bug 1587746: remove RangeBoundaryBase::Set and use constructor instead. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D48826

--HG--
extra : moz-landing-system : lando
2019-10-11 12:43:57 +00:00
Masayuki Nakano
ac74e89b26 Bug 1566795 - part 6: Make HTMLEditor::RemoveInlinePropertyInternal() remove text node style which comes from block parent r=m_kato
Finally, `Document.execCommand()` still does not work fine if selection
starts from very start of block and/or end at very end of block because
`PromoteInlineRange()` extends selection range to contain the
containers, then, `SubtreeContentIterator` won't list up text nodes.

In this case, `RemoveInlinePropertyInternal()` expects that
`RemoveStyleInside()` removes text node style with creating
`<span>` elements.  However, `RemoveStyleInsilde()` only handles
`Element`s and it handles elements from most-descendants.
Therefore, it cannot distinguish whether text node style comes
from removing inline elements or parent block.

This patch makes `RemoveInlinePropertyInternal()` collect
descendant text nodes in the range after handling all nodes in
the range except descendant text nodes, then, check the
final style of descendant text nodes, finally, remove the style
if coming from parent block.

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

--HG--
extra : moz-landing-system : lando
2019-10-09 08:04:34 +00:00
Makoto Kato
aecde3cc69 Bug 1587312 - Fix typo of finding non-anonymous content. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D48640

--HG--
extra : moz-landing-system : lando
2019-10-09 05:42:42 +00:00
Masayuki Nakano
92ead719bd Bug 1566795 - part 5: Make the for loop of HTMLEditor::RemoveInlinePropertyInternal() partially selected text nodes r=m_kato
If selection range is not in **one** text node, `RemoveInlinePropertyInternal()`
collects target nodes with `SubtreeContentIterator`.  It only collects topmost
nodes which are **entirely** contained in the range (it's enough because their
descendants will be handled by `RemoveStyleInside()` recursively).

The reasons why it uses `SubtreeContentIterator` rather than
`PreContentIterator` must be:
1. Performance reason.
2. Assuming there are no multiple text nodes.
3. Not expects that user removes text node styles come from parent block.

The reason 2 is wrong because when removing a style, all browsers don't
join text nodes which was in removing element with adjacent text nodes.
(I.e., we cannot change this behavior for compatibility.)

The reason 3 is of course wrong we're struggling with this scenario.

Therefore, `RemoveInlinePropertyInternal()` needs to collect partially
selected text nodes by itself (if there are).  Then, we can merge the
single text node selected case with the `for` loop.

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

--HG--
extra : moz-landing-system : lando
2019-10-08 09:24:47 +00:00
Masayuki Nakano
bb14f09ee9 Bug 1566795 - part 4: Make HTMLEditor not check IsCSSEnabled() at removing inline style r=m_kato
For compatibility with Chrome, when removing inline style at block parent,
we should reset the style with creating `<span>` element whose `style`
attribute removes the style.  We do this only in CSS mode, but we should do
it in HTML mode too.

This patch also makes `FontFaceStateCommand::SetState()` ignore `tt` value
if its root caller is `Document::ExecCommand()`.  It was implemented for
composer to handle XUL command in bug 115922.  Therefore, we should not do
this special handling on the web.  If it were possible to separate this
change to another bug, it'd be nicer.  But without this change, we'll have
a lot of regressions of `Document.execCommand("fontname")`.  Therefore,
this is also fixed in this patch.

Note that this removes first `.ini` file selection because
the tests cannot be run without test number range parameter.
So, the sections are not used anymore.

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

--HG--
extra : moz-landing-system : lando
2019-10-08 09:24:19 +00:00
Razvan Maries
a6b9e7fdbc Backed out changeset 90695432b21e (bug 1566795)for build bustages on HTMLStyleEditor.cpp. CLOSED TREE 2019-10-08 10:21:58 +03:00
Masayuki Nakano
b1996e5052 Bug 1566795 - part 4: Make HTMLEditor not check IsCSSEnabled() at removing inline style r=m_kato
For compatibility with Chrome, when removing inline style at block parent,
we should reset the style with creating `<span>` element whose `style`
attribute removes the style.  We do this only in CSS mode, but we should do
it in HTML mode too.

This patch also makes `FontFaceStateCommand::SetState()` ignore `tt` value
if its root caller is `Document::ExecCommand()`.  It was implemented for
composer to handle XUL command in bug 115922.  Therefore, we should not do
this special handling on the web.  If it were possible to separate this
change to another bug, it'd be nicer.  But without this change, we'll have
a lot of regressions of `Document.execCommand("fontname")`.  Therefore,
this is also fixed in this patch.

Note that this removes first `.ini` file selection because
the tests cannot be run without test number range parameter.
So, the sections are not used anymore.

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

--HG--
extra : moz-landing-system : lando
2019-10-07 05:31:19 +00:00
Masayuki Nakano
6a1791bc12 Bug 1566795 - part 3: Clean up HTMLEditor::RemoveStyleInside() r=m_kato
Surprisingly, its `aChildOnly` is never set to `true` and if it were set to
`true`, it does unnecessary recursive calls.  Therefore, we can make it
simpler.

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

--HG--
extra : moz-landing-system : lando
2019-10-07 03:33:11 +00:00
Makoto Kato
be2e7568aa Bug 1568996 - Flush layout before calling nsFrameSelection::MoveCaret. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D47532

--HG--
extra : moz-landing-system : lando
2019-10-07 08:18:33 +00:00
Makoto Kato
1ab2eca2d2 Bug 1584901 - Convert tail space to NBSP in composition string. r=masayuki
This is related to bug 1530649. When using <span> element with contentedtiable,
we won't insert <br> element at last. When Korean IME on macOS commits
composition by space key, composition string has space.

Gekco removes U+0020 space when it is last character into editing host. To keep
whitespace, we have to replace with NBSP when it is last.

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

--HG--
extra : moz-landing-system : lando
2019-10-07 08:16:18 +00:00
Masayuki Nakano
3cc02eccbf Bug 1566795 - part 2: Clean up HTMLEditor::SplitAboveRange() r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D47859

--HG--
extra : moz-landing-system : lando
2019-10-07 01:11:31 +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
Sylvestre Ledru
f12b9fa5c3 Bug 1519636 - Reformat recent changes to the Google coding style r=Ehsan
# ignore-this-changeset

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

--HG--
extra : moz-landing-system : lando
2019-10-06 18:29:55 +00:00
Emma Malysz
e4eba2b24f Bug 1586337, Replace XUL textbox with HTML input in testcases within editor directory r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D48100

--HG--
extra : moz-landing-system : lando
2019-10-04 16:30:10 +00:00
Tim Nguyen
91976e6a66 Bug 1586018 - Remove a11y tree tests, reftests and crashtests only related to textbox. r=surkov,emilio
Differential Revision: https://phabricator.services.mozilla.com/D48080

--HG--
extra : moz-landing-system : lando
2019-10-03 18:01:08 +00:00
Tim Nguyen
2ed60e9a99 Bug 1586019 - Remove textbox .plain class support. r=bgrins
Differential Revision: https://phabricator.services.mozilla.com/D48074

--HG--
extra : moz-landing-system : lando
2019-10-03 16:21:42 +00:00
Alexander Surkov
e670b51391 Bug 1582590 - Clean up unused <textbox type='autocomplete'> platform code. r=NeilDeakin
Differential Revision: https://phabricator.services.mozilla.com/D46541

--HG--
extra : moz-landing-system : lando
2019-10-03 11:18:53 +00:00
Gabriele Svelto
10d41866a5 Bug 1585156 - Remove useless inclusions of nsIDOMWindow.h and nsIDOMWindowUtils.h r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D47678

--HG--
extra : moz-landing-system : lando
2019-09-30 22:06:47 +00:00
Geoff Brown
d964f2d601 Bug 1584290 - Enable many reftests on Android; r=geckoview-reviewers,snorp
Most of these tests have been disabled for a long time; they run well
in the current test environment.

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

--HG--
extra : moz-landing-system : lando
2019-09-30 16:34:16 +00:00
Christoph Kerschbaumer
7271448df4 Bug 1584282: Remove forgotten debug statement within test_bug629172.html from Bug 1497200. r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D47307

--HG--
extra : moz-landing-system : lando
2019-09-26 16:48:43 +00:00
Jorg K
389a1827c2 Bug 1581774 - revert part of rev 5e2fad03c885 from bug 1507543 for Thunderbirds since it breaks the spellcheck. r=m_kato
--HG--
extra : rebase_source : 8dd6fdf15b48115691d21c476875a9bc5cd48591
2019-09-26 09:42:42 +02:00
Tim Nguyen
b0d1ddb586 Bug 1581956 - Make search-textbox not use the <textbox> tag. r=surkov,MarcoZ
Differential Revision: https://phabricator.services.mozilla.com/D46219

--HG--
extra : moz-landing-system : lando
2019-09-25 19:12:48 +00:00
Christoph Kerschbaumer
53d5895e71 Bug 1497200: Apply Meta CSP to about:downloads. r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D45330

--HG--
extra : moz-landing-system : lando
2019-09-25 13:50:28 +00:00
Makoto Kato
2c7f1d861c Bug 1474978 - Add crashtest. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D46756

--HG--
extra : moz-landing-system : lando
2019-09-23 10:37:40 +00:00
Mirko Brodesser
a962446e79 Bug 1581523: part 4) Don't set mWrapColumn depending on <body>'s style. r=jorgk
Instead, rely on the proper initialization of `mWrapColumn` via
`nsPlainTextSerializer::Init`.

This will allow to move `mWrapColumn` to `nsPlainTextSerializer::Settings::mWrapColumn`,
simplifying reasoning about it.

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

--HG--
extra : moz-landing-system : lando
2019-09-23 11:43:59 +00:00
Masayuki Nakano
5d03660aa8 Bug 1581206 - Reconvert browser_bug629172.js to mochitest r=Ehsan
Currently, we can use chrome process's shortcut key with
`EventUtils.synthesizeKey()` with enabling `"test.events.async.enabled"` pref.
So, we should reconvert it to a mochitest for making it more stable.

Oddly, when I try to run this test as test-verify on macOS, it permanently
fails rendering resizer of `<textarea>` elements immediately after creation.
Therefore, this patch disables this test in test-verify on macOS.

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

--HG--
rename : editor/libeditor/tests/browser_bug629172.js => editor/libeditor/tests/test_bug629172.html
extra : moz-landing-system : lando
2019-09-20 14:56:47 +00:00
Masayuki Nakano
52da57f7a9 Bug 1581337 - Make HTMLEditor::DeleteMostAncestorMailCiteElementIfEmpty() do nothing if found mail-cite element is not empty r=m_kato
When rewriting `DeleteMostAncestorMailCiteElementIfEmpty()` with early-return
style, I forgot to make it do nothing when found element is empty:
https://searchfox.org/mozilla-central/rev/94e642e6036dc694b07cab895c9b5b267f0db065/editor/libeditor/HTMLEditRules.cpp#4078
This patch restores it.

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

--HG--
extra : moz-landing-system : lando
2019-09-18 11:38:35 +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