Commit Graph

124 Commits

Author SHA1 Message Date
Nika Layzell
c62dc4b532 Bug 1399626 - Part 5: Update ContentEventHandler to use the new nsIContentIterator::Init overload when possible, r=masayuki
MozReview-Commit-ID: 2Zk8zTs58hu
2017-10-02 11:58:00 -04:00
Michael Layzell
615d87dfaf Bug 1384915 - Part 4: Update RawRange to use RangeBoundaries, r=masayuki 2017-09-25 18:14:43 -04:00
Michael Layzell
9601431bf2 Bug 1384915 - Part 2: Make NodePosition a wrapper around RangeBoundary, r=masayuki 2017-09-25 18:14:42 -04:00
Nicholas Nethercote
2ef37710e7 Bug 1395828 (part 4) - Remove nsIParserService/nsParserService. r=mrbkap.
It a stateless wrapper around static methods in nsHTMLTags and nsHTMLElement,
and hence an unnecessary layer of indirection that just adds complexity and
slowness. This patch removes it, cutting almost 300 lines of code.

This requires making nsElementTable.h an exported header, to expose the
nsHTMLElement methods.

--HG--
extra : rebase_source : abbcb8e5001389affbf717092213b898673db07f
2017-09-05 20:19:06 +10: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
Masayuki Nakano
4ce89d8f61 Bug 1369072 - part3: nsXBLPrototypeHandler::DispatchXBLCommand() should use controller of visible window r=smaug
With previous change, KeyboardEvent is dispatched even when invisible window
has focus.  However, nsRootWindow::GetControllerForCommand() returns controller
for focused window even when the window is invisible because it uses
nsFocusManager::GetFocusedDescendant() to retrieve focused window.

Perhaps, we can assume that users won't expect to do something with invisible
window when they type some keys.  Then, nsRootWindow::GetControllerForCommand()
should return controller for visible ancestor window if focused window is
invisible.

This patch makes nsFocusManager::GetFocusedDescendant() can return only visible
descendants.  However, it already has a bool argument.  Therefore, it should
have a flag instead of adding new flag.  Most changes of this patch is replacing
its callers.

Then, nsRootWindow::GetControllerForCommand() and nsRootWindow::GetControllers()
should have a bool flag if it should return controller(s) for visible window.
This patch adds a bool flag for it.  Fortunately, the interface isn't scriptable.

Finally, this patch makes nsXBLPrototypeHandler::DispatchXBLCommand() and
EventStateManager::DoContentCommandEvent() retrieve controller for visible
window since they are always handles user input.

MozReview-Commit-ID: GygttTHuKRm

--HG--
extra : rebase_source : 1341273c4606298cb9b890b9312d9f5c8a75d144
2017-09-07 22:54:49 +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
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
Masayuki Nakano
acde25fb18 Bug 1375502 - part1: ContentEventHandler shouldn't use nsRange for temporary use r=mats
Allocating and initializing nsRange is too expensive especially for temporary
use.  However, ContentEventHandler uses nsRange only for representing two DOM
points.  So, it should use simpler helper class, RawRange, for reducing some
unnecessary runtime cost.

Note that this still uses nsRange for initializing nsIContentIterator.  This
will be fixed by the following patch.

MozReview-Commit-ID: 5TUy6yJf7HA

--HG--
extra : rebase_source : c4eb58e8f37c408c75479e6961ba9225f8bcee77
2017-06-23 13:21:47 +09:00
Jim Chen
41148177ef Bug 1351170 - 1. Correctly calculate start offset for non-text nodes; r=masayuki
When the start node is a non-container node (i.e. <br>), and the start
offset is 0, we should not include a newline character for the node. For
example, for this range,

> <br/>hello
>  \___/

the start node/offset is (<br/>, 0) and end node/offset is ("hello", 1).
The calculated range offset should be 0, and the range length should be
2: 1 for the <br/> newline character plus 1 for "h".

The patch also ensures this behavior for pre-mode nsContentIterator, for
both start and end node adjustments. For start nodes, we include any
non-container nodes with offset 0 in the range. For end node, we exclude
any non-container nodes with offset 0 from the range.

MozReview-Commit-ID: Lt2tCLbapq7

--HG--
extra : rebase_source : 7d86b6cf04581f1cd71fa85f8c8586541b3a84e9
2017-07-19 14:29:59 -04:00
Masayuki Nakano
b1f8f6d611 Bug 1377989 - part10: Rename local variables, |parent| which is set to container of nsRange to |container| r=smaug
MozReview-Commit-ID: 9w3O7MJEDBS

--HG--
extra : rebase_source : 92194bd18c9e79210c7cb4e9835a528d51e8ba7a
2017-07-11 23:52:39 +09:00
Masayuki Nakano
4ee17d1b8c Bug 1377989 - part2: Rename nsRange::GetEndParent() to nsRange::GetEndContainer() r=smaug
MozReview-Commit-ID: K4qPjtZ62yO

--HG--
extra : rebase_source : 8653db98b9bd70c77a6aac8d906f401f0222c58a
2017-07-11 21:11:37 +09:00
Masayuki Nakano
2f2ce53be5 Bug 1377989 - part1: Rename nsRange::GetStartParent() to nsRange::GetStartContainer() r=smaug
Web standards use "Container" instead of "Parent".  So, nsRange shouldn't use "Parent" for its members and methods.

MozReview-Commit-ID: Ho6N0diuWtE

--HG--
extra : rebase_source : ee4eb7068a68b118c7fe98e9e9e7fa9c9e7f13e2
2017-07-11 20:53:04 +09:00
Sylvestre Ledru
4e9cf83ee8 Bug 1378712 - Remove all trailing whitespaces r=Ehsan
MozReview-Commit-ID: Kdz2xtTF9EG

--HG--
extra : rebase_source : 7235b3802f25bab29a8c6ba40a181a722f3df0ce
2017-07-06 14:00:35 +02:00
Masayuki Nakano
5a78a77b68 Bug 1375825 - part2: ContentEventHandler::ExpandToClusterBoundary() should check the return value of nsTextFrame::PeekOffsetCharacter() r=jfkthame
ContentEventHandler::ExpandToClusterBoundary() doesn't check the return value of nsTextFrame::PeekOffsetCharacter().  Therefore, it may set its result to reversed offset. (e.g., when aForward is true and offset is 6, the result may be 5.  When aForward is false and offset is 5, the result may be 6.)

For avoiding that, ContentEventHandler::ExpandToClusterBoundary() should check the result and only when it returns nsIFrame::FOUND, it should compute the proper offset.

On the other hand, it's too bad for ContentEventHandler that nsTextFrame::PeekOffsetCharacter() to return nsIFrame::CONTINUE_UNSELECTABLE when the user-select style is "all" because IME doesn't expect such cases.

Therefore, this patch adds additional argument to nsIFrame::PeekOffsetCharacter(), aOptions which is a struct containing bool members.  The reason why it's not a bit mask enum is, such struct doesn't cause simple mistake at checking the value and the code is shorter.  When mIgnoreUserStyleAll of it is true, this patch makes nsTextFrame not return nsIFrame::CONTINUE_UNSELECTABLE.

MozReview-Commit-ID: ACNNBTP92YZ

--HG--
extra : rebase_source : bd85da902e7fb59135d15514cb20a5599a4a640b
2017-06-29 10:58:16 +09:00
Nicholas Nethercote
fe9268c4cd Bug 1374580 (part 2) - Remove nsAFlat{,C}String typedefs. r=froydnj.
All the instances are converted as follows.

- nsAFlatString  --> nsString
- nsAFlatCString --> nsCString

--HG--
extra : rebase_source : b37350642c58a85a08363df2e7c610873faa6e41
2017-06-20 19:19:05 +10:00
Masayuki Nakano
61af94acbd Bug 1367683 Optimize initializing nsRange r=smaug
nsRange::DoSetRange() adds/remove its root to/from mutation observer, initializes common ancestor, registers itself to the common ancestor, unregisters itself from old common ancestor, and notifies selection listeners of selection change.

However, those runtime cost is expensive but on the other hand, a lot of callers set both start and end of the range and that causes calling DoSetRange() twice.

This patch renames Set() to SetStartAndEnd() for easier to understand the meaning and make it call DoSetRange() only once.

MozReview-Commit-ID: FRV55tuBAgg

--HG--
extra : rebase_source : 67adf929cf119e2425f7d3741651217522094590
2017-05-30 13:18:25 +09:00
Emilio Cobos Álvarez
e44543aad4 Bug 1360241: Devirtualize nsIFrame::GetType. r=heycam
MozReview-Commit-ID: 5Nzhyta5Hle

--HG--
extra : rebase_source : c2e9d4bfb9239f5e851d110cd7dff98c1e1a8d8b
2017-04-30 17:30:08 +02:00
Masatoshi Kimura
a4c9e326d4 Bug 1358758 - Use CSSIntRect for nsIFrame::GetScreenRect. r=kats
MozReview-Commit-ID: KXPL1ERbFDa

--HG--
extra : rebase_source : 263b18d1736b09bb62d914f066481281966b288c
2017-04-25 07:33:13 +09:00
Andrea Marchesini
50e007bc26 Bug 1357411 - Use IgnoredErrorResult in dom/events/ContentEventHandler.cpp, r=qdot 2017-04-18 21:11:08 +02:00
Emilio Cobos Álvarez
045eb695b0 Bug 1350050: Remove unneeded nsTextFrame casts in ContentEventHandler. r=smaug
MozReview-Commit-ID: FcSYAuQSHUt

--HG--
extra : rebase_source : 41b23e164e721334923a0f3f16e65be80d4f667f
2017-03-23 20:41:58 +01:00
Cameron McCormack
babad063ff Bug 1328832 - Part 2: Rename mozFlushType to mozilla::FlushType and make it an enum class. r=bzbarsky
MozReview-Commit-ID: D3fIngSHSsl
2017-01-05 15:31:56 +08:00
Andrea Marchesini
793b227795 Bug 1309818 - Fixing some warning when compiling dom/*, r=smaug 2016-10-13 14:33:07 +02:00
Masayuki Nakano
7a28856eef Bug 1304624 ContentEventHandler::GetFlatTextLengthInRange() shouldn't include a line break length caused by the end node's open tag when the given range ends before the open tag r=smaug
This must be a regression of bug 1213589.  When removing whole text from an editor, the editor removes moz-<br> after removing all nodes.  Immediately before the remove, moz-<br> becomes <br>.  So, IMEContentObserver::AttributeChanged() detects the native text length for the <br> element changing from 0 to 2 (on Windows) or 1 (on the other platforms).  However, the call of ContentEventHandler::GetFlatTextLengthInRange() in IMEContentObserver::AttributeChanged() returns 2 (on Windows) or 1 (on the other platforms).  Although, it tries to get the length from the start of the editor to before aElement, it always includes the length of the line breaker caused by the end node.

The reason is, ContentEventHandler::GetFlatTextLengthInRange() always adds the line breaker's length for the end node without checking the range includes open tag of the end node.  Therefore, this patch adds the check into ContentEventHandler::GetFlatTextLengthInRange().  So, ContentEventHandler::GetFlatTextLengthInRange() becomes to support NodePositionBefore() for the end of the range.

Additionally, this patch fixes a bug at appending text node length.  In the loop, |aEndPosition| shouldn't be referred because it may be hacked with |endPosition|.  So, detecting the last text node should be compared with |endPosition|.

For making the method code safer, this changes whole |aEndPosition| after defining |endPosition| is replaced with |endPosition|.

MozReview-Commit-ID: FUp2nxuQHnO

--HG--
extra : rebase_source : 611992faf95082ce8ae005b7bcce90a3bea4f99e
2016-09-29 14:04:15 +09:00
Masayuki Nakano
a1c3cc4ad1 Bug 1296217 ContentEventHandler::OnQueryTextRectArray() should apply CSS transform to each character or line breaker rect r=smaug
Currently, ContentEventHandler::OnQueryTextRectArray() is used only in e10s mode (at caching necessary character rects in ContentCacheInChild).  Therefore, this bug occurs only in e10s mode.

ContentEventHandler::OnQueryTextRectArray() applies CSS transform only to each frame rect.  Therefore, character rect's width and height are not applied.

This patch makes the loop apply CSS transform to each character or line breaker rect (i.e., each item of charRects).  Then, we need to rewrite the lastCharRect hack.  It stores the last charRect value for computing next line breaker rect if next line breaker is caused by a block level element or something, i.e., not caused by a <br> frame.  So, when brRect is computed with lastCharRect, the loop needs to apply CSS transform of the last text frame to the following brRect because it tries to compute a caret rect immediately after the last character.  For doing this, this patch adds lastFrame which stores the last frame for lastCharRect and set it to baseFrame.  Then, at applying CSS transform to each charRect, it can apply CSS transform of expected frame.

Similarly, when brRect is computed with last text frame, this patch looks for the last text frame from lastTextContent and use it as base frame to apply to CSS transform.

MozReview-Commit-ID: 5Yr2HMrooHd

--HG--
extra : rebase_source : fa643f442036d9167a1df3a4383b0802a1729a3e
2016-09-06 11:46:31 +09:00
Masayuki Nakano
7bacea600f Bug 1295354 part.2 ContentEventHandler::GetLastFrameInRangeForTextRect() shouldn't use empty text node as far as possible r=smaug
JS can create empty text nodes. Therefore, ContentEventHandler::GetLastFrameInRangeForTextRect() shouldn't use it for computing retrieving a text frame (Although, such text nodes shouldn't have primary frames).

MozReview-Commit-ID: EJAthEpNZNU

--HG--
extra : rebase_source : ccd05b46911077daa855a5c085839fd14aadc2ee
2016-08-17 14:50:19 +09:00
Masayuki Nakano
0283c8daef Bug 1295354 part.1 ContentEventHandler::GetLastFrameInRangeForTextRect() shouldn't set nextNodeOfRangeEnd to the start node of aRange because the start node should always be in the range r=smaug
nextNodeOfRangeEnd is used for excluding unnecessary node for computing text rect.  When aRange ends at start of a text node, the frames which are created for the text node shouldn't be used.  However, if the end node of aRange is same as the start node of aRange, the node is not outside of aRange.

This could occur when it's called with empty range or there are some empty text nodes.

MozReview-Commit-ID: C1yCN5WrULe

--HG--
extra : rebase_source : 35d5b8feecd351bef29fe4af79a0f6f5bdad8bec
2016-08-16 14:37:40 +09:00
Masayuki Nakano
a000f807cb Bug 1286464 part.19 ContentEventHandler::OnQueryTextRect() should handle the case when queried range starts from the end of mRootContent r=smaug
First, when the first node causing text is invisible, OnQueryTextRect() still fails even with this patch. We shouldn't fix it in this bug because it's unusual case but this bug is very important especially for some web service using HTML editor like Gmail.

This patch fixes all cases when the start offset of queried range reaches the end of mRootContent.

1. When the last node causing text is a <br> element (either content <br> element or moz-<br> element), its frame is a placeholder for empty line.  Therefore, this patch sets the rect to the frame rect.

2. When the last node causing text is a text node, the last frame generated for it represents its line (including empty line).  Therefore, this patch sets the rect to the result of GetLineBreakerRectAfter().

3. When the last node causes a line breaker before it, the frame may be a placeholder for it (this is not usual case, when user types Enter key at the end of <p> element, <p><br></p> is generated by Gecko).  In this case, this patch sets a possible caret rect which is guessed from the content box of the frame and its font height.

4. When there are no nodes causing text in mRootContent, this patch sets a possible caret rect like case #3.

MozReview-Commit-ID: FS9cWJQ39DK

--HG--
extra : rebase_source : cb2ea4cfb4c8d5c85a4dd7498aa11bd86b61c2ef
2016-08-12 14:57:33 +09:00
Masayuki Nakano
95ad200286 Bug 1286464 part.18 ContentEventHandler::OnQueryTextRectArray() should compute line breaker's rect with the last character's node when the start of queried range is a line breaker and it's caused by a block frame r=smaug
Similar to OnQueryTextRect(), OnQueryTextRectArray() should compute a line breaker's rect with the last character when it's the first character in queried range and not caused by <br> frame.

MozReview-Commit-ID: CGDHbcrc6zB

--HG--
extra : rebase_source : 7e7cad1aebc4b1c675360a1a1ff6e704d17c4e5c
2016-08-08 19:05:35 +09:00
Masayuki Nakano
2408130832 Bug 1286464 part.17 ContentEventHandler::OnQueryTextRect() should compute a line breaker's rect from the last text frame if the queried range starts with a block frame r=smaug
When queried range starts with a block frame, we cannot compute proper line breaker's rect at its open tag only with the frame's rect because the proper rect should be at the end of previous text frame.

Therefore, this patch makes SetRangeFromFlatTextOffset() return the last text node found at scanning the range. Then, OnQueryTextRect() can compute the first line breaker's rect with it (if there is at least one text node).

However, if the last text node is hidden by CSS or something, this patch won't work. We need to do something in another bug for hidden frame's issue, though. But note that IME typically doesn't request hidden text's rect because neither selection nor composition string is in such range.

MozReview-Commit-ID: 2FFzNoubJ1y

--HG--
extra : rebase_source : b9c4af40b8747f19da8e55434d580e29322c9601
2016-08-08 18:11:11 +09:00
Masayuki Nakano
7b45431d6c Bug 1286464 part.16 Rename ContentEventHandler::Get*FrameHavingFlatTextInRange() to ContentEventHandler::Get*FrameInRangeForTextRect() and make them treat a moz-<br> element as a normal <br> element because it doesn't cause text but needs to compute text rect in the last empty line r=smaug
In plain text editor, moz-<br> element is appended for a placeholder of empty line when the text ends with a line breaker. Therefore, when we compute text rects, we need to handle it same as a normal <br> element even though it doesn't cause any text.

MozReview-Commit-ID: 4IXLafU6o0W

--HG--
extra : rebase_source : 5db9c70e3acd40e4f47f35fcf293702ce0fb0295
2016-08-02 14:00:32 +09:00
Masayuki Nakano
b933e7c9bb Bug 1286464 part.15 Rewrite ContentEventHandler::OnQueryTextRect() with new utilities like ContentEventHandler::OnQueryTextRectArray() r=smaug
Although, this patch is pretty big and complicated, but I have no idea to separate this since this rewrites all over the OnQueryTextRect() with new utility methods which are implemented for OnQueryTextRectArray().

Currently, OnQueryTextRect() doesn't support line breaks before block level elements. Therefore, in HTML editors, eQueryTextRect may not work fine if the range includes open tags of block level elements. This causes odd positioning of IME's candidate window in non-e10s mode.

This implements ContentEventHandler::GetLastFrameHavingFlatTextInRange() which scans the given range from last to first. However, this hits wrong NS_ASSERTION() in nsContentIterator::Last().  mLast can be nullptr if there is no content but Init() returns NS_OK even in such case.  I think that returning NS_OK is fine because it's not illegal case.  Therefore this patch fixes the wrong assertion.

MozReview-Commit-ID: E6OnIA1eMou

--HG--
extra : rebase_source : e44114b6fb0024c2ab7f9101b12335de4b5cc4aa
2016-08-12 14:11:33 +09:00
Masayuki Nakano
3734289fe2 Bug 1286464 part.14 When ContentEventHandler::OnQueryTextRectArray() reaches the end of query range, it should append caret rect at the end of the content r=smaug
When the loop in ContentEventHandler::OnQueryTextRectArray() reaches at the end of contents, it should append a caret rect at the end of the contents. That helps deciding popup position of IME when caret is at the end of the contents.

This patch guesses the caret rect with eQueryTextRect event (for avoiding the dependency of native caret position of eQueryCaretRect event handler).

MozReview-Commit-ID: 8cGeHpkzX9g

--HG--
extra : rebase_source : c7adc65ccf0fefa7cb1c3bd0b056dc04f8a85b3e
2016-08-05 16:51:49 +09:00
Masayuki Nakano
65203b7481 Bug 1286464 part.13 ContentEventHandler::OnQueryTextRectArray() should guess a line breaker's rect with previous character's rect if it's available r=smaug
This is hack for returning better rect for a line breaker caused by non-<br> element. E.g., if a block frame causes a line break, after the last visible character is the best position, i.e., there is |<p>ABC</p><p>DEF</p>| and the caret is after "C", querying next character's rect should be computed with "C"'s rect, rather than computed with next <p> element's border rect.

MozReview-Commit-ID: 7nXt74GGpNf

--HG--
extra : rebase_source : 14807e98cc9a6be22e6168570a299abf0ecaf267
2016-08-05 14:31:37 +09:00
Masayuki Nakano
0ee732da0b Bug 1286464 part.12 ContentEventHandler::GetFirstFrameHavingFlatTextInRange() should return only frames whose content causes text r=smaug
If it returns frames which don't cause text, the caller needs complicated loop. So, it should return only frames which causes some text.

MozReview-Commit-ID: 9gny0w1PUMa

--HG--
extra : rebase_source : 423c7b57355d659e1a5bd96dac35060cae38801c
2016-07-21 17:45:17 +09:00
Masayuki Nakano
dd3468f808 Bug 1286464 part.10 ContentEventHandler::OnQueryTextRectArray() should append same rects for following characters of a line breaker in nsTextFrame r=smaug
If line breakers in a text node works as is, e.g., |white-space: pre;| is specified, we need to handle line breakers in text frames too.

This patch handles "\n" in text nodes same as line breakers caused by some elements.

MozReview-Commit-ID: JmXesusFxzR

--HG--
extra : rebase_source : dca28a6e4661eef3c8a102916c451e0f021bf6d5
2016-08-05 14:06:30 +09:00
Masayuki Nakano
2a4ac3b7fa Bug 1286464 part.9 ContentEventHandler::OnQueryTextRectArray() shouldn't append same rect for following character of a lien breaker when the query range starts from middle of the line breaker r=smaug
If the query range starts middle of a line breaker, i.e., "\r[\n", ContentEventHandler::OnQueryTextRectArray() does not need to (in other words, should not) append same rect anymore.

This patch checks if the range starts middle of a line breaker and in such case, skip to append same rect.

MozReview-Commit-ID: H5gdtAakGcP

--HG--
extra : rebase_source : 3afaca4d6e9f09e2054c4a6bd876635cfef6c58c
2016-08-05 13:53:08 +09:00
Masayuki Nakano
7826a090ce Bug 1286464 part.8 ContentEventHandler::OnQueryTextRectArray() should handle line break before a node r=smaug
Some elements causes a line break before itself. In such case, OnQueryTextRectArray() should append one or two rects for such line breakers.

This patch also implements GetLineBreakerRectBefore(). It computes line breaker rect for the given frame. Even if it's a <br> frame, we cannot use its rect because <br> frame height is computed with line height but we need text's height (i.e., font height) and both height and width are 0 if it's in quirks mode and in non-empty line.  Therefore, this patch computes it with frame's baseline, font's max-ascent and max-descent.

Although, this patch computes a line breaker rect caused by a open tag of a block level element with block frame's rect. However, it shouldn't be used actually as far as possible.  Following patches will kill the path to the hack.

MozReview-Commit-ID: 9cym04j9NH9

--HG--
extra : rebase_source : 3117d68f056dc69550a16f52adade82049ba8277
2016-08-05 13:36:22 +09:00
Masayuki Nakano
85f2cccc4f Bug 1286464 part.7 ContentEventHandler::OnQueryTextRect() should redirect the query event to OnQueryCaretRect() if its query range is empty r=smaug
When eQueryTextRect's query range length is 0 (this may be caused by native IME's bug), it should return caret rect. Therefore, it should redirect such query events to OnQueryCaretRect(). Such IME must want caret rect in such case.

MozReview-Commit-ID: JaUwhw1Cn5G

--HG--
extra : rebase_source : aef43e028fdf19b1e4977ce0d73e3fd700793ba9
2016-07-25 23:19:53 +09:00
Masayuki Nakano
d170e03f6c Bug 1286464 part.6 ContentEventHandler::OnQueryCaretRect() should use eQueryTextRect event when it needs to guess the caret rect r=smaug
ContentEventHandler::OnQueryTextRect() is now too complicated. So, we shouldn't duplicate similar code in OnQueryCaretRect(). When it needs to guess a caret rect from a character rect, we shouldn't compute character rect by itself.

MozReview-Commit-ID: 5G4MzQJzmoV

--HG--
extra : rebase_source : 31f2ec578eeb2af82b8af2d938448eb42afd50ea
2016-07-29 00:37:09 +09:00
Masayuki Nakano
20e4c11caf Bug 1286464 part.5 Create ContentEventHandler::EnsureNonEmptyRect() for query various rect event handlers r=smaug
This can kill the duplicated code in a lot of places in ContentEventHandler.

MozReview-Commit-ID: BRpBkbXyeBs

--HG--
extra : rebase_source : 98021e68cd0150149e6417c5a8f91979f5baad76
2016-08-05 13:01:17 +09:00
Masayuki Nakano
d8cc4e966b Bug 1286464 part.4 ContentEventHandler::SetRangeFromFlatTextOffset() should set end of the range to after a line break when the range is end between a set of native line breakers r=smaug
Currently, ContentEventHandler::SetRangeFromFlatTextOffset() sets end point to before a line breaker when the end of queried range is between a set of native line breakers (i.e., "\r]\n" on Windows). This causes unexpected empty range (e.g., "[]\n") when it queries a text rect at [\r]\n.

Therefore, it should select an XP line breaker in such case (i.e., the range should be "[\n]" when it queries "[\r]\n" or "\r[\n]").

Note that we don't need to do anything at setting selection start because it's always aligned to before the line breaker.

MozReview-Commit-ID: 6ht8QNAhibY

--HG--
extra : rebase_source : b7933554c2a5bf51b8faabe3a96d006971510e0a
2016-07-28 17:23:47 +09:00
Masayuki Nakano
92692b4cb4 Bug 1286464 part.3 Make static methods, AdjustTextRectNode() and GetFirstFrameInRange(), members of ContentEventHandler r=smaug
This patch makes the static methods members of ContentEventHandler because ContentEventHandler::NodePosition is useful for them.

* nsINode* AdjustTextRectNode(nsINode*, int32_t&) -> NodePosition GetNodeHavingFlatText(nsINode* int32_t)
* nsIFrame* GetFirstFrameInRange(nsRange*, int32_t&) -> FrameAndNodeOffset GetFirstFrameHavingFlatTextInRange(nsRange*)

So, this patch avoids unclear in/out arguments of them.

MozReview-Commit-ID: 7yWeIkRdGj

--HG--
extra : rebase_source : 635cec95ee9f3d73f619186925464ae17010e929
2016-08-05 12:43:40 +09:00
Masayuki Nakano
24e9e4a700 Bug 1286464 part.2 GetFirstFrameInRange() should return node offset since it may return different node's frame r=m_kato
GetFirstFrameInRange() uses AdjustTextRectNode() which may return different node before retrieving the result frame. Therefore, the caller may need offset in the new node.

MozReview-Commit-ID: 2AQU5WfahT9

--HG--
extra : rebase_source : c753d34dc2691da2ec25c9f5a6fe17d67af24a70
2016-07-14 22:57:00 +09:00
Masayuki Nakano
bc5856516b Bug 1286464 part.1 Cleaning up ContentEventHandler::OnQueryTextRectArray() r=m_kato
MozReview-Commit-ID: BDLkQLrzoUI

--HG--
extra : rebase_source : c1b0074bde0580be466259f82d0756ff18e29f53
2016-07-14 22:46:37 +09:00
Masayuki Nakano
8a489e63dd Bug 1257446 part.2 ContentEventHandler::OnQueryTextRectArray() shouldn't set empty rect to the result r=m_kato
Returning empty rects for eQueryTextRectArray causes each dispatcher needing to check every rect. It doesn't make sense especially compared with eQueryTextRect.

So, it should ensure that empty rect won't be returned to dispatchers.

MozReview-Commit-ID: CpMqqihzSDf

--HG--
extra : rebase_source : 0343e2eecf5e25043d260157cf4d8b0874e0ceb6
2016-07-12 20:28:06 +09:00
Masayuki Nakano
f382711dc3 Bug 1260651 part.59 Rename nsEditor to mozilla::EditorBase (and also their file names) r=mccr8
This patch also renames:

EditorInputEventDispatcher -> mozilla::EditorInputEventDispatcher

And some variable names are renamed from aEditor or mEditor to aEditorBase or mEditorBase for making their types clearer.

MozReview-Commit-ID: 2FCXWpLMn8e

--HG--
rename : editor/libeditor/nsEditor.cpp => editor/libeditor/EditorBase.cpp
rename : editor/libeditor/nsEditor.h => editor/libeditor/EditorBase.h
2016-07-08 13:10:13 +09:00
Makoto Kato
689ca97c17 Bug 1203871 - Part 2. Implement eQueryTextRectArray. r=masayuki
It will use on ContentCache.  Also, SetRangeFromFlatTextOffset issue will hanle on another bug.

MozReview-Commit-ID: 9Yu8bLlcZS5

--HG--
extra : rebase_source : c8eba70bdedf303b0fa649c1a609fe6120983e65
extra : histedit_source : 4189807b57ede13c1546e95052fcc298c8581d06
2016-06-23 10:40:04 +01:00
Masayuki Nakano
60bb642e47 Bug 1275528 part.1 Support a way to query content relative to insertion point r=smaug
Native IME handler may want to query content relative to start of selection (or composition if there is it). Additionally, in e10s mode, insertion point in actual content may be different from the cache in parent.  Therefore, in some cases, it does make sense to query content with offset relative to start of selection or composition.

This patch implements it simply and only in non-e10s mode.

Additionally, this fixes a bug of nsQueryContentEventResult::GetOffset() which hasn't been accepted its calls even if the event message is valid (eQueryTextContent, eQueryTextRect and eQueryCaretRect).

MozReview-Commit-ID: 34I7vyTUAgO

--HG--
extra : rebase_source : d79ba0dc3e002f7691495ee1ff8bdb3854d8f6fe
2016-06-16 14:10:49 +09:00
Masayuki Nakano
13d4f396fe Bug 1185307 part.2 Replace upcast from nsISelection to mozilla::dom::Selection with nsISelection::AsSelection() r=smaug
MozReview-Commit-ID: Gs3oiAgJFG9

--HG--
extra : rebase_source : a136405d99ff3361a595157986b3a33026bcd5f5
2016-06-17 22:32:49 +09:00