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

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

Issue 2842693005: Store physical backing size in ViewAndroid (Closed)
Patch Set: no cvc/eventf Created 3 years, 7 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 float dpi_scale, 214 float dpi_scale,
215 const JavaRef<jobject>& java_bridge_retained_object_set) 215 const JavaRef<jobject>& java_bridge_retained_object_set)
216 : WebContentsObserver(web_contents), 216 : WebContentsObserver(web_contents),
217 java_ref_(env, obj), 217 java_ref_(env, obj),
218 web_contents_(static_cast<WebContentsImpl*>(web_contents)), 218 web_contents_(static_cast<WebContentsImpl*>(web_contents)),
219 page_scale_(1), 219 page_scale_(1),
220 dpi_scale_(dpi_scale), 220 dpi_scale_(dpi_scale),
221 device_orientation_(0), 221 device_orientation_(0),
222 accessibility_enabled_(false) { 222 accessibility_enabled_(false) {
223 GetViewAndroid()->SetLayer(cc::Layer::Create()); 223 GetViewAndroid()->SetLayer(cc::Layer::Create());
224 gfx::Size physical_size( 224 GetViewAndroid()->UpdateLayerBounds();
boliu 2017/04/29 00:18:40 SetLayer should just do this automatically
Jinsuk Kim 2017/04/30 00:23:50 Done.
225 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj),
226 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj));
227 GetViewAndroid()->GetLayer()->SetBounds(physical_size);
228 225
229 // Currently, the only use case we have for overriding a user agent involves 226 // Currently, the only use case we have for overriding a user agent involves
230 // spoofing a desktop Linux user agent for "Request desktop site". 227 // spoofing a desktop Linux user agent for "Request desktop site".
231 // Automatically set it for all WebContents so that it is available when a 228 // Automatically set it for all WebContents so that it is available when a
232 // NavigationEntry requires the user agent to be overridden. 229 // NavigationEntry requires the user agent to be overridden.
233 const char kLinuxInfoStr[] = "X11; Linux x86_64"; 230 const char kLinuxInfoStr[] = "X11; Linux x86_64";
234 std::string product = content::GetContentClient()->GetProduct(); 231 std::string product = content::GetContentClient()->GetProduct();
235 std::string spoofed_ua = 232 std::string spoofed_ua =
236 BuildUserAgentFromOSAndProduct(kLinuxInfoStr, product); 233 BuildUserAgentFromOSAndProduct(kLinuxInfoStr, product);
237 web_contents->SetUserAgentOverride(spoofed_ua); 234 web_contents->SetUserAgentOverride(spoofed_ua);
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 return Java_ContentViewCore_getContext(env, obj); 646 return Java_ContentViewCore_getContext(env, obj);
650 } 647 }
651 648
652 gfx::Size ContentViewCoreImpl::GetViewSize() const { 649 gfx::Size ContentViewCoreImpl::GetViewSize() const {
653 gfx::Size size = GetViewportSizeDip(); 650 gfx::Size size = GetViewportSizeDip();
654 if (DoBrowserControlsShrinkBlinkSize()) 651 if (DoBrowserControlsShrinkBlinkSize())
655 size.Enlarge(0, -GetTopControlsHeightDip() - GetBottomControlsHeightDip()); 652 size.Enlarge(0, -GetTopControlsHeightDip() - GetBottomControlsHeightDip());
656 return size; 653 return size;
657 } 654 }
658 655
659 gfx::Size ContentViewCoreImpl::GetPhysicalBackingSize() const {
660 JNIEnv* env = AttachCurrentThread();
661 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
662 if (j_obj.is_null())
663 return gfx::Size();
664 return gfx::Size(
665 Java_ContentViewCore_getPhysicalBackingWidthPix(env, j_obj),
666 Java_ContentViewCore_getPhysicalBackingHeightPix(env, j_obj));
667 }
668
669 gfx::Size ContentViewCoreImpl::GetViewportSizePix() const { 656 gfx::Size ContentViewCoreImpl::GetViewportSizePix() const {
670 JNIEnv* env = AttachCurrentThread(); 657 JNIEnv* env = AttachCurrentThread();
671 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 658 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
672 if (j_obj.is_null()) 659 if (j_obj.is_null())
673 return gfx::Size(); 660 return gfx::Size();
674 return gfx::Size(Java_ContentViewCore_getViewportWidthPix(env, j_obj), 661 return gfx::Size(Java_ContentViewCore_getViewportWidthPix(env, j_obj),
675 Java_ContentViewCore_getViewportHeightPix(env, j_obj)); 662 Java_ContentViewCore_getViewportHeightPix(env, j_obj));
676 } 663 }
677 664
678 int ContentViewCoreImpl::GetTopControlsHeightPix() const { 665 int ContentViewCoreImpl::GetTopControlsHeightPix() const {
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 void ContentViewCoreImpl::RemoveJavascriptInterface( 1010 void ContentViewCoreImpl::RemoveJavascriptInterface(
1024 JNIEnv* env, 1011 JNIEnv* env,
1025 const JavaParamRef<jobject>& /* obj */, 1012 const JavaParamRef<jobject>& /* obj */,
1026 const JavaParamRef<jstring>& name) { 1013 const JavaParamRef<jstring>& name) {
1027 java_bridge_dispatcher_host_->RemoveNamedObject( 1014 java_bridge_dispatcher_host_->RemoveNamedObject(
1028 ConvertJavaStringToUTF8(env, name)); 1015 ConvertJavaStringToUTF8(env, name));
1029 } 1016 }
1030 1017
1031 void ContentViewCoreImpl::WasResized(JNIEnv* env, 1018 void ContentViewCoreImpl::WasResized(JNIEnv* env,
1032 const JavaParamRef<jobject>& obj) { 1019 const JavaParamRef<jobject>& obj) {
1033 gfx::Size physical_size( 1020 GetViewAndroid()->UpdateLayerBounds();
boliu 2017/04/29 00:18:40 this intuitively makes no sense, because now that
Jinsuk Kim 2017/04/30 00:23:49 It was added here: https://codereview.chromium.org
1034 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj),
1035 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj));
1036 GetViewAndroid()->GetLayer()->SetBounds(physical_size);
1037
1038 SendScreenRectsAndResizeWidget(); 1021 SendScreenRectsAndResizeWidget();
1039 } 1022 }
1040 1023
1041 void ContentViewCoreImpl::SetAccessibilityEnabled( 1024 void ContentViewCoreImpl::SetAccessibilityEnabled(
1042 JNIEnv* env, 1025 JNIEnv* env,
1043 const JavaParamRef<jobject>& obj, 1026 const JavaParamRef<jobject>& obj,
1044 bool enabled) { 1027 bool enabled) {
1045 SetAccessibilityEnabledInternal(enabled); 1028 SetAccessibilityEnabledInternal(enabled);
1046 } 1029 }
1047 1030
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 return ScopedJavaLocalRef<jobject>(); 1258 return ScopedJavaLocalRef<jobject>();
1276 1259
1277 return view->GetJavaObject(); 1260 return view->GetJavaObject();
1278 } 1261 }
1279 1262
1280 bool RegisterContentViewCore(JNIEnv* env) { 1263 bool RegisterContentViewCore(JNIEnv* env) {
1281 return RegisterNativesImpl(env); 1264 return RegisterNativesImpl(env);
1282 } 1265 }
1283 1266
1284 } // namespace content 1267 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698