summaryrefslogtreecommitdiff
path: root/chromium/ui/events/event.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-10-13 13:24:50 +0200
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-10-14 10:57:25 +0000
commitaf3d4809763ef308f08ced947a73b624729ac7ea (patch)
tree4402b911e30383f6c6dace1e8cf3b8e85355db3a /chromium/ui/events/event.cc
parent0e8ff63a407fe323e215bb1a2c423c09a4747c8a (diff)
downloadqtwebengine-chromium-af3d4809763ef308f08ced947a73b624729ac7ea.tar.gz
BASELINE: Update Chromium to 47.0.2526.14
Also adding in sources needed for spellchecking. Change-Id: Idd44170fa1616f26315188970a8d5ba7d472b18a Reviewed-by: Michael Brüning <michael.bruning@theqtcompany.com>
Diffstat (limited to 'chromium/ui/events/event.cc')
-rw-r--r--chromium/ui/events/event.cc118
1 files changed, 48 insertions, 70 deletions
diff --git a/chromium/ui/events/event.cc b/chromium/ui/events/event.cc
index 953220d0a63..9af664c6272 100644
--- a/chromium/ui/events/event.cc
+++ b/chromium/ui/events/event.cc
@@ -319,8 +319,8 @@ void LocatedEvent::UpdateForRootTransform(
MouseEvent::MouseEvent(const base::NativeEvent& native_event)
: LocatedEvent(native_event),
- changed_button_flags_(
- GetChangedMouseButtonFlagsFromNative(native_event)) {
+ changed_button_flags_(GetChangedMouseButtonFlagsFromNative(native_event)),
+ pointer_details_(PointerDetails(EventPointerType::POINTER_TYPE_MOUSE)) {
if (type() == ET_MOUSE_PRESSED || type() == ET_MOUSE_RELEASED)
SetClickCount(GetRepeatCount(*this));
}
@@ -332,7 +332,8 @@ MouseEvent::MouseEvent(EventType type,
int flags,
int changed_button_flags)
: LocatedEvent(type, location, root_location, time_stamp, flags),
- changed_button_flags_(changed_button_flags) {
+ changed_button_flags_(changed_button_flags),
+ pointer_details_(PointerDetails(EventPointerType::POINTER_TYPE_MOUSE)) {
if (this->type() == ET_MOUSE_MOVED && IsAnyButton())
SetType(ET_MOUSE_DRAGGED);
}
@@ -514,12 +515,15 @@ TouchEvent::TouchEvent(const base::NativeEvent& native_event)
: LocatedEvent(native_event),
touch_id_(GetTouchId(native_event)),
unique_event_id_(ui::GetNextTouchEventId()),
- radius_x_(GetTouchRadiusX(native_event)),
- radius_y_(GetTouchRadiusY(native_event)),
rotation_angle_(GetTouchAngle(native_event)),
- force_(GetTouchForce(native_event)),
may_cause_scrolling_(false),
- should_remove_native_touch_id_mapping_(false) {
+ should_remove_native_touch_id_mapping_(false),
+ pointer_details_(PointerDetails(EventPointerType::POINTER_TYPE_TOUCH,
+ GetTouchRadiusX(native_event),
+ GetTouchRadiusY(native_event),
+ GetTouchForce(native_event),
+ /* tilt_x */ 0.0f,
+ /* tilt_y */ 0.0f)) {
latency()->AddLatencyNumberWithTimestamp(
INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0,
base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1);
@@ -537,12 +541,10 @@ TouchEvent::TouchEvent(EventType type,
: LocatedEvent(type, location, location, time_stamp, 0),
touch_id_(touch_id),
unique_event_id_(ui::GetNextTouchEventId()),
- radius_x_(0.0f),
- radius_y_(0.0f),
rotation_angle_(0.0f),
- force_(0.0f),
may_cause_scrolling_(false),
- should_remove_native_touch_id_mapping_(false) {
+ should_remove_native_touch_id_mapping_(false),
+ pointer_details_(PointerDetails(EventPointerType::POINTER_TYPE_TOUCH)) {
latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
}
@@ -558,12 +560,15 @@ TouchEvent::TouchEvent(EventType type,
: LocatedEvent(type, location, location, time_stamp, flags),
touch_id_(touch_id),
unique_event_id_(ui::GetNextTouchEventId()),
- radius_x_(radius_x),
- radius_y_(radius_y),
rotation_angle_(angle),
- force_(force),
may_cause_scrolling_(false),
- should_remove_native_touch_id_mapping_(false) {
+ should_remove_native_touch_id_mapping_(false),
+ pointer_details_(PointerDetails(EventPointerType::POINTER_TYPE_TOUCH,
+ radius_x,
+ radius_y,
+ force,
+ /* tilt_x */ 0.0f,
+ /* tilt_y */ 0.0f)) {
latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
FixRotationAngle();
}
@@ -572,12 +577,10 @@ TouchEvent::TouchEvent(const TouchEvent& copy)
: LocatedEvent(copy),
touch_id_(copy.touch_id_),
unique_event_id_(copy.unique_event_id_),
- radius_x_(copy.radius_x_),
- radius_y_(copy.radius_y_),
rotation_angle_(copy.rotation_angle_),
- force_(copy.force_),
may_cause_scrolling_(copy.may_cause_scrolling_),
- should_remove_native_touch_id_mapping_(false) {
+ should_remove_native_touch_id_mapping_(false),
+ pointer_details_(copy.pointer_details_) {
// Copied events should not remove touch id mapping, as this either causes the
// mapping to be lost before the initial event has finished dispatching, or
// the copy to attempt to remove the mapping from a null |native_event_|.
@@ -601,9 +604,9 @@ void TouchEvent::UpdateForRootTransform(
bool success = gfx::DecomposeTransform(&decomp, inverted_root_transform);
DCHECK(success);
if (decomp.scale[0])
- radius_x_ *= decomp.scale[0];
+ pointer_details_.radius_x_ *= decomp.scale[0];
if (decomp.scale[1])
- radius_y_ *= decomp.scale[1];
+ pointer_details_.radius_y_ *= decomp.scale[1];
}
void TouchEvent::DisableSynchronousHandling() {
@@ -669,10 +672,7 @@ KeyEvent::KeyEvent(const base::NativeEvent& native_event)
EventFlagsFromNative(native_event)),
key_code_(KeyboardCodeFromNative(native_event)),
code_(CodeFromNative(native_event)),
- is_char_(IsCharFromNative(native_event)),
- platform_keycode_(PlatformKeycodeFromNative(native_event)),
- key_(DomKey::NONE),
- character_(0) {
+ is_char_(IsCharFromNative(native_event)) {
if (IsRepeated(*this))
set_flags(flags() | ui::EF_IS_REPEAT);
@@ -682,7 +682,7 @@ KeyEvent::KeyEvent(const base::NativeEvent& native_event)
#if defined(OS_WIN)
// Only Windows has native character events.
if (is_char_)
- character_ = native_event.wParam;
+ key_ = DomKey::FromCharacter(native_event.wParam);
#endif
}
@@ -691,11 +691,7 @@ KeyEvent::KeyEvent(EventType type,
int flags)
: Event(type, EventTimeForNow(), flags),
key_code_(key_code),
- code_(UsLayoutKeyboardCodeToDomCode(key_code)),
- is_char_(false),
- platform_keycode_(0),
- key_(DomKey::NONE),
- character_() {
+ code_(UsLayoutKeyboardCodeToDomCode(key_code)) {
}
KeyEvent::KeyEvent(EventType type,
@@ -704,11 +700,7 @@ KeyEvent::KeyEvent(EventType type,
int flags)
: Event(type, EventTimeForNow(), flags),
key_code_(key_code),
- code_(code),
- is_char_(false),
- platform_keycode_(0),
- key_(DomKey::NONE),
- character_(0) {
+ code_(code) {
}
KeyEvent::KeyEvent(EventType type,
@@ -716,15 +708,11 @@ KeyEvent::KeyEvent(EventType type,
DomCode code,
int flags,
DomKey key,
- base::char16 character,
base::TimeDelta time_stamp)
: Event(type, time_stamp, flags),
key_code_(key_code),
code_(code),
- is_char_(false),
- platform_keycode_(0),
- key_(key),
- character_(character) {
+ key_(key) {
}
KeyEvent::KeyEvent(base::char16 character, KeyboardCode key_code, int flags)
@@ -732,9 +720,7 @@ KeyEvent::KeyEvent(base::char16 character, KeyboardCode key_code, int flags)
key_code_(key_code),
code_(DomCode::NONE),
is_char_(true),
- platform_keycode_(0),
- key_(DomKey::CHARACTER),
- character_(character) {
+ key_(DomKey::FromCharacter(character)) {
}
KeyEvent::KeyEvent(const KeyEvent& rhs)
@@ -742,9 +728,7 @@ KeyEvent::KeyEvent(const KeyEvent& rhs)
key_code_(rhs.key_code_),
code_(rhs.code_),
is_char_(rhs.is_char_),
- platform_keycode_(rhs.platform_keycode_),
- key_(rhs.key_),
- character_(rhs.character_) {
+ key_(rhs.key_) {
if (rhs.extended_key_event_data_)
extended_key_event_data_.reset(rhs.extended_key_event_data_->Clone());
}
@@ -756,8 +740,6 @@ KeyEvent& KeyEvent::operator=(const KeyEvent& rhs) {
code_ = rhs.code_;
key_ = rhs.key_;
is_char_ = rhs.is_char_;
- platform_keycode_ = rhs.platform_keycode_;
- character_ = rhs.character_;
if (rhs.extended_key_event_data_)
extended_key_event_data_.reset(rhs.extended_key_event_data_->Clone());
@@ -772,14 +754,6 @@ void KeyEvent::SetExtendedKeyEventData(scoped_ptr<ExtendedKeyEventData> data) {
}
void KeyEvent::ApplyLayout() const {
- // If the client has set the character (e.g. faked key events from virtual
- // keyboard), it's client's responsibility to set the dom key correctly.
- // Otherwise, set the dom key as unidentified.
- // Please refer to crbug.com/443889.
- if (character_ != 0) {
- key_ = DomKey::UNIDENTIFIED;
- return;
- }
ui::DomCode code = code_;
if (code == DomCode::NONE) {
// Catch old code that tries to do layout without a physical key, and try
@@ -803,13 +777,12 @@ void KeyEvent::ApplyLayout() const {
// returns 'a' for VKEY_A even if the key is actually bound to 'à' in X11.
// GetCharacterFromXEvent returns 'à' in that case.
if (!IsControlDown() && native_event()) {
- GetMeaningFromXEvent(native_event(), &key_, &character_);
+ key_ = GetDomKeyFromXEvent(native_event());
return;
}
#elif defined(USE_OZONE)
if (KeyboardLayoutEngineManager::GetKeyboardLayoutEngine()->Lookup(
- code, flags(), &key_, &character_, &dummy_key_code,
- &platform_keycode_)) {
+ code, flags(), &key_, &dummy_key_code)) {
return;
}
#else
@@ -818,33 +791,38 @@ void KeyEvent::ApplyLayout() const {
EventTypeFromNative(native_event()) == ET_KEY_RELEASED);
}
#endif
- if (!DomCodeToUsLayoutMeaning(code, flags(), &key_, &character_,
- &dummy_key_code)) {
+ if (!DomCodeToUsLayoutDomKey(code, flags(), &key_, &dummy_key_code))
key_ = DomKey::UNIDENTIFIED;
- }
}
DomKey KeyEvent::GetDomKey() const {
- // Determination of character_ and key_ may be done lazily.
+ // Determination of key_ may be done lazily.
if (key_ == DomKey::NONE)
ApplyLayout();
return key_;
}
base::char16 KeyEvent::GetCharacter() const {
- // Determination of character_ and key_ may be done lazily.
+ // Determination of key_ may be done lazily.
if (key_ == DomKey::NONE)
ApplyLayout();
- return character_;
+ if (key_.IsCharacter()) {
+ // Historically ui::KeyEvent has held only BMP characters.
+ // Until this explicitly changes, require |key_| to hold a BMP character.
+ DomKey::Base utf32_character = key_.ToCharacter();
+ base::char16 ucs2_character = static_cast<base::char16>(utf32_character);
+ DCHECK(static_cast<DomKey::Base>(ucs2_character) == utf32_character);
+ return ucs2_character;
+ }
+ return 0;
}
base::char16 KeyEvent::GetText() const {
if ((flags() & EF_CONTROL_DOWN) != 0) {
- base::char16 character;
ui::DomKey key;
ui::KeyboardCode key_code;
- if (DomCodeToControlCharacter(code_, flags(), &key, &character, &key_code))
- return character;
+ if (DomCodeToControlCharacter(code_, flags(), &key, &key_code))
+ return key.ToCharacter();
}
return GetUnmodifiedText();
}
@@ -905,7 +883,7 @@ KeyboardCode KeyEvent::GetLocatedWindowsKeyboardCode() const {
uint16 KeyEvent::GetConflatedWindowsKeyCode() const {
if (is_char_)
- return character_;
+ return key_.ToCharacter();
return key_code_;
}