Bug 1194851. Change GetOrMaybeCreateDisplayPort into just MaybeCreateDisplayPort, and make it only return a bool, and not the displayport rect. r=botond

This makes the one caller that needs the displayport rect have to ask for it seperately.

The reason for this is later in the patch series we need to add "RelativeToScrollFrame/Port" to all displayport getters, but there is no semantically good way to do that to the name GetOrMaybeCreateDisplayPort.
This commit is contained in:
Timothy Nikkel 2016-01-07 18:27:48 -06:00
Родитель bf347397f1
Коммит f42493831a
3 изменённых файлов: 34 добавлений и 44 удалений

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

@ -3017,30 +3017,26 @@ nsLayoutUtils::CalculateAndSetDisplayPortMargins(nsIScrollableFrame* aScrollFram
content, presShell, displayportMargins, 0, aRepaintMode);
}
bool
nsLayoutUtils::GetOrMaybeCreateDisplayPort(nsDisplayListBuilder& aBuilder,
nsIFrame* aScrollFrame,
nsRect aDisplayPortBase,
nsRect* aOutDisplayport) {
void
nsLayoutUtils::MaybeCreateDisplayPort(nsDisplayListBuilder& aBuilder,
nsIFrame* aScrollFrame,
nsRect aDisplayPortBase) {
nsIContent* content = aScrollFrame->GetContent();
nsIScrollableFrame* scrollableFrame = do_QueryFrame(aScrollFrame);
if (!content || !scrollableFrame) {
return false;
return;
}
// Set the base rect. Note that this will not influence 'haveDisplayPort',
// which is based on either the whole rect or margins being set, but it
// will affect what is returned in 'aOutDisplayPort' if margins are set.
// which is based on either the whole rect or margins being set.
SetDisplayPortBase(content, aDisplayPortBase);
bool haveDisplayPort = GetDisplayPort(content, aOutDisplayport);
bool haveDisplayPort = HasDisplayPort(content);
// We perform an optimization where we ensure that at least one
// async-scrollable frame (i.e. one that WantsAsyncScroll()) has a displayport.
// If that's not the case yet, and we are async-scrollable, we will get a
// displayport.
// Note: we only do this in processes where we do subframe scrolling to
// begin with (i.e., not in the parent process on B2G).
if (aBuilder.IsPaintingToWindow() &&
nsLayoutUtils::AsyncPanZoomEnabled(aScrollFrame) &&
!aBuilder.HaveScrollableDisplayPort() &&
@ -3049,15 +3045,15 @@ nsLayoutUtils::GetOrMaybeCreateDisplayPort(nsDisplayListBuilder& aBuilder,
// If we don't already have a displayport, calculate and set one.
if (!haveDisplayPort) {
CalculateAndSetDisplayPortMargins(scrollableFrame, nsLayoutUtils::RepaintMode::DoNotRepaint);
haveDisplayPort = GetDisplayPort(content, aOutDisplayport);
NS_ASSERTION(haveDisplayPort, "should have a displayport after having just set it");
#ifdef DEBUG
haveDisplayPort = HasDisplayPort(content);
MOZ_ASSERT(haveDisplayPort, "should have a displayport after having just set it");
#endif
}
// Record that the we now have a scrollable display port.
aBuilder.SetHaveScrollableDisplayPort();
}
return haveDisplayPort;
}
nsIScrollableFrame*

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

@ -2706,24 +2706,18 @@ public:
RepaintMode aRepaintMode);
/**
* Get the display port for |aScrollFrame|'s content. If |aScrollFrame|
* WantsAsyncScroll() and we don't have a scrollable displayport yet (as
* tracked by |aBuilder|), calculate and set a display port. Returns true if
* there is (now) a displayport, and if so the displayport is returned in
* |aOutDisplayport|.
* If |aScrollFrame| WantsAsyncScroll() and we don't have a scrollable
* displayport yet (as tracked by |aBuilder|), calculate and set a
* displayport.
*
* Note that a displayport can either be stored as a rect, or as a base
* rect + margins. If it is stored as a base rect + margins, the base rect
* is updated to |aDisplayPortBase|, and the rect assembled from the
* base rect and margins is returned. If this function creates a displayport,
* it computes margins and stores |aDisplayPortBase| as the base rect.
* If this function creates a displayport, it computes margins and stores
* |aDisplayPortBase| as the base rect.
*
* This is intended to be called during display list building.
*/
static bool GetOrMaybeCreateDisplayPort(nsDisplayListBuilder& aBuilder,
nsIFrame* aScrollFrame,
nsRect aDisplayPortBase,
nsRect* aOutDisplayport);
static void MaybeCreateDisplayPort(nsDisplayListBuilder& aBuilder,
nsIFrame* aScrollFrame,
nsRect aDisplayPortBase);
static nsIScrollableFrame* GetAsyncScrollableAncestorFrame(nsIFrame* aTarget);

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

@ -3226,26 +3226,26 @@ ScrollFrameHelper::DecideScrollableLayer(nsDisplayListBuilder* aBuilder,
if (aBuilder->IsPaintingToWindow()) {
wasUsingDisplayPort = nsLayoutUtils::HasDisplayPort(content);
nsRect displayportBase = *aDirtyRect;
nsPresContext* pc = mOuter->PresContext();
if (mIsRoot && (pc->IsRootContentDocument() || !pc->GetParentPresContext())) {
displayportBase =
nsRect(nsPoint(0, 0), nsLayoutUtils::CalculateCompositionSizeForFrame(mOuter));
}
nsRect displayPort;
if (aAllowCreateDisplayPort) {
nsRect displayportBase = *aDirtyRect;
nsPresContext* pc = mOuter->PresContext();
if (mIsRoot && (pc->IsRootContentDocument() || !pc->GetParentPresContext())) {
displayportBase =
nsRect(nsPoint(0, 0), nsLayoutUtils::CalculateCompositionSizeForFrame(mOuter));
}
// Provide the value of the display port base rect, and possibly create a
// display port if there isn't one already.
usingDisplayPort = nsLayoutUtils::GetOrMaybeCreateDisplayPort(
*aBuilder, mOuter, displayportBase, &displayPort);
} else {
// We should have already been called with aAllowCreateDisplayPort == true
// which should have set a displayport base.
MOZ_ASSERT(content->GetProperty(nsGkAtoms::DisplayPortBase));
usingDisplayPort = nsLayoutUtils::GetDisplayPort(content, &displayPort);
nsLayoutUtils::MaybeCreateDisplayPort(*aBuilder, mOuter, displayportBase);
}
// If we don't have aAllowCreateDisplayPort == true then should have already
// been called with aAllowCreateDisplayPort == true which should have set a
// displayport base.
MOZ_ASSERT(content->GetProperty(nsGkAtoms::DisplayPortBase));
nsRect displayPort;
usingDisplayPort = nsLayoutUtils::GetDisplayPort(content, &displayPort);
// Override the dirty rectangle if the displayport has been set.
if (usingDisplayPort) {
*aDirtyRect = displayPort;