mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1360666 - Update IME state when nsObjectLoadingContent content changes type from 'loading' to a valid content type. r=masayuki
MozReview-Commit-ID: 2cjJ5SvJsTa
This commit is contained in:
parent
84951ded23
commit
37050ac3cc
@ -280,6 +280,14 @@ GetContentWindow(nsIContent* aContent)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool nsFocusManager::IsFocused(nsIContent* aContent)
|
||||||
|
{
|
||||||
|
if (!aContent || !mFocusedContent) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return aContent == mFocusedContent.get();
|
||||||
|
}
|
||||||
|
|
||||||
// get the current window for the given content node
|
// get the current window for the given content node
|
||||||
static nsPIDOMWindowOuter*
|
static nsPIDOMWindowOuter*
|
||||||
GetCurrentWindow(nsIContent* aContent)
|
GetCurrentWindow(nsIContent* aContent)
|
||||||
|
@ -68,6 +68,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
nsIContent* GetFocusedContent() { return mFocusedContent; }
|
nsIContent* GetFocusedContent() { return mFocusedContent; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if aContent currently has focus.
|
||||||
|
*/
|
||||||
|
bool IsFocused(nsIContent* aContent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a focused window. Version of nsIFocusManager::GetFocusedWindow.
|
* Return a focused window. Version of nsIFocusManager::GetFocusedWindow.
|
||||||
*/
|
*/
|
||||||
|
@ -87,11 +87,14 @@
|
|||||||
#include "mozilla/EventDispatcher.h"
|
#include "mozilla/EventDispatcher.h"
|
||||||
#include "mozilla/EventStateManager.h"
|
#include "mozilla/EventStateManager.h"
|
||||||
#include "mozilla/EventStates.h"
|
#include "mozilla/EventStates.h"
|
||||||
|
#include "IMEStateManager.h"
|
||||||
|
#include "mozilla/widget/IMEData.h"
|
||||||
#include "mozilla/IntegerPrintfMacros.h"
|
#include "mozilla/IntegerPrintfMacros.h"
|
||||||
#include "mozilla/dom/HTMLObjectElementBinding.h"
|
#include "mozilla/dom/HTMLObjectElementBinding.h"
|
||||||
#include "mozilla/dom/HTMLEmbedElement.h"
|
#include "mozilla/dom/HTMLEmbedElement.h"
|
||||||
#include "mozilla/dom/HTMLObjectElement.h"
|
#include "mozilla/dom/HTMLObjectElement.h"
|
||||||
#include "nsChannelClassifier.h"
|
#include "nsChannelClassifier.h"
|
||||||
|
#include "nsFocusManager.h"
|
||||||
|
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
// Thanks so much, Microsoft! :(
|
// Thanks so much, Microsoft! :(
|
||||||
@ -1847,7 +1850,20 @@ nsObjectLoadingContent::UpdateObjectParameters()
|
|||||||
if (newType != mType) {
|
if (newType != mType) {
|
||||||
retval = (ParameterUpdateFlags)(retval | eParamStateChanged);
|
retval = (ParameterUpdateFlags)(retval | eParamStateChanged);
|
||||||
LOG(("OBJLC [%p]: Type changed from %u -> %u", this, mType, newType));
|
LOG(("OBJLC [%p]: Type changed from %u -> %u", this, mType, newType));
|
||||||
|
bool updateIMEState = (mType == eType_Loading && newType == eType_Plugin);
|
||||||
mType = newType;
|
mType = newType;
|
||||||
|
// The IME manager needs to know if this is a plugin so it can adjust
|
||||||
|
// input handling to an appropriate mode for plugins.
|
||||||
|
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||||
|
nsCOMPtr<nsIContent> thisContent =
|
||||||
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
||||||
|
MOZ_ASSERT(thisContent, "should have content");
|
||||||
|
if (updateIMEState && thisContent && fm && fm->IsFocused(thisContent)) {
|
||||||
|
widget::IMEState state;
|
||||||
|
state.mEnabled = widget::IMEState::PLUGIN;
|
||||||
|
state.mOpen = widget::IMEState::DONT_CHANGE_OPEN_STATE;
|
||||||
|
IMEStateManager::UpdateIMEState(state, thisContent, nullptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!URIEquals(mBaseURI, newBaseURI)) {
|
if (!URIEquals(mBaseURI, newBaseURI)) {
|
||||||
|
@ -869,7 +869,7 @@ IMEStateManager::OnEditorDestroying(EditorBase& aEditorBase)
|
|||||||
void
|
void
|
||||||
IMEStateManager::UpdateIMEState(const IMEState& aNewIMEState,
|
IMEStateManager::UpdateIMEState(const IMEState& aNewIMEState,
|
||||||
nsIContent* aContent,
|
nsIContent* aContent,
|
||||||
EditorBase& aEditorBase)
|
EditorBase* aEditorBase)
|
||||||
{
|
{
|
||||||
MOZ_LOG(sISMLog, LogLevel::Info,
|
MOZ_LOG(sISMLog, LogLevel::Info,
|
||||||
("UpdateIMEState(aNewIMEState={ mEnabled=%s, "
|
("UpdateIMEState(aNewIMEState={ mEnabled=%s, "
|
||||||
@ -877,7 +877,7 @@ IMEStateManager::UpdateIMEState(const IMEState& aNewIMEState,
|
|||||||
"sPresContext=0x%p, sContent=0x%p, sWidget=0x%p (available: %s), "
|
"sPresContext=0x%p, sContent=0x%p, sWidget=0x%p (available: %s), "
|
||||||
"sActiveIMEContentObserver=0x%p, sIsGettingNewIMEState=%s",
|
"sActiveIMEContentObserver=0x%p, sIsGettingNewIMEState=%s",
|
||||||
GetIMEStateEnabledName(aNewIMEState.mEnabled),
|
GetIMEStateEnabledName(aNewIMEState.mEnabled),
|
||||||
GetIMEStateSetOpenName(aNewIMEState.mOpen), aContent, &aEditorBase,
|
GetIMEStateSetOpenName(aNewIMEState.mOpen), aContent, aEditorBase,
|
||||||
sPresContext.get(), sContent.get(),
|
sPresContext.get(), sContent.get(),
|
||||||
sWidget, GetBoolName(sWidget && !sWidget->Destroyed()),
|
sWidget, GetBoolName(sWidget && !sWidget->Destroyed()),
|
||||||
sActiveIMEContentObserver.get(),
|
sActiveIMEContentObserver.get(),
|
||||||
@ -890,7 +890,16 @@ IMEStateManager::UpdateIMEState(const IMEState& aNewIMEState,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIPresShell> presShell = aEditorBase.GetPresShell();
|
MOZ_ASSERT(aContent, "we must have content");
|
||||||
|
|
||||||
|
nsCOMPtr<nsIPresShell> presShell;
|
||||||
|
if (!aEditorBase) {
|
||||||
|
nsIDocument* doc = aContent->OwnerDoc();
|
||||||
|
presShell = doc->GetShell();
|
||||||
|
} else {
|
||||||
|
presShell = aEditorBase->GetPresShell();
|
||||||
|
}
|
||||||
|
|
||||||
if (NS_WARN_IF(!presShell)) {
|
if (NS_WARN_IF(!presShell)) {
|
||||||
MOZ_LOG(sISMLog, LogLevel::Error,
|
MOZ_LOG(sISMLog, LogLevel::Error,
|
||||||
(" UpdateIMEState(), FAILED due to "
|
(" UpdateIMEState(), FAILED due to "
|
||||||
@ -951,7 +960,7 @@ IMEStateManager::UpdateIMEState(const IMEState& aNewIMEState,
|
|||||||
"active IMEContentObserver"));
|
"active IMEContentObserver"));
|
||||||
RefPtr<IMEContentObserver> contentObserver = sActiveIMEContentObserver;
|
RefPtr<IMEContentObserver> contentObserver = sActiveIMEContentObserver;
|
||||||
if (!contentObserver->MaybeReinitialize(widget, sPresContext,
|
if (!contentObserver->MaybeReinitialize(widget, sPresContext,
|
||||||
aContent, &aEditorBase)) {
|
aContent, aEditorBase)) {
|
||||||
MOZ_LOG(sISMLog, LogLevel::Error,
|
MOZ_LOG(sISMLog, LogLevel::Error,
|
||||||
(" UpdateIMEState(), failed to reinitialize the "
|
(" UpdateIMEState(), failed to reinitialize the "
|
||||||
"active IMEContentObserver"));
|
"active IMEContentObserver"));
|
||||||
@ -1007,7 +1016,7 @@ IMEStateManager::UpdateIMEState(const IMEState& aNewIMEState,
|
|||||||
// XXX In this case, it might not be enough safe to notify IME of anything.
|
// XXX In this case, it might not be enough safe to notify IME of anything.
|
||||||
// So, don't try to flush pending notifications of IMEContentObserver
|
// So, don't try to flush pending notifications of IMEContentObserver
|
||||||
// here.
|
// here.
|
||||||
CreateIMEContentObserver(&aEditorBase);
|
CreateIMEContentObserver(aEditorBase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ public:
|
|||||||
// widget. So, the caller must have focus.
|
// widget. So, the caller must have focus.
|
||||||
static void UpdateIMEState(const IMEState &aNewIMEState,
|
static void UpdateIMEState(const IMEState &aNewIMEState,
|
||||||
nsIContent* aContent,
|
nsIContent* aContent,
|
||||||
EditorBase& aEditorBase);
|
EditorBase* aEditorBase);
|
||||||
|
|
||||||
// This method is called when user operates mouse button in focused editor
|
// This method is called when user operates mouse button in focused editor
|
||||||
// and before the editor handles it.
|
// and before the editor handles it.
|
||||||
|
@ -330,7 +330,7 @@ EditorBase::PostCreate()
|
|||||||
rv = GetPreferredIMEState(&newState);
|
rv = GetPreferredIMEState(&newState);
|
||||||
NS_ENSURE_SUCCESS(rv, NS_OK);
|
NS_ENSURE_SUCCESS(rv, NS_OK);
|
||||||
nsCOMPtr<nsIContent> content = GetFocusedContentForIME();
|
nsCOMPtr<nsIContent> content = GetFocusedContentForIME();
|
||||||
IMEStateManager::UpdateIMEState(newState, content, *this);
|
IMEStateManager::UpdateIMEState(newState, content, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FYI: This call might cause destroying this editor.
|
// FYI: This call might cause destroying this editor.
|
||||||
@ -528,7 +528,7 @@ EditorBase::SetFlags(uint32_t aFlags)
|
|||||||
// NOTE: When the enabled state isn't going to be modified, this method
|
// NOTE: When the enabled state isn't going to be modified, this method
|
||||||
// is going to do nothing.
|
// is going to do nothing.
|
||||||
nsCOMPtr<nsIContent> content = GetFocusedContentForIME();
|
nsCOMPtr<nsIContent> content = GetFocusedContentForIME();
|
||||||
IMEStateManager::UpdateIMEState(newState, content, *this);
|
IMEStateManager::UpdateIMEState(newState, content, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user