mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-24 21:58:06 +00:00
Bug 1254629 - Let query events fail when content root is wrong; r=masayuki
Make query events fail (including when caching selection) if the queried content root is different from what we expected. Also, introduce a fix-up to the selection fix in test_imestate.html.
This commit is contained in:
parent
fb47188c38
commit
ae409c5147
@ -740,10 +740,11 @@ IMEContentObserver::HandleQueryContentEvent(WidgetQueryContentEvent* aEvent)
|
||||
mIsHandlingQueryContentEvent = true;
|
||||
ContentEventHandler handler(GetPresContext());
|
||||
nsresult rv = handler.HandleQueryContentEvent(aEvent);
|
||||
if (aEvent->mSucceeded) {
|
||||
// We need to guarantee that mRootContent should be always same value for
|
||||
// the observing editor.
|
||||
aEvent->mReply.mContentsRoot = mRootContent;
|
||||
|
||||
if (!IsInitializedWithPlugin() &&
|
||||
NS_WARN_IF(aEvent->mReply.mContentsRoot != mRootContent)) {
|
||||
// Focus has changed unexpectedly, so make the query fail.
|
||||
aEvent->mSucceeded = false;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
@ -1261,7 +1262,8 @@ IMEContentObserver::UpdateSelectionCache()
|
||||
WidgetQueryContentEvent selection(true, eQuerySelectedText, mWidget);
|
||||
ContentEventHandler handler(GetPresContext());
|
||||
handler.OnQuerySelectedText(&selection);
|
||||
if (NS_WARN_IF(!selection.mSucceeded)) {
|
||||
if (NS_WARN_IF(!selection.mSucceeded) ||
|
||||
NS_WARN_IF(selection.mReply.mContentsRoot != mRootContent)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1232,6 +1232,9 @@ function runEditorFlagChangeTests()
|
||||
|
||||
var container = document.getElementById("display");
|
||||
|
||||
// Reset selection from previous tests.
|
||||
window.getSelection().collapse(container, 0);
|
||||
|
||||
// the editor has focus directly.
|
||||
container.setAttribute("contenteditable", "true");
|
||||
container.focus();
|
||||
@ -1252,9 +1255,6 @@ function runEditorFlagChangeTests()
|
||||
editor.QueryInterface(Components.interfaces.nsIEditorIMESupport);
|
||||
var flags = editor.flags;
|
||||
|
||||
// Reset selection from previous tests.
|
||||
editor.selection.collapse(container, 0);
|
||||
|
||||
// input characters
|
||||
synthesizeCompositionChange(
|
||||
{ "composition":
|
||||
|
Loading…
x
Reference in New Issue
Block a user