Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/android/content_view_core_impl.h" | 5 #include "content/browser/android/content_view_core_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 jobject obj, | 208 jobject obj, |
| 209 WebContents* web_contents, | 209 WebContents* web_contents, |
| 210 const base::android::JavaRef<jobject>& view_android_delegate, | 210 const base::android::JavaRef<jobject>& view_android_delegate, |
| 211 ui::WindowAndroid* window_android, | 211 ui::WindowAndroid* window_android, |
| 212 jobject java_bridge_retained_object_set) | 212 jobject java_bridge_retained_object_set) |
| 213 : WebContentsObserver(web_contents), | 213 : WebContentsObserver(web_contents), |
| 214 java_ref_(env, obj), | 214 java_ref_(env, obj), |
| 215 view_(view_android_delegate), | 215 view_(view_android_delegate), |
| 216 web_contents_(static_cast<WebContentsImpl*>(web_contents)), | 216 web_contents_(static_cast<WebContentsImpl*>(web_contents)), |
| 217 page_scale_(1), | 217 page_scale_(1), |
| 218 dpi_scale_(ui::GetScaleFactorForNativeView(&view_)), | 218 dpi_scale_(ui::GetScaleFactorForNativeView(&view_)), |
|
no sievers
2016/08/17 19:21:02
so can this be removed now?
Tima Vaisburd
2016/08/17 19:28:38
This CL only does a small cleanup wrt set_content_
boliu
2016/08/17 19:32:38
the question is can dpi_scale_ be removed, and the
| |
| 219 device_orientation_(0), | 219 device_orientation_(0), |
| 220 accessibility_enabled_(false) { | 220 accessibility_enabled_(false) { |
| 221 CHECK(web_contents) << | 221 CHECK(web_contents) << |
| 222 "A ContentViewCoreImpl should be created with a valid WebContents."; | 222 "A ContentViewCoreImpl should be created with a valid WebContents."; |
| 223 DCHECK(window_android); | 223 DCHECK(window_android); |
| 224 DCHECK(!view_android_delegate.is_null()); | 224 DCHECK(!view_android_delegate.is_null()); |
| 225 window_android->AddChild(&view_); | 225 window_android->AddChild(&view_); |
| 226 view_.SetLayer(cc::Layer::Create()); | 226 view_.SetLayer(cc::Layer::Create()); |
| 227 gfx::Size physical_size( | 227 gfx::Size physical_size( |
| 228 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj), | 228 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj), |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 420 const gfx::SizeF& viewport_size, | 420 const gfx::SizeF& viewport_size, |
| 421 const gfx::Vector2dF& controls_offset, | 421 const gfx::Vector2dF& controls_offset, |
| 422 const gfx::Vector2dF& content_offset, | 422 const gfx::Vector2dF& content_offset, |
| 423 bool is_mobile_optimized_hint, | 423 bool is_mobile_optimized_hint, |
| 424 const gfx::SelectionBound& selection_start) { | 424 const gfx::SelectionBound& selection_start) { |
| 425 JNIEnv* env = AttachCurrentThread(); | 425 JNIEnv* env = AttachCurrentThread(); |
| 426 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 426 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 427 if (obj.is_null() || !view_.GetWindowAndroid()) | 427 if (obj.is_null() || !view_.GetWindowAndroid()) |
| 428 return; | 428 return; |
| 429 | 429 |
| 430 view_.GetWindowAndroid()->set_content_offset( | 430 view_.GetWindowAndroid()->set_content_offset(content_offset); |
| 431 gfx::ScaleVector2d(content_offset, dpi_scale_)); | |
| 432 | 431 |
| 433 page_scale_ = page_scale_factor; | 432 page_scale_ = page_scale_factor; |
| 434 | 433 |
| 435 // The CursorAnchorInfo API in Android only supports zero width selection | 434 // The CursorAnchorInfo API in Android only supports zero width selection |
| 436 // bounds. | 435 // bounds. |
| 437 const jboolean has_insertion_marker = | 436 const jboolean has_insertion_marker = |
| 438 selection_start.type() == gfx::SelectionBound::CENTER; | 437 selection_start.type() == gfx::SelectionBound::CENTER; |
| 439 const jboolean is_insertion_marker_visible = selection_start.visible(); | 438 const jboolean is_insertion_marker_visible = selection_start.visible(); |
| 440 const jfloat insertion_marker_horizontal = | 439 const jfloat insertion_marker_horizontal = |
| 441 has_insertion_marker ? selection_start.edge_top().x() : 0.0f; | 440 has_insertion_marker ? selection_start.edge_top().x() : 0.0f; |
| (...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1588 return ScopedJavaLocalRef<jobject>(); | 1587 return ScopedJavaLocalRef<jobject>(); |
| 1589 | 1588 |
| 1590 return view->GetJavaObject(); | 1589 return view->GetJavaObject(); |
| 1591 } | 1590 } |
| 1592 | 1591 |
| 1593 bool RegisterContentViewCore(JNIEnv* env) { | 1592 bool RegisterContentViewCore(JNIEnv* env) { |
| 1594 return RegisterNativesImpl(env); | 1593 return RegisterNativesImpl(env); |
| 1595 } | 1594 } |
| 1596 | 1595 |
| 1597 } // namespace content | 1596 } // namespace content |
| OLD | NEW |