Closed
Bug 808964
Opened 13 years ago
Closed 13 years ago
AccessKeyLabel should be empty string for elements without the accesskey attribute
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
FIXED
mozilla19
People
(Reporter: listenleser, Assigned: s)
Details
(Whiteboard: [good first bug][mentor=Ms2ger][lang=c++])
Attachments
(1 file, 3 obsolete files)
|
1.81 KB,
patch
|
smaug
:
review+
|
Details | Diff | Splinter Review |
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."
Comment 1•13 years ago
|
||
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++]
| Assignee | ||
Comment 2•13 years ago
|
||
Okey let me try :)
| Assignee | ||
Comment 3•13 years ago
|
||
here my patch, it elt.accessKeyLabel returns an empty string if it's not set, "Alt+Shift+<key>" else.
Attachment #678745 -
Flags: review?
Updated•13 years ago
|
Assignee: nobody → s
Comment 4•13 years ago
|
||
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 5•13 years ago
|
||
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+
| Assignee | ||
Comment 6•13 years ago
|
||
OK, thanks Ms2ger !
| Assignee | ||
Comment 7•13 years ago
|
||
fixing style issue
Attachment #678745 -
Attachment is obsolete: true
Attachment #678826 -
Flags: review?(bugs)
Comment 8•13 years ago
|
||
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-
| Assignee | ||
Comment 9•13 years ago
|
||
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 ... ?
| Assignee | ||
Comment 10•13 years ago
|
||
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)
Comment 11•13 years ago
|
||
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.
Updated•13 years ago
|
Attachment #679068 -
Flags: review?(bugs) → review-
Comment 12•13 years ago
|
||
(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 ?
| Assignee | ||
Comment 13•13 years ago
|
||
Oups I didn't noticed that i was connected with the other account !
Comment 14•13 years ago
|
||
(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).
| Assignee | ||
Comment 15•13 years ago
|
||
Attachment #679068 -
Attachment is obsolete: true
Attachment #679125 -
Flags: review?(bugs)
Comment 16•13 years ago
|
||
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+
Comment 17•13 years ago
|
||
| Assignee | ||
Comment 18•13 years ago
|
||
Great :)
Comment 19•13 years ago
|
||
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Updated•13 years ago
|
Target Milestone: --- → mozilla19
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
•