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

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

Issue 481683003: Support for Adaptive Handle Orientation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 5 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/popup_touch_handle_drawable.cc
diff --git a/content/browser/android/popup_touch_handle_drawable.cc b/content/browser/android/popup_touch_handle_drawable.cc
index 7791ddfe452faf63e9b81d2133e810f86057b0f1..28b0525361f45ce0e3dc6773ea8a094b9d5e1931 100644
--- a/content/browser/android/popup_touch_handle_drawable.cc
+++ b/content/browser/android/popup_touch_handle_drawable.cc
@@ -29,6 +29,8 @@ PopupTouchHandleDrawable::PopupTouchHandleDrawable(JNIEnv* env,
float dpi_scale)
: java_ref_(env, obj), dpi_scale_(dpi_scale) {
DCHECK(!java_ref_.is_empty());
+ drawable_horizontal_padding_ratio_ =
+ Java_PopupTouchHandleDrawable_getHandleHorizontalPaddingRatio(env, obj);
}
PopupTouchHandleDrawable::~PopupTouchHandleDrawable() {
@@ -50,31 +52,34 @@ void PopupTouchHandleDrawable::SetEnabled(bool enabled) {
}
void PopupTouchHandleDrawable::SetOrientation(
- ui::TouchHandleOrientation orientation) {
+ ui::TouchHandleOrientation orientation,
+ bool mirror_vertical,
+ bool mirror_horizontal) {
JNIEnv* env = base::android::AttachCurrentThread();
ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
if (!obj.is_null()) {
- Java_PopupTouchHandleDrawable_setOrientation(env, obj.obj(),
- static_cast<int>(orientation));
+ Java_PopupTouchHandleDrawable_setOrientation(
+ env, obj.obj(), static_cast<int>(orientation), mirror_vertical,
+ mirror_horizontal);
}
}
-void PopupTouchHandleDrawable::SetAlpha(float alpha) {
+void PopupTouchHandleDrawable::SetOrigin(const gfx::PointF& origin) {
JNIEnv* env = base::android::AttachCurrentThread();
ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
- bool visible = alpha > 0;
- if (!obj.is_null())
- Java_PopupTouchHandleDrawable_setVisible(env, obj.obj(), visible);
+ if (!obj.is_null()) {
+ const gfx::PointF origin_pix = gfx::ScalePoint(origin, dpi_scale_);
+ Java_PopupTouchHandleDrawable_setOrigin(env, obj.obj(), origin_pix.x(),
+ origin_pix.y());
+ }
}
-void PopupTouchHandleDrawable::SetFocus(const gfx::PointF& position) {
- const gfx::PointF position_pix = gfx::ScalePoint(position, dpi_scale_);
+void PopupTouchHandleDrawable::SetAlpha(float alpha) {
JNIEnv* env = base::android::AttachCurrentThread();
ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
- if (!obj.is_null()) {
- Java_PopupTouchHandleDrawable_setFocus(env, obj.obj(), position_pix.x(),
- position_pix.y());
- }
+ bool visible = alpha > 0;
+ if (!obj.is_null())
+ Java_PopupTouchHandleDrawable_setVisible(env, obj.obj(), visible);
}
gfx::RectF PopupTouchHandleDrawable::GetVisibleBounds() const {
@@ -90,6 +95,10 @@ gfx::RectF PopupTouchHandleDrawable::GetVisibleBounds() const {
return gfx::ScaleRect(unscaled_rect, 1.f / dpi_scale_);
}
+float PopupTouchHandleDrawable::GetDrawableHorizontalPaddingRatio() const {
+ return drawable_horizontal_padding_ratio_;
+}
+
// static
bool PopupTouchHandleDrawable::RegisterPopupTouchHandleDrawable(JNIEnv* env) {
return RegisterNativesImpl(env);

Powered by Google App Engine
This is Rietveld 408576698