Commit Graph

33 Commits

Author SHA1 Message Date
Masayuki Nakano
39daaa7db8 Bug 1534561 - Make editor use PresShell directly rather than nsIPresShell r=m_kato
`PresShell.h` is exposed as `mozilla/PresShell.h` and `PresShell` is the only
concrete class of `nsIPresShell`.  Therefore, we have no reason to access
`PresShell` via `nsIPresShell`.

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

--HG--
extra : moz-landing-system : lando
2019-03-15 05:01:10 +00:00
Masayuki Nakano
9609df9a73 Bug 1525481 - part 3: Make editor not expose internal errors to the web r=m_kato
As far as I've tested, Chrome does not throw exception even when editor is
destroyed or editor content is modified unexpectedly.  So, we should return
`NS_OK` from most public methods of editor when internal methods return
`NS_ERROR_EDITOR_DESTROYED` or `NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE`.

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

--HG--
extra : moz-landing-system : lando
2019-02-25 09:07:54 +00:00
Masayuki Nakano
f4e8c4a068 Bug 1528676 - Remove telemetry probes for HTMLEditors which have shown Gecko build-in editing UIs and if they are operated r=m_kato,Ehsan
Those probes are now expired and we got enough data:

- Almost no user uses the grip to move absolute positioned element
- There were over one thousand users using the inline table editor and the object resizers.
- Such users keep using even after we disabled the UIs by default.

Perhaps, such small number of users keep using the UIs, i.e., I guess the
number won't become smaller in short term.  Therefore, this patch removes the
telemetry probes and members of HTMLEditor which are necessary to call
Telemetry API.

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

--HG--
extra : moz-landing-system : lando
2019-02-22 02:17:27 +00:00
Sylvestre Ledru
265e672179 Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
# ignore-this-changeset

--HG--
extra : amend_source : 4d301d3b0b8711c4692392aa76088ba7fd7d1022
2018-11-30 11:46:48 +01:00
Masayuki Nakano
41166eca5f Bug 1465702 - part 4: Make public methods of HTMLEditor create AutoEditActionDataSetter if necessary r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D10008

--HG--
extra : moz-landing-system : lando
2018-10-30 10:00:17 +00:00
Masayuki Nakano
9c1afc4bee Bug 1484116 - part 1: Create HTMLEditor::InsertTableColumnsWithTransaction() for internal use of nsITableEditor::InsertTableColumn() r=m_kato
nsITableEditor::InsertTableColumn() is an XPCOM method but it's used internally.
So, HTMLEditor should implement it with a non-virtual method and internal
users should use it instead.

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

--HG--
extra : moz-landing-system : lando
2018-09-20 09:15:08 +00:00
Masayuki Nakano
3e96aa79b3 Bug 1484117 - part 1: Create HTMLEditor::InsertTableRowsWithTransaction() for internal use of nsITableEditor::InsertTableRow() r=m_kato
nsITableEditor::InsertTableRow() is an XPCOM method but there are some internal
users.  So, HTMLEditor should implement it with a non-virtual method and
it should be used by all internal users.

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

--HG--
extra : moz-landing-system : lando
2018-09-20 06:55:17 +00:00
Masayuki Nakano
7f96a82ad5 Bug 1484121 - part 1: Create HTMLEditor::DeleteSelectedTableColumnsWithTransaction() for internal use of nsITableEditor::DeleteTableColumn() r=m_kato
nsITableEditor::DeleteTableColumn() is an XPCOM method but used internally.
So, it should be implemented with non-virtual method and internal users
should use it.

Note that this changes only one thing.  This moves
|AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(...| from
below DeleteTableElementAndChildrenWithTransaction() to above it.
I.e., DeleteTableElementAndChildrenWithTransaction() works under
EditSubAction::eDeleteNode as the top level sub-action now.  This is same
as DeleteSelectedTableRowsWithTransaction().  Therefore, the difference
with it when it removes <table> is now fixed.

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

--HG--
extra : moz-landing-system : lando
2018-09-19 06:34:33 +00:00
Masayuki Nakano
47fa32ffd8 Bug 1484122 - part 1: Create HTMLEditor::DeleteSelectedTableRowsWithTransaction() for internal use of nsITableEditor::DeleteTableRow() r=m_kato
nsITableEditor::DeleteTableRow() is an XPCOM method but there are some internal
users.  So, it should be implemented as non-virtual protected method and
internal users should use it instead.

This also renames (and reimplement) HTMLEditor::DeleteTable2() since it's
really bad name and the code dispatches unnecessary "selectionchange" events.

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

--HG--
extra : moz-landing-system : lando
2018-09-18 07:56:45 +00:00
Masayuki Nakano
63856d6d6e Bug 1485929 - Create HTMLEditor::RefreshInlineTableEditingUIInternal() for internal use r=m_kato
HTMLEditor::RefreshInlineTableEditingUI() is an XPCOM method.  Therefore,
we should create a non-virtual method for internal use.

Additionally, this patch makes related methods safer for nested calls of
ShowInlineTableEditingUI() and HideInlineTableEditingUI().  If
ShowInlineTableEditingUI() and RefreshInlineTableEditingUIInternal() detects
hiding or replacing current UI, they return error to make the callers stop
handling anything for new UI.

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

--HG--
extra : moz-landing-system : lando
2018-09-11 12:10:54 +00:00
Masayuki Nakano
908ba601c1 Bug 1485925 - part 1: Create HTMLEditor::HideResizersInternal() for internal use r=m_kato
HTMLEditor::HideResizers() is an XPCOM method, so, we should create non-virtual
method for internal use.

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

--HG--
extra : moz-landing-system : lando
2018-09-06 05:02:46 +00:00
Masayuki Nakano
a24cf41019 Bug 1484110 - part 2: Rewrite HTMLEditor::HideInlineTableEditingUI() r=m_kato
First, HTMLEditor::HideInlineTableEditingUI() always returns NS_OK.  So, we
can change its return type to void.

Additionally, it removes each UI from the DOM tree one by one.  However, each
mutation could cause showing same UI again.  In such case,
ShowInlineTableEditingUI() overwrites each UI with newly created element.
Then, HTMLEditor cannot remove the old UI anymore.  Therefore, this patch
moves all members of the UI into local variables first.
2018-08-17 18:23:13 +09:00
Masayuki Nakano
b808917841 Bug 1449564 - part 1: Disable object resizer and inline table editor in default r=m_kato
Gecko supports resizers of <img> elements and <table>, <td>, <th> elements and
has UI to remove existing table row or column in default.  However, the other
browsers don't have such UI and web apps need to disable this feature with
calling both:
document.execCommand("enableObjectResizing", false, false);
document.execCommand("enableInlineTableEditing", false, false);
for avoiding conflicting with their own features to edit such elements.

Therefore, it doesn't make sense to keep enabling them in default only on
Gecko.  If web apps want to keep using these features, they should call:
document.execCommand("enableObjectResizing", false, true);
document.execCommand("enableInlineTableEditing", false, true);
at initializing the editor.

And also this patch fixes bugs of
document.queryCommandState("enableObjectResizing") and
document.queryCommandState("enableInlineTableEditing").  They always return
false even after calling document.execCommand(..., false, true) since
nsSetDocumentStateCommand::GetCommandStateParams() sets bool value as
STATE_ATTRIBUTE.  However, nsHTMLDocument::QueryCommandValue() which is the
caller referring STATE_ATTRIBUTE doesn't treat it as bool value.  And also
those commands are related to state of document.  Therefore, they should be
return as bool value of STATE_ALL instead.  Then,
nsHTMLDocument::QueryCommandState() returns the state as expected.  Note that
those commands are supported only by Gecko.  So, we don't need to worry about
the compatibility.

Finally, this patch rewrites 2 existing tests to check basic behavior of
resizers and appearance of resizers.

Note that this patch does not add new tests to test inline table editor
since it's difficult to test the behavior with current API.  Perhaps, we
should add an API to nsIHTMLEditor to retrieve each anonymous elements in
another bug since it requires to add wrapping API of SpecialPowers.

MozReview-Commit-ID: 1FhYo5vcV60

--HG--
rename : editor/libeditor/tests/test_objectResizing.html => editor/libeditor/tests/test_resizers_appearance.html
rename : editor/libeditor/tests/test_bug640321.html => editor/libeditor/tests/test_resizers_resizing_elements.html
extra : rebase_source : a707de5a64ef1f8ce974cdf1be093d1b4f61c7bc
2018-04-02 17:26:46 +09:00
Emilio Cobos Álvarez
fffb25b74f Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj
This was done automatically replacing:

  s/mozilla::Move/std::move/
  s/ Move(/ std::move(/
  s/(Move(/(std::move(/

Removing the 'using mozilla::Move;' lines.

And then with a few manual fixups, see the bug for the split series..

MozReview-Commit-ID: Jxze3adipUh
2018-06-01 10:45:27 +02:00
Masayuki Nakano
92a4e5d234 Bug 1452538 - Add telemetry probes HTMLEditors which have shown Gecko build-in editing UIs and count of user interaction with them r=Ehsan
Gecko has some built-in UIs:
* to edit size of objects like <img>, <table> and absolute positioned elements.
* to edit position of absolute positioned elements.
* to add/remove table columns and rows.

Currently, those UIs are available in both designMode editor and contenteditable
editor only on Gecko.  I.e., the other browsers' users cannot modify as such
without web apps implement such function.  So, for compatibility with the
other browsers, we should hide those UIs by default.  On the other hand, if
this is too risky for backward compatibility, we should not do that.

So, before doing that, we should collect actual usage data of object resizers,
inline table editing UI, positioning UI of absolute positioned elements with
telemetry probes.

This patch adds 3 sets of probes for each UI.  One is percentage of showing
each UI in all instantiated HTMLEditor.  The other is number of user interaction
of each UI in HTMLEditors which has shown the UI.

This patch makes all new probes as "opt-out" because they are really important
data since used for deciding whether those UIs are necessary or unnecessary.

MozReview-Commit-ID: B9Y6GTiCPw6

--HG--
extra : rebase_source : 00e49f31712e24cb269ad3aa65c7d13b7cccb3a5
2018-04-09 17:31:23 +09:00
Boris Zbarsky
597b4545d2 Bug 1429903 part 4. Remove nsIDOMEventTarget. r=mccr8
MozReview-Commit-ID: 9XuenUHxfPx
2018-04-20 00:49:30 -04:00
Boris Zbarsky
88937275cc Bug 1449631 part 9. Remove nsIDOMEventTarget::AddEventListener. r=smaug
Also switch the XPCOM-y version of EventTarget::AddEventListner to a
Nullable<bool> for aWantsUntrusted.

The three-arg overload of AddEventListener in ContentFrameMessageManager was
never called, so all the AddEventListener overloads there are not needed.

MozReview-Commit-ID: 4IhqHmPVWzE
2018-04-05 13:42:42 -04:00
Boris Zbarsky
1dce94cf16 Bug 1449631 part 2. Remove nsIDOMEventTarget::RemoveEventListener. r=smaug
We can't have a null content in
ScrollbarActivity::StopListeningForScrollAreaEvents, because only viewport
frames have a null GetContent().

MozReview-Commit-ID: 9iAg0ivVqqG
2018-04-05 13:42:40 -04:00
Makoto Kato
8c5d5f7c30 Bug 1449147 - Clean up more nsIDOMNode usages in editor. r=masayuki
To reduce QI, I would like to replace nsIDOMNode with nsINode.  And some
parameters in *DataTransder.cpp's methods is unused (it uses as nullptr),
so we should remove these parameters.

Also nsIDOMNodeList is unused now, so we should remove this including.

MozReview-Commit-ID: 1QTIkxDazjJ

--HG--
extra : rebase_source : 3961e897fcaa96975facc822821f1e223cab358d
2018-03-27 20:19:35 +09:00
Boris Zbarsky
29d232e53f Bug 1447098 part 1. Rename FromContent on various DOM classes to FromNode. r=mystor
MozReview-Commit-ID: 202nkbmkwfR
2018-03-21 17:39:04 -04:00
Makoto Kato
250a70b6ca Bug 1446861 - Remove more nsIDOMElement usages from editor. r=masayuki
Except table access and XPCOM methods for c-c, tests and etc, we can remove
more nsIDOMElement usages to avoid QI.

MozReview-Commit-ID: HO5kAaZAs6Q

--HG--
extra : rebase_source : 41ede0bace33504ad852dc4e0016ea346cd7bdee
2018-03-19 14:14:45 +09:00
Boris Zbarsky
fba82e4ebc Bug 1432977 part 3. Remove nsIDOMHTMLElement's offsetWidth/Height attributes. r=mccr8
MozReview-Commit-ID: EoSwBkeGj60
2018-01-29 23:40:11 -05:00
Masatoshi Kimura
f576a03e65 Bug 1433100 - Constify the parameter of HTMLEditor::DoInlineTableEditingAction. r=m_kato
--HG--
extra : source : 9042789502045102cf46b19d0382b0d4c0364377
2018-01-25 22:16:32 +09:00
Makoto Kato
70a0912794 Bug 1425547 - Remove unused methods from nsIHTMLInlineTableEditor. r=masayuki
inlineTableEditingEnabled and refreshInlineTableEditingUI are used by
bluegriffon, but other methods aren't used by m-c, c-c and bluegriffon.
So I would like to remove these methods.  Then we can clean up
DoInlineTableEditingAction.

MozReview-Commit-ID: 3R0bJDU5vqv

--HG--
extra : rebase_source : 74c7615613bba65326069929cb53c3ea48f2e9a4
extra : amend_source : a1ac9af3de50daa0cbfd98e2790afa402d9932ef
2018-01-19 16:41:41 +09:00
Makoto Kato
42a03792a6 Bug 1425467 - mInlineEditedCell should be Element. r=masayuki
mInlineEditedCell for inline table editor is still nsIDOMElement.  To avoid QI
and virtual call, we should replace it with Element.

MozReview-Commit-ID: 76yfQJxwm9d

--HG--
extra : rebase_source : e89de17faa20d16a8823e1016b6ba8a6f78993b6
2017-12-15 10:14:54 -06:00
Makoto Kato
012ef9e1c1 Bug 1380292 - Don't turn on object resizer, inline table editor and etc when element isn't into editor. r=masayuki 2017-09-09 10:49:02 -04:00
Makoto Kato
e9bdbc5bb1 Bug 1387945 - Use nsIContent for CreateAnonymousElement. r=masayuki
CreateAnonymousElement still uses nsIDOMNode, but we should use nsIContent for it.

MozReview-Commit-ID: 2xgzlE6NVra

--HG--
extra : rebase_source : c93a9acb230604da391f705b0038e3cf7fbd4f23
2017-08-07 14:09:51 +09:00
Bobby Holley
1bd3bc937c Bug 1386110 - Use a smart pointer to reliably de-register NAC regardless of how it goes away. r=masayuki
MozReview-Commit-ID: HTSu5BjxD8I
2017-08-03 20:26:11 -07:00
Makoto Kato
9b683468d5 Bug 699703 - Need reframe before calling SetSelectionAfterTableEdit. r=masayuki
HTMLEditor::TabInTable inserts row element, then it selects a cell.  But when enabling lazy frame construction for editable node, it selects invalid cell and table.

Because HTMLEditor::SetSelectionAfterTableEdit doesn't select cell correctly on InsertTableRow().

HTMLEditor::SetSelectionAfterTableEdit uses HTMLEditor::GetCellAt, so it depends on frame.  So we need flush frame before calling it.

Also, a comment of HTMLEditor::InsertTableRow is invalid now because we don't use nsresult version of CreateElementWithDefualts.

MozReview-Commit-ID: 698TvmMZgwB

--HG--
extra : rebase_source : 95df12f1f870a2c68d02b24b8758dfe6d381a416
2017-07-14 15:48:40 +09:00
Cameron McCormack
fdb731a4d4 Bug 1377256 - Part 1: Don't pass parent explicitly into HTMLEditor::DeleteRefToAnonymousNode. r=m_kato
MozReview-Commit-ID: HUySaoG07jg

--HG--
extra : rebase_source : adb3a65387eb209073d95211fa185bcab2791b0f
2017-07-04 17:01:32 +08:00
Makoto Kato
ef514b53ec Bug 1313986 - Part 4. Use Element instead of nsIDOMElement for resizer. r=masayuki
Resizer and etc attributes on table editor still use nsIDOMElement.  Converting to Element makes both implementation and the callers simpler.

MozReview-Commit-ID: TTFSvqn5GE

--HG--
extra : rebase_source : 705576c4eb0fe5f8f566f3415a8a72842c919edd
2016-11-24 15:58:01 +09:00
Masayuki Nakano
2773c4d0ef Bug 1310618 Replace nsresult variables |res| with |rv| under editor/ r=Ehsan
In our coding rules, variable names of nsresult should be rv.  Indeed, when you see |rv| in the code, you must assume that its type if nsresult.

However, a lot of code under editor/ uses |res| for the variables of nsresult.  Let's replace |res| with |rv|.

And this patch improves following points:

1. When |rv| is set in both |if| and |else| block and they are check outside of them, this moves the check into each |if| and |else| block because even if the failure is notified with warning, you cannot see which case was performed and failed.  This change makes it clear.

2. When |return rv;| returns non-error code because |rv| is checked with NS_ENSURE_SUCCESS() immediately before, setting replacing it with |return NS_OK;| is clearer.

3. Move declaration of |nsresult rv| into smaller scope as far as possible.  This prevents setting rv to unexpected value and easier to check its value at reading the code.

MozReview-Commit-ID: 9MAqj7sFey3

--HG--
extra : rebase_source : 0fd316b851ea616b3a95d8c1afc111ff55e11993
2016-10-19 18:09:33 +09:00
Masayuki Nakano
9b6e26f0bb Bug 1260651 part.56 Rename nsHTMLEditor to mozilla::HTMLEditor and related stuff r=mccr8
This patch renames classes/structs as:

nsHTMLEditor -> mozilla::HTMLEditor
nsHTMLEditor::BlobReader -> mozilla::HTMLEditor::BlobReader
SetSelectionAfterTableEdit -> mozilla::AutoSelectionSetterAfterTableEdit

nsHTMLEditor.h -> HTMLEditor.h (exposed as mozilla/editor/HTMLEditor.h)
nsHTMLAbsPosition.cpp -> HTMLAbsPositionEditor.cpp
nsHTMLAnonymousUtils.cpp -> HTMLAnonymousNodeEditor.cpp
nsHTMLDataTransfer.cpp -> HTMLEditorDataTransfer.cpp
nsHTMLEditorStyle.cpp -> HTMLStyleEditor.cpp
nsHTMLInlineTableEditor.cpp -> HTMLInlineTableEditor.cpp
nsHTMLObjectResizer.cpp -> HTMLEditorObjectResizer.cpp
nsTableEditor.cpp -> HTMLTableEditor.cpp

These new file names are clearer names which related to HTMLEditor than old names.

MozReview-Commit-ID: DTWaoFvy0DF

--HG--
rename : editor/libeditor/nsHTMLAbsPosition.cpp => editor/libeditor/HTMLAbsPositionEditor.cpp
rename : editor/libeditor/nsHTMLAnonymousUtils.cpp => editor/libeditor/HTMLAnonymousNodeEditor.cpp
rename : editor/libeditor/nsHTMLEditor.cpp => editor/libeditor/HTMLEditor.cpp
rename : editor/libeditor/nsHTMLEditor.h => editor/libeditor/HTMLEditor.h
rename : editor/libeditor/nsHTMLDataTransfer.cpp => editor/libeditor/HTMLEditorDataTransfer.cpp
rename : editor/libeditor/nsHTMLObjectResizer.cpp => editor/libeditor/HTMLEditorObjectResizer.cpp
rename : editor/libeditor/nsHTMLInlineTableEditor.cpp => editor/libeditor/HTMLInlineTableEditor.cpp
rename : editor/libeditor/nsHTMLEditorStyle.cpp => editor/libeditor/HTMLStyleEditor.cpp
rename : editor/libeditor/nsTableEditor.cpp => editor/libeditor/HTMLTableEditor.cpp
2016-07-09 11:42:33 +09:00