From d0a4b621f0a637b8ce085b72f8dca5ad7bdc1263 Mon Sep 17 00:00:00 2001 From: Ting-Yu Lin Date: Wed, 24 Dec 2014 19:14:00 +0100 Subject: [PATCH] Bug 1090682 - Do not consume NS_MOUSE_MOZLONGTAP if SelectWord failed. f=mtseng, r=roc --- layout/base/SelectionCarets.cpp | 22 ++++++++++++++++------ layout/base/SelectionCarets.h | 4 ++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/layout/base/SelectionCarets.cpp b/layout/base/SelectionCarets.cpp index 28b71cdf5854..b29b4600cd5f 100644 --- a/layout/base/SelectionCarets.cpp +++ b/layout/base/SelectionCarets.cpp @@ -262,7 +262,13 @@ SelectionCarets::HandleEvent(WidgetEvent* aEvent) } else if (aEvent->message == NS_MOUSE_MOZLONGTAP) { if (!mVisible) { SELECTIONCARETS_LOG("SelectWord from APZ"); - SelectWord(); + nsresult wordSelected = SelectWord(); + + if (NS_FAILED(wordSelected)) { + SELECTIONCARETS_LOG("SelectWord from APZ failed!") + return nsEventStatus_eIgnore; + } + return nsEventStatus_eConsumeNoDefault; } } @@ -553,25 +559,25 @@ nsresult SelectionCarets::SelectWord() { if (!mPresShell) { - return NS_OK; + return NS_ERROR_UNEXPECTED; } nsIFrame* rootFrame = mPresShell->GetRootFrame(); if (!rootFrame) { - return NS_OK; + return NS_ERROR_NOT_AVAILABLE; } // Find content offsets for mouse down point nsIFrame *ptFrame = nsLayoutUtils::GetFrameForPoint(rootFrame, mDownPoint, nsLayoutUtils::IGNORE_PAINT_SUPPRESSION | nsLayoutUtils::IGNORE_CROSS_DOC); if (!ptFrame) { - return NS_OK; + return NS_ERROR_FAILURE; } bool selectable; ptFrame->IsSelectable(&selectable, nullptr); if (!selectable) { - return NS_OK; + return NS_ERROR_FAILURE; } nsPoint ptInFrame = mDownPoint; @@ -1212,7 +1218,11 @@ SelectionCarets::FireLongTap(nsITimer* aTimer, void* aSelectionCarets) "Unexpected timer"); SELECTIONCARETS_LOG_STATIC("SelectWord from non-APZ"); - self->SelectWord(); + nsresult wordSelected = self->SelectWord(); + + if (NS_FAILED(wordSelected)) { + SELECTIONCARETS_LOG_STATIC("SelectWord from non-APZ failed!"); + } } void diff --git a/layout/base/SelectionCarets.h b/layout/base/SelectionCarets.h index fb31f69f657a..36a984c7d5e8 100644 --- a/layout/base/SelectionCarets.h +++ b/layout/base/SelectionCarets.h @@ -121,8 +121,8 @@ private: void UpdateSelectionCarets(); /** - * Select word base on current position, only active when element - * is focused. Triggered by long tap event. + * Select a word base on current position, which activates only if element is + * selectable. Triggered by long tap event. */ nsresult SelectWord();