Bug 1059165 - Part 3 - Do not show touch caret when content is empty. r=ehsan

We want HasNonEmptyTextContent() to descend recursively into editingHost
since <div contenteditable="true"><span>123</span></div> should be
considered as non-empty.
This commit is contained in:
Ting-Yu Lin 2014-10-29 00:34:00 +01:00
parent d04bc8538b
commit 3b4aaaf44c

View File

@ -31,6 +31,7 @@
#include "nsDOMTokenList.h"
#include "nsCaret.h"
#include "mozilla/dom/CustomEvent.h"
#include "nsContentUtils.h"
using namespace mozilla;
@ -426,11 +427,24 @@ TouchCaret::IsDisplayable()
return false;
}
dom::Element* editingHost = focusFrame->GetContent()->GetEditingHost();
if (!editingHost) {
TOUCHCARET_LOG("Cannot get editing host!");
return false;
}
if (!nsContentUtils::HasNonEmptyTextContent(
editingHost, nsContentUtils::eRecurseIntoChildren)) {
TOUCHCARET_LOG("The content is empty!");
return false;
}
if (!IsCaretShowingInScrollFrame()) {
TOUCHCARET_LOG("Caret does not show in the scrollable frame!");
return false;
}
TOUCHCARET_LOG("Touch caret is displayable!");
return true;
}