Commit Graph

31 Commits

Author SHA1 Message Date
Masayuki Nakano
05db7b82d5 Bug 1574852 - part 67-5: Rewrite HTMLEditRules::HandleDeleteNonCollapsedSelection() with EditorDOMPoint r=m_kato
Before splitting the method, we should make it use `EditorDOMPoint` to
treat selection edges.

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

--HG--
extra : moz-landing-system : lando
2019-09-06 00:59:32 +00:00
Masayuki Nakano
d696ee098d Bug 1572685 - part 7: Move HTMLEditRules::mRangeItem to TopLevelEditSubActionData r=m_kato
For avoiding allocation cost of `RangeItem`, it should be stored by `HTMLEditor`
and reused by all `TopLevelEditSubActionData` instances for the editor instance.

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

--HG--
extra : moz-landing-system : lando
2019-08-20 01:51:19 +00:00
Sylvestre Ledru
7f60810d86 Bug 1519636 - Reformat recent changes to the Google coding style r=Ehsan
# ignore-this-changeset

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

--HG--
extra : moz-landing-system : lando
2019-04-12 13:14:25 +00:00
Masayuki Nakano
a50a0700d4 Bug 1530649 - Improve composition string handling which ends with whitespaces r=m_kato
If insertion string ends with ASCII whitespace and there is no following
content in the block, `HTMLEditRules::AdjustWhitespaces()` needs to insert
`<br>` element.  It's called only by `HTMLEditRules::AfterEditInner()` and
that does only simple things with `WSRunObject`.  Therefore, this moves the
code into `AfterEditInner()`.

For making it adjust the whitespaces, `HTMLEditRules::WillInsertText()` needs
to notify `AfterEditInner()` of dirty range with `mDocChangeRange`.  Therefore,
this patch makes it set `mDocChangeRange` manually after inserting composition
string.

On the other hand, there is another bug.  `WSRunObject` was designed to treat
only inserting text for `WSRunObject::InsertText()`.  I.e., not designed to
treat replacing existing composition string with new string.  Therefore,
`WSRunObject::InsertText()` adjusts whitespaces only around start of
composition string.  Therefore, if composition string ends with an ASCII
whitespace, it's not replaced with NBSP and that causes:
- failing `WSRunObject::AdjustWhitespaces()` inserts `<br>` element at
  `AfterEditInner()` of committing composition.
- then, next composition's first `WSRunObject::InsertText()` removes the
  last whitespace due to not followed by `<br>` nor any other content.
Therefore, this patch makes `WSRunObject` takes 2 DOM points to be able to
treat replaced range.

In strictly speaking, the latter change require more changes and tests for
supporting replacement with any other methods.  However, it's risky and out
of scope of this bug.

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

--HG--
extra : moz-landing-system : lando
2019-04-09 05:28:38 +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
b376e84323 Bug 1497746 - part 4: Move EditorBase::mRangeUpdater to AutoEditActionDataSetter r=m_kato
Similar to EditorBase::mSavedSel, we can move EditorBase::mRangeUpdater too
because of it's referred only when there is AutoEditActionDataSetter instance
so that it also does not need to be in the cycle collection.

And now, it can be marked as MOZ_STACK_CLASS and remove cycle collection
support.

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

--HG--
extra : moz-landing-system : lando
2018-11-26 06:31:56 +00:00
Makoto Kato
414c3e8695 Bug 358033 - Part 1. Restore direction of Selection. r=masayuki
SelectionState doesn't save and restore current selection's direction.  So the
direction of selection is always default after undoing.

So we should restore direction of selection.

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

--HG--
extra : moz-landing-system : lando
2018-07-23 02:44:42 +00:00
Masayuki Nakano
2d04b175d7 Bug 1451672 - part 16: Rename EditorBase::MoveNode() to EditorBase::MoveNodeWithTransaction() and create EditorBase::MoveNodeToEndWithTransaction() r=m_kato
This patch renames EditorBase::MoveNode() to
EditorBase::MoveNodeWithTransaction() and redesign its parameters including
replacing a set of container node and offset in it to EditorDOMPointBase.
However, it takes magic number -1 as meaning end of the container.
Therefore, this patch adds MoveNodeToEndWithTransaction() for keeping the
callers simple.

MozReview-Commit-ID: BeTq5c7GQNN

--HG--
extra : rebase_source : b3a617a5a1a493cb0fcbefe2d9a9708b0257b1a8
2018-04-12 23:58:52 +09: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
Masayuki Nakano
537b829474 Bug 1447213 - Change editor methods which take |const EditorRawDOMPoint&| but called with EditorDOMPoint.AsRaw() to template methods r=m_kato
A lot of methods take |const EditorRawDOMPoint&| as their argument.  However,
some of them are called with EditorDOMPoint::AsRaw(). This is not good for
performance because:
1. Needs to create temporary instance of EditorRawDOMPoint.
2. EditorRawDOMPoint::AsRaw() may be used by simple mistake.
3. Such methods may call EditorRawDOMPoint::Offset(), however, it's not copied
   to the original EditorDOMPoint instance.  So, callers may need to compute
   offset again.

So, such methods should be changed to template methods if they are not virtual
method and AsRaw() should be gotten rid of for prevent it looking not expensive.

MozReview-Commit-ID: DAqqW4a2EMS

--HG--
extra : rebase_source : 120b920477fe6e7231271411a00994325acdb842
2018-03-20 14:05:47 +09:00
Boris Zbarsky
c4a9eb60ff Bug 1446533 part 10. Remove remaining nsIDOMCharacterData uses in editor. r=mystor
MozReview-Commit-ID: CfZNQRiDs43
2018-03-19 15:45:55 -04:00
Makoto Kato
d438423b79 Bug 1425091 - Part 3. SelAdjCreateNode and SelAdjInsertNode should check whether valid point. r=masayuki
This crashtest case hits assertion in SelAdjInsertNode due to invalid offset
point. So we check whether this is valid.

Also, SelAdjCreateNode and SelAdjInsertNode should use EditorRawDOMPoint to avoid offset calculation and check valid offset.

MozReview-Commit-ID: A1kaKEzc36e

--HG--
extra : rebase_source : c46843fdd6e9e18f49b9cedb008cda6cf3436811
2017-12-15 10:49:53 -06:00
Masayuki Nakano
dacd109e2f Bug 1423835 - part 2: Rename EditorDOMPointBase::Container() to EditorDOMPointBase::GetContainer() and add some useful methods to access its container r=m_kato
EditorDOMPointBase::Container() may return nullptr.  So, it should be renamed
to GetContainer().

Then, the method name becomes longer and a lot of callers access the result
directly.  So, there should be following methods to make the callers shorter:

- GetContainerAsContent() to return the container as nsIContent*.
- GetContainerAsElement() to return the container as dom::Element*.
- GetContainerAsText() to return the container as dom::Text.
- GetContainerAsDOMNode() to return the container as nsIDOMNode*.
- CanContainerHaveChildren() to check if the container can have child nodes.
- IsInDataNode() to check if the point is in a data node including text node.
- IsInTextNode() to check if the point is in a text node.
- IsContainerHTMLElement() to check if the container is specific HTML element.
- IsContainerAnyOfHTMLElements() to check if the container is one of the
  specified HTML elements.

MozReview-Commit-ID: LkN2WBbCPj0

--HG--
extra : rebase_source : 9da1e70d4c74f7ad573e244cf6c7b21a0c7b4410
2017-12-07 18:45:52 +09:00
Masayuki Nakano
070ede0cf4 Bug 1413181 - part 3: EditorBase::CreateTxnForSplitNode() and EditorBase::SplitNode() should take EditorRawDOMPoint to specify the start of right node r=m_kato
EditorBase::CreateTxnForSplitNode() and EditorBase::SplitNode() takes a set of
container and offset in it for specifying a point to split.

Instead, they should take EditorRawDOMPoint for specifying start of right node.

MozReview-Commit-ID: 5VwS8oudzIT

--HG--
extra : rebase_source : 727948e5cf95f0713019f57ae9a007b85569fa56
2017-11-12 11:30:30 +09:00
Masayuki Nakano
365f79c262 Bug 1414713 - EditorUtils::IsDescendantOf() should take EditorDOMPoint and EditorRawDOMPoint as out param r=catalinb,m_kato
EditorUtils::IsDescendantOf() current takes a pointer to offset or a pointer to
child content if the caller needs to know the child of the most ancestor node.

However, some callers should get a child as EditorDOMPoint or EditorRawDOMPoint.
Then, they can be used for some editor methods which need to take child node
for performance optimization.

This patch makes EditorUtils::IsDescendantOf() as only two overloads.  One takes
pointer to EditorRawDOMPoint as optional out argument.  The other takes pointer
to EditorDOMPoint as an out param.

Additionally, this creates new constructor of AutoTrackDOMPoint for making it
can treat EditorDOMPoint directly.

MozReview-Commit-ID: IsAGTUvKI19

--HG--
extra : rebase_source : 97469a21b974c6a1dd515ab472bbc4a88c1899c8
2017-11-06 17:01:33 +09:00
Olli Pettay
aeabc0c261 Bug 1392564 - Use nursery purple buffer for nsRange and RangeItem, r=mccr8
--HG--
extra : rebase_source : 650d101bb0cec4ed21b35945ae1185aca577b120
2017-08-22 17:47:00 +03:00
Ehsan Akhgari
43a6f66350 Backout bug 1386480 for causing bug 1391410 2017-08-17 17:16:27 -04:00
Ehsan Akhgari
b0411401ec Bug 1386480 - Make RangeItem a non-cycle-collectable type; r=masayuki 2017-08-14 12:14:34 -04:00
Masayuki Nakano
dd7bcc05ab Bug 1377989 - part6: Rename mEndParent of nsRange and similar members of similar objects to mEndContainer r=smaug
MozReview-Commit-ID: KOcajaTv5ga

--HG--
extra : rebase_source : c1fac0fd8aebf02d0623eb291d914b4ac1fd7065
2017-07-11 22:57:55 +09:00
Masayuki Nakano
4ff0c2334b Bug 1377989 - part5: Rename mStartParent of nsRange and similar members of similar objects to mStartContainer r=smaug
MozReview-Commit-ID: 5QJahMKnKEJ

--HG--
extra : rebase_source : 0b4aee62fcd70574b3dc44e05392b2a8d6ff6ee5
2017-07-11 22:46:11 +09:00
Makoto Kato
945e02484a Bug 1372859 - Remove SelAdj* method of nsIDOM* version from RangeUpdater. r=masayuki
Since RangeUpdater::SelAdj* method of nsIDOM* version requires additional QI and we don't use nsIDOM* as parameter, it is unnecessary to keep it.

MozReview-Commit-ID: 4XyYBG6Qrhl

--HG--
extra : rebase_source : 5fd830a2ffeff944471f026ded704a46ac4dd3d5
2017-06-14 19:34:38 +09:00
Ehsan Akhgari
5a1d782b90 Bug 1371277 - Use reserved space for one item in SelectionState::mArray; r=masayuki
This avoids dynamic allocations in SelectionState::SaveSelection() in the common
case for the selections that only have a maximum of one range stored in them.
2017-06-09 01:17:42 -04:00
Masayuki Nakano
94713accb3 Bug 1260651 part.49 Rename nsTextEditRules to mozilla::TextEditRules (and also their file names) r=mccr8
MozReview-Commit-ID: DzNeLcT1r1e

--HG--
rename : editor/libeditor/nsTextEditRules.cpp => editor/libeditor/TextEditRules.cpp
rename : editor/libeditor/nsTextEditRules.h => editor/libeditor/TextEditRules.h
rename : editor/libeditor/nsTextEditRulesBidi.cpp => editor/libeditor/TextEditRulesBidi.cpp
2016-07-09 11:34:41 +09:00
Masayuki Nakano
0306bbfb8d Bug 1260651 part.44 Rename nsAutoMoveNodeSelNotify to mozilla::AutoMoveNodeSelNotify r=mccr8
MozReview-Commit-ID: Bahm520giss
2016-06-24 15:24:44 +09:00
Masayuki Nakano
b5223c28f5 Bug 1260651 part.43 Rename nsAutoInsertContainerSelNotify to mozilla::AutoInsertContainerSelNotify r=mccr8
MozReview-Commit-ID: GEfM8GJO3xd
2016-06-24 15:21:35 +09:00
Masayuki Nakano
35be83ddea Bug 1260651 part.42 Rename nsAutoRemoveContainerSelNotify to mozilla::AutoRemoveContainerSelNotify r=mccr8
MozReview-Commit-ID: GyU26vXBGyt
2016-07-07 18:27:18 +09:00
Masayuki Nakano
ae63c1d600 Bug 1260651 part.41 Rename mozilla::dom::AutoReplaceContainerSelNotify to mozilla::AutoReplaceContainerSelNotify r=mccr8
MozReview-Commit-ID: 2EB2yQOpjO9
2016-06-24 15:14:16 +09:00
Masayuki Nakano
bc3f10f5dc Bug 1260651 part.40 Rename nsAutoTrackDOMPoint to mozilla::AutoTrackDOMPoint r=mccr8
MozReview-Commit-ID: 775stH3pteA
2016-06-24 15:08:16 +09:00
Masayuki Nakano
452819e0f2 Bug 1260651 part.39 Rename nsRangeUpdater to mozilla::RangeUpdater r=mccr8
MozReview-Commit-ID: 8xPhGbSSOjx
2016-06-24 15:01:40 +09:00
Masayuki Nakano
06439489fa Bug 1260651 part.38 Rename nsRangeStore to mozilla::RangeItem because the instances called 'item' in many places r=mccr8
MozReview-Commit-ID: BUU44fpTNyW
2016-06-24 14:44:14 +09:00
Masayuki Nakano
70604c32d8 Bug 1260651 part.37 Rename nsSelectionState to mozilla::SelectionState (and their file names too) r=mccr8
Note that this fixes some new bustage of nsHTMLEditor.

nbsp is conflict with nsWSRunObject.cpp's same name constant.  Therefore, I moved it into nsHTMLEditor and rename it to kNBSP.

And including some missing header files.

MozReview-Commit-ID: hwL8BIbSMQ

--HG--
rename : editor/libeditor/nsSelectionState.cpp => editor/libeditor/SelectionState.cpp
rename : editor/libeditor/nsSelectionState.h => editor/libeditor/SelectionState.h
2016-07-07 18:15:53 +09:00