RESOLVED FIXED 50961
<title> should support dir attribute
https://bugs.webkit.org/show_bug.cgi?id=50961
Summary <title> should support dir attribute
Xiaomei Ji
Reported 2010-12-13 13:01:45 PST
Following is from the spec: User agents should use the document's title when referring to the document in their user interface. When the contents of a title element are used in this way, the directionality of that title element should be used to set the directionality of the document's title in the user interface. In addition, http://dev.w3.org/html5/spec/Overview.html#text-rendered-in-native-user-interfaces requires text from elements generally to be rendered in native user interfaces in a manner that honors the directionality of the element from which the text was obtained, mentioning dialogs, title bars, pop-up menus, and tooltips as particular examples.
Attachments
Patch (60.56 KB, patch)
2011-03-28 08:26 PDT, Evan Martin
no flags
Patch (62.94 KB, patch)
2011-03-29 03:38 PDT, Evan Martin
no flags
Patch (63.36 KB, patch)
2011-03-29 07:12 PDT, Evan Martin
no flags
Patch (63.60 KB, patch)
2011-03-30 06:05 PDT, Evan Martin
no flags
Patch (63.70 KB, patch)
2011-03-31 03:12 PDT, Evan Martin
no flags
Mac build fix (67.10 KB, patch)
2011-03-31 04:24 PDT, Ryosuke Niwa
no flags
Patch (71.62 KB, patch)
2011-03-31 04:43 PDT, Evan Martin
no flags
Patch (73.34 KB, patch)
2011-03-31 05:33 PDT, Evan Martin
no flags
Patch (74.91 KB, patch)
2011-03-31 05:41 PDT, Evan Martin
no flags
Patch (75.55 KB, patch)
2011-03-31 07:23 PDT, Evan Martin
eric: review+
Evan Martin
Comment 1 2011-03-27 02:16:57 PDT
Evan Martin
Comment 2 2011-03-28 08:26:42 PDT
Eric Seidel (no email)
Comment 3 2011-03-28 08:42:15 PDT
Comment on attachment 87148 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=87148&action=review > Source/WebCore/ChangeLog:11 > + Introduce a new StringWithDirection object that carries a String along > + with the TextDirection associated with the String. Use this object for > + document titles used within WebCore. Put FIXMEs at the WebKit level to > + expose the new direction information to clients. You might want to explain here that we need to do this so that titles can be stored in History as well as for display of the current page. > Source/WebCore/dom/Document.cpp:392 > + , m_title("", LTR) Just have a default constructor here and then you don't even need these lines. > Source/WebCore/dom/Document.cpp:1328 > + m_title = StringWithDirection(canonicalizedTitle(this, m_rawTitle.m_string), m_rawTitle.m_direction); Why not just pass the StringWithDirection to canonicalizedTitle() and then return one? > Source/WebCore/dom/Document.cpp:1335 > + setTitle(StringWithDirection(title, LTR), 0); You should comment here that this is called by the JavaScript document.title = "" setter and thus we always assume an LTR context. > Source/WebCore/dom/Document.cpp:1367 > + static_cast<HTMLTitleElement*>(m_titleElement.get())->setText(m_title.m_string); You should just add a string() accessor instead of grabbing at m_string. > Source/WebCore/dom/Document.h:816 > + void setTitle(const String&); You should comment here that these two are only used by teh DOM bindings. > Source/WebCore/dom/Document.h:1300 > + StringWithDirection m_title; > + StringWithDirection m_rawTitle; It seems that only one of these really needs the direction, or? > Source/WebCore/html/HTMLTitleElement.cpp:37 > + , m_title("", LTR) Default constructor and this goes away. :) > Source/WebCore/html/HTMLTitleElement.cpp:79 > +StringWithDirection HTMLTitleElement::textWithDirection() Should this be a const method? > Source/WebCore/html/HTMLTitleElement.cpp:81 > + RenderStyle* style = computedStyle(); I believe this can be NULL, do we need to check that? > Source/WebCore/loader/DocumentLoader.cpp:654 > + if (title.m_string.isEmpty()) You might add a isEmpty() accessor to StringWithDirection. Certainly string() woudl be nicer than m_string here. :) > Source/WebCore/loader/FrameLoader.cpp:615 > + if (!ptitle.m_string.isNull()) consider adding isNull(). > Source/WebCore/platform/text/StringWithDirection.h:55 > + TextDirection m_direction; I think you need to make it clear that this is the directional context of the string. I worry folks will get confused that this the "direction" of the string. It could be an LTR context but all hebrew and thus render as RTL, no? > Source/WebCore/svg/SVGTitleElement.cpp:44 > + // FIXME: does SVG have a concept of text direction? > + document()->setTitle(StringWithDirection(textContent(), LTR), this); There is "direction", but I don't think it applies to title elements. http://www.w3.org/TR/SVG/text.html#DirectionProperty
Early Warning System Bot
Comment 4 2011-03-28 08:43:21 PDT
Build Bot
Comment 5 2011-03-28 08:58:46 PDT
WebKit Review Bot
Comment 6 2011-03-28 12:51:36 PDT
Gustavo Noronha (kov)
Comment 7 2011-03-28 23:43:12 PDT
Evan Martin
Comment 8 2011-03-29 03:38:42 PDT
Early Warning System Bot
Comment 9 2011-03-29 03:53:37 PDT
Eric Seidel (no email)
Comment 10 2011-03-29 03:53:59 PDT
Comment on attachment 87293 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=87293&action=review Seems OK. > Source/WebCore/dom/Document.h:816 > + String title() const { return m_title.string(); } > + void setTitle(const String&); // Used by DOM bindings; no direction known. These two are used by teh DOM bindings, and you could separate them by a newline to indicate that. But this is also OK. > Source/WebCore/html/HTMLTitleElement.cpp:37 > + , m_title("", LTR) This is no longer needed, right? > Source/WebCore/loader/FrameLoader.cpp:615 > - if (!ptitle.isNull()) > + if (!ptitle.isEmpty()) We decided that the old isNull behavior was in error? > Source/WebCore/platform/text/StringWithDirection.h:50 > + StringWithDirection(const String& string, TextDirection dir) : m_string(string), m_direction(dir) {} Should this have a default parameter for dir? Then this could be implicitly constructed from string. i'm not sure if that's good or bad.
Build Bot
Comment 11 2011-03-29 04:52:15 PDT
Evan Martin
Comment 12 2011-03-29 07:12:11 PDT
Evan Martin
Comment 13 2011-03-29 07:15:46 PDT
This patch addresses Eric's comments, but I'll probably wait for some of the bots to pass it before I consider committing it.
Early Warning System Bot
Comment 14 2011-03-29 07:30:16 PDT
Ryosuke Niwa
Comment 15 2011-03-29 07:41:09 PDT
Comment on attachment 87312 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=87312&action=review > Source/WebCore/dom/Document.cpp:1338 > +void Document::setTitle(const StringWithDirection& title, Element* titleElement) I think this function is a little confusing. I feel as if this function will modify DOM to have the specified direction in the title.
Build Bot
Comment 16 2011-03-29 08:23:17 PDT
Build Bot
Comment 17 2011-03-29 08:45:23 PDT
Collabora GTK+ EWS bot
Comment 18 2011-03-29 12:02:37 PDT
WebKit Review Bot
Comment 19 2011-03-29 12:09:16 PDT
Evan Martin
Comment 20 2011-03-30 06:05:26 PDT
Early Warning System Bot
Comment 21 2011-03-30 06:31:05 PDT
Build Bot
Comment 22 2011-03-30 06:52:12 PDT
WebKit Review Bot
Comment 23 2011-03-30 09:07:56 PDT
Evan Martin
Comment 24 2011-03-31 03:12:34 PDT
Eric Seidel (no email)
Comment 25 2011-03-31 03:16:38 PDT
Comment on attachment 87687 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=87687&action=review This looks good to me. I suspect WebKit-level folks may have opinions. You should consider emailing webkit-dev once this lands and encouraging WebKit-level hackers to respect title directionality on their ports. > Source/WebCore/html/HTMLTitleElement.cpp:84 > + if (RenderStyle* style = computedStyle()) > + direction = style->direction(); > + else if (RefPtr<RenderStyle> style = styleForRenderer()) > + direction = style->direction(); Sad that we don't have a reliable way to get a style, always. (Not your fault of course).
Early Warning System Bot
Comment 26 2011-03-31 03:30:03 PDT
Build Bot
Comment 27 2011-03-31 03:42:32 PDT
Ryosuke Niwa
Comment 28 2011-03-31 04:24:37 PDT
Created attachment 87695 [details] Mac build fix
Evan Martin
Comment 29 2011-03-31 04:43:25 PDT
Early Warning System Bot
Comment 30 2011-03-31 05:09:30 PDT
Build Bot
Comment 31 2011-03-31 05:24:41 PDT
Evan Martin
Comment 32 2011-03-31 05:33:21 PDT
Evan Martin
Comment 33 2011-03-31 05:41:09 PDT
Build Bot
Comment 34 2011-03-31 06:13:39 PDT
Evan Martin
Comment 35 2011-03-31 07:23:42 PDT
Eric Seidel (no email)
Comment 36 2011-03-31 07:37:08 PDT
Comment on attachment 87722 [details] Patch Still looks fine.
Evan Martin
Comment 37 2011-03-31 08:17:24 PDT
WebKit Review Bot
Comment 38 2011-03-31 08:28:10 PDT
http://trac.webkit.org/changeset/82580 might have broken GTK Linux 32-bit Release and Qt Linux Release minimal
Note You need to log in before you can comment on or make changes to this bug.