summaryrefslogtreecommitdiff
path: root/dom/events
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2017-07-05 01:56:28 +0200
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2017-07-05 01:56:28 +0200
commit74aabfc1feb223a44c8133d9fc8f84932385f583 (patch)
tree4123064b7832755705258af969d6b2232d64c291 /dom/events
parentbdff0cd04ab27260cbe6439ac6019f6ee1c5d65a (diff)
downloadpalemoon-gre-74aabfc1feb223a44c8133d9fc8f84932385f583.tar.gz
DOM - implement selection events (move cancelBubble to Event)
Diffstat (limited to 'dom/events')
-rw-r--r--dom/events/Event.cpp15
-rw-r--r--dom/events/Event.h9
-rw-r--r--dom/events/UIEvent.cpp15
-rw-r--r--dom/events/UIEvent.h5
-rw-r--r--dom/events/test/mochitest.ini1
-rw-r--r--dom/events/test/test_bug1298970.html33
6 files changed, 57 insertions, 21 deletions
diff --git a/dom/events/Event.cpp b/dom/events/Event.cpp
index b35ac0570..b296a6d98 100644
--- a/dom/events/Event.cpp
+++ b/dom/events/Event.cpp
@@ -1243,6 +1243,21 @@ Event::GetShadowRelatedTarget(nsIContent* aCurrentTarget,
return nullptr;
}
+NS_IMETHODIMP
+Event::GetCancelBubble(bool* aCancelBubble)
+{
+ NS_ENSURE_ARG_POINTER(aCancelBubble);
+ *aCancelBubble = CancelBubble();
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+Event::SetCancelBubble(bool aCancelBubble)
+{
+ mEvent->mFlags.mPropagationStopped = aCancelBubble;
+ return NS_OK;
+}
+
} // namespace dom
} // namespace mozilla
diff --git a/dom/events/Event.h b/dom/events/Event.h
index a78522533..246a04b68 100644
--- a/dom/events/Event.h
+++ b/dom/events/Event.h
@@ -183,6 +183,11 @@ public:
return mEvent->mFlags.mCancelable;
}
+ bool CancelBubble() const
+ {
+ return mEvent->mFlags.mPropagationStopped;
+ }
+
// xpidl implementation
// void PreventDefault();
@@ -335,7 +340,9 @@ private:
NS_IMETHOD_(WidgetEvent*) GetInternalNSEvent(void) override { return _to GetInternalNSEvent(); } \
NS_IMETHOD_(void) SetTrusted(bool aTrusted) override { _to SetTrusted(aTrusted); } \
NS_IMETHOD_(void) SetOwner(EventTarget* aOwner) override { _to SetOwner(aOwner); } \
- NS_IMETHOD_(Event*) InternalDOMEvent() override { return _to InternalDOMEvent(); }
+ NS_IMETHOD_(Event*) InternalDOMEvent() override { return _to InternalDOMEvent(); } \
+ NS_IMETHOD GetCancelBubble(bool* aCancelBubble) override { return _to GetCancelBubble(aCancelBubble); } \
+ NS_IMETHOD SetCancelBubble(bool aCancelBubble) override { return _to SetCancelBubble(aCancelBubble); }
#define NS_FORWARD_TO_EVENT_NO_SERIALIZATION_NO_DUPLICATION \
NS_FORWARD_NSIDOMEVENT_NO_SERIALIZATION_NO_DUPLICATION(Event::)
diff --git a/dom/events/UIEvent.cpp b/dom/events/UIEvent.cpp
index 9a0dbeead..604742a45 100644
--- a/dom/events/UIEvent.cpp
+++ b/dom/events/UIEvent.cpp
@@ -277,21 +277,6 @@ UIEvent::RangeOffset() const
return targetFrame->GetContentOffsetsFromPoint(pt).offset;
}
-NS_IMETHODIMP
-UIEvent::GetCancelBubble(bool* aCancelBubble)
-{
- NS_ENSURE_ARG_POINTER(aCancelBubble);
- *aCancelBubble = CancelBubble();
- return NS_OK;
-}
-
-NS_IMETHODIMP
-UIEvent::SetCancelBubble(bool aCancelBubble)
-{
- mEvent->mFlags.mPropagationStopped = aCancelBubble;
- return NS_OK;
-}
-
nsIntPoint
UIEvent::GetLayerPoint() const
{
diff --git a/dom/events/UIEvent.h b/dom/events/UIEvent.h
index a35da4cee..9d95f8334 100644
--- a/dom/events/UIEvent.h
+++ b/dom/events/UIEvent.h
@@ -142,11 +142,6 @@ public:
int32_t RangeOffset() const;
- bool CancelBubble() const
- {
- return mEvent->mFlags.mPropagationStopped;
- }
-
bool IsChar() const;
protected:
diff --git a/dom/events/test/mochitest.ini b/dom/events/test/mochitest.ini
index b14ecdd4f..2b1856e9e 100644
--- a/dom/events/test/mochitest.ini
+++ b/dom/events/test/mochitest.ini
@@ -183,3 +183,4 @@ support-files =
bug1096146_embedded.html
[test_offsetxy.html]
[test_bug1304044.html]
+[test_bug1298970.html]
diff --git a/dom/events/test/test_bug1298970.html b/dom/events/test/test_bug1298970.html
new file mode 100644
index 000000000..6b00aabff
--- /dev/null
+++ b/dom/events/test/test_bug1298970.html
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1298970
+-->
+<head>
+ <title>Test for Bug 1298970</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1298970">Mozilla Bug 1298970</a>
+<p id="display"></p>
+<div id="inner"></div>
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 1298970 **/
+var target = document.getElementById("inner");
+var event = new Event("test", { bubbles: true, cancelable: true });
+
+is(event.cancelBubble, false, "Event.cancelBubble should be false by default");
+
+target.addEventListener("test", (e) => {
+ e.stopPropagation();
+ is(e.cancelBubble, true, "Event.cancelBubble should be true after stopPropagation");
+}, true);
+
+target.dispatchEvent(event);
+
+</script>
+</body>
+</html>
+