Skip to content

Commit

Permalink
Apply more changes from sync-tab branch
Browse files Browse the repository at this point in the history
  • Loading branch information
rojkov authored and tmeshkova committed Feb 4, 2014
1 parent a43a27b commit 8c62bf4
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 9 deletions.
23 changes: 18 additions & 5 deletions embedding/embedlite/embedthread/EmbedContentController.cpp
Expand Up @@ -22,6 +22,7 @@ static FakeListener sFakeListener;
EmbedContentController::EmbedContentController(EmbedLiteViewThreadParent* aRenderFrame, MessageLoop* aUILoop)
: mUILoop(aUILoop)
, mRenderFrame(aRenderFrame)
, mHaveZoomConstraints(false)
{
}

Expand Down Expand Up @@ -139,11 +140,16 @@ void EmbedContentController::ClearRenderFrame()
bool EmbedContentController::GetRootZoomConstraints(ZoomConstraints* aOutConstraints)
{
if (aOutConstraints) {
// Until we support the meta-viewport tag properly allow zooming
// from 1/4 to 4x by default.
aOutConstraints->mAllowZoom = true;
aOutConstraints->mMinZoom = CSSToScreenScale(0.25f);
aOutConstraints->mMaxZoom = CSSToScreenScale(4.0f);
if (mHaveZoomConstraints) {
*aOutConstraints = mZoomConstraints;
} else {
NS_WARNING("Apply default zoom constraints");
// Until we support the meta-viewport tag properly allow zooming
// from 1/4 to 4x by default.
aOutConstraints->mAllowZoom = true;
aOutConstraints->mMinZoom = CSSToScreenScale(0.25f);
aOutConstraints->mMaxZoom = CSSToScreenScale(4.0f);
}
return true;
}
return false;
Expand Down Expand Up @@ -181,3 +187,10 @@ EmbedContentController::ReceiveInputEvent(const InputData& aEvent,

return mAPZC->ReceiveInputEvent(aEvent, aOutTargetGuid);
}

void
EmbedContentController::SaveZoomConstraints(const ZoomConstraints& aConstraints)
{
mHaveZoomConstraints = true;
mZoomConstraints = aConstraints;
}
9 changes: 8 additions & 1 deletion embedding/embedlite/embedthread/EmbedContentController.h
Expand Up @@ -13,7 +13,6 @@
namespace mozilla {
namespace layers {
class APZCTreeManager;
class CompositorParent;
}
namespace embedlite {
class EmbedLiteViewListener;
Expand Down Expand Up @@ -52,13 +51,21 @@ class EmbedContentController : public mozilla::layers::GeckoContentController
ScrollableLayerGuid* aOutTargetGuid);

mozilla::layers::APZCTreeManager* GetManager() { return mAPZC; }

// Methods used by EmbedLiteViewThreadParent to set fields stored here.

void SaveZoomConstraints(const ZoomConstraints& aConstraints);

private:
EmbedLiteViewListener* const GetListener() const;
void DoRequestContentRepaint(const FrameMetrics& aFrameMetrics);

MessageLoop* mUILoop;
EmbedLiteViewThreadParent* mRenderFrame;

bool mHaveZoomConstraints;
ZoomConstraints mZoomConstraints;

// Extra
ScrollableLayerGuid mLastScrollLayerGuid;
CSSIntPoint mLastScrollOffset;
Expand Down
13 changes: 10 additions & 3 deletions embedding/embedlite/utils/TabChildHelper.cpp
Expand Up @@ -214,9 +214,7 @@ TabChildHelper::Observe(nsISupports* aSubject,
mView->SendZoomToRect(0, 0, rect);
} else if (!strcmp(aTopic, BEFORE_FIRST_PAINT)) {
nsCOMPtr<nsIDocument> subject(do_QueryInterface(aSubject));
nsCOMPtr<nsIDOMDocument> domDoc;
mView->mWebNavigation->GetDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
nsCOMPtr<nsIDocument> doc(GetDocument());

if (SameCOMIdentity(subject, doc)) {
nsCOMPtr<nsIDOMWindowUtils> utils(GetDOMWindowUtils());
Expand Down Expand Up @@ -896,3 +894,12 @@ TabChildHelper::HandlePossibleViewportChange()
mFrameMetrics = metrics;
return true;
}

already_AddRefed<nsIDocument>
TabChildHelper::GetDocument()
{
nsCOMPtr<nsIDOMDocument> domDoc;
mView->mWebNavigation->GetDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
return doc.forget();
}
3 changes: 3 additions & 0 deletions embedding/embedlite/utils/TabChildHelper.h
Expand Up @@ -14,6 +14,7 @@
#include "InputData.h"
#include "nsDataHashtable.h"
#include "nsIDOMEventListener.h"
#include "nsIDocument.h"

class CancelableTask;
class nsPresContext;
Expand Down Expand Up @@ -85,6 +86,8 @@ class TabChildHelper : public nsIDOMEventListener,

// Get the DOMWindowUtils for the top-level window in this tab.
already_AddRefed<nsIDOMWindowUtils> GetDOMWindowUtils();
// Get the Document for the top-level window in this tab.
already_AddRefed<nsIDocument> GetDocument();

// Wrapper for nsIDOMWindowUtils.setCSSViewport(). This updates some state
// variables local to this class before setting it.
Expand Down

0 comments on commit 8c62bf4

Please sign in to comment.