| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/renderer_host/render_widget_host_view_android.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 6 | 6 |
| 7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
| 8 | 8 |
| 9 #include "base/android/build_info.h" | 9 #include "base/android/build_info.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 } | 711 } |
| 712 | 712 |
| 713 void RenderWidgetHostViewAndroid::SelectionChanged(const base::string16& text, | 713 void RenderWidgetHostViewAndroid::SelectionChanged(const base::string16& text, |
| 714 size_t offset, | 714 size_t offset, |
| 715 const gfx::Range& range) { | 715 const gfx::Range& range) { |
| 716 RenderWidgetHostViewBase::SelectionChanged(text, offset, range); | 716 RenderWidgetHostViewBase::SelectionChanged(text, offset, range); |
| 717 | 717 |
| 718 if (selection_controller_) | 718 if (selection_controller_) |
| 719 selection_controller_->OnSelectionEmpty(text.empty()); | 719 selection_controller_->OnSelectionEmpty(text.empty()); |
| 720 | 720 |
| 721 if (text.empty() || range.is_empty() || !content_view_core_) | 721 if (!content_view_core_) |
| 722 return; | 722 return; |
| 723 if (range.is_empty()) { |
| 724 content_view_core_->OnSelectionChanged(""); |
| 725 return; |
| 726 } |
| 727 |
| 728 DCHECK(!text.empty()); |
| 723 size_t pos = range.GetMin() - offset; | 729 size_t pos = range.GetMin() - offset; |
| 724 size_t n = range.length(); | 730 size_t n = range.length(); |
| 725 | 731 |
| 726 DCHECK(pos + n <= text.length()) << "The text can not fully cover range."; | 732 DCHECK(pos + n <= text.length()) << "The text can not fully cover range."; |
| 727 if (pos >= text.length()) { | 733 if (pos >= text.length()) { |
| 728 NOTREACHED() << "The text can not cover range."; | 734 NOTREACHED() << "The text can not cover range."; |
| 729 return; | 735 return; |
| 730 } | 736 } |
| 731 | 737 |
| 732 std::string utf8_selection = base::UTF16ToUTF8(text.substr(pos, n)); | 738 std::string utf8_selection = base::UTF16ToUTF8(text.substr(pos, n)); |
| (...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1742 results->orientationAngle = display.RotationAsDegree(); | 1748 results->orientationAngle = display.RotationAsDegree(); |
| 1743 results->orientationType = | 1749 results->orientationType = |
| 1744 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); | 1750 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); |
| 1745 gfx::DeviceDisplayInfo info; | 1751 gfx::DeviceDisplayInfo info; |
| 1746 results->depth = info.GetBitsPerPixel(); | 1752 results->depth = info.GetBitsPerPixel(); |
| 1747 results->depthPerComponent = info.GetBitsPerComponent(); | 1753 results->depthPerComponent = info.GetBitsPerComponent(); |
| 1748 results->isMonochrome = (results->depthPerComponent == 0); | 1754 results->isMonochrome = (results->depthPerComponent == 0); |
| 1749 } | 1755 } |
| 1750 | 1756 |
| 1751 } // namespace content | 1757 } // namespace content |
| OLD | NEW |