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

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

Issue 1412713003: Reland 'Use FrameSelection::selectedText where possible.' Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use SelectionEditor::setWithoutValidation. Created 5 years, 1 month 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 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 { 1228 {
1229 return createRange(frame()->selection().selection().toNormalizedEphemeralRan ge()); 1229 return createRange(frame()->selection().selection().toNormalizedEphemeralRan ge());
1230 } 1230 }
1231 1231
1232 WebString WebLocalFrameImpl::selectionAsText() const 1232 WebString WebLocalFrameImpl::selectionAsText() const
1233 { 1233 {
1234 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame()); 1234 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame());
1235 if (pluginContainer) 1235 if (pluginContainer)
1236 return pluginContainer->plugin()->selectionAsText(); 1236 return pluginContainer->plugin()->selectionAsText();
1237 1237
1238 const EphemeralRange range = frame()->selection().selection().toNormalizedEp hemeralRange(); 1238 String text = frame()->selection().selectedText(TextIteratorEmitsObjectRepla cementCharacter);
1239 if (range.isNull())
1240 return WebString();
1241
1242 String text = plainText(range, TextIteratorEmitsObjectReplacementCharacter);
1243 #if OS(WIN) 1239 #if OS(WIN)
1244 replaceNewlinesWithWindowsStyleNewlines(text); 1240 replaceNewlinesWithWindowsStyleNewlines(text);
1245 #endif 1241 #endif
1246 replaceNBSPWithSpace(text); 1242 replaceNBSPWithSpace(text);
1247 return text; 1243 return text;
1248 } 1244 }
1249 1245
1250 WebString WebLocalFrameImpl::selectionAsMarkup() const 1246 WebString WebLocalFrameImpl::selectionAsMarkup() const
1251 { 1247 {
1252 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame()); 1248 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame());
1253 if (pluginContainer) 1249 if (pluginContainer)
1254 return pluginContainer->plugin()->selectionAsMarkup(); 1250 return pluginContainer->plugin()->selectionAsMarkup();
1255 1251
1256 const EphemeralRange range = frame()->selection().selection().toNormalizedEp hemeralRange(); 1252 return frame()->selection().selectedHTMLForClipboard();
1257 if (range.isNull())
1258 return WebString();
1259
1260 return createMarkup(range.startPosition(), range.endPosition(), AnnotateForI nterchange, ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs);
1261 } 1253 }
1262 1254
1263 void WebLocalFrameImpl::selectWordAroundPosition(LocalFrame* frame, VisiblePosit ion position) 1255 void WebLocalFrameImpl::selectWordAroundPosition(LocalFrame* frame, VisiblePosit ion position)
1264 { 1256 {
1265 TRACE_EVENT0("blink", "WebLocalFrameImpl::selectWordAroundPosition"); 1257 TRACE_EVENT0("blink", "WebLocalFrameImpl::selectWordAroundPosition");
1266 frame->selection().selectWordAroundPosition(position); 1258 frame->selection().selectWordAroundPosition(position);
1267 } 1259 }
1268 1260
1269 bool WebLocalFrameImpl::selectWordAroundCaret() 1261 bool WebLocalFrameImpl::selectWordAroundCaret()
1270 { 1262 {
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
2192 } 2184 }
2193 2185
2194 WebSandboxFlags WebLocalFrameImpl::effectiveSandboxFlags() const 2186 WebSandboxFlags WebLocalFrameImpl::effectiveSandboxFlags() const
2195 { 2187 {
2196 if (!frame()) 2188 if (!frame())
2197 return WebSandboxFlags::None; 2189 return WebSandboxFlags::None;
2198 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags( )); 2190 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags( ));
2199 } 2191 }
2200 2192
2201 } // namespace blink 2193 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698