Commit Graph

7947 Commits

Author SHA1 Message Date
Ehsan Akhgari
b62766b04e Bug 1393140 - Rewrite EditorBase::FindBetterInsertionPoint() without using nsINode::GetChildAt(); r=masayuki 2017-09-01 12:12:39 -04:00
Masayuki Nakano
199c190cbe Bug 1395157 - Make EditorBase::EndPlaceholderTransaction() not retrieve nor hold nsIPresShell and nsCaret r=Ehsan
EditorBase::EndPlaceholderTransaction() has hidden caret.  However, it doesn't
do it anymore.  However, bug 805697 didn't remove unnecessary code that
retrieves and hold nsIPresShell and nsCaret.  This patch removes them.

MozReview-Commit-ID: Eh9pbf8p2bZ

--HG--
extra : rebase_source : e766906089af1cd3c6efa95b82e3b126ae097ab2
2017-08-30 23:24:26 +09:00
Andrew McCreight
78807d8776 Bug 1391005 - Eliminate NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED. r=peterv
Replace it with NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION, because it
has been the same for a while.

MozReview-Commit-ID: 5agRGFyUry1

--HG--
extra : rebase_source : 5388c56b2f6905c6ef969150f0c5b77bf247624d
2017-08-29 16:02:48 -07:00
Nicholas Nethercote
0eadf50d37 Bug 1394583 - Remove default properties from nsIHTMLEditor. r=masayuki.
nsIHTMLEditor's addDefaultProperty(), removeDefaultProperty(),
removeAllDefaultProperties() methods are never used -- not from C++ code or
script, in either mozilla-central or comm-central.

So this patch removes them. This means that HMLTEditor::mDefaultStyles is never
used, so the patch removes it and all the code that manipulates it as well.

--HG--
extra : rebase_source : 76634ce2bb2d94534b8d7f299c4ebd6a83b66637
2017-08-25 16:59:17 +10:00
Makoto Kato
fedf4a0136 Bug 1391978 - Part 9. Replace nsISelection::GetAnchorNode with Selection::GetAnchorNode. r=masayuki
MozReview-Commit-ID: CiIClvsiNxX

--HG--
extra : rebase_source : a739151e75d8920dd76b9729fd0d698f574218ed
extra : histedit_source : d9004420476b49aa5e063a00b01928e509214843
2017-08-25 16:12:39 +09:00
Makoto Kato
349e2e739f Bug 1391978 - Part 8. Replace nsISelection::GetAnchorOffset with Selection::AnchorOffset. r=masayuki
MozReview-Commit-ID: GgxyRsVXHwl

--HG--
extra : rebase_source : 7d3d869f21669486e9dd3bb925451e5bd20fa3b0
extra : histedit_source : 0e2f13e733d143a782391c420da9bfa34f0c228a
2017-08-25 16:12:39 +09:00
Makoto Kato
7732ebc1b4 Bug 1391978 - Part 7. HTMLEditRules::NormalizeSelection should use nsINode instead of nsIDOMNode. r=masayuki
HTMLEditRules::NormalizeSelection uses nsIDOMNode for node handling, so we replace with nsINode, then use Selection::Extend and Selection::Collapse.

MozReview-Commit-ID: 6Ijo19vTwRi

--HG--
extra : rebase_source : 3171ed5808d9045b268cc76989c7d06ea220d393
extra : histedit_source : f3a1af1f84cceb80200a3965385dfb1d036c9e60
2017-08-25 16:12:39 +09:00
Makoto Kato
83778753b6 Bug 1391978 - Part 6. Replace nsISelection::Extend with Selection::Extend. r=masayuki
Except to HTMLEditRules::NormalizeSelection, I replace nsISelection::Extend with Selection::Extend.

MozReview-Commit-ID: H83zpvAo5Xa

--HG--
extra : rebase_source : b217dd1d506229d848126b9c2494d1b4f9dc3a35
extra : histedit_source : 8999bc5b1b1edfe7e48a432d52640b8181490624
2017-08-28 17:54:34 +09:00
Makoto Kato
6f6e4ef550 Bug 1391978 - Part 5. Replace nsISelection::GetFocusOffset/GetAnchroOffset with Selection::FocusOffset/AnchorOffset. r=masayuki
MozReview-Commit-ID: 6OpO1GQyhFO

--HG--
extra : rebase_source : 3e57ddbebc7985ec0e5ada4b1e83631d6f1c83b5
extra : histedit_source : 655c5c3e4c4a3f30d028f9b4b316573a187bd0f0
2017-08-25 16:12:38 +09:00
Makoto Kato
72387d25cd Bug 1391978 - Part 4. Replace nsISelection::GetFocusNode with Selection::GetFocusNode. r=masayuki
MozReview-Commit-ID: GFtkRvsFaYI

--HG--
extra : rebase_source : c11007a58ee312a7845ba4b8c0886dec49cd8c39
extra : histedit_source : e0a2d06a061a9cad3ff83e6be5e697a1c2748756
2017-08-25 16:12:38 +09:00
Makoto Kato
1480dbb45c Bug 1391978 - Part 3. Replace nsISelection::GetIsCollapsed with Selection::IsCollapsed. r=masayuki
MozReview-Commit-ID: AYCX9V8smzm

--HG--
extra : rebase_source : 2c45cffa7d526a9e07126c90f17232b02b1612ea
extra : histedit_source : bd451bdd633df2eb155102f9c3b29b49a25b9c69
2017-08-25 17:48:04 +09:00
Makoto Kato
a7d3c9c2a0 Bug 1391978 - Part 2. Replace nsISelection::SelectAllChildren with Selection::SelectAllChildren. r=masayuki
MozReview-Commit-ID: m9bLHIIfy9

--HG--
extra : rebase_source : 47aa2e674a8f6615989b25ddb2b11b6614587b7b
extra : histedit_source : 847922b8ff86389a4a264efda7c4f933743c8f63
2017-08-25 16:12:38 +09:00
Makoto Kato
26ce168fcc Bug 1391978 - Part 1. Replace nsISelection::GetRangeCount with Selection::RangeCount. r=masayuki
I would like to remove more dependency of old nsISelection interface from editor if possible.  So we can replace nsISelection::GetRangeCount with Selection::RangeCount.

MozReview-Commit-ID: 2Mh5ceQI2om

--HG--
extra : rebase_source : 03c8a5b49e2929b0ce6c6af8b78c9677a55a14c4
extra : histedit_source : ca7741379c7cc5b7b938aad22a57f419a2442fd3
2017-08-28 14:52:25 +09:00
Olli Pettay
4ef3c3fdf6 Bug 1371657 - Ensure we use the right root element in editor. r=masayuki 2017-08-28 14:57:46 -04:00
Sebastian Hengst
9769c22d10 merge mozilla-inbound to mozilla-central. r=merge a=merge
MozReview-Commit-ID: AeoHOxZLi6m
2017-08-28 16:53:53 +02:00
Ehsan Akhgari
6f420e6a00 Bug 1394180 - Reduce the number of calls to nsINode::GetChildAt() in EditorBase::InsertTextImpl(); r=masayuki 2017-08-28 01:42:30 -04:00
Masayuki Nakano
3bd4299525 Bug 1393348 - part2: nsISelectionController::SELECTION_* should be sequential integer values r=smaug
nsISelectionController::SELECTION_* are declared as bit-mask.  However, no
methods of nsISelectionController treat them as bit-mask and these
values need a switch statement in nsFrameSelection to convert SelectionType to
array index of nsFrameSelection::mDOMSelections because it's too big to create
an array to do it.  Additionally, this conversion appears profile of
attachment 8848015.

So, now, we should declare these values as sequential integer values.

However, only nsTextFrame uses these values as bit-mask.  Therefore, this patch
adds new type, SelectionTypeMask and creates new inline method,
ToSelectionTypeMask(SelectionType), to retrieve mask value for a SelectionType.

MozReview-Commit-ID: 5Za8mA6iu4

--HG--
extra : rebase_source : 86617c1f5fa23166458f4353cb834f9e7c5b131b
2017-08-24 19:14:04 +09:00
Nicholas Nethercote
c7df832636 Bug 1393642 - Remove nsIAtom/nsIAtomService usage from script in editor/. r=masayuki.
nsIHTMLEditor has several scriptable methods (addDefaultProperty(),
removeDefaultProperty(), etc.) that have nsIAtom parameters. We're in the
process of deCOMtaminating nsIAtom (bug 1392883) so these methods need to be
changed.

This patch does the following.

- It changes those methods to take an AString instead of an nsIAtom.

- For each existing method, it adds to HTMLEditor a new C++ method of the same
  name that takes an nsIAtom parameter.

- It updates TextEditorTest.cpp to use strings instead of atoms, in order to
  keep using the XPIDL methods.

- It updates test_bug1140105.html to pass strings instead of atoms to
  getInlineProperty(). This removes the use of nsIAtomService.

--HG--
extra : rebase_source : e005c3b5a08207b3d5d5fb55c47c8bc475b33453
2017-08-25 15:40:45 +10:00
Sebastian Hengst
6fd5b9e1ca merge mozilla-central to autoland. r=merge a=merge 2017-08-25 13:19:59 +02:00
Sebastian Hengst
31302b9cec merge mozilla-inbound to mozilla-central. r=merge a=merge
MozReview-Commit-ID: 5armhVE9Jui
2017-08-25 13:12:04 +02:00
Ehsan Akhgari
b174b2306a Bug 1392867 follow-up: Document that the aChild argument won't get AddRef'ed
DONTBUILD
2017-08-24 18:39:24 -04:00
Makoto Kato
5bd44e5cfd Bug 1393355 - Move SetTextRangeStyle from nsISelectionPrivate to Selection. r=masayuki
There is no reason that SetTextRangeStyle is defined at nsISelectionPrivate.  Also, SetTextRangeStyle isn't scriptable, and is called from CompositionTransaction::SetIMESelection only.  So we should move this to Selection.

MozReview-Commit-ID: FCOA6wVhvYZ

--HG--
extra : rebase_source : 64eb9e5fb973195b2c87ab4eb296685c8a4d0319
2017-08-24 16:56:12 +09:00
Masayuki Nakano
e3529fd155 Bug 1375502 - part2: Add nsIContentIterator::Init(nsINode*, uint32_t, nsINode*, uint32_t) r=mats
nsIContentIterator::Init() takes nsRange but it's too expensive for some users.
So, there should be another Init() which can be specified a range in DOM tree
with 2 pairs of nsINode* and uint32_t.

MozReview-Commit-ID: 6JXic0KOM2d

--HG--
extra : rebase_source : 28ff355a2aa0dcb5d65495806ef8c67f1da642ea
2017-06-26 17:26:27 +09:00
Olli Pettay
045eeefaaa Bug 1390402, add a faster variant of TextEditor::GetDocumentIsEmpty(), r=masayuki
--HG--
extra : rebase_source : 3238aec96be5b0393c395ce8cce9a0489d2e671d
2017-08-24 13:53:34 +03:00
Eric Rahm
a33f11e0f5 Bug 1391803 - Use nsStringFwd.h for forward declaring string classes. r=froydnj
We should not be declaring forward declarations for nsString classes directly,
instead we should use nsStringFwd.h. This will make changing the underlying
types easier.

--HG--
extra : rebase_source : b2c7554e8632f078167ff2f609392e63a136c299
2017-08-16 16:48:52 -07:00
Sebastian Hengst
99e5cb9c14 merge mozilla-inbound to mozilla-central. r=merge a=merge
MozReview-Commit-ID: GSKVB94r7Kk
2017-08-23 16:29:51 +02:00
Makoto Kato
a1548f0668 Bug 1348073 - Part 4. Unnecessary VK_RIGHT to move caret on non-visual frame that is whitespace only node. r=masayuki
Since we enable lazy frame construction for editable region, whitespace only node might not have frame even if editable.  This test has whitespace only node into contenteditable, we need adjust caret operation for this test.

MozReview-Commit-ID: GQfKiYdYOdi

--HG--
extra : rebase_source : 0685d724f6af050d79c1cf007c7ee48c05da14ac
2017-08-21 15:33:03 +09:00
Ehsan Akhgari
31e4d33b89 Bug 1392870 - Avoid using nsINode::GetChildAt() in HTMLEditRules::DeleteNonTableElements(); r=masayuki 2017-08-23 01:01:04 -04:00
Ehsan Akhgari
e7f2972a7f Bug 1392867 - Part 2: Avoid calling GetChildAt() in HTMLEditRules::TryToJoinBlocks(); r=masayuki 2017-08-23 01:00:07 -04:00
Ehsan Akhgari
07f926500c Bug 1392867 - Part 1: Add an overload of EditorUtils::IsDescendantOf() which returns an nsIContent* out argument for the child node found instead of its index in the parent; r=masayuki 2017-08-23 01:00:07 -04:00
Nicholas Nethercote
092af8e0a1 Bug 1390428 (part 5) - Remove more nsXPIDLCString uses. r=erahm.
These are all simple cases, with similarities to previous patches in this
series.

--HG--
extra : rebase_source : 6ef36382df9fef217d5cb737e218d65ac062f90a
2017-08-16 14:07:18 +10: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
Makoto Kato
3ee9303468 Bug 1381541 - queryCommandState should consider that parent node of selection is null. r=masayuki
When parent node of selected node is null, crash might occur in GetCSSBackgroundColorState.  So when parent is null, we should return default value.  In this situation, Edge and Blink don't throw error, Gecko shouldn't return error too.

MozReview-Commit-ID: 5C6jSAFkCso

--HG--
extra : rebase_source : 0185f9fb5fde92eee5611e6bb95e8676c10b135c
2017-08-18 14:48:39 +09:00
Masayuki Nakano
a7240d8532 Bug 1391538 - nsTextFragment for text nodes in <input> or <textarea> shouldn't store text as single byte characters even if all characters are less than U+0100 r=smaug
nsTextFrame stores text as single byte character array if all characters are
less than U+0100.  Although, this saves footprint, but retrieving and modifying
text needs converting cost.  Therefore, if it's created for a text node in
<input> or <textarea>, it should store text as char16_t array.

MozReview-Commit-ID: 9Z82rketT7g

--HG--
extra : rebase_source : 59f59ac1488c21a57d95d253cc794a011d672c95
2017-08-18 16:05:16 +09:00
Wes Kocher
c043502159 Merge m-c to autoland, a=merge
MozReview-Commit-ID: 7sFZmPUXSx6
2017-08-18 17:21:29 -07:00
Masayuki Nakano
30fb5747b0 Bug 1391165 - part4: nsIEditor::EndOfDocument() should be implemented with an internal method which takes pointer to Selection r=smaug
EditorBase::GetSelection() sometimes appears in profile.  So, it shouldn't be
called in nsIEditor::EndOfDocument() if the callers of
nsIEditor::EndOfDocument() has a pointer to Selection.

This patch adds EditorBase::CollapseSelectionToEnd() for the internal method
and make all callers of nsIEditor::EndOfDocument() use it.

MozReview-Commit-ID: 8H4ThxzdKDf

--HG--
extra : rebase_source : 7436d7f286351fa9c91175b40e686f7ca1f3c69f
2017-08-17 17:08:22 +09:00
Masayuki Nakano
a329587e5e Bug 1391165 - part3: TextEditRules::CollapseSelectionToTrailingBRIfNeeded() should use EditorBase::GetChildOffset() only when it's necessary r=smaug
In most cases, TextEditRules::CollapseSelectionToTrailingBRIfNeeded() doesn't
use the index anymore.  Therefore, it should stop using
EditorBase::GetNodeLocation() and use EditorBase::GetChildOffset() only when
the offset is necessary.

MozReview-Commit-ID: 9vGcLnTUnsu

--HG--
extra : rebase_source : af0cdad3a1905bf2e5654a109aa4037ec70b422b
2017-08-17 16:48:49 +09:00
Masayuki Nakano
0290f8a69f Bug 1391165 - part2: TextEditRules::CollapseSelectionToTrailingBRIfNeeded() should use nsINode::GetNextSibling() for retrieving next child of a node r=smaug
nsINode::GetChildAt() is too expensive if it's used for next sibling of a node.

This patch makes it use nsINode::GetNextSibling() instead.

MozReview-Commit-ID: CAC7gFNo77w

--HG--
extra : rebase_source : 185457b910e2e09c58a6f02525ae61aff149511c
2017-08-17 16:35:30 +09:00
Masayuki Nakano
87f491432c Bug 1391165 - part1: EditorBase::GetChildOffset() and EditorBase::GetNodeLocation() shouldn't use nsINode::IndexOf() as far as possible r=smaug
nsINode::IndexOf() is expensive especially when it's in a hot path, it's too
expensive.  So, EditorBase::GetChildOffset() and EditorBase::GetNodeLocation()
should check child's siblings first.  If some of them are nullptr, it means
that it's first child or last child of the parent.

Note that EditorBase::GetChildOffset() may return wrong index if it's called
while aChild is being removed from aParent or aParent isn't actual parent of
aChild.  However, there are MOZ_ASSERTs to ensure value isn't -1.  Therefore,
it's safe to assume that aParent is always the parent of aChild and it won't
be called from ContentRemoved() of mutation observers.

MozReview-Commit-ID: 8JdYWuZbHe5

--HG--
extra : rebase_source : 6ded91a3aa8b00ab4d2d544c2c392d88cb769cef
2017-08-17 16:24:16 +09:00
Ehsan Akhgari
950a791753 Bug 1391315 - Avoid using nsINode::GetChildAt() in TextEditRules::DocumentIsEmpty(); r=masayuki
This method will become a lot slower when bug 651120 lands.
2017-08-18 01:49:08 -04:00
Yoshi Huang
b930b3d1ee Bug 1390770 - rewrite test_bug289384.html for new data: URI inheritance model. r=masayuki 2017-08-18 10:35:58 +08:00
Ehsan Akhgari
43a6f66350 Backout bug 1386480 for causing bug 1391410 2017-08-17 17:16:27 -04:00
Carsten "Tomcat" Book
99aa3f8e70 Merge mozilla-central to mozilla-inbound 2017-08-17 13:13:10 +02:00
Makoto Kato
4ad29844a4 Bug 1380824 - Call RepaintSelection out of script blocker. r=masayuki
MozReview-Commit-ID: LFyZLW0da7f
2017-08-17 15:28:04 +09:00
Nicholas Nethercote
025461bde7 Bug 1390428 (part 1) - Remove many nsXPIDLCString local variables. r=erahm.
These are all easy cases where an nsXPIDLCString local variable is set via
getter_Copies() and then is only used in ways that nsCStrings can also be used
(i.e. no null checks or implicit conversions to |char*|).

In every case the patch trivially replaces the nsXPIDLCString with an
nsCString. (Also, there are a couple of unused nsXPIDLCString variables that
the patch simply removes.)
2017-08-16 13:58:35 +10:00
Xidorn Quan
179961b3c9 Bug 1383845 - Enable tests disabled for bug 1383845. r=TYLin
MozReview-Commit-ID: Glao9d9PiUF

--HG--
extra : rebase_source : cfc70fcb350a7ee8e325ba1bda0bcdead62d786e
2017-08-17 10:51:59 +10:00
Masayuki Nakano
d2dd8c5d8f Bug 1390831 - Make test_bug635636.html e10s-aware r=Ehsan
test_bug655636.html refers gBrowser, however, it's available only in chrome
process and it's referred only for listening to "pageshow" event instead of
"load" event of the data URI.  So, we must be able to use "unload" event of the
previous URL instead.

Although, this testcase (even without this change) won't cause crash even if
backing out the patch for bug 635636 anymore.

MozReview-Commit-ID: B8qOwVZqZQm

--HG--
extra : rebase_source : d383181886152684a8bf9c2caf7248d5f7582c0a
2017-08-16 21:03:18 +09:00
Masatoshi Kimura
be91c9a266 Bug 886907 - Remove old synchronous contentPrefService from the tree. r=adw
MozReview-Commit-ID: BZsB3FR3jHC

--HG--
rename : toolkit/components/contentprefs/ContentPrefService2.jsm => toolkit/components/contentprefs/ContentPrefService2.js
rename : toolkit/components/contentprefs/nsContentPrefService.manifest => toolkit/components/contentprefs/ContentPrefService2.manifest
extra : rebase_source : ab45b7668e97734004502ea776effedcb9b74974
2017-08-11 23:29:55 +09:00
Masayuki Nakano
e1a21d5a3e Bug 1387317 - part5: AutoPlaceHolderBatch should take EditorBase instead of nsIEditor r=m_kato
AutoPlaceHolderBatch can take EditorBase class and its inherited class, AutoEditBatch, can be removed if we implement other constructor which doesn't take transaction name.

Additionally, nsIEditor::(Begin|End)PlaceHolderTransaction() are referred only by AutoPlaceHolderBatch.  Therefore, they can be non-public methods and removed from nsIEditor interface.

Note that this patch also repalces "PlaceHolder" with "Placeholder" since it's a word.

MozReview-Commit-ID: 5dw3kcX3bOx

--HG--
extra : rebase_source : e926cc1c2ebea70eb08e43778a8b52912b559b7b
2017-08-14 14:56:39 +09:00
Masayuki Nakano
1bbc0d5920 Bug 1387317 - part4: Make editor flag setters use new AddFlags() or RemoveFlags() if useful r=m_kato
MozReview-Commit-ID: EMDeGfK37Lx

--HG--
extra : rebase_source : 8a2b4e809c608649fbb41edd32d2165db7e77516
2017-08-08 12:36:29 +09:00