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

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

Issue 2300463002: Add observers for DIP scale change. (Closed)
Patch Set: Addressed comments Created 4 years, 2 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 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 7854c3e44ecb2dd4432142a395239ddef0b483d0..fe0af7a6a09b3a584e93a25f8bb83f0530c3efe2 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -803,6 +803,15 @@ float ContentViewCoreImpl::GetBottomControlsHeightDip() const {
return GetBottomControlsHeightPix() / dpi_scale();
}
+void ContentViewCoreImpl::ForceLayout() {
boliu 2016/10/19 04:19:18 naming is hard, but definitely avoid overloading t
Tima Vaisburd 2016/10/19 20:25:11 The modestly looking |view->WasResized();| eventua
+ 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;
@@ -868,6 +877,15 @@ void ContentViewCoreImpl::SetFocus(JNIEnv* env,
SetFocusInternal(focused);
}
+void ContentViewCoreImpl::SetDIPScale(JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ jfloat dipScale,
+ jboolean forceLayout) {
+ dpi_scale_ = dipScale;
+ if (forceLayout)
+ ForceLayout();
boliu 2016/10/19 04:19:18 only if changed?
Tima Vaisburd 2016/10/19 20:25:11 Yes, I added that. Now I realized that during repa
+}
+
void ContentViewCoreImpl::SetFocusInternal(bool focused) {
if (!GetRenderWidgetHostViewAndroid())
return;
@@ -1236,16 +1254,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));
view_.GetLayer()->SetBounds(physical_size);
- if (view) {
- web_contents_->SendScreenRects();
- view->WasResized();
- }
+ ForceLayout();
}
long ContentViewCoreImpl::GetNativeImeAdapter(

Powered by Google App Engine
This is Rietveld 408576698