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

Unified Diff: content/browser/android/content_view_core_impl.cc

Issue 2480203002: ui: Cleanup class/struct forward declarations (Closed)
Patch Set: Sync CL to position 430550 Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/android/content_view_core_impl.cc
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc
index 5e012e29fa14d8bdd675b78e41dd281e2d8c6bed..2aad65ed5b5b6decf7a34ad900a9f560c674be6d 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -207,12 +207,13 @@ ContentViewCoreImpl::ContentViewCoreImpl(
JNIEnv* env,
const JavaRef<jobject>& obj,
WebContents* web_contents,
+ float dpi_scale,
const JavaRef<jobject>& java_bridge_retained_object_set)
: WebContentsObserver(web_contents),
java_ref_(env, obj),
web_contents_(static_cast<WebContentsImpl*>(web_contents)),
page_scale_(1),
- dpi_scale_(ui::GetScaleFactorForNativeView(GetViewAndroid())),
+ dpi_scale_(dpi_scale),
device_orientation_(0),
accessibility_enabled_(false) {
GetViewAndroid()->SetLayer(cc::Layer::Create());
@@ -786,6 +787,15 @@ float ContentViewCoreImpl::GetBottomControlsHeightDip() const {
return GetBottomControlsHeightPix() / dpi_scale();
}
+void ContentViewCoreImpl::SendScreenRectsAndResizeWidget() {
+ RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid();
+ if (view) {
+ // |SendScreenRects()| indirectly calls GetViewSize() that asks Java layer.
+ web_contents_->SendScreenRects();
+ view->WasResized();
+ }
+}
+
void ContentViewCoreImpl::MoveRangeSelectionExtent(const gfx::PointF& extent) {
if (!web_contents_)
return;
@@ -851,6 +861,16 @@ void ContentViewCoreImpl::SetFocus(JNIEnv* env,
SetFocusInternal(focused);
}
+void ContentViewCoreImpl::SetDIPScale(JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ jfloat dpi_scale) {
+ if (dpi_scale_ == dpi_scale)
+ return;
+
+ dpi_scale_ = dpi_scale;
+ SendScreenRectsAndResizeWidget();
+}
+
void ContentViewCoreImpl::SetFocusInternal(bool focused) {
if (!GetRenderWidgetHostViewAndroid())
return;
@@ -1219,16 +1239,12 @@ void ContentViewCoreImpl::RemoveJavascriptInterface(
void ContentViewCoreImpl::WasResized(JNIEnv* env,
const JavaParamRef<jobject>& obj) {
- RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid();
gfx::Size physical_size(
Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj),
Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj));
GetViewAndroid()->GetLayer()->SetBounds(physical_size);
- if (view) {
- web_contents_->SendScreenRects();
- view->WasResized();
- }
+ SendScreenRectsAndResizeWidget();
}
long ContentViewCoreImpl::GetNativeImeAdapter(
@@ -1536,6 +1552,7 @@ jlong Init(JNIEnv* env,
const JavaParamRef<jobject>& jweb_contents,
const JavaParamRef<jobject>& jview_android_delegate,
jlong jwindow_android,
+ jfloat dipScale,
const JavaParamRef<jobject>& retained_objects_set) {
WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(
WebContents::FromJavaWebContents(jweb_contents));
@@ -1549,8 +1566,9 @@ jlong Init(JNIEnv* env,
DCHECK(window_android);
window_android->AddChild(view_android);
+ // TODO: pass dipScale.
ContentViewCoreImpl* view = new ContentViewCoreImpl(
- env, obj, web_contents, retained_objects_set);
+ env, obj, web_contents, dipScale, retained_objects_set);
return reinterpret_cast<intptr_t>(view);
}
« no previous file with comments | « content/browser/android/content_view_core_impl.h ('k') | content/browser/android/java/gin_java_bridge_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698