Closed
Bug 1167022
Opened 10 years ago
Closed 10 years ago
Shouldn't notify IME of focus/blur when a focused editor is reframed
Categories
(Core :: DOM: Editor, defect)
Core
DOM: Editor
Tracking
()
RESOLVED
FIXED
mozilla41
Tracking | Status | |
---|---|---|
firefox41 | --- | fixed |
People
(Reporter: masayuki, Assigned: masayuki)
References
Details
(Keywords: inputmethod)
Attachments
(5 files, 3 obsolete files)
5.35 KB,
patch
|
jchen
:
review+
|
Details | Diff | Splinter Review |
7.70 KB,
patch
|
Details | Diff | Splinter Review | |
9.35 KB,
patch
|
jchen
:
review+
|
Details | Diff | Splinter Review |
17.85 KB,
patch
|
Details | Diff | Splinter Review | |
6.31 KB,
patch
|
smaug
:
review+
|
Details | Diff | Splinter Review |
If we notify IME of focus blur, IME may commit existing composition. This is unexpected behavior when focused editor is reframed.
We shouldn't notify IME of focus/blur during reframing.
Assignee | ||
Comment 1•10 years ago
|
||
First, IMEContentObserver should be able to restart to observe focused editor even after reframed (i.e., root content which is anonymous div element is replaced with the other).
Attachment #8608530 -
Flags: review?(bugs)
Assignee | ||
Comment 2•10 years ago
|
||
When IMEStateManager::UpdateIMEState() is called, it should try to restart observing the content with existing IMEContentObserver. I.e., this shouldn't cause notifying IME of focus/blur at reframing the editor.
Attachment #8608531 -
Flags: review?(nchen)
Attachment #8608531 -
Flags: review?(bugs)
Assignee | ||
Comment 3•10 years ago
|
||
Fix runEditorReframeTests() without MozIMEFocus(In|Out) events because nsITextInputProcessor allows JS to receive notifications to IME.
Attachment #8608532 -
Flags: review?(nchen)
Assignee | ||
Comment 4•10 years ago
|
||
Since JS can receive notifications to IME directly, we can get rid of hacky events for this test now.
Attachment #8608533 -
Flags: review?(bugs)
Comment 5•10 years ago
|
||
Comment on attachment 8608530 [details] [diff] [review]
part.1 Make IMEContentObserver possible to restart editor root node
>+ bool firstInitialization =
>+ !(mRootContent && !mRootContent->IsInComposedDoc());
took some time to understand this
>+ void NotifyIMEOfBlur(bool aPostEvent);
>+ /**
>+ * UnregisterObservers() unresiters all listeners and observers.
unregisters
Attachment #8608530 -
Flags: review?(bugs) → review+
Comment 6•10 years ago
|
||
Comment on attachment 8608531 [details] [diff] [review]
part.2 IMEStateManager::UpdateIMEState() should try to restart to observe focused editor if it's reframed
>+void
>+IMEContentObserver::MaybeRestartToObserve(nsIWidget* aWidget,
>+ nsPresContext* aPresContext,
>+ nsIContent* aContent,
>+ nsIEditor* aEditor)
Could this return bool
>+{
>+ if (GetState() != eState_StoppedObserving ||
>+ !IsObservingContent(aPresContext, aContent)) {
>+ return;
>+ }
>+
>+ Init(aWidget, aPresContext, aContent, aEditor);
so here add
return IsManaging(aPresContext, aContent);
>+ if (sActiveIMEContentObserver && IsIMEObserverNeeded(aNewIMEState)) {
>+ PR_LOG(sISMLog, PR_LOG_DEBUG,
>+ ("ISM: IMEStateManager::UpdateIMEState(), try to reinitialize the "
>+ "active IMEContentObserver"));
>+ sActiveIMEContentObserver->MaybeRestartToObserve(widget, sPresContext,
>+ aContent, aEditor);
>+ if (!sActiveIMEContentObserver->IsManaging(sPresContext, aContent)) {
Then you could merge MaybeRestartToObserve and IsManaging call here.
Attachment #8608531 -
Flags: review?(bugs) → review+
Comment 7•10 years ago
|
||
Comment on attachment 8608533 [details] [diff] [review]
part.4 Get rid of MozIMEFocus(In|Out) events
nice
Attachment #8608533 -
Flags: review?(bugs) → review+
Assignee | ||
Comment 8•10 years ago
|
||
(In reply to Olli Pettay [:smaug] from comment #5)
> Comment on attachment 8608530 [details] [diff] [review]
> part.1 Make IMEContentObserver possible to restart editor root node
>
> >+ bool firstInitialization =
> >+ !(mRootContent && !mRootContent->IsInComposedDoc());
> took some time to understand this
Sorry, it's just copied from GetState() of part.2 because part.1 and part.2 were in one patch, but I separated it for review. I believe that you can understand it quickly when you reviewed part.2.
Assignee | ||
Comment 9•10 years ago
|
||
Attachment #8608530 -
Attachment is obsolete: true
Assignee | ||
Comment 10•10 years ago
|
||
Attachment #8608531 -
Attachment is obsolete: true
Attachment #8608531 -
Flags: review?(nchen)
Attachment #8609238 -
Flags: review?(nchen)
Assignee | ||
Comment 11•10 years ago
|
||
Attachment #8608533 -
Attachment is obsolete: true
Comment 12•10 years ago
|
||
Comment on attachment 8609238 [details] [diff] [review]
part.2 IMEStateManager::UpdateIMEState() should try to restart to observe focused editor when it's reframed (r=smaug)
Review of attachment 8609238 [details] [diff] [review]:
-----------------------------------------------------------------
LGTM with some nits
::: dom/events/IMEContentObserver.h
@@ +78,5 @@
> + * with new node instances.
> + * @return Returns true if the instance is managing the content.
> + * Otherwise, false.
> + */
> + bool MaybeRestartToObserve(nsIWidget* aWidget,
I think "MaybeRestartToObserve" is not a very clear name because we are doing more than resetting observers; we are calling Init() to re-initialize.
I think "MaybeReinit" or "EnsureIsManaging" would be more clear names.
::: dom/events/IMEStateManager.cpp
@@ +1141,5 @@
> }
>
> // static
> bool
> +IMEStateManager::IsIMEObserverNeeded(const IMEState& aState)
Maybe remove IMEStateManager::IsIMEObserverNeeded, and just use IMEState::IsEditable?
@@ +1203,3 @@
> PR_LOG(sISMLog, PR_LOG_DEBUG,
> ("ISM: IMEStateManager::CreateIMEContentObserver() doesn't create "
> + "IMEContentObserver because of it's not necessary"));
"IMEContentObserver because it's not necessary" (don't need the 'of')
Attachment #8609238 -
Flags: review?(nchen) → review+
Updated•10 years ago
|
Attachment #8608532 -
Flags: review?(nchen) → review+
Assignee | ||
Comment 13•10 years ago
|
||
(In reply to Jim Chen [:jchen] [:darchons] from comment #12)
> Comment on attachment 8609238 [details] [diff] [review]
> part.2 IMEStateManager::UpdateIMEState() should try to restart to observe
> focused editor when it's reframed (r=smaug)
>
> Review of attachment 8609238 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> LGTM with some nits
>
> ::: dom/events/IMEContentObserver.h
> @@ +78,5 @@
> > + * with new node instances.
> > + * @return Returns true if the instance is managing the content.
> > + * Otherwise, false.
> > + */
> > + bool MaybeRestartToObserve(nsIWidget* aWidget,
>
> I think "MaybeRestartToObserve" is not a very clear name because we are
> doing more than resetting observers; we are calling Init() to re-initialize.
>
> I think "MaybeReinit" or "EnsureIsManaging" would be more clear names.
Okay, I'll rename it to MaybeReinitialize().
> ::: dom/events/IMEStateManager.cpp
> @@ +1141,5 @@
> > }
> >
> > // static
> > bool
> > +IMEStateManager::IsIMEObserverNeeded(const IMEState& aState)
>
> Maybe remove IMEStateManager::IsIMEObserverNeeded, and just use
> IMEState::IsEditable?
Yeah, it's same at least for now. However, I'd like to wrap with a method named what it does. In the future, if we add some conditions, this method guarantees both CreateIMEContentObserver() and UpdateIMEState() use does same check.
> @@ +1203,3 @@
> > PR_LOG(sISMLog, PR_LOG_DEBUG,
> > ("ISM: IMEStateManager::CreateIMEContentObserver() doesn't create "
> > + "IMEContentObserver because of it's not necessary"));
>
> "IMEContentObserver because it's not necessary" (don't need the 'of')
Oops!
Comment 14•10 years ago
|
||
Comment 15•10 years ago
|
||
Assignee | ||
Comment 16•10 years ago
|
||
(In reply to Phil Ringnalda (:philor) from comment #15)
> Backed out in
> https://hg.mozilla.org/integration/mozilla-inbound/rev/fb82a47beb96 for
> reftest-e10s bustage like
> https://treeherder.mozilla.org/logviewer.html#?job_id=10113856&repo=mozilla-
> inbound and
> https://treeherder.mozilla.org/logviewer.html#?job_id=10114581&repo=mozilla-
> inbound
Hmm, that's wired, is it really caused by the patches? The patches don't touch to layout...
Assignee | ||
Comment 17•10 years ago
|
||
Okay, probably the assertion detects my bug. But I'm still not sure the timeouts.
Assignee | ||
Comment 18•10 years ago
|
||
PuppetWidget queries content at IME-focus notification. Then, ContentEventHandler flushes the layout. Then, nsEditor may actually created *while* IMEContentObserver::Init() sends IME-focus notification. Therefore, IMEStateManager::UpdateIMEState() tries to reinitialize it with the latest contents.
So, IME-focus notification shouldn't be sent after registering as observers.
This patch restores the order of sending notification and registering as observers. And also, if the IMEContentObserver already starts to observe the latest contents after sending IME-focus notification, it doesn't try to register itself as observer again.
Attachment #8610078 -
Flags: review?(bugs)
Updated•10 years ago
|
Attachment #8610078 -
Flags: review?(bugs) → review+
Comment 19•10 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/d4a4025d966e
https://hg.mozilla.org/integration/mozilla-inbound/rev/59a6bef031e2
https://hg.mozilla.org/integration/mozilla-inbound/rev/34d5aa9774c2
https://hg.mozilla.org/integration/mozilla-inbound/rev/c4bb1e305234
https://hg.mozilla.org/integration/mozilla-inbound/rev/8adf9f289057
https://hg.mozilla.org/mozilla-central/rev/d4a4025d966e
https://hg.mozilla.org/mozilla-central/rev/59a6bef031e2
https://hg.mozilla.org/mozilla-central/rev/34d5aa9774c2
https://hg.mozilla.org/mozilla-central/rev/c4bb1e305234
https://hg.mozilla.org/mozilla-central/rev/8adf9f289057
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla41
You need to log in
before you can comment on or make changes to this bug.
Description
•