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

Side by Side Diff: third_party/WebKit/Source/web/WebLocalFrameImpl.cpp

Issue 2260283002: Adapt WebRange to only deal with EphemeralRanges. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added back the isNull case, sorry. Created 4 years, 4 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/web/WebRange.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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 frame()->inputMethodController().cancelComposition(); 975 frame()->inputMethodController().cancelComposition();
976 } 976 }
977 977
978 bool WebLocalFrameImpl::hasMarkedText() const 978 bool WebLocalFrameImpl::hasMarkedText() const
979 { 979 {
980 return frame()->inputMethodController().hasComposition(); 980 return frame()->inputMethodController().hasComposition();
981 } 981 }
982 982
983 WebRange WebLocalFrameImpl::markedRange() const 983 WebRange WebLocalFrameImpl::markedRange() const
984 { 984 {
985 return frame()->inputMethodController().compositionRange(); 985 return frame()->inputMethodController().compositionEphemeralRange();
986 } 986 }
987 987
988 bool WebLocalFrameImpl::firstRectForCharacterRange(unsigned location, unsigned l ength, WebRect& rectInViewport) const 988 bool WebLocalFrameImpl::firstRectForCharacterRange(unsigned location, unsigned l ength, WebRect& rectInViewport) const
989 { 989 {
990 if ((location + length < location) && (location + length)) 990 if ((location + length < location) && (location + length))
991 length = 0; 991 length = 0;
992 992
993 Element* editable = frame()->selection().rootEditableElementOrDocumentElemen t(); 993 Element* editable = frame()->selection().rootEditableElementOrDocumentElemen t();
994 if (!editable) 994 if (!editable)
995 return false; 995 return false;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame()); 1102 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame());
1103 if (pluginContainer) 1103 if (pluginContainer)
1104 return pluginContainer->plugin()->hasSelection(); 1104 return pluginContainer->plugin()->hasSelection();
1105 1105
1106 // frame()->selection()->isNone() never returns true. 1106 // frame()->selection()->isNone() never returns true.
1107 return frame()->selection().start() != frame()->selection().end(); 1107 return frame()->selection().start() != frame()->selection().end();
1108 } 1108 }
1109 1109
1110 WebRange WebLocalFrameImpl::selectionRange() const 1110 WebRange WebLocalFrameImpl::selectionRange() const
1111 { 1111 {
1112 return createRange(frame()->selection().selection().toNormalizedEphemeralRan ge()); 1112 return frame()->selection().selection().toNormalizedEphemeralRange();
1113 } 1113 }
1114 1114
1115 WebString WebLocalFrameImpl::selectionAsText() const 1115 WebString WebLocalFrameImpl::selectionAsText() const
1116 { 1116 {
1117 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame()); 1117 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame());
1118 if (pluginContainer) 1118 if (pluginContainer)
1119 return pluginContainer->plugin()->selectionAsText(); 1119 return pluginContainer->plugin()->selectionAsText();
1120 1120
1121 String text = frame()->selection().selectedText(TextIteratorEmitsObjectRepla cementCharacter); 1121 String text = frame()->selection().selectedText(TextIteratorEmitsObjectRepla cementCharacter);
1122 #if OS(WIN) 1122 #if OS(WIN)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 void WebLocalFrameImpl::selectRange(const WebRange& webRange) 1158 void WebLocalFrameImpl::selectRange(const WebRange& webRange)
1159 { 1159 {
1160 TRACE_EVENT0("blink", "WebLocalFrameImpl::selectRange"); 1160 TRACE_EVENT0("blink", "WebLocalFrameImpl::selectRange");
1161 1161
1162 // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets n eeds to be audited. 1162 // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets n eeds to be audited.
1163 // see http://crbug.com/590369 for more details. 1163 // see http://crbug.com/590369 for more details.
1164 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 1164 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets();
1165 1165
1166 DocumentLifecycle::DisallowTransitionScope(frame()->document()->lifecycle()) ; 1166 DocumentLifecycle::DisallowTransitionScope(frame()->document()->lifecycle()) ;
1167 1167
1168 // TODO(dglazkov): Use EphemeralRange here. 1168 frame()->selection().setSelectedRange(webRange.createEphemeralRange(frame()) , VP_DEFAULT_AFFINITY, SelectionDirectionalMode::NonDirectional, NotUserTriggere d);
1169 // See http://crbug.com/636216 for more details.
1170 if (Range* range = webRange.createRange(frame()))
1171 frame()->selection().setSelectedRange(range, VP_DEFAULT_AFFINITY, Select ionDirectionalMode::NonDirectional, NotUserTriggered);
1172 } 1169 }
1173 1170
1174 WebString WebLocalFrameImpl::rangeAsText(const WebRange& webRange) 1171 WebString WebLocalFrameImpl::rangeAsText(const WebRange& webRange)
1175 { 1172 {
1176 // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets n eeds to be audited. 1173 // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets n eeds to be audited.
1177 // see http://crbug.com/590369 for more details. 1174 // see http://crbug.com/590369 for more details.
1178 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 1175 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets();
1179 1176
1180 DocumentLifecycle::DisallowTransitionScope(frame()->document()->lifecycle()) ; 1177 DocumentLifecycle::DisallowTransitionScope(frame()->document()->lifecycle()) ;
1181 1178
1182 // TODO(dglazkov): Use EphemeralRange here. 1179 return plainText(webRange.createEphemeralRange(frame()), TextIteratorEmitsOb jectReplacementCharacter);
1183 // See http://crbug.com/636216 for more details.
1184 if (Range* range = webRange.createRange(frame()))
1185 return range->text();
1186
1187 return WebString();
1188 } 1180 }
1189 1181
1190 void WebLocalFrameImpl::moveRangeSelectionExtent(const WebPoint& point) 1182 void WebLocalFrameImpl::moveRangeSelectionExtent(const WebPoint& point)
1191 { 1183 {
1192 TRACE_EVENT0("blink", "WebLocalFrameImpl::moveRangeSelectionExtent"); 1184 TRACE_EVENT0("blink", "WebLocalFrameImpl::moveRangeSelectionExtent");
1193 frame()->selection().moveRangeSelectionExtent(frame()->view()->viewportToCon tents(point)); 1185 frame()->selection().moveRangeSelectionExtent(frame()->view()->viewportToCon tents(point));
1194 } 1186 }
1195 1187
1196 void WebLocalFrameImpl::moveRangeSelection(const WebPoint& baseInViewport, const WebPoint& extentInViewport, WebFrame::TextGranularity granularity) 1188 void WebLocalFrameImpl::moveRangeSelection(const WebPoint& baseInViewport, const WebPoint& extentInViewport, WebFrame::TextGranularity granularity)
1197 { 1189 {
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after
2245 feature = UseCounter::ChromeLoadTimesNpnNegotiatedProtocol; 2237 feature = UseCounter::ChromeLoadTimesNpnNegotiatedProtocol;
2246 } else if (metric == "wasAlternateProtocolAvailable") { 2238 } else if (metric == "wasAlternateProtocolAvailable") {
2247 feature = UseCounter::ChromeLoadTimesWasAlternateProtocolAvailable; 2239 feature = UseCounter::ChromeLoadTimesWasAlternateProtocolAvailable;
2248 } else if (metric == "connectionInfo") { 2240 } else if (metric == "connectionInfo") {
2249 feature = UseCounter::ChromeLoadTimesConnectionInfo; 2241 feature = UseCounter::ChromeLoadTimesConnectionInfo;
2250 } 2242 }
2251 UseCounter::count(frame(), feature); 2243 UseCounter::count(frame(), feature);
2252 } 2244 }
2253 2245
2254 } // namespace blink 2246 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/web/WebRange.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698