Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[embedlite] Add implementation for UpdateZoomConstraints. Contributes…
… to JB#37171

New ZoomConstraintsClient calls UpdateZoomConstraints for the widget. Frame
metrics update code elsewhere can be dropped. In order to apz zoom to
work apz.allow.zooming must be true.
  • Loading branch information
rainemak committed Dec 5, 2018
1 parent 023e1e9 commit c4df861
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 56 deletions.
2 changes: 1 addition & 1 deletion embedding/embedlite/embedding.js
Expand Up @@ -51,7 +51,7 @@ pref("font.size.inflation.disabledInMasterProcess", true);
pref("layers.max-active", 20);

// APZC preferences.

pref("apz.allow_zooming", true);
pref("apz.asyncscroll.throttle", 15);
pref("apz.fling_accel_base_mult", "1.125f");
pref("apz.min_skate_speed", "1.0f");
Expand Down
11 changes: 11 additions & 0 deletions embedding/embedlite/embedshared/EmbedLitePuppetWidget.cpp
Expand Up @@ -669,6 +669,17 @@ bool EmbedLitePuppetWidget::AsyncPanZoomEnabled() const
return true;
}

void EmbedLitePuppetWidget::UpdateZoomConstraints(const uint32_t &aPresShellId, const FrameMetrics::ViewID &aViewId, const mozilla::Maybe<ZoomConstraints> &aConstraints)
{
EmbedLiteViewChildIface* view = GetEmbedLiteChildView();
LOGT("view: %p, mWindow: %p, child view: %p", mView, mWindow, view);
if (view) {
view->UpdateZoomConstraints(aPresShellId,
aViewId,
aConstraints);
}
}

CompositorParent*
EmbedLitePuppetWidget::NewCompositorParent(int aSurfaceWidth, int aSurfaceHeight)
{
Expand Down
4 changes: 4 additions & 0 deletions embedding/embedlite/embedshared/EmbedLitePuppetWidget.h
Expand Up @@ -157,6 +157,10 @@ class EmbedLitePuppetWidget : public nsBaseWidget

virtual bool AsyncPanZoomEnabled() const override;

virtual void UpdateZoomConstraints(const uint32_t& aPresShellId,
const FrameMetrics::ViewID& aViewId,
const mozilla::Maybe<ZoomConstraints>& aConstraints) override;

/**
* Called before the LayerManager draws the layer tree.
*
Expand Down
10 changes: 0 additions & 10 deletions embedding/embedlite/embedshared/EmbedLiteViewBaseChild.cpp
Expand Up @@ -88,7 +88,6 @@ EmbedLiteViewBaseChild::EmbedLiteViewBaseChild(const uint32_t& aWindowId, const
, mChrome(nullptr)
, mDOMWindow(nullptr)
, mWebNavigation(nullptr)
, mViewResized(false)
, mWindowObserverRegistered(false)
, mIsFocused(false)
, mMargins(0, 0, 0, 0)
Expand Down Expand Up @@ -772,13 +771,6 @@ EmbedLiteViewBaseChild::RecvUpdateFrame(const FrameMetrics& aFrameMetrics)
return true;
}

// if (mViewResized &&
// aFrameMetrics.GetIsRoot() &&
// mHelper->mLastRootMetrics.GetPresShellId() == aFrameMetrics.GetPresShellId() &&
// mHelper->HandlePossibleViewportChange(mHelper->mInnerSize)) {
// mViewResized = false;
// }

RelayFrameMetrics(aFrameMetrics);

if (sHandleDefaultAZPC.viewport) {
Expand Down Expand Up @@ -1218,8 +1210,6 @@ EmbedLiteViewBaseChild::DispatchSynthesizedMouseEvent(const WidgetTouchEvent& aE
void EmbedLiteViewBaseChild::WidgetBoundsChanged(const nsIntRect& aSize)
{
LOGT("sz[%d,%d]", aSize.width, aSize.height);
mViewResized = true;

MOZ_ASSERT(mHelper && mWebBrowser);

nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(mWebBrowser);
Expand Down
1 change: 0 additions & 1 deletion embedding/embedlite/embedshared/EmbedLiteViewBaseChild.h
Expand Up @@ -187,7 +187,6 @@ class EmbedLiteViewBaseChild : public PEmbedLiteViewChild,
RefPtr<WebBrowserChrome> mChrome;
nsCOMPtr<nsPIDOMWindow> mDOMWindow;
nsCOMPtr<nsIWebNavigation> mWebNavigation;
bool mViewResized;
bool mWindowObserverRegistered;
bool mIsFocused;
nsIntMargin mMargins;
Expand Down
46 changes: 2 additions & 44 deletions embedding/embedlite/utils/TabChildHelper.cpp
Expand Up @@ -195,9 +195,6 @@ TabChildHelper::InitTabChildGlobal()
NS_ENSURE_TRUE(root, false);
root->SetParentTarget(scope);

chromeHandler->AddEventListener(NS_LITERAL_STRING("DOMMetaAdded"), this, false);
chromeHandler->AddEventListener(NS_LITERAL_STRING("scroll"), this, false);

return true;
}

Expand Down Expand Up @@ -229,40 +226,14 @@ TabChildHelper::Observe(nsISupports* aSubject,
nsCOMPtr<nsIDocument> doc(GetDocument());

if (SameCOMIdentity(subject, doc)) {
mozilla::dom::AutoNoJSAPI nojsapi;

nsCOMPtr<nsIPresShell> shell(doc->GetShell());
if (shell) {
shell->SetIsFirstPaint(true);
}

APZCCallbackHelper::InitializeRootDisplayport(shell);

// if (!sDisableViewportHandler) {
// // Reset CSS viewport and zoom to default on new page, then
// // calculate them properly using the actual metadata from the
// // page.
// SetCSSViewport(kDefaultViewportSize);

// // In some cases before-first-paint gets called before
// // RecvUpdateDimensions is called and therefore before we have an
// // mInnerSize value set. In such cases defer initializing the viewport
// // until we we get an inner size.
// if (HasValidInnerSize()) {
// InitializeRootMetrics();

// utils->SetResolution(mLastRootMetrics.GetPresShellResolution(),
// mLastRootMetrics.GetPresShellResolution());
//// HandlePossibleViewportChange(mInnerSize);
// // Relay frame metrics to subscribed listeners
// mView->RelayFrameMetrics(mLastRootMetrics);
// }
// }



nsCOMPtr<nsIObserverService> observerService =
do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
nsCOMPtr<nsIObserverService> observerService = do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
if (observerService) {
observerService->NotifyObservers(aSubject, "embedlite-before-first-paint", nullptr);
}
Expand All @@ -275,17 +246,7 @@ TabChildHelper::Observe(nsISupports* aSubject,
NS_IMETHODIMP
TabChildHelper::HandleEvent(nsIDOMEvent* aEvent)
{
nsAutoString eventType;
aEvent->GetType(eventType);
// Should this also handle "MozScrolledAreaChanged".
if (eventType.EqualsLiteral("DOMMetaAdded")) {
// This meta data may or may not have been a meta viewport tag. If it was,
// we should handle it immediately.
// HandlePossibleViewportChange(mInnerSize);
// Relay frame metrics to subscribed listeners
// mView->RelayFrameMetrics(mLastRootMetrics);
}

(void)(aEvent);
return NS_OK;
}

Expand Down Expand Up @@ -496,10 +457,7 @@ TabChildHelper::ReportSizeUpdate(const gfxSize& aSize)
mHasValidInnerSize = true;
}

// ScreenIntSize oldScreenSize(mInnerSize);
mInnerSize = ScreenIntSize::FromUnknownSize(gfx::IntSize(aSize.width, aSize.height));

// HandlePossibleViewportChange(oldScreenSize);
}

// -- nsITabChild --------------
Expand Down

0 comments on commit c4df861

Please sign in to comment.