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

Side by Side Diff: ui/android/view_android.cc

Issue 2202123002: Make WebView respond to device scale change (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Made WindowAndroid::content_offset() device scale independent, restored AwContents.onSizeChanged(),… Created 4 years, 4 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ui/android/view_android.h" 5 #include "ui/android/view_android.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "cc/layers/layer.h" 10 #include "cc/layers/layer.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); 123 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
124 if (delegate.is_null()) 124 if (delegate.is_null())
125 return; 125 return;
126 126
127 float scale = display::Screen::GetScreen() 127 float scale = display::Screen::GetScreen()
128 ->GetDisplayNearestWindow(this) 128 ->GetDisplayNearestWindow(this)
129 .device_scale_factor(); 129 .device_scale_factor();
130 int left_margin = std::round(bounds.x() * scale); 130 int left_margin = std::round(bounds.x() * scale);
131 // TODO(jinsukkim): Move content_offset() to ViewAndroid, since it's 131 // TODO(jinsukkim): Move content_offset() to ViewAndroid, since it's
132 // specific to a given web contents/render widget. 132 // specific to a given web contents/render widget.
133 float content_offset_y_pix = GetWindowAndroid()->content_offset().y(); 133 int top_margin = std::round(
134 int top_margin = std::round(content_offset_y_pix + bounds.y() * scale); 134 (GetWindowAndroid()->content_offset().y() + bounds.y()) * scale);
135 JNIEnv* env = base::android::AttachCurrentThread(); 135 JNIEnv* env = base::android::AttachCurrentThread();
136 Java_ViewAndroidDelegate_setViewPosition(env, 136 Java_ViewAndroidDelegate_setViewPosition(env,
137 delegate.obj(), 137 delegate.obj(),
138 anchor.obj(), 138 anchor.obj(),
139 bounds.x(), 139 bounds.x(),
140 bounds.y(), 140 bounds.y(),
141 bounds.width(), 141 bounds.width(),
142 bounds.height(), 142 bounds.height(),
143 scale, 143 scale,
144 left_margin, 144 left_margin,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 if (delegate.is_null()) 184 if (delegate.is_null())
185 return; 185 return;
186 JNIEnv* env = base::android::AttachCurrentThread(); 186 JNIEnv* env = base::android::AttachCurrentThread();
187 Java_ViewAndroidDelegate_startDragAndDrop(env, 187 Java_ViewAndroidDelegate_startDragAndDrop(env,
188 delegate.obj(), 188 delegate.obj(),
189 jtext.obj(), 189 jtext.obj(),
190 jimage.obj()); 190 jimage.obj());
191 } 191 }
192 192
193 } // namespace ui 193 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698