зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1175383 TabChild should store PuppetWidget as is rather than as nsIWidget r=smaug
This commit is contained in:
Родитель
47a56a31ae
Коммит
e4779ba1cf
|
@ -295,7 +295,7 @@ TabChildBase::GetPageSize(nsCOMPtr<nsIDocument> aDocument, const CSSSize& aViewp
|
|||
bool
|
||||
TabChildBase::HandlePossibleViewportChange(const ScreenIntSize& aOldScreenSize)
|
||||
{
|
||||
nsIWidget* widget = WebWidget();
|
||||
PuppetWidget* widget = WebWidget();
|
||||
if (!widget || !widget->AsyncPanZoomEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1108,18 +1108,19 @@ TabChild::Init()
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mWidget = nsIWidget::CreatePuppetWidget(this);
|
||||
if (!mWidget) {
|
||||
nsCOMPtr<nsIWidget> widget = nsIWidget::CreatePuppetWidget(this);
|
||||
mPuppetWidget = static_cast<PuppetWidget*>(widget.get());
|
||||
if (!mPuppetWidget) {
|
||||
NS_ERROR("couldn't create fake widget");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mWidget->Create(
|
||||
mPuppetWidget->Create(
|
||||
nullptr, 0, // no parents
|
||||
gfx::IntRect(gfx::IntPoint(0, 0), gfx::IntSize(0, 0)),
|
||||
nullptr // HandleWidgetEvent
|
||||
);
|
||||
|
||||
baseWindow->InitWindow(0, mWidget, 0, 0, 0, 0);
|
||||
baseWindow->InitWindow(0, mPuppetWidget, 0, 0, 0, 0);
|
||||
baseWindow->Create();
|
||||
|
||||
NotifyTabContextUpdated();
|
||||
|
@ -1166,7 +1167,7 @@ TabChild::Init()
|
|||
do_QueryInterface(window->GetChromeEventHandler());
|
||||
docShell->SetChromeEventHandler(chromeHandler);
|
||||
|
||||
mAPZEventState = new APZEventState(mWidget,
|
||||
mAPZEventState = new APZEventState(mPuppetWidget,
|
||||
new TabChildContentReceivedInputBlockCallback(this));
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1608,11 +1609,11 @@ TabChild::DestroyWindow()
|
|||
if (baseWindow)
|
||||
baseWindow->Destroy();
|
||||
|
||||
// NB: the order of mWidget->Destroy() and mRemoteFrame->Destroy()
|
||||
// NB: the order of mPuppetWidget->Destroy() and mRemoteFrame->Destroy()
|
||||
// is important: we want to kill off remote layers before their
|
||||
// frames
|
||||
if (mWidget) {
|
||||
mWidget->Destroy();
|
||||
if (mPuppetWidget) {
|
||||
mPuppetWidget->Destroy();
|
||||
}
|
||||
|
||||
if (mRemoteFrame) {
|
||||
|
@ -2075,8 +2076,9 @@ TabChild::RecvUpdateDimensions(const CSSRect& rect, const CSSSize& size,
|
|||
}
|
||||
|
||||
ScreenIntRect screenRect = GetOuterRect();
|
||||
mWidget->Resize(screenRect.x + chromeDisp.x, screenRect.y + chromeDisp.y,
|
||||
screenSize.width, screenSize.height, true);
|
||||
mPuppetWidget->Resize(screenRect.x + chromeDisp.x,
|
||||
screenRect.y + chromeDisp.y,
|
||||
screenSize.width, screenSize.height, true);
|
||||
|
||||
nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(WebNavigation());
|
||||
baseWin->SetPositionAndSize(0, 0, screenSize.width, screenSize.height,
|
||||
|
@ -2224,7 +2226,7 @@ bool
|
|||
TabChild::RecvRealMouseButtonEvent(const WidgetMouseEvent& event)
|
||||
{
|
||||
WidgetMouseEvent localEvent(event);
|
||||
localEvent.widget = mWidget;
|
||||
localEvent.widget = mPuppetWidget;
|
||||
APZCCallbackHelper::DispatchWidgetEvent(localEvent);
|
||||
return true;
|
||||
}
|
||||
|
@ -2236,12 +2238,12 @@ TabChild::RecvMouseWheelEvent(const WidgetWheelEvent& aEvent,
|
|||
{
|
||||
if (AsyncPanZoomEnabled()) {
|
||||
nsCOMPtr<nsIDocument> document(GetDocument());
|
||||
APZCCallbackHelper::SendSetTargetAPZCNotification(WebWidget(), document, aEvent, aGuid,
|
||||
aInputBlockId);
|
||||
APZCCallbackHelper::SendSetTargetAPZCNotification(
|
||||
mPuppetWidget, document, aEvent, aGuid, aInputBlockId);
|
||||
}
|
||||
|
||||
WidgetWheelEvent event(aEvent);
|
||||
event.widget = mWidget;
|
||||
event.widget = mPuppetWidget;
|
||||
APZCCallbackHelper::DispatchWidgetEvent(event);
|
||||
|
||||
if (AsyncPanZoomEnabled()) {
|
||||
|
@ -2343,9 +2345,12 @@ TabChild::UpdateTapState(const WidgetTouchEvent& aEvent, nsEventStatus aStatus)
|
|||
|
||||
case NS_TOUCH_END:
|
||||
if (!TouchManager::gPreventMouseEvents) {
|
||||
APZCCallbackHelper::DispatchSynthesizedMouseEvent(NS_MOUSE_MOVE, time, currentPoint, 0, mWidget);
|
||||
APZCCallbackHelper::DispatchSynthesizedMouseEvent(NS_MOUSE_BUTTON_DOWN, time, currentPoint, 0, mWidget);
|
||||
APZCCallbackHelper::DispatchSynthesizedMouseEvent(NS_MOUSE_BUTTON_UP, time, currentPoint, 0, mWidget);
|
||||
APZCCallbackHelper::DispatchSynthesizedMouseEvent(
|
||||
NS_MOUSE_MOVE, time, currentPoint, 0, mPuppetWidget);
|
||||
APZCCallbackHelper::DispatchSynthesizedMouseEvent(
|
||||
NS_MOUSE_BUTTON_DOWN, time, currentPoint, 0, mPuppetWidget);
|
||||
APZCCallbackHelper::DispatchSynthesizedMouseEvent(
|
||||
NS_MOUSE_BUTTON_UP, time, currentPoint, 0, mPuppetWidget);
|
||||
}
|
||||
// fall through
|
||||
case NS_TOUCH_CANCEL:
|
||||
|
@ -2421,18 +2426,18 @@ TabChild::RecvRealTouchEvent(const WidgetTouchEvent& aEvent,
|
|||
TABC_LOG("Receiving touch event of type %d\n", aEvent.message);
|
||||
|
||||
WidgetTouchEvent localEvent(aEvent);
|
||||
localEvent.widget = mWidget;
|
||||
localEvent.widget = mPuppetWidget;
|
||||
|
||||
APZCCallbackHelper::ApplyCallbackTransform(localEvent, aGuid,
|
||||
mWidget->GetDefaultScale(), GetPresShellResolution());
|
||||
mPuppetWidget->GetDefaultScale(), GetPresShellResolution());
|
||||
|
||||
if (localEvent.message == NS_TOUCH_START && AsyncPanZoomEnabled()) {
|
||||
if (gfxPrefs::TouchActionEnabled()) {
|
||||
APZCCallbackHelper::SendSetAllowedTouchBehaviorNotification(WebWidget(),
|
||||
APZCCallbackHelper::SendSetAllowedTouchBehaviorNotification(mPuppetWidget,
|
||||
localEvent, aInputBlockId, mSetAllowedTouchBehaviorCallback);
|
||||
}
|
||||
nsCOMPtr<nsIDocument> document = GetDocument();
|
||||
APZCCallbackHelper::SendSetTargetAPZCNotification(WebWidget(), document,
|
||||
APZCCallbackHelper::SendSetTargetAPZCNotification(mPuppetWidget, document,
|
||||
localEvent, aGuid, aInputBlockId);
|
||||
}
|
||||
|
||||
|
@ -2463,7 +2468,7 @@ TabChild::RecvRealDragEvent(const WidgetDragEvent& aEvent,
|
|||
const uint32_t& aDropEffect)
|
||||
{
|
||||
WidgetDragEvent localEvent(aEvent);
|
||||
localEvent.widget = mWidget;
|
||||
localEvent.widget = mPuppetWidget;
|
||||
|
||||
nsCOMPtr<nsIDragSession> dragSession = nsContentUtils::GetDragSession();
|
||||
if (dragSession) {
|
||||
|
@ -2526,8 +2531,7 @@ bool
|
|||
TabChild::RecvRealKeyEvent(const WidgetKeyboardEvent& event,
|
||||
const MaybeNativeKeyBinding& aBindings)
|
||||
{
|
||||
PuppetWidget* widget = static_cast<PuppetWidget*>(mWidget.get());
|
||||
AutoCacheNativeKeyCommands autoCache(widget);
|
||||
AutoCacheNativeKeyCommands autoCache(mPuppetWidget);
|
||||
|
||||
if (event.message == NS_KEY_PRESS) {
|
||||
// If content code called preventDefault() on a keydown event, then we don't
|
||||
|
@ -2546,7 +2550,7 @@ TabChild::RecvRealKeyEvent(const WidgetKeyboardEvent& event,
|
|||
}
|
||||
|
||||
WidgetKeyboardEvent localEvent(event);
|
||||
localEvent.widget = mWidget;
|
||||
localEvent.widget = mPuppetWidget;
|
||||
nsEventStatus status = APZCCallbackHelper::DispatchWidgetEvent(localEvent);
|
||||
|
||||
if (event.message == NS_KEY_DOWN) {
|
||||
|
@ -2572,7 +2576,10 @@ TabChild::RecvKeyEvent(const nsString& aType,
|
|||
const bool& aPreventDefault)
|
||||
{
|
||||
bool ignored = false;
|
||||
nsContentUtils::SendKeyEvent(mWidget, aType, aKeyCode, aCharCode,
|
||||
// XXX Why nsContentUtils::SendKeyEvent takes nsCOMPtr<nsIWidget> for the
|
||||
// first argument? Why not just nsIWidget*?
|
||||
nsCOMPtr<nsIWidget> widget(mPuppetWidget);
|
||||
nsContentUtils::SendKeyEvent(widget, aType, aKeyCode, aCharCode,
|
||||
aModifiers, aPreventDefault, &ignored);
|
||||
return true;
|
||||
}
|
||||
|
@ -2581,7 +2588,7 @@ bool
|
|||
TabChild::RecvCompositionEvent(const WidgetCompositionEvent& event)
|
||||
{
|
||||
WidgetCompositionEvent localEvent(event);
|
||||
localEvent.widget = mWidget;
|
||||
localEvent.widget = mPuppetWidget;
|
||||
APZCCallbackHelper::DispatchWidgetEvent(localEvent);
|
||||
return true;
|
||||
}
|
||||
|
@ -2590,7 +2597,7 @@ bool
|
|||
TabChild::RecvSelectionEvent(const WidgetSelectionEvent& event)
|
||||
{
|
||||
WidgetSelectionEvent localEvent(event);
|
||||
localEvent.widget = mWidget;
|
||||
localEvent.widget = mPuppetWidget;
|
||||
APZCCallbackHelper::DispatchWidgetEvent(localEvent);
|
||||
return true;
|
||||
}
|
||||
|
@ -2906,7 +2913,7 @@ TabChild::InitRenderingState(const TextureFactoryIdentifier& aTextureFactoryIden
|
|||
const uint64_t& aLayersId,
|
||||
PRenderFrameChild* aRenderFrame)
|
||||
{
|
||||
static_cast<PuppetWidget*>(mWidget.get())->InitIMEState();
|
||||
mPuppetWidget->InitIMEState();
|
||||
|
||||
RenderFrameChild* remoteFrame = static_cast<RenderFrameChild*>(aRenderFrame);
|
||||
if (!remoteFrame) {
|
||||
|
@ -2945,8 +2952,9 @@ TabChild::InitRenderingState(const TextureFactoryIdentifier& aTextureFactoryIden
|
|||
}
|
||||
|
||||
ShadowLayerForwarder* lf =
|
||||
mWidget->GetLayerManager(shadowManager, mTextureFactoryIdentifier.mParentBackend)
|
||||
->AsShadowForwarder();
|
||||
mPuppetWidget->GetLayerManager(
|
||||
shadowManager, mTextureFactoryIdentifier.mParentBackend)
|
||||
->AsShadowForwarder();
|
||||
MOZ_ASSERT(lf && lf->HasShadowManager(),
|
||||
"PuppetWidget should have shadow manager");
|
||||
lf->IdentifyTextureHost(mTextureFactoryIdentifier);
|
||||
|
@ -3043,8 +3051,8 @@ TabChild::MakeVisible()
|
|||
compositor->SendNotifyVisible(mLayersId);
|
||||
}
|
||||
|
||||
if (mWidget) {
|
||||
mWidget->Show(true);
|
||||
if (mPuppetWidget) {
|
||||
mPuppetWidget->Show(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3061,8 +3069,8 @@ TabChild::MakeHidden()
|
|||
compositor->RecvClearCachedResources(mLayersId);
|
||||
}
|
||||
|
||||
if (mWidget) {
|
||||
mWidget->Show(false);
|
||||
if (mPuppetWidget) {
|
||||
mPuppetWidget->Show(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3197,22 +3205,26 @@ TabChild::GetFrom(uint64_t aLayersId)
|
|||
void
|
||||
TabChild::DidComposite(uint64_t aTransactionId)
|
||||
{
|
||||
MOZ_ASSERT(mWidget);
|
||||
MOZ_ASSERT(mWidget->GetLayerManager());
|
||||
MOZ_ASSERT(mWidget->GetLayerManager()->GetBackendType() == LayersBackend::LAYERS_CLIENT);
|
||||
MOZ_ASSERT(mPuppetWidget);
|
||||
MOZ_ASSERT(mPuppetWidget->GetLayerManager());
|
||||
MOZ_ASSERT(mPuppetWidget->GetLayerManager()->GetBackendType() ==
|
||||
LayersBackend::LAYERS_CLIENT);
|
||||
|
||||
ClientLayerManager *manager = static_cast<ClientLayerManager*>(mWidget->GetLayerManager());
|
||||
ClientLayerManager *manager =
|
||||
static_cast<ClientLayerManager*>(mPuppetWidget->GetLayerManager());
|
||||
manager->DidComposite(aTransactionId);
|
||||
}
|
||||
|
||||
void
|
||||
TabChild::ClearCachedResources()
|
||||
{
|
||||
MOZ_ASSERT(mWidget);
|
||||
MOZ_ASSERT(mWidget->GetLayerManager());
|
||||
MOZ_ASSERT(mWidget->GetLayerManager()->GetBackendType() == LayersBackend::LAYERS_CLIENT);
|
||||
MOZ_ASSERT(mPuppetWidget);
|
||||
MOZ_ASSERT(mPuppetWidget->GetLayerManager());
|
||||
MOZ_ASSERT(mPuppetWidget->GetLayerManager()->GetBackendType() ==
|
||||
LayersBackend::LAYERS_CLIENT);
|
||||
|
||||
ClientLayerManager *manager = static_cast<ClientLayerManager*>(mWidget->GetLayerManager());
|
||||
ClientLayerManager *manager =
|
||||
static_cast<ClientLayerManager*>(mPuppetWidget->GetLayerManager());
|
||||
manager->ClearCachedResources();
|
||||
}
|
||||
|
||||
|
@ -3250,7 +3262,7 @@ TabChild::RecvUIResolutionChanged()
|
|||
ScreenIntSize oldScreenSize = GetInnerSize();
|
||||
mDPI = 0;
|
||||
mDefaultScale = 0;
|
||||
static_cast<PuppetWidget*>(mWidget.get())->ClearBackingScaleCache();
|
||||
static_cast<PuppetWidget*>(mPuppetWidget.get())->ClearBackingScaleCache();
|
||||
nsCOMPtr<nsIDocument> document(GetDocument());
|
||||
nsCOMPtr<nsIPresShell> presShell = document->GetShell();
|
||||
if (presShell) {
|
||||
|
@ -3263,8 +3275,9 @@ TabChild::RecvUIResolutionChanged()
|
|||
ScreenIntSize screenSize = GetInnerSize();
|
||||
if (mHasValidInnerSize && oldScreenSize != screenSize) {
|
||||
ScreenIntRect screenRect = GetOuterRect();
|
||||
mWidget->Resize(screenRect.x + mChromeDisp.x, screenRect.y + mChromeDisp.y,
|
||||
screenSize.width, screenSize.height, true);
|
||||
mPuppetWidget->Resize(screenRect.x + mChromeDisp.x,
|
||||
screenRect.y + mChromeDisp.y,
|
||||
screenSize.width, screenSize.height, true);
|
||||
|
||||
nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(WebNavigation());
|
||||
baseWin->SetPositionAndSize(0, 0, screenSize.width, screenSize.height,
|
||||
|
@ -3336,7 +3349,7 @@ ScreenIntSize
|
|||
TabChild::GetInnerSize()
|
||||
{
|
||||
LayoutDeviceIntSize innerSize =
|
||||
RoundedToInt(mUnscaledInnerSize * mWidget->GetDefaultScale());
|
||||
RoundedToInt(mUnscaledInnerSize * mPuppetWidget->GetDefaultScale());
|
||||
return ViewAs<ScreenPixel>(innerSize, PixelCastJustification::LayoutDeviceIsScreenForTabDims);
|
||||
};
|
||||
|
||||
|
@ -3344,7 +3357,7 @@ ScreenIntRect
|
|||
TabChild::GetOuterRect()
|
||||
{
|
||||
LayoutDeviceIntRect outerRect =
|
||||
RoundedToInt(mUnscaledOuterRect * mWidget->GetDefaultScale());
|
||||
RoundedToInt(mUnscaledOuterRect * mPuppetWidget->GetDefaultScale());
|
||||
return ViewAs<ScreenPixel>(outerRect, PixelCastJustification::LayoutDeviceIsScreenForTabDims);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "mozilla/layers/CompositorTypes.h"
|
||||
#include "nsIWebBrowserChrome3.h"
|
||||
#include "mozilla/dom/ipc/IdType.h"
|
||||
#include "PuppetWidget.h"
|
||||
|
||||
class nsICachedFileDescriptorListener;
|
||||
class nsIDOMWindowUtils;
|
||||
|
@ -169,6 +170,9 @@ class TabChildBase : public nsISupports,
|
|||
public nsMessageManagerScriptExecutor,
|
||||
public ipc::MessageManagerCallback
|
||||
{
|
||||
protected:
|
||||
typedef mozilla::widget::PuppetWidget PuppetWidget;
|
||||
|
||||
public:
|
||||
TabChildBase();
|
||||
|
||||
|
@ -176,7 +180,7 @@ public:
|
|||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TabChildBase)
|
||||
|
||||
virtual nsIWebNavigation* WebNavigation() const = 0;
|
||||
virtual nsIWidget* WebWidget() = 0;
|
||||
virtual PuppetWidget* WebWidget() = 0;
|
||||
nsIPrincipal* GetPrincipal() { return mPrincipal; }
|
||||
// Recalculates the display state, including the CSS
|
||||
// viewport. This should be called whenever we believe the
|
||||
|
@ -429,7 +433,7 @@ public:
|
|||
override;
|
||||
|
||||
virtual nsIWebNavigation* WebNavigation() const override { return mWebNav; }
|
||||
virtual nsIWidget* WebWidget() override { return mWidget; }
|
||||
virtual PuppetWidget* WebWidget() override { return mPuppetWidget; }
|
||||
|
||||
/** Return the DPI of the widget this TabChild draws to. */
|
||||
void GetDPI(float* aDPI);
|
||||
|
@ -614,7 +618,7 @@ private:
|
|||
|
||||
TextureFactoryIdentifier mTextureFactoryIdentifier;
|
||||
nsCOMPtr<nsIWebNavigation> mWebNav;
|
||||
nsCOMPtr<nsIWidget> mWidget;
|
||||
nsRefPtr<PuppetWidget> mPuppetWidget;
|
||||
nsCOMPtr<nsIURI> mLastURI;
|
||||
RenderFrameChild* mRemoteFrame;
|
||||
nsRefPtr<nsIContentChild> mManager;
|
||||
|
|
Загрузка…
Ссылка в новой задаче