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

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

Issue 714003002: Allow changing top controls height (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 6 years 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 "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/android/scoped_java_ref.h" 10 #include "base/android/scoped_java_ref.h"
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 709
710 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 710 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
711 if (obj.is_null()) 711 if (obj.is_null())
712 return ScopedJavaLocalRef<jobject>(); 712 return ScopedJavaLocalRef<jobject>();
713 713
714 return Java_ContentViewCore_getContext(env, obj.obj()); 714 return Java_ContentViewCore_getContext(env, obj.obj());
715 } 715 }
716 716
717 gfx::Size ContentViewCoreImpl::GetViewSize() const { 717 gfx::Size ContentViewCoreImpl::GetViewSize() const {
718 gfx::Size size = GetViewportSizeDip(); 718 gfx::Size size = GetViewportSizeDip();
719 size.Enlarge(0, -GetTopControlsLayoutHeightDip()); 719 if (DoTopControlsShrinkBlinkSize())
720 size.Enlarge(0, -GetTopControlsHeightDip());
720 return size; 721 return size;
721 } 722 }
722 723
723 gfx::Size ContentViewCoreImpl::GetPhysicalBackingSize() const { 724 gfx::Size ContentViewCoreImpl::GetPhysicalBackingSize() const {
724 JNIEnv* env = AttachCurrentThread(); 725 JNIEnv* env = AttachCurrentThread();
725 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 726 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
726 if (j_obj.is_null()) 727 if (j_obj.is_null())
727 return gfx::Size(); 728 return gfx::Size();
728 return gfx::Size( 729 return gfx::Size(
729 Java_ContentViewCore_getPhysicalBackingWidthPix(env, j_obj.obj()), 730 Java_ContentViewCore_getPhysicalBackingWidthPix(env, j_obj.obj()),
730 Java_ContentViewCore_getPhysicalBackingHeightPix(env, j_obj.obj())); 731 Java_ContentViewCore_getPhysicalBackingHeightPix(env, j_obj.obj()));
731 } 732 }
732 733
733 gfx::Size ContentViewCoreImpl::GetViewportSizePix() const { 734 gfx::Size ContentViewCoreImpl::GetViewportSizePix() const {
734 JNIEnv* env = AttachCurrentThread(); 735 JNIEnv* env = AttachCurrentThread();
735 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 736 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
736 if (j_obj.is_null()) 737 if (j_obj.is_null())
737 return gfx::Size(); 738 return gfx::Size();
738 return gfx::Size( 739 return gfx::Size(
739 Java_ContentViewCore_getViewportWidthPix(env, j_obj.obj()), 740 Java_ContentViewCore_getViewportWidthPix(env, j_obj.obj()),
740 Java_ContentViewCore_getViewportHeightPix(env, j_obj.obj())); 741 Java_ContentViewCore_getViewportHeightPix(env, j_obj.obj()));
741 } 742 }
742 743
743 int ContentViewCoreImpl::GetTopControlsLayoutHeightPix() const { 744 int ContentViewCoreImpl::GetTopControlsHeightPix() const {
744 JNIEnv* env = AttachCurrentThread(); 745 JNIEnv* env = AttachCurrentThread();
745 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 746 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
746 if (j_obj.is_null()) 747 if (j_obj.is_null())
747 return 0; 748 return 0;
748 return Java_ContentViewCore_getTopControlsLayoutHeightPix(env, j_obj.obj()); 749 return Java_ContentViewCore_getTopControlsHeightPix(env, j_obj.obj());
749 } 750 }
750 751
751 gfx::Size ContentViewCoreImpl::GetViewportSizeDip() const { 752 gfx::Size ContentViewCoreImpl::GetViewportSizeDip() const {
752 return gfx::ToCeiledSize( 753 return gfx::ToCeiledSize(
753 gfx::ScaleSize(GetViewportSizePix(), 1.0f / dpi_scale())); 754 gfx::ScaleSize(GetViewportSizePix(), 1.0f / dpi_scale()));
754 } 755 }
755 756
756 float ContentViewCoreImpl::GetTopControlsLayoutHeightDip() const { 757 bool ContentViewCoreImpl::DoTopControlsShrinkBlinkSize() const {
757 return GetTopControlsLayoutHeightPix() / dpi_scale(); 758 JNIEnv* env = AttachCurrentThread();
759 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
760 if (j_obj.is_null())
761 return false;
762 return Java_ContentViewCore_doTopControlsShrinkBlinkSize(env, j_obj.obj());
763 }
764
765 float ContentViewCoreImpl::GetTopControlsHeightDip() const {
766 return GetTopControlsHeightPix() / dpi_scale();
758 } 767 }
759 768
760 void ContentViewCoreImpl::AttachLayer(scoped_refptr<cc::Layer> layer) { 769 void ContentViewCoreImpl::AttachLayer(scoped_refptr<cc::Layer> layer) {
761 root_layer_->InsertChild(layer, 0); 770 root_layer_->InsertChild(layer, 0);
762 root_layer_->SetIsDrawable(false); 771 root_layer_->SetIsDrawable(false);
763 } 772 }
764 773
765 void ContentViewCoreImpl::RemoveLayer(scoped_refptr<cc::Layer> layer) { 774 void ContentViewCoreImpl::RemoveLayer(scoped_refptr<cc::Layer> layer) {
766 layer->RemoveFromParent(); 775 layer->RemoveFromParent();
767 776
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 reinterpret_cast<ui::WindowAndroid*>(window_android), 1347 reinterpret_cast<ui::WindowAndroid*>(window_android),
1339 retained_objects_set); 1348 retained_objects_set);
1340 return reinterpret_cast<intptr_t>(view); 1349 return reinterpret_cast<intptr_t>(view);
1341 } 1350 }
1342 1351
1343 bool RegisterContentViewCore(JNIEnv* env) { 1352 bool RegisterContentViewCore(JNIEnv* env) {
1344 return RegisterNativesImpl(env); 1353 return RegisterNativesImpl(env);
1345 } 1354 }
1346 1355
1347 } // namespace content 1356 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/content_view_core_impl.h ('k') | content/browser/renderer_host/compositor_impl_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698