widget/ContentEvents.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef mozilla_ContentEvents_h__
michael@0 7 #define mozilla_ContentEvents_h__
michael@0 8
michael@0 9 #include <stdint.h>
michael@0 10
michael@0 11 #include "mozilla/BasicEvents.h"
michael@0 12 #include "mozilla/dom/DataTransfer.h"
michael@0 13 #include "mozilla/dom/EventTarget.h"
michael@0 14 #include "nsCOMPtr.h"
michael@0 15 #include "nsRect.h"
michael@0 16 #include "nsStringGlue.h"
michael@0 17
michael@0 18 class nsIContent;
michael@0 19
michael@0 20 namespace mozilla {
michael@0 21
michael@0 22 /******************************************************************************
michael@0 23 * mozilla::InternalScrollPortEvent
michael@0 24 ******************************************************************************/
michael@0 25
michael@0 26 class InternalScrollPortEvent : public WidgetGUIEvent
michael@0 27 {
michael@0 28 public:
michael@0 29 virtual InternalScrollPortEvent* AsScrollPortEvent() MOZ_OVERRIDE
michael@0 30 {
michael@0 31 return this;
michael@0 32 }
michael@0 33
michael@0 34 enum orientType
michael@0 35 {
michael@0 36 vertical = 0,
michael@0 37 horizontal = 1,
michael@0 38 both = 2
michael@0 39 };
michael@0 40
michael@0 41 InternalScrollPortEvent(bool aIsTrusted, uint32_t aMessage,
michael@0 42 nsIWidget* aWidget) :
michael@0 43 WidgetGUIEvent(aIsTrusted, aMessage, aWidget, NS_SCROLLPORT_EVENT),
michael@0 44 orient(vertical)
michael@0 45 {
michael@0 46 }
michael@0 47
michael@0 48 virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
michael@0 49 {
michael@0 50 MOZ_ASSERT(eventStructType == NS_SCROLLPORT_EVENT,
michael@0 51 "Duplicate() must be overridden by sub class");
michael@0 52 // Not copying widget, it is a weak reference.
michael@0 53 InternalScrollPortEvent* result =
michael@0 54 new InternalScrollPortEvent(false, message, nullptr);
michael@0 55 result->AssignScrollPortEventData(*this, true);
michael@0 56 result->mFlags = mFlags;
michael@0 57 return result;
michael@0 58 }
michael@0 59
michael@0 60 orientType orient;
michael@0 61
michael@0 62 void AssignScrollPortEventData(const InternalScrollPortEvent& aEvent,
michael@0 63 bool aCopyTargets)
michael@0 64 {
michael@0 65 AssignGUIEventData(aEvent, aCopyTargets);
michael@0 66
michael@0 67 orient = aEvent.orient;
michael@0 68 }
michael@0 69 };
michael@0 70
michael@0 71 /******************************************************************************
michael@0 72 * mozilla::InternalScrollPortEvent
michael@0 73 ******************************************************************************/
michael@0 74
michael@0 75 class InternalScrollAreaEvent : public WidgetGUIEvent
michael@0 76 {
michael@0 77 public:
michael@0 78 virtual InternalScrollAreaEvent* AsScrollAreaEvent() MOZ_OVERRIDE
michael@0 79 {
michael@0 80 return this;
michael@0 81 }
michael@0 82
michael@0 83 InternalScrollAreaEvent(bool aIsTrusted, uint32_t aMessage,
michael@0 84 nsIWidget* aWidget) :
michael@0 85 WidgetGUIEvent(aIsTrusted, aMessage, aWidget, NS_SCROLLAREA_EVENT)
michael@0 86 {
michael@0 87 }
michael@0 88
michael@0 89 virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
michael@0 90 {
michael@0 91 MOZ_ASSERT(eventStructType == NS_SCROLLAREA_EVENT,
michael@0 92 "Duplicate() must be overridden by sub class");
michael@0 93 // Not copying widget, it is a weak reference.
michael@0 94 InternalScrollAreaEvent* result =
michael@0 95 new InternalScrollAreaEvent(false, message, nullptr);
michael@0 96 result->AssignScrollAreaEventData(*this, true);
michael@0 97 result->mFlags = mFlags;
michael@0 98 return result;
michael@0 99 }
michael@0 100
michael@0 101 nsRect mArea;
michael@0 102
michael@0 103 void AssignScrollAreaEventData(const InternalScrollAreaEvent& aEvent,
michael@0 104 bool aCopyTargets)
michael@0 105 {
michael@0 106 AssignGUIEventData(aEvent, aCopyTargets);
michael@0 107
michael@0 108 mArea = aEvent.mArea;
michael@0 109 }
michael@0 110 };
michael@0 111
michael@0 112 /******************************************************************************
michael@0 113 * mozilla::InternalFormEvent
michael@0 114 *
michael@0 115 * We hold the originating form control for form submit and reset events.
michael@0 116 * originator is a weak pointer (does not hold a strong reference).
michael@0 117 ******************************************************************************/
michael@0 118
michael@0 119 class InternalFormEvent : public WidgetEvent
michael@0 120 {
michael@0 121 public:
michael@0 122 virtual InternalFormEvent* AsFormEvent() MOZ_OVERRIDE { return this; }
michael@0 123
michael@0 124 InternalFormEvent(bool aIsTrusted, uint32_t aMessage) :
michael@0 125 WidgetEvent(aIsTrusted, aMessage, NS_FORM_EVENT),
michael@0 126 originator(nullptr)
michael@0 127 {
michael@0 128 }
michael@0 129
michael@0 130 virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
michael@0 131 {
michael@0 132 MOZ_ASSERT(eventStructType == NS_FORM_EVENT,
michael@0 133 "Duplicate() must be overridden by sub class");
michael@0 134 InternalFormEvent* result = new InternalFormEvent(false, message);
michael@0 135 result->AssignFormEventData(*this, true);
michael@0 136 result->mFlags = mFlags;
michael@0 137 return result;
michael@0 138 }
michael@0 139
michael@0 140 nsIContent *originator;
michael@0 141
michael@0 142 void AssignFormEventData(const InternalFormEvent& aEvent, bool aCopyTargets)
michael@0 143 {
michael@0 144 AssignEventData(aEvent, aCopyTargets);
michael@0 145
michael@0 146 // Don't copy originator due to a weak pointer.
michael@0 147 }
michael@0 148 };
michael@0 149
michael@0 150 /******************************************************************************
michael@0 151 * mozilla::InternalClipboardEvent
michael@0 152 ******************************************************************************/
michael@0 153
michael@0 154 class InternalClipboardEvent : public WidgetEvent
michael@0 155 {
michael@0 156 public:
michael@0 157 virtual InternalClipboardEvent* AsClipboardEvent() MOZ_OVERRIDE
michael@0 158 {
michael@0 159 return this;
michael@0 160 }
michael@0 161
michael@0 162 InternalClipboardEvent(bool aIsTrusted, uint32_t aMessage) :
michael@0 163 WidgetEvent(aIsTrusted, aMessage, NS_CLIPBOARD_EVENT)
michael@0 164 {
michael@0 165 }
michael@0 166
michael@0 167 virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
michael@0 168 {
michael@0 169 MOZ_ASSERT(eventStructType == NS_CLIPBOARD_EVENT,
michael@0 170 "Duplicate() must be overridden by sub class");
michael@0 171 InternalClipboardEvent* result = new InternalClipboardEvent(false, message);
michael@0 172 result->AssignClipboardEventData(*this, true);
michael@0 173 result->mFlags = mFlags;
michael@0 174 return result;
michael@0 175 }
michael@0 176
michael@0 177 nsCOMPtr<dom::DataTransfer> clipboardData;
michael@0 178
michael@0 179 void AssignClipboardEventData(const InternalClipboardEvent& aEvent,
michael@0 180 bool aCopyTargets)
michael@0 181 {
michael@0 182 AssignEventData(aEvent, aCopyTargets);
michael@0 183
michael@0 184 clipboardData = aEvent.clipboardData;
michael@0 185 }
michael@0 186 };
michael@0 187
michael@0 188 /******************************************************************************
michael@0 189 * mozilla::InternalFocusEvent
michael@0 190 ******************************************************************************/
michael@0 191
michael@0 192 class InternalFocusEvent : public InternalUIEvent
michael@0 193 {
michael@0 194 public:
michael@0 195 virtual InternalFocusEvent* AsFocusEvent() MOZ_OVERRIDE { return this; }
michael@0 196
michael@0 197 InternalFocusEvent(bool aIsTrusted, uint32_t aMessage) :
michael@0 198 InternalUIEvent(aIsTrusted, aMessage, NS_FOCUS_EVENT),
michael@0 199 fromRaise(false), isRefocus(false)
michael@0 200 {
michael@0 201 }
michael@0 202
michael@0 203 virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
michael@0 204 {
michael@0 205 MOZ_ASSERT(eventStructType == NS_FOCUS_EVENT,
michael@0 206 "Duplicate() must be overridden by sub class");
michael@0 207 InternalFocusEvent* result = new InternalFocusEvent(false, message);
michael@0 208 result->AssignFocusEventData(*this, true);
michael@0 209 result->mFlags = mFlags;
michael@0 210 return result;
michael@0 211 }
michael@0 212
michael@0 213 /// The possible related target
michael@0 214 nsCOMPtr<dom::EventTarget> relatedTarget;
michael@0 215
michael@0 216 bool fromRaise;
michael@0 217 bool isRefocus;
michael@0 218
michael@0 219 void AssignFocusEventData(const InternalFocusEvent& aEvent, bool aCopyTargets)
michael@0 220 {
michael@0 221 AssignUIEventData(aEvent, aCopyTargets);
michael@0 222
michael@0 223 relatedTarget = aCopyTargets ? aEvent.relatedTarget : nullptr;
michael@0 224 fromRaise = aEvent.fromRaise;
michael@0 225 isRefocus = aEvent.isRefocus;
michael@0 226 }
michael@0 227 };
michael@0 228
michael@0 229 /******************************************************************************
michael@0 230 * mozilla::InternalTransitionEvent
michael@0 231 ******************************************************************************/
michael@0 232
michael@0 233 class InternalTransitionEvent : public WidgetEvent
michael@0 234 {
michael@0 235 public:
michael@0 236 virtual InternalTransitionEvent* AsTransitionEvent() MOZ_OVERRIDE
michael@0 237 {
michael@0 238 return this;
michael@0 239 }
michael@0 240
michael@0 241 InternalTransitionEvent(bool aIsTrusted, uint32_t aMessage)
michael@0 242 : WidgetEvent(aIsTrusted, aMessage, NS_TRANSITION_EVENT)
michael@0 243 , elapsedTime(0.0)
michael@0 244 {
michael@0 245 mFlags.mCancelable = false;
michael@0 246 }
michael@0 247
michael@0 248 virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
michael@0 249 {
michael@0 250 MOZ_ASSERT(eventStructType == NS_TRANSITION_EVENT,
michael@0 251 "Duplicate() must be overridden by sub class");
michael@0 252 InternalTransitionEvent* result =
michael@0 253 new InternalTransitionEvent(false, message);
michael@0 254 result->AssignTransitionEventData(*this, true);
michael@0 255 result->mFlags = mFlags;
michael@0 256 return result;
michael@0 257 }
michael@0 258
michael@0 259 nsString propertyName;
michael@0 260 float elapsedTime;
michael@0 261 nsString pseudoElement;
michael@0 262
michael@0 263 void AssignTransitionEventData(const InternalTransitionEvent& aEvent,
michael@0 264 bool aCopyTargets)
michael@0 265 {
michael@0 266 AssignEventData(aEvent, aCopyTargets);
michael@0 267
michael@0 268 propertyName = aEvent.propertyName;
michael@0 269 elapsedTime = aEvent.elapsedTime;
michael@0 270 pseudoElement = aEvent.pseudoElement;
michael@0 271 }
michael@0 272 };
michael@0 273
michael@0 274 /******************************************************************************
michael@0 275 * mozilla::InternalAnimationEvent
michael@0 276 ******************************************************************************/
michael@0 277
michael@0 278 class InternalAnimationEvent : public WidgetEvent
michael@0 279 {
michael@0 280 public:
michael@0 281 virtual InternalAnimationEvent* AsAnimationEvent() MOZ_OVERRIDE
michael@0 282 {
michael@0 283 return this;
michael@0 284 }
michael@0 285
michael@0 286 InternalAnimationEvent(bool aIsTrusted, uint32_t aMessage)
michael@0 287 : WidgetEvent(aIsTrusted, aMessage, NS_ANIMATION_EVENT)
michael@0 288 , elapsedTime(0.0)
michael@0 289 {
michael@0 290 mFlags.mCancelable = false;
michael@0 291 }
michael@0 292
michael@0 293 virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
michael@0 294 {
michael@0 295 MOZ_ASSERT(eventStructType == NS_ANIMATION_EVENT,
michael@0 296 "Duplicate() must be overridden by sub class");
michael@0 297 InternalAnimationEvent* result = new InternalAnimationEvent(false, message);
michael@0 298 result->AssignAnimationEventData(*this, true);
michael@0 299 result->mFlags = mFlags;
michael@0 300 return result;
michael@0 301 }
michael@0 302
michael@0 303 nsString animationName;
michael@0 304 float elapsedTime;
michael@0 305 nsString pseudoElement;
michael@0 306
michael@0 307 void AssignAnimationEventData(const InternalAnimationEvent& aEvent,
michael@0 308 bool aCopyTargets)
michael@0 309 {
michael@0 310 AssignEventData(aEvent, aCopyTargets);
michael@0 311
michael@0 312 animationName = aEvent.animationName;
michael@0 313 elapsedTime = aEvent.elapsedTime;
michael@0 314 pseudoElement = aEvent.pseudoElement;
michael@0 315 }
michael@0 316 };
michael@0 317
michael@0 318 } // namespace mozilla
michael@0 319
michael@0 320 #endif // mozilla_ContentEvents_h__

mercurial