mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1179632 part.2 WidgetCompositionEvent should store NativeIMEContext which caused the event and PuppetWidget should store it for GetNativeIMEContext() r=smaug, sr=smaug
This commit is contained in:
parent
24944df82e
commit
e6e250467e
@ -1137,11 +1137,21 @@ IMEStateManager::DispatchCompositionEvent(
|
||||
|
||||
MOZ_LOG(sISMLog, LogLevel::Info,
|
||||
("ISM: IMEStateManager::DispatchCompositionEvent(aNode=0x%p, "
|
||||
"aPresContext=0x%p, aCompositionEvent={ message=%s, "
|
||||
"aPresContext=0x%p, aCompositionEvent={ mMessage=%s, "
|
||||
"mNativeIMEContext={ mRawNativeIMEContext=0x%X, "
|
||||
"mOriginProcessID=0x%X }, widget(0x%p)={ "
|
||||
"GetNativeIMEContext()={ mRawNativeIMEContext=0x%X, "
|
||||
"mOriginProcessID=0x%X }, Destroyed()=%s }, "
|
||||
"mFlags={ mIsTrusted=%s, mPropagationStopped=%s } }, "
|
||||
"aIsSynthesized=%s), tabParent=%p",
|
||||
aEventTargetNode, aPresContext,
|
||||
ToChar(aCompositionEvent->mMessage),
|
||||
aCompositionEvent->mNativeIMEContext.mRawNativeIMEContext,
|
||||
aCompositionEvent->mNativeIMEContext.mOriginProcessID,
|
||||
aCompositionEvent->widget.get(),
|
||||
aCompositionEvent->widget->GetNativeIMEContext().mRawNativeIMEContext,
|
||||
aCompositionEvent->widget->GetNativeIMEContext().mOriginProcessID,
|
||||
GetBoolName(aCompositionEvent->widget->Destroyed()),
|
||||
GetBoolName(aCompositionEvent->mFlags.mIsTrusted),
|
||||
GetBoolName(aCompositionEvent->mFlags.mPropagationStopped),
|
||||
GetBoolName(aIsSynthesized), tabParent.get()));
|
||||
@ -1271,8 +1281,18 @@ IMEStateManager::OnCompositionEventDiscarded(
|
||||
|
||||
MOZ_LOG(sISMLog, LogLevel::Info,
|
||||
("ISM: IMEStateManager::OnCompositionEventDiscarded(aCompositionEvent={ "
|
||||
"mMessage=%s, mFlags={ mIsTrusted=%s } })",
|
||||
"mMessage=%s, mNativeIMEContext={ mRawNativeIMEContext=0x%X, "
|
||||
"mOriginProcessID=0x%X }, widget(0x%p)={ "
|
||||
"GetNativeIMEContext()={ mRawNativeIMEContext=0x%X, "
|
||||
"mOriginProcessID=0x%X }, Destroyed()=%s }, "
|
||||
"mFlags={ mIsTrusted=%s } })",
|
||||
ToChar(aCompositionEvent->mMessage),
|
||||
aCompositionEvent->mNativeIMEContext.mRawNativeIMEContext,
|
||||
aCompositionEvent->mNativeIMEContext.mOriginProcessID,
|
||||
aCompositionEvent->widget.get(),
|
||||
aCompositionEvent->widget->GetNativeIMEContext().mRawNativeIMEContext,
|
||||
aCompositionEvent->widget->GetNativeIMEContext().mOriginProcessID,
|
||||
GetBoolName(aCompositionEvent->widget->Destroyed()),
|
||||
GetBoolName(aCompositionEvent->mFlags.mIsTrusted)));
|
||||
|
||||
if (!aCompositionEvent->mFlags.mIsTrusted) {
|
||||
|
@ -39,8 +39,7 @@ TextComposition::TextComposition(nsPresContext* aPresContext,
|
||||
: mPresContext(aPresContext)
|
||||
, mNode(aNode)
|
||||
, mTabParent(aTabParent)
|
||||
, mNativeContext(
|
||||
aCompositionEvent->widget->GetNativeData(NS_NATIVE_IME_CONTEXT))
|
||||
, mNativeContext(aCompositionEvent->mNativeIMEContext)
|
||||
, mCompositionStartOffset(0)
|
||||
, mCompositionTargetOffset(0)
|
||||
, mIsSynthesizedForTests(aCompositionEvent->mFlags.mIsSynthesizedForTests)
|
||||
@ -54,6 +53,7 @@ TextComposition::TextComposition(nsPresContext* aPresContext,
|
||||
Preferences::GetBool("dom.compositionevent.allow_control_characters",
|
||||
false))
|
||||
{
|
||||
MOZ_ASSERT(aCompositionEvent->mNativeIMEContext.IsValid());
|
||||
}
|
||||
|
||||
void
|
||||
@ -66,12 +66,6 @@ TextComposition::Destroy()
|
||||
// this being destroyed for cleaning up the stuff.
|
||||
}
|
||||
|
||||
bool
|
||||
TextComposition::MatchesNativeContext(nsIWidget* aWidget) const
|
||||
{
|
||||
return mNativeContext == aWidget->GetNativeData(NS_NATIVE_IME_CONTEXT);
|
||||
}
|
||||
|
||||
bool
|
||||
TextComposition::IsValidStateForComposition(nsIWidget* aWidget) const
|
||||
{
|
||||
@ -114,6 +108,7 @@ TextComposition::CloneAndDispatchAs(
|
||||
compositionEvent.time = aCompositionEvent->time;
|
||||
compositionEvent.timeStamp = aCompositionEvent->timeStamp;
|
||||
compositionEvent.mData = aCompositionEvent->mData;
|
||||
compositionEvent.mNativeIMEContext = aCompositionEvent->mNativeIMEContext;
|
||||
compositionEvent.mOriginalMessage = aCompositionEvent->mMessage;
|
||||
compositionEvent.mFlags.mIsSynthesizedForTests =
|
||||
aCompositionEvent->mFlags.mIsSynthesizedForTests;
|
||||
@ -613,6 +608,7 @@ TextComposition::CompositionEventDispatcher::Run()
|
||||
switch (mEventMessage) {
|
||||
case eCompositionStart: {
|
||||
WidgetCompositionEvent compStart(true, eCompositionStart, widget);
|
||||
compStart.mNativeIMEContext = mTextComposition->mNativeContext;
|
||||
WidgetQueryContentEvent selectedText(true, eQuerySelectedText, widget);
|
||||
ContentEventHandler handler(presContext);
|
||||
handler.OnQuerySelectedText(&selectedText);
|
||||
@ -629,6 +625,7 @@ TextComposition::CompositionEventDispatcher::Run()
|
||||
case eCompositionCommitAsIs:
|
||||
case eCompositionCommit: {
|
||||
WidgetCompositionEvent compEvent(true, mEventMessage, widget);
|
||||
compEvent.mNativeIMEContext = mTextComposition->mNativeContext;
|
||||
if (mEventMessage != eCompositionCommitAsIs) {
|
||||
compEvent.mData = mData;
|
||||
}
|
||||
@ -650,16 +647,25 @@ TextComposition::CompositionEventDispatcher::Run()
|
||||
******************************************************************************/
|
||||
|
||||
TextCompositionArray::index_type
|
||||
TextCompositionArray::IndexOf(nsIWidget* aWidget)
|
||||
TextCompositionArray::IndexOf(const NativeIMEContext& aNativeIMEContext)
|
||||
{
|
||||
if (!aNativeIMEContext.IsValid()) {
|
||||
return NoIndex;
|
||||
}
|
||||
for (index_type i = Length(); i > 0; --i) {
|
||||
if (ElementAt(i - 1)->MatchesNativeContext(aWidget)) {
|
||||
if (ElementAt(i - 1)->GetNativeIMEContext() == aNativeIMEContext) {
|
||||
return i - 1;
|
||||
}
|
||||
}
|
||||
return NoIndex;
|
||||
}
|
||||
|
||||
TextCompositionArray::index_type
|
||||
TextCompositionArray::IndexOf(nsIWidget* aWidget)
|
||||
{
|
||||
return IndexOf(aWidget->GetNativeIMEContext());
|
||||
}
|
||||
|
||||
TextCompositionArray::index_type
|
||||
TextCompositionArray::IndexOf(nsPresContext* aPresContext)
|
||||
{
|
||||
|
@ -76,7 +76,10 @@ public:
|
||||
// came from nsDOMWindowUtils.
|
||||
bool IsSynthesizedForTests() const { return mIsSynthesizedForTests; }
|
||||
|
||||
bool MatchesNativeContext(nsIWidget* aWidget) const;
|
||||
const widget::NativeIMEContext& GetNativeIMEContext() const
|
||||
{
|
||||
return mNativeContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called when IMEStateManager stops managing the instance.
|
||||
@ -191,7 +194,7 @@ private:
|
||||
|
||||
// mNativeContext stores a opaque pointer. This works as the "ID" for this
|
||||
// composition. Don't access the instance, it may not be available.
|
||||
void* mNativeContext;
|
||||
widget::NativeIMEContext mNativeContext;
|
||||
|
||||
// mEditorWeak is a weak reference to the focused editor handling composition.
|
||||
nsWeakPtr mEditorWeak;
|
||||
@ -400,6 +403,7 @@ class TextCompositionArray final :
|
||||
public nsAutoTArray<RefPtr<TextComposition>, 2>
|
||||
{
|
||||
public:
|
||||
index_type IndexOf(const widget::NativeIMEContext& aNativeIMEContext);
|
||||
index_type IndexOf(nsIWidget* aWidget);
|
||||
index_type IndexOf(nsPresContext* aPresContext);
|
||||
index_type IndexOf(nsPresContext* aPresContext, nsINode* aNode);
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "nsRect.h"
|
||||
#include "nsStringGlue.h"
|
||||
|
||||
class nsIWidget;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class WritingMode;
|
||||
@ -228,6 +230,49 @@ struct IMEState final
|
||||
#define NS_ONLY_ONE_NATIVE_IME_CONTEXT \
|
||||
(reinterpret_cast<void*>(static_cast<intptr_t>(-1)))
|
||||
|
||||
struct NativeIMEContext final
|
||||
{
|
||||
// Pointer to native IME context. Typically this is the result of
|
||||
// nsIWidget::GetNativeData(NS_RAW_NATIVE_IME_CONTEXT) in the parent process.
|
||||
// See also NS_ONLY_ONE_NATIVE_IME_CONTEXT.
|
||||
uintptr_t mRawNativeIMEContext;
|
||||
// Process ID of the origin of mNativeIMEContext.
|
||||
uint64_t mOriginProcessID;
|
||||
|
||||
NativeIMEContext()
|
||||
{
|
||||
Init(nullptr);
|
||||
}
|
||||
|
||||
explicit NativeIMEContext(nsIWidget* aWidget)
|
||||
{
|
||||
Init(aWidget);
|
||||
}
|
||||
|
||||
bool IsValid() const
|
||||
{
|
||||
return mRawNativeIMEContext &&
|
||||
mOriginProcessID != static_cast<uintptr_t>(-1);
|
||||
}
|
||||
|
||||
void Init(nsIWidget* aWidget);
|
||||
void InitWithRawNativeIMEContext(const void* aRawNativeIMEContext)
|
||||
{
|
||||
InitWithRawNativeIMEContext(const_cast<void*>(aRawNativeIMEContext));
|
||||
}
|
||||
void InitWithRawNativeIMEContext(void* aRawNativeIMEContext);
|
||||
|
||||
bool operator==(const NativeIMEContext& aOther) const
|
||||
{
|
||||
return mRawNativeIMEContext == aOther.mRawNativeIMEContext &&
|
||||
mOriginProcessID == aOther.mOriginProcessID;
|
||||
}
|
||||
bool operator!=(const NativeIMEContext& aOther) const
|
||||
{
|
||||
return !(*this == aOther);
|
||||
}
|
||||
};
|
||||
|
||||
struct InputContext final
|
||||
{
|
||||
InputContext()
|
||||
|
@ -79,9 +79,9 @@ PuppetWidget::PuppetWidget(TabChild* aTabChild)
|
||||
, mMemoryPressureObserver(nullptr)
|
||||
, mDPI(-1)
|
||||
, mDefaultScale(-1)
|
||||
, mNativeKeyCommandsValid(false)
|
||||
, mCursorHotspotX(0)
|
||||
, mCursorHotspotY(0)
|
||||
, mNativeKeyCommandsValid(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(PuppetWidget);
|
||||
|
||||
@ -319,6 +319,24 @@ PuppetWidget::DispatchEvent(WidgetGUIEvent* event, nsEventStatus& aStatus)
|
||||
}
|
||||
}
|
||||
|
||||
if (event->mClass == eCompositionEventClass) {
|
||||
// Store the latest native IME context of parent process's widget or
|
||||
// TextEventDispatcher if it's in this process.
|
||||
WidgetCompositionEvent* compositionEvent = event->AsCompositionEvent();
|
||||
#ifdef DEBUG
|
||||
if (mNativeIMEContext.IsValid() &&
|
||||
mNativeIMEContext != compositionEvent->mNativeIMEContext) {
|
||||
RefPtr<TextComposition> composition =
|
||||
IMEStateManager::GetTextCompositionFor(this);
|
||||
MOZ_ASSERT(!composition,
|
||||
"When there is composition caused by old native IME context, "
|
||||
"composition events caused by different native IME context are not "
|
||||
"allowed");
|
||||
}
|
||||
#endif // #ifdef DEBUG
|
||||
mNativeIMEContext = compositionEvent->mNativeIMEContext;
|
||||
}
|
||||
|
||||
aStatus = nsEventStatus_eIgnore;
|
||||
|
||||
if (GetCurrentWidgetListener()) {
|
||||
@ -574,6 +592,11 @@ PuppetWidget::IMEEndComposition(bool aCancel)
|
||||
return NS_OK;
|
||||
#endif
|
||||
|
||||
// There must not be composition which is caused by the PuppetWidget instance.
|
||||
if (NS_WARN_IF(!mNativeIMEContext.IsValid())) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsEventStatus status;
|
||||
bool noCompositionEvent = true;
|
||||
WidgetCompositionEvent compositionCommitEvent(true, eCompositionCommit, this);
|
||||
@ -683,6 +706,12 @@ PuppetWidget::GetInputContext()
|
||||
return context;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(NativeIMEContext)
|
||||
PuppetWidget::GetNativeIMEContext()
|
||||
{
|
||||
return mNativeIMEContext;
|
||||
}
|
||||
|
||||
nsresult
|
||||
PuppetWidget::NotifyIMEOfFocusChange(const IMENotification& aIMENotification)
|
||||
{
|
||||
@ -1120,9 +1149,8 @@ PuppetWidget::GetNativeData(uint32_t aDataType)
|
||||
case NS_NATIVE_DISPLAY:
|
||||
// These types are ignored (see bug 1183828).
|
||||
break;
|
||||
case NS_NATIVE_IME_CONTEXT:
|
||||
// TODO: Implement this in next patch.
|
||||
return nullptr;
|
||||
case NS_RAW_NATIVE_IME_CONTEXT:
|
||||
MOZ_CRASH("You need to call GetNativeIMEContext() instead");
|
||||
case NS_NATIVE_WINDOW:
|
||||
case NS_NATIVE_PLUGIN_PORT:
|
||||
case NS_NATIVE_GRAPHIC:
|
||||
|
@ -179,6 +179,7 @@ public:
|
||||
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
|
||||
const InputContextAction& aAction) override;
|
||||
NS_IMETHOD_(InputContext) GetInputContext() override;
|
||||
NS_IMETHOD_(NativeIMEContext) GetNativeIMEContext() override;
|
||||
virtual nsIMEUpdatePreference GetIMEUpdatePreference() override;
|
||||
|
||||
NS_IMETHOD SetCursor(nsCursor aCursor) override;
|
||||
@ -254,9 +255,6 @@ public:
|
||||
|
||||
virtual void StartAsyncScrollbarDrag(const AsyncDragMetrics& aDragMetrics) override;
|
||||
protected:
|
||||
bool mEnabled;
|
||||
bool mVisible;
|
||||
|
||||
virtual nsresult NotifyIMEInternal(
|
||||
const IMENotification& aIMENotification) override;
|
||||
|
||||
@ -322,21 +320,33 @@ private:
|
||||
// IME
|
||||
nsIMEUpdatePreference mIMEPreferenceOfParent;
|
||||
InputContext mInputContext;
|
||||
// mNativeIMEContext is initialized when this dispatches every composition
|
||||
// event both from parent process's widget and TextEventDispatcher in same
|
||||
// process. If it hasn't been started composition yet, this isn't necessary
|
||||
// for XP code since there is no TextComposition instance which is caused by
|
||||
// the PuppetWidget instance.
|
||||
NativeIMEContext mNativeIMEContext;
|
||||
ContentCacheInChild mContentCache;
|
||||
bool mNeedIMEStateInit;
|
||||
|
||||
// The DPI of the screen corresponding to this widget
|
||||
float mDPI;
|
||||
double mDefaultScale;
|
||||
|
||||
// Precomputed answers for ExecuteNativeKeyBinding
|
||||
bool mNativeKeyCommandsValid;
|
||||
InfallibleTArray<mozilla::CommandInt> mSingleLineCommands;
|
||||
InfallibleTArray<mozilla::CommandInt> mMultiLineCommands;
|
||||
InfallibleTArray<mozilla::CommandInt> mRichTextCommands;
|
||||
|
||||
nsCOMPtr<imgIContainer> mCustomCursor;
|
||||
uint32_t mCursorHotspotX, mCursorHotspotY;
|
||||
|
||||
protected:
|
||||
bool mEnabled;
|
||||
bool mVisible;
|
||||
|
||||
private:
|
||||
bool mNeedIMEStateInit;
|
||||
bool mNativeKeyCommandsValid;
|
||||
};
|
||||
|
||||
struct AutoCacheNativeKeyCommands
|
||||
|
@ -134,6 +134,17 @@ TextEventDispatcher::InitEvent(WidgetGUIEvent& aEvent) const
|
||||
aEvent.time = PR_IntervalNow();
|
||||
aEvent.refPoint = LayoutDeviceIntPoint(0, 0);
|
||||
aEvent.mFlags.mIsSynthesizedForTests = mForTests;
|
||||
if (aEvent.mClass != eCompositionEventClass) {
|
||||
return;
|
||||
}
|
||||
// Currently, we should set special native IME context when composition
|
||||
// events are dispatched from PuppetWidget since PuppetWidget may have not
|
||||
// known actual native IME context yet and it caches native IME context
|
||||
// when it dispatches every WidgetCompositionEvent.
|
||||
if (XRE_IsContentProcess()) {
|
||||
aEvent.AsCompositionEvent()->
|
||||
mNativeIMEContext.InitWithRawNativeIMEContext(mWidget);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -366,6 +366,7 @@ public:
|
||||
WidgetCompositionEvent(bool aIsTrusted, EventMessage aMessage,
|
||||
nsIWidget* aWidget)
|
||||
: WidgetGUIEvent(aIsTrusted, aMessage, aWidget, eCompositionEventClass)
|
||||
, mNativeIMEContext(aWidget)
|
||||
, mOriginalMessage(eVoidEvent)
|
||||
{
|
||||
// XXX compositionstart is cancelable in draft of DOM3 Events.
|
||||
@ -393,6 +394,10 @@ public:
|
||||
|
||||
RefPtr<TextRangeArray> mRanges;
|
||||
|
||||
// mNativeIMEContext stores the native IME context which causes the
|
||||
// composition event.
|
||||
widget::NativeIMEContext mNativeIMEContext;
|
||||
|
||||
// If the instance is a clone of another event, mOriginalMessage stores
|
||||
// the another event's mMessage.
|
||||
EventMessage mOriginalMessage;
|
||||
|
@ -1264,7 +1264,7 @@ nsWindow::GetNativeData(uint32_t aDataType)
|
||||
case NS_NATIVE_WIDGET:
|
||||
return (void *) this;
|
||||
|
||||
case NS_NATIVE_IME_CONTEXT:
|
||||
case NS_RAW_NATIVE_IME_CONTEXT:
|
||||
// We assume that there is only one context per process on Android
|
||||
return NS_ONLY_ONE_NATIVE_IME_CONTEXT;
|
||||
|
||||
|
@ -685,7 +685,7 @@ void* nsChildView::GetNativeData(uint32_t aDataType)
|
||||
retVal = 0;
|
||||
break;
|
||||
|
||||
case NS_NATIVE_IME_CONTEXT:
|
||||
case NS_RAW_NATIVE_IME_CONTEXT:
|
||||
retVal = [mView inputContext];
|
||||
// If input context isn't available on this widget, we should set |this|
|
||||
// instead of nullptr since if this returns nullptr, IMEStateManager
|
||||
|
@ -592,7 +592,7 @@ void* nsCocoaWindow::GetNativeData(uint32_t aDataType)
|
||||
// and it doesn't matter so just return nullptr.
|
||||
NS_ERROR("Requesting NS_NATIVE_GRAPHIC on a top-level window!");
|
||||
break;
|
||||
case NS_NATIVE_IME_CONTEXT: {
|
||||
case NS_RAW_NATIVE_IME_CONTEXT: {
|
||||
NSView* view = mWindow ? [mWindow contentView] : nil;
|
||||
if (view) {
|
||||
retVal = [view inputContext];
|
||||
|
@ -539,7 +539,7 @@ nsWindow::GetNativeData(uint32_t aDataType)
|
||||
return mScreen->GetNativeWindow();
|
||||
case NS_NATIVE_OPENGL_CONTEXT:
|
||||
return mScreen->GetGLContext().take();
|
||||
case NS_NATIVE_IME_CONTEXT:
|
||||
case NS_RAW_NATIVE_IME_CONTEXT:
|
||||
// There is only one IME context on Gonk.
|
||||
return NS_ONLY_ONE_NATIVE_IME_CONTEXT;
|
||||
}
|
||||
|
@ -1737,7 +1737,7 @@ nsWindow::GetNativeData(uint32_t aDataType)
|
||||
return (void *) GDK_WINDOW_XID(gdk_window_get_toplevel(mGdkWindow));
|
||||
case NS_NATIVE_PLUGIN_OBJECT_PTR:
|
||||
return (void *) mPluginNativeWindow;
|
||||
case NS_NATIVE_IME_CONTEXT:
|
||||
case NS_RAW_NATIVE_IME_CONTEXT:
|
||||
// If IME context isn't available on this widget, we should set |this|
|
||||
// instead of nullptr since if we return nullptr, IMEStateManager
|
||||
// cannot manage composition with TextComposition instance. Although,
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include "mozilla/layers/ChromeProcessController.h"
|
||||
#include "mozilla/layers/InputAPZContext.h"
|
||||
#include "mozilla/layers/APZCCallbackHelper.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/TabParent.h"
|
||||
#include "mozilla/Move.h"
|
||||
#include "mozilla/Services.h"
|
||||
@ -86,6 +87,7 @@ static nsRefPtrHashtable<nsVoidPtrHashKey, nsIWidget>* sPluginWidgetList;
|
||||
|
||||
nsIRollupListener* nsBaseWidget::gRollupListener = nullptr;
|
||||
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::layers;
|
||||
using namespace mozilla::ipc;
|
||||
using namespace mozilla::widget;
|
||||
@ -2079,9 +2081,49 @@ nsIWidget::SnapshotWidgetOnScreen()
|
||||
return dt->Snapshot();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsIWidget::NativeIMEContext)
|
||||
nsIWidget::GetNativeIMEContext()
|
||||
{
|
||||
return NativeIMEContext(this);
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
|
||||
void
|
||||
NativeIMEContext::Init(nsIWidget* aWidget)
|
||||
{
|
||||
if (!aWidget) {
|
||||
mRawNativeIMEContext = reinterpret_cast<uintptr_t>(nullptr);
|
||||
mOriginProcessID = static_cast<uint64_t>(-1);
|
||||
return;
|
||||
}
|
||||
if (!XRE_IsContentProcess()) {
|
||||
mRawNativeIMEContext = reinterpret_cast<uintptr_t>(
|
||||
aWidget->GetNativeData(NS_RAW_NATIVE_IME_CONTEXT));
|
||||
mOriginProcessID = 0;
|
||||
return;
|
||||
}
|
||||
// If this is created in a child process, aWidget is an instance of
|
||||
// PuppetWidget which doesn't support NS_RAW_NATIVE_IME_CONTEXT.
|
||||
// Instead of that PuppetWidget::GetNativeIMEContext() returns cached
|
||||
// native IME context of the parent process.
|
||||
*this = aWidget->GetNativeIMEContext();
|
||||
}
|
||||
|
||||
void
|
||||
NativeIMEContext::InitWithRawNativeIMEContext(void* aRawNativeIMEContext)
|
||||
{
|
||||
if (NS_WARN_IF(!aRawNativeIMEContext)) {
|
||||
mRawNativeIMEContext = reinterpret_cast<uintptr_t>(nullptr);
|
||||
mOriginProcessID = static_cast<uint64_t>(-1);
|
||||
return;
|
||||
}
|
||||
mRawNativeIMEContext = reinterpret_cast<uintptr_t>(aRawNativeIMEContext);
|
||||
mOriginProcessID =
|
||||
XRE_IsContentProcess() ? ContentChild::GetSingleton()->GetID() : 0;
|
||||
}
|
||||
|
||||
void
|
||||
IMENotification::TextChangeDataBase::MergeWith(
|
||||
const IMENotification::TextChangeDataBase& aOther)
|
||||
|
@ -544,6 +544,7 @@ struct ParamTraits<mozilla::WidgetCompositionEvent>
|
||||
{
|
||||
WriteParam(aMsg, static_cast<mozilla::WidgetGUIEvent>(aParam));
|
||||
WriteParam(aMsg, aParam.mData);
|
||||
WriteParam(aMsg, aParam.mNativeIMEContext);
|
||||
bool hasRanges = !!aParam.mRanges;
|
||||
WriteParam(aMsg, hasRanges);
|
||||
if (hasRanges) {
|
||||
@ -557,6 +558,7 @@ struct ParamTraits<mozilla::WidgetCompositionEvent>
|
||||
if (!ReadParam(aMsg, aIter,
|
||||
static_cast<mozilla::WidgetGUIEvent*>(aResult)) ||
|
||||
!ReadParam(aMsg, aIter, &aResult->mData) ||
|
||||
!ReadParam(aMsg, aIter, &aResult->mNativeIMEContext) ||
|
||||
!ReadParam(aMsg, aIter, &hasRanges)) {
|
||||
return false;
|
||||
}
|
||||
@ -681,6 +683,24 @@ struct ParamTraits<nsIMEUpdatePreference>
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct ParamTraits<mozilla::widget::NativeIMEContext>
|
||||
{
|
||||
typedef mozilla::widget::NativeIMEContext paramType;
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aParam)
|
||||
{
|
||||
WriteParam(aMsg, aParam.mRawNativeIMEContext);
|
||||
WriteParam(aMsg, aParam.mOriginProcessID);
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
||||
{
|
||||
return ReadParam(aMsg, aIter, &aResult->mRawNativeIMEContext) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mOriginProcessID);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct ParamTraits<mozilla::widget::IMENotification::Point>
|
||||
{
|
||||
|
@ -105,11 +105,13 @@ typedef void* nsNativeWidget;
|
||||
#define NS_NATIVE_OPENGL_CONTEXT 12
|
||||
// See RegisterPluginWindowForRemoteUpdates
|
||||
#define NS_NATIVE_PLUGIN_ID 13
|
||||
// This is available only with GetNativeData(). Anybody shouldn't access this
|
||||
// pointer as a valid pointer since the result may be special value like
|
||||
// NS_ONLY_ONE_NATIVE_IME_CONTEXT. So, the result is just an identifier of
|
||||
// distinguishing a text composition is caused by which native IME context.
|
||||
#define NS_NATIVE_IME_CONTEXT 14
|
||||
// This is available only with GetNativeData() in parent process. Anybody
|
||||
// shouldn't access this pointer as a valid pointer since the result may be
|
||||
// special value like NS_ONLY_ONE_NATIVE_IME_CONTEXT. So, the result is just
|
||||
// an identifier of distinguishing a text composition is caused by which native
|
||||
// IME context. Note that the result is only valid in the process. So,
|
||||
// XP code should use nsIWidget::GetNativeIMEContext() instead of using this.
|
||||
#define NS_RAW_NATIVE_IME_CONTEXT 14
|
||||
#ifdef XP_MACOSX
|
||||
#define NS_NATIVE_PLUGIN_PORT_QD 100
|
||||
#define NS_NATIVE_PLUGIN_PORT_CG 101
|
||||
@ -128,8 +130,8 @@ typedef void* nsNativeWidget;
|
||||
#endif
|
||||
|
||||
#define NS_IWIDGET_IID \
|
||||
{ 0xd953b7a1, 0x6981, 0x4ed7, \
|
||||
{ 0xbc, 0xf0, 0xed, 0x96, 0x70, 0xee, 0x23, 0x28 } }
|
||||
{ 0xaaa79c8d, 0xc99d, 0x4fe1, \
|
||||
{ 0xa5, 0x11, 0xd3, 0xeb, 0xb1, 0x61, 0x9e, 0x26 } }
|
||||
|
||||
/*
|
||||
* Window shadow styles
|
||||
@ -334,6 +336,7 @@ class nsIWidget : public nsISupports {
|
||||
typedef mozilla::widget::IMEState IMEState;
|
||||
typedef mozilla::widget::InputContext InputContext;
|
||||
typedef mozilla::widget::InputContextAction InputContextAction;
|
||||
typedef mozilla::widget::NativeIMEContext NativeIMEContext;
|
||||
typedef mozilla::widget::SizeConstraints SizeConstraints;
|
||||
typedef mozilla::widget::TextEventDispatcher TextEventDispatcher;
|
||||
typedef mozilla::CompositorVsyncDispatcher CompositorVsyncDispatcher;
|
||||
@ -1796,6 +1799,13 @@ public:
|
||||
*/
|
||||
NS_IMETHOD_(InputContext) GetInputContext() = 0;
|
||||
|
||||
/**
|
||||
* Get native IME context. This is different from GetNativeData() with
|
||||
* NS_RAW_NATIVE_IME_CONTEXT, the result is unique even if in a remote
|
||||
* process.
|
||||
*/
|
||||
NS_IMETHOD_(NativeIMEContext) GetNativeIMEContext();
|
||||
|
||||
/*
|
||||
* Given a WidgetKeyboardEvent, this method synthesizes a corresponding
|
||||
* native (OS-level) event for it. This method allows tests to simulate
|
||||
|
@ -664,7 +664,7 @@ nsWindow::GetNativeData(uint32_t aDataType)
|
||||
case NS_NATIVE_SHELLWIDGET: {
|
||||
break;
|
||||
}
|
||||
case NS_NATIVE_IME_CONTEXT:
|
||||
case NS_RAW_NATIVE_IME_CONTEXT:
|
||||
// Our qt widget looks like using only one context per process.
|
||||
// However, it's better to set the context's pointer.
|
||||
return qApp->inputMethod();
|
||||
|
@ -879,7 +879,7 @@ void* nsWindow::GetNativeData(uint32_t aDataType)
|
||||
// not implemented
|
||||
break;
|
||||
|
||||
case NS_NATIVE_IME_CONTEXT:
|
||||
case NS_RAW_NATIVE_IME_CONTEXT:
|
||||
retVal = NS_ONLY_ONE_NATIVE_IME_CONTEXT;
|
||||
break;
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ IMEHandler::Terminate()
|
||||
void*
|
||||
IMEHandler::GetNativeData(nsWindow* aWindow, uint32_t aDataType)
|
||||
{
|
||||
if (aDataType == NS_NATIVE_IME_CONTEXT) {
|
||||
if (aDataType == NS_RAW_NATIVE_IME_CONTEXT) {
|
||||
#ifdef NS_ENABLE_TSF
|
||||
if (IsTSFAvailable()) {
|
||||
return TSFTextStore::GetThreadManager();
|
||||
|
@ -3150,7 +3150,7 @@ void* nsWindow::GetNativeData(uint32_t aDataType)
|
||||
return (void*)::GetDC(mWnd);
|
||||
#endif
|
||||
|
||||
case NS_NATIVE_IME_CONTEXT:
|
||||
case NS_RAW_NATIVE_IME_CONTEXT:
|
||||
case NS_NATIVE_TSF_THREAD_MGR:
|
||||
case NS_NATIVE_TSF_CATEGORY_MGR:
|
||||
case NS_NATIVE_TSF_DISPLAY_ATTR_MGR:
|
||||
|
Loading…
Reference in New Issue
Block a user