Closed Bug 559710 Opened 14 years ago Closed 14 years ago

Don't add a br node under text controls when the editor is not initialized for them yet

Categories

(Core :: Layout: Form Controls, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9.3a5

People

(Reporter: ehsan.akhgari, Assigned: ehsan.akhgari)

References

Details

(Keywords: perf)

Attachments

(1 file, 6 obsolete files)

Attached patch Patch (v1) (obsolete) — Splinter Review
See bug 473178 comment 27.  This is a very good perf improvement, if we can make sure that the a11y module can handle having a different anonymous content tree in that case.

The patch I attached does this, maybe David or Alexander can look into fixing this in the a11y side?

I've pushed this patch to the try server, and I'll post an update here with the failure logs when they're available.
Ehsan, could you describe your patch please? I need to understand how it can affect on a11y. Honestly I don't see a reason why presence or absence of initial <br> can affect on a11y. It might change the way how accessible text methods work but it should be ok. If there is no any bad affection on a11y then all we need is to fix mochitests.
(Mid air collision)

I think the problem might be our tests. I'm not convinced we are testing a case that is required for accessibility, since our accessibility engine is pretty capable of exposing all kinds of trees.

I think perhaps we can loosen our tests. Ehsan do you have a try build that Marco (or Alex/I) can take for a spin?
OK I looking at this now (built it).
This patch caused no issues in my tests with Accerciser (Linux a11y diagnostic tool). My tests included https://bug473178.bugzilla.mozilla.org/attachment.cgi?id=357388 as well as some contenteditable examples for good measure.
The information exposed through the atk text interface was correct and updated correctly as you would expect.
I'd like Marco to spin this patch against various AT before we land it, but he is off until Monday. Can we wait?
(In reply to comment #1)
> Linux accessibility test failures:
> 
> http://tinderbox.mozilla.org/showlog.cgi?log=MozillaTry/1271381238.1271390607.15302.gz

Regarding the fails... why are we getting two children? What are they?
(In reply to comment #2)
> Ehsan, could you describe your patch please?

Before the lazy initialization code, an editor object was being instantiated for all input text controls.  The way that the editor works is that it modifies a div element which is the root of the native anonymous content tree.  When the value is not empty, the editor uses a text node under the anonymous div for storing and displaying the value.  When the value is empty, the editor removes that text node and adds a special br node (which it calls the bogus node) under the anonymous div.

With my original lazy initialization patch, I imitated the exact same behavior when no editor was present.  This patch modifies that behavior so that at all times there is only a single text node under the anonymous div.  When the value is empty, we set the value of the text node to "\n" in order to preserve the line-height calculations, and when the value is not empty, we set the text node value to the input control value.

> I need to understand how it can
> affect on a11y. Honestly I don't see a reason why presence or absence of
> initial <br> can affect on a11y. It might change the way how accessible text
> methods work but it should be ok. If there is no any bad affection on a11y then
> all we need is to fix mochitests.

Well, that I can't be certain of, because I don't know what is expected to happen at the a11y side, and what types of assumptions the a11y code currently makes.
(In reply to comment #3)
> I think perhaps we can loosen our tests. Ehsan do you have a try build that
> Marco (or Alex/I) can take for a spin?

The try server build I submitted last night is available at:

<http://build.mozilla.org/tryserver-builds/eakhgari@mozilla.com-try-a437d6e37e79>
(In reply to comment #8)
> (In reply to comment #1)
> > Linux accessibility test failures:
> > 
> > http://tinderbox.mozilla.org/showlog.cgi?log=MozillaTry/1271381238.1271390607.15302.gz
> 
> Regarding the fails... why are we getting two children? What are they?

Is there any way to make the test log what it sees?  If so, I can add it to the patch and push it to try to see what children we're getting.
I threw this try-server build against several screen readers with varying testcases (sites with input @type="text", textarea, contenteditable elements), and didn't find anything wrong. Looks like this perf improvement has no negative impact on assistive technologies.
Comment on attachment 439419 [details] [diff] [review]
Patch (v1)

Requesting review from bz, and also feedback from David to give me the official go from the a11y side of things.

Also, should I just modify the a11y test to expect two children?  Or do we need a more involved fix?
Attachment #439419 - Flags: review?(bzbarsky)
Attachment #439419 - Flags: feedback?(bolterbugz)
(In reply to comment #13)

> Also, should I just modify the a11y test to expect two children?  Or do we need
> a more involved fix?

I would really appreciate to know who is a second child. Child adoption is serious thing :)
(In reply to comment #14)
> (In reply to comment #13)
> 
> > Also, should I just modify the a11y test to expect two children?  Or do we need
> > a more involved fix?
> 
> I would really appreciate to know who is a second child. Child adoption is
> serious thing :)

I'm building right now with a11y turned on, and I'll ask for David's advice with regard to child adoption later today!
Assignee: nobody → ehsan
Depends on: 560270
David gave me the verbal go on just adding a child to the list, and filing a follow-up bug to figure out why it's now needed.

I filed bug 560270 about that, and will attach a new patch here in a moment.
Attached patch Patch (v1.1) (obsolete) — Splinter Review
Attachment #439419 - Attachment is obsolete: true
Attachment #439972 - Flags: review?(bzbarsky)
Attachment #439972 - Flags: review?(bolterbugz)
Attachment #439419 - Flags: review?(bzbarsky)
Attachment #439419 - Flags: feedback?(bolterbugz)
Comment on attachment 439972 [details] [diff] [review]
Patch (v1.1)

r=me for the a11y test change, with one nit:

>--- a/accessible/tests/mochitest/tree/test_combobox.xul
>+++ b/accessible/tests/mochitest/tree/test_combobox.xul


>             role: ROLE_ENTRY,
>             children: [
>               {
>                 role: ROLE_TEXT_LEAF // HTML 5 placeholder attribute value
>+              },
>+              {
>+                role: ROLE_TEXT_LEAF // XXXehsan We don't yet know what this is!

Assuming we can co-debug the follow up since the editor scares me still; okay.
Nit: please reference bug 560270 in the comment.
Attachment #439972 - Flags: review?(bolterbugz) → review+
So, this text node is coming from the textnode under the value div.  There would be a problem with just ignoring this textnode.  When the value is empty, we convert it to "\n" for line-height calculations, and the a11y code converts that newline into a space and exposes the text leaf node with that space.  This means that a11y clients will think that there's a space inside the text box, while in fact there isn't any space there.

I think the correct way to fix it is to look at the content node (or maybe the frame) for retrieving the value, instead of going through the textnode contents.

OTOH, we believe that accessibility clients do not use the text leaf contents to get the value of the textbox.  David is going to confirm this with one of his contacts, and we'll wait for him to get back at us.
Comment on attachment 439972 [details] [diff] [review]
Patch (v1.1)

Switching the review request to roc as he knows the background of this bug, and Boris has a lot of review requests to catch up on.
Attachment #439972 - Flags: review?(bzbarsky) → review?(roc)
Jamie, what API does NVDA call on text fields, text boxes and their ilk?
If the accessible supports IAccessibleText (which it must), we currently use IAccessibleText alone to get the text.

Out of curiosity, why is this being converted to a space anyway? This makes sense when it is just DOM content, but in this case, it's being used for line height calculation, so it should be different. Can that be detected?
(In reply to comment #22)
> If the accessible supports IAccessibleText (which it must), we currently use
> IAccessibleText alone to get the text.

If I understand things correctly, our IAccessibleText implementation just asks the content node for the value, so this should be fine.  David, please correct me if I'm wrong.

> Out of curiosity, why is this being converted to a space anyway? This makes
> sense when it is just DOM content, but in this case, it's being used for line
> height calculation, so it should be different. Can that be detected?

For input elements, if you set the value of the single line text boxes to something like "test\nme" using js, the input control converts that newline to a space by default before showing that on screen.  The accessibility code is trying to simulate that behavior for the text leaves inside the text control.

So, David, if the value of the editor.singleLine.pasteNewlines is 2 (which is the default for Firefox), newlines will always be converted into spaces inside the text node in question, so in fact the accessibility code can check that pref and ignore text nodes which have a value of "\n" if that pref's value is 2.  Is that something which we can do inside the a11y code?

Note that the pref in question is actually being misused here (it was originally added to only affect the "paste" behavior, as its name suggests), and the mess will be fixed with bug 549475 eventually.
Comment on attachment 439972 [details] [diff] [review]
Patch (v1.1)

the layout code is fine, but fix the XXX comment.
Attachment #439972 - Flags: review?(roc) → review+
Attached patch Current patch (obsolete) — Splinter Review
Current patch with the fixed comment.  Waiting for David's green light before pushing this.
Attachment #439972 - Attachment is obsolete: true
(In reply to comment #22)
> If the accessible supports IAccessibleText (which it must), we currently use
> IAccessibleText alone to get the text.

Oh that makes things more worrisome.

> Out of curiosity, why is this being converted to a space anyway? This makes
> sense when it is just DOM content, but in this case, it's being used for line
> height calculation, so it should be different. Can that be detected?

Let's discuss on bug 560270.
Depends on: 560665, 560669
Attached patch New patch (obsolete) — Splinter Review
I fixed a few unneeded things in the patch.  I'm carrying the r+'s forward on this patch.
Attachment #440036 - Attachment is obsolete: true
Attached patch Patch (v1.2) (obsolete) — Splinter Review
So, apparently the non-breaking space inside the anonymous div's for empty elements are not needed.  I confirmed it with bz on IRC, and ran our reftests agaist this patch, so I'm removing them in this patch.  This is a trivial change, but I'm asking for roc's review again here.
Attachment #440961 - Attachment is obsolete: true
Attachment #441164 - Flags: review?(roc)
+    textContent = mValueDiv->GetChildAt(0);

Why not just set it to textNode?
Attached patch Patch (v1.3) (obsolete) — Splinter Review
Makes sense.
Attachment #441164 - Attachment is obsolete: true
Attachment #441192 - Flags: review?(roc)
Attachment #441164 - Flags: review?(roc)
The try server shows an accessibility test failure, which I don't quite understand:

http://tinderbox.mozilla.org/showlog.cgi?log=MozillaTry/1272058499.1272067606.30923.gz

I don't get this failure on Mac with a11y enabled.  I'm currently building it on Linux to see what's going on.
Attached patch Patch (v1.4)Splinter Review
This fixes one more accessibility test failure which I didn't catch earlier because the failing test does not run on Mac.
Attachment #441192 - Attachment is obsolete: true
Attachment #441298 - Flags: review?(bolterbugz)
Attachment #441298 - Flags: review?(bolterbugz) → review+
http://hg.mozilla.org/mozilla-central/rev/26ce8f7e485c
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3a5
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: