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

Side by Side Diff: content/browser/android/content_view_core_impl.cc

Issue 2106753004: Introduce bottom controls to CC and let it respond to scrolling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change to height and ratio Created 4 years, 5 months 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
OLDNEW
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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 416
417 // All positions and sizes are in CSS pixels. 417 // All positions and sizes are in CSS pixels.
418 // Note that viewport_width/height is a best effort based. 418 // Note that viewport_width/height is a best effort based.
419 // ContentViewCore has the actual information about the physical viewport size. 419 // ContentViewCore has the actual information about the physical viewport size.
420 void ContentViewCoreImpl::UpdateFrameInfo( 420 void ContentViewCoreImpl::UpdateFrameInfo(
421 const gfx::Vector2dF& scroll_offset, 421 const gfx::Vector2dF& scroll_offset,
422 float page_scale_factor, 422 float page_scale_factor,
423 const gfx::Vector2dF& page_scale_factor_limits, 423 const gfx::Vector2dF& page_scale_factor_limits,
424 const gfx::SizeF& content_size, 424 const gfx::SizeF& content_size,
425 const gfx::SizeF& viewport_size, 425 const gfx::SizeF& viewport_size,
426 const gfx::Vector2dF& controls_offset, 426 const gfx::Vector2dF& top_controls_height,
427 const gfx::Vector2dF& content_offset, 427 const float top_controls_shown_ratio,
428 const gfx::Vector2dF& bottom_controls_height,
429 const float bottom_controls_shown_ratio,
428 bool is_mobile_optimized_hint, 430 bool is_mobile_optimized_hint,
429 const gfx::SelectionBound& selection_start) { 431 const gfx::SelectionBound& selection_start) {
430 JNIEnv* env = AttachCurrentThread(); 432 JNIEnv* env = AttachCurrentThread();
431 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 433 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
432 if (obj.is_null() || !window_android_) 434 if (obj.is_null() || !window_android_)
433 return; 435 return;
434 436
435 window_android_->set_content_offset( 437 window_android_->set_content_offset(gfx::ScaleVector2d(
436 gfx::ScaleVector2d(content_offset, dpi_scale_)); 438 gfx::Vector2dF(0.0f, top_controls_height.y() * top_controls_shown_ratio),
439 dpi_scale_));
437 440
438 page_scale_ = page_scale_factor; 441 page_scale_ = page_scale_factor;
439 442
440 // The CursorAnchorInfo API in Android only supports zero width selection 443 // The CursorAnchorInfo API in Android only supports zero width selection
441 // bounds. 444 // bounds.
442 const jboolean has_insertion_marker = 445 const jboolean has_insertion_marker =
443 selection_start.type() == gfx::SelectionBound::CENTER; 446 selection_start.type() == gfx::SelectionBound::CENTER;
444 const jboolean is_insertion_marker_visible = selection_start.visible(); 447 const jboolean is_insertion_marker_visible = selection_start.visible();
445 const jfloat insertion_marker_horizontal = 448 const jfloat insertion_marker_horizontal =
446 has_insertion_marker ? selection_start.edge_top().x() : 0.0f; 449 has_insertion_marker ? selection_start.edge_top().x() : 0.0f;
447 const jfloat insertion_marker_top = 450 const jfloat insertion_marker_top =
448 has_insertion_marker ? selection_start.edge_top().y() : 0.0f; 451 has_insertion_marker ? selection_start.edge_top().y() : 0.0f;
449 const jfloat insertion_marker_bottom = 452 const jfloat insertion_marker_bottom =
450 has_insertion_marker ? selection_start.edge_bottom().y() : 0.0f; 453 has_insertion_marker ? selection_start.edge_bottom().y() : 0.0f;
451 454
452 Java_ContentViewCore_updateFrameInfo( 455 Java_ContentViewCore_updateFrameInfo(
453 env, obj.obj(), 456 env, obj.obj(),
454 scroll_offset.x(), 457 scroll_offset.x(),
455 scroll_offset.y(), 458 scroll_offset.y(),
456 page_scale_factor, 459 page_scale_factor,
457 page_scale_factor_limits.x(), 460 page_scale_factor_limits.x(),
458 page_scale_factor_limits.y(), 461 page_scale_factor_limits.y(),
459 content_size.width(), 462 content_size.width(),
460 content_size.height(), 463 content_size.height(),
461 viewport_size.width(), 464 viewport_size.width(),
462 viewport_size.height(), 465 viewport_size.height(),
463 controls_offset.y(), 466 top_controls_height.y(),
464 content_offset.y(), 467 top_controls_shown_ratio,
468 bottom_controls_height.y(),
469 bottom_controls_shown_ratio,
465 is_mobile_optimized_hint, 470 is_mobile_optimized_hint,
466 has_insertion_marker, 471 has_insertion_marker,
467 is_insertion_marker_visible, 472 is_insertion_marker_visible,
468 insertion_marker_horizontal, 473 insertion_marker_horizontal,
469 insertion_marker_top, 474 insertion_marker_top,
470 insertion_marker_bottom); 475 insertion_marker_bottom);
471 } 476 }
472 477
473 void ContentViewCoreImpl::SetTitle(const base::string16& title) { 478 void ContentViewCoreImpl::SetTitle(const base::string16& title) {
474 JNIEnv* env = AttachCurrentThread(); 479 JNIEnv* env = AttachCurrentThread();
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 780
776 gfx::Size size_dip = gfx::ScaleToCeiledSize(size_pix, 1.0f / dpi_scale()); 781 gfx::Size size_dip = gfx::ScaleToCeiledSize(size_pix, 1.0f / dpi_scale());
777 if (DoTopControlsShrinkBlinkSize()) 782 if (DoTopControlsShrinkBlinkSize())
778 size_dip.Enlarge(0, -GetTopControlsHeightDip()); 783 size_dip.Enlarge(0, -GetTopControlsHeightDip());
779 return size_dip; 784 return size_dip;
780 } 785 }
781 786
782 gfx::Size ContentViewCoreImpl::GetViewSize() const { 787 gfx::Size ContentViewCoreImpl::GetViewSize() const {
783 gfx::Size size = GetViewportSizeDip(); 788 gfx::Size size = GetViewportSizeDip();
784 if (DoTopControlsShrinkBlinkSize()) 789 if (DoTopControlsShrinkBlinkSize())
785 size.Enlarge(0, -GetTopControlsHeightDip()); 790 size.Enlarge(0, -GetTopControlsHeightDip() - GetBottomControlsHeightDip());
786 return size; 791 return size;
787 } 792 }
788 793
789 gfx::Size ContentViewCoreImpl::GetPhysicalBackingSize() const { 794 gfx::Size ContentViewCoreImpl::GetPhysicalBackingSize() const {
790 JNIEnv* env = AttachCurrentThread(); 795 JNIEnv* env = AttachCurrentThread();
791 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 796 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
792 if (j_obj.is_null()) 797 if (j_obj.is_null())
793 return gfx::Size(); 798 return gfx::Size();
794 return gfx::Size( 799 return gfx::Size(
795 Java_ContentViewCore_getPhysicalBackingWidthPix(env, j_obj.obj()), 800 Java_ContentViewCore_getPhysicalBackingWidthPix(env, j_obj.obj()),
(...skipping 11 matching lines...) Expand all
807 } 812 }
808 813
809 int ContentViewCoreImpl::GetTopControlsHeightPix() const { 814 int ContentViewCoreImpl::GetTopControlsHeightPix() const {
810 JNIEnv* env = AttachCurrentThread(); 815 JNIEnv* env = AttachCurrentThread();
811 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 816 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
812 if (j_obj.is_null()) 817 if (j_obj.is_null())
813 return 0; 818 return 0;
814 return Java_ContentViewCore_getTopControlsHeightPix(env, j_obj.obj()); 819 return Java_ContentViewCore_getTopControlsHeightPix(env, j_obj.obj());
815 } 820 }
816 821
822 int ContentViewCoreImpl::GetBottomControlsHeightPix() const {
823 JNIEnv* env = AttachCurrentThread();
824 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
825 if (j_obj.is_null())
826 return 0;
827 return Java_ContentViewCore_getBottomControlsHeightPix(env, j_obj.obj());
828 }
829
817 gfx::Size ContentViewCoreImpl::GetViewportSizeDip() const { 830 gfx::Size ContentViewCoreImpl::GetViewportSizeDip() const {
818 return gfx::ScaleToCeiledSize(GetViewportSizePix(), 1.0f / dpi_scale()); 831 return gfx::ScaleToCeiledSize(GetViewportSizePix(), 1.0f / dpi_scale());
819 } 832 }
820 833
821 bool ContentViewCoreImpl::DoTopControlsShrinkBlinkSize() const { 834 bool ContentViewCoreImpl::DoTopControlsShrinkBlinkSize() const {
822 JNIEnv* env = AttachCurrentThread(); 835 JNIEnv* env = AttachCurrentThread();
823 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 836 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
824 if (j_obj.is_null()) 837 if (j_obj.is_null())
825 return false; 838 return false;
826 return Java_ContentViewCore_doTopControlsShrinkBlinkSize(env, j_obj.obj()); 839 return Java_ContentViewCore_doTopControlsShrinkBlinkSize(env, j_obj.obj());
827 } 840 }
828 841
829 float ContentViewCoreImpl::GetTopControlsHeightDip() const { 842 float ContentViewCoreImpl::GetTopControlsHeightDip() const {
830 return GetTopControlsHeightPix() / dpi_scale(); 843 return GetTopControlsHeightPix() / dpi_scale();
831 } 844 }
832 845
846 float ContentViewCoreImpl::GetBottomControlsHeightDip() const {
847 return GetBottomControlsHeightPix() / dpi_scale();
848 }
849
833 void ContentViewCoreImpl::AttachLayer(scoped_refptr<cc::Layer> layer) { 850 void ContentViewCoreImpl::AttachLayer(scoped_refptr<cc::Layer> layer) {
834 root_layer_->InsertChild(layer, 0); 851 root_layer_->InsertChild(layer, 0);
835 root_layer_->SetIsDrawable(false); 852 root_layer_->SetIsDrawable(false);
836 } 853 }
837 854
838 void ContentViewCoreImpl::RemoveLayer(scoped_refptr<cc::Layer> layer) { 855 void ContentViewCoreImpl::RemoveLayer(scoped_refptr<cc::Layer> layer) {
839 layer->RemoveFromParent(); 856 layer->RemoveFromParent();
840 857
841 if (!root_layer_->children().size()) 858 if (!root_layer_->children().size())
842 root_layer_->SetIsDrawable(true); 859 root_layer_->SetIsDrawable(true);
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 return ScopedJavaLocalRef<jobject>(); 1659 return ScopedJavaLocalRef<jobject>();
1643 1660
1644 return view->GetJavaObject(); 1661 return view->GetJavaObject();
1645 } 1662 }
1646 1663
1647 bool RegisterContentViewCore(JNIEnv* env) { 1664 bool RegisterContentViewCore(JNIEnv* env) {
1648 return RegisterNativesImpl(env) && JNI_DragEvent::RegisterNativesImpl(env); 1665 return RegisterNativesImpl(env) && JNI_DragEvent::RegisterNativesImpl(env);
1649 } 1666 }
1650 1667
1651 } // namespace content 1668 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698