Граф коммитов

30 Коммитов

Автор SHA1 Сообщение Дата
Edgar Chen 5fedbb92b8 Bug 1422197 - Add fast path to get DocGroup in binding code for [CEReactions]; r=smaug
MozReview-Commit-ID: HgbFo9ddr0o

--HG--
extra : rebase_source : 04989782fc7c7ce79e0e65b3dc907c9e174a0809
2017-11-27 16:10:27 +08:00
Masayuki Nakano 0021ffcddf Bug 1423097 - part 1: Implement Selection::AnchorRef() and Selection::FocusRef() r=smaug
Some methods of editor retrieves anchor and focus of selection.  However, there
are no methods which directly access RangeBoundary of anchor and focus.

This patch adds it for making editor code simpler and avoiding unnecessary
child offset computation.

MozReview-Commit-ID: EvepQpFMi8S

--HG--
extra : rebase_source : 38f3c506db5c9d8790bbd625d552bfbc8d99cebc
2017-12-05 16:36:57 +09:00
Ting-Yu Lin 7326c2887e Bug 1417376 Part 2 - Pass nsPoint parameters by const references instead of references. r=mats
MozReview-Commit-ID: 6TveqwkOvc0

--HG--
extra : rebase_source : d4674181a6198279bedbfc2efe4e0b1715c91d51
2017-11-15 18:26:10 +08:00
Ting-Yu Lin 34d8925cd4 Bug 1417376 Part 1 - Change nsPoint parameter to pass by value for DoAutoScroll(). r=mats
This private method DoAutoScroll() modifies aPoint inside of it, and none of
other callers (StartAutoScrollTimer() and nsAutoScrollTimer::Notify()) read
aPoint afterwards, so we make aPoint pass by value rather than pass by
non-const-reference. This is necessary for later parts.

MozReview-Commit-ID: 9PtxFXIka7X

--HG--
extra : rebase_source : 3bd47f071b3cecdc439ebc3b56c6a4f7ef56eff8
2017-11-16 10:32:22 +08:00
Masayuki Nakano 898bbb3137 Bug 1415062 - part 1: Selection should have Collapse(const RawRangeBoundary&) and Collapse(const RawRangeBoundary&, ErrorResult&) for avoiding computing offset of child node in container r=smaug
Selection should have Collapse() methods which take RawRangeBoundary instead of
a set of container and offset in it.  Then, if caller know only child node but
doesn't know offset in the container, neither callers, Selections nor nsRange
needs to compute offset.  This makes them avoid calling expensive method,
nsINode::IndexOf().

MozReview-Commit-ID: 79IRajLe1FE

--HG--
extra : rebase_source : a8ce52ff1654974461d5ecfed98b73d9cca34133
2017-11-07 15:29:15 +09:00
Andrew McCreight 298aa82710 Bug 1412125, part 2 - Fix dom/ mode lines. r=qdot
This was automatically generated by the script modeline.py.

MozReview-Commit-ID: BgulzkGteAL

--HG--
extra : rebase_source : a4b9d16a4c06c4e85d7d85f485221b1e4ebdfede
2017-10-26 15:08:41 -07:00
Ehsan Akhgari a3b87e2b92 Bug 1405039 - Avoid using nsINode::GetChildAt() in HTMLEditor::GetSelectedElement(); r=masayuki 2017-10-02 14:22:57 -04:00
Andrew McCreight 58abe33226 Bug 1216885 - Make nsISelectionPrivate not inherit from nsISelection. r=smaug
nsISelectionPrivate is accessible to script, while nsISelection is
not, so making the former inherit from the latter means script doesn't
have a complete view of the inheritance chain so the XPIDL compiler
produces an error.

It turns out that nothing in script relies on this inheritance, which
makes sense because I'm not sure how it would even work, so just
remove it.

MozReview-Commit-ID: 3Py2T7cprlD

--HG--
extra : rebase_source : 89fac3ad0f7a30c1c71da79d554ebfa153d5fb33
2017-09-11 15:19:22 -07:00
Makoto Kato b7d709c044 Bug 1397791 - Move StartBatchChanges and EndBatchChanges from nsISelectionPrivate to Selection. r=smaug
There is no reason to keep StartBatchChanges and EndBatchChanges in nsISelectionPrivate since this is noscript method.  And if moving it to Selection, we can remove virtual keyword.

MozReview-Commit-ID: Go6njiW3r2x

--HG--
extra : rebase_source : cb5bfce8312de7d49496e5f841e9786ff16102f6
2017-09-08 12:10:44 +09:00
Ehsan Akhgari 2231e4a948 Bug 1397577 - Avoid using GetChildAt() in HTMLEditor::GetSelectedOrParentTableElement(); r=smaug 2017-09-07 10:29:02 -04:00
Masayuki Nakano 1c17ef6f96 Bug 1393816 - part2: Selection::SetBaseAndExtent() should use mCachedRange if it's available r=smaug
Similar to Selection::Collapse(), if mCachedRange is available,
Selection::SetBaseAndExtent() should use it rather than creating new nsRange
instance.

Then, it can reduce the allocation cost and may reduce some other cost, e.g.,
adding it to mutation observer.

MozReview-Commit-ID: InQQusw2KMc

--HG--
extra : rebase_source : 967f0d4ad2b7bc706e417af547bbbb21e5f54306
2017-08-26 00:12:38 +09:00
Masayuki Nakano 5c2c570f9b Bug 1393816 - part1: Cache a range until new range is created in Selection r=smaug
When setting value of <input type="text">, nsTextEditorState removes all
ranges of normal selection first.  Then, TextEditor sets the value.  Finally,
TextEditor collapses the selection at the end of the text.

In bug 1386471, we got that there are some problems to remove the call of
Selection::RemoveAllRanges() in nsTextEditorState.  Therefore, we need another
approach to improve Selection::Collapse().

The approach of this patch is, when removing all ranges from normal selection,
Selection can cache an nsRange instance if there is an instance which is not
referenced from other than the Selection (i.e., it'll be removed when
Selection::Clear() is called).  Then, Selection::Collapse() can reuse it.  With
this fix, Selection::Collapse() can reduce allocation cost and may reduce some
other cost like adding it to mutation observer.

However, keeping nsRange instance may cause increasing mutation observer's cost
since nsRange will be adjusted its start node/offset and end node/offset with
mutation observer to guarantee that the range is always valid.  So, we can
cache such range only when the caller (or its callee) will set selection range
later.  Therefore, this patch adds Selection::RemoveAllRangesTemporarily()
and make only nsTextEditorState::SetValue() and
ContentEventHandler::OnSelectionEvent() use it.

MozReview-Commit-ID: FjWrbz4S1ld

--HG--
extra : rebase_source : 83677640525e0b1a84bdd7fce63ff4704b9cc22b
2017-08-25 19:21:39 +09: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
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
Makoto Kato fa46fdd1ad Bug 1348073 - Part 1. MoveCaret should move caret when focus node is whitespace only even if it is no frame. r=jfkthame
When enabling lazy frame construction, whitespace only node might not have frame.  So editor/libeditor/tests/test_bug1315065.html is failure because nsFrameSelection::MoveCaret returns error since focus node is whitespace only node that has no frame.

So if focus node is whitespace only, we should promote to parent to get primary frame then try again.

MozReview-Commit-ID: K83T2LP3Pc5

--HG--
extra : rebase_source : 707584424e83574dd3151e12a915473f676ce5a0
2017-08-23 19:09:07 +09:00
Ehsan Akhgari dea2e72d91 Bug 1390382 - Part 1: Inline Selection::IsCollapsed(); r=smaug 2017-08-15 18:57:14 -04:00
Masayuki Nakano b11e66f8da Bug 1388004 - part1: Make nsContentUtils::GetHTMLEditor() return HTMLEditor* rather than nsIEditor* r=smaug
nsContentUtils::GetHTMLEditor() currently returns nsIEditor* since editor of doc shell may be any type of editors such as TextEditor or editor object which is implemented by JS.  However, nsIEditor is now a builtin class.  So, it can return HTMLEditor.

MozReview-Commit-ID: 3YoFOplZa7W

--HG--
extra : rebase_source : 46f42d23babd64bf0a5003e66e8fe3b9e0bd7166
2017-08-07 16:33:59 +09:00
Aryeh Gregor 99a150fe57 Bug 1359397 - Don't allow Selection in nodes not in the document; r=masayuki
This matches the spec and Chrome, and seems to bring us closer to Edge
and WebKit as well.  It also matches our own behavior for addRange(),
which was changed in bug 1341137.

For collapse and selectAllChildren, we match the tests and browsers, but
the spec is incorrect at the time of this writing:
https://github.com/w3c/selection-api/pull/86

The removeAllRanges test hadn't been updated for the spec change.

MozReview-Commit-ID: DTK8283k5IP

--HG--
extra : rebase_source : 54701e7136c33ebce651d5f74c3dc1d8b944f9a3
2017-08-10 15:02:08 +03:00
Wes Kocher db7d003ae0 Merge m-c to autoland a=merge CLOSED TREE
MozReview-Commit-ID: Ko3lhAvzMJN
2017-08-03 18:22:09 -07:00
Ehsan Akhgari 7fe0be04ed Bug 1386411 - Part 3: Inline some helper functions in Selection.cpp; r=bzbarsky 2017-08-03 17:05:19 -04:00
Ehsan Akhgari 1774c1cc7d Bug 1386411 - Part 2: Devirtualize and inline nsISelection::AsSelection(); r=bzbarsky
nsISelection is builtinclass, so this method doesn't need to be virtual.
2017-08-03 17:05:17 -04:00
Aryeh Gregor ca4b09e233 Bug 1359157 - Support Selection.type from spec; r=smaug
All other browsers already support it, more or less interoperably.

MozReview-Commit-ID: 4VoOeqBoKI0

--HG--
extra : rebase_source : fdd5198cc5fe8c2175242ddcc170947e7ca592b9
2017-08-03 17:13:24 +03:00
Ehsan Akhgari 8e7275d330 Bug 1385369 - Reserve 1 space in Selection::mRanges; r=qdot
Most selections on the Web end up with one Range inside them.
By reserving the space for this one range inline, we can avoid the
allocator pressure in a lot of hot code when manipulating the
Selection object.
2017-07-28 15:27:57 -04:00
Masayuki Nakano e756fe8300 Bug 1377989 - part7: Rename aParent, aParentNode and aNode related to nsRange to aContainer r=smaug
MozReview-Commit-ID: K7Lu0U0pdC8

--HG--
extra : rebase_source : 324de9d2927231414395799c0f002889321b7d1e
2017-07-11 23:33:04 +09:00
Bill McCloskey f115503a0b Bug 1372405 - Provide names for all runnables in the tree (r=froydnj)
MozReview-Commit-ID: DKR6ROiHRS7
2017-06-26 14:19:58 -07:00
Carsten "Tomcat" Book 8a1350b5a6 Backed out changeset 4f6302a98ae4 (bug 1372405)
--HG--
extra : rebase_source : 41632f3158e88e692809731394a683d065a73dfb
2017-06-21 13:59:26 +02:00
Bill McCloskey 6b3e84ed5f Bug 1372405 - Provide names for all runnables in the tree (r=froydnj)
MozReview-Commit-ID: DKR6ROiHRS7
2017-06-20 21:44:11 -07:00
Carsten "Tomcat" Book ea1b86680c Backed out changeset 9846de3bd954 (bug 1372405)
--HG--
extra : rebase_source : 5d4a48e8ec394c329994689d938d2a6e9b2752b0
2017-06-20 08:27:02 +02:00
Bill McCloskey 4592152411 Bug 1372405 - Provide names for all runnables in the tree (r=froydnj)
MozReview-Commit-ID: DKR6ROiHRS7
2017-06-19 22:25:47 -07:00
Mats Palmgren d582beef4f Bug 1373999 part 1 - Move layout/generic/nsSelection.cpp verbatim to dom/base/Selection.cpp, and layout/generic/Selection*.h to dom/base/. Also export a few table header files that it needs. r=smaug
MozReview-Commit-ID: 9YUmEOIHUdc

--HG--
rename : layout/generic/nsSelection.cpp => dom/base/Selection.cpp
rename : layout/generic/Selection.h => dom/base/Selection.h
rename : layout/generic/SelectionChangeListener.h => dom/base/SelectionChangeListener.h
2017-06-19 00:07:36 +02:00