Bug 1558482 - Apply visibleRect and scaling when painting. r=mattwoodrow

visibleRect should affect both WR/layers, and scaling will only affect
layers.

Differential Revision: https://phabricator.services.mozilla.com/D34525

--HG--
extra : rebase_source : 49273db3e10088c9493f693d5f8b58864dcb01aa
This commit is contained in:
Ryan Hunt 2019-06-11 07:52:12 -05:00
Родитель 99aaa4e6c6
Коммит d4e1195aed
5 изменённых файлов: 48 добавлений и 12 удалений

Просмотреть файл

@ -60,6 +60,7 @@
#include "mozilla/TextEvents.h"
#include "mozilla/TouchEvents.h"
#include "mozilla/Unused.h"
#include "Units.h"
#include "nsBrowserStatusFilter.h"
#include "nsContentUtils.h"
#include "nsDocShell.h"
@ -3328,6 +3329,17 @@ ScreenIntSize BrowserChild::GetInnerSize() {
innerSize, PixelCastJustification::LayoutDeviceIsScreenForTabDims);
};
nsRect BrowserChild::GetVisibleRect() {
bool isForceRendering = mIsTopLevel && mRenderLayers;
if (isForceRendering && !mEffectsInfo.IsVisible()) {
// We are forced to render even though we are not visible. In this case, we
// don't have an accurate visible rect, so we must be conservative.
return nsRect(nsPoint(), CSSPixel::ToAppUnits(mUnscaledInnerSize));
} else {
return mEffectsInfo.mVisibleRect;
}
}
ScreenIntRect BrowserChild::GetOuterRect() {
LayoutDeviceIntRect outerRect =
RoundedToInt(mUnscaledOuterRect * mPuppetWidget->GetDefaultScale());

Просмотреть файл

@ -418,6 +418,8 @@ class BrowserChild final : public nsMessageManagerScriptExecutor,
bool IsTransparent() const { return mIsTransparent; }
const EffectsInfo& GetEffectsInfo() const { return mEffectsInfo; }
void GetMaxTouchPoints(uint32_t* aTouchPoints) {
*aTouchPoints = mMaxTouchPoints;
}
@ -547,6 +549,8 @@ class BrowserChild final : public nsMessageManagerScriptExecutor,
ScreenIntSize GetInnerSize();
nsRect GetVisibleRect();
// Call RecvShow(nsIntSize(0, 0)) and block future calls to RecvShow().
void DoFakeShow(const ShowInfo& aShowInfo);

Просмотреть файл

@ -26,6 +26,7 @@
#include "mozilla/StaticPrefs.h"
#include "mozilla/Unused.h"
#include "nsCharTraits.h"
#include "mozilla/dom/BrowserChild.h"
#include "mozilla/dom/Document.h"
#include "mozilla/dom/DocumentInlines.h"
#include "nsFontMetrics.h"
@ -3786,12 +3787,20 @@ nsresult nsLayoutUtils::PaintFrame(gfxContext* aRenderingContext,
builder->SetInActiveDocShell(isActive);
}
nsRect rootVisualOverflow = aFrame->GetVisualOverflowRectRelativeToSelf();
// If we are in a remote browser, then apply clipping from ancestor browsers
if (BrowserChild* browserChild = BrowserChild::GetFrom(presShell)) {
rootVisualOverflow.IntersectRect(rootVisualOverflow,
browserChild->GetVisibleRect());
}
nsIFrame* rootScrollFrame = presShell->GetRootScrollFrame();
if (rootScrollFrame && !aFrame->GetParent()) {
nsIScrollableFrame* rootScrollableFrame =
presShell->GetRootScrollFrameAsScrollable();
MOZ_ASSERT(rootScrollableFrame);
nsRect displayPortBase = aFrame->GetVisualOverflowRectRelativeToSelf();
nsRect displayPortBase = rootVisualOverflow;
nsRect temp = displayPortBase;
Unused << rootScrollableFrame->DecideScrollableLayer(
builder, &displayPortBase, &temp,
@ -3806,7 +3815,7 @@ nsresult nsLayoutUtils::PaintFrame(gfxContext* aRenderingContext,
// |ignoreViewportScrolling| and |usingDisplayPort| are persistent
// document-rendering state. We rely on PresShell to flush
// retained layers as needed when that persistent state changes.
visibleRegion = aFrame->GetVisualOverflowRectRelativeToSelf();
visibleRegion = rootVisualOverflow;
} else {
visibleRegion = aDirtyRegion;
}

Просмотреть файл

@ -101,7 +101,8 @@ enum class PartialUpdateFailReason {
RebuildLimit,
FrameType,
Disabled,
Content
Content,
VisibleRect,
};
struct RetainedDisplayListMetrics {
@ -146,6 +147,8 @@ struct RetainedDisplayListMetrics {
return "Disabled";
case PartialUpdateFailReason::Content:
return "Content";
case PartialUpdateFailReason::VisibleRect:
return "VisibleRect";
default:
MOZ_ASSERT_UNREACHABLE("Enum value not handled!");
}
@ -254,6 +257,7 @@ struct RetainedDisplayListBuilder {
nsDisplayListBuilder mBuilder;
RetainedDisplayList mList;
nsRect mPreviousVisibleRect;
WeakFrame mPreviousCaret;
RetainedDisplayListMetrics mMetrics;
};

Просмотреть файл

@ -2882,11 +2882,19 @@ FrameLayerBuilder* nsDisplayList::BuildLayers(nsDisplayListBuilder* aBuilder,
rootLayer->SetScrollMetadata(nsTArray<ScrollMetadata>());
}
float rootLayerResolution = StaticPrefs::LayoutUseContainersForRootFrames()
? presShell->GetResolution()
: 1.0f;
ContainerLayerParameters containerParameters(rootLayerResolution,
rootLayerResolution);
float resolutionUniform = StaticPrefs::LayoutUseContainersForRootFrames()
? presShell->GetResolution()
: 1.0f;
float resolutionX = resolutionUniform;
float resolutionY = resolutionUniform;
// If we are in a remote browser, then apply scaling from ancestor browsers
if (BrowserChild* browserChild = BrowserChild::GetFrom(presShell)) {
resolutionX *= browserChild->GetEffectsInfo().mScaleX;
resolutionY *= browserChild->GetEffectsInfo().mScaleY;
}
ContainerLayerParameters containerParameters(resolutionX, resolutionY);
{
PaintTelemetry::AutoRecord record(PaintTelemetry::Metric::Layerization);
@ -2906,11 +2914,10 @@ FrameLayerBuilder* nsDisplayList::BuildLayers(nsDisplayListBuilder* aBuilder,
if (!root) {
return nullptr;
}
// Root is being scaled up by the X/Y resolution. Scale it back down.
root->SetPostScale(1.0f / resolutionX, 1.0f / resolutionY);
if (StaticPrefs::LayoutUseContainersForRootFrames()) {
// Root is being scaled up by the X/Y resolution. Scale it back down.
root->SetPostScale(1.0f / containerParameters.mXScale,
1.0f / containerParameters.mYScale);
root->SetScaleToResolution(containerParameters.mXScale);
root->SetScaleToResolution(resolutionUniform);
}
auto callback = [root](ScrollableLayerGuid::ViewID aScrollId) -> bool {