Chromium Code Reviews| 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 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1026 void FrameSelection::scheduleVisualUpdate() const { | 1026 void FrameSelection::scheduleVisualUpdate() const { |
| 1027 if (Page* page = m_frame->page()) | 1027 if (Page* page = m_frame->page()) |
| 1028 page->animator().scheduleVisualUpdate(m_frame->localFrameRoot()); | 1028 page->animator().scheduleVisualUpdate(m_frame->localFrameRoot()); |
| 1029 } | 1029 } |
| 1030 | 1030 |
| 1031 void FrameSelection::scheduleVisualUpdateForPaintInvalidationIfNeeded() const { | 1031 void FrameSelection::scheduleVisualUpdateForPaintInvalidationIfNeeded() const { |
| 1032 if (FrameView* frameView = m_frame->view()) | 1032 if (FrameView* frameView = m_frame->view()) |
| 1033 frameView->scheduleVisualUpdateForPaintInvalidationIfNeeded(); | 1033 frameView->scheduleVisualUpdateForPaintInvalidationIfNeeded(); |
| 1034 } | 1034 } |
| 1035 | 1035 |
| 1036 static bool hasNonSeparatorCharacter(const String& text) { | |
| 1037 for (unsigned i = 0; i < text.length(); i++) { | |
| 1038 if (!isSeparator(text.characterStartingAt(i))) | |
| 1039 return true; | |
| 1040 } | |
| 1041 return false; | |
| 1042 } | |
| 1043 | |
| 1044 bool FrameSelection::selectWordAroundPosition(const VisiblePosition& position) { | 1036 bool FrameSelection::selectWordAroundPosition(const VisiblePosition& position) { |
| 1045 static const EWordSide wordSideList[2] = {RightWordIfOnBoundary, | 1037 static const EWordSide wordSideList[2] = {RightWordIfOnBoundary, |
| 1046 LeftWordIfOnBoundary}; | 1038 LeftWordIfOnBoundary}; |
| 1047 for (EWordSide wordSide : wordSideList) { | 1039 for (EWordSide wordSide : wordSideList) { |
| 1048 // TODO(yoichio): We should have Position version of |start/endOfWord| | 1040 // TODO(yoichio): We should have Position version of |start/endOfWord| |
| 1049 // for avoiding unnecessary canonicalization. | 1041 // for avoiding unnecessary canonicalization. |
| 1050 // Then we don't need |hasNonSeparatorCharacter|. | 1042 // Then we don't need |hasNonSeparatorCharacter|. |
|
yoichio
2017/03/16 05:41:14
Please remove this line.
rlanday
2017/03/16 16:40:17
Done
| |
| 1051 VisiblePosition start = startOfWord(position, wordSide); | 1043 VisiblePosition start = startOfWord(position, wordSide); |
| 1052 VisiblePosition end = endOfWord(position, wordSide); | 1044 VisiblePosition end = endOfWord(position, wordSide); |
| 1053 String text = | 1045 String text = |
| 1054 plainText(EphemeralRange(start.deepEquivalent(), end.deepEquivalent())); | 1046 plainText(EphemeralRange(start.deepEquivalent(), end.deepEquivalent())); |
| 1055 if (!text.isEmpty() && hasNonSeparatorCharacter(text)) { | 1047 if (!text.isEmpty() && !isSeparator(text.characterStartingAt(0))) { |
| 1056 setSelection(SelectionInDOMTree::Builder() | 1048 setSelection(SelectionInDOMTree::Builder() |
| 1057 .collapse(start.toPositionWithAffinity()) | 1049 .collapse(start.toPositionWithAffinity()) |
| 1058 .extend(end.deepEquivalent()) | 1050 .extend(end.deepEquivalent()) |
| 1059 .build(), | 1051 .build(), |
| 1060 CloseTyping | ClearTypingStyle, | 1052 CloseTyping | ClearTypingStyle, |
| 1061 CursorAlignOnScroll::IfNeeded, WordGranularity); | 1053 CursorAlignOnScroll::IfNeeded, WordGranularity); |
| 1062 return true; | 1054 return true; |
| 1063 } | 1055 } |
| 1064 } | 1056 } |
| 1065 | 1057 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1156 } | 1148 } |
| 1157 | 1149 |
| 1158 void showTree(const blink::FrameSelection* sel) { | 1150 void showTree(const blink::FrameSelection* sel) { |
| 1159 if (sel) | 1151 if (sel) |
| 1160 sel->showTreeForThis(); | 1152 sel->showTreeForThis(); |
| 1161 else | 1153 else |
| 1162 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; | 1154 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; |
| 1163 } | 1155 } |
| 1164 | 1156 |
| 1165 #endif | 1157 #endif |
| OLD | NEW |