Bug 1143518 - Remove the TryCapture path which is now obsolete. r=smaug

This commit is contained in:
Kartikaya Gupta 2015-03-16 12:32:17 -04:00
parent 4017c4020a
commit 74500c29ee
4 changed files with 7 additions and 127 deletions

View File

@ -236,8 +236,6 @@ private:
namespace mozilla {
namespace dom {
TabParent* sEventCapturer;
TabParent *TabParent::mIMETabParent = nullptr;
TabParent::LayerToTabParentTable* TabParent::sLayerToTabParentTable = nullptr;
@ -262,7 +260,6 @@ TabParent::TabParent(nsIContentParent* aManager,
, mIMECompositionStart(0)
, mIMESeqno(0)
, mIMECompositionRectOffset(0)
, mEventCaptureDepth(0)
, mRect(0, 0, 0, 0)
, mDimensions(0, 0)
, mOrientation(0)
@ -401,9 +398,6 @@ TabParent::Recv__delete__()
void
TabParent::ActorDestroy(ActorDestroyReason why)
{
if (sEventCapturer == this) {
sEventCapturer = nullptr;
}
if (mIMETabParent == this) {
mIMETabParent = nullptr;
}
@ -1325,22 +1319,7 @@ bool TabParent::SendRealTouchEvent(WidgetTouchEvent& event)
return false;
}
if (event.message == NS_TOUCH_START) {
// Adjust the widget coordinates to be relative to our frame.
nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
if (!frameLoader) {
// No frame anymore?
sEventCapturer = nullptr;
return false;
}
mChildProcessOffsetAtTouchStart = GetChildProcessOffset();
MOZ_ASSERT((!sEventCapturer && mEventCaptureDepth == 0) ||
(sEventCapturer == this && mEventCaptureDepth > 0));
// We want to capture all remaining touch events in this series
// for fast-path dispatch.
sEventCapturer = this;
++mEventCaptureDepth;
}
// PresShell::HandleEventInternal adds touches on touch end/cancel. This
@ -1373,41 +1352,6 @@ bool TabParent::SendRealTouchEvent(WidgetTouchEvent& event)
PBrowserParent::SendRealTouchEvent(event, guid, blockId);
}
/*static*/ TabParent*
TabParent::GetEventCapturer()
{
return sEventCapturer;
}
bool
TabParent::TryCapture(const WidgetGUIEvent& aEvent)
{
MOZ_ASSERT(sEventCapturer == this && mEventCaptureDepth > 0);
if (aEvent.mClass != eTouchEventClass) {
// Only capture of touch events is implemented, for now.
return false;
}
WidgetTouchEvent event(*aEvent.AsTouchEvent());
bool isTouchPointUp = (event.message == NS_TOUCH_END ||
event.message == NS_TOUCH_CANCEL);
if (event.message == NS_TOUCH_START || isTouchPointUp) {
// Let the DOM see touch start/end events so that its touch-point
// state stays consistent.
if (isTouchPointUp && 0 == --mEventCaptureDepth) {
// All event series are un-captured, don't try to catch any
// more.
sEventCapturer = nullptr;
}
return false;
}
SendRealTouchEvent(event);
return true;
}
bool
TabParent::RecvSyncMessage(const nsString& aMessage,
const ClonedMessageData& aData,
@ -2550,11 +2494,6 @@ TabParent::GetLoadContext()
return loadContext.forget();
}
/* Be careful if you call this method while proceding a real touch event. For
* example sending a touchstart during a real touchend may results into
* a busted mEventCaptureDepth and following touch events may not do what you
* expect.
*/
NS_IMETHODIMP
TabParent::InjectTouchEvent(const nsAString& aType,
uint32_t* aIdentifiers,
@ -2614,11 +2553,6 @@ TabParent::InjectTouchEvent(const nsAString& aType,
event.touches.AppendElement(t);
}
if ((msg == NS_TOUCH_END || msg == NS_TOUCH_CANCEL) && sEventCapturer) {
WidgetGUIEvent* guiEvent = event.AsGUIEvent();
TryCapture(*guiEvent);
}
SendRealTouchEvent(event);
return NS_OK;
}

View File

@ -102,30 +102,6 @@ public:
nsIXULBrowserWindow* GetXULBrowserWindow();
/**
* Return the TabParent that has decided it wants to capture an
* event series for fast-path dispatch to its subprocess, if one
* has.
*
* DOM event dispatch and widget are free to ignore capture
* requests from TabParents; the end result wrt remote content is
* (must be) always the same, albeit usually slower without
* subprocess capturing. This allows frontends/widget backends to
* "opt in" to faster cross-process dispatch.
*/
static TabParent* GetEventCapturer();
/**
* If this is the current event capturer, give this a chance to
* capture the event. If it was captured, return true, false
* otherwise. Un-captured events should follow normal DOM
* dispatch; captured events should result in no further
* processing from the caller of TryCapture().
*
* It's an error to call TryCapture() if this isn't the event
* capturer.
*/
bool TryCapture(const WidgetGUIEvent& aEvent);
void Destroy();
virtual bool RecvMoveFocus(const bool& aForward) MOZ_OVERRIDE;
@ -440,9 +416,6 @@ protected:
LayoutDeviceIntRect mIMECaretRect;
LayoutDeviceIntRect mIMEEditorRect;
// The number of event series we're currently capturing.
int32_t mEventCaptureDepth;
nsIntRect mRect;
ScreenIntSize mDimensions;
ScreenOrientation mOrientation;

View File

@ -415,23 +415,10 @@ APZCCallbackHelper::ApplyCallbackTransform(WidgetTouchEvent& aEvent,
nsEventStatus
APZCCallbackHelper::DispatchWidgetEvent(WidgetGUIEvent& aEvent)
{
if (!aEvent.widget)
return nsEventStatus_eConsumeNoDefault;
// A nested process may be capturing events.
if (TabParent* capturer = TabParent::GetEventCapturer()) {
if (capturer->TryCapture(aEvent)) {
// Only touch events should be captured, and touch events from a parent
// process should not make it here. Capture for those is done elsewhere
// (for gonk, in nsWindow::DispatchTouchInputViaAPZ).
MOZ_ASSERT(!XRE_IsParentProcess());
return nsEventStatus_eConsumeNoDefault;
}
nsEventStatus status = nsEventStatus_eConsumeNoDefault;
if (aEvent.widget) {
aEvent.widget->DispatchEvent(&aEvent, status);
}
nsEventStatus status;
NS_ENSURE_SUCCESS(aEvent.widget->DispatchEvent(&aEvent, status),
nsEventStatus_eConsumeNoDefault);
return status;
}

View File

@ -317,24 +317,10 @@ nsWindow::DispatchTouchEventForAPZ(const MultiTouchInput& aInput,
// Convert it to an event we can send to Gecko
WidgetTouchEvent event = aInput.ToWidgetTouchEvent(this);
// If there is an event capturing child process, send it directly there.
// This happens if we already sent a touchstart event through the root
// process hit test and it ended up going to a child process. The event
// capturing process should get all subsequent touch events in the same
// event block. In this case the TryCapture call below will return true,
// and the child process will take care of responding to the event as needed
// so we don't need to do anything else here.
if (TabParent* capturer = TabParent::GetEventCapturer()) {
InputAPZContext context(aGuid, aInputBlockId);
if (capturer->TryCapture(event)) {
return;
}
}
// If it didn't get captured, dispatch the event into the gecko root process
// for "normal" flow. The event might get sent to the child process still,
// but if it doesn't we need to notify the APZ of various things. All of
// that happens in DispatchEventForAPZ
// Dispatch the event into the gecko root process for "normal" flow.
// The event might get sent to a child process, but if it doesn't we need to
// notify the APZ of various things. All of that happens in
// ProcessUntransformedAPZEvent
ProcessUntransformedAPZEvent(&event, aGuid, aInputBlockId);
}