Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: third_party/WebKit/Source/core/editing/FrameSelection.cpp

Issue 2723913002: Relax text validation in FrameSelection::selectWordAroundPosition (Closed)
Patch Set: update Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 hasNonSeparatorCharacter(const String& text) {
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.
1092 // Then we don't need |hasNonSeparatorCharacter|.
1082 VisiblePosition start = startOfWord(position, wordSide); 1093 VisiblePosition start = startOfWord(position, wordSide);
1083 VisiblePosition end = endOfWord(position, wordSide); 1094 VisiblePosition end = endOfWord(position, wordSide);
1084 String text = 1095 String text =
1085 plainText(EphemeralRange(start.deepEquivalent(), end.deepEquivalent())); 1096 plainText(EphemeralRange(start.deepEquivalent(), end.deepEquivalent()));
1086 if (!text.isEmpty() && !isSeparator(text.characterStartingAt(0))) { 1097 if (!text.isEmpty() && hasNonSeparatorCharacter(text)) {
1087 setSelection(SelectionInDOMTree::Builder() 1098 setSelection(SelectionInDOMTree::Builder()
1088 .collapse(start.toPositionWithAffinity()) 1099 .collapse(start.toPositionWithAffinity())
1089 .extend(end.deepEquivalent()) 1100 .extend(end.deepEquivalent())
1090 .build(), 1101 .build(),
1091 CloseTyping | ClearTypingStyle, 1102 CloseTyping | ClearTypingStyle,
1092 CursorAlignOnScroll::IfNeeded, WordGranularity); 1103 CursorAlignOnScroll::IfNeeded, WordGranularity);
1093 return true; 1104 return true;
1094 } 1105 }
1095 } 1106 }
1096 1107
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 } 1196 }
1186 1197
1187 void showTree(const blink::FrameSelection* sel) { 1198 void showTree(const blink::FrameSelection* sel) {
1188 if (sel) 1199 if (sel)
1189 sel->showTreeForThis(); 1200 sel->showTreeForThis();
1190 else 1201 else
1191 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; 1202 LOG(INFO) << "Cannot showTree for <null> FrameSelection.";
1192 } 1203 }
1193 1204
1194 #endif 1205 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698