зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1197824 - Add a zoom-constraints-updated message. r=snorp
With this patch the ZoomConstraintsClient updates get broadcast via the observer service on Android, allowing code in browser.js to switch over to using it. --HG-- extra : commitid : FZvsgS8s2oT
This commit is contained in:
Родитель
ffff568fff
Коммит
f0e19c3fe8
|
@ -27,6 +27,7 @@ using mozilla::unused;
|
|||
|
||||
#include "nsAppShell.h"
|
||||
#include "nsIdleService.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsWindow.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsFocusManager.h"
|
||||
|
@ -2541,3 +2542,34 @@ nsWindow::GetMaxTouchPoints() const
|
|||
{
|
||||
return GeckoAppShell::GetMaxTouchPoints();
|
||||
}
|
||||
|
||||
void
|
||||
nsWindow::UpdateZoomConstraints(const uint32_t& aPresShellId,
|
||||
const FrameMetrics::ViewID& aViewId,
|
||||
const mozilla::Maybe<ZoomConstraints>& aConstraints)
|
||||
{
|
||||
#ifdef MOZ_ANDROID_APZ
|
||||
nsBaseWidget::UpdateZoomConstraints(aPresShellId, aViewId, aConstraints);
|
||||
#else
|
||||
if (!aConstraints) {
|
||||
// This is intended to "clear" previously stored constraints but in our
|
||||
// case we don't need to bother since they'll get GC'd from browser.js
|
||||
return;
|
||||
}
|
||||
nsIContent* content = nsLayoutUtils::FindContentFor(aViewId);
|
||||
nsIDocument* doc = content ? content->GetComposedDoc() : nullptr;
|
||||
if (!doc) {
|
||||
return;
|
||||
}
|
||||
nsCOMPtr<nsIObserverService> obsServ = mozilla::services::GetObserverService();
|
||||
nsPrintfCString json("{ \"allowZoom\": %s,"
|
||||
" \"allowDoubleTapZoom\": %s,"
|
||||
" \"minZoom\": %f,"
|
||||
" \"maxZoom\": %f }",
|
||||
aConstraints->mAllowZoom ? "true" : "false",
|
||||
aConstraints->mAllowDoubleTapZoom ? "true" : "false",
|
||||
aConstraints->mMinZoom.scale, aConstraints->mMaxZoom.scale);
|
||||
obsServ->NotifyObservers(doc, "zoom-constraints-updated",
|
||||
NS_ConvertASCIItoUTF16(json.get()).get());
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -169,6 +169,10 @@ public:
|
|||
|
||||
virtual uint32_t GetMaxTouchPoints() const override;
|
||||
|
||||
void UpdateZoomConstraints(const uint32_t& aPresShellId,
|
||||
const FrameMetrics::ViewID& aViewId,
|
||||
const mozilla::Maybe<ZoomConstraints>& aConstraints) override;
|
||||
|
||||
protected:
|
||||
void BringToFront();
|
||||
nsWindow *FindTopLevel();
|
||||
|
|
Загрузка…
Ссылка в новой задаче