import changes from `dev' branch of rmottola/Arctic-Fox:

- Bug 1256731 - patch 2 - Notify front-end code when screen resolution changes on Windows, so that TabsInTitlebar code can refresh its computations. r=gijs,emk (4b0baacc83)
- Bug 1261307: Convert |StreamSocketConsumer::ReceiveSocketData| to |UniquePtr|, r=nfroyd (65088da288)
- Bug 1264377. Get rid of some unnecessary custom JSClass hook functions in xpconnect sandboxes and DOM simple globals. r=bholley (578df7a830)
- Bug 1249518 - Make DaemonSocketPDU able to send multiple file descriptors in single unit. r=tzimmermann (1bf04f8f43)
This commit is contained in:
2024-08-15 09:40:27 +08:00
parent fe3519e975
commit 4cf8b0e818
17 changed files with 79 additions and 47 deletions
@@ -222,7 +222,11 @@ public:
{
DaemonSocketPDU& pdu = GetPDU();
aArg1 = pdu.AcquireFd();
auto receiveFds = pdu.AcquireFds();
if (NS_WARN_IF(receiveFds.Length() == 0)) {
return NS_ERROR_ILLEGAL_VALUE;
}
aArg1 = receiveFds[0];
if (NS_WARN_IF(aArg1 < 0)) {
return NS_ERROR_ILLEGAL_VALUE;
@@ -279,7 +283,14 @@ BluetoothDaemonSocketModule::ConnectRsp(const DaemonSocketPDUHeader& aHeader,
BluetoothSocketResultHandler* aRes)
{
/* the file descriptor is attached in the PDU's ancillary data */
int fd = aPDU.AcquireFd();
auto receiveFds = aPDU.AcquireFds();
if (receiveFds.Length() == 0) {
ErrorRunnable::Dispatch(aRes, &BluetoothSocketResultHandler::OnError,
ConstantInitOp1<BluetoothStatus>(STATUS_FAIL));
return;
}
int fd = -1;
fd = receiveFds[0];
if (fd < 0) {
ErrorRunnable::Dispatch(aRes, &BluetoothSocketResultHandler::OnError,
ConstantInitOp1<BluetoothStatus>(STATUS_FAIL));
+3 -3
View File
@@ -63,7 +63,7 @@ public:
//
void ReceiveSocketData(
int aIndex, nsAutoPtr<mozilla::ipc::UnixSocketBuffer>& aBuffer) override;
int aIndex, UniquePtr<mozilla::ipc::UnixSocketBuffer>& aBuffer) override;
void OnConnectSuccess(int aIndex) override;
void OnConnectError(int aIndex) override;
@@ -363,12 +363,12 @@ NfcConsumer::IsNfcServiceThread() const
void
NfcConsumer::ReceiveSocketData(
int aIndex, nsAutoPtr<mozilla::ipc::UnixSocketBuffer>& aBuffer)
int aIndex, UniquePtr<mozilla::ipc::UnixSocketBuffer>& aBuffer)
{
MOZ_ASSERT(IsNfcServiceThread());
MOZ_ASSERT(aIndex == STREAM_SOCKET);
Receive(aBuffer);
Receive(aBuffer.get());
}
void
+17 -8
View File
@@ -119,7 +119,7 @@ DaemonSocketPDU::Receive(int aFd)
iv.iov_base = GetData(0);
iv.iov_len = GetAvailableSpace();
uint8_t cmsgbuf[CMSG_SPACE(sizeof(int))];
uint8_t cmsgbuf[CMSG_SPACE(sizeof(int)* MAX_NFDS)];
struct msghdr msg;
memset(&msg, 0, sizeof(msg));
@@ -140,24 +140,33 @@ DaemonSocketPDU::Receive(int aFd)
SetRange(0, res);
struct cmsghdr *chdr = CMSG_FIRSTHDR(&msg);
struct cmsghdr* chdr = CMSG_FIRSTHDR(&msg);
for (; chdr; chdr = CMSG_NXTHDR(&msg, chdr)) {
if (NS_WARN_IF(!CMSGHDR_CONTAINS_FD(chdr))) {
continue;
}
// Retrieve sent file descriptor. If multiple file descriptors
// have been sent, we close all but the final one.
mReceivedFd = *(static_cast<int*>(CMSG_DATA(chdr)));
// Retrieve sent file descriptors.
size_t fdCount = (chdr->cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr))) / sizeof(int);
for (size_t i = 0; i < fdCount; i++) {
int* receivedFd = static_cast<int*>(CMSG_DATA(chdr)) + i;
mReceivedFds.AppendElement(ScopedClose(*receivedFd));
}
}
return res;
}
int
DaemonSocketPDU::AcquireFd()
nsTArray<int>
DaemonSocketPDU::AcquireFds()
{
return mReceivedFd.forget();
// Forget all RAII object to avoid closing the fds.
nsTArray<int> fds;
for (auto& fd : mReceivedFds) {
fds.AppendElement(fd.forget());
}
mReceivedFds.Clear();
return fds;
}
nsresult
+4 -2
View File
@@ -10,10 +10,12 @@
#include "mozilla/FileUtils.h"
#include "mozilla/ipc/SocketBase.h"
#include "mozilla/ipc/DaemonSocketMessageHandlers.h"
#include "nsTArray.h"
namespace mozilla {
namespace ipc {
static const size_t MAX_NFDS = 16;
class DaemonSocketIOConsumer;
/**
@@ -72,7 +74,7 @@ public:
ssize_t Send(int aFd) override;
ssize_t Receive(int aFd) override;
int AcquireFd();
nsTArray<int> AcquireFds();
nsresult UpdateHeader();
@@ -82,7 +84,7 @@ private:
DaemonSocketIOConsumer* mConsumer;
RefPtr<DaemonSocketResultHandler> mRes;
ScopedClose mReceivedFd;
nsTArray<ScopedClose> mReceivedFds;
};
}
-6
View File
@@ -11,12 +11,6 @@ import ipdl.builtin
from ipdl.cxx.ast import *
from ipdl.type import Actor, ActorType, ProcessGraph, TypeVisitor, builtinHeaderIncludes
# FIXME/cjones: the chromium Message logging code doesn't work on
# gcc/POSIX, because it wprintf()s across the chromium/mozilla
# boundary. one side builds with -fshort-wchar, the other doesn't.
# this code will remain off until the chromium base lib is replaced
EMIT_LOGGING_CODE = ('win32' == sys.platform)
##-----------------------------------------------------------------------------
## "Public" interface to lowering
##
+4 -4
View File
@@ -882,7 +882,7 @@ KeyStore::SendData(const uint8_t *aData, int aLength)
// |StreamSocketConsumer|, |ListenSocketConsumer|
void
KeyStore::ReceiveSocketData(int aIndex, nsAutoPtr<UnixSocketBuffer>& aMessage)
KeyStore::ReceiveSocketData(int aIndex, UniquePtr<UnixSocketBuffer>& aMessage)
{
MOZ_ASSERT(NS_IsMainThread());
@@ -892,13 +892,13 @@ KeyStore::ReceiveSocketData(int aIndex, nsAutoPtr<UnixSocketBuffer>& aMessage)
mHandlerInfo.state == STATE_PROCESSING) {
switch (mHandlerInfo.state) {
case STATE_IDLE:
result = ReadCommand(aMessage);
result = ReadCommand(aMessage.get());
break;
case STATE_READ_PARAM_LEN:
result = ReadLength(aMessage);
result = ReadLength(aMessage.get());
break;
case STATE_READ_PARAM_DATA:
result = ReadData(aMessage);
result = ReadData(aMessage.get());
break;
case STATE_PROCESSING:
if (mHandlerInfo.command == 'g') {
+1 -1
View File
@@ -124,7 +124,7 @@ private:
//
void ReceiveSocketData(int aIndex,
nsAutoPtr<UnixSocketBuffer>& aMessage) override;
UniquePtr<UnixSocketBuffer>& aMessage) override;
void OnConnectSuccess(int aIndex) override;
void OnConnectError(int aIndex) override;
void OnDisconnect(int aIndex) override;
+2 -2
View File
@@ -227,7 +227,7 @@ public:
}
private:
nsAutoPtr<UnixSocketBuffer> mBuffer;
UniquePtr<UnixSocketBuffer> mBuffer;
};
void
@@ -366,7 +366,7 @@ StreamSocket::~StreamSocket()
}
void
StreamSocket::ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aBuffer)
StreamSocket::ReceiveSocketData(UniquePtr<UnixSocketBuffer>& aBuffer)
{
mConsumer->ReceiveSocketData(mIndex, aBuffer);
}
+1 -1
View File
@@ -34,7 +34,7 @@ public:
*
* @param aBuffer Data received from the socket.
*/
void ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aBuffer);
void ReceiveSocketData(UniquePtr<UnixSocketBuffer>& aBuffer);
/**
* Starts a task on the socket that will try to connect to a socket in a
+2 -2
View File
@@ -7,7 +7,7 @@
#ifndef mozilla_ipc_streamsocketconsumer_h
#define mozilla_ipc_streamsocketconsumer_h
#include "nsAutoPtr.h"
#include "mozilla/UniquePtr.h"
namespace mozilla {
namespace ipc {
@@ -27,7 +27,7 @@ public:
* @param aBuffer Data received from the socket.
*/
virtual void ReceiveSocketData(int aIndex,
nsAutoPtr<UnixSocketBuffer>& aBuffer) = 0;
UniquePtr<UnixSocketBuffer>& aBuffer) = 0;
/**
* Callback for socket success. Consumer-thread only.
+2 -2
View File
@@ -248,21 +248,21 @@ caption {
titlebar,
toolbar:not([nowindowdrag="true"]):not([customizing="true"]),
statusbar:not([nowindowdrag="true"]),
%endif
windowdragbox {
-moz-window-dragging: drag;
}
/* The list below is non-comprehensive and will probably need some tweaking. */
toolbaritem,
toolbarbutton,
button,
textbox,
searchbar,
tab,
radio,
splitter {
-moz-window-dragging: no-drag;
}
%endif
/******* toolbar *******/
+6 -14
View File
@@ -3,9 +3,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifdef XP_WIN
#define USE_HITTEST
#define HAVE_CSS_WINDOW_DRAG_SUPPORT
#elifdef MOZ_WIDGET_COCOA
#define USE_HITTEST
#define HAVE_CSS_WINDOW_DRAG_SUPPORT
#endif
this.EXPORTED_SYMBOLS = [ "WindowDraggingElement" ];
@@ -13,10 +13,10 @@ this.EXPORTED_SYMBOLS = [ "WindowDraggingElement" ];
this.WindowDraggingElement = function WindowDraggingElement(elem) {
this._elem = elem;
this._window = elem.ownerDocument.defaultView;
#ifdef USE_HITTEST
if (!this.isPanel())
this._elem.addEventListener("MozMouseHittest", this, false);
else
#ifdef HAVE_CSS_WINDOW_DRAG_SUPPORT
if (!this.isPanel()) {
return;
}
#endif
this._elem.addEventListener("mousedown", this, false);
};
@@ -60,14 +60,6 @@ WindowDraggingElement.prototype = {
},
handleEvent: function(aEvent) {
let isPanel = this.isPanel();
#ifdef USE_HITTEST
if (!isPanel) {
if (this.shouldDrag(aEvent))
aEvent.preventDefault();
return;
}
#endif
switch (aEvent.type) {
case "mousedown":
if (!this.shouldDrag(aEvent))
+5
View File
@@ -54,6 +54,11 @@ nsIWidgetListener::SizeModeChanged(nsSizeMode aSizeMode)
{
}
void
nsIWidgetListener::UIResolutionChanged()
{
}
void
nsIWidgetListener::FullscreenChanged(bool aInFullscreen)
{
+6
View File
@@ -79,6 +79,12 @@ public:
*/
virtual void SizeModeChanged(nsSizeMode aSizeMode);
/**
* Called when the DPI (device resolution scaling factor) is changed,
* such that UI elements may need to be rescaled.
*/
virtual void UIResolutionChanged();
/**
* Called when the z-order of the window is changed. Returns true if the
* notification was handled. aPlacement indicates the new z order. If
+1
View File
@@ -113,6 +113,7 @@ void nsWindowBase::ChangedDPI()
if (presShell) {
presShell->BackingScaleFactorChanged();
}
mWidgetListener->UIResolutionChanged();
}
}
+11
View File
@@ -368,6 +368,17 @@ nsWebShellWindow::SizeModeChanged(nsSizeMode sizeMode)
// then need to be different.
}
void
nsWebShellWindow::UIResolutionChanged()
{
nsCOMPtr<nsPIDOMWindow> ourWindow =
mDocShell ? mDocShell->GetWindow() : nullptr;
if (ourWindow) {
MOZ_ASSERT(ourWindow->IsOuterWindow());
ourWindow->DispatchCustomEvent(NS_LITERAL_STRING("resolutionchange"));
}
}
void
nsWebShellWindow::OSToolbarButtonPressed()
{
+1
View File
@@ -56,6 +56,7 @@ public:
virtual bool WindowResized(nsIWidget* aWidget, int32_t aWidth, int32_t aHeight) override;
virtual bool RequestWindowClose(nsIWidget* aWidget) override;
virtual void SizeModeChanged(nsSizeMode sizeMode) override;
virtual void UIResolutionChanged() override;
virtual void OSToolbarButtonPressed() override;
virtual bool ZLevelChanged(bool aImmediate, nsWindowZ *aPlacement,
nsIWidget* aRequestBelow, nsIWidget** aActualBelow) override;