Skip to content

Commit

Permalink
Pointer/hover media query support: platform-independent changes
Browse files Browse the repository at this point in the history
Platform-independent changes on our way to support pointer, any-pointer, hover and any-hover media queries.
http://dev.w3.org/csswg/mediaqueries-4/#mf-interaction

This will be followed by platform-specific changes. For example, crrev.com/696713002 adds Android-specific changes this CL.

BUG=136119

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

Cr-Commit-Position: refs/heads/master@{#304126}
  • Loading branch information
mustaqahmed authored and Commit bot committed Nov 14, 2014
1 parent f26779f commit 29eb709
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 0 deletions.
10 changes: 10 additions & 0 deletions content/public/common/common_param_traits_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ IPC_ENUM_TRAITS_MAX_VALUE(content::V8CacheOptions,
content::V8_CACHE_OPTIONS_LAST)
IPC_ENUM_TRAITS_MAX_VALUE(content::V8ScriptStreamingMode,
content::V8_SCRIPT_STREAMING_MODE_LAST)
IPC_ENUM_TRAITS_MIN_MAX_VALUE(ui::PointerType,
ui::POINTER_TYPE_FIRST,
ui::POINTER_TYPE_LAST)
IPC_ENUM_TRAITS_MIN_MAX_VALUE(ui::HoverType,
ui::HOVER_TYPE_FIRST,
ui::HOVER_TYPE_LAST)

IPC_STRUCT_TRAITS_BEGIN(blink::WebPoint)
IPC_STRUCT_TRAITS_MEMBER(x)
Expand Down Expand Up @@ -165,6 +171,10 @@ IPC_STRUCT_TRAITS_BEGIN(content::WebPreferences)
IPC_STRUCT_TRAITS_MEMBER(device_supports_mouse)
IPC_STRUCT_TRAITS_MEMBER(touch_adjustment_enabled)
IPC_STRUCT_TRAITS_MEMBER(pointer_events_max_touch_points)
IPC_STRUCT_TRAITS_MEMBER(available_pointer_types)
IPC_STRUCT_TRAITS_MEMBER(primary_pointer_type)
IPC_STRUCT_TRAITS_MEMBER(available_hover_types)
IPC_STRUCT_TRAITS_MEMBER(primary_hover_type)
IPC_STRUCT_TRAITS_MEMBER(sync_xhr_in_documents_enabled)
IPC_STRUCT_TRAITS_MEMBER(deferred_image_decoding_enabled)
IPC_STRUCT_TRAITS_MEMBER(image_color_profiles_enabled)
Expand Down
18 changes: 18 additions & 0 deletions content/public/common/web_preferences.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ COMPILE_ASSERT_MATCHING_ENUMS(
V8_SCRIPT_STREAMING_MODE_LAST,
WebSettings::V8ScriptStreamingModeAllPlusBlockParsingBlocking);

COMPILE_ASSERT_MATCHING_ENUMS(ui::POINTER_TYPE_NONE,
WebSettings::PointerTypeNone);
COMPILE_ASSERT_MATCHING_ENUMS(ui::POINTER_TYPE_COARSE,
WebSettings::PointerTypeCoarse);
COMPILE_ASSERT_MATCHING_ENUMS(ui::POINTER_TYPE_FINE,
WebSettings::PointerTypeFine);

COMPILE_ASSERT_MATCHING_ENUMS(ui::HOVER_TYPE_NONE,
WebSettings::HoverTypeNone);
COMPILE_ASSERT_MATCHING_ENUMS(ui::HOVER_TYPE_ON_DEMAND,
WebSettings::HoverTypeOnDemand);
COMPILE_ASSERT_MATCHING_ENUMS(ui::HOVER_TYPE_HOVER,
WebSettings::HoverTypeHover);

WebPreferences::WebPreferences()
: default_font_size(16),
default_fixed_font_size(13),
Expand Down Expand Up @@ -119,6 +133,10 @@ WebPreferences::WebPreferences()
device_supports_mouse(true),
touch_adjustment_enabled(true),
pointer_events_max_touch_points(0),
available_pointer_types(0),
primary_pointer_type(ui::POINTER_TYPE_NONE),
available_hover_types(0),
primary_hover_type(ui::HOVER_TYPE_NONE),
sync_xhr_in_documents_enabled(true),
deferred_image_decoding_enabled(false),
image_color_profiles_enabled(false),
Expand Down
7 changes: 7 additions & 0 deletions content/public/common/web_preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "base/strings/string16.h"
#include "content/common/content_export.h"
#include "net/base/network_change_notifier.h"
#include "ui/base/touch/touch_device.h"
#include "url/gurl.h"

namespace blink {
Expand Down Expand Up @@ -131,10 +132,16 @@ struct CONTENT_EXPORT WebPreferences {
bool css_variables_enabled;
bool region_based_columns_enabled;
bool touch_enabled;
// TODO(mustaq): Nuke when the new API is ready
bool device_supports_touch;
// TODO(mustaq): Nuke when the new API is ready
bool device_supports_mouse;
bool touch_adjustment_enabled;
int pointer_events_max_touch_points;
int available_pointer_types;
ui::PointerType primary_pointer_type;
int available_hover_types;
ui::HoverType primary_hover_type;
bool sync_xhr_in_documents_enabled;
bool deferred_image_decoding_enabled;
bool image_color_profiles_enabled;
Expand Down
6 changes: 6 additions & 0 deletions content/renderer/render_view_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,12 @@ void RenderView::ApplyWebPreferences(const WebPreferences& prefs,

WebRuntimeFeatures::enableTouch(prefs.touch_enabled);
settings->setMaxTouchPoints(prefs.pointer_events_max_touch_points);
settings->setAvailablePointerTypes(prefs.available_pointer_types);
settings->setPrimaryPointerType(
static_cast<WebSettings::PointerType>(prefs.primary_pointer_type));
settings->setAvailableHoverTypes(prefs.available_hover_types);
settings->setPrimaryHoverType(
static_cast<WebSettings::HoverType>(prefs.primary_hover_type));
settings->setDeviceSupportsTouch(prefs.device_supports_touch);
settings->setDeviceSupportsMouse(prefs.device_supports_mouse);
settings->setEnableTouchAdjustment(prefs.touch_adjustment_enabled);
Expand Down
22 changes: 22 additions & 0 deletions ui/base/touch/touch_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,28 @@ UI_BASE_EXPORT bool IsTouchDevicePresent();
// http://www.w3.org/TR/pointerevents/#widl-Navigator-maxTouchPoints
UI_BASE_EXPORT int MaxTouchPoints();

// Bit field values indicating available pointer types. Identical to
// blink::WebSettings::PointerType enums, enforced by compile-time assertions
// in content/public/common/web_preferences.cc .
enum PointerType {
POINTER_TYPE_NONE = 1 << 0,
POINTER_TYPE_FIRST = POINTER_TYPE_NONE,
POINTER_TYPE_COARSE = 1 << 1,
POINTER_TYPE_FINE = 1 << 2,
POINTER_TYPE_LAST = POINTER_TYPE_FINE
};

// Bit field values indicating available hover types. Identical to
// blink::WebSettings::HoverType enums, enforced by compile-time assertions
// in content/public/common/web_preferences.cc .
enum HoverType {
HOVER_TYPE_NONE = 1 << 0,
HOVER_TYPE_FIRST = HOVER_TYPE_NONE,
HOVER_TYPE_ON_DEMAND = 1 << 1,
HOVER_TYPE_HOVER = 1 << 2,
HOVER_TYPE_LAST = HOVER_TYPE_HOVER
};

#if defined(OS_ANDROID)
bool RegisterTouchDeviceAndroid(JNIEnv* env);
#endif
Expand Down

0 comments on commit 29eb709

Please sign in to comment.