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

Side by Side Diff: ui/events/event.cc

Issue 267723008: Retires ui::TranslatedKeyEvent and replaces it with KeyEvent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed AcceleratorControllerTest.MAYBE_ProcessOnce more. Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/events/event.h ('k') | ui/keyboard/keyboard_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/events/event.h" 5 #include "ui/events/event.h"
6 6
7 #if defined(USE_X11) 7 #if defined(USE_X11)
8 #include <X11/extensions/XInput2.h> 8 #include <X11/extensions/XInput2.h>
9 #include <X11/Xlib.h> 9 #include <X11/Xlib.h>
10 #endif 10 #endif
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 break; 579 break;
580 default: 580 default:
581 return; 581 return;
582 } 582 }
583 if (type() == ET_KEY_PRESSED) 583 if (type() == ET_KEY_PRESSED)
584 set_flags(flags() | mask); 584 set_flags(flags() | mask);
585 else 585 else
586 set_flags(flags() & ~mask); 586 set_flags(flags() & ~mask);
587 } 587 }
588 588
589 //////////////////////////////////////////////////////////////////////////////// 589 bool KeyEvent::IsTranslated() const {
590 // TranslatedKeyEvent 590 switch (type()) {
591 591 case ET_KEY_PRESSED:
592 TranslatedKeyEvent::TranslatedKeyEvent(const base::NativeEvent& native_event, 592 case ET_KEY_RELEASED:
593 bool is_char) 593 return false;
594 : KeyEvent(native_event, is_char) { 594 case ET_TRANSLATED_KEY_PRESS:
595 SetType(type() == ET_KEY_PRESSED ? 595 case ET_TRANSLATED_KEY_RELEASE:
596 ET_TRANSLATED_KEY_PRESS : ET_TRANSLATED_KEY_RELEASE); 596 return true;
597 default:
598 NOTREACHED();
599 return false;
600 }
597 } 601 }
598 602
599 TranslatedKeyEvent::TranslatedKeyEvent(bool is_press, 603 void KeyEvent::SetTranslated(bool translated) {
600 KeyboardCode key_code, 604 switch (type()) {
601 int flags) 605 case ET_KEY_PRESSED:
602 : KeyEvent((is_press ? ET_TRANSLATED_KEY_PRESS : ET_TRANSLATED_KEY_RELEASE), 606 case ET_TRANSLATED_KEY_PRESS:
603 key_code, 607 SetType(translated ? ET_TRANSLATED_KEY_PRESS : ET_KEY_PRESSED);
604 flags, 608 break;
605 false) { 609 case ET_KEY_RELEASED:
606 } 610 case ET_TRANSLATED_KEY_RELEASE:
607 611 SetType(translated ? ET_TRANSLATED_KEY_RELEASE : ET_KEY_RELEASED);
608 TranslatedKeyEvent::TranslatedKeyEvent(const KeyEvent& key_event) 612 break;
609 : KeyEvent(key_event) { 613 default:
610 SetType(type() == ET_KEY_PRESSED ? 614 NOTREACHED();
611 ET_TRANSLATED_KEY_PRESS : ET_TRANSLATED_KEY_RELEASE); 615 }
612 set_is_char(false);
613 }
614
615 void TranslatedKeyEvent::ConvertToKeyEvent() {
616 SetType(type() == ET_TRANSLATED_KEY_PRESS ?
617 ET_KEY_PRESSED : ET_KEY_RELEASED);
618 } 616 }
619 617
620 //////////////////////////////////////////////////////////////////////////////// 618 ////////////////////////////////////////////////////////////////////////////////
621 // ScrollEvent 619 // ScrollEvent
622 620
623 ScrollEvent::ScrollEvent(const base::NativeEvent& native_event) 621 ScrollEvent::ScrollEvent(const base::NativeEvent& native_event)
624 : MouseEvent(native_event) { 622 : MouseEvent(native_event) {
625 if (type() == ET_SCROLL) { 623 if (type() == ET_SCROLL) {
626 GetScrollOffsets(native_event, 624 GetScrollOffsets(native_event,
627 &x_offset_, &y_offset_, 625 &x_offset_, &y_offset_,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 int GestureEvent::GetLowestTouchId() const { 688 int GestureEvent::GetLowestTouchId() const {
691 if (touch_ids_bitfield_ == 0) 689 if (touch_ids_bitfield_ == 0)
692 return -1; 690 return -1;
693 int i = -1; 691 int i = -1;
694 // Find the index of the least significant 1 bit 692 // Find the index of the least significant 1 bit
695 while (!(1 << ++i & touch_ids_bitfield_)); 693 while (!(1 << ++i & touch_ids_bitfield_));
696 return i; 694 return i;
697 } 695 }
698 696
699 } // namespace ui 697 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/event.h ('k') | ui/keyboard/keyboard_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698