Bug 140922 - Document.dir should reflect the 'dir' attribute of the root html element
Summary: Document.dir should reflect the 'dir' attribute of the root html element
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL: https://src.chromium.org/viewvc/blink...
Keywords: BlinkMergeCandidate
Depends on: 141480
Blocks:
  Show dependency treegraph
 
Reported: 2015-01-26 20:09 PST by Chris Dumez
Modified: 2015-02-11 11:53 PST (History)
7 users (show)

See Also:


Attachments
Patch (7.29 KB, patch)
2015-01-26 20:45 PST, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2015-01-26 20:09:36 PST
Document.dir should reflect the 'dir' content attribute of the root html element as per the specification:
http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#dom-document-dir

Currently, WebKit reflects the 'dir' content attribute of the body element. 
    
Firefox (tested v28) and IE (tested v11) and Chrome match the spec.
Comment 1 Chris Dumez 2015-01-26 20:45:06 PST
Created attachment 245408 [details]
Patch
Comment 2 Chris Dumez 2015-01-26 21:54:05 PST
Comment on attachment 245408 [details]
Patch

Clearing flags on attachment: 245408

Committed r179166: <http://trac.webkit.org/changeset/179166>
Comment 3 Chris Dumez 2015-01-26 21:54:12 PST
All reviewed patches have been landed.  Closing bug.
Comment 4 Sam Weinig 2015-02-11 10:48:03 PST
This caused a regression where we crash if the document has no root element when calling document.dir.  Filed https://bugs.webkit.org/show_bug.cgi?id=141480.
Comment 5 Chris Dumez 2015-02-11 11:53:14 PST
Comment on attachment 245408 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=245408&action=review

> Source/WebCore/html/HTMLDocument.cpp:111
> +    if (!is<HTMLHtmlElement>(*documentElement))

We need to stop dereferencing documentElement here as documentElement can be null. is<>() will take care of the null-check for us.