Closed Bug 808964 Opened 12 years ago Closed 12 years ago

AccessKeyLabel should be empty string for elements without the accesskey attribute

Categories

(Core :: DOM: Core & HTML, defect)

10 Branch
x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla19

People

(Reporter: listenleser, Assigned: s)

Details

(Whiteboard: [good first bug][mentor=Ms2ger][lang=c++])

Attachments

(1 file, 3 obsolete files)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.3) Gecko/20100101 Firefox/10.0.3
Build ID: 20120309135702

Steps to reproduce:

1. Chose an element without an accesskey attribute.
2. Look at its accessKeyLabel property (e.g.
alert(document.getElementsByTagName('body')[0].accessKeyLabel)
)


Actual results:

The accessKeyLabel property is "Alt+Umschalt+" (or whatever language you use).
I tested this both in Firefox 10 and 16.


Expected results:

Instead it should be the empty string.
http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#dom-accesskeylabel says:
"The accessKeyLabel IDL attribute must return a string that represents the element's assigned access key, if any. If the element does not have one, then the IDL attribute must return the empty string."
To fix this bug, one will need to change nsGenericHTMLElement::GetAccessKeyLabel [1] to only call GetAccessKeyLabelPrefix if GetAccessKey returns a non-empty string.

[1] http://mxr.mozilla.org/mozilla-central/source/content/html/content/src/nsGenericHTMLElement.cpp#449
Status: UNCONFIRMED → NEW
Ever confirmed: true
Whiteboard: [good first bug][mentor=Ms2ger][lang=c++]
Okey let me try :)
here my patch, it  elt.accessKeyLabel  returns an empty string if it's not set, "Alt+Shift+<key>" else.
Attachment #678745 - Flags: review?
Assignee: nobody → s
Comment on attachment 678745 [details] [diff] [review]
patch for accessKeyLabel if not set

For future reference, it is always better to request review from an actual person.
Attachment #678745 - Flags: review? → review?(Ms2ger)
Comment on attachment 678745 [details] [diff] [review]
patch for accessKeyLabel if not set

Review of attachment 678745 [details] [diff] [review]:
-----------------------------------------------------------------

Just two style issues. Please fix those, and ask for review from :smaug on the updated patch.

::: content/html/content/src/nsGenericHTMLElement.cpp
@@ +455,3 @@
>        nsAutoString suffix;
>        GetAccessKey(suffix);
> +      if(!suffix.IsEmpty() && presContext->EventStateManager()->GetAccessKeyLabelPrefix(aLabel))

You should add a space between 'if' and '(', and wrap the condition over two lines, so that the line isn't longer than 80 characters. (&& at the end.)
Attachment #678745 - Flags: review?(Ms2ger) → feedback+
OK, thanks Ms2ger !
Attached patch Patch V2 style issue (obsolete) — Splinter Review
fixing style issue
Attachment #678745 - Attachment is obsolete: true
Attachment #678826 - Flags: review?(bugs)
Comment on attachment 678826 [details] [diff] [review]
Patch V2 style issue

> NS_IMETHODIMP
> nsGenericHTMLElement::GetAccessKeyLabel(nsAString& aLabel)
> {
>   nsPresContext *presContext = GetPresContext();
> 
>-  if (presContext &&
>-    presContext->EventStateManager()->GetAccessKeyLabelPrefix(aLabel)) {
>+  if (presContext) {
>       nsAutoString suffix;
>       GetAccessKey(suffix);
>-      aLabel.Append(suffix);
>+      if (!suffix.IsEmpty() && 
>+	 presContext->EventStateManager()->GetAccessKeyLabelPrefix(aLabel))
You're using tab here. Only use spaces. prescontext should be aligned under !suffix
And always use {} with |if|
  if (expression) {
    stmt;
  }

Could you update the test 
http://mxr.mozilla.org/mozilla-central/source/content/html/content/test/test_bug583533.html?force=1
to test also this case when accessKeyLabel isn't there.
Attachment #678826 - Flags: review?(bugs) → review-
Sorry for the tabs, now I have setup my vimrc it should be fine.
and about the test, should I add a new element without accessKey and test or ... ?
Attached patch PatchV3 (obsolete) — Splinter Review
Here my solution, I've fixed tabs with vim to follow mozilla coding style. 
But I'm not sure about what I've wrote in the test file
Attachment #678826 - Attachment is obsolete: true
Attachment #679068 - Flags: review?(bugs)
I would have expected something like 
var div = document.createElement("div");
document.body.appendChild(div);
is(div.accessKeyLabel, "", "accessKeyLabel should be empty string");


And why you're modifying nsGenericHTMLElement::GetAccessKeyLabel, could you please
make it use 2 space indentation.
Attachment #679068 - Flags: review?(bugs) → review-
(In reply to Olli Pettay [:smaug] from comment #11)
> I would have expected something like 
> var div = document.createElement("div");
> document.body.appendChild(div);
> is(div.accessKeyLabel, "", "accessKeyLabel should be empty string");
> 
Okey I'll add this and the enf of the test file. should I specify that this is related to this bug in comment ?

> 
> And why you're modifying nsGenericHTMLElement::GetAccessKeyLabel, could you
> please
> make it use 2 space indentation.

Sorry but, It's not clear for me how did I modified nsGenericHTMLElement::GetAccessKeyLabel ? and how it should be ?
Oups I didn't noticed that i was connected with the other account !
(In reply to salexandre.bm from comment #12)
> Okey I'll add this and the enf of the test file. should I specify that this
> is related to this bug in comment ?
You can add some comment
// for bug 808964


> 
> > 
> > And why you're modifying nsGenericHTMLElement::GetAccessKeyLabel, could you
> > please
> > make it use 2 space indentation.
> 
> Sorry but, It's not clear for me how did I modified
> nsGenericHTMLElement::GetAccessKeyLabel ? and how it should be ?
Oops, I wasn't going to write 'why' but 'now that' or something like that.
Anyhow for example
       nsAutoString suffix;
       GetAccessKey(suffix);
have 4 space indentation from the |if|. Should be 2 spaces only.
Same with the |if| you're adding (the one which has aLabel.Append(suffix) in it).
Attached patch Patch v4Splinter Review
Attachment #679068 - Attachment is obsolete: true
Attachment #679125 - Flags: review?(bugs)
Comment on attachment 679125 [details] [diff] [review]
Patch v4

Thanks.

I'll push this to tryserver, and if everything looks good, push to mozilla-central.
Attachment #679125 - Flags: review?(bugs) → review+
Great :)
https://hg.mozilla.org/mozilla-central/rev/abac7a34e15c
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla19
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: