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) {
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

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

@ -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();