WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
140925
HTMLElement.dir should only return known values
https://bugs.webkit.org/show_bug.cgi?id=140925
Summary
HTMLElement.dir should only return known values
Chris Dumez
Reported
2015-01-26 22:13:07 PST
HTMLElement.dir should only return known values according to the HTML specification:
https://html.spec.whatwg.org/multipage/dom.html#dom-document-dir
Chrome and Firefox 28 match the specification. IE11's behavior is slightly different: - When setting an unknown 'dir' value, an exception will be thrown. (stricter than the spec) - Setting a known 'dir' value in a non-canonical case (e.g. "RTL"), the value will be directly converted to its canonical form (e.g. "rtl") before updating the DOM tree. (close to the spec but changing the case upon setting).
Attachments
Patch
(9.90 KB, patch)
2015-01-26 22:42 PST
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Chris Dumez
Comment 1
2015-01-26 22:42:50 PST
Created
attachment 245425
[details]
Patch
Darin Adler
Comment 2
2015-01-27 07:17:28 PST
Comment on
attachment 245425
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=245425&action=review
I made some comments but I still set commit-queue+. We can refine with a follow-up patch, I suppose.
> Source/WebCore/html/HTMLElement.cpp:466 > +// Returns the conforming 'dir' value associated with the state the attribute is in (in its canonical case), if any, > +// or the empty string if the attribute is in a state that has no associated keyword value or if the attribute is > +// not in a defined state (e.g. the attribute is missing and there is no missing value default). > +//
http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#limited-to-only-known-values
This comment is too long. There are patterns like this throughout the DOM and I don’t think every one needs such a long comment.
> Source/WebCore/html/HTMLElement.cpp:467 > +static inline const AtomicString& toValidDirValue(const AtomicString& value)
I don’t think this needs to be a separate function. I would just put this logic inside the dir function.
> Source/WebCore/html/HTMLElement.cpp:471 > + static NeverDestroyed<AtomicString> ltrValue("ltr", AtomicString::ConstructFromLiteral); > + static NeverDestroyed<AtomicString> rtlValue("rtl", AtomicString::ConstructFromLiteral); > + static NeverDestroyed<AtomicString> autoValue("auto", AtomicString::ConstructFromLiteral);
Why not define these inside the return statements instead of in a block at the top of the function? That would actually be slightly more efficient. We could also even consider adding these strings to the “commonly used atomic strings” list in AtomicString.h.
WebKit Commit Bot
Comment 3
2015-01-27 07:59:59 PST
Comment on
attachment 245425
[details]
Patch Clearing flags on attachment: 245425 Committed
r179181
: <
http://trac.webkit.org/changeset/179181
>
WebKit Commit Bot
Comment 4
2015-01-27 08:00:04 PST
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug