Skip to content

Commit

Permalink
Merge r235009 - Pack booleans in Event into a bitfield
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=188713

Reviewed by Daniel Bates.

Use bitfields for booleans in Event class.

* dom/Event.cpp:
(WebCore::Event::Event):
* dom/Event.h:
(WebCore::Event::IsComposed): Added.
(WebCore::Event): Packed booleans into a bitfield.
  • Loading branch information
rniwa authored and carlosgcampos committed Aug 20, 2018
1 parent 6949238 commit 10c1cf7
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 35 deletions.
15 changes: 15 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,18 @@
2018-08-17 Ryosuke Niwa <rniwa@webkit.org>

Pack booleans in Event into a bitfield
https://bugs.webkit.org/show_bug.cgi?id=188713

Reviewed by Daniel Bates.

Use bitfields for booleans in Event class.

* dom/Event.cpp:
(WebCore::Event::Event):
* dom/Event.h:
(WebCore::Event::IsComposed): Added.
(WebCore::Event): Packed booleans into a bitfield.

2018-08-17 Alex Christensen <achristensen@webkit.org>

Clean up CSSSelectorList after r234825
Expand Down
49 changes: 28 additions & 21 deletions Source/WebCore/dom/Event.cpp
Expand Up @@ -34,41 +34,48 @@

namespace WebCore {

ALWAYS_INLINE Event::Event(MonotonicTime createTime, const AtomicString& type, IsTrusted isTrusted, CanBubble canBubble, IsCancelable cancelable, IsComposed composed)
: m_type { type }
, m_isInitialized { !type.isNull() }
, m_canBubble { canBubble == CanBubble::Yes }
, m_cancelable { cancelable == IsCancelable::Yes }
, m_composed { composed == IsComposed::Yes }
, m_propagationStopped { false }
, m_immediatePropagationStopped { false }
, m_wasCanceled { false }
, m_defaultHandled { false }
, m_isDefaultEventHandlerIgnored { false }
, m_isTrusted { isTrusted == IsTrusted::Yes }
, m_isExecutingPassiveEventListener { false }
, m_eventPhase { NONE }
, m_createTime { createTime }
{
}

Event::Event(IsTrusted isTrusted)
: m_isTrusted(isTrusted == IsTrusted::Yes)
, m_createTime(MonotonicTime::now())
: Event { MonotonicTime::now(), { }, isTrusted, CanBubble::No, IsCancelable::No, IsComposed::No }
{
}

Event::Event(const AtomicString& eventType, CanBubble canBubble, IsCancelable isCancelable)
: m_type(eventType)
, m_isInitialized(true)
, m_canBubble(canBubble == CanBubble::Yes)
, m_cancelable(isCancelable == IsCancelable::Yes)
, m_isTrusted(true)
, m_createTime(MonotonicTime::now())
: Event { MonotonicTime::now(), eventType, IsTrusted::Yes, canBubble, isCancelable, IsComposed::No }
{
ASSERT(!eventType.isNull());
}

Event::Event(const AtomicString& eventType, CanBubble canBubble, IsCancelable isCancelable, MonotonicTime timestamp)
: m_type(eventType)
, m_isInitialized(true)
, m_canBubble(canBubble == CanBubble::Yes)
, m_cancelable(isCancelable == IsCancelable::Yes)
, m_isTrusted(true)
, m_createTime(timestamp)
: Event { timestamp, eventType, IsTrusted::Yes, canBubble, isCancelable, IsComposed::No }
{
ASSERT(!eventType.isNull());
}

Event::Event(const AtomicString& eventType, const EventInit& initializer, IsTrusted isTrusted)
: m_type(eventType)
, m_isInitialized(true)
, m_canBubble(initializer.bubbles)
, m_cancelable(initializer.cancelable)
, m_composed(initializer.composed)
, m_isTrusted(isTrusted == IsTrusted::Yes)
, m_createTime(MonotonicTime::now())
: Event { MonotonicTime::now(), eventType, isTrusted,
initializer.bubbles ? CanBubble::Yes : CanBubble::No,
initializer.cancelable ? IsCancelable::Yes : IsCancelable::No,
initializer.composed ? IsComposed::Yes : IsComposed::No }
{
ASSERT(!eventType.isNull());
}

Event::~Event() = default;
Expand Down
32 changes: 18 additions & 14 deletions Source/WebCore/dom/Event.h
Expand Up @@ -43,8 +43,9 @@ class Event : public ScriptWrappable, public RefCounted<Event> {
enum class IsTrusted : uint8_t { No, Yes };
enum class CanBubble : uint8_t { No, Yes };
enum class IsCancelable : uint8_t { No, Yes };
enum class IsComposed : uint8_t { No, Yes };

enum PhaseType {
enum PhaseType {
NONE = 0,
CAPTURING_PHASE = 1,
AT_TARGET = 2,
Expand Down Expand Up @@ -148,24 +149,27 @@ class Event : public ScriptWrappable, public RefCounted<Event> {
virtual void receivedTarget() { }

private:
AtomicString m_type;
explicit Event(MonotonicTime createTime, const AtomicString& type, IsTrusted, CanBubble, IsCancelable, IsComposed);

void setCanceledFlagIfPossible();

bool m_isInitialized { false };
bool m_canBubble { false };
bool m_cancelable { false };
bool m_composed { false };
AtomicString m_type;

unsigned m_isInitialized : 1;
unsigned m_canBubble : 1;
unsigned m_cancelable : 1;
unsigned m_composed : 1;

unsigned m_propagationStopped : 1;
unsigned m_immediatePropagationStopped : 1;
unsigned m_wasCanceled : 1;
unsigned m_defaultHandled : 1;
unsigned m_isDefaultEventHandlerIgnored : 1;
unsigned m_isTrusted : 1;
unsigned m_isExecutingPassiveEventListener : 1;

bool m_propagationStopped { false };
bool m_immediatePropagationStopped { false };
bool m_wasCanceled { false };
bool m_defaultHandled { false };
bool m_isDefaultEventHandlerIgnored { false };
bool m_isTrusted { false };
bool m_isExecutingPassiveEventListener { false };
unsigned m_eventPhase : 2;

PhaseType m_eventPhase { NONE };
RefPtr<EventTarget> m_currentTarget;
const EventPath* m_eventPath { nullptr };
RefPtr<EventTarget> m_target;
Expand Down

0 comments on commit 10c1cf7

Please sign in to comment.