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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 795493003: Don't create multiple WebRange objects for getting selection text. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 4039 matching lines...) Expand 10 before | Expand all | Expand 10 after
4050 // If current focused element is editable, we will send 100 more chars 4050 // If current focused element is editable, we will send 100 more chars
4051 // before and after selection. It is for input method surrounding text 4051 // before and after selection. It is for input method surrounding text
4052 // feature. 4052 // feature.
4053 if (location > kExtraCharsBeforeAndAfterSelection) 4053 if (location > kExtraCharsBeforeAndAfterSelection)
4054 offset = location - kExtraCharsBeforeAndAfterSelection; 4054 offset = location - kExtraCharsBeforeAndAfterSelection;
4055 else 4055 else
4056 offset = 0; 4056 offset = 0;
4057 length = location + length - offset + kExtraCharsBeforeAndAfterSelection; 4057 length = location + length - offset + kExtraCharsBeforeAndAfterSelection;
4058 WebRange webrange = WebRange::fromDocumentRange(frame_, offset, length); 4058 WebRange webrange = WebRange::fromDocumentRange(frame_, offset, length);
4059 if (!webrange.isNull()) 4059 if (!webrange.isNull())
4060 text = WebRange::fromDocumentRange( 4060 text = webrange.toPlainText();
4061 frame_, offset, length).toPlainText();
4062 } else { 4061 } else {
4063 offset = location; 4062 offset = location;
4064 text = frame_->selectionAsText(); 4063 text = frame_->selectionAsText();
4065 // http://crbug.com/101435 4064 // http://crbug.com/101435
4066 // In some case, frame->selectionAsText() returned text's length is not 4065 // In some case, frame->selectionAsText() returned text's length is not
4067 // equal to the length returned from webwidget()->caretOrSelectionRange(). 4066 // equal to the length returned from webwidget()->caretOrSelectionRange().
4068 // So we have to set the range according to text.length(). 4067 // So we have to set the range according to text.length().
4069 range.set_end(range.start() + text.length()); 4068 range.set_end(range.start() + text.length());
4070 } 4069 }
4071 } 4070 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
4266 4265
4267 #if defined(ENABLE_BROWSER_CDMS) 4266 #if defined(ENABLE_BROWSER_CDMS)
4268 RendererCdmManager* RenderFrameImpl::GetCdmManager() { 4267 RendererCdmManager* RenderFrameImpl::GetCdmManager() {
4269 if (!cdm_manager_) 4268 if (!cdm_manager_)
4270 cdm_manager_ = new RendererCdmManager(this); 4269 cdm_manager_ = new RendererCdmManager(this);
4271 return cdm_manager_; 4270 return cdm_manager_;
4272 } 4271 }
4273 #endif // defined(ENABLE_BROWSER_CDMS) 4272 #endif // defined(ENABLE_BROWSER_CDMS)
4274 4273
4275 } // namespace content 4274 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698