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

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: 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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 // Note that viewport_width/height is a best effort based. 415 // Note that viewport_width/height is a best effort based.
416 // ContentViewCore has the actual information about the physical viewport size. 416 // ContentViewCore has the actual information about the physical viewport size.
417 void ContentViewCoreImpl::UpdateFrameInfo( 417 void ContentViewCoreImpl::UpdateFrameInfo(
418 const gfx::Vector2dF& scroll_offset, 418 const gfx::Vector2dF& scroll_offset,
419 float page_scale_factor, 419 float page_scale_factor,
420 const gfx::Vector2dF& page_scale_factor_limits, 420 const gfx::Vector2dF& page_scale_factor_limits,
421 const gfx::SizeF& content_size, 421 const gfx::SizeF& content_size,
422 const gfx::SizeF& viewport_size, 422 const gfx::SizeF& viewport_size,
423 const gfx::Vector2dF& controls_offset, 423 const gfx::Vector2dF& controls_offset,
424 const gfx::Vector2dF& content_offset, 424 const gfx::Vector2dF& content_offset,
425 const gfx::Vector2dF& bottom_controls_offset,
426 const gfx::Vector2dF& bottom_controls_translate,
425 bool is_mobile_optimized_hint, 427 bool is_mobile_optimized_hint,
426 const gfx::SelectionBound& selection_start) { 428 const gfx::SelectionBound& selection_start) {
427 JNIEnv* env = AttachCurrentThread(); 429 JNIEnv* env = AttachCurrentThread();
428 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 430 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
429 if (obj.is_null() || !window_android_) 431 if (obj.is_null() || !window_android_)
430 return; 432 return;
431 433
432 window_android_->set_content_offset( 434 window_android_->set_content_offset(
433 gfx::ScaleVector2d(content_offset, dpi_scale_)); 435 gfx::ScaleVector2d(content_offset, dpi_scale_));
434 436
(...skipping 17 matching lines...) Expand all
452 scroll_offset.y(), 454 scroll_offset.y(),
453 page_scale_factor, 455 page_scale_factor,
454 page_scale_factor_limits.x(), 456 page_scale_factor_limits.x(),
455 page_scale_factor_limits.y(), 457 page_scale_factor_limits.y(),
456 content_size.width(), 458 content_size.width(),
457 content_size.height(), 459 content_size.height(),
458 viewport_size.width(), 460 viewport_size.width(),
459 viewport_size.height(), 461 viewport_size.height(),
460 controls_offset.y(), 462 controls_offset.y(),
461 content_offset.y(), 463 content_offset.y(),
464 bottom_controls_offset.y(),
465 bottom_controls_translate.y(),
462 is_mobile_optimized_hint, 466 is_mobile_optimized_hint,
463 has_insertion_marker, 467 has_insertion_marker,
464 is_insertion_marker_visible, 468 is_insertion_marker_visible,
465 insertion_marker_horizontal, 469 insertion_marker_horizontal,
466 insertion_marker_top, 470 insertion_marker_top,
467 insertion_marker_bottom); 471 insertion_marker_bottom);
468 } 472 }
469 473
470 void ContentViewCoreImpl::SetTitle(const base::string16& title) { 474 void ContentViewCoreImpl::SetTitle(const base::string16& title) {
471 JNIEnv* env = AttachCurrentThread(); 475 JNIEnv* env = AttachCurrentThread();
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 776
773 gfx::Size size_dip = gfx::ScaleToCeiledSize(size_pix, 1.0f / dpi_scale()); 777 gfx::Size size_dip = gfx::ScaleToCeiledSize(size_pix, 1.0f / dpi_scale());
774 if (DoTopControlsShrinkBlinkSize()) 778 if (DoTopControlsShrinkBlinkSize())
775 size_dip.Enlarge(0, -GetTopControlsHeightDip()); 779 size_dip.Enlarge(0, -GetTopControlsHeightDip());
776 return size_dip; 780 return size_dip;
777 } 781 }
778 782
779 gfx::Size ContentViewCoreImpl::GetViewSize() const { 783 gfx::Size ContentViewCoreImpl::GetViewSize() const {
780 gfx::Size size = GetViewportSizeDip(); 784 gfx::Size size = GetViewportSizeDip();
781 if (DoTopControlsShrinkBlinkSize()) 785 if (DoTopControlsShrinkBlinkSize())
782 size.Enlarge(0, -GetTopControlsHeightDip()); 786 size.Enlarge(0, -GetTopControlsHeightDip() - GetBottomControlsHeightDip());
783 return size; 787 return size;
784 } 788 }
785 789
786 gfx::Size ContentViewCoreImpl::GetPhysicalBackingSize() const { 790 gfx::Size ContentViewCoreImpl::GetPhysicalBackingSize() const {
787 JNIEnv* env = AttachCurrentThread(); 791 JNIEnv* env = AttachCurrentThread();
788 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 792 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
789 if (j_obj.is_null()) 793 if (j_obj.is_null())
790 return gfx::Size(); 794 return gfx::Size();
791 return gfx::Size( 795 return gfx::Size(
792 Java_ContentViewCore_getPhysicalBackingWidthPix(env, j_obj.obj()), 796 Java_ContentViewCore_getPhysicalBackingWidthPix(env, j_obj.obj()),
(...skipping 11 matching lines...) Expand all
804 } 808 }
805 809
806 int ContentViewCoreImpl::GetTopControlsHeightPix() const { 810 int ContentViewCoreImpl::GetTopControlsHeightPix() const {
807 JNIEnv* env = AttachCurrentThread(); 811 JNIEnv* env = AttachCurrentThread();
808 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 812 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
809 if (j_obj.is_null()) 813 if (j_obj.is_null())
810 return 0; 814 return 0;
811 return Java_ContentViewCore_getTopControlsHeightPix(env, j_obj.obj()); 815 return Java_ContentViewCore_getTopControlsHeightPix(env, j_obj.obj());
812 } 816 }
813 817
818 int ContentViewCoreImpl::GetBottomControlsHeightPix() const {
819 JNIEnv* env = AttachCurrentThread();
820 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
821 if (j_obj.is_null())
822 return 0;
823 return Java_ContentViewCore_getBottomControlsHeightPix(env, j_obj.obj());
824 }
825
814 gfx::Size ContentViewCoreImpl::GetViewportSizeDip() const { 826 gfx::Size ContentViewCoreImpl::GetViewportSizeDip() const {
815 return gfx::ScaleToCeiledSize(GetViewportSizePix(), 1.0f / dpi_scale()); 827 return gfx::ScaleToCeiledSize(GetViewportSizePix(), 1.0f / dpi_scale());
816 } 828 }
817 829
818 bool ContentViewCoreImpl::DoTopControlsShrinkBlinkSize() const { 830 bool ContentViewCoreImpl::DoTopControlsShrinkBlinkSize() const {
819 JNIEnv* env = AttachCurrentThread(); 831 JNIEnv* env = AttachCurrentThread();
820 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 832 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
821 if (j_obj.is_null()) 833 if (j_obj.is_null())
822 return false; 834 return false;
823 return Java_ContentViewCore_doTopControlsShrinkBlinkSize(env, j_obj.obj()); 835 return Java_ContentViewCore_doTopControlsShrinkBlinkSize(env, j_obj.obj());
824 } 836 }
825 837
826 float ContentViewCoreImpl::GetTopControlsHeightDip() const { 838 float ContentViewCoreImpl::GetTopControlsHeightDip() const {
827 return GetTopControlsHeightPix() / dpi_scale(); 839 return GetTopControlsHeightPix() / dpi_scale();
828 } 840 }
829 841
842 float ContentViewCoreImpl::GetBottomControlsHeightDip() const {
843 return GetBottomControlsHeightPix() / dpi_scale();
844 }
845
830 void ContentViewCoreImpl::AttachLayer(scoped_refptr<cc::Layer> layer) { 846 void ContentViewCoreImpl::AttachLayer(scoped_refptr<cc::Layer> layer) {
831 root_layer_->InsertChild(layer, 0); 847 root_layer_->InsertChild(layer, 0);
832 root_layer_->SetIsDrawable(false); 848 root_layer_->SetIsDrawable(false);
833 } 849 }
834 850
835 void ContentViewCoreImpl::RemoveLayer(scoped_refptr<cc::Layer> layer) { 851 void ContentViewCoreImpl::RemoveLayer(scoped_refptr<cc::Layer> layer) {
836 layer->RemoveFromParent(); 852 layer->RemoveFromParent();
837 853
838 if (!root_layer_->children().size()) 854 if (!root_layer_->children().size())
839 root_layer_->SetIsDrawable(true); 855 root_layer_->SetIsDrawable(true);
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 return ScopedJavaLocalRef<jobject>(); 1597 return ScopedJavaLocalRef<jobject>();
1582 1598
1583 return view->GetJavaObject(); 1599 return view->GetJavaObject();
1584 } 1600 }
1585 1601
1586 bool RegisterContentViewCore(JNIEnv* env) { 1602 bool RegisterContentViewCore(JNIEnv* env) {
1587 return RegisterNativesImpl(env); 1603 return RegisterNativesImpl(env);
1588 } 1604 }
1589 1605
1590 } // namespace content 1606 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698