Bug 1090682 - Do not consume NS_MOUSE_MOZLONGTAP if SelectWord failed. f=mtseng, r=roc

This commit is contained in:
Ting-Yu Lin 2014-12-24 19:14:00 +01:00
Родитель f580f63a40
Коммит d0a4b621f0
2 изменённых файлов: 18 добавлений и 8 удалений

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

@ -262,7 +262,13 @@ SelectionCarets::HandleEvent(WidgetEvent* aEvent)
} else if (aEvent->message == NS_MOUSE_MOZLONGTAP) { } else if (aEvent->message == NS_MOUSE_MOZLONGTAP) {
if (!mVisible) { if (!mVisible) {
SELECTIONCARETS_LOG("SelectWord from APZ"); 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; return nsEventStatus_eConsumeNoDefault;
} }
} }
@ -553,25 +559,25 @@ nsresult
SelectionCarets::SelectWord() SelectionCarets::SelectWord()
{ {
if (!mPresShell) { if (!mPresShell) {
return NS_OK; return NS_ERROR_UNEXPECTED;
} }
nsIFrame* rootFrame = mPresShell->GetRootFrame(); nsIFrame* rootFrame = mPresShell->GetRootFrame();
if (!rootFrame) { if (!rootFrame) {
return NS_OK; return NS_ERROR_NOT_AVAILABLE;
} }
// Find content offsets for mouse down point // Find content offsets for mouse down point
nsIFrame *ptFrame = nsLayoutUtils::GetFrameForPoint(rootFrame, mDownPoint, nsIFrame *ptFrame = nsLayoutUtils::GetFrameForPoint(rootFrame, mDownPoint,
nsLayoutUtils::IGNORE_PAINT_SUPPRESSION | nsLayoutUtils::IGNORE_CROSS_DOC); nsLayoutUtils::IGNORE_PAINT_SUPPRESSION | nsLayoutUtils::IGNORE_CROSS_DOC);
if (!ptFrame) { if (!ptFrame) {
return NS_OK; return NS_ERROR_FAILURE;
} }
bool selectable; bool selectable;
ptFrame->IsSelectable(&selectable, nullptr); ptFrame->IsSelectable(&selectable, nullptr);
if (!selectable) { if (!selectable) {
return NS_OK; return NS_ERROR_FAILURE;
} }
nsPoint ptInFrame = mDownPoint; nsPoint ptInFrame = mDownPoint;
@ -1212,7 +1218,11 @@ SelectionCarets::FireLongTap(nsITimer* aTimer, void* aSelectionCarets)
"Unexpected timer"); "Unexpected timer");
SELECTIONCARETS_LOG_STATIC("SelectWord from non-APZ"); 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 void

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

@ -121,8 +121,8 @@ private:
void UpdateSelectionCarets(); void UpdateSelectionCarets();
/** /**
* Select word base on current position, only active when element * Select a word base on current position, which activates only if element is
* is focused. Triggered by long tap event. * selectable. Triggered by long tap event.
*/ */
nsresult SelectWord(); nsresult SelectWord();