Backed out 3 changesets (bug 1851041) for causing bustage on nsClipboard.cpp. CLOSED TREE

Backed out changeset 5cb270a4e6b6 (bug 1851041)
Backed out changeset f6e5e427d8e8 (bug 1851041)
Backed out changeset 7c7228999e18 (bug 1851041)
This commit is contained in:
Natalia Csoregi 2023-10-05 23:59:45 +03:00
Родитель 97a364c186
Коммит ddf1824cda
6 изменённых файлов: 78 добавлений и 140 удалений

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

@ -57,8 +57,6 @@ using namespace mozilla::dom;
using namespace mozilla::gfx;
using namespace mozilla::image;
LazyLogModule sWidgetDragServiceLog("WidgetDragService");
#define DRAGIMAGES_PREF "nglayout.enable_drag_images"
nsBaseDragService::nsBaseDragService()

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

@ -16,17 +16,10 @@
#include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/HTMLCanvasElement.h"
#include "mozilla/dom/RemoteDragStartData.h"
#include "mozilla/Logging.h"
#include "nsTArray.h"
#include "nsRegion.h"
#include "Units.h"
extern mozilla::LazyLogModule sWidgetDragServiceLog;
#define MOZ_DRAGSERVICE_LOG(...) \
MOZ_LOG(sWidgetDragServiceLog, mozilla::LogLevel::Debug, (__VA_ARGS__))
#define MOZ_DRAGSERVICE_LOG_ENABLED() \
MOZ_LOG_TEST(sWidgetDragServiceLog, mozilla::LogLevel::Debug)
// translucency level for drag images
#define DRAG_TRANSLUCENCY 0.65

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

@ -1433,42 +1433,6 @@ bool WinUtils::GetAutoRotationState(AR_STATE* aRotationState) {
return false;
}
// static
void WinUtils::GetClipboardFormatAsString(UINT aFormat, nsAString& aOutput) {
wchar_t buf[256] = {};
// Get registered format name and ensure the existence of a terminating '\0'
// if the registered name is more than 256 characters.
if (::GetClipboardFormatNameW(aFormat, buf, ARRAYSIZE(buf) - 1)) {
aOutput.Append(buf);
return;
}
// Standard clipboard formats
// https://learn.microsoft.com/en-us/windows/win32/dataxchg/standard-clipboard-formats
switch (aFormat) {
case CF_TEXT: // 1
aOutput.Append(u"CF_TEXT"_ns);
break;
case CF_BITMAP: // 2
aOutput.Append(u"CF_BITMAP"_ns);
break;
case CF_DIB: // 8
aOutput.Append(u"CF_DIB"_ns);
break;
case CF_UNICODETEXT: // 13
aOutput.Append(u"CF_UNICODETEXT"_ns);
break;
case CF_HDROP: // 15
aOutput.Append(u"CF_HDROP"_ns);
break;
case CF_DIBV5: // 17
aOutput.Append(u"CF_DIBV5"_ns);
break;
default:
aOutput.AppendPrintf("%u", aFormat);
break;
}
}
static bool IsTabletDevice() {
// Guarantees that:
// - The device has a touch screen.

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

@ -592,8 +592,6 @@ class WinUtils {
static bool GetAutoRotationState(AR_STATE* aRotationState);
static void GetClipboardFormatAsString(UINT aFormat, nsAString& aOutput);
private:
static WhitelistVec BuildWhitelist();

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

@ -47,7 +47,6 @@
#include "nsMimeTypes.h"
#include "imgITools.h"
#include "imgIContainer.h"
#include "WinUtils.h"
/* static */
UINT nsClipboard::GetClipboardFileDescriptorFormatA() {
@ -472,6 +471,41 @@ static void RepeatedlyTryOleSetClipboard(IDataObject* aDataObj) {
RepeatedlyTry(::OleSetClipboard, LogOleSetClipboardResult, aDataObj);
}
static void GetClipboardFormatAsString(UINT aFormat, nsAString& aOutput) {
wchar_t buf[256] = {};
// Get registered format name and ensure the existence of a terminating '\0'
// if the registered name is more than 256 characters.
if (::GetClipboardFormatNameW(aFormat, buf, ARRAYSIZE(buf) - 1)) {
aOutput.Append(buf);
return;
}
// Standard clipboard formats
// https://learn.microsoft.com/en-us/windows/win32/dataxchg/standard-clipboard-formats
switch (aFormat) {
case CF_TEXT: // 1
aOutput.Append(u"CF_TEXT"_ns);
break;
case CF_BITMAP: // 2
aOutput.Append(u"CF_BITMAP"_ns);
break;
case CF_DIB: // 8
aOutput.Append(u"CF_DIB"_ns);
break;
case CF_UNICODETEXT: // 13
aOutput.Append(u"CF_UNICODETEXT"_ns);
break;
case CF_HDROP: // 15
aOutput.Append(u"CF_HDROP"_ns);
break;
case CF_DIBV5: // 17
aOutput.Append(u"CF_DIBV5"_ns);
break;
default:
aOutput.AppendPrintf("%u", aFormat);
break;
}
}
//-------------------------------------------------------------------------
NS_IMETHODIMP nsClipboard::SetNativeClipboardData(
nsITransferable* aTransferable, nsIClipboardOwner* aOwner,
@ -1327,7 +1361,7 @@ nsClipboard::GetNativeClipboardData(nsITransferable* aTransferable,
FORMATETC fEtc;
while (S_OK == pEnum->Next(1, &fEtc, nullptr)) {
nsAutoString format;
WinUtils::GetClipboardFormatAsString(fEtc.cfFormat, format);
GetClipboardFormatAsString(fEtc.cfFormat, format);
MOZ_CLIPBOARD_LOG(" FORMAT %s",
NS_ConvertUTF16toUTF8(format).get());
}

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

@ -40,7 +40,6 @@
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/DataSurfaceHelpers.h"
#include "mozilla/gfx/Tools.h"
#include "mozilla/ScopeExit.h"
using namespace mozilla;
using namespace mozilla::gfx;
@ -455,24 +454,6 @@ nsDragService::SetIDataObject(IDataObject* aDataObj) {
mDataObject = aDataObj;
NS_IF_ADDREF(mDataObject);
if (MOZ_DRAGSERVICE_LOG_ENABLED()) {
MOZ_DRAGSERVICE_LOG("nsDragService::SetIDataObject (%p)", mDataObject);
IEnumFORMATETC* pEnum = nullptr;
if (mDataObject &&
S_OK == mDataObject->EnumFormatEtc(DATADIR_GET, &pEnum)) {
MOZ_DRAGSERVICE_LOG(" formats in DataObject:");
FORMATETC fEtc;
while (S_OK == pEnum->Next(1, &fEtc, nullptr)) {
nsAutoString format;
WinUtils::GetClipboardFormatAsString(fEtc.cfFormat, format);
MOZ_DRAGSERVICE_LOG(" FORMAT %s",
NS_ConvertUTF16toUTF8(format).get());
}
pEnum->Release();
}
}
return NS_OK;
}
@ -487,16 +468,9 @@ void nsDragService::SetDroppedLocal() {
//-------------------------------------------------------------------------
NS_IMETHODIMP
nsDragService::IsDataFlavorSupported(const char* aDataFlavor, bool* _retval) {
if (!aDataFlavor || !mDataObject || !_retval) {
MOZ_DRAGSERVICE_LOG("%s: error", __PRETTY_FUNCTION__);
return NS_ERROR_FAILURE;
}
if (!aDataFlavor || !mDataObject || !_retval) return NS_ERROR_FAILURE;
*_retval = false;
auto logging = MakeScopeExit([&] {
MOZ_DRAGSERVICE_LOG("IsDataFlavorSupported: %s is%s found", aDataFlavor,
*_retval ? "" : " not");
});
FORMATETC fe;
UINT format = 0;
@ -514,76 +488,53 @@ nsDragService::IsDataFlavorSupported(const char* aDataFlavor, bool* _retval) {
uint32_t cnt = dataObjCol->GetNumDataObjects();
for (uint32_t i = 0; i < cnt; ++i) {
IDataObject* dataObj = dataObjCol->GetDataObjectAt(i);
if (S_OK == dataObj->QueryGetData(&fe)) {
*_retval = true; // found it!
}
if (S_OK == dataObj->QueryGetData(&fe)) *_retval = true; // found it!
}
}
return NS_OK;
}
// Ok, so we have a single object. Check to see if has the correct
// data type. Since this can come from an outside app, we also
// need to see if we need to perform text->unicode conversion if
// the client asked for unicode and it wasn't available.
format = nsClipboard::GetFormat(aDataFlavor);
SET_FORMATETC(fe, format, 0, DVASPECT_CONTENT, -1,
TYMED_HGLOBAL | TYMED_FILE | TYMED_GDI);
if (mDataObject->QueryGetData(&fe) == S_OK) {
*_retval = true; // found it!
return NS_OK;
}
// We haven't found the exact flavor the client asked for, but
// maybe we can still find it from something else that's in the
// data object.
if (strcmp(aDataFlavor, kTextMime) == 0) {
// If unicode wasn't there, it might exist as CF_TEXT, client asked
// for unicode and it wasn't present, check if we
// have CF_TEXT. We'll handle the actual data substitution in
// the data object.
SET_FORMATETC(fe, CF_TEXT, 0, DVASPECT_CONTENT, -1,
TYMED_HGLOBAL | TYMED_FILE | TYMED_GDI);
if (mDataObject->QueryGetData(&fe) == S_OK) {
*_retval = true; // found it!
}
return NS_OK;
}
if (strcmp(aDataFlavor, kURLMime) == 0) {
// client asked for a url and it wasn't present, but if we
// have a file, then we have a URL to give them (the path, or
// the internal URL if an InternetShortcut).
format = nsClipboard::GetFormat(kFileMime);
} // if special collection object
else {
// Ok, so we have a single object. Check to see if has the correct
// data type. Since this can come from an outside app, we also
// need to see if we need to perform text->unicode conversion if
// the client asked for unicode and it wasn't available.
format = nsClipboard::GetFormat(aDataFlavor);
SET_FORMATETC(fe, format, 0, DVASPECT_CONTENT, -1,
TYMED_HGLOBAL | TYMED_FILE | TYMED_GDI);
if (mDataObject->QueryGetData(&fe) == S_OK) {
*_retval = true; // found it!
}
return NS_OK;
}
if (format == CF_HDROP) {
// Dragging a link from browsers creates both a URL and a FILE which is a
// *.url shortcut in the data object. The file is useful when dropping in
// Windows Explorer to create a internet shortcut. But when dropping in the
// browser, users do not expect to have this file. So do not try to look up
// virtal file if there is a URL in the data object.
format = nsClipboard::GetFormat(kURLMime);
SET_FORMATETC(fe, format, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL);
if (mDataObject->QueryGetData(&fe) == S_OK) {
return NS_OK;
}
// If the client wants a file, maybe we find a virtual file.
format = nsClipboard::GetClipboardFileDescriptorFormatW();
SET_FORMATETC(fe, format, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL);
if (mDataObject->QueryGetData(&fe) == S_OK) {
*_retval = true; // found it!
}
// XXX should we fall back to CFSTR_FILEDESCRIPTORA?
return NS_OK;
} else {
// We haven't found the exact flavor the client asked for, but
// maybe we can still find it from something else that's on the
// clipboard
if (strcmp(aDataFlavor, kTextMime) == 0) {
// If unicode wasn't there, it might exist as CF_TEXT, client asked
// for unicode and it wasn't present, check if we
// have CF_TEXT. We'll handle the actual data substitution in
// the data object.
SET_FORMATETC(fe, CF_TEXT, 0, DVASPECT_CONTENT, -1,
TYMED_HGLOBAL | TYMED_FILE | TYMED_GDI);
if (mDataObject->QueryGetData(&fe) == S_OK) {
*_retval = true; // found it!
}
} else if (strcmp(aDataFlavor, kURLMime) == 0) {
// client asked for a url and it wasn't present, but if we
// have a file, then we have a URL to give them (the path, or
// the internal URL if an InternetShortcut).
format = nsClipboard::GetFormat(kFileMime);
SET_FORMATETC(fe, format, 0, DVASPECT_CONTENT, -1,
TYMED_HGLOBAL | TYMED_FILE | TYMED_GDI);
if (mDataObject->QueryGetData(&fe) == S_OK) {
*_retval = true; // found it!
}
} else if (format == CF_HDROP) {
// if the client wants a file, maybe we find a virtual file
format = nsClipboard::GetClipboardFileDescriptorFormatW();
SET_FORMATETC(fe, format, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL);
if (mDataObject->QueryGetData(&fe) == S_OK) {
*_retval = true; // found it!
}
}
} // else try again
}
return NS_OK;