2015-01-28 06:27:30 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_textcompositionsynthesizer_h_
|
|
|
|
#define mozilla_textcompositionsynthesizer_h_
|
|
|
|
|
2016-04-19 20:51:25 +00:00
|
|
|
#include "mozilla/RefPtr.h"
|
2015-01-28 06:27:30 +00:00
|
|
|
#include "nsString.h"
|
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "mozilla/EventForwards.h"
|
2015-01-28 06:27:32 +00:00
|
|
|
#include "mozilla/TextEventDispatcherListener.h"
|
2015-01-28 06:27:30 +00:00
|
|
|
#include "mozilla/TextRange.h"
|
Bug 1217700 part.1 nsIWidget should return reference to IMENotificationRequests r=m_kato
IMEContentObserver may need to change notifications to send when TextInputProcessor begins input transaction. In current design, IMEContentObserver needs to retrieve IMENotificationRequests at every change. However, if nsIWidget returns a reference to its IMENotificationRequests, IMEContentObserver can call it only once.
For that purpose, this patch changes nsIWidget::GetIMENotificationRequests() to nsIWidget::IMENotificationRequestsRef() and make it return |const IMENotificationRequests&|. However, if the lifetime of the instance of IMENotificationRequest is shorter than the widget instance's, it's dangerous. Therefore, it always returns TextEventDispatcher::mIMENotificationRequests. TextEventDispatcher's lifetime is longer than the widget. Therefore, this guarantees the lifetime.
On the other hand, widget needs to update TextEventDispatcher::mIMENotificationRequests before calls of nsIWidget::IMENotificationRequestsRef(). Therefore, this patch makes TextEventDispatcher update proper IMENotificationRequests when it gets focus or starts new input transaction and clear mIMENotificationRequests when it loses focus.
Note that TextEventDispatcher gets proper requests both from native text event dispatcher listener (typically, implemented by native IME handler class) and TextInputProcessor when TextInputProcessor has input transaction because even if TextInputProcessor overrides native IME, native IME still needs to know the content changes since they may get new input transaction after that.
However, there may not be native IME handler in content process. If it runs in Android, PuppetWidget may have native IME handler because widget directly handles IME in e10s mode for Android. Otherwise, native IME handler is in its parent process. So, if TextInputHandler has input transaction in content process, PuppetWidget needs to behave as native event handler. Therefore, this patch makes PuppetWidget inherit TextEventDispatcherListener and implements PuppetWidget::IMENotificationRequestsRef().
MozReview-Commit-ID: 2SW3moONTOX
--HG--
extra : rebase_source : d2634ada6c33dbf7a966fadb68608411ee24bfab
2017-04-14 16:35:58 +00:00
|
|
|
#include "mozilla/widget/IMEData.h"
|
2015-01-28 06:27:30 +00:00
|
|
|
|
|
|
|
class nsIWidget;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace widget {
|
|
|
|
|
2017-07-25 14:27:31 +00:00
|
|
|
class PuppetWidget;
|
|
|
|
|
2015-01-28 06:27:30 +00:00
|
|
|
/**
|
|
|
|
* TextEventDispatcher is a helper class for dispatching widget events defined
|
|
|
|
* in TextEvents.h. Currently, this is a helper for dispatching
|
2015-02-19 06:50:18 +00:00
|
|
|
* WidgetCompositionEvent and WidgetKeyboardEvent. This manages the behavior
|
|
|
|
* of them for conforming to DOM Level 3 Events.
|
2015-01-28 06:27:30 +00:00
|
|
|
* An instance of this class is created by nsIWidget instance and owned by it.
|
|
|
|
* This is typically created only by the top level widgets because only they
|
|
|
|
* handle IME.
|
|
|
|
*/
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class TextEventDispatcher final
|
2015-01-28 06:27:30 +00:00
|
|
|
{
|
|
|
|
~TextEventDispatcher()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(TextEventDispatcher)
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit TextEventDispatcher(nsIWidget* aWidget);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes the instance for IME or automated test. Either IME or tests
|
2015-01-28 06:27:32 +00:00
|
|
|
* need to call one of them before starting composition. If they return
|
|
|
|
* NS_ERROR_ALREADY_INITIALIZED, it means that the listener already listens
|
|
|
|
* notifications from TextEventDispatcher for same purpose (for IME or tests).
|
|
|
|
* If this returns another error, the caller shouldn't keep starting
|
|
|
|
* composition.
|
|
|
|
*
|
|
|
|
* @param aListener Specify the listener to listen notifications and
|
|
|
|
* requests. This must not be null.
|
|
|
|
* NOTE: aListener is stored as weak reference in
|
|
|
|
* TextEventDispatcher. See mListener
|
|
|
|
* definition below.
|
2015-01-28 06:27:30 +00:00
|
|
|
*/
|
2015-02-10 08:09:29 +00:00
|
|
|
nsresult BeginInputTransaction(TextEventDispatcherListener* aListener);
|
2016-03-16 04:47:48 +00:00
|
|
|
nsresult BeginTestInputTransaction(TextEventDispatcherListener* aListener,
|
|
|
|
bool aIsAPZAware);
|
2016-03-16 04:47:47 +00:00
|
|
|
nsresult BeginNativeInputTransaction();
|
2015-01-28 06:27:30 +00:00
|
|
|
|
2017-07-25 14:27:31 +00:00
|
|
|
/**
|
|
|
|
* BeginInputTransactionFor() should be used when aPuppetWidget dispatches
|
|
|
|
* a composition or keyboard event coming from its parent process.
|
|
|
|
*/
|
|
|
|
nsresult BeginInputTransactionFor(const WidgetGUIEvent* aEvent,
|
|
|
|
PuppetWidget* aPuppetWidget);
|
|
|
|
|
2015-06-11 03:53:42 +00:00
|
|
|
/**
|
|
|
|
* EndInputTransaction() should be called when the listener stops using
|
|
|
|
* the TextEventDispatcher.
|
|
|
|
*
|
|
|
|
* @param aListener The listener using the TextEventDispatcher instance.
|
|
|
|
*/
|
|
|
|
void EndInputTransaction(TextEventDispatcherListener* aListener);
|
|
|
|
|
2015-01-28 06:27:30 +00:00
|
|
|
/**
|
|
|
|
* OnDestroyWidget() is called when mWidget is being destroyed.
|
|
|
|
*/
|
|
|
|
void OnDestroyWidget();
|
|
|
|
|
2016-03-16 04:47:47 +00:00
|
|
|
nsIWidget* GetWidget() const { return mWidget; }
|
|
|
|
|
Bug 1217700 part.1 nsIWidget should return reference to IMENotificationRequests r=m_kato
IMEContentObserver may need to change notifications to send when TextInputProcessor begins input transaction. In current design, IMEContentObserver needs to retrieve IMENotificationRequests at every change. However, if nsIWidget returns a reference to its IMENotificationRequests, IMEContentObserver can call it only once.
For that purpose, this patch changes nsIWidget::GetIMENotificationRequests() to nsIWidget::IMENotificationRequestsRef() and make it return |const IMENotificationRequests&|. However, if the lifetime of the instance of IMENotificationRequest is shorter than the widget instance's, it's dangerous. Therefore, it always returns TextEventDispatcher::mIMENotificationRequests. TextEventDispatcher's lifetime is longer than the widget. Therefore, this guarantees the lifetime.
On the other hand, widget needs to update TextEventDispatcher::mIMENotificationRequests before calls of nsIWidget::IMENotificationRequestsRef(). Therefore, this patch makes TextEventDispatcher update proper IMENotificationRequests when it gets focus or starts new input transaction and clear mIMENotificationRequests when it loses focus.
Note that TextEventDispatcher gets proper requests both from native text event dispatcher listener (typically, implemented by native IME handler class) and TextInputProcessor when TextInputProcessor has input transaction because even if TextInputProcessor overrides native IME, native IME still needs to know the content changes since they may get new input transaction after that.
However, there may not be native IME handler in content process. If it runs in Android, PuppetWidget may have native IME handler because widget directly handles IME in e10s mode for Android. Otherwise, native IME handler is in its parent process. So, if TextInputHandler has input transaction in content process, PuppetWidget needs to behave as native event handler. Therefore, this patch makes PuppetWidget inherit TextEventDispatcherListener and implements PuppetWidget::IMENotificationRequestsRef().
MozReview-Commit-ID: 2SW3moONTOX
--HG--
extra : rebase_source : d2634ada6c33dbf7a966fadb68608411ee24bfab
2017-04-14 16:35:58 +00:00
|
|
|
const IMENotificationRequests& IMENotificationRequestsRef() const
|
|
|
|
{
|
|
|
|
return mIMENotificationRequests;
|
|
|
|
}
|
|
|
|
|
2015-01-28 06:27:31 +00:00
|
|
|
/**
|
|
|
|
* GetState() returns current state of this class.
|
|
|
|
*
|
|
|
|
* @return NS_OK: Fine to compose text.
|
2015-02-10 08:09:29 +00:00
|
|
|
* NS_ERROR_NOT_INITIALIZED: BeginInputTransaction() or
|
|
|
|
* BeginInputTransactionForTests()
|
|
|
|
* should be called.
|
2015-01-28 06:27:31 +00:00
|
|
|
* NS_ERROR_NOT_AVAILABLE: The widget isn't available for
|
|
|
|
* composition.
|
|
|
|
*/
|
|
|
|
nsresult GetState() const;
|
|
|
|
|
2015-01-28 06:27:31 +00:00
|
|
|
/**
|
|
|
|
* IsComposing() returns true after calling StartComposition() and before
|
|
|
|
* calling CommitComposition().
|
|
|
|
*/
|
|
|
|
bool IsComposing() const { return mIsComposing; }
|
|
|
|
|
2016-06-29 08:39:59 +00:00
|
|
|
/**
|
|
|
|
* IsInNativeInputTransaction() returns true if native IME handler began a
|
|
|
|
* transaction and it's not finished yet.
|
|
|
|
*/
|
|
|
|
bool IsInNativeInputTransaction() const
|
|
|
|
{
|
|
|
|
return mInputTransactionType == eNativeInputTransaction;
|
|
|
|
}
|
|
|
|
|
2015-02-19 06:50:20 +00:00
|
|
|
/**
|
|
|
|
* IsDispatchingEvent() returns true while this instance dispatching an event.
|
|
|
|
*/
|
|
|
|
bool IsDispatchingEvent() const { return mDispatchingEvent > 0; }
|
|
|
|
|
2016-03-16 04:47:47 +00:00
|
|
|
/**
|
|
|
|
* GetPseudoIMEContext() returns pseudo native IME context if there is an
|
|
|
|
* input transaction whose type is not for native event handler.
|
|
|
|
* Otherwise, returns nullptr.
|
|
|
|
*/
|
|
|
|
void* GetPseudoIMEContext() const
|
|
|
|
{
|
|
|
|
if (mInputTransactionType == eNoInputTransaction ||
|
|
|
|
mInputTransactionType == eNativeInputTransaction) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return const_cast<TextEventDispatcher*>(this);
|
|
|
|
}
|
|
|
|
|
2015-01-28 06:27:31 +00:00
|
|
|
/**
|
|
|
|
* StartComposition() starts composition explicitly.
|
2016-03-16 04:47:48 +00:00
|
|
|
*
|
|
|
|
* @param aEventTime If this is not nullptr, WidgetCompositionEvent will
|
|
|
|
* be initialized with this. Otherwise, initialized
|
|
|
|
* with the time at initializing.
|
2015-01-28 06:27:31 +00:00
|
|
|
*/
|
2016-03-16 04:47:48 +00:00
|
|
|
nsresult StartComposition(nsEventStatus& aStatus,
|
|
|
|
const WidgetEventTime* aEventTime = nullptr);
|
2015-01-28 06:27:31 +00:00
|
|
|
|
2015-01-28 06:27:31 +00:00
|
|
|
/**
|
|
|
|
* CommitComposition() commits composition.
|
|
|
|
*
|
|
|
|
* @param aCommitString If this is null, commits with the last composition
|
|
|
|
* string. Otherwise, commits the composition with
|
|
|
|
* this value.
|
2016-03-16 04:47:48 +00:00
|
|
|
* @param aEventTime If this is not nullptr, WidgetCompositionEvent will
|
|
|
|
* be initialized with this. Otherwise, initialized
|
|
|
|
* with the time at initializing.
|
2015-01-28 06:27:31 +00:00
|
|
|
*/
|
|
|
|
nsresult CommitComposition(nsEventStatus& aStatus,
|
2016-03-16 04:47:48 +00:00
|
|
|
const nsAString* aCommitString = nullptr,
|
|
|
|
const WidgetEventTime* aEventTime = nullptr);
|
2015-01-28 06:27:31 +00:00
|
|
|
|
2015-01-28 06:27:30 +00:00
|
|
|
/**
|
|
|
|
* SetPendingCompositionString() sets new composition string which will be
|
2015-09-11 12:21:27 +00:00
|
|
|
* dispatched with eCompositionChange event by calling Flush().
|
2015-01-28 06:27:30 +00:00
|
|
|
*
|
|
|
|
* @param aString New composition string.
|
|
|
|
*/
|
|
|
|
nsresult SetPendingCompositionString(const nsAString& aString)
|
|
|
|
{
|
|
|
|
return mPendingComposition.SetString(aString);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* AppendClauseToPendingComposition() appends a clause information to
|
|
|
|
* the pending composition string.
|
|
|
|
*
|
|
|
|
* @param aLength Length of the clause.
|
2016-06-03 09:48:37 +00:00
|
|
|
* @param aTextRangeType One of TextRangeType::eRawClause,
|
2016-06-03 09:57:21 +00:00
|
|
|
* TextRangeType::eSelectedRawClause,
|
2016-06-03 10:05:32 +00:00
|
|
|
* TextRangeType::eConvertedClause or
|
2016-06-03 10:15:21 +00:00
|
|
|
* TextRangeType::eSelectedClause.
|
2015-01-28 06:27:30 +00:00
|
|
|
*/
|
|
|
|
nsresult AppendClauseToPendingComposition(uint32_t aLength,
|
2016-06-04 00:49:21 +00:00
|
|
|
TextRangeType aTextRangeType)
|
2015-01-28 06:27:30 +00:00
|
|
|
{
|
2016-06-04 00:49:21 +00:00
|
|
|
return mPendingComposition.AppendClause(aLength, aTextRangeType);
|
2015-01-28 06:27:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SetCaretInPendingComposition() sets caret position in the pending
|
|
|
|
* composition string and its length. This is optional. If IME doesn't
|
|
|
|
* want to show caret, it shouldn't need to call this.
|
|
|
|
*
|
|
|
|
* @param aOffset Offset of the caret in the pending composition
|
|
|
|
* string. This should not be larger than the length
|
|
|
|
* of the pending composition string.
|
|
|
|
* @param aLength Caret width. If this is 0, caret will be collapsed.
|
|
|
|
* Note that Gecko doesn't supported wide caret yet,
|
|
|
|
* therefore, this is ignored for now.
|
|
|
|
*/
|
|
|
|
nsresult SetCaretInPendingComposition(uint32_t aOffset,
|
|
|
|
uint32_t aLength)
|
|
|
|
{
|
|
|
|
return mPendingComposition.SetCaret(aOffset, aLength);
|
|
|
|
}
|
|
|
|
|
2016-03-16 04:47:48 +00:00
|
|
|
/**
|
|
|
|
* SetPendingComposition() is useful if native IME handler already creates
|
|
|
|
* array of clauses and/or caret information.
|
|
|
|
*
|
|
|
|
* @param aString Composition string. This may include native line
|
|
|
|
* breakers since they will be replaced with XP line
|
|
|
|
* breakers automatically.
|
|
|
|
* @param aRanges This should include the ranges of clauses and/or
|
|
|
|
* a range of caret. Note that this method allows
|
|
|
|
* some ranges overlap each other and the range order
|
|
|
|
* is not from start to end.
|
|
|
|
*/
|
|
|
|
nsresult SetPendingComposition(const nsAString& aString,
|
|
|
|
const TextRangeArray* aRanges)
|
|
|
|
{
|
|
|
|
return mPendingComposition.Set(aString, aRanges);
|
|
|
|
}
|
|
|
|
|
2015-01-28 06:27:30 +00:00
|
|
|
/**
|
|
|
|
* FlushPendingComposition() sends the pending composition string
|
|
|
|
* to the widget of the store DOM window. Before calling this, IME needs to
|
|
|
|
* set pending composition string with SetPendingCompositionString(),
|
|
|
|
* AppendClauseToPendingComposition() and/or
|
|
|
|
* SetCaretInPendingComposition().
|
2016-03-16 04:47:48 +00:00
|
|
|
*
|
|
|
|
* @param aEventTime If this is not nullptr, WidgetCompositionEvent will
|
|
|
|
* be initialized with this. Otherwise, initialized
|
|
|
|
* with the time at initializing.
|
2015-01-28 06:27:30 +00:00
|
|
|
*/
|
2016-03-16 04:47:48 +00:00
|
|
|
nsresult FlushPendingComposition(nsEventStatus& aStatus,
|
|
|
|
const WidgetEventTime* aEventTime = nullptr)
|
2015-01-28 06:27:30 +00:00
|
|
|
{
|
2016-03-16 04:47:48 +00:00
|
|
|
return mPendingComposition.Flush(this, aStatus, aEventTime);
|
2015-01-28 06:27:30 +00:00
|
|
|
}
|
|
|
|
|
2015-02-19 06:50:20 +00:00
|
|
|
/**
|
|
|
|
* ClearPendingComposition() makes this instance forget pending composition.
|
|
|
|
*/
|
|
|
|
void ClearPendingComposition()
|
|
|
|
{
|
|
|
|
mPendingComposition.Clear();
|
|
|
|
}
|
|
|
|
|
2016-03-16 04:47:48 +00:00
|
|
|
/**
|
|
|
|
* GetPendingCompositionClauses() returns text ranges which was appended by
|
|
|
|
* AppendClauseToPendingComposition() or SetPendingComposition().
|
|
|
|
*/
|
|
|
|
const TextRangeArray* GetPendingCompositionClauses() const
|
|
|
|
{
|
|
|
|
return mPendingComposition.GetClauses();
|
|
|
|
}
|
|
|
|
|
2015-01-28 06:27:31 +00:00
|
|
|
/**
|
|
|
|
* @see nsIWidget::NotifyIME()
|
|
|
|
*/
|
|
|
|
nsresult NotifyIME(const IMENotification& aIMENotification);
|
|
|
|
|
2015-02-19 06:50:18 +00:00
|
|
|
/**
|
|
|
|
* DispatchKeyboardEvent() maybe dispatches aKeyboardEvent.
|
|
|
|
*
|
2015-08-28 23:58:27 +00:00
|
|
|
* @param aMessage Must be eKeyDown or eKeyUp.
|
2015-02-19 06:50:18 +00:00
|
|
|
* Use MaybeDispatchKeypressEvents() for dispatching
|
2015-08-28 23:58:27 +00:00
|
|
|
* eKeyPress.
|
2015-02-19 06:50:18 +00:00
|
|
|
* @param aKeyboardEvent A keyboard event.
|
|
|
|
* @param aStatus If dispatching event should be marked as consumed,
|
|
|
|
* set nsEventStatus_eConsumeNoDefault. Otherwise,
|
|
|
|
* set nsEventStatus_eIgnore. After dispatching
|
|
|
|
* a event and it's consumed this returns
|
|
|
|
* nsEventStatus_eConsumeNoDefault.
|
2016-03-16 04:47:48 +00:00
|
|
|
* @param aData Calling this method may cause calling
|
|
|
|
* WillDispatchKeyboardEvent() of the listener.
|
|
|
|
* aData will be set to its argument.
|
2015-02-19 06:50:18 +00:00
|
|
|
* @return true if an event is dispatched. Otherwise, false.
|
|
|
|
*/
|
2015-08-26 12:56:59 +00:00
|
|
|
bool DispatchKeyboardEvent(EventMessage aMessage,
|
2015-02-19 06:50:18 +00:00
|
|
|
const WidgetKeyboardEvent& aKeyboardEvent,
|
2016-03-16 04:47:48 +00:00
|
|
|
nsEventStatus& aStatus,
|
|
|
|
void* aData = nullptr);
|
2015-02-19 06:50:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* MaybeDispatchKeypressEvents() maybe dispatches a keypress event which is
|
|
|
|
* generated from aKeydownEvent.
|
|
|
|
*
|
|
|
|
* @param aKeyboardEvent A keyboard event.
|
|
|
|
* @param aStatus Sets the result when the caller dispatches
|
|
|
|
* aKeyboardEvent. Note that if the value is
|
|
|
|
* nsEventStatus_eConsumeNoDefault, this does NOT
|
|
|
|
* dispatch keypress events.
|
|
|
|
* When this method dispatches one or more keypress
|
|
|
|
* events and one of them is consumed, this returns
|
|
|
|
* nsEventStatus_eConsumeNoDefault.
|
2016-03-16 04:47:48 +00:00
|
|
|
* @param aData Calling this method may cause calling
|
|
|
|
* WillDispatchKeyboardEvent() of the listener.
|
|
|
|
* aData will be set to its argument.
|
Bug 1303273 part.3 Dispatch eKeyPress events without NativeKey::HandleCharMessage() when it handles WM_(SYS)KEYDOWN message and there are following WM_(SYS)CHAR messages which includes non-control character r=m_kato
This patch creates NativeKey::DispatchKeyPressEventsWithRetrievedCharMessages() for dispatching eKeyPress event with mCommittedCharsAndModifiers when it stores following printable WM_(SYS)CHAR messages.
Using loop for dispatching eKeyPress event for every WM_(SYS)CHAR message is wrong because WidgetKeyboardEvent::mKeyValue is initialized with mCommittedCharsAndModifiers and it causes TextEventDispatcher dispatching multiple eKeyPress events at every call of MaybeDispatchKeypressEvents(). Therefore, if mKeyValue is "^^", eKeyPress event is dispatched 4 times --for the first message, eKeyPress events are fired for each "^" and for the second message, eKeyPress events are fired again for each "^"--. Therefore, when it handles WM_(SYS)KEYDOWN and it causes inputting one or more printable characters, it's the easiest way not to use HandleCharMessage().
The new method calls TextEventDispatcher::MaybeDispatchKeypressEvents() only once and it requests to call the callback method with new argument of MaybeDispatchKeypressEvents() when it needs to dispatch 2 or more eKeyPress events. Then, NativeKey::WillDispatchKeyboardEvent() can set each eKeyPress event to raw information of the message and proper modifier state.
With this change, we can dispatch multiple eKeyPress events with retrieved WM_(SYS)CHAR message information rather than retrieved information from active keyboard layout. Therefore, NeedsToHandleWithoutFollowingCharMessages() doesn't return true even when mCommittedCharsAndModifiers stores two or more characters.
FYI: there is a bug in test_keycodes.xul. That is, Alt+'A' of Greek keyboard layout should cause WM_SYSCHAR with a corresponding Greek character but ASCII characters are specified. Therefore, this patch includes the fix of these bugs
MozReview-Commit-ID: JVm7ZJVug0O
--HG--
extra : rebase_source : 414ecbe2c01c53f294d1346414b1a289aa0abfe8
2016-10-06 11:52:03 +00:00
|
|
|
* @param aNeedsCallback Set true when caller needs to initialize each
|
|
|
|
* eKeyPress event immediately before dispatch.
|
|
|
|
* Then, WillDispatchKeyboardEvent() is always called.
|
2015-02-19 06:50:18 +00:00
|
|
|
* @return true if one or more events are dispatched.
|
|
|
|
* Otherwise, false.
|
|
|
|
*/
|
|
|
|
bool MaybeDispatchKeypressEvents(const WidgetKeyboardEvent& aKeyboardEvent,
|
2016-03-16 04:47:48 +00:00
|
|
|
nsEventStatus& aStatus,
|
Bug 1303273 part.3 Dispatch eKeyPress events without NativeKey::HandleCharMessage() when it handles WM_(SYS)KEYDOWN message and there are following WM_(SYS)CHAR messages which includes non-control character r=m_kato
This patch creates NativeKey::DispatchKeyPressEventsWithRetrievedCharMessages() for dispatching eKeyPress event with mCommittedCharsAndModifiers when it stores following printable WM_(SYS)CHAR messages.
Using loop for dispatching eKeyPress event for every WM_(SYS)CHAR message is wrong because WidgetKeyboardEvent::mKeyValue is initialized with mCommittedCharsAndModifiers and it causes TextEventDispatcher dispatching multiple eKeyPress events at every call of MaybeDispatchKeypressEvents(). Therefore, if mKeyValue is "^^", eKeyPress event is dispatched 4 times --for the first message, eKeyPress events are fired for each "^" and for the second message, eKeyPress events are fired again for each "^"--. Therefore, when it handles WM_(SYS)KEYDOWN and it causes inputting one or more printable characters, it's the easiest way not to use HandleCharMessage().
The new method calls TextEventDispatcher::MaybeDispatchKeypressEvents() only once and it requests to call the callback method with new argument of MaybeDispatchKeypressEvents() when it needs to dispatch 2 or more eKeyPress events. Then, NativeKey::WillDispatchKeyboardEvent() can set each eKeyPress event to raw information of the message and proper modifier state.
With this change, we can dispatch multiple eKeyPress events with retrieved WM_(SYS)CHAR message information rather than retrieved information from active keyboard layout. Therefore, NeedsToHandleWithoutFollowingCharMessages() doesn't return true even when mCommittedCharsAndModifiers stores two or more characters.
FYI: there is a bug in test_keycodes.xul. That is, Alt+'A' of Greek keyboard layout should cause WM_SYSCHAR with a corresponding Greek character but ASCII characters are specified. Therefore, this patch includes the fix of these bugs
MozReview-Commit-ID: JVm7ZJVug0O
--HG--
extra : rebase_source : 414ecbe2c01c53f294d1346414b1a289aa0abfe8
2016-10-06 11:52:03 +00:00
|
|
|
void* aData = nullptr,
|
|
|
|
bool aNeedsCallback = false);
|
2015-02-19 06:50:18 +00:00
|
|
|
|
2015-01-28 06:27:30 +00:00
|
|
|
private:
|
|
|
|
// mWidget is owner of the instance. When this is created, this is set.
|
|
|
|
// And when mWidget is released, this is cleared by OnDestroyWidget().
|
|
|
|
// Note that mWidget may be destroyed already (i.e., mWidget->Destroyed() may
|
|
|
|
// return true).
|
|
|
|
nsIWidget* mWidget;
|
2015-01-28 06:27:32 +00:00
|
|
|
// mListener is a weak reference to TextEventDispatcherListener. That might
|
|
|
|
// be referred by JS. Therefore, the listener might be difficult to release
|
|
|
|
// itself if this is a strong reference. Additionally, it's difficult to
|
|
|
|
// check if a method to uninstall the listener is called by valid instance.
|
|
|
|
// So, using weak reference is the best way in this case.
|
|
|
|
nsWeakPtr mListener;
|
Bug 1217700 part.1 nsIWidget should return reference to IMENotificationRequests r=m_kato
IMEContentObserver may need to change notifications to send when TextInputProcessor begins input transaction. In current design, IMEContentObserver needs to retrieve IMENotificationRequests at every change. However, if nsIWidget returns a reference to its IMENotificationRequests, IMEContentObserver can call it only once.
For that purpose, this patch changes nsIWidget::GetIMENotificationRequests() to nsIWidget::IMENotificationRequestsRef() and make it return |const IMENotificationRequests&|. However, if the lifetime of the instance of IMENotificationRequest is shorter than the widget instance's, it's dangerous. Therefore, it always returns TextEventDispatcher::mIMENotificationRequests. TextEventDispatcher's lifetime is longer than the widget. Therefore, this guarantees the lifetime.
On the other hand, widget needs to update TextEventDispatcher::mIMENotificationRequests before calls of nsIWidget::IMENotificationRequestsRef(). Therefore, this patch makes TextEventDispatcher update proper IMENotificationRequests when it gets focus or starts new input transaction and clear mIMENotificationRequests when it loses focus.
Note that TextEventDispatcher gets proper requests both from native text event dispatcher listener (typically, implemented by native IME handler class) and TextInputProcessor when TextInputProcessor has input transaction because even if TextInputProcessor overrides native IME, native IME still needs to know the content changes since they may get new input transaction after that.
However, there may not be native IME handler in content process. If it runs in Android, PuppetWidget may have native IME handler because widget directly handles IME in e10s mode for Android. Otherwise, native IME handler is in its parent process. So, if TextInputHandler has input transaction in content process, PuppetWidget needs to behave as native event handler. Therefore, this patch makes PuppetWidget inherit TextEventDispatcherListener and implements PuppetWidget::IMENotificationRequestsRef().
MozReview-Commit-ID: 2SW3moONTOX
--HG--
extra : rebase_source : d2634ada6c33dbf7a966fadb68608411ee24bfab
2017-04-14 16:35:58 +00:00
|
|
|
// mIMENotificationRequests should store current IME's notification requests.
|
|
|
|
// So, this may be invalid when IME doesn't have focus.
|
|
|
|
IMENotificationRequests mIMENotificationRequests;
|
2015-01-28 06:27:30 +00:00
|
|
|
|
|
|
|
// mPendingComposition stores new composition string temporarily.
|
2015-09-11 12:21:27 +00:00
|
|
|
// These values will be used for dispatching eCompositionChange event
|
2015-01-28 06:27:30 +00:00
|
|
|
// in Flush(). When Flush() is called, the members will be cleared
|
|
|
|
// automatically.
|
|
|
|
class PendingComposition
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PendingComposition();
|
|
|
|
nsresult SetString(const nsAString& aString);
|
2016-06-04 00:49:21 +00:00
|
|
|
nsresult AppendClause(uint32_t aLength, TextRangeType aTextRangeType);
|
2015-01-28 06:27:30 +00:00
|
|
|
nsresult SetCaret(uint32_t aOffset, uint32_t aLength);
|
2016-03-16 04:47:48 +00:00
|
|
|
nsresult Set(const nsAString& aString, const TextRangeArray* aRanges);
|
2016-03-16 04:47:48 +00:00
|
|
|
nsresult Flush(TextEventDispatcher* aDispatcher,
|
|
|
|
nsEventStatus& aStatus,
|
|
|
|
const WidgetEventTime* aEventTime);
|
2016-03-16 04:47:48 +00:00
|
|
|
const TextRangeArray* GetClauses() const { return mClauses; }
|
2015-01-28 06:27:30 +00:00
|
|
|
void Clear();
|
|
|
|
|
|
|
|
private:
|
2015-11-19 09:31:56 +00:00
|
|
|
nsString mString;
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<TextRangeArray> mClauses;
|
2015-01-28 06:27:30 +00:00
|
|
|
TextRange mCaret;
|
2017-03-15 10:09:30 +00:00
|
|
|
bool mReplacedNativeLineBreakers;
|
2015-01-28 06:27:31 +00:00
|
|
|
|
|
|
|
void EnsureClauseArray();
|
2017-03-15 09:51:32 +00:00
|
|
|
|
2017-03-15 09:59:34 +00:00
|
|
|
/**
|
|
|
|
* ReplaceNativeLineBreakers() replaces "\r\n" and "\r" to "\n" and adjust
|
|
|
|
* each clause information and the caret information.
|
|
|
|
*/
|
|
|
|
void ReplaceNativeLineBreakers();
|
|
|
|
|
2017-03-15 09:51:32 +00:00
|
|
|
/**
|
|
|
|
* AdjustRange() adjusts aRange as in the string with XP line breakers.
|
|
|
|
*
|
|
|
|
* @param aRange The reference to a range in aNativeString.
|
|
|
|
* This will be modified.
|
|
|
|
* @param aNativeString The string with native line breakers.
|
|
|
|
* This may include "\r\n" and/or "\r".
|
|
|
|
*/
|
|
|
|
static void AdjustRange(TextRange& aRange, const nsAString& aNativeString);
|
2015-01-28 06:27:30 +00:00
|
|
|
};
|
|
|
|
PendingComposition mPendingComposition;
|
|
|
|
|
2015-02-19 06:50:20 +00:00
|
|
|
// While dispatching an event, this is incremented.
|
|
|
|
uint16_t mDispatchingEvent;
|
|
|
|
|
2016-03-16 04:47:47 +00:00
|
|
|
enum InputTransactionType : uint8_t
|
|
|
|
{
|
|
|
|
// No input transaction has been started.
|
|
|
|
eNoInputTransaction,
|
2016-03-16 04:47:48 +00:00
|
|
|
// Input transaction for native IME or keyboard event handler. Note that
|
|
|
|
// keyboard events may be dispatched via parent process if there is.
|
2017-07-25 14:27:31 +00:00
|
|
|
// In remote processes, this is also used when events come from the parent
|
|
|
|
// process and are not for tests because we cannot distinguish if
|
|
|
|
// TextEventDispatcher has which type of transaction when it dispatches
|
|
|
|
// (eNativeInputTransaction or eSameProcessSyncInputTransaction).
|
2016-03-16 04:47:47 +00:00
|
|
|
eNativeInputTransaction,
|
2016-03-16 04:47:48 +00:00
|
|
|
// Input transaction for automated tests which are APZ-aware. Note that
|
|
|
|
// keyboard events may be dispatched via parent process if there is.
|
|
|
|
eAsyncTestInputTransaction,
|
|
|
|
// Input transaction for automated tests which assume events are fired
|
|
|
|
// synchronously. I.e., keyboard events are always dispatched in the
|
|
|
|
// current process.
|
2017-07-25 14:27:31 +00:00
|
|
|
// In remote processes, this is also used when events come from the parent
|
|
|
|
// process and are not dispatched by the instance itself for APZ-aware
|
|
|
|
// tests because this instance won't dispatch the events via the parent
|
|
|
|
// process again.
|
2016-03-16 04:47:48 +00:00
|
|
|
eSameProcessSyncTestInputTransaction,
|
|
|
|
// Input transaction for Others (must be IME on B2G). Events are fired
|
|
|
|
// synchronously because TextInputProcessor which is the only user of
|
|
|
|
// this input transaction type supports only keyboard apps on B2G.
|
|
|
|
// Keyboard apps on B2G doesn't want to dispatch keyboard events to
|
|
|
|
// chrome process. Therefore, this should dispatch key events only in
|
|
|
|
// the current process.
|
|
|
|
eSameProcessSyncInputTransaction
|
2016-03-16 04:47:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
InputTransactionType mInputTransactionType;
|
|
|
|
|
2016-03-16 04:47:48 +00:00
|
|
|
bool IsForTests() const
|
|
|
|
{
|
|
|
|
return mInputTransactionType == eAsyncTestInputTransaction ||
|
|
|
|
mInputTransactionType == eSameProcessSyncTestInputTransaction;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ShouldSendInputEventToAPZ() returns true when WidgetInputEvent should
|
|
|
|
// be dispatched via its parent process (if there is) for APZ. Otherwise,
|
|
|
|
// when the input transaction is for IME of B2G or automated tests which
|
|
|
|
// isn't APZ-aware, WidgetInputEvent should be dispatched form current
|
|
|
|
// process directly.
|
|
|
|
bool ShouldSendInputEventToAPZ() const
|
|
|
|
{
|
|
|
|
switch (mInputTransactionType) {
|
|
|
|
case eNativeInputTransaction:
|
|
|
|
case eAsyncTestInputTransaction:
|
|
|
|
return true;
|
|
|
|
case eSameProcessSyncTestInputTransaction:
|
|
|
|
case eSameProcessSyncInputTransaction:
|
|
|
|
return false;
|
|
|
|
case eNoInputTransaction:
|
|
|
|
NS_WARNING("Why does the caller need to dispatch an event when "
|
|
|
|
"there is no input transaction?");
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
MOZ_CRASH("Define the behavior of new InputTransactionType");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-28 06:27:31 +00:00
|
|
|
// See IsComposing().
|
|
|
|
bool mIsComposing;
|
2015-01-28 06:27:31 +00:00
|
|
|
|
Bug 1217700 part.1 nsIWidget should return reference to IMENotificationRequests r=m_kato
IMEContentObserver may need to change notifications to send when TextInputProcessor begins input transaction. In current design, IMEContentObserver needs to retrieve IMENotificationRequests at every change. However, if nsIWidget returns a reference to its IMENotificationRequests, IMEContentObserver can call it only once.
For that purpose, this patch changes nsIWidget::GetIMENotificationRequests() to nsIWidget::IMENotificationRequestsRef() and make it return |const IMENotificationRequests&|. However, if the lifetime of the instance of IMENotificationRequest is shorter than the widget instance's, it's dangerous. Therefore, it always returns TextEventDispatcher::mIMENotificationRequests. TextEventDispatcher's lifetime is longer than the widget. Therefore, this guarantees the lifetime.
On the other hand, widget needs to update TextEventDispatcher::mIMENotificationRequests before calls of nsIWidget::IMENotificationRequestsRef(). Therefore, this patch makes TextEventDispatcher update proper IMENotificationRequests when it gets focus or starts new input transaction and clear mIMENotificationRequests when it loses focus.
Note that TextEventDispatcher gets proper requests both from native text event dispatcher listener (typically, implemented by native IME handler class) and TextInputProcessor when TextInputProcessor has input transaction because even if TextInputProcessor overrides native IME, native IME still needs to know the content changes since they may get new input transaction after that.
However, there may not be native IME handler in content process. If it runs in Android, PuppetWidget may have native IME handler because widget directly handles IME in e10s mode for Android. Otherwise, native IME handler is in its parent process. So, if TextInputHandler has input transaction in content process, PuppetWidget needs to behave as native event handler. Therefore, this patch makes PuppetWidget inherit TextEventDispatcherListener and implements PuppetWidget::IMENotificationRequestsRef().
MozReview-Commit-ID: 2SW3moONTOX
--HG--
extra : rebase_source : d2634ada6c33dbf7a966fadb68608411ee24bfab
2017-04-14 16:35:58 +00:00
|
|
|
// true while NOTIFY_IME_OF_FOCUS is received but NOTIFY_IME_OF_BLUR has not
|
|
|
|
// received yet. Otherwise, false.
|
|
|
|
bool mHasFocus;
|
|
|
|
|
2015-02-19 06:50:18 +00:00
|
|
|
// If this is true, keydown and keyup events are dispatched even when there
|
|
|
|
// is a composition.
|
|
|
|
static bool sDispatchKeyEventsDuringComposition;
|
|
|
|
|
2015-02-10 08:09:29 +00:00
|
|
|
nsresult BeginInputTransactionInternal(
|
|
|
|
TextEventDispatcherListener* aListener,
|
2016-03-16 04:47:47 +00:00
|
|
|
InputTransactionType aType);
|
2015-01-28 06:27:32 +00:00
|
|
|
|
2015-01-28 06:27:31 +00:00
|
|
|
/**
|
|
|
|
* InitEvent() initializes aEvent. This must be called before dispatching
|
|
|
|
* the event.
|
|
|
|
*/
|
2015-02-19 06:50:18 +00:00
|
|
|
void InitEvent(WidgetGUIEvent& aEvent) const;
|
2015-01-28 06:27:31 +00:00
|
|
|
|
2015-08-04 09:52:00 +00:00
|
|
|
|
2015-02-19 06:50:20 +00:00
|
|
|
/**
|
|
|
|
* DispatchEvent() dispatches aEvent on aWidget.
|
|
|
|
*/
|
|
|
|
nsresult DispatchEvent(nsIWidget* aWidget,
|
|
|
|
WidgetGUIEvent& aEvent,
|
|
|
|
nsEventStatus& aStatus);
|
|
|
|
|
2015-08-04 09:52:00 +00:00
|
|
|
/**
|
|
|
|
* DispatchInputEvent() dispatches aEvent on aWidget.
|
|
|
|
*/
|
|
|
|
nsresult DispatchInputEvent(nsIWidget* aWidget,
|
|
|
|
WidgetInputEvent& aEvent,
|
2016-03-16 04:47:48 +00:00
|
|
|
nsEventStatus& aStatus);
|
2015-08-04 09:52:00 +00:00
|
|
|
|
2015-01-28 06:27:31 +00:00
|
|
|
/**
|
|
|
|
* StartCompositionAutomaticallyIfNecessary() starts composition if it hasn't
|
|
|
|
* been started it yet.
|
|
|
|
*
|
|
|
|
* @param aStatus If it succeeded to start composition normally, this
|
|
|
|
* returns nsEventStatus_eIgnore. Otherwise, e.g.,
|
|
|
|
* the composition is canceled during dispatching
|
|
|
|
* compositionstart event, this returns
|
|
|
|
* nsEventStatus_eConsumeNoDefault. In this case,
|
|
|
|
* the caller shouldn't keep doing its job.
|
2016-03-16 04:47:48 +00:00
|
|
|
* @param aEventTime If this is not nullptr, WidgetCompositionEvent will
|
|
|
|
* be initialized with this. Otherwise, initialized
|
|
|
|
* with the time at initializing.
|
2015-01-28 06:27:31 +00:00
|
|
|
* @return Only when something unexpected occurs, this returns
|
|
|
|
* an error. Otherwise, returns NS_OK even if aStatus
|
|
|
|
* is nsEventStatus_eConsumeNoDefault.
|
|
|
|
*/
|
2016-03-16 04:47:48 +00:00
|
|
|
nsresult StartCompositionAutomaticallyIfNecessary(
|
|
|
|
nsEventStatus& aStatus,
|
|
|
|
const WidgetEventTime* aEventTime);
|
2015-02-19 06:50:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* DispatchKeyboardEventInternal() maybe dispatches aKeyboardEvent.
|
|
|
|
*
|
2015-08-28 23:58:27 +00:00
|
|
|
* @param aMessage Must be eKeyDown, eKeyUp or eKeyPress.
|
2015-08-28 23:58:27 +00:00
|
|
|
* @param aKeyboardEvent A keyboard event. If aMessage is eKeyPress and
|
2015-02-19 06:50:18 +00:00
|
|
|
* the event is for second or later character, its
|
|
|
|
* mKeyValue should be empty string.
|
|
|
|
* @param aStatus If dispatching event should be marked as consumed,
|
|
|
|
* set nsEventStatus_eConsumeNoDefault. Otherwise,
|
|
|
|
* set nsEventStatus_eIgnore. After dispatching
|
|
|
|
* a event and it's consumed this returns
|
|
|
|
* nsEventStatus_eConsumeNoDefault.
|
2016-03-16 04:47:48 +00:00
|
|
|
* @param aData Calling this method may cause calling
|
|
|
|
* WillDispatchKeyboardEvent() of the listener.
|
|
|
|
* aData will be set to its argument.
|
2015-08-28 23:58:27 +00:00
|
|
|
* @param aIndexOfKeypress This must be 0 if aMessage isn't eKeyPress or
|
2015-02-19 06:50:18 +00:00
|
|
|
* aKeyboard.mKeyNameIndex isn't
|
|
|
|
* KEY_NAME_INDEX_USE_STRING. Otherwise, i.e.,
|
2015-08-28 23:58:27 +00:00
|
|
|
* when an eKeyPress event causes inputting
|
2015-02-19 06:50:18 +00:00
|
|
|
* text, this must be between 0 and
|
|
|
|
* mKeyValue.Length() - 1 since keypress events
|
|
|
|
* sending only one character per event.
|
Bug 1303273 part.3 Dispatch eKeyPress events without NativeKey::HandleCharMessage() when it handles WM_(SYS)KEYDOWN message and there are following WM_(SYS)CHAR messages which includes non-control character r=m_kato
This patch creates NativeKey::DispatchKeyPressEventsWithRetrievedCharMessages() for dispatching eKeyPress event with mCommittedCharsAndModifiers when it stores following printable WM_(SYS)CHAR messages.
Using loop for dispatching eKeyPress event for every WM_(SYS)CHAR message is wrong because WidgetKeyboardEvent::mKeyValue is initialized with mCommittedCharsAndModifiers and it causes TextEventDispatcher dispatching multiple eKeyPress events at every call of MaybeDispatchKeypressEvents(). Therefore, if mKeyValue is "^^", eKeyPress event is dispatched 4 times --for the first message, eKeyPress events are fired for each "^" and for the second message, eKeyPress events are fired again for each "^"--. Therefore, when it handles WM_(SYS)KEYDOWN and it causes inputting one or more printable characters, it's the easiest way not to use HandleCharMessage().
The new method calls TextEventDispatcher::MaybeDispatchKeypressEvents() only once and it requests to call the callback method with new argument of MaybeDispatchKeypressEvents() when it needs to dispatch 2 or more eKeyPress events. Then, NativeKey::WillDispatchKeyboardEvent() can set each eKeyPress event to raw information of the message and proper modifier state.
With this change, we can dispatch multiple eKeyPress events with retrieved WM_(SYS)CHAR message information rather than retrieved information from active keyboard layout. Therefore, NeedsToHandleWithoutFollowingCharMessages() doesn't return true even when mCommittedCharsAndModifiers stores two or more characters.
FYI: there is a bug in test_keycodes.xul. That is, Alt+'A' of Greek keyboard layout should cause WM_SYSCHAR with a corresponding Greek character but ASCII characters are specified. Therefore, this patch includes the fix of these bugs
MozReview-Commit-ID: JVm7ZJVug0O
--HG--
extra : rebase_source : 414ecbe2c01c53f294d1346414b1a289aa0abfe8
2016-10-06 11:52:03 +00:00
|
|
|
* @param aNeedsCallback Set true when caller needs to initialize each
|
|
|
|
* eKeyPress event immediately before dispatch.
|
|
|
|
* Then, WillDispatchKeyboardEvent() is always called.
|
2015-02-19 06:50:18 +00:00
|
|
|
* @return true if an event is dispatched. Otherwise, false.
|
|
|
|
*/
|
2015-08-26 12:56:59 +00:00
|
|
|
bool DispatchKeyboardEventInternal(EventMessage aMessage,
|
2015-02-19 06:50:18 +00:00
|
|
|
const WidgetKeyboardEvent& aKeyboardEvent,
|
|
|
|
nsEventStatus& aStatus,
|
2016-03-16 04:47:48 +00:00
|
|
|
void* aData,
|
Bug 1303273 part.3 Dispatch eKeyPress events without NativeKey::HandleCharMessage() when it handles WM_(SYS)KEYDOWN message and there are following WM_(SYS)CHAR messages which includes non-control character r=m_kato
This patch creates NativeKey::DispatchKeyPressEventsWithRetrievedCharMessages() for dispatching eKeyPress event with mCommittedCharsAndModifiers when it stores following printable WM_(SYS)CHAR messages.
Using loop for dispatching eKeyPress event for every WM_(SYS)CHAR message is wrong because WidgetKeyboardEvent::mKeyValue is initialized with mCommittedCharsAndModifiers and it causes TextEventDispatcher dispatching multiple eKeyPress events at every call of MaybeDispatchKeypressEvents(). Therefore, if mKeyValue is "^^", eKeyPress event is dispatched 4 times --for the first message, eKeyPress events are fired for each "^" and for the second message, eKeyPress events are fired again for each "^"--. Therefore, when it handles WM_(SYS)KEYDOWN and it causes inputting one or more printable characters, it's the easiest way not to use HandleCharMessage().
The new method calls TextEventDispatcher::MaybeDispatchKeypressEvents() only once and it requests to call the callback method with new argument of MaybeDispatchKeypressEvents() when it needs to dispatch 2 or more eKeyPress events. Then, NativeKey::WillDispatchKeyboardEvent() can set each eKeyPress event to raw information of the message and proper modifier state.
With this change, we can dispatch multiple eKeyPress events with retrieved WM_(SYS)CHAR message information rather than retrieved information from active keyboard layout. Therefore, NeedsToHandleWithoutFollowingCharMessages() doesn't return true even when mCommittedCharsAndModifiers stores two or more characters.
FYI: there is a bug in test_keycodes.xul. That is, Alt+'A' of Greek keyboard layout should cause WM_SYSCHAR with a corresponding Greek character but ASCII characters are specified. Therefore, this patch includes the fix of these bugs
MozReview-Commit-ID: JVm7ZJVug0O
--HG--
extra : rebase_source : 414ecbe2c01c53f294d1346414b1a289aa0abfe8
2016-10-06 11:52:03 +00:00
|
|
|
uint32_t aIndexOfKeypress = 0,
|
|
|
|
bool aNeedsCallback = false);
|
Bug 1217700 part.1 nsIWidget should return reference to IMENotificationRequests r=m_kato
IMEContentObserver may need to change notifications to send when TextInputProcessor begins input transaction. In current design, IMEContentObserver needs to retrieve IMENotificationRequests at every change. However, if nsIWidget returns a reference to its IMENotificationRequests, IMEContentObserver can call it only once.
For that purpose, this patch changes nsIWidget::GetIMENotificationRequests() to nsIWidget::IMENotificationRequestsRef() and make it return |const IMENotificationRequests&|. However, if the lifetime of the instance of IMENotificationRequest is shorter than the widget instance's, it's dangerous. Therefore, it always returns TextEventDispatcher::mIMENotificationRequests. TextEventDispatcher's lifetime is longer than the widget. Therefore, this guarantees the lifetime.
On the other hand, widget needs to update TextEventDispatcher::mIMENotificationRequests before calls of nsIWidget::IMENotificationRequestsRef(). Therefore, this patch makes TextEventDispatcher update proper IMENotificationRequests when it gets focus or starts new input transaction and clear mIMENotificationRequests when it loses focus.
Note that TextEventDispatcher gets proper requests both from native text event dispatcher listener (typically, implemented by native IME handler class) and TextInputProcessor when TextInputProcessor has input transaction because even if TextInputProcessor overrides native IME, native IME still needs to know the content changes since they may get new input transaction after that.
However, there may not be native IME handler in content process. If it runs in Android, PuppetWidget may have native IME handler because widget directly handles IME in e10s mode for Android. Otherwise, native IME handler is in its parent process. So, if TextInputHandler has input transaction in content process, PuppetWidget needs to behave as native event handler. Therefore, this patch makes PuppetWidget inherit TextEventDispatcherListener and implements PuppetWidget::IMENotificationRequestsRef().
MozReview-Commit-ID: 2SW3moONTOX
--HG--
extra : rebase_source : d2634ada6c33dbf7a966fadb68608411ee24bfab
2017-04-14 16:35:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ClearNotificationRequests() clears mIMENotificationRequests.
|
|
|
|
*/
|
|
|
|
void ClearNotificationRequests();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* UpdateNotificationRequests() updates mIMENotificationRequests with
|
|
|
|
* current state. If the instance doesn't have focus, this clears
|
|
|
|
* mIMENotificationRequests. Otherwise, updates it with both requests of
|
|
|
|
* current listener and native listener.
|
|
|
|
*/
|
|
|
|
void UpdateNotificationRequests();
|
2015-01-28 06:27:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace widget
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // #ifndef mozilla_widget_textcompositionsynthesizer_h_
|