Diff
Modified: trunk/Source/WTF/ChangeLog (206449 => 206450)
--- trunk/Source/WTF/ChangeLog 2016-09-27 18:31:32 UTC (rev 206449)
+++ trunk/Source/WTF/ChangeLog 2016-09-27 19:08:34 UTC (rev 206450)
@@ -1,3 +1,14 @@
+2016-09-20 Anders Carlsson <[email protected]>
+
+ PlatformEvent::m_modifiers should be an OptionSet
+ https://bugs.webkit.org/show_bug.cgi?id=162326
+
+ Reviewed by Daniel Bates.
+
+ * wtf/OptionSet.h:
+ (WTF::OptionSet::operator!=):
+ (WTF::OptionSet::operator-):
+
2016-09-27 Jer Noble <[email protected]>
Remove deprecated ENCRYPTED_MEDIA implementation.
Modified: trunk/Source/WTF/wtf/OptionSet.h (206449 => 206450)
--- trunk/Source/WTF/wtf/OptionSet.h 2016-09-27 18:31:32 UTC (rev 206449)
+++ trunk/Source/WTF/wtf/OptionSet.h 2016-09-27 19:08:34 UTC (rev 206450)
@@ -23,8 +23,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef OptionSet_h
-#define OptionSet_h
+#pragma once
#include <initializer_list>
#include <iterator>
@@ -67,7 +66,7 @@
};
using iterator = Iterator<StorageType>;
- static OptionSet fromRaw(StorageType storageType)
+ static constexpr OptionSet fromRaw(StorageType storageType)
{
return OptionSet(static_cast<T>(storageType), FromRawValue);
}
@@ -109,6 +108,16 @@
return m_storage & optionSet.m_storage;
}
+ constexpr friend bool operator==(OptionSet lhs, OptionSet rhs)
+ {
+ return lhs.m_storage == rhs.m_storage;
+ }
+
+ constexpr friend bool operator!=(OptionSet lhs, OptionSet rhs)
+ {
+ return lhs.m_storage != rhs.m_storage;
+ }
+
friend OptionSet& operator|=(OptionSet& lhs, OptionSet rhs)
{
lhs.m_storage |= rhs.m_storage;
@@ -116,6 +125,11 @@
return lhs;
}
+ constexpr friend OptionSet operator-(OptionSet lhs, OptionSet rhs)
+ {
+ return OptionSet::fromRaw(lhs.m_storage & ~rhs.m_storage);
+ }
+
private:
enum InitializationTag { FromRawValue };
constexpr OptionSet(T t, InitializationTag)
@@ -128,5 +142,3 @@
}
using WTF::OptionSet;
-
-#endif // OptionSet_h
Modified: trunk/Source/WebCore/ChangeLog (206449 => 206450)
--- trunk/Source/WebCore/ChangeLog 2016-09-27 18:31:32 UTC (rev 206449)
+++ trunk/Source/WebCore/ChangeLog 2016-09-27 19:08:34 UTC (rev 206450)
@@ -1,3 +1,32 @@
+2016-09-20 Anders Carlsson <[email protected]>
+
+ PlatformEvent::m_modifiers should be an OptionSet
+ https://bugs.webkit.org/show_bug.cgi?id=162326
+
+ Reviewed by Daniel Bates.
+
+ * page/EventHandler.cpp:
+ (WebCore::EventHandler::handleAccessKey):
+ * page/EventHandler.h:
+ * page/mac/EventHandlerMac.mm:
+ (WebCore::EventHandler::accessKeyModifiers):
+ * platform/PlatformEvent.h:
+ (WebCore::PlatformEvent::shiftKey):
+ (WebCore::PlatformEvent::ctrlKey):
+ (WebCore::PlatformEvent::altKey):
+ (WebCore::PlatformEvent::metaKey):
+ (WebCore::PlatformEvent::modifiers):
+ (WebCore::PlatformEvent::PlatformEvent):
+ * platform/PlatformKeyboardEvent.h:
+ (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):
+ * platform/mac/PlatformEventFactoryMac.mm:
+ (WebCore::modifiersForEvent):
+ (WebCore::typeForEvent):
+ * replay/SerializationMethods.cpp:
+ (JSC::EncodingTraits<PlatformKeyboardEvent>::encodeValue):
+ (JSC::EncodingTraits<PlatformKeyboardEvent>::decodeValue):
+ * replay/WebInputs.json:
+
2016-09-27 Gustavo Noronha Silva <[email protected]>
[GTK] Handle Wayland & X11 correctly for GST_GL
Modified: trunk/Source/WebCore/page/EventHandler.cpp (206449 => 206450)
--- trunk/Source/WebCore/page/EventHandler.cpp 2016-09-27 18:31:32 UTC (rev 206449)
+++ trunk/Source/WebCore/page/EventHandler.cpp 2016-09-27 19:08:34 UTC (rev 206450)
@@ -2971,8 +2971,9 @@
// IE matches lower and upper case access keys regardless of Shift key state - but if both upper and
// lower case variants are present in a document, the correct element is matched based on Shift key state.
// Firefox only matches an access key if Shift is not pressed, and does that case-insensitively.
- ASSERT(!(accessKeyModifiers() & PlatformEvent::ShiftKey));
- if ((event.modifiers() & ~PlatformEvent::ShiftKey) != accessKeyModifiers())
+ ASSERT(!accessKeyModifiers().contains(PlatformEvent::Modifier::ShiftKey));
+
+ if ((event.modifiers() - PlatformEvent::Modifier::ShiftKey) != accessKeyModifiers())
return false;
Element* element = m_frame.document()->getElementByAccessKey(event.unmodifiedText());
if (!element)
Modified: trunk/Source/WebCore/page/EventHandler.h (206449 => 206450)
--- trunk/Source/WebCore/page/EventHandler.h 2016-09-27 18:31:32 UTC (rev 206449)
+++ trunk/Source/WebCore/page/EventHandler.h 2016-09-27 19:08:34 UTC (rev 206450)
@@ -244,7 +244,7 @@
bool needsKeyboardEventDisambiguationQuirks() const;
- static unsigned accessKeyModifiers();
+ static OptionSet<PlatformEvent::Modifier> accessKeyModifiers();
WEBCORE_EXPORT bool handleAccessKey(const PlatformKeyboardEvent&);
WEBCORE_EXPORT bool keyEvent(const PlatformKeyboardEvent&);
void defaultKeyboardEventHandler(KeyboardEvent&);
Modified: trunk/Source/WebCore/page/efl/EventHandlerEfl.cpp (206449 => 206450)
--- trunk/Source/WebCore/page/efl/EventHandlerEfl.cpp 2016-09-27 18:31:32 UTC (rev 206449)
+++ trunk/Source/WebCore/page/efl/EventHandlerEfl.cpp 2016-09-27 19:08:34 UTC (rev 206450)
@@ -120,8 +120,8 @@
return true;
}
-unsigned EventHandler::accessKeyModifiers()
+OptionSet<PlatformEvent::Modifier> EventHandler::accessKeyModifiers()
{
- return PlatformEvent::AltKey;
+ return PlatformEvent::Modifier::AltKey;
}
}
Modified: trunk/Source/WebCore/page/gtk/EventHandlerGtk.cpp (206449 => 206450)
--- trunk/Source/WebCore/page/gtk/EventHandlerGtk.cpp 2016-09-27 18:31:32 UTC (rev 206449)
+++ trunk/Source/WebCore/page/gtk/EventHandlerGtk.cpp 2016-09-27 19:08:34 UTC (rev 206450)
@@ -120,9 +120,9 @@
return true;
}
-unsigned EventHandler::accessKeyModifiers()
+OptionSet<PlatformEvent::Modifier> EventHandler::accessKeyModifiers()
{
- return PlatformEvent::AltKey;
+ return PlatformEvent::Modifier::AltKey;
}
// GTK+ must scroll horizontally if the mouse pointer is on top of the
Modified: trunk/Source/WebCore/page/ios/EventHandlerIOS.mm (206449 => 206450)
--- trunk/Source/WebCore/page/ios/EventHandlerIOS.mm 2016-09-27 18:31:32 UTC (rev 206449)
+++ trunk/Source/WebCore/page/ios/EventHandlerIOS.mm 2016-09-27 19:08:34 UTC (rev 206450)
@@ -537,15 +537,15 @@
return true;
}
-unsigned EventHandler::accessKeyModifiers()
+OptionSet<PlatformEvent::Modifier> EventHandler::accessKeyModifiers()
{
// Control+Option key combinations are usually unused on Mac OS X, but not when VoiceOver is enabled.
// So, we use Control in this case, even though it conflicts with Emacs-style key bindings.
// See <https://bugs.webkit.org/show_bug.cgi?id=21107> for more detail.
if (AXObjectCache::accessibilityEnhancedUserInterfaceEnabled())
- return PlatformKeyboardEvent::CtrlKey;
+ return PlatformEvent::Modifier::CtrlKey;
- return PlatformKeyboardEvent::CtrlKey | PlatformKeyboardEvent::AltKey;
+ return { PlatformEvent::Modifier::CtrlKey, PlatformEvent::Modifier::AltKey };
}
PlatformMouseEvent EventHandler::currentPlatformMouseEvent() const
Modified: trunk/Source/WebCore/page/mac/EventHandlerMac.mm (206449 => 206450)
--- trunk/Source/WebCore/page/mac/EventHandlerMac.mm 2016-09-27 18:31:32 UTC (rev 206449)
+++ trunk/Source/WebCore/page/mac/EventHandlerMac.mm 2016-09-27 19:08:34 UTC (rev 206450)
@@ -783,15 +783,15 @@
return false;
}
-unsigned EventHandler::accessKeyModifiers()
+OptionSet<PlatformEvent::Modifier> EventHandler::accessKeyModifiers()
{
// Control+Option key combinations are usually unused on Mac OS X, but not when VoiceOver is enabled.
// So, we use Control in this case, even though it conflicts with Emacs-style key bindings.
// See <https://bugs.webkit.org/show_bug.cgi?id=21107> for more detail.
if (AXObjectCache::accessibilityEnhancedUserInterfaceEnabled())
- return PlatformEvent::CtrlKey;
+ return PlatformEvent::Modifier::CtrlKey;
- return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
+ return { PlatformEvent::Modifier::CtrlKey, PlatformEvent::Modifier::AltKey };
}
static ScrollableArea* scrollableAreaForBox(RenderBox& box)
Modified: trunk/Source/WebCore/page/win/EventHandlerWin.cpp (206449 => 206450)
--- trunk/Source/WebCore/page/win/EventHandlerWin.cpp 2016-09-27 18:31:32 UTC (rev 206449)
+++ trunk/Source/WebCore/page/win/EventHandlerWin.cpp 2016-09-27 19:08:34 UTC (rev 206450)
@@ -112,9 +112,9 @@
return false;
}
-unsigned EventHandler::accessKeyModifiers()
+OptionSet<PlatformEvent::Modifier> EventHandler::accessKeyModifiers()
{
- return PlatformEvent::AltKey;
+ return PlatformEvent::Modifier::AltKey;
}
}
Modified: trunk/Source/WebCore/platform/PlatformEvent.h (206449 => 206450)
--- trunk/Source/WebCore/platform/PlatformEvent.h 2016-09-27 18:31:32 UTC (rev 206449)
+++ trunk/Source/WebCore/platform/PlatformEvent.h 2016-09-27 19:08:34 UTC (rev 206450)
@@ -23,9 +23,10 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef PlatformEvent_h
-#define PlatformEvent_h
+#pragma once
+#include <wtf/OptionSet.h>
+
namespace WebCore {
class PlatformEvent {
@@ -68,7 +69,7 @@
#endif
};
- enum Modifiers : uint8_t {
+ enum class Modifier {
AltKey = 1 << 0,
CtrlKey = 1 << 1,
MetaKey = 1 << 2,
@@ -77,12 +78,12 @@
Type type() const { return static_cast<Type>(m_type); }
- bool shiftKey() const { return m_modifiers & ShiftKey; }
- bool ctrlKey() const { return m_modifiers & CtrlKey; }
- bool altKey() const { return m_modifiers & AltKey; }
- bool metaKey() const { return m_modifiers & MetaKey; }
+ bool shiftKey() const { return m_modifiers.contains(Modifier::ShiftKey); }
+ bool ctrlKey() const { return m_modifiers.contains(Modifier::CtrlKey); }
+ bool altKey() const { return m_modifiers.contains(Modifier::AltKey); }
+ bool metaKey() const { return m_modifiers.contains(Modifier::MetaKey); }
- unsigned modifiers() const { return m_modifiers; }
+ OptionSet<Modifier> modifiers() const { return m_modifiers; }
double timestamp() const { return m_timestamp; }
@@ -89,7 +90,6 @@
protected:
PlatformEvent()
: m_type(NoType)
- , m_modifiers(0)
, m_timestamp(0)
{
}
@@ -96,12 +96,11 @@
explicit PlatformEvent(Type type)
: m_type(type)
- , m_modifiers(0)
, m_timestamp(0)
{
}
- PlatformEvent(Type type, Modifiers modifiers, double timestamp)
+ PlatformEvent(Type type, OptionSet<Modifier> modifiers, double timestamp)
: m_type(type)
, m_modifiers(modifiers)
, m_timestamp(timestamp)
@@ -110,17 +109,16 @@
PlatformEvent(Type type, bool shiftKey, bool ctrlKey, bool altKey, bool metaKey, double timestamp)
: m_type(type)
- , m_modifiers(0)
, m_timestamp(timestamp)
{
if (shiftKey)
- m_modifiers |= ShiftKey;
+ m_modifiers |= Modifier::ShiftKey;
if (ctrlKey)
- m_modifiers |= CtrlKey;
+ m_modifiers |= Modifier::CtrlKey;
if (altKey)
- m_modifiers |= AltKey;
+ m_modifiers |= Modifier::AltKey;
if (metaKey)
- m_modifiers |= MetaKey;
+ m_modifiers |= Modifier::MetaKey;
}
// Explicit protected destructor so that people don't accidentally
@@ -130,10 +128,8 @@
}
unsigned m_type;
- unsigned m_modifiers;
+ OptionSet<Modifier> m_modifiers;
double m_timestamp;
};
} // namespace WebCore
-
-#endif // PlatformEvent_h
Modified: trunk/Source/WebCore/platform/PlatformKeyboardEvent.h (206449 => 206450)
--- trunk/Source/WebCore/platform/PlatformKeyboardEvent.h 2016-09-27 18:31:32 UTC (rev 206449)
+++ trunk/Source/WebCore/platform/PlatformKeyboardEvent.h 2016-09-27 19:08:34 UTC (rev 206450)
@@ -24,8 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef PlatformKeyboardEvent_h
-#define PlatformKeyboardEvent_h
+#pragma once
#include "KeypressCommand.h"
#include "PlatformEvent.h"
@@ -73,7 +72,7 @@
{
}
- PlatformKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers modifiers, double timestamp)
+ PlatformKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier> modifiers, double timestamp)
: PlatformEvent(type, modifiers, timestamp)
, m_text(text)
, m_unmodifiedText(unmodifiedText)
@@ -192,5 +191,3 @@
};
} // namespace WebCore
-
-#endif // PlatformKeyboardEvent_h
Modified: trunk/Source/WebCore/platform/gtk/PlatformKeyboardEventGtk.cpp (206449 => 206450)
--- trunk/Source/WebCore/platform/gtk/PlatformKeyboardEventGtk.cpp 2016-09-27 18:31:32 UTC (rev 206449)
+++ trunk/Source/WebCore/platform/gtk/PlatformKeyboardEventGtk.cpp 2016-09-27 19:08:34 UTC (rev 206450)
@@ -555,18 +555,18 @@
return event->type == GDK_KEY_RELEASE ? PlatformEvent::KeyUp : PlatformEvent::KeyDown;
}
-static PlatformEvent::Modifiers modifiersForGdkKeyEvent(GdkEventKey* event)
+static OptionSet<PlatformEvent::Modifier> modifiersForGdkKeyEvent(GdkEventKey* event)
{
- unsigned int modifiers = 0;
+ OptionSet<PlatformEvent::Modifier> modifiers;
if (event->state & GDK_SHIFT_MASK || event->keyval == GDK_3270_BackTab)
- modifiers |= PlatformEvent::ShiftKey;
+ modifiers |= PlatformEvent::Modifier::ShiftKey;
if (event->state & GDK_CONTROL_MASK)
- modifiers |= PlatformEvent::CtrlKey;
+ modifiers |= PlatformEvent::Modifier::CtrlKey;
if (event->state & GDK_MOD1_MASK)
- modifiers |= PlatformEvent::AltKey;
+ modifiers |= PlatformEvent::Modifier::AltKey;
if (event->state & GDK_META_MASK)
- modifiers |= PlatformEvent::MetaKey;
- return static_cast<PlatformEvent::Modifiers>(modifiers);
+ modifiers |= PlatformEvent::Modifier::MetaKey;
+ return modifiers;
}
// Keep this in sync with the other platform event constructors
Modified: trunk/Source/WebCore/platform/gtk/PlatformMouseEventGtk.cpp (206449 => 206450)
--- trunk/Source/WebCore/platform/gtk/PlatformMouseEventGtk.cpp 2016-09-27 18:31:32 UTC (rev 206449)
+++ trunk/Source/WebCore/platform/gtk/PlatformMouseEventGtk.cpp 2016-09-27 19:08:34 UTC (rev 206450)
@@ -42,15 +42,14 @@
m_position = IntPoint((int)event->x, (int)event->y);
m_globalPosition = IntPoint((int)event->x_root, (int)event->y_root);
- m_modifiers = 0;
if (event->state & GDK_SHIFT_MASK)
- m_modifiers |= ShiftKey;
+ m_modifiers |= PlatformEvent::Modifier::ShiftKey;
if (event->state & GDK_CONTROL_MASK)
- m_modifiers |= CtrlKey;
+ m_modifiers |= PlatformEvent::Modifier::CtrlKey;
if (event->state & GDK_MOD1_MASK)
- m_modifiers |= AltKey;
+ m_modifiers |= PlatformEvent::Modifier::AltKey;
if (event->state & GDK_META_MASK)
- m_modifiers |= MetaKey;
+ m_modifiers |= PlatformEvent::Modifier::MetaKey;
switch (event->type) {
case GDK_BUTTON_PRESS:
@@ -87,15 +86,14 @@
m_position = IntPoint((int)motion->x, (int)motion->y);
m_globalPosition = IntPoint((int)motion->x_root, (int)motion->y_root);
- m_modifiers = 0;
if (motion->state & GDK_SHIFT_MASK)
- m_modifiers |= ShiftKey;
+ m_modifiers |= PlatformEvent::Modifier::ShiftKey;
if (motion->state & GDK_CONTROL_MASK)
- m_modifiers |= CtrlKey;
+ m_modifiers |= PlatformEvent::Modifier::CtrlKey;
if (motion->state & GDK_MOD1_MASK)
- m_modifiers |= AltKey;
+ m_modifiers |= PlatformEvent::Modifier::AltKey;
if (motion->state & GDK_META_MASK)
- m_modifiers |= MetaKey;
+ m_modifiers |= PlatformEvent::Modifier::MetaKey;
switch (motion->type) {
case GDK_MOTION_NOTIFY:
Modified: trunk/Source/WebCore/platform/gtk/PlatformWheelEventGtk.cpp (206449 => 206450)
--- trunk/Source/WebCore/platform/gtk/PlatformWheelEventGtk.cpp 2016-09-27 18:31:32 UTC (rev 206449)
+++ trunk/Source/WebCore/platform/gtk/PlatformWheelEventGtk.cpp 2016-09-27 19:08:34 UTC (rev 206450)
@@ -43,15 +43,14 @@
m_type = PlatformEvent::Wheel;
m_timestamp = currentTime();
- m_modifiers = 0;
if (event->state & GDK_SHIFT_MASK)
- m_modifiers |= ShiftKey;
+ m_modifiers |= Modifier::ShiftKey;
if (event->state & GDK_CONTROL_MASK)
- m_modifiers |= CtrlKey;
+ m_modifiers |= Modifier::CtrlKey;
if (event->state & GDK_MOD1_MASK)
- m_modifiers |= AltKey;
+ m_modifiers |= Modifier::AltKey;
if (event->state & GDK_META_MASK)
- m_modifiers |= MetaKey;
+ m_modifiers |= Modifier::MetaKey;
m_deltaX = 0;
m_deltaY = 0;
Modified: trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.mm (206449 => 206450)
--- trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.mm 2016-09-27 18:31:32 UTC (rev 206449)
+++ trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.mm 2016-09-27 19:08:34 UTC (rev 206450)
@@ -35,18 +35,18 @@
namespace WebCore {
-static unsigned modifiersForEvent(WebEvent *event)
+static OptionSet<PlatformEvent::Modifier> modifiersForEvent(WebEvent *event)
{
- unsigned modifiers = 0;
+ OptionSet<PlatformEvent::Modifier> modifiers;
if (event.modifierFlags & WebEventFlagMaskShift)
- modifiers |= PlatformEvent::ShiftKey;
+ modifiers |= PlatformEvent::Modifier::ShiftKey;
if (event.modifierFlags & WebEventFlagMaskControl)
- modifiers |= PlatformEvent::CtrlKey;
+ modifiers |= PlatformEvent::Modifier::CtrlKey;
if (event.modifierFlags & WebEventFlagMaskAlternate)
- modifiers |= PlatformEvent::AltKey;
+ modifiers |= PlatformEvent::Modifier::AltKey;
if (event.modifierFlags & WebEventFlagMaskCommand)
- modifiers |= PlatformEvent::MetaKey;
+ modifiers |= PlatformEvent::Modifier::MetaKey;
return modifiers;
}
@@ -82,7 +82,6 @@
PlatformMouseEventBuilder(WebEvent *event)
{
m_type = mouseEventType(event);
- m_modifiers = 0;
m_timestamp = currentTime();
m_position = pointForEvent(event);
@@ -104,7 +103,6 @@
ASSERT(event.type == WebEventScrollWheel);
m_type = PlatformEvent::Wheel;
- m_modifiers = 0;
m_timestamp = currentTime();
m_position = pointForEvent(event);
Modified: trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm (206449 => 206450)
--- trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm 2016-09-27 18:31:32 UTC (rev 206449)
+++ trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm 2016-09-27 19:08:34 UTC (rev 206450)
@@ -426,21 +426,21 @@
return false;
}
-static inline PlatformEvent::Modifiers modifiersForEvent(NSEvent *event)
+static inline OptionSet<PlatformEvent::Modifier> modifiersForEvent(NSEvent *event)
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- unsigned modifiers = 0;
- if ([event modifierFlags] & NSShiftKeyMask)
- modifiers |= PlatformEvent::ShiftKey;
- if ([event modifierFlags] & NSControlKeyMask)
- modifiers |= PlatformEvent::CtrlKey;
- if ([event modifierFlags] & NSAlternateKeyMask)
- modifiers |= PlatformEvent::AltKey;
- if ([event modifierFlags] & NSCommandKeyMask)
- modifiers |= PlatformEvent::MetaKey;
+ OptionSet<PlatformEvent::Modifier> modifiers;
+ if (event.modifierFlags & NSShiftKeyMask)
+ modifiers |= PlatformEvent::Modifier::ShiftKey;
+ if (event.modifierFlags & NSControlKeyMask)
+ modifiers |= PlatformEvent::Modifier::CtrlKey;
+ if (event.modifierFlags & NSAlternateKeyMask)
+ modifiers |= PlatformEvent::Modifier::AltKey;
+ if (event.modifierFlags & NSCommandKeyMask)
+ modifiers |= PlatformEvent::Modifier::MetaKey;
#pragma clang diagnostic pop
- return (PlatformEvent::Modifiers)modifiers;
+ return modifiers;
}
static int typeForEvent(NSEvent *event)
@@ -451,7 +451,7 @@
if (mouseButtonForEvent(event) == RightButton)
return static_cast<int>(NSMenuTypeContextMenu);
- if (mouseButtonForEvent(event) == LeftButton && (modifiersForEvent(event) & PlatformEvent::CtrlKey))
+ if (mouseButtonForEvent(event) == LeftButton && modifiersForEvent(event).contains(PlatformEvent::Modifier::CtrlKey))
return static_cast<int>(NSMenuTypeContextMenu);
return static_cast<int>(NSMenuTypeNone);
Modified: trunk/Source/WebCore/replay/SerializationMethods.cpp (206449 => 206450)
--- trunk/Source/WebCore/replay/SerializationMethods.cpp 2016-09-27 18:31:32 UTC (rev 206449)
+++ trunk/Source/WebCore/replay/SerializationMethods.cpp 2016-09-27 19:08:34 UTC (rev 206450)
@@ -253,7 +253,7 @@
ENCODE_TYPE_WITH_KEY(encodedValue, double, timestamp, input.timestamp());
ENCODE_TYPE_WITH_KEY(encodedValue, PlatformEvent::Type, type, input.type());
- ENCODE_TYPE_WITH_KEY(encodedValue, PlatformEvent::Modifiers, modifiers, static_cast<PlatformEvent::Modifiers>(input.modifiers()));
+ ENCODE_TYPE_WITH_KEY(encodedValue, PlatformEvent::Modifier, modifiers, input.modifiers());
ENCODE_TYPE_WITH_KEY(encodedValue, String, text, input.text());
ENCODE_TYPE_WITH_KEY(encodedValue, String, unmodifiedText, input.unmodifiedText());
ENCODE_TYPE_WITH_KEY(encodedValue, String, keyIdentifier, input.keyIdentifier());
@@ -274,7 +274,7 @@
{
DECODE_TYPE_WITH_KEY(encodedValue, double, timestamp);
DECODE_TYPE_WITH_KEY(encodedValue, PlatformEvent::Type, type);
- DECODE_TYPE_WITH_KEY(encodedValue, PlatformEvent::Modifiers, modifiers);
+ DECODE_TYPE_WITH_KEY(encodedValue, PlatformEvent::Modifier, modifiers);
DECODE_TYPE_WITH_KEY(encodedValue, String, text);
DECODE_TYPE_WITH_KEY(encodedValue, String, unmodifiedText);
DECODE_TYPE_WITH_KEY(encodedValue, String, keyIdentifier);
Modified: trunk/Source/WebCore/replay/WebInputs.json (206449 => 206450)
--- trunk/Source/WebCore/replay/WebInputs.json 2016-09-27 18:31:32 UTC (rev 206449)
+++ trunk/Source/WebCore/replay/WebInputs.json 2016-09-27 19:08:34 UTC (rev 206450)
@@ -13,9 +13,9 @@
"header": "replay/MemoizedDOMResult.h"
},
{
- "name": "Modifiers", "mode": "SCALAR", "storage": "uint8_t",
+ "name": "Modifier", "mode": "SCALAR",
"enclosing_class": "PlatformEvent",
- "flags": ["ENUM"],
+ "flags": ["OPTION_SET"],
"values": ["AltKey", "CtrlKey", "MetaKey", "ShiftKey"],
"header": "platform/PlatformEvent.h"
},
Modified: trunk/Source/WebKit/win/AccessibleBase.cpp (206449 => 206450)
--- trunk/Source/WebKit/win/AccessibleBase.cpp 2016-09-27 18:31:32 UTC (rev 206449)
+++ trunk/Source/WebKit/win/AccessibleBase.cpp 2016-09-27 19:08:34 UTC (rev 206450)
@@ -597,17 +597,17 @@
static String accessKeyModifiers;
if (accessKeyModifiers.isNull()) {
StringBuilder accessKeyModifiersBuilder;
- unsigned modifiers = EventHandler::accessKeyModifiers();
+ auto modifiers = EventHandler::accessKeyModifiers();
// Follow the same order as Mozilla MSAA implementation:
// Ctrl+Alt+Shift+Meta+key. MSDN states that keyboard shortcut strings
// should not be localized and defines the separator as "+".
- if (modifiers & PlatformEvent::CtrlKey)
+ if (modifiers.contains(PlatformEvent::Modifier::CtrlKey))
accessKeyModifiersBuilder.appendLiteral("Ctrl+");
- if (modifiers & PlatformEvent::AltKey)
+ if (modifiers.contains(PlatformEvent::Modifier::AltKey))
accessKeyModifiersBuilder.appendLiteral("Alt+");
- if (modifiers & PlatformEvent::ShiftKey)
+ if (modifiers.contains(PlatformEvent::Modifier::ShiftKey))
accessKeyModifiersBuilder.appendLiteral("Shift+");
- if (modifiers & PlatformEvent::MetaKey)
+ if (modifiers.contains(PlatformEvent::Modifier::MetaKey))
accessKeyModifiersBuilder.appendLiteral("Win+");
accessKeyModifiers = accessKeyModifiersBuilder.toString();
}
Modified: trunk/Source/WebKit2/ChangeLog (206449 => 206450)
--- trunk/Source/WebKit2/ChangeLog 2016-09-27 18:31:32 UTC (rev 206449)
+++ trunk/Source/WebKit2/ChangeLog 2016-09-27 19:08:34 UTC (rev 206450)
@@ -1,3 +1,16 @@
+2016-09-20 Anders Carlsson <[email protected]>
+
+ PlatformEvent::m_modifiers should be an OptionSet
+ https://bugs.webkit.org/show_bug.cgi?id=162326
+
+ Reviewed by Daniel Bates.
+
+ * Shared/WebEventConversion.cpp:
+ (WebKit::WebKit2PlatformMouseEvent::WebKit2PlatformMouseEvent):
+ (WebKit::WebKit2PlatformWheelEvent::WebKit2PlatformWheelEvent):
+ (WebKit::WebKit2PlatformKeyboardEvent::WebKit2PlatformKeyboardEvent):
+ (WebKit::WebKit2PlatformGestureEvent::WebKit2PlatformGestureEvent):
+
2016-09-27 Dan Bernstein <[email protected]>
[iOS] REGRESSION (r182126): Selection highlight and handles aren’t visible with WKSelectionGranularityCharacter
Modified: trunk/Source/WebKit2/Shared/WebEventConversion.cpp (206449 => 206450)
--- trunk/Source/WebKit2/Shared/WebEventConversion.cpp 2016-09-27 18:31:32 UTC (rev 206449)
+++ trunk/Source/WebKit2/Shared/WebEventConversion.cpp 2016-09-27 19:08:34 UTC (rev 206450)
@@ -68,15 +68,14 @@
ASSERT_NOT_REACHED();
}
- m_modifiers = 0;
if (webEvent.shiftKey())
- m_modifiers |= ShiftKey;
+ m_modifiers |= Modifier::ShiftKey;
if (webEvent.controlKey())
- m_modifiers |= CtrlKey;
+ m_modifiers |= Modifier::CtrlKey;
if (webEvent.altKey())
- m_modifiers |= AltKey;
+ m_modifiers |= Modifier::AltKey;
if (webEvent.metaKey())
- m_modifiers |= MetaKey;
+ m_modifiers |= Modifier::MetaKey;
m_timestamp = webEvent.timestamp();
@@ -105,16 +104,6 @@
m_eventNumber = webEvent.eventNumber();
m_menuTypeForEvent = webEvent.menuTypeForEvent();
#endif
-
- m_modifierFlags = 0;
- if (webEvent.shiftKey())
- m_modifierFlags |= WebEvent::ShiftKey;
- if (webEvent.controlKey())
- m_modifierFlags |= WebEvent::ControlKey;
- if (webEvent.altKey())
- m_modifierFlags |= WebEvent::AltKey;
- if (webEvent.metaKey())
- m_modifierFlags |= WebEvent::MetaKey;
}
};
@@ -130,15 +119,14 @@
// PlatformEvent
m_type = PlatformEvent::Wheel;
- m_modifiers = 0;
if (webEvent.shiftKey())
- m_modifiers |= ShiftKey;
+ m_modifiers |= Modifier::ShiftKey;
if (webEvent.controlKey())
- m_modifiers |= CtrlKey;
+ m_modifiers |= Modifier::CtrlKey;
if (webEvent.altKey())
- m_modifiers |= AltKey;
+ m_modifiers |= Modifier::AltKey;
if (webEvent.metaKey())
- m_modifiers |= MetaKey;
+ m_modifiers |= Modifier::MetaKey;
m_timestamp = webEvent.timestamp();
@@ -189,15 +177,14 @@
ASSERT_NOT_REACHED();
}
- m_modifiers = 0;
if (webEvent.shiftKey())
- m_modifiers |= ShiftKey;
+ m_modifiers |= Modifier::ShiftKey;
if (webEvent.controlKey())
- m_modifiers |= CtrlKey;
+ m_modifiers |= Modifier::CtrlKey;
if (webEvent.altKey())
- m_modifiers |= AltKey;
+ m_modifiers |= Modifier::AltKey;
if (webEvent.metaKey())
- m_modifiers |= MetaKey;
+ m_modifiers |= Modifier::MetaKey;
m_timestamp = webEvent.timestamp();
@@ -325,15 +312,14 @@
ASSERT_NOT_REACHED();
}
- m_modifiers = 0;
if (webEvent.shiftKey())
- m_modifiers |= ShiftKey;
+ m_modifiers |= Modifier::ShiftKey;
if (webEvent.controlKey())
- m_modifiers |= CtrlKey;
+ m_modifiers |= Modifier::CtrlKey;
if (webEvent.altKey())
- m_modifiers |= AltKey;
+ m_modifiers |= Modifier::AltKey;
if (webEvent.metaKey())
- m_modifiers |= MetaKey;
+ m_modifiers |= Modifier::MetaKey;
m_timestamp = webEvent.timestamp();
@@ -383,15 +369,14 @@
ASSERT_NOT_REACHED();
}
- m_modifiers = 0;
if (webEvent.shiftKey())
- m_modifiers |= ShiftKey;
+ m_modifiers |= Modifier::ShiftKey;
if (webEvent.controlKey())
- m_modifiers |= CtrlKey;
+ m_modifiers |= Modifier::CtrlKey;
if (webEvent.altKey())
- m_modifiers |= AltKey;
+ m_modifiers |= Modifier::AltKey;
if (webEvent.metaKey())
- m_modifiers |= MetaKey;
+ m_modifiers |= Modifier::MetaKey;
m_timestamp = webEvent.timestamp();
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/OptionSet.cpp (206449 => 206450)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/OptionSet.cpp 2016-09-27 18:31:32 UTC (rev 206449)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/OptionSet.cpp 2016-09-27 19:08:34 UTC (rev 206450)
@@ -60,6 +60,32 @@
EXPECT_FALSE(set.contains(ExampleFlags::E));
}
+TEST(WTF_OptionSet, Equal)
+{
+ OptionSet<ExampleFlags> set { ExampleFlags::A, ExampleFlags::B };
+
+ EXPECT_TRUE(set == { ExampleFlags::A, ExampleFlags::B });
+ EXPECT_TRUE(set == { ExampleFlags::B, ExampleFlags::A });
+ EXPECT_FALSE(set == ExampleFlags::B);
+}
+
+TEST(WTF_OptionSet, NotEqual)
+{
+ OptionSet<ExampleFlags> set = ExampleFlags::A;
+
+ EXPECT_TRUE(set != ExampleFlags::A);
+ EXPECT_TRUE(set != ExampleFlags::B);
+}
+
+TEST(WTF_OptionSet, Minus)
+{
+ OptionSet<ExampleFlags> set { ExampleFlags::A, ExampleFlags:B, ExampleFlags::C };
+
+ EXPECT_TRUE((set - ExampleFlags::A) == { ExampleFlags::B, ExampleFlags::C });
+ EXPECT_TRUE((set - ExampleFlags::D) == { ExampleFlags::A, ExampleFlags::B, ExampleFlags::C });
+ EXPECT_TRUE((set - set).isEmpty());
+}
+
TEST(WTF_OptionSet, ContainsTwoFlags)
{
OptionSet<ExampleFlags> set { ExampleFlags::A, ExampleFlags::B };