mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 558976 part.1 Merge nsIWidget::ResetInputState(), nsIWidget::CancelComposition(), nsIWidget::OnIMEFocusChange() and nsIWidget::OnIMESelectionChange() r=roc, sr=roc
This commit is contained in:
parent
b9dc9d2a5e
commit
b34fa8551e
@ -598,11 +598,10 @@ nsIMEStateManager::NotifyIME(NotificationToIME aNotification,
|
||||
if (!composition || !composition->IsSynthesizedForTests()) {
|
||||
switch (aNotification) {
|
||||
case NOTIFY_IME_OF_CURSOR_POS_CHANGED:
|
||||
return aWidget->ResetInputState();
|
||||
return aWidget->NotifyIME(aNotification);
|
||||
case REQUEST_TO_COMMIT_COMPOSITION:
|
||||
return composition ? aWidget->ResetInputState() : NS_OK;
|
||||
case REQUEST_TO_CANCEL_COMPOSITION:
|
||||
return composition ? aWidget->CancelIMEComposition() : NS_OK;
|
||||
return composition ? aWidget->NotifyIME(aNotification) : NS_OK;
|
||||
default:
|
||||
MOZ_NOT_REACHED("Unsupported notification");
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
@ -745,9 +744,9 @@ nsTextStateManager::Init(nsIWidget* aWidget,
|
||||
false, false))->RunDOMEventWhenSafe();
|
||||
}
|
||||
|
||||
aWidget->OnIMEFocusChange(true);
|
||||
aWidget->NotifyIME(NOTIFY_IME_OF_FOCUS);
|
||||
|
||||
// OnIMEFocusChange(true) might cause recreating nsTextStateManager
|
||||
// NOTIFY_IME_OF_FOCUS might cause recreating nsTextStateManager
|
||||
// instance via nsIMEStateManager::UpdateIMEState(). So, this
|
||||
// instance might already have been destroyed, check it.
|
||||
if (!mRootContent) {
|
||||
@ -783,14 +782,14 @@ void
|
||||
nsTextStateManager::Destroy(void)
|
||||
{
|
||||
// If CreateTextStateManager failed, mRootContent will be null,
|
||||
// and we should not call OnIMEFocusChange(false)
|
||||
// and we should not call NotifyIME(NOTIFY_IME_OF_BLUR)
|
||||
if (mRootContent) {
|
||||
if (nsIMEStateManager::sIsTestingIME && mEditableNode) {
|
||||
nsIDocument* doc = mEditableNode->OwnerDoc();
|
||||
(new nsAsyncDOMEvent(doc, NS_LITERAL_STRING("MozIMEFocusOut"),
|
||||
false, false))->RunDOMEventWhenSafe();
|
||||
}
|
||||
mWidget->OnIMEFocusChange(false);
|
||||
mWidget->NotifyIME(NOTIFY_IME_OF_BLUR);
|
||||
}
|
||||
// Even if there are some pending notification, it'll never notify the widget.
|
||||
mWidget = nullptr;
|
||||
@ -837,7 +836,7 @@ public:
|
||||
|
||||
NS_IMETHOD Run() {
|
||||
if (mDispatcher->mWidget) {
|
||||
mDispatcher->mWidget->OnIMESelectionChange();
|
||||
mDispatcher->mWidget->NotifyIME(NOTIFY_IME_OF_SELECTION_CHANGE);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -722,7 +722,7 @@ TabParent::RecvNotifyIMEFocus(const bool& aFocus,
|
||||
mIMETabParent = aFocus ? this : nullptr;
|
||||
mIMESelectionAnchor = 0;
|
||||
mIMESelectionFocus = 0;
|
||||
widget->OnIMEFocusChange(aFocus);
|
||||
widget->NotifyIME(aFocus ? NOTIFY_IME_OF_FOCUS : NOTIFY_IME_OF_BLUR);
|
||||
|
||||
if (aFocus) {
|
||||
*aPreference = widget->GetIMEUpdatePreference();
|
||||
@ -757,7 +757,7 @@ TabParent::RecvNotifyIMESelection(const uint32_t& aSeqno,
|
||||
if (aSeqno == mIMESeqno) {
|
||||
mIMESelectionAnchor = aAnchor;
|
||||
mIMESelectionFocus = aFocus;
|
||||
widget->OnIMESelectionChange();
|
||||
widget->NotifyIME(NOTIFY_IME_OF_SELECTION_CHANGE);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -852,8 +852,9 @@ TabParent::SendCompositionEvent(nsCompositionEvent& event)
|
||||
}
|
||||
|
||||
/**
|
||||
* During ResetInputState or CancelComposition, widget usually sends a
|
||||
* NS_TEXT_TEXT event to finalize or clear the composition, respectively
|
||||
* During REQUEST_TO_COMMIT_COMPOSITION or REQUEST_TO_CANCEL_COMPOSITION,
|
||||
* widget usually sends a NS_TEXT_TEXT event to finalize or clear the
|
||||
* composition, respectively
|
||||
*
|
||||
* Because the event will not reach content in time, we intercept it
|
||||
* here and pass the text as the EndIMEComposition return value
|
||||
@ -933,11 +934,8 @@ TabParent::RecvEndIMEComposition(const bool& aCancel,
|
||||
|
||||
mIMECompositionEnding = true;
|
||||
|
||||
if (aCancel) {
|
||||
widget->CancelIMEComposition();
|
||||
} else {
|
||||
widget->ResetInputState();
|
||||
}
|
||||
widget->NotifyIME(aCancel ? REQUEST_TO_CANCEL_COMPOSITION :
|
||||
REQUEST_TO_COMMIT_COMPOSITION);
|
||||
|
||||
mIMECompositionEnding = false;
|
||||
*aComposition = mIMECompositionText;
|
||||
|
@ -92,8 +92,8 @@ typedef nsEventStatus (* EVENT_CALLBACK)(nsGUIEvent *event);
|
||||
#endif
|
||||
|
||||
#define NS_IWIDGET_IID \
|
||||
{ 0xDAEE334D, 0x9031, 0x4928, \
|
||||
{ 0x9D, 0xD7, 0x75, 0x2E, 0x8B, 0x6B, 0xF7, 0x0E } }
|
||||
{ 0xAD5FEF46, 0x7200, 0x417C, \
|
||||
{ 0xA9, 0x1C, 0xAB, 0x30, 0x1C, 0x86, 0xE4, 0x6F } }
|
||||
|
||||
/*
|
||||
* Window shadow styles
|
||||
@ -189,10 +189,11 @@ enum nsTopLevelWidgetZPlacement { // for PlaceBehind()
|
||||
*
|
||||
* If mWantUpdates is true, nsTextStateManager will observe text change and
|
||||
* selection change and call nsIWidget::OnIMETextChange() and
|
||||
* nsIWidget::OnIMESelectionChange(). The observing cost is very expensive.
|
||||
* nsIWidget::NotifyIME(NOTIFY_IME_OF_SELECTION_CHANGE). The observing cost is
|
||||
* very expensive.
|
||||
* If the IME implementation on a particular platform doesn't care about
|
||||
* OnIMETextChange and OnIMESelectionChange, they should set mWantUpdates to
|
||||
* false to avoid the cost.
|
||||
* OnIMETextChange and NotifyIME(NOTIFY_IME_OF_SELECTION_CHANGE), they should
|
||||
* set mWantUpdates to false to avoid the cost.
|
||||
*
|
||||
* If mWantHints is true, PuppetWidget will forward the content of text fields
|
||||
* to the chrome process to be cached. This way we return the cached content
|
||||
@ -419,6 +420,7 @@ class nsIWidget : public nsISupports {
|
||||
typedef mozilla::layers::LayerManager LayerManager;
|
||||
typedef mozilla::layers::LayersBackend LayersBackend;
|
||||
typedef mozilla::layers::PLayersChild PLayersChild;
|
||||
typedef mozilla::widget::NotificationToIME NotificationToIME;
|
||||
typedef mozilla::widget::IMEState IMEState;
|
||||
typedef mozilla::widget::InputContext InputContext;
|
||||
typedef mozilla::widget::InputContextAction InputContextAction;
|
||||
@ -1486,25 +1488,10 @@ class nsIWidget : public nsISupports {
|
||||
*/
|
||||
virtual nsresult ForceUpdateNativeMenuAt(const nsAString& indexString) = 0;
|
||||
|
||||
/*
|
||||
* Force Input Method Editor to commit the uncommitted input
|
||||
/**
|
||||
* Notify IME of the specified notification.
|
||||
*/
|
||||
NS_IMETHOD ResetInputState()=0;
|
||||
|
||||
/*
|
||||
* Following methods relates to IME 'Opened'/'Closed' state.
|
||||
* 'Opened' means the user can input any character. I.e., users can input Japanese
|
||||
* and other characters. The user can change the state to 'Closed'.
|
||||
* 'Closed' means the user can input ASCII characters only. This is the same as a
|
||||
* non-IME environment. The user can change the state to 'Opened'.
|
||||
* For more information is here.
|
||||
* http://bugzilla.mozilla.org/show_bug.cgi?id=16940#c48
|
||||
*/
|
||||
|
||||
/*
|
||||
* Destruct and don't commit the IME composition string.
|
||||
*/
|
||||
NS_IMETHOD CancelIMEComposition() = 0;
|
||||
NS_IMETHOD NotifyIME(NotificationToIME aNotification) = 0;
|
||||
|
||||
/*
|
||||
* Notifies the input context changes.
|
||||
@ -1533,14 +1520,6 @@ class nsIWidget : public nsISupports {
|
||||
*/
|
||||
NS_IMETHOD GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState) = 0;
|
||||
|
||||
/*
|
||||
* An editable node (i.e. input/textarea/design mode document)
|
||||
* is receiving or giving up focus
|
||||
* aFocus is true if node is receiving focus
|
||||
* aFocus is false if node is giving up focus (blur)
|
||||
*/
|
||||
NS_IMETHOD OnIMEFocusChange(bool aFocus) = 0;
|
||||
|
||||
/*
|
||||
* Text content of the focused node has changed
|
||||
* aStart is the starting offset of the change
|
||||
@ -1551,11 +1530,6 @@ class nsIWidget : public nsISupports {
|
||||
uint32_t aOldEnd,
|
||||
uint32_t aNewEnd) = 0;
|
||||
|
||||
/*
|
||||
* Selection has changed in the focused node
|
||||
*/
|
||||
NS_IMETHOD OnIMESelectionChange(void) = 0;
|
||||
|
||||
/*
|
||||
* Retrieves preference for IME updates
|
||||
*/
|
||||
|
@ -367,15 +367,23 @@ PuppetWidget::IMEEndComposition(bool aCancel)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PuppetWidget::ResetInputState()
|
||||
PuppetWidget::NotifyIME(NotificationToIME aNotification)
|
||||
{
|
||||
return IMEEndComposition(false);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PuppetWidget::CancelComposition()
|
||||
{
|
||||
return IMEEndComposition(true);
|
||||
switch (aNotification) {
|
||||
case NOTIFY_IME_OF_CURSOR_POS_CHANGED:
|
||||
case REQUEST_TO_COMMIT_COMPOSITION:
|
||||
return IMEEndComposition(false);
|
||||
case REQUEST_TO_CANCEL_COMPOSITION:
|
||||
return IMEEndComposition(true);
|
||||
case NOTIFY_IME_OF_FOCUS:
|
||||
return NotifyIMEOfFocusChange(true);
|
||||
case NOTIFY_IME_OF_BLUR:
|
||||
return NotifyIMEOfFocusChange(false);
|
||||
case NOTIFY_IME_OF_SELECTION_CHANGE:
|
||||
return NotifyIMEOfSelectionChange();
|
||||
default:
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(void)
|
||||
@ -418,8 +426,8 @@ PuppetWidget::GetInputContext()
|
||||
return context;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PuppetWidget::OnIMEFocusChange(bool aFocus)
|
||||
nsresult
|
||||
PuppetWidget::NotifyIMEOfFocusChange(bool aFocus)
|
||||
{
|
||||
#ifndef MOZ_CROSS_PROCESS_IME
|
||||
return NS_OK;
|
||||
@ -440,8 +448,8 @@ PuppetWidget::OnIMEFocusChange(bool aFocus)
|
||||
mTabChild->SendNotifyIMETextHint(queryEvent.mReply.mString);
|
||||
}
|
||||
} else {
|
||||
// ResetInputState might not have been called yet
|
||||
ResetInputState();
|
||||
// Might not have been committed composition yet
|
||||
IMEEndComposition(false);
|
||||
}
|
||||
|
||||
uint32_t chromeSeqno;
|
||||
@ -452,7 +460,7 @@ PuppetWidget::OnIMEFocusChange(bool aFocus)
|
||||
|
||||
if (aFocus) {
|
||||
if (mIMEPreference.mWantUpdates && mIMEPreference.mWantHints) {
|
||||
OnIMESelectionChange(); // Update selection
|
||||
NotifyIMEOfSelectionChange(); // Update selection
|
||||
}
|
||||
} else {
|
||||
mIMELastBlurSeqno = chromeSeqno;
|
||||
@ -493,8 +501,8 @@ PuppetWidget::OnIMETextChange(uint32_t aStart, uint32_t aEnd, uint32_t aNewEnd)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PuppetWidget::OnIMESelectionChange(void)
|
||||
nsresult
|
||||
PuppetWidget::NotifyIMEOfSelectionChange()
|
||||
{
|
||||
#ifndef MOZ_CROSS_PROCESS_IME
|
||||
return NS_OK;
|
||||
|
@ -149,15 +149,12 @@ public:
|
||||
bool* aAllowRetaining = nullptr);
|
||||
virtual gfxASurface* GetThebesSurface();
|
||||
|
||||
NS_IMETHOD ResetInputState();
|
||||
NS_IMETHOD NotifyIME(NotificationToIME aNotification) MOZ_OVERRIDE;
|
||||
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
|
||||
const InputContextAction& aAction);
|
||||
NS_IMETHOD_(InputContext) GetInputContext();
|
||||
NS_IMETHOD CancelComposition();
|
||||
NS_IMETHOD OnIMEFocusChange(bool aFocus);
|
||||
NS_IMETHOD OnIMETextChange(uint32_t aOffset, uint32_t aEnd,
|
||||
uint32_t aNewEnd);
|
||||
NS_IMETHOD OnIMESelectionChange(void);
|
||||
virtual nsIMEUpdatePreference GetIMEUpdatePreference();
|
||||
|
||||
NS_IMETHOD SetCursor(nsCursor aCursor);
|
||||
@ -183,6 +180,8 @@ private:
|
||||
void SetChild(PuppetWidget* aChild);
|
||||
|
||||
nsresult IMEEndComposition(bool aCancel);
|
||||
nsresult NotifyIMEOfFocusChange(bool aFocus);
|
||||
nsresult NotifyIMEOfSelectionChange();
|
||||
|
||||
class PaintTask : public nsRunnable {
|
||||
public:
|
||||
|
@ -140,15 +140,12 @@ public:
|
||||
NS_IMETHOD BeginMoveDrag(nsMouseEvent* aEvent);
|
||||
virtual nsresult ActivateNativeMenuItemAt(const nsAString& indexString) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
virtual nsresult ForceUpdateNativeMenuAt(const nsAString& indexString) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD ResetInputState() { return NS_OK; }
|
||||
NS_IMETHOD CancelIMEComposition() { return NS_OK; }
|
||||
NS_IMETHOD NotifyIME(NotificationToIME aNotification) MOZ_OVERRIDE { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD SetLayersAcceleration(bool aEnabled);
|
||||
virtual bool GetLayersAcceleration() { return mUseLayersAcceleration; }
|
||||
virtual bool ComputeShouldAccelerate(bool aDefault);
|
||||
NS_IMETHOD GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD OnIMEFocusChange(bool aFocus) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD OnIMETextChange(uint32_t aStart, uint32_t aOldEnd, uint32_t aNewEnd) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD OnIMESelectionChange(void) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
virtual nsIMEUpdatePreference GetIMEUpdatePreference() { return nsIMEUpdatePreference(false, false); }
|
||||
NS_IMETHOD OnDefaultButtonLoaded(const nsIntRect &aButtonRect) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD OverrideSystemMouseScrollSpeed(int32_t aOriginalDelta, bool aIsHorizontal, int32_t &aOverriddenDelta);
|
||||
|
Loading…
Reference in New Issue
Block a user