Bug 1057256 - Part 2 - Add null pointer check for touch and selection carets. r=roc

TouchCaret::IsDisplayable() contains more null pointer check. It covers
what's original there in TouchCaret::HandleEvent().
This commit is contained in:
Ting-Yu Lin 2014-08-25 02:50:00 +02:00
parent 9b08fc1098
commit 75ae3bce11
2 changed files with 13 additions and 7 deletions

View File

@ -539,6 +539,10 @@ SelectionCarets::SelectWord()
nsLayoutUtils::TransformPoint(canvasFrame, ptFrame, ptInFrame);
nsIFrame* caretFocusFrame = GetCaretFocusFrame();
if (!caretFocusFrame) {
return NS_OK;
}
SetSelectionDragState(true);
nsFrame* frame = static_cast<nsFrame*>(ptFrame);
nsresult rs = frame->SelectByTypeAtPoint(mPresShell->GetPresContext(), ptInFrame,
@ -637,6 +641,10 @@ SelectionCarets::DragSelection(const nsPoint &movePoint)
}
nsIFrame* caretFocusFrame = GetCaretFocusFrame();
if (!caretFocusFrame) {
return nsEventStatus_eConsumeNoDefault;
}
nsRefPtr<nsFrameSelection> fs = caretFocusFrame->GetFrameSelection();
nsresult result;
@ -735,6 +743,10 @@ void
SelectionCarets::SetSelectionDragState(bool aState)
{
nsIFrame* caretFocusFrame = GetCaretFocusFrame();
if (!caretFocusFrame) {
return;
}
nsRefPtr<nsFrameSelection> fs = caretFocusFrame->GetFrameSelection();
fs->SetDragState(aState);
}

View File

@ -543,13 +543,7 @@ nsEventStatus
TouchCaret::HandleEvent(WidgetEvent* aEvent)
{
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
if (!presShell) {
return nsEventStatus_eIgnore;
}
mozilla::dom::Element* touchCaretElement = presShell->GetTouchCaretElement();
if (!touchCaretElement) {
if (!IsDisplayable()) {
return nsEventStatus_eIgnore;
}