Chromium Code Reviews| Index: third_party/WebKit/Source/core/editing/EditingUtilities.cpp |
| diff --git a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp |
| index fed03353f55ed4fa03b8f0b67ffc02d2b62934ef..ce35912d30cecc6e279ef5b555d56c7ae8fd0168 100644 |
| --- a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp |
| +++ b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp |
| @@ -544,7 +544,18 @@ PositionInFlatTree lastEditablePositionBeforePositionInRoot(const PositionInFlat |
| int uncheckedPreviousOffset(const Node* n, int current) |
|
yosin_UTC9
2016/03/25 04:13:30
Could you avoid to use one letter variable name?
Seigo Nonaka
2016/03/25 05:11:22
Done.
|
| { |
| - return n->layoutObject() ? n->layoutObject()->previousOffset(current) : current - 1; |
|
tkent
2016/03/25 04:34:08
Is it ok to remove n->layoutObject() check in the
yosin_UTC9
2016/03/25 04:57:53
Yes. Using |LayoutObject::previousOffset()| is wro
tkent
2016/03/25 05:05:25
I asked about a case of no LayoutObject. Anyway, w
Seigo Nonaka
2016/03/25 05:11:21
Sure, I'm happy to add these test case but let me
Seigo Nonaka
2016/03/25 05:11:22
Thank you for your follow-up comment.
Let me add o
yosin_UTC9
2016/03/25 05:50:04
Oh, sorry for confusion.
|return n->layoutObject(
Seigo Nonaka
2016/03/25 08:02:41
Added test cases for first-letter and text-transfo
yosin_UTC9
2016/03/25 08:18:55
You need to call |updateLayoutAndStyleForPainting(
|
| + if (!n->isTextNode()) |
| + return current - 1; |
| + const String& text = toText(n)->data(); |
| + if (text.is8Bit()) |
| + return current - 1; // TODO(nona): Good to support CR x LF. |
| + TextBreakIterator* iterator = cursorMovementIterator(text.characters16(), text.length()); |
| + if (!iterator) |
| + return current - 1; |
| + long result = iterator->preceding(current); |
|
yosin_UTC9
2016/03/25 04:13:30
|int| is better since |TextBreakIterator::precedin
Seigo Nonaka
2016/03/25 05:11:22
Done.
|
| + if (result == TextBreakDone) |
|
yosin_UTC9
2016/03/25 04:13:30
Use ternary or early return:
return reuslt == Tex
Seigo Nonaka
2016/03/25 05:11:21
Done.
|
| + result = current - 1; |
| + return result; |
| } |
| static int uncheckedPreviousOffsetForBackwardDeletion(const Node* n, int current) |
| @@ -554,7 +565,18 @@ static int uncheckedPreviousOffsetForBackwardDeletion(const Node* n, int current |
| int uncheckedNextOffset(const Node* n, int current) |
| { |
| - return n->layoutObject() ? n->layoutObject()->nextOffset(current) : current + 1; |
| + if (!n->isTextNode()) |
| + return current + 1; |
| + const String& text = toText(n)->data(); |
| + if (text.is8Bit()) |
| + return current + 1; // TODO(nona): Good to support CR x LF. |
| + TextBreakIterator* iterator = cursorMovementIterator(text.characters16(), text.length()); |
| + if (!iterator) |
| + return current + 1; |
| + long result = iterator->following(current); |
|
yosin_UTC9
2016/03/25 04:13:30
|int| is better since |TextBreakIterator::followin
Seigo Nonaka
2016/03/25 05:11:21
Done.
|
| + if (result == TextBreakDone) |
|
yosin_UTC9
2016/03/25 04:13:30
Use ternary or early return:
return reuslt == Tex
Seigo Nonaka
2016/03/25 05:11:22
Done.
|
| + result = current + 1; |
| + return result; |
| } |
| template <typename Strategy> |