Commit Graph

9003 Commits

Author SHA1 Message Date
Masayuki Nakano
d97102c926 Bug 1465702 - part 7: Make protected/private methods of EditorBase/TextEditor/HTMLEditor use SelectionRefPtr() instead of GetSelection() r=m_kato
Now, any protected/private methods of editor classes can refer
SelectionRefPtr() safely.  So, we can cut the cost of calling GetSelection()
only once per edit action handling.

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

--HG--
extra : moz-landing-system : lando
2018-10-30 10:04:08 +00:00
Masayuki Nakano
53578eb0db Bug 1465702 - part 6: Remove unnecessary Selection argument from TextEditRules and HTMLEditRules and rename/reimplement TextEditRules::SelectionRef() as TextEditRules::SelectionRefPtr() r=m_kato
When each method of TextEditRules and HTMLEditRules should be called only by
EditorBase/TextEditor/HTMLEditor while the editor instance has
AutoEditActionDataSetter instance.  Therefore, we can get rid of all
pointers/references of Selection from each method's argument.

Additionally, this reimplements TextEditRules::SelectionRef() with
EditorBase::SelectionRefPtr() and make it return |const RefPtr<Selection>&|
rather than |Selection&| since RefPtr reference is required when we call
methods which are marked as MOZ_CAN_RUN_SCRIPT.

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

--HG--
extra : moz-landing-system : lando
2018-10-30 10:02:58 +00:00
Masayuki Nakano
f91716e775 Bug 1465702 - part 5: Remove unnecessary Selection argument from editor module r=m_kato
EditorBase::SelectionRefPtr() is now safe to use in editor and really fast to
retrieve Selection than EditorBase::GetSelection().  Therefore, we can get rid of
all Selection pointer/reference argument of each method which always take
normal Selection.

Note that this changes nsIHTMLEditor.checkSelectionStateForAnonymousButtons()
because its argument is only Selection.  So, BlueGriffon should work even
though it calls the method with nsIEditor.selection.

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

--HG--
extra : moz-landing-system : lando
2018-10-30 10:01:38 +00: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
062a07e7b0 Bug 1465702 - part 3: Make public methods of TextEditor create AutoEditActionDataSetter if necessary r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D10007

--HG--
extra : moz-landing-system : lando
2018-10-30 09:59:33 +00:00
Masayuki Nakano
779965a889 Bug 1465702 - part 2: Make public methods of EditorBase create AutoEditActionDataSetter if necessary r=m_kato
This patch makes public methods of EditorBase create AutoEditActionDataSetter
as far as possible.  However, does not do so for some public methods if they are
not necessary to create it.

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

--HG--
extra : moz-landing-system : lando
2018-10-30 09:57:52 +00:00
Masayuki Nakano
7f8df77fb6 Bug 1465702 - part 1: Add EditorBase::AutoEditActionDataSetter to store edit action and grab Selection instance while editor classes handle an edit action r=m_kato
Like TextEditRules, EditorBase should have a stack class which cache necessary
objects and current handling edit action.  The edit action will be necessary
when we implement InputEvent.inputType.

Different from TextEditRules, this adds |const RefPtr<Selection>&| instead
of |Selection&|.  The reason is, when I add MOZ_CAN_RUN_SCRIPT to some methods,
it's not allowed like this:

> foo->CanRunScriptMethod(SelectionRef());

I'll update TextEditRules for consistency in the following patches.

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

--HG--
extra : moz-landing-system : lando
2018-10-30 09:56:41 +00:00
Makoto Kato
0ca1f40c1b Bug 1485890 - Remove dumpContentTree, debugDumpContent and debugUnitTests from nsIEditor. r=masayuki
Since bug 1491173 is landed, there is no users of dumpContentTree,
debugDumpContent and debugUnitTests.  So Let's remove these methods from
nsIEditor.

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

--HG--
extra : moz-landing-system : lando
2018-10-29 07:23:49 +00:00
Masayuki Nakano
9507d36bda Bug 1501259 - HTMLEditor::InsertAsPlaintextQuotation() shouldn't refer |newNode| after calling its |forget()| r=m_kato
Regression of bug 1476897, HTMLEditor::InsertAsPlaintextQuotation() refers
|newNode| which is new created <span> element by the method at collapsing
Selection.  However, it's already been moved to its out param.  Therefore,
after the fix of bug 1476897, it won't collapse Selection.  This patch
moves the code moving |newNode| to the out param after collapsing Selection.

Additionally, this makes HTMLEditor::InsertAsCitedQuotationInternal() use
same style code around collapsing Selection since it's also tested by the
new test of nsIEditorMailSupport.insertAsCitedQuotation().

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

--HG--
extra : moz-landing-system : lando
2018-10-29 04:13:50 +00:00
Cristina Coroiu
aea73c87db Bug 1446282 - Disable browser_bug629172.js on debug mac and win10x64 for frequent failures. r=jmaher
--HG--
extra : histedit_source : da7342ce510c03304865c910085c32c841430a19
2018-10-25 20:25:00 +03:00
Masayuki Nakano
51565faee9 Bug 1501260 - Make HTMLEditRules::DocumentModifiedWorker() create bogus node via editor instance r=m_kato
HTMLEditRules::DocumentModifiedWorker() may be called asynchronously via
AddScriptRunnder. Therefore, this may not be in the stack while editor handles
an edit action. Then, HTMLEditRules cannot access edit action data which will
be put on the stack after fixing bug 1465702. So, it should do it after once
calling a method of editor instance (and editor instance should call back
proper HTMLEditRules method).

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

--HG--
extra : moz-landing-system : lando
2018-10-25 05:55:04 +00:00
Masayuki Nakano
ede88b49c1 Bug 1501180 - Make TextEditRules::Notify() hide input characters via editor instance r=m_kato
TextEditRules::Notify() is callback of the timer.  Therefore, this won't be
in the stack while editor handles an edit action.  Then, TextEditRules
cannot access edit action data which will be put on the stack after fixing
bug 1465702.  So, it should do it after once calling a method of editor
instance (and editor instance should call back proper TextEditRules method).

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

--HG--
extra : moz-landing-system : lando
2018-10-25 03:35:26 +00:00
Masayuki Nakano
446538a446 Bug 1501177 - Create HTMLEditor::InsertAsCitedQuotationInternal() for internal use of nsIEditorMailSupport::InsertAsCitedQuotation() r=m_kato
HTMLEditor::InsertAsCitedQuotation() is an XPCOM method, so, it shouldn't be
used for internal use.  Instead, there should be non-virtual method and
InsertAsCitedQuotation() should use it.

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

--HG--
extra : moz-landing-system : lando
2018-10-25 04:49:13 +00:00
Masayuki Nakano
cb95d44ffc Bug 1500862 - part 3: Change all stack base helper classes which access protected members of EditorBase to nested classes of EditorBase r=m_kato
AutoTransactionBatch, AutoPlaceholderBatch, AutoSelectionRestorer,
AutoTopLevelEditSubActionNotifier, AutoTransactionsConserveSelection and
AutoUpdateViewBatch access protected members of EditorBase.  The access
scope management assume that they are used only by EditorBase or its
subclasses or TextEditRules or its inherited class (i.e., HTMLEditRules).

For guaranteeing this at build-time, we should change them to nested classes
of EditorBase.  Then, EditorBase and its subclasses and friends can use them.

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

--HG--
extra : moz-landing-system : lando
2018-10-24 09:42:06 +00:00
Masayuki Nakano
87499ae61c Bug 1500862 - part 2: Create AutoTransactionBatchExternal class which calls XPCOM methods instead of non-virtual internal methods r=m_kato
Unfortunately, TextServicesDocument::InsertText() is too complicated to
do it with both editor class and TextServicesDocument separately.
Therefore, this patch adds AutoTransactionBatchExternal class which is
almost same as AutoTransactionBatch but uses XPCOM methods to begin/end
transaction.  This change helps editor to manage whether it starts to
handle new edit action or not when BeginTransaction() is called explicitly.

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

--HG--
extra : moz-landing-system : lando
2018-10-24 05:18:40 +00:00
Masayuki Nakano
25b5b80801 Bug 1500862 - part 1: Make HTMLEditor::SetInlineProperty() remove exclusive style automatically r=m_kato
StyleUpdatingCommand::ToggleState() removes exclusive style when it sets
superscript style or subscript style.  However, it accesses protected
members of EditorBase via AutoTransactionBatch even though it's outside
of editor classes.

This patch moves the removing exclusive style code from the method to
HTMLEditor::SetInlineProperty() and rename it "AsAction".

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

--HG--
extra : moz-landing-system : lando
2018-10-24 04:17:42 +00:00
Julian Descottes
52b85a20e2 Bug 1499096 - Update wrong usage of ok() with todo_is();r=Standard8
Depends on D8739.
This changeset updates calls to ok() that were most likely intended
for is(), but are not working as is.

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

--HG--
extra : moz-landing-system : lando
2018-10-23 07:13:02 +00:00
Julian Descottes
2fcd6cb020 Bug 1499096 - Update tests using ok() to is();r=Standard8
This changeset updates all the test that were wrongly using ok() and wanted to
use is() AND for which the assert is still passing without any modification
required.

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

--HG--
extra : moz-landing-system : lando
2018-10-23 07:12:23 +00:00
Masayuki Nakano
cda6a9ac80 Bug 1484126 - part 21: Rewrite some loops in HTMLTableEditor.cpp with CellData::NextColumnIndex() or CellData::NextRowIndex() r=m_kato
A lot of loops in HTMLTableEditor.cpp scans cells along column-axis or
row-axis.  In those cases, they need to skip columns/rows which are spanned
from prior column/row.  So, we can rewrite them with CellData::NextColumnIndex()
or CellData::NextRowColumn().

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

--HG--
extra : moz-landing-system : lando
2018-10-16 01:10:44 +00:00
Masayuki Nakano
deccc4b041 Bug 1484126 - part 20: Replace |CellData::mFirst.mColumn + CellData::mEffectiveColSpan| with CellData::NextColumnIndex() r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D8357

--HG--
extra : moz-landing-system : lando
2018-10-15 11:37:38 +00:00
Masayuki Nakano
4b04d7a2fa Bug 1484126 - part 19: Replace |CellData::mCurrent.mColumn + CellData::NumberOfFollowingColumns()| with CellData::LastColumnIndex() r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D8356

--HG--
extra : moz-landing-system : lando
2018-10-15 11:35:33 +00:00
Masayuki Nakano
1e41589a76 Bug 1484126 - part 18: Make HTMLEditor::InsertTableCellsWithTransaction() use CellData::NextColumnIndex() instead of |CellData::mCurrent::mColumn + CellData::mColSpan| r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D8355

--HG--
extra : moz-landing-system : lando
2018-10-15 11:35:10 +00:00
Masayuki Nakano
fa7eb4fc9f Bug 1484126 - part 17: Make all CellData users refer CellData::mIsSelected directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D8354

--HG--
extra : moz-landing-system : lando
2018-10-15 11:34:40 +00:00
Masayuki Nakano
cad6cdb5d5 Bug 1484126 - part 16: Replace |CellData::mEffectiveColSpan - 1| with CellData::NumberOfFollowingColumns() r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D8353

--HG--
extra : moz-landing-system : lando
2018-10-15 11:34:06 +00:00
Masayuki Nakano
140330e8d3 Bug 1484126 - part 15: Make all CellData users refer CellData::mEffectiveColspan directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D8352

--HG--
extra : moz-landing-system : lando
2018-10-15 11:33:33 +00:00
Masayuki Nakano
ff86516630 Bug 1484126 - part 14: Replace |CellData::mEffectiveRowSpan - 1| with CellData::NumberOfFollowingRows() r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D8351

--HG--
extra : moz-landing-system : lando
2018-10-15 11:15:15 +00:00
Masayuki Nakano
5c8e2f568e Bug 1484126 - part 13: Make all CellData users refer CellData::mEffectiveRowSpan directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D8350

--HG--
extra : moz-landing-system : lando
2018-10-15 10:44:08 +00:00
Masayuki Nakano
d4155efc9f Bug 1484126 - part 12: Make all CellData users refer CellData::mColSpan directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D8349

--HG--
extra : moz-landing-system : lando
2018-10-15 08:22:29 +00:00
Masayuki Nakano
e782a5f973 Bug 1484126 - part 11: Make all CellData users refer CellData.mRowSpan directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D8348

--HG--
extra : moz-landing-system : lando
2018-10-15 08:14:18 +00:00
Masayuki Nakano
5b5f57c621 Bug 1484126 - part 10: Replace all comparisons of CellData::mFirst.mColumn and CellData::mCurrent.mColumn with CellData::IsSpannedFromOtherColumn() or CellData::IsSpannedFromOtherRowOrColumn() r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D8347

--HG--
extra : moz-landing-system : lando
2018-10-15 08:06:14 +00:00
Masayuki Nakano
632c38026b Bug 1484126 - part 9: Make all CellData users refer CellData::mFirst.mColumn directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D8346

--HG--
extra : moz-landing-system : lando
2018-10-15 07:37:57 +00:00
Masayuki Nakano
44e8323821 Bug 1484126 - part 8: Replace |CellData::mCurrent.mRow - CellData::mFirst.mRow| with CellData::NumberOfPrecedingRows() r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D8345

--HG--
extra : moz-landing-system : lando
2018-10-15 05:06:13 +00:00
Masayuki Nakano
9b2f3a5b31 Bug 1484126 - part 7: Replace all comparisons of CellData::mFirst.mRow and CellData::mCurrent.mRow with CellData::IsSpannedFromOtherRow() r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D8344

--HG--
extra : moz-landing-system : lando
2018-10-15 04:21:34 +00:00
Masayuki Nakano
cf118e4bf3 Bug 1484126 - part 6: Make all CellData users refer CellData::mFirst.mRow directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D8343

--HG--
extra : moz-landing-system : lando
2018-10-15 04:10:32 +00:00
Masayuki Nakano
32323fbf7f Bug 1484126 - part 5: Make all CellData users refer CellData::mElement directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D8342

--HG--
extra : moz-landing-system : lando
2018-10-15 04:06:32 +00:00
Masayuki Nakano
57ed02b758 Bug 1484126 - part 4: Make all CellData users use CellData::mCurrent.mColumn r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D8341

--HG--
extra : moz-landing-system : lando
2018-10-15 02:01:09 +00:00
Masayuki Nakano
5c59a980fc Bug 1484126 - part 3: Make all CellData users use CellData::mCurrent.mRow r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D8340

--HG--
extra : moz-landing-system : lando
2018-10-15 01:43:54 +00:00
Masayuki Nakano
2bf1b6ac55 Bug 1484126 - part 2: Make all nsITableEditor::GetCellDataAt() use CellData r=m_kato
This patch makes all nsITableEditor::GetCellDataAt() use CellData, and if
each caller checks the result of GetCellDataAt() with NS_FAILED(), this
replaces it with CellData::FailedOrNotFound() since GetCellDataAt() returns
error even when it does not find a cell element.  Finally, copies each
CellData member to the variable which received corresponding value from
GetCellDataAt() for making this change safe.  Note that for easier to review,
the copying blocks have odd indent.  Those variables will be removed or
corrected the indent by the following patches.

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

--HG--
extra : moz-landing-system : lando
2018-10-15 01:43:11 +00:00
Masayuki Nakano
08c4b07fc9 Bug 1484126 - part 1: Create CellData struct which implements nsITableEditor::GetCellDataAt() r=m_kato
nsITableEditor::GetCellDataAt() is an XPCOM method but used internally a lot.
Additionally, it scatters a lot of variables (including unused) since it takes
a lot of out arguments to return.  Therefore, this should be implemented as
struct and users should refer each member as result.

This does not replaces the callers yet since it's too risky if the caller is
not tested by automated test.  Following patches will replace the method call
and each variable step by step.

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

--HG--
extra : moz-landing-system : lando
2018-10-12 13:40:25 +00:00
Masayuki Nakano
e7eda01d23 Bug 1484126 - part 0: Add automated tests for nsITableEditor.getCellDataAt() r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D8337

--HG--
extra : moz-landing-system : lando
2018-10-12 04:09:19 +00:00
Masayuki Nakano
1c08e312af Bug 1497815 - Rename EditorEventListener::EnsureCommitCompoisition() to EditorEventListener::EnsureCommitComposition() r=m_kato
Just fixing typo of the method name.

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

--HG--
extra : moz-landing-system : lando
2018-10-11 09:12:15 +00:00
Masayuki Nakano
5c47cf2ccf Bug 1461708 - part 8: Make EventStateManager handle middle click paste as a default action of mouseup event r=smaug
This patch makes EventStateManager handle middle click paste as a default
action.

Unfortunately, we cannot remove the call of HandleMiddleClickPaste() in
EditorEventListener because it's important to consume middle click event
before any elements in the editor.  For example, if clicked HTMLEditor has
non-editable <a href> element, middle click event needs to be handled by the
editor rather than contentAreaUtils which handles click events of <a href>
elements.  The cause of this kind of issues is, any click event handlers
which handle non-primary button events still listen to "click" events.
Therefore, this patch makes HandleMiddleClickPaste() do nothing if the mouseup
event is fired on an editor.

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

--HG--
extra : moz-landing-system : lando
2018-10-10 12:06:17 +00:00
Masayuki Nakano
9b40433ef6 Bug 1461708 - part 7: Make EventStateManager::HandleMiddleClickPaste() dispatch ePaste event by itself r=smaug
This is preparation of the last patch.  Even if no editor is clicked with
middle button, we need to do:
- collapse Selection at the clicked point.
- dispatch "paste" event.

Therefore, HandleMiddleClickPaste() should dispatch ePaste event by itself
and each editor methods should have a bool argument which the caller wants
ePaste event automatically.

Note that Chromium dispatches "paste" event and pastes clipboard content
into clicked editor even if preceding "auxclick" event is consumed.
However, our traditional behavior is not dispatching "paste" event nor
pasting clipboard content.  Unless Chromium developer keeps their odd
behavior, we should keep our traditional behavior since our behavior is
conforming to DOM event model.

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

--HG--
extra : moz-landing-system : lando
2018-10-10 12:05:39 +00:00
Masayuki Nakano
d581c69689 Bug 1461708 - part 6: Make EditorEventListener::MouseClick() use WidgetMouseEvent instead of dom::MouseEvent r=m_kato
The event argument of only EditorEventListener::MouseClick() can be replaced
with WidgetMouseEvent simply.  So, for avoiding unnecessary RefPtr in
EditorEventListener::HandleEvent(), we should fix this now.

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

--HG--
extra : moz-landing-system : lando
2018-10-10 12:05:21 +00:00
Masayuki Nakano
fd4e78f2a1 Bug 1461708 - part 5: Move EditorEventListener::HandleMiddleClickPaste() to EventStateManager r=smaug
EventStateManager needs to handle middle click paste without editor.
Therefore, the handler should be in EventStateManager.

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

--HG--
extra : moz-landing-system : lando
2018-10-10 12:04:17 +00:00
Masayuki Nakano
d472d6f312 Bug 1461708 - part 4: Move implementation of UIEvent::GetRangeParent() and UIEvent::RangeOffset() to nsLayoutUtils r=smaug
We need to move EditorEventListener::HandleMiddleClickPaste() into
EventStateManager to handle middle click paste after all click events are
dispatched.  This is preparation of the change.

HandleMiddleClickPaste() uses UIEvent::GetRangeParent() and
UIEvent::RangeOffset() to collapse Selection at clicked point.  However,
EventStateManager cannot access them since EventStateManager can handle it
with WidgetMouseEvent.  Fortunately, only WidgetMouseEvent is necessary for
implementing them.  Therefore, we can move the implementation into
nsLayoutUtils and merge them.

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

--HG--
extra : moz-landing-system : lando
2018-10-10 12:03:34 +00:00
Dão Gottwald
b1186958ff Bug 1473927 - Load textbox.css and numberbox.css as document stylesheets. r=paolo 2018-10-09 10:22:15 +02:00
Makoto Kato
e851a155cb Bug 1487301 - Part 2. Set ancestor limitter if no set yet. r=masayuki
The ancestor limiter is set by focus event handler of editor. But window that
is run script has no focus, this event isn't fired by addRange etc.

Some execCommand's commands such as 'forwardDelete' uses WillDeleteSelection
then selection for deletion is set by selection controller (in
TextEditor::ExtendSelectionForDelete). So, due to no ancestor limiter, caret
(and any for delete commands such as CharacterExtendForDelete) can move to out
of editor's root.

So we should set ancestor limiter if nothing. If focus event is received by
user interaction etc, limiter will be set again.

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

--HG--
extra : rebase_source : 240c3bc09b37d46d1ce3245bcca55cafc59454c5
2018-09-20 19:03:24 +09:00
Makoto Kato
eed71e1db2 Bug 1487301 - Part 1. FindSelectionRoot should return Element. r=masayuki
FindSelectionRoot isn't const method and returns already_AddRefed<nsIContent>.
But this method doesn't modify any members and nodes, so we can change to const
method

Also, this method already returns Element, so it shouldn't return nsIContent.

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

--HG--
extra : rebase_source : d4a5dbe96dfc0a71b39f3d5c6d1a4c7ce85f4fa9
2018-09-20 18:53:35 +09:00
arthur.iakab
326255bed6 Backed out changeset 82b600b76a38 (bug 1473927)for marionette failures on test_element_state_chrome.py CLOSED TREE 2018-10-08 23:34:50 +03:00