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

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

Issue 2300463002: Add observers for DIP scale change. (Closed)
Patch Set: Do not force layout during initialization. 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..4c056c0fc80b89f50ba982f97e2b4cee89aa7dd3 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -215,7 +215,7 @@ ContentViewCoreImpl::ContentViewCoreImpl(
view_(view_android_delegate),
web_contents_(static_cast<WebContentsImpl*>(web_contents)),
page_scale_(1),
- dpi_scale_(ui::GetScaleFactorForNativeView(&view_)),
+ dpi_scale_(1),
boliu 2016/10/18 00:26:25 why is this change needed?
Tima Vaisburd 2016/10/19 01:15:54 It is actually not needed, but I wanted to make it
device_orientation_(0),
accessibility_enabled_(false) {
CHECK(web_contents) <<
@@ -803,6 +803,15 @@ float ContentViewCoreImpl::GetBottomControlsHeightDip() const {
return GetBottomControlsHeightPix() / dpi_scale();
}
+void ContentViewCoreImpl::ForceLayout() {
boliu 2016/10/18 00:26:25 just call this "WasResized"?
Tima Vaisburd 2016/10/19 01:15:54 WasResized() already existed, now it sets the phys
+ 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();
+}
+
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