Bug 1350642 - Remove the PBrowser::Msg_GetTabCount sync IPC; r=krizsa
MozReview-Commit-ID: LJbijk5Xc1W
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -4499,34 +4499,35 @@ nsGlobalWindowOuter::CanMoveResizeWindow
return false;
}
if (!CanSetProperty("dom.disable_window_move_resize")) {
return false;
}
// Ignore the request if we have more than one tab in the window.
- uint32_t itemCount = 0;
if (XRE_IsContentProcess()) {
nsCOMPtr<nsIDocShell> docShell = GetDocShell();
if (docShell) {
nsCOMPtr<nsITabChild> child = docShell->GetTabChild();
- if (child) {
+ bool hasSiblings = true;
+ if (child &&
+ NS_SUCCEEDED(child->GetHasSiblings(&hasSiblings)) &&
+ hasSiblings) {
child->SendGetTabCount(&itemCount);
}
}
} else {
nsCOMPtr<nsIDocShellTreeOwner> treeOwner = GetTreeOwner();
- if (!treeOwner || NS_FAILED(treeOwner->GetTabCount(&itemCount))) {
- itemCount = 0;
+ uint32_t itemCount = 0;
+ if (treeOwner && NS_SUCCEEDED(treeOwner->GetTabCount(&itemCount)) &&
+ itemCount > 1) {
+ return false;
}
}
- if (itemCount > 1) {
- return false;
- }
}
if (mDocShell) {
bool allow;
nsresult rv = mDocShell->GetAllowWindowControl(&allow);
if (NS_SUCCEEDED(rv) && !allow)
return false;
}
--- a/dom/interfaces/base/nsITabChild.idl
+++ b/dom/interfaces/base/nsITabChild.idl
@@ -15,26 +15,29 @@ native CommandsArray(nsTArray<nsCString>
interface nsITabChild : nsISupports
{
readonly attribute nsISupports messageManager;
attribute nsIWebBrowserChrome3 webBrowserChrome;
[notxpcom] void sendRequestFocus(in boolean canFocus);
- [notxpcom] void sendGetTabCount(out uint32_t tabCount);
-
[noscript, notxpcom] void enableDisableCommands(in AString action,
in CommandsArrayRef enabledCommands,
in CommandsArrayRef disabledCommands);
[noscript] void remoteSizeShellTo(in int32_t width, in int32_t height,
in int32_t shellItemWidth, in int32_t shellItemHeight);
[noscript] void remoteDropLinks(in unsigned long linksCount,
[array, size_is(linksCount)] in nsIDroppedLinkItem links);
readonly attribute uint64_t tabId;
+ /*
+ * Indicates whether or not there are other tabs in this tab's window.
+ */
+ attribute boolean hasSiblings;
+
[noscript, notxpcom] void beforeUnloadAdded();
[noscript, notxpcom] void beforeUnloadRemoved();
};
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -520,24 +520,16 @@ parent:
double aPointerPressure,
uint32_t aPointerOrientation,
uint64_t aObserverId);
async SynthesizeNativeTouchTap(LayoutDeviceIntPoint aPoint,
bool aLongTap,
uint64_t aObserverId);
async ClearNativeTouchSequence(uint64_t aObserverId);
- /**
- * Returns the number of tabs in the window via the out parameter.
- * If the number of tabs can't be determined, returns 0.
- *
- * @param aValue where to store the tab count
- */
- sync GetTabCount() returns (uint32_t value);
-
async AccessKeyNotHandled(WidgetKeyboardEvent event);
async SetHasBeforeUnload(bool aHasBeforeUnload);
child:
async NativeSynthesisResponse(uint64_t aObserverId, nsCString aResponse);
parent:
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -408,16 +408,17 @@ TabChild::TabChild(nsIContentChild* aMan
, mDidFakeShow(false)
, mNotified(false)
, mTriedBrowserInit(false)
, mOrientation(eScreenOrientation_PortraitPrimary)
, mIgnoreKeyPressEvent(false)
, mHasValidInnerSize(false)
, mDestroyed(false)
, mUniqueId(aTabId)
+ , mHasSiblings(true)
, mIsTransparent(false)
, mIPCOpen(false)
, mParentIsActive(false)
, mDidSetRealShowInfo(false)
, mDidLoadURLInit(false)
, mAwaitingLA(false)
, mSkipKeyPress(false)
, mLayerObserverEpoch(1)
@@ -3002,22 +3003,16 @@ TabChild::SetWebBrowserChrome(nsIWebBrow
void
TabChild::SendRequestFocus(bool aCanFocus)
{
PBrowserChild::SendRequestFocus(aCanFocus);
}
void
-TabChild::SendGetTabCount(uint32_t* tabCount)
-{
- PBrowserChild::SendGetTabCount(tabCount);
-}
-
-void
TabChild::EnableDisableCommands(const nsAString& aAction,
nsTArray<nsCString>& aEnabledCommands,
nsTArray<nsCString>& aDisabledCommands)
{
PBrowserChild::SendEnableDisableCommands(PromiseFlatString(aAction),
aEnabledCommands, aDisabledCommands);
}
--- a/dom/ipc/TabChild.h
+++ b/dom/ipc/TabChild.h
@@ -845,16 +845,21 @@ private:
bool mHasValidInnerSize;
bool mDestroyed;
// Position of client area relative to the outer window
LayoutDeviceIntPoint mClientOffset;
// Position of tab, relative to parent widget (typically the window)
LayoutDeviceIntPoint mChromeOffset;
TabId mUniqueId;
+ // Whether or not this tab has siblings (other tabs in the same window).
+ // This is one factor used when choosing to allow or deny a non-system
+ // script's attempt to resize the window.
+ bool mHasSiblings;
+
// Holds the compositor options for the compositor rendering this tab,
// once we find out which compositor that is.
Maybe<mozilla::layers::CompositorOptions> mCompositorOptions;
friend class ContentChild;
bool mIsTransparent;
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -3545,32 +3545,16 @@ TabParent::GetShowInfo()
isTransparent, mDPI, mRounding, mDefaultScale.scale);
}
return ShowInfo(EmptyString(), false, false, false,
false, mDPI, mRounding, mDefaultScale.scale);
}
mozilla::ipc::IPCResult
-TabParent::RecvGetTabCount(uint32_t* aValue)
-{
- *aValue = 0;
-
- nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow = GetXULBrowserWindow();
- NS_ENSURE_TRUE(xulBrowserWindow, IPC_OK());
-
- uint32_t tabCount;
- nsresult rv = xulBrowserWindow->GetTabCount(&tabCount);
- NS_ENSURE_SUCCESS(rv, IPC_OK());
-
- *aValue = tabCount;
- return IPC_OK();
-}
-
-mozilla::ipc::IPCResult
TabParent::RecvLookUpDictionary(const nsString& aText,
nsTArray<FontRange>&& aFontRangeArray,
const bool& aIsVertical,
const LayoutDeviceIntPoint& aPoint)
{
nsCOMPtr<nsIWidget> widget = GetWidget();
if (!widget) {
return IPC_OK();
--- a/dom/ipc/TabParent.h
+++ b/dom/ipc/TabParent.h
@@ -626,18 +626,16 @@ protected:
virtual mozilla::ipc::IPCResult RecvRemoteIsReadyToHandleInputEvents() override;
virtual mozilla::ipc::IPCResult RecvPaintWhileInterruptingJSNoOp(const uint64_t& aLayerObserverEpoch) override;
virtual mozilla::ipc::IPCResult RecvSetDimensions(const uint32_t& aFlags,
const int32_t& aX, const int32_t& aY,
const int32_t& aCx, const int32_t& aCy) override;
- virtual mozilla::ipc::IPCResult RecvGetTabCount(uint32_t* aValue) override;
-
virtual mozilla::ipc::IPCResult RecvShowCanvasPermissionPrompt(const nsCString& aFirstPartyURI) override;
ContentCacheInParent mContentCache;
nsIntRect mRect;
ScreenIntSize mDimensions;
ScreenOrientationInternal mOrientation;
float mDPI;
--- a/ipc/ipdl/sync-messages.ini
+++ b/ipc/ipdl/sync-messages.ini
@@ -830,18 +830,16 @@ description =
description =
[PBrowser::GetInputContext]
description =
[PBrowser::IsParentWindowMainWidgetVisible]
description =
description =
[PBrowser::RequestNativeKeyBindings]
description =
-[PBrowser::GetTabCount]
-description =
[PBrowser::DispatchWheelEvent]
description =
[PBrowser::DispatchMouseEvent]
description =
[PBrowser::DispatchKeyboardEvent]
description =
[PBrowser::EnsureLayersConnected]
description =