Bug 1298970 - Move UIEvent.cancelBubble to Event. r=smaug

MozReview-Commit-ID: JPc1JwfqpaZ

--HG--
extra : rebase_source : 9cad67011a76b0084bdc8b271de8356666068e0d
This commit is contained in:
Stone Shih 2016-11-29 10:28:21 +08:00
Родитель cb9b077de5
Коммит d5527884b7
10 изменённых файлов: 59 добавлений и 25 удалений

Просмотреть файл

@ -1255,6 +1255,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

Просмотреть файл

@ -176,6 +176,11 @@ public:
return mEvent->mFlags.mComposed;
}
bool CancelBubble() const
{
return mEvent->PropagationStopped();
}
// xpidl implementation
// void PreventDefault();
@ -383,7 +388,9 @@ private:
NS_IMETHOD_(WidgetEvent*) WidgetEventPtr(void) override { return _to WidgetEventPtr(); } \
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::) \

Просмотреть файл

@ -288,21 +288,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
{

Просмотреть файл

@ -93,11 +93,6 @@ public:
int32_t RangeOffset() const;
bool CancelBubble() const
{
return mEvent->PropagationStopped();
}
bool IsChar() const;
protected:

Просмотреть файл

@ -184,3 +184,4 @@ skip-if = toolkit == 'android' #CRASH_DUMP, RANDOM
[test_wheel_default_action.html]
[test_bug687787.html]
[test_bug1305458.html]
[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>

Просмотреть файл

@ -205,6 +205,7 @@ interface nsIDOMEvent : nsISupports
boolean getPreventDefault();
readonly attribute boolean isTrusted;
attribute boolean cancelBubble;
[noscript] void duplicatePrivateData();
[noscript] void setTarget(in nsIDOMEventTarget aTarget);

Просмотреть файл

@ -49,8 +49,6 @@ interface nsIDOMUIEvent : nsISupports
readonly attribute nsIDOMNode rangeParent;
readonly attribute long rangeOffset;
attribute boolean cancelBubble;
readonly attribute boolean isChar;
[notxpcom, nostdcall] EventPtr AsEvent();

Просмотреть файл

@ -51,6 +51,7 @@ interface Event {
readonly attribute DOMHighResTimeStamp timeStamp;
void initEvent(DOMString type, boolean bubbles, boolean cancelable);
attribute boolean cancelBubble;
};
// Mozilla specific legacy stuff.
@ -65,7 +66,6 @@ partial interface Event {
[ChromeOnly] readonly attribute EventTarget? composedTarget;
[ChromeOnly] readonly attribute boolean multipleActionsPrevented;
[ChromeOnly] readonly attribute boolean isSynthesized;
boolean getPreventDefault();
};

Просмотреть файл

@ -34,7 +34,6 @@ partial interface UIEvent {
readonly attribute unsigned long which;
readonly attribute Node? rangeParent;
readonly attribute long rangeOffset;
attribute boolean cancelBubble;
readonly attribute boolean isChar;
};