Skip to content

Commit

Permalink
Add up-to-date IPDL interface for zooming API
Browse files Browse the repository at this point in the history
  • Loading branch information
rojkov authored and tmeshkova committed Feb 1, 2014
1 parent 54c946d commit 9acebbe
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 15 deletions.
16 changes: 14 additions & 2 deletions embedding/embedlite/PEmbedLiteView.ipdl
Expand Up @@ -22,6 +22,7 @@ using class mozilla::WidgetKeyboardEvent from "ipc/nsGUIEventIPC.h";
using class mozilla::WidgetMouseEvent from "ipc/nsGUIEventIPC.h";
using MultiTouchInput from "InputData.h";
using mozilla::CSSIntPoint from "Units.h";
using struct mozilla::layers::ZoomConstraints from "FrameMetrics.h";

namespace mozilla {
namespace embedlite {
Expand Down Expand Up @@ -79,9 +80,20 @@ parent:
async OnScrolledAreaChanged(uint32_t aWidth, uint32_t aHeight);
async OnScrollChanged(int32_t offSetX, int32_t offSetY);
async OnTitleChanged(nsString aTitle);
UpdateZoomConstraints(bool aAllowZoom, float aMinZoom, float aMaxZoom);

ZoomToRect(CSSRect aRect);
/**
* Updates the zoom constraints for a scrollable frame in this tab.
* The zoom controller code lives on the parent side and so this allows it to
* have up-to-date zoom constraints.
*/
UpdateZoomConstraints(uint32_t aPresShellId, ViewID aViewId, bool aIsRoot,
ZoomConstraints aConstraints);

/**
* Instructs the EmbedLiteViewThreadParent to forward a request to zoom to a rect given in
* CSS pixels. This rect is relative to the document.
*/
ZoomToRect(uint32_t aPresShellId, ViewID aViewId, CSSRect aRect);
async SetBackgroundColor(nscolor color);
ContentReceivedTouch(ScrollableLayerGuid aGuid, bool aPreventDefault);
sync GetGLViewSize()
Expand Down
12 changes: 8 additions & 4 deletions embedding/embedlite/embedthread/EmbedLiteViewThreadParent.cpp
Expand Up @@ -260,17 +260,21 @@ EmbedLiteViewThreadParent::RecvOnTitleChanged(const nsString& aTitle)
}

bool
EmbedLiteViewThreadParent::RecvUpdateZoomConstraints(const bool& aAllowZoom, const float& min, const float& max)
EmbedLiteViewThreadParent::RecvUpdateZoomConstraints(const uint32_t& aPresShellId,
const ViewID& aViewId,
const bool& aIsRoot,
const ZoomConstraints& aConstraints)
{
if (mController->GetManager()) {
ZoomConstraints constraints(aAllowZoom, CSSToScreenScale(min), CSSToScreenScale(max));
mController->GetManager()->UpdateZoomConstraints(ScrollableLayerGuid(mRootLayerTreeId, 0, 0), constraints);
mController->GetManager()->UpdateZoomConstraints(ScrollableLayerGuid(mRootLayerTreeId, 0, 0), aConstraints);
}
return true;
}

bool
EmbedLiteViewThreadParent::RecvZoomToRect(const CSSRect& aRect)
EmbedLiteViewThreadParent::RecvZoomToRect(const uint32_t& aPresShellId,
const ViewID& aViewId,
const CSSRect& aRect)
{
if (mController->GetManager()) {
mController->GetManager()->ZoomToRect(ScrollableLayerGuid(mRootLayerTreeId, 0, 0), aRect);
Expand Down
9 changes: 7 additions & 2 deletions embedding/embedlite/embedthread/EmbedLiteViewThreadParent.h
Expand Up @@ -111,8 +111,13 @@ class EmbedLiteViewThreadParent : public PEmbedLiteViewParent,
const nsString& aJSON,
InfallibleTArray<nsString>* aJSONRetVal);
virtual bool
RecvUpdateZoomConstraints(const bool&, const float&, const float&);
virtual bool RecvZoomToRect(const CSSRect& aRect);
RecvUpdateZoomConstraints(const uint32_t& aPresShellId,
const ViewID& aViewId,
const bool& aIsRoot,
const ZoomConstraints& aConstraints);
virtual bool RecvZoomToRect(const uint32_t& aPresShellId,
const ViewID& aViewId,
const CSSRect& aRect);
virtual bool RecvSetBackgroundColor(const nscolor& aColor);
virtual bool RecvContentReceivedTouch(const ScrollableLayerGuid& aGuid, const bool& aPreventDefault);

Expand Down
2 changes: 1 addition & 1 deletion embedding/embedlite/modules/EmbedLiteAppService.cpp
Expand Up @@ -276,7 +276,7 @@ EmbedLiteAppService::ZoomToRect(uint32_t aWinId, float aX, float aY, float aWidt
{
EmbedLiteViewThreadChild* view = sGetViewById(aWinId);
NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
view->SendZoomToRect(CSSRect(aX, aY, aWidth, aHeight));
view->SendZoomToRect(0, 0, CSSRect(aX, aY, aWidth, aHeight));
return NS_OK;
}

Expand Down
13 changes: 7 additions & 6 deletions embedding/embedlite/utils/TabChildHelper.cpp
Expand Up @@ -211,7 +211,7 @@ TabChildHelper::Observe(nsISupports* aSubject,
sscanf(NS_ConvertUTF16toUTF8(aData).get(),
"{\"x\":%f,\"y\":%f,\"w\":%f,\"h\":%f}",
&rect.x, &rect.y, &rect.width, &rect.height);
mView->SendZoomToRect(rect);
mView->SendZoomToRect(0, 0, rect);
} else if (!strcmp(aTopic, BEFORE_FIRST_PAINT)) {
nsCOMPtr<nsIDocument> subject(do_QueryInterface(aSubject));
nsCOMPtr<nsIDOMDocument> domDoc;
Expand Down Expand Up @@ -778,13 +778,14 @@ TabChildHelper::HandlePossibleViewportChange()
nsCOMPtr<nsIDOMWindowUtils> utils(GetDOMWindowUtils());

nsViewportInfo viewportInfo = nsContentUtils::GetViewportInfo(document, mInnerSize);
uint32_t presShellId;
ViewID viewId;
uint32_t presShellId = 0;
ViewID viewId = 0;
if (APZCCallbackHelper::GetScrollIdentifiers(document->GetDocumentElement(),
&presShellId, &viewId)) {
mView->SendUpdateZoomConstraints(viewportInfo.IsZoomAllowed(),
viewportInfo.GetMinZoom().scale,
viewportInfo.GetMaxZoom().scale);
ZoomConstraints constraints(viewportInfo.IsZoomAllowed(),
viewportInfo.GetMinZoom(),
viewportInfo.GetMaxZoom());
mView->SendUpdateZoomConstraints(0, 0, true, constraints);
}


Expand Down

0 comments on commit 9acebbe

Please sign in to comment.