summaryrefslogtreecommitdiffstats
path: root/dom/events
diff options
context:
space:
mode:
Diffstat (limited to 'dom/events')
-rw-r--r--dom/events/Clipboard.cpp37
-rw-r--r--dom/events/Clipboard.h2
-rw-r--r--dom/events/ClipboardItem.cpp12
-rw-r--r--dom/events/ClipboardItem.h2
-rw-r--r--dom/events/DataTransfer.cpp4
-rw-r--r--dom/events/DataTransferItem.cpp8
-rw-r--r--dom/events/DataTransferItem.h2
-rw-r--r--dom/events/EventStateManager.cpp7
-rw-r--r--dom/events/IMEStateManager.cpp2
-rw-r--r--dom/events/WheelHandlingHelper.cpp7
-rw-r--r--dom/events/test/pointerevents/mochitest.toml1
-rw-r--r--dom/events/test/pointerevents/test_getCoalescedEvents.html43
-rw-r--r--dom/events/test/test_dom_storage_event.html4
13 files changed, 80 insertions, 51 deletions
diff --git a/dom/events/Clipboard.cpp b/dom/events/Clipboard.cpp
index b797f93961..3574d08365 100644
--- a/dom/events/Clipboard.cpp
+++ b/dom/events/Clipboard.cpp
@@ -59,6 +59,19 @@ bool Clipboard::IsTestingPrefEnabledOrHasReadPermission(
nsGkAtoms::clipboardRead);
}
+// Mandatory data types defined in
+// https://w3c.github.io/clipboard-apis/#mandatory-data-types-x. The types
+// should be in the same order as kNonPlainTextExternalFormats in
+// DataTransfer.
+static const nsLiteralCString kMandatoryDataTypes[] = {
+ nsLiteralCString(kHTMLMime), nsLiteralCString(kTextMime),
+ nsLiteralCString(kPNGImageMime)};
+
+// static
+Span<const nsLiteralCString> Clipboard::MandatoryDataTypes() {
+ return Span<const nsLiteralCString>(kMandatoryDataTypes);
+}
+
namespace {
/**
@@ -87,16 +100,6 @@ class ClipboardGetCallback : public nsIAsyncClipboardGetCallback {
RefPtr<Promise> mPromise;
};
-static nsTArray<nsCString> MandatoryDataTypesAsCStrings() {
- // Mandatory data types defined in
- // https://w3c.github.io/clipboard-apis/#mandatory-data-types-x. The types
- // should be in the same order as kNonPlainTextExternalFormats in
- // DataTransfer.
- return nsTArray<nsCString>{nsLiteralCString(kHTMLMime),
- nsLiteralCString(kTextMime),
- nsLiteralCString(kPNGImageMime)};
-}
-
class ClipboardGetCallbackForRead final : public ClipboardGetCallback {
public:
explicit ClipboardGetCallbackForRead(nsIGlobalObject* aGlobal,
@@ -122,7 +125,7 @@ class ClipboardGetCallbackForRead final : public ClipboardGetCallback {
AutoTArray<RefPtr<ClipboardItem::ItemEntry>, 3> entries;
// We might reuse the request from DataTransfer created for paste event,
// which could contain more types that are not in the mandatory list.
- for (const auto& format : MandatoryDataTypesAsCStrings()) {
+ for (const auto& format : kMandatoryDataTypes) {
if (flavorList.Contains(format)) {
auto entry = MakeRefPtr<ClipboardItem::ItemEntry>(
mGlobal, NS_ConvertUTF8toUTF16(format));
@@ -287,10 +290,13 @@ void Clipboard::RequestRead(Promise* aPromise, ReadRequestType aType,
return;
}
+ AutoTArray<nsCString, ArrayLength(kMandatoryDataTypes)> types;
+ types.AppendElements(Span<const nsLiteralCString>(kMandatoryDataTypes));
+
callback = MakeRefPtr<ClipboardGetCallbackForRead>(global, std::move(p));
- rv = clipboardService->AsyncGetData(
- MandatoryDataTypesAsCStrings(), nsIClipboard::kGlobalClipboard,
- owner->GetWindowContext(), &aPrincipal, callback);
+ rv = clipboardService->AsyncGetData(types, nsIClipboard::kGlobalClipboard,
+ owner->GetWindowContext(),
+ &aPrincipal, callback);
break;
}
case ReadRequestType::eReadText: {
@@ -731,7 +737,8 @@ already_AddRefed<Promise> Clipboard::Write(
RefPtr<ClipboardWriteCallback> callback =
MakeRefPtr<ClipboardWriteCallback>(p, aData[0]);
nsresult rv = clipboard->AsyncSetData(nsIClipboard::kGlobalClipboard,
- callback, getter_AddRefs(request));
+ owner->GetWindowContext(), callback,
+ getter_AddRefs(request));
if (NS_FAILED(rv)) {
p->MaybeReject(rv);
return p.forget();
diff --git a/dom/events/Clipboard.h b/dom/events/Clipboard.h
index a9952e6052..f4d44c25db 100644
--- a/dom/events/Clipboard.h
+++ b/dom/events/Clipboard.h
@@ -51,6 +51,8 @@ class Clipboard : public DOMEventTargetHelper {
// testing purposes.
static bool ReadTextEnabled(JSContext* aCx, JSObject* aGlobal);
+ static Span<const nsLiteralCString> MandatoryDataTypes();
+
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
diff --git a/dom/events/ClipboardItem.cpp b/dom/events/ClipboardItem.cpp
index 76196be3b6..0d5df85492 100644
--- a/dom/events/ClipboardItem.cpp
+++ b/dom/events/ClipboardItem.cpp
@@ -6,6 +6,7 @@
#include "mozilla/dom/ClipboardItem.h"
+#include "mozilla/dom/Clipboard.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/Record.h"
#include "nsComponentManagerUtils.h"
@@ -290,6 +291,17 @@ already_AddRefed<ClipboardItem> ClipboardItem::Constructor(
return item.forget();
}
+// static
+bool ClipboardItem::Supports(const GlobalObject& aGlobal,
+ const nsAString& aType) {
+ for (const auto& mandatoryType : Clipboard::MandatoryDataTypes()) {
+ if (CompareUTF8toUTF16(mandatoryType, aType) == 0) {
+ return true;
+ }
+ }
+ return false;
+}
+
void ClipboardItem::GetTypes(nsTArray<nsString>& aTypes) const {
for (const auto& item : mItems) {
aTypes.AppendElement(item->Type());
diff --git a/dom/events/ClipboardItem.h b/dom/events/ClipboardItem.h
index 9fe45bf936..53b914745c 100644
--- a/dom/events/ClipboardItem.h
+++ b/dom/events/ClipboardItem.h
@@ -107,6 +107,8 @@ class ClipboardItem final : public nsWrapperCache {
const Record<nsString, OwningNonNull<Promise>>& aItems,
const ClipboardItemOptions& aOptions, ErrorResult& aRv);
+ static bool Supports(const GlobalObject& aGlobal, const nsAString& aType);
+
dom::PresentationStyle PresentationStyle() const {
return mPresentationStyle;
};
diff --git a/dom/events/DataTransfer.cpp b/dom/events/DataTransfer.cpp
index ba56575749..b2f70dab54 100644
--- a/dom/events/DataTransfer.cpp
+++ b/dom/events/DataTransfer.cpp
@@ -909,7 +909,7 @@ already_AddRefed<nsITransferable> DataTransfer::GetTransferable(
// from another origin or from the OS.
if (mMode == Mode::ReadWrite) {
if (nsCOMPtr<nsIGlobalObject> global = GetGlobal()) {
- transferable->SetRequestingPrincipal(global->PrincipalOrNull());
+ transferable->SetDataPrincipal(global->PrincipalOrNull());
}
}
@@ -1083,7 +1083,7 @@ already_AddRefed<nsITransferable> DataTransfer::GetTransferable(
static_cast<char*>(stringBuffer->Data())[amountRead] = 0;
nsCString str;
- stringBuffer->ToString(totalCustomLength, str);
+ str.Assign(stringBuffer, totalCustomLength);
nsCOMPtr<nsISupportsCString> strSupports(
do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID));
strSupports->SetData(str);
diff --git a/dom/events/DataTransferItem.cpp b/dom/events/DataTransferItem.cpp
index 8b1aa1902c..27bce8bd8b 100644
--- a/dom/events/DataTransferItem.cpp
+++ b/dom/events/DataTransferItem.cpp
@@ -76,6 +76,7 @@ already_AddRefed<DataTransferItem> DataTransferItem::Clone(
it->mData = mData;
it->mPrincipal = mPrincipal;
it->mChromeOnly = mChromeOnly;
+ it->mDoNotAttemptToLoadData = mDoNotAttemptToLoadData;
return it.forget();
}
@@ -144,7 +145,7 @@ void DataTransferItem::SetData(nsIVariant* aData) {
}
void DataTransferItem::FillInExternalData() {
- if (mData) {
+ if (mData || mDoNotAttemptToLoadData) {
return;
}
@@ -183,6 +184,11 @@ void DataTransferItem::FillInExternalData() {
nsresult rv = clipboard->GetData(trans, mDataTransfer->ClipboardType(),
windowContext);
if (NS_WARN_IF(NS_FAILED(rv))) {
+ if (rv == NS_ERROR_CONTENT_BLOCKED) {
+ // If the load of this content was blocked by Content Analysis,
+ // do not attempt to load it again.
+ mDoNotAttemptToLoadData = true;
+ }
return;
}
} else {
diff --git a/dom/events/DataTransferItem.h b/dom/events/DataTransferItem.h
index 111f498e82..1e98ba8b92 100644
--- a/dom/events/DataTransferItem.h
+++ b/dom/events/DataTransferItem.h
@@ -42,6 +42,7 @@ class DataTransferItem final : public nsISupports, public nsWrapperCache {
mChromeOnly(false),
mKind(aKind),
mType(aType),
+ mDoNotAttemptToLoadData(false),
mDataTransfer(aDataTransfer) {
MOZ_ASSERT(mDataTransfer, "Must be associated with a DataTransfer");
}
@@ -122,6 +123,7 @@ class DataTransferItem final : public nsISupports, public nsWrapperCache {
eKind mKind;
const nsString mType;
nsCOMPtr<nsIVariant> mData;
+ bool mDoNotAttemptToLoadData;
nsCOMPtr<nsIPrincipal> mPrincipal;
RefPtr<DataTransfer> mDataTransfer;
diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp
index 3c24cdb30a..23803e5447 100644
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -15,6 +15,7 @@
#include "mozilla/HTMLEditor.h"
#include "mozilla/IMEStateManager.h"
#include "mozilla/Likely.h"
+#include "mozilla/FocusModel.h"
#include "mozilla/MiscEvents.h"
#include "mozilla/MathAlgorithms.h"
#include "mozilla/MouseEvents.h"
@@ -3728,14 +3729,14 @@ nsresult EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
break;
}
- if (frame->IsFocusable(/* aWithMouse = */ true)) {
+ auto flags = IsFocusableFlags::WithMouse;
+ if (frame->IsFocusable(flags)) {
break;
}
if (ShadowRoot* root = newFocus->GetShadowRoot()) {
if (root->DelegatesFocus()) {
- if (Element* firstFocusable =
- root->GetFocusDelegate(/* aWithMouse */ true)) {
+ if (Element* firstFocusable = root->GetFocusDelegate(flags)) {
newFocus = firstFocusable;
break;
}
diff --git a/dom/events/IMEStateManager.cpp b/dom/events/IMEStateManager.cpp
index 966b2f62f7..1e6affb111 100644
--- a/dom/events/IMEStateManager.cpp
+++ b/dom/events/IMEStateManager.cpp
@@ -1631,7 +1631,7 @@ MOZ_CAN_RUN_SCRIPT static bool IsNextFocusableElementTextControl(
// FIXME: Should probably use nsIFrame::IsFocusable if possible, to account
// for things like visibility: hidden or so.
- if (!nextElement->IsFocusableWithoutStyle(false)) {
+ if (!nextElement->IsFocusableWithoutStyle()) {
return false;
}
diff --git a/dom/events/WheelHandlingHelper.cpp b/dom/events/WheelHandlingHelper.cpp
index 3b5653c50e..1633c68d72 100644
--- a/dom/events/WheelHandlingHelper.cpp
+++ b/dom/events/WheelHandlingHelper.cpp
@@ -725,15 +725,10 @@ ESMAutoDirWheelDeltaAdjuster::ESMAutoDirWheelDeltaAdjuster(
}
WritingMode writingMode = honouredFrame->GetWritingMode();
- WritingMode::BlockDir blockDir = writingMode.GetBlockDir();
- WritingMode::InlineDir inlineDir = writingMode.GetInlineDir();
// Get whether the honoured frame's content in the horizontal direction starts
// from right to left(E.g. it's true either if "writing-mode: vertical-rl", or
// if "writing-mode: horizontal-tb; direction: rtl;" in CSS).
- mIsHorizontalContentRightToLeft =
- (blockDir == WritingMode::BlockDir::eBlockRL ||
- (blockDir == WritingMode::BlockDir::eBlockTB &&
- inlineDir == WritingMode::InlineDir::eInlineRTL));
+ mIsHorizontalContentRightToLeft = writingMode.IsPhysicalRTL();
}
void ESMAutoDirWheelDeltaAdjuster::OnAdjusted() {
diff --git a/dom/events/test/pointerevents/mochitest.toml b/dom/events/test/pointerevents/mochitest.toml
index c22e1bdf94..8d6990d4ff 100644
--- a/dom/events/test/pointerevents/mochitest.toml
+++ b/dom/events/test/pointerevents/mochitest.toml
@@ -64,7 +64,6 @@ support-files = ["!/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js
skip-if = [
"os == 'android'", # Bug 1312791
"display == 'wayland' && os_version == '22.04'", # Bug 1856971
- "verify && os == 'win'", # Bug 1659744
]
["test_getCoalescedEvents_touch.html"]
diff --git a/dom/events/test/pointerevents/test_getCoalescedEvents.html b/dom/events/test/pointerevents/test_getCoalescedEvents.html
index 69eeac6919..9c0c0c5baa 100644
--- a/dom/events/test/pointerevents/test_getCoalescedEvents.html
+++ b/dom/events/test/pointerevents/test_getCoalescedEvents.html
@@ -18,14 +18,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1303957
/** Test for Bug 1303957 **/
SimpleTest.waitForExplicitFinish();
-function runTests() {
- let target0 = window.document.getElementById("target0");
- let utils = SpecialPowers.getDOMWindowUtils(window);
+SimpleTest.waitForFocus(async () => {
+ await SpecialPowers.pushPrefEnv({"set": [["dom.events.coalesce.mousemove", true]]});
+
+ const target0 = window.document.getElementById("target0");
+ const utils = SpecialPowers.getDOMWindowUtils(window);
utils.advanceTimeAndRefresh(0);
- SimpleTest.executeSoon(async () => {
- // Flush all pending mouse events before synthesizing events.
+ await new Promise(resolve => SimpleTest.executeSoon(resolve));
+ const waitForPointerMove = new Promise(resolve => {
target0.addEventListener("pointermove", (ev) => {
let length = ev.getCoalescedEvents().length;
ok(length >= 1, "Coalesced events should >= 1, got " + length);
@@ -49,11 +51,11 @@ function runTests() {
ok(coalescedEvent.offsetX >= prevOffsetX, "getCoalescedEvents()[" + i + "].offsetX = " + coalescedEvent.offsetX);
ok(coalescedEvent.offsetX == 5 || coalescedEvent.offsetX == 10 ||
- coalescedEvent.offsetX == 15 || coalescedEvent.offsetX == 20, "expected offsetX");
+ coalescedEvent.offsetX == 15 || coalescedEvent.offsetX == 20, "expected offsetX");
ok(coalescedEvent.offsetY >= prevOffsetY, "getCoalescedEvents()[" + i + "].offsetY = " + coalescedEvent.offsetY);
ok(coalescedEvent.offsetY == 5 || coalescedEvent.offsetY == 10 ||
- coalescedEvent.offsetY == 15 || coalescedEvent.offsetY == 20, "expected offsetY");
+ coalescedEvent.offsetY == 15 || coalescedEvent.offsetY == 20, "expected offsetY");
prevOffsetX = coalescedEvent.offsetX;
prevOffsetY = coalescedEvent.offsetY;
@@ -64,23 +66,24 @@ function runTests() {
ok((coalescedEvent.clientX <= x+2) && (coalescedEvent.clientX >= x-2), "getCoalescedEvents()[" + i + "].clientX");
ok((coalescedEvent.clientY <= y+2) && (coalescedEvent.clientY >= y-2), "getCoalescedEvents()[" + i + "].clientY");
}
+ resolve();
}, { once: true });
+ });
- target0.addEventListener("pointerup", (ev) => {
- utils.restoreNormalRefresh();
- SimpleTest.finish();
- }, { once: true });
+ info("Synthesizing native mouse moves....");
+ await promiseNativeMouseEvent({ type: "mousemove", target: target0, offsetX: 5, offsetY: 5 });
+ await promiseNativeMouseEvent({ type: "mousemove", target: target0, offsetX: 10, offsetY: 10 });
+ await promiseNativeMouseEvent({ type: "mousemove", target: target0, offsetX: 15, offsetY: 15 });
+ await promiseNativeMouseEvent({ type: "mousemove", target: target0, offsetX: 20, offsetY: 20 });
+ utils.restoreNormalRefresh();
+ await waitForPointerMove;
- await promiseNativeMouseEvent({ type: "mousemove", target: target0, offsetX: 5, offsetY: 5 });
- await promiseNativeMouseEvent({ type: "mousemove", target: target0, offsetX: 10, offsetY: 10 });
- await promiseNativeMouseEvent({ type: "mousemove", target: target0, offsetX: 15, offsetY: 15 });
- await promiseNativeMouseEvent({ type: "mousemove", target: target0, offsetX: 20, offsetY: 20 });
- synthesizeNativeMouseEvent({ type: "click", target: target0, offsetX: 20, offsetY: 20 });
- });
-}
+ target0.addEventListener("pointerup", (ev) => {
+ SimpleTest.finish();
+ }, { once: true });
-SimpleTest.waitForFocus(() => {
- SpecialPowers.pushPrefEnv({"set": [["dom.events.coalesce.mousemove", true]]}, runTests);
+ info("Synthesizing a native click....");
+ synthesizeNativeMouseEvent({ type: "click", target: target0, offsetX: 20, offsetY: 20 });
});
</script>
diff --git a/dom/events/test/test_dom_storage_event.html b/dom/events/test/test_dom_storage_event.html
index 88cc288d41..ce9db0dc7f 100644
--- a/dom/events/test/test_dom_storage_event.html
+++ b/dom/events/test/test_dom_storage_event.html
@@ -28,7 +28,7 @@ const kTests = [
{ createEventArg: "storageEvent",
type: "ddd", bubbles: false, cancelable: false,
- key: 'key', oldValue: 'a', newValue: 'b', url: null, storageArea: null },
+ key: 'key', oldValue: 'a', newValue: 'b', url: '', storageArea: null },
{ createEventArg: "StorageEvent",
type: "eee", bubbles: true, cancelable: true,
@@ -36,7 +36,7 @@ const kTests = [
{ createEventArg: "storageevent",
type: "fff", bubbles: false, cancelable: true,
- key: null, oldValue: null, newValue: null, url: null, storageArea: null },
+ key: null, oldValue: null, newValue: null, url: '', storageArea: null },
];
for (var i = 0; i < kTests.length; i++) {