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

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

Issue 1377963004: Use FrameSelection::selectedText where possible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update layout in HTMLTextFormControlElement::setSelectionRange. Created 5 years, 2 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
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 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 { 1234 {
1235 return createRange(frame()->selection().selection().toNormalizedEphemeralRan ge()); 1235 return createRange(frame()->selection().selection().toNormalizedEphemeralRan ge());
1236 } 1236 }
1237 1237
1238 WebString WebLocalFrameImpl::selectionAsText() const 1238 WebString WebLocalFrameImpl::selectionAsText() const
1239 { 1239 {
1240 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame()); 1240 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame());
1241 if (pluginContainer) 1241 if (pluginContainer)
1242 return pluginContainer->plugin()->selectionAsText(); 1242 return pluginContainer->plugin()->selectionAsText();
1243 1243
1244 const EphemeralRange range = frame()->selection().selection().toNormalizedEp hemeralRange(); 1244 String text = frame()->selection().selectedText(TextIteratorEmitsObjectRepla cementCharacter);
1245 if (range.isNull())
1246 return WebString();
1247
1248 String text = plainText(range, TextIteratorEmitsObjectReplacementCharacter);
1249 #if OS(WIN) 1245 #if OS(WIN)
1250 replaceNewlinesWithWindowsStyleNewlines(text); 1246 replaceNewlinesWithWindowsStyleNewlines(text);
1251 #endif 1247 #endif
1252 replaceNBSPWithSpace(text); 1248 replaceNBSPWithSpace(text);
1253 return text; 1249 return text;
1254 } 1250 }
1255 1251
1256 WebString WebLocalFrameImpl::selectionAsMarkup() const 1252 WebString WebLocalFrameImpl::selectionAsMarkup() const
1257 { 1253 {
1258 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame()); 1254 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame());
1259 if (pluginContainer) 1255 if (pluginContainer)
1260 return pluginContainer->plugin()->selectionAsMarkup(); 1256 return pluginContainer->plugin()->selectionAsMarkup();
1261 1257
1262 const EphemeralRange range = frame()->selection().selection().toNormalizedEp hemeralRange(); 1258 return frame()->selection().selectedHTMLForClipboard();
1263 if (range.isNull())
1264 return WebString();
1265
1266 return createMarkup(range.startPosition(), range.endPosition(), AnnotateForI nterchange, ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs);
1267 } 1259 }
1268 1260
1269 void WebLocalFrameImpl::selectWordAroundPosition(LocalFrame* frame, VisiblePosit ion position) 1261 void WebLocalFrameImpl::selectWordAroundPosition(LocalFrame* frame, VisiblePosit ion position)
1270 { 1262 {
1271 TRACE_EVENT0("blink", "WebLocalFrameImpl::selectWordAroundPosition"); 1263 TRACE_EVENT0("blink", "WebLocalFrameImpl::selectWordAroundPosition");
1272 frame->selection().selectWordAroundPosition(position); 1264 frame->selection().selectWordAroundPosition(position);
1273 } 1265 }
1274 1266
1275 bool WebLocalFrameImpl::selectWordAroundCaret() 1267 bool WebLocalFrameImpl::selectWordAroundCaret()
1276 { 1268 {
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
2198 } 2190 }
2199 2191
2200 WebSandboxFlags WebLocalFrameImpl::effectiveSandboxFlags() const 2192 WebSandboxFlags WebLocalFrameImpl::effectiveSandboxFlags() const
2201 { 2193 {
2202 if (!frame()) 2194 if (!frame())
2203 return WebSandboxFlags::None; 2195 return WebSandboxFlags::None;
2204 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags( )); 2196 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags( ));
2205 } 2197 }
2206 2198
2207 } // namespace blink 2199 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698