зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1573014 - Early-exit ShrinkToDisplaySizeIfNeeded() in reader mode. r=hiro
Differential Revision: https://phabricator.services.mozilla.com/D42967 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
5b141b34d7
Коммит
52a4f25b4b
|
@ -74,6 +74,7 @@ class MockMVMContext : public MVMContext {
|
|||
return Some(mDisplaySize);
|
||||
}
|
||||
bool AllowZoomingForDocument() const { return true; }
|
||||
bool IsInReaderMode() const { return false; }
|
||||
bool IsDocumentLoading() const { return false; }
|
||||
|
||||
void SetResolutionAndScaleTo(float aResolution,
|
||||
|
|
|
@ -124,6 +124,16 @@ bool GeckoMVMContext::AllowZoomingForDocument() const {
|
|||
return nsLayoutUtils::AllowZoomingForDocument(mDocument);
|
||||
}
|
||||
|
||||
bool GeckoMVMContext::IsInReaderMode() const {
|
||||
MOZ_ASSERT(mDocument);
|
||||
nsString uri;
|
||||
if (NS_FAILED(mDocument->GetDocumentURI(uri))) {
|
||||
return false;
|
||||
}
|
||||
static auto readerModeUriPrefix = NS_LITERAL_STRING("about:reader");
|
||||
return StringBeginsWith(uri, readerModeUriPrefix);
|
||||
}
|
||||
|
||||
bool GeckoMVMContext::IsDocumentLoading() const {
|
||||
MOZ_ASSERT(mDocument);
|
||||
return mDocument->GetReadyStateEnum() == Document::READYSTATE_LOADING;
|
||||
|
|
|
@ -47,6 +47,7 @@ class GeckoMVMContext : public MVMContext {
|
|||
const override;
|
||||
Maybe<LayoutDeviceIntSize> GetContentViewerSize() const override;
|
||||
bool AllowZoomingForDocument() const override;
|
||||
bool IsInReaderMode() const override;
|
||||
bool IsDocumentLoading() const override;
|
||||
|
||||
void SetResolutionAndScaleTo(float aResolution,
|
||||
|
|
|
@ -51,6 +51,7 @@ class MVMContext {
|
|||
const = 0;
|
||||
virtual Maybe<LayoutDeviceIntSize> GetContentViewerSize() const = 0;
|
||||
virtual bool AllowZoomingForDocument() const = 0;
|
||||
virtual bool IsInReaderMode() const = 0;
|
||||
virtual bool IsDocumentLoading() const = 0;
|
||||
|
||||
virtual void SetResolutionAndScaleTo(float aResolution,
|
||||
|
|
|
@ -614,10 +614,13 @@ void MobileViewportManager::ShrinkToDisplaySizeIfNeeded(
|
|||
return;
|
||||
}
|
||||
|
||||
if (!mContext->AllowZoomingForDocument()) {
|
||||
if (!mContext->AllowZoomingForDocument() || mContext->IsInReaderMode()) {
|
||||
// If zoom is disabled, we don't scale down wider contents to fit them
|
||||
// into device screen because users won't be able to zoom out the tiny
|
||||
// contents.
|
||||
// We special-case reader mode, because it doesn't allow zooming, but
|
||||
// the restriction is often not yet in place at the time this logic
|
||||
// runs.
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче