Skip to content

Commit

Permalink
Move TouchSelectionController from content to ui
Browse files Browse the repository at this point in the history
This patch is only moving new unified touch selection files from
content/ to ui/touch_selection/. This is the first step to allow Aura
use the new unified TouchSelectionController.

The only change to TouchSelectionController needed for this move is
replacing use of cc::ViewportSelectionBound with ui::SelectionBound.

The actual use of the new touch selection for Aura will happen in future
CL(s). After that, we can remove current touch selection code from
ui/base/touch/.

BUG=399721

Review URL: https://codereview.chromium.org/759433002

Cr-Commit-Position: refs/heads/master@{#307336}
  • Loading branch information
mohsen authored and Commit bot committed Dec 8, 2014
1 parent 57e80c7 commit 29fd405
Show file tree
Hide file tree
Showing 49 changed files with 703 additions and 411 deletions.
7 changes: 7 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ group("root") {
"//ui/snapshot",
"//ui/strings",
"//ui/surface",
"//ui/touch_selection",
"//ui/views",
"//ui/views/controls/webview",
"//ui/web_dialogs",
Expand Down Expand Up @@ -297,6 +298,12 @@ group("root") {
]
}

if (is_mac || is_ios) {
deps -= [
"//ui/touch_selection",
]
}

if (is_win) {
deps -= [
"//apps",
Expand Down
2 changes: 1 addition & 1 deletion android_webview/java_library_common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ $(call intermediates-dir-for,GYP,shared)/enums/popup_item_type_java/org/chromium
$(call intermediates-dir-for,GYP,shared)/enums/private_key_types_java/org/chromium/net/PrivateKeyType.java \
$(call intermediates-dir-for,GYP,shared)/enums/result_codes_java/org/chromium/content_public/common/ResultCode.java \
$(call intermediates-dir-for,GYP,shared)/enums/screen_orientation_values_java/org/chromium/content_public/common/ScreenOrientationValues.java \
$(call intermediates-dir-for,GYP,shared)/enums/selection_event_type_java/org/chromium/content/browser/input/SelectionEventType.java \
$(call intermediates-dir-for,GYP,shared)/enums/selection_event_type_java/org/chromium/ui/touch_selection/SelectionEventType.java \
$(call intermediates-dir-for,GYP,shared)/enums/speech_recognition_error_java/org/chromium/content_public/common/SpeechRecognitionErrorCode.java \
$(call intermediates-dir-for,GYP,shared)/enums/top_controls_state_java/org/chromium/content_public/common/TopControlsState.java \
$(call intermediates-dir-for,GYP,shared)/enums/window_open_disposition_java/org/chromium/ui/WindowOpenDisposition.java \
Expand Down
2 changes: 1 addition & 1 deletion android_webview/libwebviewchromium.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
'../content/content.gyp:popup_item_type_java',
'../content/content.gyp:result_codes_java',
'../content/content.gyp:screen_orientation_values_java',
'../content/content.gyp:selection_event_type_java',
'../content/content.gyp:speech_recognition_error_java',
'../content/content.gyp:top_controls_state_java',
'../media/media.gyp:media_android_imageformat',
Expand All @@ -37,6 +36,7 @@
'../ui/android/ui_android.gyp:touch_device_types_java',
'../ui/android/ui_android.gyp:window_open_disposition_java',
'../ui/android/ui_android.gyp:text_input_type_java',
'../ui/touch_selection/ui_touch_selection.gyp:selection_event_type_java',
],
# Enable feedback-directed optimisation for the library when building in
# android.
Expand Down
16 changes: 16 additions & 0 deletions build/all.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
'../url/url.gyp:*',
],
'conditions': [
['OS!="ios" and OS!="mac"', {
'dependencies': [
'../ui/touch_selection/ui_touch_selection.gyp:*',
],
}],
['OS=="ios"', {
'dependencies': [
'../ios/ios.gyp:*',
Expand Down Expand Up @@ -312,6 +317,11 @@
'../url/url.gyp:url_unittests',
],
'conditions': [
['OS!="ios" and OS!="mac"', {
'dependencies': [
'../ui/touch_selection/ui_touch_selection.gyp:ui_touch_selection_unittests',
],
}],
['OS!="ios" and OS!="android"', {
'dependencies': [
'../cc/blink/cc_blink_tests.gyp:cc_blink_unittests',
Expand Down Expand Up @@ -834,6 +844,7 @@
'../tools/android/findbugs_plugin/findbugs_plugin.gyp:findbugs_plugin_test',
'../ui/base/ui_base_tests.gyp:ui_base_unittests',
'../ui/events/events.gyp:events_unittests',
'../ui/touch_selection/ui_touch_selection.gyp:ui_touch_selection_unittests',
# Unit test bundles packaged as an apk.
'../android_webview/android_webview.gyp:android_webview_test_apk',
'../android_webview/android_webview.gyp:android_webview_unittests_apk',
Expand Down Expand Up @@ -862,6 +873,7 @@
'../ui/base/ui_base_tests.gyp:ui_base_unittests_apk',
'../ui/events/events.gyp:events_unittests_apk',
'../ui/gfx/gfx_tests.gyp:gfx_unittests_apk',
'../ui/touch_selection/ui_touch_selection.gyp:ui_touch_selection_unittests_apk',
],
'conditions': [
['enable_webrtc==1 and "<(libpeer_target_type)"=="static_library"', {
Expand Down Expand Up @@ -1075,6 +1087,7 @@
'../ui/base/ui_base_tests.gyp:ui_base_unittests',
'../ui/events/events.gyp:events_unittests',
'../ui/gfx/gfx_tests.gyp:gfx_unittests',
'../ui/touch_selection/ui_touch_selection.gyp:ui_touch_selection_unittests',
'../ui/views/views.gyp:views_unittests',
'../url/url.gyp:url_unittests',
],
Expand Down Expand Up @@ -1179,6 +1192,7 @@
'../ui/events/events.gyp:events_unittests',
'../ui/gfx/gfx_tests.gyp:gfx_unittests',
'../ui/keyboard/keyboard.gyp:keyboard_unittests',
'../ui/touch_selection/ui_touch_selection.gyp:ui_touch_selection_unittests',
'../url/url.gyp:url_unittests',
],
},
Expand Down Expand Up @@ -1219,6 +1233,7 @@
'../third_party/widevine/cdm/widevine_cdm.gyp:widevinecdmadapter',
'../ui/base/ui_base_tests.gyp:ui_base_unittests',
'../ui/gfx/gfx_tests.gyp:gfx_unittests',
'../ui/touch_selection/ui_touch_selection.gyp:ui_touch_selection_unittests',
'../ui/views/views.gyp:views_unittests',
'../url/url.gyp:url_unittests',
],
Expand Down Expand Up @@ -1267,6 +1282,7 @@
'../ui/keyboard/keyboard.gyp:*',
'../ui/message_center/message_center.gyp:*',
'../ui/snapshot/snapshot.gyp:snapshot_unittests',
'../ui/touch_selection/ui_touch_selection.gyp:ui_touch_selection_unittests',
'../ui/views/examples/examples.gyp:views_examples_with_content_exe',
'../ui/views/views.gyp:views',
'../ui/views/views.gyp:views_unittests',
Expand Down
1 change: 1 addition & 0 deletions build/android/pylib/gtest/gtest_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
'sql_unittests',
'sync_unit_tests',
'ui_base_unittests',
'ui_touch_selection_unittests',
'unit_tests',
'webkit_unit_tests',
]
Expand Down
1 change: 1 addition & 0 deletions content/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ include_rules = [
"+ui/snapshot",
"+ui/strings/grit/ui_strings.h",
"+ui/surface",
"+ui/touch_selection",
"+ui/wm",
# Content knows about grd files, but the specifics of how to get a resource
# given its id is left to the embedder.
Expand Down
1 change: 1 addition & 0 deletions content/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ source_set("browser") {
"//third_party/libyuv",
"//ui/resources",
"//ui/surface",
"//ui/touch_selection",
]
}

Expand Down
22 changes: 11 additions & 11 deletions content/browser/android/composited_touch_handle_drawable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ class HandleResources {
center_bitmap_.setImmutable();
}

const SkBitmap& GetBitmap(TouchHandleOrientation orientation) {
const SkBitmap& GetBitmap(ui::TouchHandleOrientation orientation) {
DCHECK(loaded_);
switch (orientation) {
case TOUCH_HANDLE_LEFT:
case ui::TOUCH_HANDLE_LEFT:
return left_bitmap_;
case TOUCH_HANDLE_RIGHT:
case ui::TOUCH_HANDLE_RIGHT:
return right_bitmap_;
case TOUCH_HANDLE_CENTER:
case ui::TOUCH_HANDLE_CENTER:
return center_bitmap_;
case TOUCH_HANDLE_ORIENTATION_UNDEFINED:
case ui::TOUCH_HANDLE_ORIENTATION_UNDEFINED:
NOTREACHED() << "Invalid touch handle orientation.";
};
return center_bitmap_;
Expand All @@ -83,7 +83,7 @@ CompositedTouchHandleDrawable::CompositedTouchHandleDrawable(
float dpi_scale,
jobject context)
: dpi_scale_(dpi_scale),
orientation_(TOUCH_HANDLE_ORIENTATION_UNDEFINED),
orientation_(ui::TOUCH_HANDLE_ORIENTATION_UNDEFINED),
layer_(cc::UIResourceLayer::Create()) {
g_selection_resources.Get().LoadIfNecessary(context);
DCHECK(root_layer);
Expand All @@ -99,7 +99,7 @@ void CompositedTouchHandleDrawable::SetEnabled(bool enabled) {
}

void CompositedTouchHandleDrawable::SetOrientation(
TouchHandleOrientation orientation) {
ui::TouchHandleOrientation orientation) {
DCHECK(layer_->parent());
orientation_ = orientation;

Expand All @@ -108,16 +108,16 @@ void CompositedTouchHandleDrawable::SetOrientation(
layer_->SetBounds(gfx::Size(bitmap.width(), bitmap.height()));

switch (orientation_) {
case TOUCH_HANDLE_LEFT:
case ui::TOUCH_HANDLE_LEFT:
focal_offset_from_origin_ = gfx::Vector2dF(bitmap.width() * 0.75f, 0);
break;
case TOUCH_HANDLE_RIGHT:
case ui::TOUCH_HANDLE_RIGHT:
focal_offset_from_origin_ = gfx::Vector2dF(bitmap.width() * 0.25f, 0);
break;
case TOUCH_HANDLE_CENTER:
case ui::TOUCH_HANDLE_CENTER:
focal_offset_from_origin_ = gfx::Vector2dF(bitmap.width() * 0.5f, 0);
break;
case TOUCH_HANDLE_ORIENTATION_UNDEFINED:
case ui::TOUCH_HANDLE_ORIENTATION_UNDEFINED:
NOTREACHED() << "Invalid touch handle orientation.";
break;
};
Expand Down
10 changes: 5 additions & 5 deletions content/browser/android/composited_touch_handle_drawable.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
#ifndef CONTENT_BROWSER_ANDROID_COMPOSITED_TOUCH_HANDLE_DRAWABLE_H_
#define CONTENT_BROWSER_ANDROID_COMPOSITED_TOUCH_HANDLE_DRAWABLE_H_

#include "content/browser/renderer_host/input/touch_handle.h"
#include "ui/touch_selection/touch_handle.h"

#include "base/android/jni_android.h"
#include "cc/layers/ui_resource_layer.h"

namespace content {

// Touch handle drawable implementation backed by a cc layer.
class CompositedTouchHandleDrawable : public TouchHandleDrawable {
class CompositedTouchHandleDrawable : public ui::TouchHandleDrawable {
public:
CompositedTouchHandleDrawable(cc::Layer* root_layer,
float dpi_scale,
jobject context);
virtual ~CompositedTouchHandleDrawable();

// TouchHandleDrawable implementation.
// ui::TouchHandleDrawable implementation.
virtual void SetEnabled(bool enabled) override;
virtual void SetOrientation(TouchHandleOrientation orientation) override;
virtual void SetOrientation(ui::TouchHandleOrientation orientation) override;
virtual void SetAlpha(float alpha) override;
virtual void SetFocus(const gfx::PointF& position) override;
virtual bool IntersectsWith(const gfx::RectF& rect) const override;
Expand All @@ -34,7 +34,7 @@ class CompositedTouchHandleDrawable : public TouchHandleDrawable {
gfx::RectF BoundingRect() const;

const float dpi_scale_;
TouchHandleOrientation orientation_;
ui::TouchHandleOrientation orientation_;
gfx::PointF focal_position_;
gfx::Vector2dF focal_offset_from_origin_;
scoped_refptr<cc::UIResourceLayer> layer_;
Expand Down
8 changes: 4 additions & 4 deletions content/browser/android/content_view_core_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ void ContentViewCoreImpl::OnSelectionChanged(const std::string& text) {
Java_ContentViewCore_onSelectionChanged(env, obj.obj(), jtext.obj());
}

void ContentViewCoreImpl::OnSelectionEvent(SelectionEventType event,
void ContentViewCoreImpl::OnSelectionEvent(ui::SelectionEventType event,
const gfx::PointF& position) {
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
Expand All @@ -599,15 +599,15 @@ void ContentViewCoreImpl::OnSelectionEvent(SelectionEventType event,
env, j_obj.obj(), event, position.x(), position.y());
}

scoped_ptr<TouchHandleDrawable>
scoped_ptr<ui::TouchHandleDrawable>
ContentViewCoreImpl::CreatePopupTouchHandleDrawable() {
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
if (obj.is_null()) {
NOTREACHED();
return scoped_ptr<TouchHandleDrawable>();
return scoped_ptr<ui::TouchHandleDrawable>();
}
return scoped_ptr<TouchHandleDrawable>(new PopupTouchHandleDrawable(
return scoped_ptr<ui::TouchHandleDrawable>(new PopupTouchHandleDrawable(
Java_ContentViewCore_createPopupTouchHandleDrawable(env, obj.obj()),
dpi_scale_));
}
Expand Down
4 changes: 2 additions & 2 deletions content/browser/android/content_view_core_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ class ContentViewCoreImpl : public ContentViewCore,
InputEventAckState ack_result);
bool FilterInputEvent(const blink::WebInputEvent& event);
void OnSelectionChanged(const std::string& text);
void OnSelectionEvent(SelectionEventType event,
void OnSelectionEvent(ui::SelectionEventType event,
const gfx::PointF& anchor_position);
scoped_ptr<TouchHandleDrawable> CreatePopupTouchHandleDrawable();
scoped_ptr<ui::TouchHandleDrawable> CreatePopupTouchHandleDrawable();

void StartContentIntent(const GURL& content_url);

Expand Down
10 changes: 5 additions & 5 deletions content/browser/android/popup_touch_handle_drawable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@ void PopupTouchHandleDrawable::SetEnabled(bool enabled) {
}

void PopupTouchHandleDrawable::SetOrientation(
TouchHandleOrientation orientation) {
ui::TouchHandleOrientation orientation) {
JNIEnv* env = base::android::AttachCurrentThread();
jobject obj = drawable_.obj();
switch (orientation) {
case TOUCH_HANDLE_LEFT:
case ui::TOUCH_HANDLE_LEFT:
Java_PopupTouchHandleDrawable_setLeftOrientation(env, obj);
break;

case TOUCH_HANDLE_RIGHT:
case ui::TOUCH_HANDLE_RIGHT:
Java_PopupTouchHandleDrawable_setRightOrientation(env, obj);
break;

case TOUCH_HANDLE_CENTER:
case ui::TOUCH_HANDLE_CENTER:
Java_PopupTouchHandleDrawable_setCenterOrientation(env, obj);
break;

case TOUCH_HANDLE_ORIENTATION_UNDEFINED:
case ui::TOUCH_HANDLE_ORIENTATION_UNDEFINED:
NOTREACHED() << "Invalid touch handle orientation.";
};
}
Expand Down
8 changes: 4 additions & 4 deletions content/browser/android/popup_touch_handle_drawable.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
#ifndef CONTENT_BROWSER_ANDROID_POPUP_TOUCH_HANDLE_DRAWABLE_H_
#define CONTENT_BROWSER_ANDROID_POPUP_TOUCH_HANDLE_DRAWABLE_H_

#include "content/browser/renderer_host/input/touch_handle.h"
#include "ui/touch_selection/touch_handle.h"

#include "base/android/jni_android.h"

namespace content {

// Touch handle drawable backed by an Android PopupWindow.
class PopupTouchHandleDrawable : public TouchHandleDrawable {
class PopupTouchHandleDrawable : public ui::TouchHandleDrawable {
public:
PopupTouchHandleDrawable(base::android::ScopedJavaLocalRef<jobject> drawable,
float dpi_scale);
virtual ~PopupTouchHandleDrawable();

// TouchHandleDrawable implementation.
// ui::TouchHandleDrawable implementation.
virtual void SetEnabled(bool enabled) override;
virtual void SetOrientation(TouchHandleOrientation orientation) override;
virtual void SetOrientation(ui::TouchHandleOrientation orientation) override;
virtual void SetAlpha(float alpha) override;
virtual void SetFocus(const gfx::PointF& position) override;
virtual bool IntersectsWith(const gfx::RectF& rect) const override;
Expand Down
Loading

0 comments on commit 29fd405

Please sign in to comment.