Bug 676470, ensure null-checking mCurrentTarget actually works, r=masayuki

--HG--
extra : rebase_source : e07cf0b42b89ea8a9236e1519c4df43c31585bd6
This commit is contained in:
Olli Pettay 2015-02-06 02:56:30 +02:00
Родитель f66501af23
Коммит c559f50a7b
1 изменённых файлов: 31 добавлений и 26 удалений

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

@ -481,32 +481,9 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext,
mCurrentTarget = aTargetFrame;
mCurrentTargetContent = nullptr;
// Focus events don't necessarily need a frame.
if (NS_EVENT_NEEDS_FRAME(aEvent)) {
NS_ASSERTION(mCurrentTarget, "mCurrentTarget is null. this should not happen. see bug #13007");
if (!mCurrentTarget) return NS_ERROR_NULL_POINTER;
}
#ifdef DEBUG
if (aEvent->HasDragEventMessage() && sIsPointerLocked) {
NS_ASSERTION(sIsPointerLocked,
"sIsPointerLocked is true. Drag events should be suppressed when the pointer is locked.");
}
#endif
// Store last known screenPoint and clientPoint so pointer lock
// can use these values as constants.
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
if (aEvent->mFlags.mIsTrusted &&
((mouseEvent && mouseEvent->IsReal()) ||
aEvent->mClass == eWheelEventClass) &&
!sIsPointerLocked) {
sLastScreenPoint =
UIEvent::CalculateScreenPoint(aPresContext, aEvent);
sLastClientPoint =
UIEvent::CalculateClientPoint(aPresContext, aEvent, nullptr);
}
// Do not take account NS_MOUSE_ENTER/EXIT so that loading a page
// when user is not active doesn't change the state to active.
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
if (aEvent->mFlags.mIsTrusted &&
((mouseEvent && mouseEvent->IsReal() &&
mouseEvent->message != NS_MOUSE_ENTER &&
@ -524,10 +501,38 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext,
++gMouseOrKeyboardEventCounter;
}
*aStatus = nsEventStatus_eIgnore;
WheelTransaction::OnEvent(aEvent);
// Focus events don't necessarily need a frame.
if (NS_EVENT_NEEDS_FRAME(aEvent)) {
NS_ASSERTION(mCurrentTarget,
"mCurrentTarget is null. this should not happen. "
"see bug #13007");
if (!mCurrentTarget) {
return NS_ERROR_NULL_POINTER;
}
}
#ifdef DEBUG
if (aEvent->HasDragEventMessage() && sIsPointerLocked) {
NS_ASSERTION(sIsPointerLocked,
"sIsPointerLocked is true. Drag events should be suppressed when "
"the pointer is locked.");
}
#endif
// Store last known screenPoint and clientPoint so pointer lock
// can use these values as constants.
if (aEvent->mFlags.mIsTrusted &&
((mouseEvent && mouseEvent->IsReal()) ||
aEvent->mClass == eWheelEventClass) &&
!sIsPointerLocked) {
sLastScreenPoint =
UIEvent::CalculateScreenPoint(aPresContext, aEvent);
sLastClientPoint =
UIEvent::CalculateClientPoint(aPresContext, aEvent, nullptr);
}
*aStatus = nsEventStatus_eIgnore;
switch (aEvent->message) {
case NS_CONTEXTMENU:
if (sIsPointerLocked) {