Bug 1208944 - Part 8. Don't get selection on start compostion when plugin has foucs. r=masayuki

This commit is contained in:
Makoto Kato 2015-12-29 22:57:38 +09:00
parent 02cfd580a7
commit d4d5e3d0d9
3 changed files with 25 additions and 9 deletions

View File

@ -497,6 +497,17 @@ ContentCacheInParent::HandleQueryContentEvent(WidgetQueryContentEvent& aEvent,
("ContentCacheInParent: 0x%p HandleQueryContentEvent("
"aEvent={ mMessage=eQuerySelectedText }, aWidget=0x%p)",
this, aWidget));
if (aWidget->PluginHasFocus()) {
MOZ_LOG(sContentCacheLog, LogLevel::Info,
("ContentCacheInParent: 0x%p HandleQueryContentEvent(), "
"return emtpy selection becasue plugin has focus",
this));
aEvent.mSucceeded = true;
aEvent.mReply.mOffset = 0;
aEvent.mReply.mReversed = false;
aEvent.mReply.mHasSelection = false;
return true;
}
if (NS_WARN_IF(!IsSelectionValid())) {
// If content cache hasn't been initialized properly, make the query
// failed.
@ -835,7 +846,12 @@ ContentCacheInParent::OnCompositionEvent(const WidgetCompositionEvent& aEvent)
// We must be able to simulate the selection because
// we might not receive selection updates in time
if (!mIsComposing) {
mCompositionStart = mSelection.StartOffset();
if (aEvent.widget && aEvent.widget->PluginHasFocus()) {
// If focus is on plugin, we cannot get selection range
mCompositionStart = 0;
} else {
mCompositionStart = mSelection.StartOffset();
}
}
mIsComposing = !aEvent.CausesDOMCompositionEndEvent();

View File

@ -1791,6 +1791,14 @@ public:
*/
NS_IMETHOD SetPluginFocused(bool& aFocused) = 0;
/*
* Tell the plugin has focus. It is unnecessary to use IPC
*/
bool PluginHasFocus()
{
return GetInputContext().mIMEState.mEnabled == IMEState::PLUGIN;
}
/*
* Notifies the input context changes.
*/

View File

@ -77,14 +77,6 @@ public:
*/
virtual bool DispatchPluginEvent(const MSG& aMsg);
/*
* Returns true if a plugin has focus on this widget. Otherwise, false.
*/
virtual bool PluginHasFocus() const final
{
return (mInputContext.mIMEState.mEnabled == IMEState::PLUGIN);
}
/*
* Touch input injection apis
*/