| 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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 // Note that viewport_width/height is a best effort based. | 402 // Note that viewport_width/height is a best effort based. |
| 403 // ContentViewCore has the actual information about the physical viewport size. | 403 // ContentViewCore has the actual information about the physical viewport size. |
| 404 void ContentViewCoreImpl::UpdateFrameInfo( | 404 void ContentViewCoreImpl::UpdateFrameInfo( |
| 405 const gfx::Vector2dF& scroll_offset, | 405 const gfx::Vector2dF& scroll_offset, |
| 406 float page_scale_factor, | 406 float page_scale_factor, |
| 407 const gfx::Vector2dF& page_scale_factor_limits, | 407 const gfx::Vector2dF& page_scale_factor_limits, |
| 408 const gfx::SizeF& content_size, | 408 const gfx::SizeF& content_size, |
| 409 const gfx::SizeF& viewport_size, | 409 const gfx::SizeF& viewport_size, |
| 410 const float top_controls_height, | 410 const float top_controls_height, |
| 411 const float top_controls_shown_ratio, | 411 const float top_controls_shown_ratio, |
| 412 bool is_mobile_optimized_hint, | 412 bool is_mobile_optimized_hint) { |
| 413 const gfx::SelectionBound& selection_start) { | |
| 414 JNIEnv* env = AttachCurrentThread(); | 413 JNIEnv* env = AttachCurrentThread(); |
| 415 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 414 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 416 if (obj.is_null() || !GetWindowAndroid()) | 415 if (obj.is_null() || !GetWindowAndroid()) |
| 417 return; | 416 return; |
| 418 | 417 |
| 419 GetViewAndroid()->set_content_offset( | 418 GetViewAndroid()->set_content_offset( |
| 420 gfx::Vector2dF(0.0f, top_controls_height * top_controls_shown_ratio)); | 419 gfx::Vector2dF(0.0f, top_controls_height * top_controls_shown_ratio)); |
| 421 | 420 |
| 422 page_scale_ = page_scale_factor; | 421 page_scale_ = page_scale_factor; |
| 423 | 422 |
| 424 // The CursorAnchorInfo API in Android only supports zero width selection | |
| 425 // bounds. | |
| 426 const jboolean has_insertion_marker = | |
| 427 selection_start.type() == gfx::SelectionBound::CENTER; | |
| 428 const jboolean is_insertion_marker_visible = selection_start.visible(); | |
| 429 const jfloat insertion_marker_horizontal = | |
| 430 has_insertion_marker ? selection_start.edge_top().x() : 0.0f; | |
| 431 const jfloat insertion_marker_top = | |
| 432 has_insertion_marker ? selection_start.edge_top().y() : 0.0f; | |
| 433 const jfloat insertion_marker_bottom = | |
| 434 has_insertion_marker ? selection_start.edge_bottom().y() : 0.0f; | |
| 435 | |
| 436 Java_ContentViewCore_updateFrameInfo( | 423 Java_ContentViewCore_updateFrameInfo( |
| 437 env, obj, scroll_offset.x(), scroll_offset.y(), page_scale_factor, | 424 env, obj, scroll_offset.x(), scroll_offset.y(), page_scale_factor, |
| 438 page_scale_factor_limits.x(), page_scale_factor_limits.y(), | 425 page_scale_factor_limits.x(), page_scale_factor_limits.y(), |
| 439 content_size.width(), content_size.height(), viewport_size.width(), | 426 content_size.width(), content_size.height(), viewport_size.width(), |
| 440 viewport_size.height(), top_controls_height, top_controls_shown_ratio, | 427 viewport_size.height(), top_controls_height, top_controls_shown_ratio, |
| 441 is_mobile_optimized_hint, has_insertion_marker, | 428 is_mobile_optimized_hint); |
| 442 is_insertion_marker_visible, insertion_marker_horizontal, | |
| 443 insertion_marker_top, insertion_marker_bottom); | |
| 444 } | 429 } |
| 445 | 430 |
| 446 void ContentViewCoreImpl::ShowSelectPopupMenu( | 431 void ContentViewCoreImpl::ShowSelectPopupMenu( |
| 447 RenderFrameHost* frame, | 432 RenderFrameHost* frame, |
| 448 const gfx::Rect& bounds, | 433 const gfx::Rect& bounds, |
| 449 const std::vector<MenuItem>& items, | 434 const std::vector<MenuItem>& items, |
| 450 int selected_item, | 435 int selected_item, |
| 451 bool multiple, | 436 bool multiple, |
| 452 bool right_aligned) { | 437 bool right_aligned) { |
| 453 JNIEnv* env = AttachCurrentThread(); | 438 JNIEnv* env = AttachCurrentThread(); |
| (...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1313 return ScopedJavaLocalRef<jobject>(); | 1298 return ScopedJavaLocalRef<jobject>(); |
| 1314 | 1299 |
| 1315 return view->GetJavaObject(); | 1300 return view->GetJavaObject(); |
| 1316 } | 1301 } |
| 1317 | 1302 |
| 1318 bool RegisterContentViewCore(JNIEnv* env) { | 1303 bool RegisterContentViewCore(JNIEnv* env) { |
| 1319 return RegisterNativesImpl(env); | 1304 return RegisterNativesImpl(env); |
| 1320 } | 1305 } |
| 1321 | 1306 |
| 1322 } // namespace content | 1307 } // namespace content |
| OLD | NEW |