Bug 1153023 - Send the child process a dimensions update when the offset changes. r=roc

This commit is contained in:
Kartikaya Gupta 2015-04-21 10:33:56 -04:00
Родитель f4cd56dd21
Коммит e8b3bc906b
2 изменённых файлов: 39 добавлений и 8 удалений

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

@ -353,6 +353,10 @@ TabParent::AddWindowListeners()
this, false, false);
}
}
if (nsIPresShell* shell = mFrameElement->OwnerDoc()->GetShell()) {
mPresShellWithRefreshListener = shell;
shell->AddPostRefreshObserver(this);
}
}
}
@ -367,6 +371,18 @@ TabParent::RemoveWindowListeners()
this, false);
}
}
if (mPresShellWithRefreshListener) {
mPresShellWithRefreshListener->RemovePostRefreshObserver(this);
mPresShellWithRefreshListener = nullptr;
}
}
void
TabParent::DidRefresh()
{
if (mChromeOffset != -GetChildProcessOffset()) {
UpdatePosition();
}
}
void
@ -401,6 +417,8 @@ TabParent::Destroy()
return;
}
RemoveWindowListeners();
// If this fails, it's most likely due to a content-process crash,
// and auto-cleanup will kick in. Otherwise, the child side will
// destroy itself and send back __delete__().
@ -910,6 +928,19 @@ TabParent::RecvSetDimensions(const uint32_t& aFlags,
return false;
}
nsresult
TabParent::UpdatePosition()
{
nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
if (!frameLoader) {
return NS_OK;
}
nsIntRect windowDims;
NS_ENSURE_SUCCESS(frameLoader->GetWindowDimensions(windowDims), NS_ERROR_FAILURE);
UpdateDimensions(windowDims, mDimensions);
return NS_OK;
}
void
TabParent::UpdateDimensions(const nsIntRect& rect, const ScreenIntSize& size)
{
@ -2997,14 +3028,7 @@ TabParent::HandleEvent(nsIDOMEvent* aEvent)
if (eventType.EqualsLiteral("MozUpdateWindowPos") && !mIsDestroyed) {
// This event is sent when the widget moved. Therefore we only update
// the position.
nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
if (!frameLoader) {
return NS_OK;
}
nsIntRect windowDims;
NS_ENSURE_SUCCESS(frameLoader->GetWindowDimensions(windowDims), NS_ERROR_FAILURE);
UpdateDimensions(windowDims, mDimensions);
return NS_OK;
return UpdatePosition();
}
return NS_OK;
}

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

@ -23,6 +23,7 @@
#include "nsISecureBrowserUI.h"
#include "nsITabParent.h"
#include "nsIXULBrowserWindow.h"
#include "nsRefreshDriver.h"
#include "nsWeakReference.h"
#include "Units.h"
#include "nsIWidget.h"
@ -74,6 +75,7 @@ class TabParent final : public PBrowserParent
, public nsISecureBrowserUI
, public nsSupportsWeakReference
, public TabContext
, public nsAPostRefreshObserver
{
typedef mozilla::dom::ClonedMessageData ClonedMessageData;
@ -120,6 +122,7 @@ public:
void RemoveWindowListeners();
void AddWindowListeners();
void DidRefresh() override;
virtual bool RecvMoveFocus(const bool& aForward) override;
virtual bool RecvEvent(const RemoteDOMEvent& aEvent) override;
@ -488,6 +491,8 @@ private:
nsRefPtr<nsIContentParent> mManager;
void TryCacheDPIAndScale();
nsresult UpdatePosition();
CSSPoint AdjustTapToChildWidget(const CSSPoint& aPoint);
// Update state prior to routing an APZ-aware event to the child process.
@ -596,6 +601,8 @@ private:
// cursor. This happens whenever the cursor is in the tab's region.
bool mTabSetsCursor;
nsRefPtr<nsIPresShell> mPresShellWithRefreshListener;
private:
// This is used when APZ needs to find the TabParent associated with a layer
// to dispatch events.