Skip to content

Commit

Permalink
Bug 1556556 - Remove some cruft related to handling the resolution in…
Browse files Browse the repository at this point in the history
… non-e10s setups. r=tnikkel

Prior to this bug, it was necessary to handle non-e10s specially, because the
resolution was being unapplied at the process boundary, and in non-e10s there
was no process boundary.

The remaining patches in this bug move the resolution unapplication away from
the process boundary in all cases, making special handling for non-e10s
unnecessary.

Differential Revision: https://phabricator.services.mozilla.com/D68273
  • Loading branch information
theres-waldo committed Apr 28, 2020
1 parent b368e58 commit 5e9a66a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 83 deletions.
61 changes: 3 additions & 58 deletions gfx/layers/apz/util/APZCCallbackHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,26 +451,6 @@ PresShell* APZCCallbackHelper::GetRootContentDocumentPresShellForContent(
return context->PresShell();
}

static PresShell* GetRootDocumentPresShell(nsIContent* aContent) {
dom::Document* doc = aContent->GetComposedDoc();
if (!doc) {
return nullptr;
}
PresShell* presShell = doc->GetPresShell();
if (!presShell) {
return nullptr;
}
nsPresContext* context = presShell->GetPresContext();
if (!context) {
return nullptr;
}
context = context->GetRootPresContext();
if (!context) {
return nullptr;
}
return context->PresShell();
}

CSSPoint APZCCallbackHelper::ApplyCallbackTransform(
const CSSPoint& aInput, const ScrollableLayerGuid& aGuid) {
CSSPoint input = aInput;
Expand All @@ -487,29 +467,16 @@ CSSPoint APZCCallbackHelper::ApplyCallbackTransform(
// compositor adds to the layer with the pres shell resolution. The points
// sent to Gecko by APZ don't have this transform unapplied (unlike other
// compositor-side transforms) because APZ doesn't know about it.
if (PresShell* presShell = GetRootDocumentPresShell(content)) {
input = input / presShell->GetResolution();
}

// This represents any resolution on the Root Content Document (RCD)
// that's not on the Root Document (RD). That is, on platforms where
// RCD == RD, it's 1, and on platforms where RCD != RD, it's the RCD
// resolution. 'input' has this resolution applied, but the scroll
// delta retrieved below do not, so we need to apply them to the
// delta before adding the delta to 'input'. (Technically, deltas
// from scroll frames outside the RCD would already have this
// resolution applied, but we don't have such scroll frames in
// practice.)
float nonRootResolution = 1.0f;
if (PresShell* presShell =
GetRootContentDocumentPresShellForContent(content)) {
nonRootResolution = presShell->GetCumulativeNonRootScaleResolution();
input = input / presShell->GetResolution();
}

// Now apply the callback-transform. This is only approximately correct,
// see the comment on GetCumulativeApzCallbackTransform for details.
CSSPoint transform = nsLayoutUtils::GetCumulativeApzCallbackTransform(
content->GetPrimaryFrame());
return input + transform * nonRootResolution;
return input + transform;
}

LayoutDeviceIntPoint APZCCallbackHelper::ApplyCallbackTransform(
Expand Down Expand Up @@ -633,24 +600,6 @@ static dom::Element* GetRootDocumentElementFor(nsIWidget* aWidget) {
return nullptr;
}

static nsIFrame* UpdateRootFrameForTouchTargetDocument(nsIFrame* aRootFrame) {
#if defined(MOZ_WIDGET_ANDROID)
// Re-target so that the hit test is performed relative to the frame for the
// Root Content Document instead of the Root Document which are different in
// Android. See bug 1229752 comment 16 for an explanation of why this is
// necessary.
if (dom::Document* doc =
aRootFrame->PresShell()->GetPrimaryContentDocument()) {
if (PresShell* presShell = doc->GetPresShell()) {
if (nsIFrame* frame = presShell->GetRootFrame()) {
return frame;
}
}
}
#endif
return aRootFrame;
}

namespace {

using FrameForPointOption = nsLayoutUtils::FrameForPointOption;
Expand Down Expand Up @@ -836,8 +785,6 @@ APZCCallbackHelper::SendSetTargetAPZCNotification(nsIWidget* aWidget,
sLastTargetAPZCNotificationInputBlock = aInputBlockId;
if (PresShell* presShell = aDocument->GetPresShell()) {
if (nsIFrame* rootFrame = presShell->GetRootFrame()) {
rootFrame = UpdateRootFrameForTouchTargetDocument(rootFrame);

bool waitForRefresh = false;
nsTArray<ScrollableLayerGuid> targets;

Expand Down Expand Up @@ -882,8 +829,6 @@ void APZCCallbackHelper::SendSetAllowedTouchBehaviorNotification(
}
if (PresShell* presShell = aDocument->GetPresShell()) {
if (nsIFrame* rootFrame = presShell->GetRootFrame()) {
rootFrame = UpdateRootFrameForTouchTargetDocument(rootFrame);

nsTArray<TouchBehaviorFlags> flags;
for (uint32_t i = 0; i < aEvent.mTouches.Length(); i++) {
flags.AppendElement(TouchActionHelper::GetAllowedTouchBehavior(
Expand Down
18 changes: 0 additions & 18 deletions layout/base/PresShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5297,24 +5297,6 @@ float PresShell::GetCumulativeResolution() {
return resolution;
}

float PresShell::GetCumulativeNonRootScaleResolution() {
float resolution = 1.0;
PresShell* currentPresShell = this;
while (currentPresShell) {
nsPresContext* currentCtx = currentPresShell->GetPresContext();
if (currentCtx != currentCtx->GetRootPresContext()) {
resolution *= currentPresShell->GetResolution();
}
nsPresContext* parentCtx = currentCtx->GetParentPresContext();
if (parentCtx) {
currentPresShell = parentCtx->PresShell();
} else {
currentPresShell = nullptr;
}
}
return resolution;
}

void PresShell::SetRestoreResolution(float aResolution,
LayoutDeviceIntSize aDisplaySize) {
if (mMobileViewportManager) {
Expand Down
6 changes: 0 additions & 6 deletions layout/base/PresShell.h
Original file line number Diff line number Diff line change
Expand Up @@ -974,12 +974,6 @@ class PresShell final : public nsStubDocumentObserver,
*/
bool IsResolutionUpdatedByApz() const { return mResolutionUpdatedByApz; }

/**
* Calculate the cumulative scale resolution from this document up to
* but not including the root document.
*/
float GetCumulativeNonRootScaleResolution();

/**
* Used by session restore code to restore a resolution before the first
* paint.
Expand Down
2 changes: 1 addition & 1 deletion layout/base/nsLayoutUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ bool nsLayoutUtils::AllowZoomingForDocument(
}

float nsLayoutUtils::GetCurrentAPZResolutionScale(PresShell* aPresShell) {
return aPresShell ? aPresShell->GetCumulativeNonRootScaleResolution() : 1.0;
return aPresShell ? aPresShell->GetCumulativeResolution() : 1.0;
}

// Return the maximum displayport size, based on the LayerManager's maximum
Expand Down

0 comments on commit 5e9a66a

Please sign in to comment.