summaryrefslogtreecommitdiffstats
path: root/widget/WidgetEventImpl.cpp
diff options
context:
space:
mode:
authorMoonchild <mcwerewolf@gmail.com>2018-06-27 14:10:49 +0200
committerGitHub <noreply@github.com>2018-06-27 14:10:49 +0200
commit9168a0fc95f523c7c852ca95969edb39069f4a03 (patch)
treed9e7ea0c5086235d0cfa7a7cc34f1760a4d74bb4 /widget/WidgetEventImpl.cpp
parenta3724697dc38820c4918b9e674ff56d2c15c5bba (diff)
parent783b60aae187d75c8c1924eceec8c4c56aa40c5e (diff)
downloadUXP-9168a0fc95f523c7c852ca95969edb39069f4a03.tar
UXP-9168a0fc95f523c7c852ca95969edb39069f4a03.tar.gz
UXP-9168a0fc95f523c7c852ca95969edb39069f4a03.tar.lz
UXP-9168a0fc95f523c7c852ca95969edb39069f4a03.tar.xz
UXP-9168a0fc95f523c7c852ca95969edb39069f4a03.zip
Merge pull request #554 from MoonchildProductions/issue12
Resolve potential null deref crashes in the editor
Diffstat (limited to 'widget/WidgetEventImpl.cpp')
-rw-r--r--widget/WidgetEventImpl.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/widget/WidgetEventImpl.cpp b/widget/WidgetEventImpl.cpp
index 7dd292cb0..59c80672b 100644
--- a/widget/WidgetEventImpl.cpp
+++ b/widget/WidgetEventImpl.cpp
@@ -12,6 +12,7 @@
#include "mozilla/Preferences.h"
#include "mozilla/TextEvents.h"
#include "mozilla/TouchEvents.h"
+#include "nsIDOMEventTarget.h"
#include "nsPrintfCString.h"
namespace mozilla {
@@ -411,6 +412,39 @@ WidgetEvent::IsAllowedToDispatchDOMEvent() const
}
/******************************************************************************
+ * mozilla::WidgetEvent
+ *
+ * Misc methods.
+ ******************************************************************************/
+
+static dom::EventTarget*
+GetTargetForDOMEvent(nsIDOMEventTarget* aTarget)
+{
+ return aTarget ? aTarget->GetTargetForDOMEvent() : nullptr;
+}
+
+dom::EventTarget*
+WidgetEvent::GetDOMEventTarget() const
+{
+ return GetTargetForDOMEvent(mTarget);
+}
+
+dom::EventTarget*
+WidgetEvent::GetCurrentDOMEventTarget() const
+{
+ return GetTargetForDOMEvent(mCurrentTarget);
+}
+
+dom::EventTarget*
+WidgetEvent::GetOriginalDOMEventTarget() const
+{
+ if (mOriginalTarget) {
+ return GetTargetForDOMEvent(mOriginalTarget);
+ }
+ return GetDOMEventTarget();
+}
+
+/******************************************************************************
* mozilla::WidgetInputEvent
******************************************************************************/