|
|
@@ -75,8 +75,8 @@ void Initialize()
|
|
|
{EventId::Handledrag , "handledrag" , false , true , DefaultActionPhase::None},
|
|
|
{EventId::Resize , "resize" , false , false , DefaultActionPhase::None},
|
|
|
{EventId::Scroll , "scroll" , false , true , DefaultActionPhase::None},
|
|
|
- {EventId::Animationend , "animationend" , true , true , DefaultActionPhase::None},
|
|
|
- {EventId::Transitionend , "transitionend" , true , true , DefaultActionPhase::None},
|
|
|
+ {EventId::Animationend , "animationend" , false , true , DefaultActionPhase::None},
|
|
|
+ {EventId::Transitionend , "transitionend" , false , true , DefaultActionPhase::None},
|
|
|
|
|
|
{EventId::Change , "change" , false , true , DefaultActionPhase::None},
|
|
|
{EventId::Submit , "submit" , true , true , DefaultActionPhase::None},
|
|
|
@@ -105,7 +105,7 @@ void Initialize()
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
-const EventSpecification& Get(EventId id)
|
|
|
+static EventSpecification& GetMutable(EventId id)
|
|
|
{
|
|
|
size_t i = static_cast<size_t>(id);
|
|
|
if (i < specifications.size())
|
|
|
@@ -113,22 +113,14 @@ const EventSpecification& Get(EventId id)
|
|
|
return specifications[0];
|
|
|
}
|
|
|
|
|
|
-const EventSpecification& GetOrInsert(const String& event_type)
|
|
|
-{
|
|
|
- // Default values for new event types defined as follows:
|
|
|
- constexpr bool interruptible = true;
|
|
|
- constexpr bool bubbles = true;
|
|
|
- constexpr DefaultActionPhase default_action_phase = DefaultActionPhase::None;
|
|
|
-
|
|
|
- return GetOrInsert(event_type, interruptible, bubbles, default_action_phase);
|
|
|
-}
|
|
|
-
|
|
|
-const EventSpecification& GetOrInsert(const String& event_type, bool interruptible, bool bubbles, DefaultActionPhase default_action_phase)
|
|
|
+// Get event specification for the given type.
|
|
|
+// If not found: Inserts a new entry with given values.
|
|
|
+static EventSpecification& GetOrInsert(const String& event_type, bool interruptible, bool bubbles, DefaultActionPhase default_action_phase)
|
|
|
{
|
|
|
auto it = type_lookup.find(event_type);
|
|
|
|
|
|
if (it != type_lookup.end())
|
|
|
- return Get(it->second);
|
|
|
+ return GetMutable(it->second);
|
|
|
|
|
|
// No specification found for this name, insert a new entry with default values
|
|
|
EventId new_id = static_cast<EventId>(specifications.size());
|
|
|
@@ -137,6 +129,21 @@ const EventSpecification& GetOrInsert(const String& event_type, bool interruptib
|
|
|
return specifications.back();
|
|
|
}
|
|
|
|
|
|
+const EventSpecification& Get(EventId id)
|
|
|
+{
|
|
|
+ return GetMutable(id);
|
|
|
+}
|
|
|
+
|
|
|
+const EventSpecification& GetOrInsert(const String& event_type)
|
|
|
+{
|
|
|
+ // Default values for new event types defined as follows:
|
|
|
+ constexpr bool interruptible = true;
|
|
|
+ constexpr bool bubbles = true;
|
|
|
+ constexpr DefaultActionPhase default_action_phase = DefaultActionPhase::None;
|
|
|
+
|
|
|
+ return GetOrInsert(event_type, interruptible, bubbles, default_action_phase);
|
|
|
+}
|
|
|
+
|
|
|
EventId GetIdOrInsert(const String& event_type)
|
|
|
{
|
|
|
auto it = type_lookup.find(event_type);
|
|
|
@@ -146,6 +153,23 @@ EventId GetIdOrInsert(const String& event_type)
|
|
|
return GetOrInsert(event_type).id;
|
|
|
}
|
|
|
|
|
|
+EventId InsertOrReplaceCustom(const String& event_type, bool interruptible, bool bubbles, DefaultActionPhase default_action_phase)
|
|
|
+{
|
|
|
+ const size_t size_before = specifications.size();
|
|
|
+ EventSpecification& specification = GetOrInsert(event_type, interruptible, bubbles, default_action_phase);
|
|
|
+ bool got_existing_entry = (size_before == specifications.size());
|
|
|
+
|
|
|
+ // If we found an existing entry of same type, replace it, but only if it is a custom event id.
|
|
|
+ if (got_existing_entry && (int)specification.id >= (int)EventId::FirstCustomId)
|
|
|
+ {
|
|
|
+ specification.interruptible = interruptible;
|
|
|
+ specification.bubbles = bubbles;
|
|
|
+ specification.default_action_phase = default_action_phase;
|
|
|
+ }
|
|
|
+
|
|
|
+ return specification.id;
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
}
|
|
|
}
|