| Index: content/browser/android/composited_touch_handle_drawable.cc
|
| diff --git a/content/browser/android/composited_touch_handle_drawable.cc b/content/browser/android/composited_touch_handle_drawable.cc
|
| index 91a019eba89157780bd68ed5d82c979b050d0c88..6811bc57fdfabbb5c970d28ae83c2188e5c85ab7 100644
|
| --- a/content/browser/android/composited_touch_handle_drawable.cc
|
| +++ b/content/browser/android/composited_touch_handle_drawable.cc
|
| @@ -101,30 +101,62 @@ void CompositedTouchHandleDrawable::SetEnabled(bool enabled) {
|
| UpdateLayerPosition();
|
| }
|
|
|
| -void CompositedTouchHandleDrawable::SetOrientation(
|
| - ui::TouchHandleOrientation orientation) {
|
| +void CompositedTouchHandleDrawable::SetLayout(
|
| + const gfx::PointF& position,
|
| + ui::TouchHandleOrientation orientation,
|
| + bool mirror_vertical,
|
| + bool mirror_horizontal,
|
| + bool mirror_changed) {
|
| DCHECK(layer_->parent());
|
| + bool orientation_changed = orientation_ != orientation;
|
| + focal_position_ = gfx::ScalePoint(position, dpi_scale_);
|
| +
|
| orientation_ = orientation;
|
|
|
| - const SkBitmap& bitmap = g_selection_resources.Get().GetBitmap(orientation);
|
| - layer_->SetBitmap(bitmap);
|
| - layer_->SetBounds(gfx::Size(bitmap.width(), bitmap.height()));
|
| + if (orientation_changed) {
|
| + const SkBitmap& bitmap = g_selection_resources.Get().GetBitmap(orientation);
|
| + const int bitmap_height = bitmap.height();
|
| + const int bitmap_width = bitmap.width();
|
| + layer_->SetBitmap(bitmap);
|
| + layer_->SetBounds(gfx::Size(bitmap_width, bitmap_height));
|
| + }
|
| +
|
| + const int layer_height = layer_->bounds().height();
|
| + const int layer_width = layer_->bounds().width();
|
| + // Invert about X and Y axis based on the mirror values
|
| + if (mirror_changed) {
|
| + gfx::Transform transform;
|
| + float scale_x = mirror_horizontal ? -1.f : 1.f;
|
| + float scale_y = mirror_vertical ? -1.f : 1.f;
|
| +
|
| + layer_->SetTransformOrigin(
|
| + gfx::Point3F(layer_width * 0.5f, layer_height * 0.5f, 0));
|
| + transform.Scale(scale_x, scale_y);
|
| + layer_->SetTransform(transform);
|
| + }
|
|
|
| + // Set the Focal offsets for the composited handle layer
|
| + // based on the orientation
|
| + int focal_offset_x = 0;
|
| + int focal_offset_y = mirror_vertical ? layer_height : 0;
|
| switch (orientation_) {
|
| case ui::TouchHandleOrientation::LEFT:
|
| - focal_offset_from_origin_ = gfx::Vector2dF(bitmap.width() * 0.75f, 0);
|
| + focal_offset_x =
|
| + mirror_horizontal ? layer_width * 0.25f : layer_width * 0.75f;
|
| break;
|
| case ui::TouchHandleOrientation::RIGHT:
|
| - focal_offset_from_origin_ = gfx::Vector2dF(bitmap.width() * 0.25f, 0);
|
| + focal_offset_x =
|
| + mirror_horizontal ? layer_width * 0.75f : layer_width * 0.25f;
|
| break;
|
| case ui::TouchHandleOrientation::CENTER:
|
| - focal_offset_from_origin_ = gfx::Vector2dF(bitmap.width() * 0.5f, 0);
|
| + focal_offset_x = layer_width * 0.5f;
|
| break;
|
| case ui::TouchHandleOrientation::UNDEFINED:
|
| NOTREACHED() << "Invalid touch handle orientation.";
|
| break;
|
| };
|
|
|
| + focal_offset_from_origin_ = gfx::Vector2dF(focal_offset_x, focal_offset_y);
|
| UpdateLayerPosition();
|
| }
|
|
|
| @@ -136,12 +168,6 @@ void CompositedTouchHandleDrawable::SetAlpha(float alpha) {
|
| layer_->SetHideLayerAndSubtree(hidden);
|
| }
|
|
|
| -void CompositedTouchHandleDrawable::SetFocus(const gfx::PointF& position) {
|
| - DCHECK(layer_->parent());
|
| - focal_position_ = gfx::ScalePoint(position, dpi_scale_);
|
| - UpdateLayerPosition();
|
| -}
|
| -
|
| gfx::RectF CompositedTouchHandleDrawable::GetVisibleBounds() const {
|
| return gfx::ScaleRect(gfx::RectF(layer_->position().x(),
|
| layer_->position().y(),
|
|
|