Bug 1231517 - part 3, Add ZoomToRect function to nsIWidget classes r=kats

This commit is contained in:
Randall Barker 2016-01-19 17:44:44 -08:00
parent 76df12fed8
commit 5595d357f2
11 changed files with 55 additions and 11 deletions

View File

@ -420,7 +420,7 @@ parent:
* Instructs the TabParent to forward a request to zoom to a rect given in * Instructs the TabParent to forward a request to zoom to a rect given in
* CSS pixels. This rect is relative to the document. * CSS pixels. This rect is relative to the document.
*/ */
ZoomToRect(uint32_t aPresShellId, ViewID aViewId, CSSRect aRect); ZoomToRect(uint32_t aPresShellId, ViewID aViewId, CSSRect aRect, uint32_t aFlags);
/** /**
* We know for sure that content has either preventDefaulted or not * We know for sure that content has either preventDefaulted or not

View File

@ -1688,7 +1688,7 @@ TabChild::RecvHandleDoubleTap(const CSSPoint& aPoint, const Modifiers& aModifier
ViewID viewId; ViewID viewId;
if (APZCCallbackHelper::GetOrCreateScrollIdentifiers( if (APZCCallbackHelper::GetOrCreateScrollIdentifiers(
document->GetDocumentElement(), &presShellId, &viewId)) { document->GetDocumentElement(), &presShellId, &viewId)) {
SendZoomToRect(presShellId, viewId, zoomToRect); SendZoomToRect(presShellId, viewId, zoomToRect, DEFAULT_BEHAVIOR);
} }
return true; return true;

View File

@ -2798,10 +2798,11 @@ TabParent::RecvBrowserFrameOpenWindow(PBrowserParent* aOpener,
bool bool
TabParent::RecvZoomToRect(const uint32_t& aPresShellId, TabParent::RecvZoomToRect(const uint32_t& aPresShellId,
const ViewID& aViewId, const ViewID& aViewId,
const CSSRect& aRect) const CSSRect& aRect,
const uint32_t& aFlags)
{ {
if (RenderFrameParent* rfp = GetRenderFrame()) { if (RenderFrameParent* rfp = GetRenderFrame()) {
rfp->ZoomToRect(aPresShellId, aViewId, aRect); rfp->ZoomToRect(aPresShellId, aViewId, aRect, aFlags);
} }
return true; return true;
} }

View File

@ -299,7 +299,8 @@ public:
virtual bool RecvZoomToRect(const uint32_t& aPresShellId, virtual bool RecvZoomToRect(const uint32_t& aPresShellId,
const ViewID& aViewId, const ViewID& aViewId,
const CSSRect& aRect) override; const CSSRect& aRect,
const uint32_t& aFlags) override;
virtual bool virtual bool
RecvUpdateZoomConstraints(const uint32_t& aPresShellId, RecvUpdateZoomConstraints(const uint32_t& aPresShellId,

View File

@ -506,11 +506,12 @@ RenderFrameParent::BuildDisplayList(nsDisplayListBuilder* aBuilder,
void void
RenderFrameParent::ZoomToRect(uint32_t aPresShellId, ViewID aViewId, RenderFrameParent::ZoomToRect(uint32_t aPresShellId, ViewID aViewId,
const CSSRect& aRect) const CSSRect& aRect,
const uint32_t aFlags)
{ {
if (GetApzcTreeManager()) { if (GetApzcTreeManager()) {
GetApzcTreeManager()->ZoomToRect(ScrollableLayerGuid(mLayersId, aPresShellId, aViewId), GetApzcTreeManager()->ZoomToRect(ScrollableLayerGuid(mLayersId, aPresShellId, aViewId),
aRect); aRect, aFlags);
} }
} }

View File

@ -79,7 +79,7 @@ public:
void OwnerContentChanged(nsIContent* aContent); void OwnerContentChanged(nsIContent* aContent);
void ZoomToRect(uint32_t aPresShellId, ViewID aViewId, const CSSRect& aRect); void ZoomToRect(uint32_t aPresShellId, ViewID aViewId, const CSSRect& aRect, const uint32_t aFlags);
void ContentReceivedInputBlock(const ScrollableLayerGuid& aGuid, void ContentReceivedInputBlock(const ScrollableLayerGuid& aGuid,
uint64_t aInputBlockId, uint64_t aInputBlockId,

View File

@ -1424,5 +1424,18 @@ PuppetWidget::SetCandidateWindowForPlugin(int32_t aX, int32_t aY)
mTabChild->SendSetCandidateWindowForPlugin(aX, aY); mTabChild->SendSetCandidateWindowForPlugin(aX, aY);
} }
void
PuppetWidget::ZoomToRect(const uint32_t& aPresShellId,
const FrameMetrics::ViewID& aViewId,
const CSSRect& aRect,
const uint32_t& aFlags)
{
if (!mTabChild) {
return;
}
mTabChild->SendZoomToRect(aPresShellId, aViewId, aRect, aFlags);
}
} // namespace widget } // namespace widget
} // namespace mozilla } // namespace mozilla

View File

@ -40,6 +40,7 @@ class PuppetWidget : public nsBaseWidget
typedef mozilla::dom::TabChild TabChild; typedef mozilla::dom::TabChild TabChild;
typedef mozilla::gfx::DrawTarget DrawTarget; typedef mozilla::gfx::DrawTarget DrawTarget;
typedef nsBaseWidget Base; typedef nsBaseWidget Base;
typedef mozilla::CSSRect CSSRect;
// The width and height of the "widget" are clamped to this. // The width and height of the "widget" are clamped to this.
static const size_t kMaxDimension; static const size_t kMaxDimension;
@ -254,6 +255,10 @@ public:
virtual void SetCandidateWindowForPlugin(int32_t aX, int32_t aY) override; virtual void SetCandidateWindowForPlugin(int32_t aX, int32_t aY) override;
virtual void ZoomToRect(const uint32_t& aPresShellId,
const FrameMetrics::ViewID& aViewId,
const CSSRect& aRect,
const uint32_t& aFlags) override;
protected: protected:
virtual nsresult NotifyIMEInternal( virtual nsresult NotifyIMEInternal(
const IMENotification& aIMENotification) override; const IMENotification& aIMENotification) override;

View File

@ -1803,6 +1803,19 @@ nsBaseWidget::GetTextEventDispatcher()
return mTextEventDispatcher; return mTextEventDispatcher;
} }
void
nsBaseWidget::ZoomToRect(const uint32_t& aPresShellId,
const FrameMetrics::ViewID& aViewId,
const CSSRect& aRect,
const uint32_t& aFlags)
{
if (!mCompositorParent || !mAPZC) {
return;
}
uint64_t layerId = mCompositorParent->RootLayerTreeId();
mAPZC->ZoomToRect(ScrollableLayerGuid(layerId, aPresShellId, aViewId), aRect, aFlags);
}
#ifdef ACCESSIBILITY #ifdef ACCESSIBILITY
a11y::Accessible* a11y::Accessible*

View File

@ -100,6 +100,7 @@ protected:
typedef mozilla::layers::APZEventState APZEventState; typedef mozilla::layers::APZEventState APZEventState;
typedef mozilla::layers::SetAllowedTouchBehaviorCallback SetAllowedTouchBehaviorCallback; typedef mozilla::layers::SetAllowedTouchBehaviorCallback SetAllowedTouchBehaviorCallback;
typedef mozilla::CSSIntRect CSSIntRect; typedef mozilla::CSSIntRect CSSIntRect;
typedef mozilla::CSSRect CSSRect;
typedef mozilla::ScreenRotation ScreenRotation; typedef mozilla::ScreenRotation ScreenRotation;
virtual ~nsBaseWidget(); virtual ~nsBaseWidget();
@ -251,7 +252,10 @@ public:
virtual nsIWidgetListener* GetPreviouslyAttachedWidgetListener() override; virtual nsIWidgetListener* GetPreviouslyAttachedWidgetListener() override;
virtual void SetPreviouslyAttachedWidgetListener(nsIWidgetListener* aListener) override; virtual void SetPreviouslyAttachedWidgetListener(nsIWidgetListener* aListener) override;
NS_IMETHOD_(TextEventDispatcher*) GetTextEventDispatcher() override final; NS_IMETHOD_(TextEventDispatcher*) GetTextEventDispatcher() override final;
virtual void ZoomToRect(const uint32_t& aPresShellId,
const FrameMetrics::ViewID& aViewId,
const CSSRect& aRect,
const uint32_t& aFlags) override;
// Helper function for dispatching events which are not processed by APZ, // Helper function for dispatching events which are not processed by APZ,
// but need to be transformed by APZ. // but need to be transformed by APZ.
nsEventStatus DispatchInputEvent(mozilla::WidgetInputEvent* aEvent) override; nsEventStatus DispatchInputEvent(mozilla::WidgetInputEvent* aEvent) override;

View File

@ -133,8 +133,8 @@ typedef void* nsNativeWidget;
#endif #endif
#define NS_IWIDGET_IID \ #define NS_IWIDGET_IID \
{ 0x73c0a475, 0x450f, 0x4202, \ { 0x6dc8ce1f, 0xbb55, 0x47c1, \
{ 0xab, 0xb4, 0x62, 0xf8, 0x9d, 0xbe, 0xf7, 0x9a } } { 0xa1, 0x6f, 0x4e, 0x12, 0x37, 0xa1, 0xc2, 0xf4 } }
/* /*
* Window shadow styles * Window shadow styles
@ -350,6 +350,7 @@ class nsIWidget : public nsISupports {
typedef mozilla::LayoutDeviceIntSize LayoutDeviceIntSize; typedef mozilla::LayoutDeviceIntSize LayoutDeviceIntSize;
typedef mozilla::ScreenIntPoint ScreenIntPoint; typedef mozilla::ScreenIntPoint ScreenIntPoint;
typedef mozilla::DesktopIntRect DesktopIntRect; typedef mozilla::DesktopIntRect DesktopIntRect;
typedef mozilla::CSSRect CSSRect;
// Used in UpdateThemeGeometries. // Used in UpdateThemeGeometries.
struct ThemeGeometry { struct ThemeGeometry {
@ -2069,6 +2070,11 @@ public:
*/ */
NS_IMETHOD_(TextEventDispatcher*) GetTextEventDispatcher() = 0; NS_IMETHOD_(TextEventDispatcher*) GetTextEventDispatcher() = 0;
virtual void ZoomToRect(const uint32_t& aPresShellId,
const FrameMetrics::ViewID& aViewId,
const CSSRect& aRect,
const uint32_t& aFlags) = 0;
protected: protected:
/** /**
* Like GetDefaultScale, but taking into account only the system settings * Like GetDefaultScale, but taking into account only the system settings