OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1068 void FrameSelection::scheduleVisualUpdate() const { | 1068 void FrameSelection::scheduleVisualUpdate() const { |
1069 if (Page* page = m_frame->page()) | 1069 if (Page* page = m_frame->page()) |
1070 page->animator().scheduleVisualUpdate(m_frame->localFrameRoot()); | 1070 page->animator().scheduleVisualUpdate(m_frame->localFrameRoot()); |
1071 } | 1071 } |
1072 | 1072 |
1073 void FrameSelection::scheduleVisualUpdateForPaintInvalidationIfNeeded() const { | 1073 void FrameSelection::scheduleVisualUpdateForPaintInvalidationIfNeeded() const { |
1074 if (FrameView* frameView = m_frame->view()) | 1074 if (FrameView* frameView = m_frame->view()) |
1075 frameView->scheduleVisualUpdateForPaintInvalidationIfNeeded(); | 1075 frameView->scheduleVisualUpdateForPaintInvalidationIfNeeded(); |
1076 } | 1076 } |
1077 | 1077 |
1078 static bool hasWord(const String& text) { | |
yosin_UTC9
2017/03/01 03:31:03
nit: s/hasWord/hasNonSeparatorCharacter/
Since th
yoichio
2017/03/01 03:42:09
Done.
| |
1079 for (unsigned i = 0; i < text.length(); i++) { | |
1080 if (!isSeparator(text.characterStartingAt(i))) | |
1081 return true; | |
1082 } | |
1083 return false; | |
1084 } | |
1085 | |
1078 bool FrameSelection::selectWordAroundPosition(const VisiblePosition& position) { | 1086 bool FrameSelection::selectWordAroundPosition(const VisiblePosition& position) { |
1079 static const EWordSide wordSideList[2] = {RightWordIfOnBoundary, | 1087 static const EWordSide wordSideList[2] = {RightWordIfOnBoundary, |
1080 LeftWordIfOnBoundary}; | 1088 LeftWordIfOnBoundary}; |
1081 for (EWordSide wordSide : wordSideList) { | 1089 for (EWordSide wordSide : wordSideList) { |
1090 // TODO(yoichio): We should have Position version of |start/endOfWord| | |
1091 // for avoiding unnecessary canonicalization. Then we don't need |hasWord|. | |
1082 VisiblePosition start = startOfWord(position, wordSide); | 1092 VisiblePosition start = startOfWord(position, wordSide); |
1083 VisiblePosition end = endOfWord(position, wordSide); | 1093 VisiblePosition end = endOfWord(position, wordSide); |
1084 String text = | 1094 String text = |
1085 plainText(EphemeralRange(start.deepEquivalent(), end.deepEquivalent())); | 1095 plainText(EphemeralRange(start.deepEquivalent(), end.deepEquivalent())); |
1086 if (!text.isEmpty() && !isSeparator(text.characterStartingAt(0))) { | 1096 if (!text.isEmpty() && hasWord(text)) { |
1087 setSelection(SelectionInDOMTree::Builder() | 1097 setSelection(SelectionInDOMTree::Builder() |
1088 .collapse(start.toPositionWithAffinity()) | 1098 .collapse(start.toPositionWithAffinity()) |
1089 .extend(end.deepEquivalent()) | 1099 .extend(end.deepEquivalent()) |
1090 .build(), | 1100 .build(), |
1091 CloseTyping | ClearTypingStyle, | 1101 CloseTyping | ClearTypingStyle, |
1092 CursorAlignOnScroll::IfNeeded, WordGranularity); | 1102 CursorAlignOnScroll::IfNeeded, WordGranularity); |
1093 return true; | 1103 return true; |
1094 } | 1104 } |
1095 } | 1105 } |
1096 | 1106 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1185 } | 1195 } |
1186 | 1196 |
1187 void showTree(const blink::FrameSelection* sel) { | 1197 void showTree(const blink::FrameSelection* sel) { |
1188 if (sel) | 1198 if (sel) |
1189 sel->showTreeForThis(); | 1199 sel->showTreeForThis(); |
1190 else | 1200 else |
1191 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; | 1201 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; |
1192 } | 1202 } |
1193 | 1203 |
1194 #endif | 1204 #endif |
OLD | NEW |