Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 3245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3256 offset = location - kExtraCharsBeforeAndAfterSelection; | 3256 offset = location - kExtraCharsBeforeAndAfterSelection; |
| 3257 else | 3257 else |
| 3258 offset = 0; | 3258 offset = 0; |
| 3259 length = location + length - offset + kExtraCharsBeforeAndAfterSelection; | 3259 length = location + length - offset + kExtraCharsBeforeAndAfterSelection; |
| 3260 WebRange webrange = WebRange::fromDocumentRange(frame, offset, length); | 3260 WebRange webrange = WebRange::fromDocumentRange(frame, offset, length); |
| 3261 if (!webrange.isNull()) | 3261 if (!webrange.isNull()) |
| 3262 text = WebRange::fromDocumentRange(frame, offset, length).toPlainText(); | 3262 text = WebRange::fromDocumentRange(frame, offset, length).toPlainText(); |
| 3263 } else { | 3263 } else { |
| 3264 offset = location; | 3264 offset = location; |
| 3265 text = frame->selectionAsText(); | 3265 text = frame->selectionAsText(); |
| 3266 // http://crbug.com/101435 | |
| 3267 // In some case, frame->selectionAsText() returned text's length is not | |
| 3268 // equal to the length returned from webview()->caretOrSelectionRange(). | |
| 3269 // So we have to set the range according to text.length(). | |
| 3270 range.set_end(range.start() + text.length()); | |
|
James Su
2011/10/28 22:05:26
I'm wondering in which case they are not equal?
| |
| 3266 } | 3271 } |
| 3267 | 3272 |
| 3268 // Sometimes we get repeated didChangeSelection calls from webkit when | 3273 // Sometimes we get repeated didChangeSelection calls from webkit when |
| 3269 // the selection hasn't actually changed. We don't want to report these | 3274 // the selection hasn't actually changed. We don't want to report these |
| 3270 // because it will cause us to continually claim the X clipboard. | 3275 // because it will cause us to continually claim the X clipboard. |
| 3271 if (selection_text_offset_ != offset || | 3276 if (selection_text_offset_ != offset || |
| 3272 selection_range_ != range || | 3277 selection_range_ != range || |
| 3273 selection_text_ != text) { | 3278 selection_text_ != text) { |
| 3274 selection_text_ = text; | 3279 selection_text_ = text; |
| 3275 selection_text_offset_ = offset; | 3280 selection_text_offset_ = offset; |
| (...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4667 return webview()->settings()->useThreadedCompositor(); | 4672 return webview()->settings()->useThreadedCompositor(); |
| 4668 } | 4673 } |
| 4669 | 4674 |
| 4670 void RenderViewImpl::OnJavaBridgeInit( | 4675 void RenderViewImpl::OnJavaBridgeInit( |
| 4671 const IPC::ChannelHandle& channel_handle) { | 4676 const IPC::ChannelHandle& channel_handle) { |
| 4672 DCHECK(!java_bridge_dispatcher_.get()); | 4677 DCHECK(!java_bridge_dispatcher_.get()); |
| 4673 #if defined(ENABLE_JAVA_BRIDGE) | 4678 #if defined(ENABLE_JAVA_BRIDGE) |
| 4674 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this, channel_handle)); | 4679 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this, channel_handle)); |
| 4675 #endif | 4680 #endif |
| 4676 } | 4681 } |
| OLD | NEW |