Bug 1468545 - Distinguish between upwards- and downwards-propagating information in InputAPZContext. r?botond
No functional changes here, but this updates the documentation in
InputAPZContext and separates the fields into two categories for easier
understanding. This is what I had in mind when I introduced this class
but never documented it anywhere, and so the "pending layerization" flag
didn't follow the convention that I had in mind. This cleans that up.
MozReview-Commit-ID: I26Ocu5Uco2
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -1722,20 +1722,17 @@ TabChild::HandleRealMouseButtonEvent(con
if (aInputBlockId && aEvent.mFlags.mHandledByAPZ) {
nsCOMPtr<nsIDocument> document(GetDocument());
pendingLayerization =
APZCCallbackHelper::SendSetTargetAPZCNotification(mPuppetWidget, document,
aEvent, aGuid,
aInputBlockId);
}
- InputAPZContext context(aGuid, aInputBlockId, nsEventStatus_eIgnore);
- if (pendingLayerization) {
- InputAPZContext::SetPendingLayerization();
- }
+ InputAPZContext context(aGuid, aInputBlockId, nsEventStatus_eIgnore, pendingLayerization);
WidgetMouseEvent localEvent(aEvent);
localEvent.mWidget = mPuppetWidget;
APZCCallbackHelper::ApplyCallbackTransform(localEvent, aGuid,
mPuppetWidget->GetDefaultScale());
DispatchWidgetEventViaAPZ(localEvent);
if (aInputBlockId && aEvent.mFlags.mHandledByAPZ) {
--- a/gfx/layers/apz/util/InputAPZContext.cpp
+++ b/gfx/layers/apz/util/InputAPZContext.cpp
@@ -7,18 +7,18 @@
#include "InputAPZContext.h"
namespace mozilla {
namespace layers {
ScrollableLayerGuid InputAPZContext::sGuid;
uint64_t InputAPZContext::sBlockId = 0;
nsEventStatus InputAPZContext::sApzResponse = nsEventStatus_eIgnore;
+bool InputAPZContext::sPendingLayerization = false;
bool InputAPZContext::sRoutedToChildProcess = false;
-bool InputAPZContext::sPendingLayerization = false;
/*static*/ ScrollableLayerGuid
InputAPZContext::GetTargetLayerGuid()
{
return sGuid;
}
/*static*/ uint64_t
@@ -28,59 +28,54 @@ InputAPZContext::GetInputBlockId()
}
/*static*/ nsEventStatus
InputAPZContext::GetApzResponse()
{
return sApzResponse;
}
-/*static*/ void
-InputAPZContext::SetRoutedToChildProcess()
-{
- sRoutedToChildProcess = true;
-}
-
-/*static*/ void
-InputAPZContext::SetPendingLayerization()
+/*static*/ bool
+InputAPZContext::HavePendingLayerization()
{
- sPendingLayerization = true;
-}
-
-InputAPZContext::InputAPZContext(const ScrollableLayerGuid& aGuid,
- const uint64_t& aBlockId,
- const nsEventStatus& aApzResponse)
- : mOldGuid(sGuid)
- , mOldBlockId(sBlockId)
- , mOldApzResponse(sApzResponse)
- , mOldRoutedToChildProcess(sRoutedToChildProcess)
- , mOldPendingLayerization(sPendingLayerization)
-{
- sGuid = aGuid;
- sBlockId = aBlockId;
- sApzResponse = aApzResponse;
- sRoutedToChildProcess = false;
- sPendingLayerization = false;
-}
-
-InputAPZContext::~InputAPZContext()
-{
- sGuid = mOldGuid;
- sBlockId = mOldBlockId;
- sApzResponse = mOldApzResponse;
- sRoutedToChildProcess = mOldRoutedToChildProcess;
- sPendingLayerization = mOldPendingLayerization;
+ return sPendingLayerization;
}
/*static*/ bool
InputAPZContext::WasRoutedToChildProcess()
{
return sRoutedToChildProcess;
}
-/*static*/ bool
-InputAPZContext::HavePendingLayerization()
+InputAPZContext::InputAPZContext(const ScrollableLayerGuid& aGuid,
+ const uint64_t& aBlockId,
+ const nsEventStatus& aApzResponse,
+ bool aPendingLayerization)
+ : mOldGuid(sGuid)
+ , mOldBlockId(sBlockId)
+ , mOldApzResponse(sApzResponse)
+ , mOldPendingLayerization(sPendingLayerization)
+ , mOldRoutedToChildProcess(sRoutedToChildProcess)
{
- return sPendingLayerization;
+ sGuid = aGuid;
+ sBlockId = aBlockId;
+ sApzResponse = aApzResponse;
+ sPendingLayerization = aPendingLayerization;
+ sRoutedToChildProcess = false;
+}
+
+InputAPZContext::~InputAPZContext()
+{
+ sGuid = mOldGuid;
+ sBlockId = mOldBlockId;
+ sApzResponse = mOldApzResponse;
+ sPendingLayerization = mOldPendingLayerization;
+ sRoutedToChildProcess = mOldRoutedToChildProcess;
+}
+
+/*static*/ void
+InputAPZContext::SetRoutedToChildProcess()
+{
+ sRoutedToChildProcess = true;
}
} // namespace layers
} // namespace mozilla
--- a/gfx/layers/apz/util/InputAPZContext.h
+++ b/gfx/layers/apz/util/InputAPZContext.h
@@ -8,48 +8,64 @@
#define mozilla_layers_InputAPZContext_h
#include "FrameMetrics.h"
#include "mozilla/EventForwards.h"
namespace mozilla {
namespace layers {
-// InputAPZContext is used to communicate the ScrollableLayerGuid,
-// input block ID, APZ response from nsIWidget to RenderFrameParent.
-// It is conceptually attached to any WidgetInputEvent
-// that has been processed by APZ directly from a widget.
+// InputAPZContext is used to communicate various pieces of information
+// around the codebase without having to plumb it through lots of functions
+// and codepaths. Conceptually it is attached to a WidgetInputEvent that is
+// relevant to APZ.
+//
+// There are two types of information bits propagated using this class. One
+// type is propagated "downwards" (from a process entry point like nsBaseWidget
+// or TabChild) into deeper code that is run during complicated operations
+// like event dispatch. The other type is information that is propagated
+// "upwards", from the deeper code back to the entry point.
class MOZ_STACK_CLASS InputAPZContext
{
private:
+ // State that is propagated downwards from InputAPZContext creation into
+ // "deeper" code.
static ScrollableLayerGuid sGuid;
static uint64_t sBlockId;
static nsEventStatus sApzResponse;
- static bool sRoutedToChildProcess;
static bool sPendingLayerization;
+ // State that is set in deeper code and propagated upwards.
+ static bool sRoutedToChildProcess;
+
public:
+ // Functions to access downwards-propagated data
static ScrollableLayerGuid GetTargetLayerGuid();
static uint64_t GetInputBlockId();
static nsEventStatus GetApzResponse();
- static void SetRoutedToChildProcess();
- static void SetPendingLayerization();
+ static bool HavePendingLayerization();
+ // Functions to access upwards-propagated data
+ static bool WasRoutedToChildProcess();
+
+ // Constructor sets the data to be propagated downwards
InputAPZContext(const ScrollableLayerGuid& aGuid,
const uint64_t& aBlockId,
- const nsEventStatus& aApzResponse);
+ const nsEventStatus& aApzResponse,
+ bool aPendingLayerization = false);
~InputAPZContext();
- static bool WasRoutedToChildProcess();
- static bool HavePendingLayerization();
+ // Functions to set data to be propagated upwards
+ static void SetRoutedToChildProcess();
private:
ScrollableLayerGuid mOldGuid;
uint64_t mOldBlockId;
nsEventStatus mOldApzResponse;
+ bool mOldPendingLayerization;
+
bool mOldRoutedToChildProcess;
- bool mOldPendingLayerization;
};
} // namespace layers
} // namespace mozilla
#endif /* mozilla_layers_InputAPZContext_h */