Skip to content

Commit

Permalink
Bug 1544218 - part 4: Make remaining APZC code use mozilla::PresShell…
Browse files Browse the repository at this point in the history
… directly rather than nsIPresShell r=kats

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

--HG--
extra : moz-landing-system : lando
  • Loading branch information
masayuki-nakano committed Apr 16, 2019
1 parent 14e2016 commit 3a4c4ee
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
29 changes: 14 additions & 15 deletions gfx/layers/apz/util/APZCCallbackHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,7 @@ static ScreenMargin ScrollFrame(nsIContent* aContent,
return displayPortMargins;
}

static void SetDisplayPortMargins(nsIPresShell* aPresShell,
nsIContent* aContent,
static void SetDisplayPortMargins(PresShell* aPresShell, nsIContent* aContent,
ScreenMargin aDisplayPortMargins,
CSSSize aDisplayPortBase) {
if (!aContent) {
Expand Down Expand Up @@ -382,7 +381,7 @@ bool APZCCallbackHelper::GetOrCreateScrollIdentifiers(
return false;
}

void APZCCallbackHelper::InitializeRootDisplayport(nsIPresShell* aPresShell) {
void APZCCallbackHelper::InitializeRootDisplayport(PresShell* aPresShell) {
// Create a view-id and set a zero-margin displayport for the root element
// of the root document in the chrome process. This ensures that the scroll
// frame for this element gets an APZC, which in turn ensures that all content
Expand Down Expand Up @@ -456,7 +455,7 @@ PresShell* APZCCallbackHelper::GetRootContentDocumentPresShellForContent(
return context->PresShell();
}

static nsIPresShell* GetRootDocumentPresShell(nsIContent* aContent) {
static PresShell* GetRootDocumentPresShell(nsIContent* aContent) {
dom::Document* doc = aContent->GetComposedDoc();
if (!doc) {
return nullptr;
Expand Down Expand Up @@ -492,8 +491,8 @@ 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 (nsIPresShell* shell = GetRootDocumentPresShell(content)) {
input = input / shell->GetResolution();
if (PresShell* presShell = GetRootDocumentPresShell(content)) {
input = input / presShell->GetResolution();
}

// This represents any resolution on the Root Content Document (RCD)
Expand Down Expand Up @@ -630,9 +629,9 @@ static dom::Element* GetRootDocumentElementFor(nsIWidget* aWidget) {
// This returns the root element that ChromeProcessController sets the
// displayport on during initialization.
if (nsView* view = nsView::GetViewFor(aWidget)) {
if (nsIPresShell* shell = view->GetPresShell()) {
MOZ_ASSERT(shell->GetDocument());
return shell->GetDocument()->GetDocumentElement();
if (PresShell* presShell = view->GetPresShell()) {
MOZ_ASSERT(presShell->GetDocument());
return presShell->GetDocument()->GetDocumentElement();
}
}
return nullptr;
Expand Down Expand Up @@ -743,9 +742,9 @@ static bool PrepareForSetTargetAPZCNotification(
}

static void SendLayersDependentApzcTargetConfirmation(
nsIPresShell* aShell, uint64_t aInputBlockId,
PresShell* aPresShell, uint64_t aInputBlockId,
const nsTArray<SLGuidAndRenderRoot>& aTargets) {
LayerManager* lm = aShell->GetLayerManager();
LayerManager* lm = aPresShell->GetLayerManager();
if (!lm) {
return;
}
Expand Down Expand Up @@ -773,7 +772,7 @@ static void SendLayersDependentApzcTargetConfirmation(
} // namespace

DisplayportSetListener::DisplayportSetListener(
nsIWidget* aWidget, nsIPresShell* aPresShell, const uint64_t& aInputBlockId,
nsIWidget* aWidget, PresShell* aPresShell, const uint64_t& aInputBlockId,
const nsTArray<SLGuidAndRenderRoot>& aTargets)
: mWidget(aWidget),
mPresShell(aPresShell),
Expand Down Expand Up @@ -913,16 +912,16 @@ void APZCCallbackHelper::NotifyMozMouseScrollEvent(
CanBubble::eYes, Cancelable::eYes);
}

void APZCCallbackHelper::NotifyFlushComplete(nsIPresShell* aShell) {
void APZCCallbackHelper::NotifyFlushComplete(PresShell* aPresShell) {
MOZ_ASSERT(NS_IsMainThread());
// In some cases, flushing the APZ state to the main thread doesn't actually
// trigger a flush and repaint (this is an intentional optimization - the
// stuff visible to the user is still correct). However, reftests update their
// snapshot based on invalidation events that are emitted during paints,
// so we ensure that we kick off a paint when an APZ flush is done. Note that
// only chrome/testing code can trigger this behaviour.
if (aShell && aShell->GetRootFrame()) {
aShell->GetRootFrame()->SchedulePaint(nsIFrame::PAINT_DEFAULT, false);
if (aPresShell && aPresShell->GetRootFrame()) {
aPresShell->GetRootFrame()->SchedulePaint(nsIFrame::PAINT_DEFAULT, false);
}

nsCOMPtr<nsIObserverService> observerService =
Expand Down
9 changes: 4 additions & 5 deletions gfx/layers/apz/util/APZCCallbackHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <functional>

class nsIContent;
class nsIPresShell;
class nsIScrollableFrame;
class nsIWidget;
template <class T>
Expand All @@ -38,7 +37,7 @@ typedef std::function<void(uint64_t, const nsTArray<TouchBehaviorFlags>&)>
/* Refer to documentation on SendSetTargetAPZCNotification for this class */
class DisplayportSetListener : public nsAPostRefreshObserver {
public:
DisplayportSetListener(nsIWidget* aWidget, nsIPresShell* aPresShell,
DisplayportSetListener(nsIWidget* aWidget, PresShell* aPresShell,
const uint64_t& aInputBlockId,
const nsTArray<SLGuidAndRenderRoot>& aTargets);
virtual ~DisplayportSetListener();
Expand All @@ -47,7 +46,7 @@ class DisplayportSetListener : public nsAPostRefreshObserver {

private:
RefPtr<nsIWidget> mWidget;
RefPtr<nsIPresShell> mPresShell;
RefPtr<PresShell> mPresShell;
uint64_t mInputBlockId;
nsTArray<SLGuidAndRenderRoot> mTargets;
};
Expand Down Expand Up @@ -89,7 +88,7 @@ class APZCCallbackHelper {

/* Initialize a zero-margin displayport on the root document element of the
given presShell. */
static void InitializeRootDisplayport(nsIPresShell* aPresShell);
static void InitializeRootDisplayport(PresShell* aPresShell);

/* Get the pres context associated with the document enclosing |aContent|. */
static nsPresContext* GetPresContextForContent(nsIContent* aContent);
Expand Down Expand Up @@ -183,7 +182,7 @@ class APZCCallbackHelper {
const ScrollableLayerGuid::ViewID& aScrollId, const nsString& aEvent);

/* Notify content that the repaint flush is complete. */
static void NotifyFlushComplete(nsIPresShell* aShell);
static void NotifyFlushComplete(PresShell* aPresShell);

static void NotifyAsyncScrollbarDragInitiated(
uint64_t aDragBlockId, const ScrollableLayerGuid::ViewID& aScrollId,
Expand Down

0 comments on commit 3a4c4ee

Please sign in to comment.