Closed
Bug 675579
Opened 14 years ago
Closed 11 years ago
The user setting input or textarea direction does not set the element's dir and does not fire the input event
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
FIXED
mozilla29
People
(Reporter: aharon, Assigned: ehsan.akhgari)
References
(Depends on 1 open bug, Blocks 1 open bug)
Details
(Keywords: dev-doc-needed)
Attachments
(3 files, 1 obsolete file)
340 bytes,
text/html
|
Details | |
Part 1: Set the dir attribute on the input/textarea element when switching the text direction; r=roc
4.25 KB,
patch
|
roc
:
review+
|
Details | Diff | Splinter Review |
5.93 KB,
patch
|
roc
:
review+
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.122 Safari/534.30
Steps to reproduce:
1. Open the attached setdir.html
2. Click on the input and type a.
3. Press Ctrl-Shift-X
4. Click on the input and type b. You will see "rtl." appear next to the period placed above the input earlier.
5. Repeat 1-4 using the textarea instead.
In other words, the user setting an element's direction sets its dir attribute, but does not fire the input event, which is what this bug is all about.
Actual results:
At step 2, a period appeared above the input, indicating that an input event has been fired and that the the element's dir property is null or empty. This shows that the page script is written correctly and is seeing input events.
At step 3, nothing happened, indicating that setting the direction did not generate an input event.
At step 4, another period appeared next to the text placed above the input earlier. This indicates that an input event has been fired, but the element's dir property is still null or empty.
Thus, setting the input's direction neither sets the element's dir property nor fires an input event. The same happened with the textarea.
This conflicts with the HTML5 spec (http://dev.w3.org/html5/spec/Overview.html#text-state-and-search-state), which states that when the user sets the direction of an input element, the user agent must:
- Set the element's dir attribute to "ltr" if the user selected a left-to-right writing direction, and "rtl" if the user selected a right-to-left writing direction.
- Queue a task to fire a simple event that bubbles named input at the input element.
There is an identical requirement for textarea (http://dev.w3.org/html5/spec/Overview.html#the-textarea-element).
Expected results:
At step 2 in "what did you do?" above, a period should appear above the input, indicating that an input event has been fired and that the the element's dir property is null or empty.
At step 3, "rtl." should have appeared next to the period placed above the input earlier. This indicates that an input event has been fired, and the element's dir property is "rtl".
At step 4, another "rtl." should appear next to the text placed above the input earlier. This indicates that an input event has been fired, and the element's dir property is "rtl".
Assignee | ||
Updated•14 years ago
|
Attachment #549737 -
Attachment mime type: text/plain → text/html
Assignee | ||
Updated•14 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
Assignee | ||
Comment 1•14 years ago
|
||
Fabien, can you work on this, please? The code responsible for this is nsEditor::SwitchTextDirection. For firing the input event, you should call FireOnInput on the element's frame, if available (see nsTextInputListener::EditAction for one and currently the only example).
Assignee: nobody → kaze
Comment 2•12 years ago
|
||
Ehsan, I'm assuming Fabien isn't working on that anymore.
Assignee: kaze → nobody
Assignee | ||
Comment 3•12 years ago
|
||
(In reply to comment #2)
> Ehsan, I'm assuming Fabien isn't working on that anymore.
No, I don't think anybody is working on this.
Reporter | ||
Comment 4•12 years ago
|
||
Re-reading my description above, I find myself wondering what I was on when I wrote it. Do follow the steps to reproduce. You will find that when you press Ctr-Shift-X, nothing appears above the input, and when you then add a character to the input, you will only get another dot above the input. Thus, Ctrl-Shift-X neither sets the dir attribute no fires an input event. It is supposed to do both.
Can anyone take on this?
Reporter | ||
Comment 5•11 years ago
|
||
Can someone take on this, please?
BTW, in contentEditable (as opposed to <input> and <textarea>), Ctrl-Shift-X already sets the dir attribute on the contentEditable element, and only the event is missing.
If the event is really bothersome, you could set the dir attribute on the current paragraph inside the contentEditable instead of the contentEditable element itself. That would at least allow Ctrl-Shift-X to set paragraph directionality when editing rich text messages in Gmail. This already works in Chrome, and can be made to work in IE, but there currently no way to do it in Firefox, and people complain about it.
Assignee | ||
Comment 6•11 years ago
|
||
Assignee | ||
Comment 7•11 years ago
|
||
Assignee | ||
Updated•11 years ago
|
Assignee: nobody → ehsan
Assignee | ||
Updated•11 years ago
|
Attachment #8360729 -
Flags: review?(roc)
Assignee | ||
Updated•11 years ago
|
Attachment #8360730 -
Flags: review?(roc)
Assignee | ||
Comment 8•11 years ago
|
||
So it turns out that dispatching the input event asynchronously breaks a whole bunch of tests: <https://tbpl.mozilla.org/?tree=Try&rev=d785c74f9a11>. I could go ahead and fix them all but this makes me wonder if there will be webcompat risks, as input events are very commonly used for things like autocomplete widgets, etc. So instead of doing that here, I filed bug 960581 to investigate that.
Depends on: 960581
Assignee | ||
Updated•11 years ago
|
Attachment #8360730 -
Attachment is obsolete: true
Attachment #8360730 -
Flags: review?(roc)
Assignee | ||
Comment 9•11 years ago
|
||
Assignee | ||
Updated•11 years ago
|
Attachment #8361130 -
Flags: review?(roc)
Assignee | ||
Comment 10•11 years ago
|
||
Things looking green: https://tbpl.mozilla.org/?tree=Try&rev=23a286fceea2
Comment on attachment 8360729 [details] [diff] [review]
Part 1: Set the dir attribute on the input/textarea element when switching the text direction; r=roc
Review of attachment 8360729 [details] [diff] [review]:
-----------------------------------------------------------------
::: editor/libeditor/base/nsEditor.cpp
@@ +5015,5 @@
> +
> + // For plaintext editors, we need to ask the input/textarea element directly.
> + if (rootElement->IsRootOfNativeAnonymousSubtree()) {
> + rootElement = rootElement->GetParent();
> + }
Let's have a GetExposedRoot method (or pick a better name) that encapsulates this decision.
Attachment #8360729 -
Flags: review?(roc) → review+
Attachment #8361130 -
Flags: review?(roc) → review+
Assignee | ||
Comment 12•11 years ago
|
||
Assignee | ||
Updated•11 years ago
|
Keywords: dev-doc-needed
Comment 13•11 years ago
|
||
Backed out for crashes, eg:
https://tbpl.mozilla.org/php/getParsedLog.php?id=33170493&tree=Mozilla-Inbound
https://tbpl.mozilla.org/php/getParsedLog.php?id=33170882&tree=Mozilla-Inbound
remote: https://hg.mozilla.org/integration/mozilla-inbound/rev/f5efef8989a5
remote: https://hg.mozilla.org/integration/mozilla-inbound/rev/d8f664832da3
Comment 14•11 years ago
|
||
And reftest failures:
https://tbpl.mozilla.org/php/getParsedLog.php?id=33171735&tree=Mozilla-Inbound
Assignee | ||
Comment 15•11 years ago
|
||
Comment 16•11 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/3475821c2448
https://hg.mozilla.org/mozilla-central/rev/8f1ffc0fe914
Status: NEW → RESOLVED
Closed: 11 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla29
Reporter | ||
Comment 17•11 years ago
|
||
Looking good on Nightly! Thanks for doing this!
(In reply to :Ehsan Akhgari (needinfo? me!) from comment #8)
> So it turns out that dispatching the input event asynchronously breaks a
> whole bunch of tests: <https://tbpl.mozilla.org/?tree=Try&rev=d785c74f9a11>.
> I could go ahead and fix them all but this makes me wonder if there will be
> webcompat risks, as input events are very commonly used for things like
> autocomplete widgets, etc. So instead of doing that here, I filed bug
> 960581 to investigate that.
I guess you wound up dispatching the event and fixing the tests, right? That is what I am seeing in Nightly, but there has not been any update on your concern re webcomapt risks. IMO, the only risk is that after this change, the value of the input can be the same at two consecutive input events, whereas before this could never be the case. I think it's a pretty small risk - and the fact is that this is the way Blink and WebKit have been behaving for a long time, and it is also in accordance with the HTML5 spec, so I think this is fine.
Re 960581, see my response there.
Reporter | ||
Comment 18•11 years ago
|
||
Oh, is the input event being generated on Ctrl-Shift-X on a contentEditable now too? I hope so.
Assignee | ||
Comment 19•11 years ago
|
||
(In reply to Aharon (Vladimir) Lanin from comment #17)
> Looking good on Nightly! Thanks for doing this!
No worries, sorry I dropped the ball on this!
> I guess you wound up dispatching the event and fixing the tests, right?
I ended up dispatching the event *synchronously*, so I didn't need to fix those tests.
> That
> is what I am seeing in Nightly, but there has not been any update on your
> concern re webcomapt risks.
That risk was about dispatching the event asynchronously.
> IMO, the only risk is that after this change,
> the value of the input can be the same at two consecutive input events,
> whereas before this could never be the case. I think it's a pretty small
> risk - and the fact is that this is the way Blink and WebKit have been
> behaving for a long time, and it is also in accordance with the HTML5 spec,
> so I think this is fine.
Yeah, I'm not much worried about that yet.
Assignee | ||
Comment 20•11 years ago
|
||
(In reply to Aharon (Vladimir) Lanin from comment #18)
> Oh, is the input event being generated on Ctrl-Shift-X on a contentEditable
> now too? I hope so.
Yes it should. Does it not in your tests?
Reporter | ||
Comment 21•11 years ago
|
||
(In reply to :Ehsan Akhgari (needinfo? me!) from comment #20)
> (In reply to Aharon (Vladimir) Lanin from comment #18)
> > Oh, is the input event being generated on Ctrl-Shift-X on a contentEditable
> > now too? I hope so.
>
> Yes it should. Does it not in your tests?
I had not tested it, but I have now, and it is indeed generated now.
However, we have a different problem (unconnected to your changes - FF 26 is the same): Ctrl-Shift-X with the caret in a contenteditable sets the dir attribute *on the body element*! I have filed bug 962015. Please take a look.
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•