2011-03-31  Evan Martin  <evan@chromium.org>

        Reviewed by Eric Seidel.

        <title> should support dir attribute
        https://bugs.webkit.org/show_bug.cgi?id=50961

        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, because in HTML the direction of
        a title can be set with the 'dir' attribute.

        Put FIXMEs at the WebKit level to expose the new direction information
        to clients.

        No behavioral change intended, so no new tests.  A follow-up will expose
        the title direction and hopefully can be accompanied by tests that
        verify it is correct.

        * dom/Document.cpp:
        (WebCore::Document::Document):
        (WebCore::Document::updateTitle):
        (WebCore::Document::setTitle):
        (WebCore::Document::removeTitle):
        * dom/Document.h:
        (WebCore::Document::title):
        * html/HTMLTitleElement.cpp:
        (WebCore::HTMLTitleElement::HTMLTitleElement):
        (WebCore::HTMLTitleElement::childrenChanged):
        (WebCore::HTMLTitleElement::text):
        (WebCore::HTMLTitleElement::textWithDirection):
        * html/HTMLTitleElement.h:
        * loader/DocumentLoader.cpp:
        (WebCore::DocumentLoader::setTitle):
        * loader/DocumentLoader.h:
        (WebCore::DocumentLoader::title):
        * loader/EmptyClients.h:
        (WebCore::EmptyFrameLoaderClient::dispatchDidReceiveTitle):
        (WebCore::EmptyFrameLoaderClient::setTitle):
        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::receivedFirstData):
        (WebCore::FrameLoader::commitProvisionalLoad):
        (WebCore::FrameLoader::setTitle):
        * loader/FrameLoader.h:
        * loader/FrameLoaderClient.h:
        * loader/HistoryController.cpp:
        (WebCore::HistoryController::updateForBackForwardNavigation):
        (WebCore::HistoryController::updateForReload):
        (WebCore::HistoryController::updateForRedirectWithLockedBackForwardList):
        (WebCore::HistoryController::updateForClientRedirect):
        (WebCore::HistoryController::updateForCommit):
        (WebCore::HistoryController::setCurrentItemTitle):
        (WebCore::HistoryController::initializeItem):
        * loader/HistoryController.h:
        * platform/text/StringWithDirection.h: Added.
        (WebCore::StringWithDirection::StringWithDirection):
        (WebCore::StringWithDirection::operator==):
        (WebCore::StringWithDirection::operator!=):
        * svg/SVGTitleElement.cpp:
        (WebCore::SVGTitleElement::insertedIntoDocument):
        (WebCore::SVGTitleElement::childrenChanged):
2011-03-31  Evan Martin  <evan@chromium.org>

        Reviewed by Eric Seidel.

        <title> should support dir attribute
        https://bugs.webkit.org/show_bug.cgi?id=50961

        Update to new FrameLoaderClient interface.

        * src/FrameLoaderClientImpl.cpp:
        (WebKit::FrameLoaderClientImpl::dispatchDidReceiveTitle):
        (WebKit::FrameLoaderClientImpl::setTitle):
        * src/FrameLoaderClientImpl.h:
        * src/WebDataSourceImpl.cpp:
        (WebKit::WebDataSourceImpl::pageTitle):
2011-03-31  Evan Martin  <evan@chromium.org>

        Reviewed by Eric Seidel.

        <title> should support dir attribute
        https://bugs.webkit.org/show_bug.cgi?id=50961

        Update to new FrameLoaderClient interface.

        * WebCoreSupport/FrameLoaderClientEfl.cpp:
        (WebCore::FrameLoaderClientEfl::dispatchDidReceiveTitle):
        (WebCore::FrameLoaderClientEfl::setTitle):
        * WebCoreSupport/FrameLoaderClientEfl.h:
2011-03-31  Evan Martin  <evan@chromium.org>

        Reviewed by Eric Seidel.

        <title> should support dir attribute
        https://bugs.webkit.org/show_bug.cgi?id=50961

        Update to new FrameLoaderClient interface.

        * WebCoreSupport/FrameLoaderClientGtk.cpp:
        (WebKit::FrameLoaderClient::dispatchDidReceiveTitle):
        (WebKit::FrameLoaderClient::setTitle):
        * WebCoreSupport/FrameLoaderClientGtk.h:
2011-03-31  Evan Martin  <evan@chromium.org>

        Reviewed by Eric Seidel.

        <title> should support dir attribute
        https://bugs.webkit.org/show_bug.cgi?id=50961

        Update to new FrameLoaderClient interface.

        * WebCoreSupport/FrameLoaderClientHaiku.cpp:
        (WebCore::FrameLoaderClientHaiku::dispatchDidReceiveTitle):
        * WebCoreSupport/FrameLoaderClientHaiku.h:
2011-03-31  Evan Martin  <evan@chromium.org>

        Reviewed by Eric Seidel.

        <title> should support dir attribute
        https://bugs.webkit.org/show_bug.cgi?id=50961

        Update to new FrameLoaderClient interface.

        * WebCoreSupport/WebFrameLoaderClient.h:
        * WebCoreSupport/WebFrameLoaderClient.mm:
        (WebFrameLoaderClient::dispatchDidReceiveTitle):
        (WebFrameLoaderClient::setTitle):
2011-03-31  Evan Martin  <evan@chromium.org>

        Reviewed by Eric Seidel.

        <title> should support dir attribute
        https://bugs.webkit.org/show_bug.cgi?id=50961

        Update to new FrameLoaderClient interface.

        * WebCoreSupport/FrameLoaderClientQt.cpp:
        (WebCore::FrameLoaderClientQt::dispatchDidReceiveTitle):
        (WebCore::FrameLoaderClientQt::setTitle):
        * WebCoreSupport/FrameLoaderClientQt.h:
2011-03-31  Evan Martin  <evan@chromium.org>

        Reviewed by Eric Seidel.

        <title> should support dir attribute
        https://bugs.webkit.org/show_bug.cgi?id=50961

        Update to new FrameLoaderClient interface.

        * WebCoreSupport/WebFrameLoaderClient.cpp:
        (WebFrameLoaderClient::dispatchDidReceiveTitle):
        * WebCoreSupport/WebFrameLoaderClient.h:
2011-03-31  Evan Martin  <evan@chromium.org>

        Reviewed by Eric Seidel.

        <title> should support dir attribute
        https://bugs.webkit.org/show_bug.cgi?id=50961

        Update to new FrameLoaderClient interface.

        * WebCoreSupport/FrameLoaderClientWinCE.cpp:
        (WebKit::FrameLoaderClientWinCE::dispatchDidReceiveTitle):
        (WebKit::FrameLoaderClientWinCE::setTitle):
        * WebCoreSupport/FrameLoaderClientWinCE.h:
2011-03-31  Evan Martin  <evan@chromium.org>

        Reviewed by Eric Seidel.

        <title> should support dir attribute
        https://bugs.webkit.org/show_bug.cgi?id=50961

        Update to new FrameLoaderClient interface.

        * WebKitSupport/FrameLoaderClientWx.cpp:
        (WebCore::FrameLoaderClientWx::dispatchDidReceiveTitle):
        (WebCore::FrameLoaderClientWx::setTitle):
        * WebKitSupport/FrameLoaderClientWx.h:
2011-03-31  Evan Martin  <evan@chromium.org>

        Reviewed by Eric Seidel.

        <title> should support dir attribute
        https://bugs.webkit.org/show_bug.cgi?id=50961

        Update to new FrameLoaderClient interface.

        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
        (WebKit::WebFrameLoaderClient::dispatchDidReceiveTitle):
        (WebKit::WebFrameLoaderClient::setTitle):
        * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@82580 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 9f08a12..1d50ded45 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,65 @@
+2011-03-31  Evan Martin  <evan@chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        <title> should support dir attribute
+        https://bugs.webkit.org/show_bug.cgi?id=50961
+
+        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, because in HTML the direction of
+        a title can be set with the 'dir' attribute.
+
+        Put FIXMEs at the WebKit level to expose the new direction information
+        to clients.
+
+        No behavioral change intended, so no new tests.  A follow-up will expose
+        the title direction and hopefully can be accompanied by tests that
+        verify it is correct.
+
+        * dom/Document.cpp:
+        (WebCore::Document::Document):
+        (WebCore::Document::updateTitle):
+        (WebCore::Document::setTitle):
+        (WebCore::Document::removeTitle):
+        * dom/Document.h:
+        (WebCore::Document::title):
+        * html/HTMLTitleElement.cpp:
+        (WebCore::HTMLTitleElement::HTMLTitleElement):
+        (WebCore::HTMLTitleElement::childrenChanged):
+        (WebCore::HTMLTitleElement::text):
+        (WebCore::HTMLTitleElement::textWithDirection):
+        * html/HTMLTitleElement.h:
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::setTitle):
+        * loader/DocumentLoader.h:
+        (WebCore::DocumentLoader::title):
+        * loader/EmptyClients.h:
+        (WebCore::EmptyFrameLoaderClient::dispatchDidReceiveTitle):
+        (WebCore::EmptyFrameLoaderClient::setTitle):
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::receivedFirstData):
+        (WebCore::FrameLoader::commitProvisionalLoad):
+        (WebCore::FrameLoader::setTitle):
+        * loader/FrameLoader.h:
+        * loader/FrameLoaderClient.h:
+        * loader/HistoryController.cpp:
+        (WebCore::HistoryController::updateForBackForwardNavigation):
+        (WebCore::HistoryController::updateForReload):
+        (WebCore::HistoryController::updateForRedirectWithLockedBackForwardList):
+        (WebCore::HistoryController::updateForClientRedirect):
+        (WebCore::HistoryController::updateForCommit):
+        (WebCore::HistoryController::setCurrentItemTitle):
+        (WebCore::HistoryController::initializeItem):
+        * loader/HistoryController.h:
+        * platform/text/StringWithDirection.h: Added.
+        (WebCore::StringWithDirection::StringWithDirection):
+        (WebCore::StringWithDirection::operator==):
+        (WebCore::StringWithDirection::operator!=):
+        * svg/SVGTitleElement.cpp:
+        (WebCore::SVGTitleElement::insertedIntoDocument):
+        (WebCore::SVGTitleElement::childrenChanged):
+
 2011-03-31  Alexander Pavlov  <apavlov@chromium.org>
 
         Reviewed by Yury Semikhatsky.
diff --git a/Source/WebCore/GNUmakefile.am b/Source/WebCore/GNUmakefile.am
index e2c49b4..88a1f07b 100644
--- a/Source/WebCore/GNUmakefile.am
+++ b/Source/WebCore/GNUmakefile.am
@@ -2689,6 +2689,7 @@
 	Source/WebCore/platform/text/SegmentedString.cpp \
 	Source/WebCore/platform/text/SegmentedString.h \
 	Source/WebCore/platform/text/String.cpp \
+	Source/WebCore/platform/text/StringWithDirection.h \
 	Source/WebCore/platform/text/SuffixTree.h \
 	Source/WebCore/platform/text/TextBoundaries.cpp \
 	Source/WebCore/platform/text/TextBoundaries.h \
diff --git a/Source/WebCore/WebCore.exp.in b/Source/WebCore/WebCore.exp.in
index f43cd5b..1b2a9c2 100644
--- a/Source/WebCore/WebCore.exp.in
+++ b/Source/WebCore/WebCore.exp.in
@@ -341,7 +341,7 @@
 __ZN7WebCore14DocumentLoader24removePlugInStreamLoaderEPNS_14ResourceLoaderE
 __ZN7WebCore14DocumentLoader7requestEv
 __ZN7WebCore14DocumentLoader8setFrameEPNS_5FrameE
-__ZN7WebCore14DocumentLoader8setTitleERKN3WTF6StringE
+__ZN7WebCore14DocumentLoader8setTitleERKNS_19StringWithDirectionE
 __ZN7WebCore14DocumentLoaderC1ERKNS_15ResourceRequestERKNS_14SubstituteDataE
 __ZN7WebCore14DocumentLoaderC2ERKNS_15ResourceRequestERKNS_14SubstituteDataE
 __ZN7WebCore14DocumentLoaderD2Ev
diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi
index 87cefa3..ef071dc 100644
--- a/Source/WebCore/WebCore.gypi
+++ b/Source/WebCore/WebCore.gypi
@@ -4844,6 +4844,7 @@
             'platform/text/RegularExpression.cpp',
             'platform/text/SegmentedString.cpp',
             'platform/text/String.cpp',
+            'platform/text/StringWithDirection.h',
             'platform/text/SuffixTree.h',
             'platform/text/TextBoundaries.cpp',
             'platform/text/TextBreakIteratorICU.cpp',
diff --git a/Source/WebCore/WebCore.vcproj/WebCore.vcproj b/Source/WebCore/WebCore.vcproj/WebCore.vcproj
index afdb455..edb7079 100755
--- a/Source/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/Source/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -30533,6 +30533,10 @@
 					>
 				</File>
 				<File
+					RelativePath="..\platform\text\StringWithDirection.h"
+					>
+				</File>
+				<File
 					RelativePath="..\platform\text\SuffixTree.h"
 					>
 				</File>
diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
index fe182f0..8a7ec17 100644
--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -3130,6 +3130,7 @@
 		98EB1F951313FE0500D0E1EA /* NotImplemented.h in Headers */ = {isa = PBXBuildFile; fileRef = 98EB1F941313FE0500D0E1EA /* NotImplemented.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		9B417064125662B3006B28FC /* ApplyBlockElementCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B417062125662B3006B28FC /* ApplyBlockElementCommand.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		9B417065125662B3006B28FC /* ApplyBlockElementCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B417063125662B3006B28FC /* ApplyBlockElementCommand.cpp */; };
+		9B6C41531344949000085B62 /* StringWithDirection.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B6C41521344949000085B62 /* StringWithDirection.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		9BAB6C6C12550631001626D4 /* EditingStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BAB6C6A12550631001626D4 /* EditingStyle.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		9BAB6C6D12550631001626D4 /* EditingStyle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BAB6C6B12550631001626D4 /* EditingStyle.cpp */; };
 		9BAF3B2412C1A39800014BF1 /* WritingDirection.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BAF3B2312C1A39800014BF1 /* WritingDirection.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -9632,6 +9633,7 @@
 		98EB1F941313FE0500D0E1EA /* NotImplemented.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NotImplemented.h; sourceTree = "<group>"; };
 		9B417062125662B3006B28FC /* ApplyBlockElementCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplyBlockElementCommand.h; sourceTree = "<group>"; };
 		9B417063125662B3006B28FC /* ApplyBlockElementCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ApplyBlockElementCommand.cpp; sourceTree = "<group>"; };
+		9B6C41521344949000085B62 /* StringWithDirection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringWithDirection.h; sourceTree = "<group>"; };
 		9BAB6C6A12550631001626D4 /* EditingStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditingStyle.h; sourceTree = "<group>"; };
 		9BAB6C6B12550631001626D4 /* EditingStyle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EditingStyle.cpp; sourceTree = "<group>"; };
 		9BAF3B2312C1A39800014BF1 /* WritingDirection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WritingDirection.h; sourceTree = "<group>"; };
@@ -17801,6 +17803,7 @@
 				B2C3D9FE0D006C1D00EF6F26 /* SegmentedString.cpp */,
 				B2C3D9FF0D006C1D00EF6F26 /* SegmentedString.h */,
 				B2C3DA000D006C1D00EF6F26 /* String.cpp */,
+				9B6C41521344949000085B62 /* StringWithDirection.h */,
 				97C0784F1165D5BE003A32EF /* SuffixTree.h */,
 				372C00C3129611F1005C9575 /* TextBoundaries.cpp */,
 				B2C3DA040D006C1D00EF6F26 /* TextBoundaries.h */,
@@ -22261,6 +22264,7 @@
 				3AB02D2A12D4F91600FBB694 /* StorageTracker.h in Headers */,
 				3AC3680012EF7A09006A3D6F /* StorageTrackerClient.h in Headers */,
 				81AC6C36131C57D30009A7E0 /* StringCallback.h in Headers */,
+				9B6C41531344949000085B62 /* StringWithDirection.h in Headers */,
 				65488D6B0DD5A83D009D83B2 /* StringSourceProvider.h in Headers */,
 				B23540F30D00782E002382FA /* StringTruncator.h in Headers */,
 				849F77760EFEC6200090849D /* StrokeStyleApplier.h in Headers */,
diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp
index e3d7f53..5144703 100644
--- a/Source/WebCore/dom/Document.cpp
+++ b/Source/WebCore/dom/Document.cpp
@@ -389,8 +389,6 @@
     , m_containsValidityStyleRules(false)
     , m_updateFocusAppearanceRestoresSelection(false)
     , m_ignoreDestructiveWriteCount(0)
-    , m_title("")
-    , m_rawTitle("")
     , m_titleSetExplicitly(false)
     , m_updateFocusAppearanceTimer(this, &Document::updateFocusAppearanceTimerFired)
     , m_startTime(currentTime())
@@ -1271,8 +1269,9 @@
  *  2. Trim leading and trailing spaces
  *  3. Collapse internal whitespace.
  */
-static inline String canonicalizedTitle(Document* document, const String& title)
+static inline StringWithDirection canonicalizedTitle(Document* document, const StringWithDirection& titleWithDirection)
 {
+    const String& title = titleWithDirection.string();
     const UChar* characters = title.characters();
     unsigned length = title.length();
     unsigned i;
@@ -1288,7 +1287,7 @@
     }
 
     if (i == length)
-        return "";
+        return StringWithDirection();
 
     // Replace control characters with spaces, and backslashes with currency symbols, and collapse whitespace.
     bool previousCharWasWS = false;
@@ -1313,17 +1312,17 @@
     }
 
     if (!builderIndex && buffer[builderIndex] == ' ')
-        return "";
+        return StringWithDirection();
 
     buffer.shrink(builderIndex + 1);
 
     // Replace the backslashes with currency symbols if the encoding requires it.
     document->displayBufferModifiedByEncoding(buffer.characters(), buffer.length());
     
-    return String::adopt(buffer);
+    return StringWithDirection(String::adopt(buffer), titleWithDirection.direction());
 }
 
-void Document::updateTitle(const String& title)
+void Document::updateTitle(const StringWithDirection& title)
 {
     if (m_rawTitle == title)
         return;
@@ -1349,16 +1348,17 @@
         }
     }
 
-    updateTitle(title);
+    // The DOM API has no method of specifying direction, so assume LTR.
+    updateTitle(StringWithDirection(title, LTR));
 
     if (m_titleElement) {
         ASSERT(m_titleElement->hasTagName(titleTag));
         if (m_titleElement->hasTagName(titleTag))
-            static_cast<HTMLTitleElement*>(m_titleElement.get())->setText(m_title);
+            static_cast<HTMLTitleElement*>(m_titleElement.get())->setText(title);
     }
 }
 
-void Document::setTitleElement(const String& title, Element* titleElement)
+void Document::setTitleElement(const StringWithDirection& title, Element* titleElement)
 {
     if (titleElement != m_titleElement) {
         if (m_titleElement || m_titleSetExplicitly)
@@ -1383,13 +1383,13 @@
         for (Node* e = headElement->firstChild(); e; e = e->nextSibling())
             if (e->hasTagName(titleTag)) {
                 HTMLTitleElement* titleElement = static_cast<HTMLTitleElement*>(e);
-                setTitleElement(titleElement->text(), titleElement);
+                setTitleElement(titleElement->textWithDirection(), titleElement);
                 break;
             }
     }
 
     if (!m_titleElement)
-        updateTitle("");
+        updateTitle(StringWithDirection());
 }
 
 String Document::nodeName() const
diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h
index 05dfb76..8a83d59 100644
--- a/Source/WebCore/dom/Document.h
+++ b/Source/WebCore/dom/Document.h
@@ -37,6 +37,7 @@
 #include "DocumentTiming.h"
 #include "QualifiedName.h"
 #include "ScriptExecutionContext.h"
+#include "StringWithDirection.h"
 #include "Timer.h"
 #include "ViewportArguments.h"
 #include <wtf/FixedArray.h>
@@ -811,9 +812,11 @@
     // Returns 0 if this is the top level document.
     HTMLFrameOwnerElement* ownerElement() const;
 
-    String title() const { return m_title; }
+    // Used by DOM bindings; no direction known.
+    String title() const { return m_title.string(); }
     void setTitle(const String&);
-    void setTitleElement(const String& title, Element* titleElement);
+
+    void setTitleElement(const StringWithDirection&, Element* titleElement);
     void removeTitle(Element* titleElement);
 
     String cookie(ExceptionCode&) const;
@@ -1158,7 +1161,7 @@
 
     String encoding() const;
 
-    void updateTitle(const String& title);
+    void updateTitle(const StringWithDirection&);
     void updateFocusAppearanceTimerFired(Timer<Document>*);
     void updateBaseURL();
 
@@ -1295,8 +1298,8 @@
     // http://www.whatwg.org/specs/web-apps/current-work/#ignore-destructive-writes-counter
     unsigned m_ignoreDestructiveWriteCount;
 
-    String m_title;
-    String m_rawTitle;
+    StringWithDirection m_title;
+    StringWithDirection m_rawTitle;
     bool m_titleSetExplicitly;
     RefPtr<Element> m_titleElement;
 
diff --git a/Source/WebCore/html/HTMLTitleElement.cpp b/Source/WebCore/html/HTMLTitleElement.cpp
index 78c8b6a..b046c7b 100644
--- a/Source/WebCore/html/HTMLTitleElement.cpp
+++ b/Source/WebCore/html/HTMLTitleElement.cpp
@@ -25,6 +25,7 @@
 
 #include "Document.h"
 #include "HTMLNames.h"
+#include "RenderStyle.h"
 #include "Text.h"
 
 namespace WebCore {
@@ -33,7 +34,6 @@
 
 inline HTMLTitleElement::HTMLTitleElement(const QualifiedName& tagName, Document* document)
     : HTMLElement(tagName, document)
-    , m_title("")
 {
     ASSERT(hasTagName(titleTag));
 }
@@ -57,7 +57,7 @@
 
 void HTMLTitleElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
 {
-    m_title = text();
+    m_title = textWithDirection();
     if (inDocument())
         document()->setTitleElement(m_title, this);
     HTMLElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
@@ -71,10 +71,20 @@
         if (n->isTextNode())
             val += static_cast<Text*>(n)->data();
     }
-    
+
     return val;
 }
 
+StringWithDirection HTMLTitleElement::textWithDirection()
+{
+    TextDirection direction = LTR;
+    if (RenderStyle* style = computedStyle())
+        direction = style->direction();
+    else if (RefPtr<RenderStyle> style = styleForRenderer())
+        direction = style->direction();
+    return StringWithDirection(text(), direction);
+}
+
 void HTMLTitleElement::setText(const String &value)
 {
     ExceptionCode ec = 0;
diff --git a/Source/WebCore/html/HTMLTitleElement.h b/Source/WebCore/html/HTMLTitleElement.h
index 8b90f56..6920997 100644
--- a/Source/WebCore/html/HTMLTitleElement.h
+++ b/Source/WebCore/html/HTMLTitleElement.h
@@ -23,6 +23,7 @@
 #define HTMLTitleElement_h
 
 #include "HTMLElement.h"
+#include "StringWithDirection.h"
 
 namespace WebCore {
 
@@ -33,6 +34,8 @@
     String text() const;
     void setText(const String&);
 
+    StringWithDirection textWithDirection();
+
 private:
     HTMLTitleElement(const QualifiedName&, Document*);
 
@@ -40,7 +43,7 @@
     virtual void removedFromDocument();
     virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
 
-    String m_title;
+    StringWithDirection m_title;
 };
 
 } //namespace
diff --git a/Source/WebCore/loader/DocumentLoader.cpp b/Source/WebCore/loader/DocumentLoader.cpp
index 121045b..1437adc 100644
--- a/Source/WebCore/loader/DocumentLoader.cpp
+++ b/Source/WebCore/loader/DocumentLoader.cpp
@@ -649,7 +649,7 @@
     m_stopRecordingResponses = true;
 }
 
-void DocumentLoader::setTitle(const String& title)
+void DocumentLoader::setTitle(const StringWithDirection& title)
 {
     if (title.isEmpty())
         return;
diff --git a/Source/WebCore/loader/DocumentLoader.h b/Source/WebCore/loader/DocumentLoader.h
index 1f88272..c6f0bc5 100644
--- a/Source/WebCore/loader/DocumentLoader.h
+++ b/Source/WebCore/loader/DocumentLoader.h
@@ -36,6 +36,7 @@
 #include "ResourceError.h"
 #include "ResourceRequest.h"
 #include "ResourceResponse.h"
+#include "StringWithDirection.h"
 #include "SubstituteData.h"
 #include "Timer.h"
 #include <wtf/HashSet.h>
@@ -121,7 +122,7 @@
         bool wasOnloadHandled() { return m_wasOnloadHandled; }
         bool isLoadingInAPISense() const;
         void setPrimaryLoadComplete(bool);
-        void setTitle(const String&);
+        void setTitle(const StringWithDirection&);
         void setIconURL(const String&);
         const String& overrideEncoding() const { return m_overrideEncoding; }
 
@@ -168,7 +169,7 @@
         const ResourceRequest& lastCheckedRequest()  { return m_lastCheckedRequest; }
 
         void stopRecordingResponses();
-        const String& title() const { return m_pageTitle; }
+        const StringWithDirection& title() const { return m_pageTitle; }
         const String& iconURL() const { return m_pageIconURL; }
 
         KURL urlForHistory() const;
@@ -298,7 +299,7 @@
         bool m_isClientRedirect;
         bool m_wasOnloadHandled;
 
-        String m_pageTitle;
+        StringWithDirection m_pageTitle;
         String m_pageIconURL;
 
         String m_overrideEncoding;
diff --git a/Source/WebCore/loader/EmptyClients.h b/Source/WebCore/loader/EmptyClients.h
index 59fd897..6acf992 100644
--- a/Source/WebCore/loader/EmptyClients.h
+++ b/Source/WebCore/loader/EmptyClients.h
@@ -266,7 +266,7 @@
     virtual void dispatchWillClose() { }
     virtual void dispatchDidReceiveIcon() { }
     virtual void dispatchDidStartProvisionalLoad() { }
-    virtual void dispatchDidReceiveTitle(const String&) { }
+    virtual void dispatchDidReceiveTitle(const StringWithDirection&) { }
     virtual void dispatchDidChangeIcons() { }
     virtual void dispatchDidCommitLoad() { }
     virtual void dispatchDidFailProvisionalLoad(const ResourceError&) { }
@@ -334,7 +334,7 @@
     virtual void prepareForDataSourceReplacement() { }
 
     virtual PassRefPtr<DocumentLoader> createDocumentLoader(const ResourceRequest& request, const SubstituteData& substituteData) { return DocumentLoader::create(request, substituteData); }
-    virtual void setTitle(const String&, const KURL&) { }
+    virtual void setTitle(const StringWithDirection&, const KURL&) { }
 
     virtual String userAgent(const KURL&) { return ""; }
 
diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp
index 347a41e..f1020e1 100644
--- a/Source/WebCore/loader/FrameLoader.cpp
+++ b/Source/WebCore/loader/FrameLoader.cpp
@@ -610,7 +610,7 @@
     dispatchDidClearWindowObjectsInAllWorlds();
     
     if (m_documentLoader) {
-        String ptitle = m_documentLoader->title();
+        StringWithDirection ptitle = m_documentLoader->title();
         // If we have a title let the WebView know about it.
         if (!ptitle.isNull())
             m_client->dispatchDidReceiveTitle(ptitle);
@@ -1924,9 +1924,9 @@
         dispatchDidCommitLoad();
 
         // If we have a title let the WebView know about it. 
-        String title = m_documentLoader->title();
-        if (!title.isNull()) 
-            m_client->dispatchDidReceiveTitle(title);         
+        StringWithDirection title = m_documentLoader->title();
+        if (!title.isNull())
+            m_client->dispatchDidReceiveTitle(title);
 
         checkCompleted();
     } else {        
@@ -3375,7 +3375,7 @@
 }
 #endif
 
-void FrameLoader::setTitle(const String& title)
+void FrameLoader::setTitle(const StringWithDirection& title)
 {
     documentLoader()->setTitle(title);
 }
diff --git a/Source/WebCore/loader/FrameLoader.h b/Source/WebCore/loader/FrameLoader.h
index 1fb9e3c..9062f21 100644
--- a/Source/WebCore/loader/FrameLoader.h
+++ b/Source/WebCore/loader/FrameLoader.h
@@ -78,6 +78,7 @@
 class SecurityOrigin;
 class SerializedScriptValue;
 class SharedBuffer;
+class StringWithDirection;
 class SubstituteData;
 class TextResourceDecoder;
 
@@ -282,7 +283,7 @@
 
     void cancelAndClear();
 
-    void setTitle(const String&);
+    void setTitle(const StringWithDirection&);
     void setIconURL(const String&);
 
     void commitProvisionalLoad();
diff --git a/Source/WebCore/loader/FrameLoaderClient.h b/Source/WebCore/loader/FrameLoaderClient.h
index 7d64912..d5d49ec 100644
--- a/Source/WebCore/loader/FrameLoaderClient.h
+++ b/Source/WebCore/loader/FrameLoaderClient.h
@@ -84,6 +84,7 @@
     class ResourceResponse;
     class SecurityOrigin;
     class SharedBuffer;
+    class StringWithDirection;
     class SubstituteData;
     class Widget;
 
@@ -139,7 +140,7 @@
         virtual void dispatchWillClose() = 0;
         virtual void dispatchDidReceiveIcon() = 0;
         virtual void dispatchDidStartProvisionalLoad() = 0;
-        virtual void dispatchDidReceiveTitle(const String& title) = 0;
+        virtual void dispatchDidReceiveTitle(const StringWithDirection&) = 0;
         virtual void dispatchDidChangeIcons() = 0;
         virtual void dispatchDidCommitLoad() = 0;
         virtual void dispatchDidFailProvisionalLoad(const ResourceError&) = 0;
@@ -227,7 +228,7 @@
         virtual void prepareForDataSourceReplacement() = 0;
 
         virtual PassRefPtr<DocumentLoader> createDocumentLoader(const ResourceRequest&, const SubstituteData&) = 0;
-        virtual void setTitle(const String& title, const KURL&) = 0;
+        virtual void setTitle(const StringWithDirection&, const KURL&) = 0;
 
         virtual String userAgent(const KURL&) = 0;
         
diff --git a/Source/WebCore/loader/HistoryController.cpp b/Source/WebCore/loader/HistoryController.cpp
index b8bece9..c1c5414 100644
--- a/Source/WebCore/loader/HistoryController.cpp
+++ b/Source/WebCore/loader/HistoryController.cpp
@@ -265,7 +265,7 @@
 {
 #if !LOG_DISABLED
     if (m_frame->loader()->documentLoader())
-        LOG(History, "WebCoreHistory: Updating History for back/forward navigation in frame %s", m_frame->loader()->documentLoader()->title().utf8().data());
+        LOG(History, "WebCoreHistory: Updating History for back/forward navigation in frame %s", m_frame->loader()->documentLoader()->title().string().utf8().data());
 #endif
 
     // Must grab the current scroll position before disturbing it
@@ -281,7 +281,7 @@
 {
 #if !LOG_DISABLED
     if (m_frame->loader()->documentLoader())
-        LOG(History, "WebCoreHistory: Updating History for reload in frame %s", m_frame->loader()->documentLoader()->title().utf8().data());
+        LOG(History, "WebCoreHistory: Updating History for reload in frame %s", m_frame->loader()->documentLoader()->title().string().utf8().data());
 #endif
 
     if (m_currentItem) {
@@ -343,7 +343,7 @@
 {
 #if !LOG_DISABLED
     if (m_frame->loader()->documentLoader())
-        LOG(History, "WebCoreHistory: Updating History for redirect load in frame %s", m_frame->loader()->documentLoader()->title().utf8().data());
+        LOG(History, "WebCoreHistory: Updating History for redirect load in frame %s", m_frame->loader()->documentLoader()->title().string().utf8().data());
 #endif
     
     Settings* settings = m_frame->settings();
@@ -385,7 +385,7 @@
 {
 #if !LOG_DISABLED
     if (m_frame->loader()->documentLoader())
-        LOG(History, "WebCoreHistory: Updating History for client redirect in frame %s", m_frame->loader()->documentLoader()->title().utf8().data());
+        LOG(History, "WebCoreHistory: Updating History for client redirect in frame %s", m_frame->loader()->documentLoader()->title().string().utf8().data());
 #endif
 
     // Clear out form data so we don't try to restore it into the incoming page.  Must happen after
@@ -410,7 +410,7 @@
     FrameLoader* frameLoader = m_frame->loader();
 #if !LOG_DISABLED
     if (frameLoader->documentLoader())
-        LOG(History, "WebCoreHistory: Updating History for commit in frame %s", frameLoader->documentLoader()->title().utf8().data());
+        LOG(History, "WebCoreHistory: Updating History for commit in frame %s", frameLoader->documentLoader()->title().string().utf8().data());
 #endif
     FrameLoadType type = frameLoader->loadType();
     if (isBackForwardLoadType(type)
@@ -526,10 +526,11 @@
     m_currentItem = item;
 }
 
-void HistoryController::setCurrentItemTitle(const String& title)
+void HistoryController::setCurrentItemTitle(const StringWithDirection& title)
 {
     if (m_currentItem)
-        m_currentItem->setTitle(title);
+        // FIXME: make use of title.direction() as well.
+        m_currentItem->setTitle(title.string());
 }
 
 bool HistoryController::currentItemShouldBeReplaced() const
@@ -576,12 +577,13 @@
     
     Frame* parentFrame = m_frame->tree()->parent();
     String parent = parentFrame ? parentFrame->tree()->uniqueName() : "";
-    String title = documentLoader->title();
+    StringWithDirection title = documentLoader->title();
 
     item->setURL(url);
     item->setTarget(m_frame->tree()->uniqueName());
     item->setParent(parent);
-    item->setTitle(title);
+    // FIXME: should store title directionality in history as well.
+    item->setTitle(title.string());
     item->setOriginalURLString(originalURL.string());
 
     if (!unreachableURL.isEmpty() || documentLoader->response().httpStatusCode() >= 400)
diff --git a/Source/WebCore/loader/HistoryController.h b/Source/WebCore/loader/HistoryController.h
index 59f11a2..15e12c0 100644
--- a/Source/WebCore/loader/HistoryController.h
+++ b/Source/WebCore/loader/HistoryController.h
@@ -40,6 +40,7 @@
 class Frame;
 class HistoryItem;
 class SerializedScriptValue;
+class StringWithDirection;
 
 class HistoryController {
     WTF_MAKE_NONCOPYABLE(HistoryController);
@@ -71,7 +72,7 @@
 
     HistoryItem* currentItem() const { return m_currentItem.get(); }
     void setCurrentItem(HistoryItem*);
-    void setCurrentItemTitle(const String&);
+    void setCurrentItemTitle(const StringWithDirection&);
     bool currentItemShouldBeReplaced() const;
 
     HistoryItem* previousItem() const { return m_previousItem.get(); }
diff --git a/Source/WebCore/platform/text/StringWithDirection.h b/Source/WebCore/platform/text/StringWithDirection.h
new file mode 100644
index 0000000..ea34ab6
--- /dev/null
+++ b/Source/WebCore/platform/text/StringWithDirection.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef StringWithDirection_h
+#define StringWithDirection_h
+
+#include "PlatformString.h"
+#include "TextDirection.h"
+
+namespace WebCore {
+
+// In some circumstances we want to store a String along with the TextDirection
+// of the String as learned from the context of the String. For example,
+// consider storing the title derived from <title dir='rtl'>some title</title>
+// in the history.
+//
+// Note that is explicitly *not* the direction of the string as learned
+// from the characters of the string; it's extra metadata we have external
+// to the string.
+class StringWithDirection {
+public:
+    StringWithDirection() {}
+    StringWithDirection(const String& string, TextDirection dir) : m_string(string), m_direction(dir) {}
+
+    const String& string() const { return m_string; }
+    TextDirection direction() const { return m_direction; }
+
+    bool isEmpty() const { return m_string.isEmpty(); }
+    bool isNull() const { return m_string.isNull(); }
+
+    bool operator==(const StringWithDirection& other) const
+    {
+        return other.m_string == m_string && other.m_direction == m_direction;
+    }
+    bool operator!=(const StringWithDirection& other) const { return !((*this) == other); }
+
+private:
+    String m_string;
+    TextDirection m_direction;
+};
+
+}
+
+#endif // StringWithDirection_h
diff --git a/Source/WebCore/svg/SVGTitleElement.cpp b/Source/WebCore/svg/SVGTitleElement.cpp
index ebcddb4..d925603 100644
--- a/Source/WebCore/svg/SVGTitleElement.cpp
+++ b/Source/WebCore/svg/SVGTitleElement.cpp
@@ -40,7 +40,8 @@
 {
     SVGStyledElement::insertedIntoDocument();
     if (firstChild())
-        document()->setTitleElement(textContent(), this);
+        // FIXME: does SVG have a title text direction?
+        document()->setTitleElement(StringWithDirection(textContent(), LTR), this);
 }
 
 void SVGTitleElement::removedFromDocument()
@@ -53,7 +54,8 @@
 {
     SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
     if (inDocument())
-        document()->setTitleElement(textContent(), this);
+        // FIXME: does SVG have title text direction?
+        document()->setTitleElement(StringWithDirection(textContent(), LTR), this);
 }
 
 AttributeToPropertyTypeMap& SVGTitleElement::attributeToPropertyTypeMap()
diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog
index 2b0e13c..dd8269a 100644
--- a/Source/WebKit/chromium/ChangeLog
+++ b/Source/WebKit/chromium/ChangeLog
@@ -1,3 +1,19 @@
+2011-03-31  Evan Martin  <evan@chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        <title> should support dir attribute
+        https://bugs.webkit.org/show_bug.cgi?id=50961
+
+        Update to new FrameLoaderClient interface.
+
+        * src/FrameLoaderClientImpl.cpp:
+        (WebKit::FrameLoaderClientImpl::dispatchDidReceiveTitle):
+        (WebKit::FrameLoaderClientImpl::setTitle):
+        * src/FrameLoaderClientImpl.h:
+        * src/WebDataSourceImpl.cpp:
+        (WebKit::WebDataSourceImpl::pageTitle):
+
 2011-03-30  David Levin  <levin@chromium.org>
 
         Reviewed by Dmitry Titov.
diff --git a/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp b/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp
index 647a70c..cd76491 100644
--- a/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp
+++ b/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp
@@ -734,10 +734,11 @@
     }
 }
 
-void FrameLoaderClientImpl::dispatchDidReceiveTitle(const String& title)
+void FrameLoaderClientImpl::dispatchDidReceiveTitle(const StringWithDirection& title)
 {
+    // FIXME: use direction of title.
     if (m_webFrame->client())
-        m_webFrame->client()->didReceiveTitle(m_webFrame, title);
+        m_webFrame->client()->didReceiveTitle(m_webFrame, title.string());
 }
 
 void FrameLoaderClientImpl::dispatchDidChangeIcons()
@@ -1328,7 +1329,7 @@
     return ds.release();
 }
 
-void FrameLoaderClientImpl::setTitle(const String& title, const KURL& url)
+void FrameLoaderClientImpl::setTitle(const StringWithDirection& title, const KURL& url)
 {
     // FIXME: inform consumer of changes to the title.
 }
diff --git a/Source/WebKit/chromium/src/FrameLoaderClientImpl.h b/Source/WebKit/chromium/src/FrameLoaderClientImpl.h
index f19c26c..2b1c26f 100644
--- a/Source/WebKit/chromium/src/FrameLoaderClientImpl.h
+++ b/Source/WebKit/chromium/src/FrameLoaderClientImpl.h
@@ -104,7 +104,7 @@
     virtual void dispatchWillClose();
     virtual void dispatchDidReceiveIcon();
     virtual void dispatchDidStartProvisionalLoad();
-    virtual void dispatchDidReceiveTitle(const WTF::String& title);
+    virtual void dispatchDidReceiveTitle(const WebCore::StringWithDirection&);
     virtual void dispatchDidChangeIcons();
     virtual void dispatchDidCommitLoad();
     virtual void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&);
@@ -166,7 +166,7 @@
     virtual void prepareForDataSourceReplacement();
     virtual PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(
         const WebCore::ResourceRequest&, const WebCore::SubstituteData&);
-    virtual void setTitle(const WTF::String& title, const WebCore::KURL&);
+    virtual void setTitle(const WebCore::StringWithDirection&, const WebCore::KURL&);
     virtual WTF::String userAgent(const WebCore::KURL&);
     virtual void savePlatformDataToCachedFrame(WebCore::CachedFrame*);
     virtual void transitionToCommittedFromCachedFrame(WebCore::CachedFrame*);
diff --git a/Source/WebKit/chromium/src/WebDataSourceImpl.cpp b/Source/WebKit/chromium/src/WebDataSourceImpl.cpp
index 1366a80..3170aff 100644
--- a/Source/WebKit/chromium/src/WebDataSourceImpl.cpp
+++ b/Source/WebKit/chromium/src/WebDataSourceImpl.cpp
@@ -82,7 +82,8 @@
 
 WebString WebDataSourceImpl::pageTitle() const
 {
-    return title();
+    // FIXME: use direction of title as well.
+    return title().string();
 }
 
 WebNavigationType WebDataSourceImpl::navigationType() const
diff --git a/Source/WebKit/efl/ChangeLog b/Source/WebKit/efl/ChangeLog
index 35da09c..7cea65a 100644
--- a/Source/WebKit/efl/ChangeLog
+++ b/Source/WebKit/efl/ChangeLog
@@ -1,3 +1,17 @@
+2011-03-31  Evan Martin  <evan@chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        <title> should support dir attribute
+        https://bugs.webkit.org/show_bug.cgi?id=50961
+
+        Update to new FrameLoaderClient interface.
+
+        * WebCoreSupport/FrameLoaderClientEfl.cpp:
+        (WebCore::FrameLoaderClientEfl::dispatchDidReceiveTitle):
+        (WebCore::FrameLoaderClientEfl::setTitle):
+        * WebCoreSupport/FrameLoaderClientEfl.h:
+
 2011-03-29  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
 
         Reviewed by Antonio Gomes.
diff --git a/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp b/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp
index fa34ac9..96b859b 100644
--- a/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp
+++ b/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp
@@ -576,9 +576,10 @@
         ewk_view_load_provisional(m_view);
 }
 
-void FrameLoaderClientEfl::dispatchDidReceiveTitle(const String& title)
+void FrameLoaderClientEfl::dispatchDidReceiveTitle(const StringWithDirection& title)
 {
-    CString cs = title.utf8();
+    // FIXME: use direction of title.
+    CString cs = title.string().utf8();
     ewk_frame_title_set(m_frame, cs.data());
 
     if (ewk_view_frame_main_get(m_view) != m_frame)
@@ -709,7 +710,7 @@
     notImplemented();
 }
 
-void FrameLoaderClientEfl::setTitle(const String& title, const KURL& url)
+void FrameLoaderClientEfl::setTitle(const StringWithDirection& title, const KURL& url)
 {
     // no need for, dispatchDidReceiveTitle is the right callback
 }
diff --git a/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.h b/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.h
index 5ea4e8c..bd07a30 100644
--- a/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.h
+++ b/Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.h
@@ -102,7 +102,7 @@
     virtual void dispatchWillClose();
     virtual void dispatchDidReceiveIcon();
     virtual void dispatchDidStartProvisionalLoad();
-    virtual void dispatchDidReceiveTitle(const String&);
+    virtual void dispatchDidReceiveTitle(const StringWithDirection&);
     virtual void dispatchDidChangeIcons();
     virtual void dispatchDidCommitLoad();
     virtual void dispatchDidFailProvisionalLoad(const ResourceError&);
@@ -193,7 +193,7 @@
     virtual void prepareForDataSourceReplacement();
 
     virtual WTF::PassRefPtr<DocumentLoader> createDocumentLoader(const ResourceRequest&, const SubstituteData&);
-    virtual void setTitle(const String& title, const KURL&);
+    virtual void setTitle(const StringWithDirection& title, const KURL&);
 
     virtual String userAgent(const KURL&);
 
diff --git a/Source/WebKit/gtk/ChangeLog b/Source/WebKit/gtk/ChangeLog
index 05c15d4..ed73a7e 100644
--- a/Source/WebKit/gtk/ChangeLog
+++ b/Source/WebKit/gtk/ChangeLog
@@ -1,3 +1,17 @@
+2011-03-31  Evan Martin  <evan@chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        <title> should support dir attribute
+        https://bugs.webkit.org/show_bug.cgi?id=50961
+
+        Update to new FrameLoaderClient interface.
+
+        * WebCoreSupport/FrameLoaderClientGtk.cpp:
+        (WebKit::FrameLoaderClient::dispatchDidReceiveTitle):
+        (WebKit::FrameLoaderClient::setTitle):
+        * WebCoreSupport/FrameLoaderClientGtk.h:
+
 2011-03-29  Philippe Normand  <pnormand@igalia.com>
 
         Unreviewed, disable an assert in testwebview due to
diff --git a/Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp b/Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
index ca8bf9a..5c594e8 100644
--- a/Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
+++ b/Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
@@ -949,14 +949,15 @@
     notifyStatus(m_frame, WEBKIT_LOAD_PROVISIONAL);
 }
 
-void FrameLoaderClient::dispatchDidReceiveTitle(const String& title)
+void FrameLoaderClient::dispatchDidReceiveTitle(const StringWithDirection& title)
 {
     if (m_loadingErrorPage)
         return;
 
     WebKitWebFramePrivate* priv = m_frame->priv;
     g_free(priv->title);
-    priv->title = g_strdup(title.utf8().data());
+    // FIXME: use direction of title.
+    priv->title = g_strdup(title.string().utf8().data());
 
     g_signal_emit_by_name(m_frame, "title-changed", priv->title);
     g_object_notify(G_OBJECT(m_frame), "title");
@@ -1119,11 +1120,12 @@
     notImplemented();
 }
 
-void FrameLoaderClient::setTitle(const String& title, const KURL& url)
+void FrameLoaderClient::setTitle(const StringWithDirection& title, const KURL& url)
 {
     WebKitWebFramePrivate* frameData = m_frame->priv;
     g_free(frameData->title);
-    frameData->title = g_strdup(title.utf8().data());
+    // FIXME: use direction of title.
+    frameData->title = g_strdup(title.string().utf8().data());
 }
 
 void FrameLoaderClient::dispatchDidReceiveContentLength(WebCore::DocumentLoader*, unsigned long identifier, int lengthReceived)
diff --git a/Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h b/Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h
index b7ead7a..97eb0ff 100644
--- a/Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h
+++ b/Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h
@@ -81,7 +81,7 @@
         virtual void dispatchWillClose();
         virtual void dispatchDidReceiveIcon();
         virtual void dispatchDidStartProvisionalLoad();
-        virtual void dispatchDidReceiveTitle(const WTF::String&);
+        virtual void dispatchDidReceiveTitle(const WebCore::StringWithDirection&);
         virtual void dispatchDidChangeIcons();
         virtual void dispatchDidCommitLoad();
         virtual void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&);
@@ -174,7 +174,7 @@
         virtual void prepareForDataSourceReplacement();
 
         virtual WTF::PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&);
-        virtual void setTitle(const WTF::String& title, const WebCore::KURL&);
+        virtual void setTitle(const WebCore::StringWithDirection& title, const WebCore::KURL&);
 
         virtual WTF::String userAgent(const WebCore::KURL&);
 
diff --git a/Source/WebKit/haiku/ChangeLog b/Source/WebKit/haiku/ChangeLog
index 7757fe7..996a1f4 100644
--- a/Source/WebKit/haiku/ChangeLog
+++ b/Source/WebKit/haiku/ChangeLog
@@ -1,3 +1,16 @@
+2011-03-31  Evan Martin  <evan@chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        <title> should support dir attribute
+        https://bugs.webkit.org/show_bug.cgi?id=50961
+
+        Update to new FrameLoaderClient interface.
+
+        * WebCoreSupport/FrameLoaderClientHaiku.cpp:
+        (WebCore::FrameLoaderClientHaiku::dispatchDidReceiveTitle):
+        * WebCoreSupport/FrameLoaderClientHaiku.h:
+
 2011-03-25  Andy Estes  <aestes@apple.com>
 
         Reviewed by Adele Peterson.
diff --git a/Source/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp b/Source/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp
index 24a98d5..c04cb7d 100644
--- a/Source/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp
+++ b/Source/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp
@@ -237,13 +237,13 @@
     }
 }
 
-void FrameLoaderClientHaiku::dispatchDidReceiveTitle(const String& title)
+void FrameLoaderClientHaiku::dispatchDidReceiveTitle(const StringWithTitle& title)
 {
     if (m_webView) {
-        m_webView->SetPageTitle(title);
-
+        // FIXME: use direction of title.
+        m_webView->SetPageTitle(title.m_string());
         BMessage message(TITLE_CHANGED);
-        message.AddString("title", title);
+        message.AddString("title", title.string());
         m_messenger->SendMessage(&message);
     }
 }
diff --git a/Source/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.h b/Source/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.h
index dbd3084..f576545 100644
--- a/Source/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.h
+++ b/Source/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.h
@@ -102,7 +102,7 @@
         virtual void dispatchWillClose();
         virtual void dispatchDidReceiveIcon();
         virtual void dispatchDidStartProvisionalLoad();
-        virtual void dispatchDidReceiveTitle(const String& title);
+        virtual void dispatchDidReceiveTitle(const StringWithDirection& title);
         virtual void dispatchDidCommitLoad();
         virtual void dispatchDidFinishDocumentLoad();
         virtual void dispatchDidFinishLoad();
@@ -143,7 +143,7 @@
         virtual void addHistoryItemForFragmentScroll();
         virtual void didFinishLoad();
         virtual void prepareForDataSourceReplacement();
-        virtual void setTitle(const String& title, const KURL&);
+        virtual void setTitle(const StringWithDirection&, const KURL&);
 
         virtual String userAgent(const KURL&);
 
diff --git a/Source/WebKit/mac/ChangeLog b/Source/WebKit/mac/ChangeLog
index d2c20ed..c962a69 100644
--- a/Source/WebKit/mac/ChangeLog
+++ b/Source/WebKit/mac/ChangeLog
@@ -1,3 +1,17 @@
+2011-03-31  Evan Martin  <evan@chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        <title> should support dir attribute
+        https://bugs.webkit.org/show_bug.cgi?id=50961
+
+        Update to new FrameLoaderClient interface.
+
+        * WebCoreSupport/WebFrameLoaderClient.h:
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::dispatchDidReceiveTitle):
+        (WebFrameLoaderClient::setTitle):
+
 2011-03-30  Dominic Cooney  <dominicc@google.com>
 
         Reviewed by Dimitri Glazkov.
diff --git a/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h b/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h
index 4fe5664..df8b34b 100644
--- a/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h
+++ b/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h
@@ -101,7 +101,7 @@
     virtual void dispatchWillClose();
     virtual void dispatchDidReceiveIcon();
     virtual void dispatchDidStartProvisionalLoad();
-    virtual void dispatchDidReceiveTitle(const WTF::String& title);
+    virtual void dispatchDidReceiveTitle(const WebCore::StringWithDirection&);
     virtual void dispatchDidChangeIcons();
     virtual void dispatchDidCommitLoad();
     virtual void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&);
@@ -196,7 +196,7 @@
     virtual void prepareForDataSourceReplacement();
     virtual PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&);
 
-    virtual void setTitle(const WTF::String& title, const WebCore::KURL&);
+    virtual void setTitle(const WebCore::StringWithDirection&, const WebCore::KURL&);
 
     virtual PassRefPtr<WebCore::Frame> createFrame(const WebCore::KURL& url, const WTF::String& name, WebCore::HTMLFrameOwnerElement*,
                                         const WTF::String& referrer, bool allowsScrolling, int marginWidth, int marginHeight);
diff --git a/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm b/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
index 92c2b03..27ce62a 100644
--- a/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
+++ b/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
@@ -624,12 +624,13 @@
         CallFrameLoadDelegate(implementations->didStartProvisionalLoadForFrameFunc, webView, @selector(webView:didStartProvisionalLoadForFrame:), m_webFrame.get());
 }
 
-void WebFrameLoaderClient::dispatchDidReceiveTitle(const String& title)
+void WebFrameLoaderClient::dispatchDidReceiveTitle(const StringWithDirection& title)
 {
     WebView *webView = getWebView(m_webFrame.get());   
     WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(webView);
     if (implementations->didReceiveTitleForFrameFunc)
-        CallFrameLoadDelegate(implementations->didReceiveTitleForFrameFunc, webView, @selector(webView:didReceiveTitle:forFrame:), (NSString *)title, m_webFrame.get());
+        // FIXME: use direction of title.
+        CallFrameLoadDelegate(implementations->didReceiveTitleForFrameFunc, webView, @selector(webView:didReceiveTitle:forFrame:), (NSString *)title.string(), m_webFrame.get());
 }
 
 void WebFrameLoaderClient::dispatchDidChangeIcons()
@@ -893,7 +894,7 @@
         WebHistoryDelegateImplementationCache* implementations = WebViewGetHistoryDelegateImplementations(view);
         if (implementations->navigatedFunc) {
             WebNavigationData *data = [[WebNavigationData alloc] initWithURLString:loader->urlForHistory()
-                                                                             title:loader->title()
+                                                                             title:loader->title().string()
                                                                    originalRequest:loader->originalRequestCopy().nsURLRequest()
                                                                           response:loader->response().nsURLResponse()
                                                                  hasSubstituteData:loader->substituteData().isValid()
@@ -907,7 +908,7 @@
     }
 
     [[WebHistory optionalSharedHistory] _visitedURL:loader->urlForHistory() 
-                                          withTitle:loader->title()
+                                          withTitle:loader->title().string()
                                              method:loader->originalRequestCopy().httpMethod()
                                          wasFailure:loader->urlForHistoryReflectsFailure()
                                  increaseVisitCount:!loader->clientRedirectSourceForHistory()]; // Do not increase visit count due to navigations that were not initiated by the user directly, avoiding growth from programmatic reloads.
@@ -1179,7 +1180,7 @@
     return loader.release();
 }
 
-void WebFrameLoaderClient::setTitle(const String& title, const KURL& url)
+void WebFrameLoaderClient::setTitle(const StringWithDirection& title, const KURL& url)
 {
     WebView* view = getWebView(m_webFrame.get());
     
@@ -1188,7 +1189,8 @@
         if (!implementations->setTitleFunc)
             return;
             
-        CallHistoryDelegate(implementations->setTitleFunc, view, @selector(webView:updateHistoryTitle:forURL:), (NSString *)title, (NSString *)url);
+        // FIXME: use direction of title.
+        CallHistoryDelegate(implementations->setTitleFunc, view, @selector(webView:updateHistoryTitle:forURL:), (NSString *)title.string(), (NSString *)url);
         return;
     }
     
@@ -1196,7 +1198,7 @@
     nsURL = [nsURL _webkit_canonicalize];
     if(!nsURL)
         return;
-    NSString *titleNSString = title;
+    NSString *titleNSString = title.string();
        
     [[[WebHistory optionalSharedHistory] itemForURL:nsURL] setTitle:titleNSString];
 }
@@ -1285,7 +1287,7 @@
         // like the ones that Safari uses for bookmarks it is the only way the DocumentLoader
         // will get the proper title.
         if (DocumentLoader* documentLoader = [dataSource _documentLoader])
-            documentLoader->setTitle([dataSource pageTitle]);
+            documentLoader->setTitle(StringWithDirection([dataSource pageTitle], LTR));
     }
 
     if (HTMLFrameOwnerElement* owner = coreFrame->ownerElement())
diff --git a/Source/WebKit/mac/WebView/WebHTMLRepresentation.mm b/Source/WebKit/mac/WebView/WebHTMLRepresentation.mm
index 03edd5d..842e605 100644
--- a/Source/WebKit/mac/WebView/WebHTMLRepresentation.mm
+++ b/Source/WebKit/mac/WebView/WebHTMLRepresentation.mm
@@ -261,7 +261,7 @@
 
 - (NSString *)title
 {
-    return nsStringNilIfEmpty([_private->dataSource _documentLoader]->title());
+    return nsStringNilIfEmpty([_private->dataSource _documentLoader]->title().string());
 }
 
 - (DOMDocument *)DOMDocument
diff --git a/Source/WebKit/qt/ChangeLog b/Source/WebKit/qt/ChangeLog
index 7bab6a92..fb5e6b3 100644
--- a/Source/WebKit/qt/ChangeLog
+++ b/Source/WebKit/qt/ChangeLog
@@ -1,3 +1,17 @@
+2011-03-31  Evan Martin  <evan@chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        <title> should support dir attribute
+        https://bugs.webkit.org/show_bug.cgi?id=50961
+
+        Update to new FrameLoaderClient interface.
+
+        * WebCoreSupport/FrameLoaderClientQt.cpp:
+        (WebCore::FrameLoaderClientQt::dispatchDidReceiveTitle):
+        (WebCore::FrameLoaderClientQt::setTitle):
+        * WebCoreSupport/FrameLoaderClientQt.h:
+
 2011-03-30  Yi Shen  <yi.4.shen@nokia.com>
 
         Reviewed by Kenneth Rohde Christiansen.
diff --git a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
index d318494..8089bfe 100644
--- a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
+++ b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
@@ -447,15 +447,16 @@
 }
 
 
-void FrameLoaderClientQt::dispatchDidReceiveTitle(const String& title)
+void FrameLoaderClientQt::dispatchDidReceiveTitle(const StringWithDirection& title)
 {
+    // FIXME: use direction of title.
     if (dumpFrameLoaderCallbacks)
-        printf("%s - didReceiveTitle: %s\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)), qPrintable(QString(title)));
+        printf("%s - didReceiveTitle: %s\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)), qPrintable(QString(title.string())));
 
     if (!m_webFrame)
         return;
 
-    emit titleChanged(title);
+    emit titleChanged(title.string());
 }
 
 
@@ -709,16 +710,17 @@
 {
 }
 
-void FrameLoaderClientQt::setTitle(const String& title, const KURL& url)
+void FrameLoaderClientQt::setTitle(const StringWithDirection& title, const KURL& url)
 {
     // Used by Apple WebKit to update the title of an existing history item.
     // QtWebKit doesn't accomodate this on history items. If it ever does,
     // it should be privateBrowsing-aware.For now, we are just passing
     // globalhistory layout tests.
+    // FIXME: use direction of title.
     if (dumpHistoryCallbacks) {
         printf("WebView updated the title for history URL \"%s\" to \"%s\".\n",
             qPrintable(drtDescriptionSuitableForTestResult(url)),
-            qPrintable(QString(title)));
+            qPrintable(QString(title.string())));
     }
 }
 
diff --git a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
index 3ec5f20..900489d 100644
--- a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
+++ b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
@@ -110,7 +110,7 @@
     virtual void dispatchWillClose();
     virtual void dispatchDidReceiveIcon();
     virtual void dispatchDidStartProvisionalLoad();
-    virtual void dispatchDidReceiveTitle(const String& title);
+    virtual void dispatchDidReceiveTitle(const StringWithDirection&);
     virtual void dispatchDidChangeIcons();
     virtual void dispatchDidCommitLoad();
     virtual void dispatchDidFailProvisionalLoad(const ResourceError&);
@@ -186,7 +186,7 @@
     virtual void prepareForDataSourceReplacement();
 
     virtual WTF::PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&);
-    virtual void setTitle(const String& title, const KURL&);
+    virtual void setTitle(const StringWithDirection&, const KURL&);
 
     virtual String userAgent(const WebCore::KURL&);
 
diff --git a/Source/WebKit/win/ChangeLog b/Source/WebKit/win/ChangeLog
index 18fae8a..f671fbc 100644
--- a/Source/WebKit/win/ChangeLog
+++ b/Source/WebKit/win/ChangeLog
@@ -1,3 +1,16 @@
+2011-03-31  Evan Martin  <evan@chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        <title> should support dir attribute
+        https://bugs.webkit.org/show_bug.cgi?id=50961
+
+        Update to new FrameLoaderClient interface.
+
+        * WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebFrameLoaderClient::dispatchDidReceiveTitle):
+        * WebCoreSupport/WebFrameLoaderClient.h:
+
 2011-03-30  Steve Falkenburg  <sfalken@apple.com>
 
         Reviewed by Adam Roben.
diff --git a/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp b/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp
index 10a3190..ca61d30 100644
--- a/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp
+++ b/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp
@@ -364,12 +364,13 @@
         frameLoadDelegate->didStartProvisionalLoadForFrame(webView, m_webFrame);
 }
 
-void WebFrameLoaderClient::dispatchDidReceiveTitle(const String& title)
+void WebFrameLoaderClient::dispatchDidReceiveTitle(const StringWithDirection& title)
 {
     WebView* webView = m_webFrame->webView();
     COMPtr<IWebFrameLoadDelegate> frameLoadDelegate;
     if (SUCCEEDED(webView->frameLoadDelegate(&frameLoadDelegate)))
-        frameLoadDelegate->didReceiveTitle(webView, BString(title), m_webFrame);
+        // FIXME: use direction of title.
+        frameLoadDelegate->didReceiveTitle(webView, BString(title.string()), m_webFrame);
 }
 
 void WebFrameLoaderClient::dispatchDidChangeIcons()
@@ -542,7 +543,7 @@
         COMPtr<IWebURLRequest> urlRequest(AdoptCOM, WebMutableURLRequest::createInstance(loader->originalRequestCopy()));
         
         COMPtr<IWebNavigationData> navigationData(AdoptCOM, WebNavigationData::createInstance(
-            loader->urlForHistory(), loader->title(), urlRequest.get(), urlResponse.get(), loader->substituteData().isValid(), loader->clientRedirectSourceForHistory()));
+            loader->urlForHistory(), loader->title().string(), urlRequest.get(), urlResponse.get(), loader->substituteData().isValid(), loader->clientRedirectSourceForHistory()));
 
         historyDelegate->didNavigateWithNavigationData(webView, navigationData.get(), m_webFrame);
         return;
@@ -552,7 +553,7 @@
     if (!history)
         return;
 
-    history->visitedURL(loader->urlForHistory(), loader->title(), loader->originalRequestCopy().httpMethod(), loader->urlForHistoryReflectsFailure(), !loader->clientRedirectSourceForHistory());
+    history->visitedURL(loader->urlForHistory(), loader->title().string(), loader->originalRequestCopy().httpMethod(), loader->urlForHistoryReflectsFailure(), !loader->clientRedirectSourceForHistory());
 }
 
 void WebFrameLoaderClient::updateGlobalHistoryRedirectLinks()
@@ -672,13 +673,13 @@
     return loader.release();
 }
 
-void WebFrameLoaderClient::setTitle(const String& title, const KURL& url)
+void WebFrameLoaderClient::setTitle(const StringWithDirection& title, const KURL& url)
 {
     WebView* webView = m_webFrame->webView();
     COMPtr<IWebHistoryDelegate> historyDelegate;
     webView->historyDelegate(&historyDelegate);
     if (historyDelegate) {
-        BString titleBSTR(title);
+        BString titleBSTR(title.string());
         BString urlBSTR(url.string());
         historyDelegate->updateHistoryTitle(webView, titleBSTR, urlBSTR);
         return;
@@ -704,7 +705,7 @@
     if (!itemPrivate)
         return;
 
-    itemPrivate->setTitle(BString(title));
+    itemPrivate->setTitle(BString(title.string()));
 }
 
 void WebFrameLoaderClient::savePlatformDataToCachedFrame(CachedFrame* cachedFrame)
diff --git a/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.h b/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.h
index d864b23..1857088 100644
--- a/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.h
+++ b/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.h
@@ -69,7 +69,7 @@
     virtual void dispatchWillClose();
     virtual void dispatchDidReceiveIcon();
     virtual void dispatchDidStartProvisionalLoad();
-    virtual void dispatchDidReceiveTitle(const WTF::String&);
+    virtual void dispatchDidReceiveTitle(const WebCore::StringWithDirection&);
     virtual void dispatchDidChangeIcons();
     virtual void dispatchDidCommitLoad();
     virtual void dispatchDidFinishDocumentLoad();
@@ -103,7 +103,7 @@
     virtual void didRunInsecureContent(WebCore::SecurityOrigin*, const WebCore::KURL&);
 
     virtual PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&);
-    virtual void setTitle(const WTF::String& title, const WebCore::KURL&);
+    virtual void setTitle(const WebCore::StringWithDirection&, const WebCore::KURL&);
 
     virtual void savePlatformDataToCachedFrame(WebCore::CachedFrame*);
     virtual void transitionToCommittedFromCachedFrame(WebCore::CachedFrame*);
diff --git a/Source/WebKit/win/WebDataSource.cpp b/Source/WebKit/win/WebDataSource.cpp
index 0350373..1498f6e 100644
--- a/Source/WebKit/win/WebDataSource.cpp
+++ b/Source/WebKit/win/WebDataSource.cpp
@@ -246,7 +246,7 @@
 HRESULT STDMETHODCALLTYPE WebDataSource::pageTitle( 
     /* [retval][out] */ BSTR* title)
 {
-    *title = BString(m_loader->title()).release();
+    *title = BString(m_loader->title().string()).release();
     return S_OK;
 }
 
diff --git a/Source/WebKit/wince/ChangeLog b/Source/WebKit/wince/ChangeLog
index e595f25..ce91c98 100644
--- a/Source/WebKit/wince/ChangeLog
+++ b/Source/WebKit/wince/ChangeLog
@@ -1,3 +1,17 @@
+2011-03-31  Evan Martin  <evan@chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        <title> should support dir attribute
+        https://bugs.webkit.org/show_bug.cgi?id=50961
+
+        Update to new FrameLoaderClient interface.
+
+        * WebCoreSupport/FrameLoaderClientWinCE.cpp:
+        (WebKit::FrameLoaderClientWinCE::dispatchDidReceiveTitle):
+        (WebKit::FrameLoaderClientWinCE::setTitle):
+        * WebCoreSupport/FrameLoaderClientWinCE.h:
+
 2011-03-27  Patrick Gansterer  <paroga@webkit.org>
 
         Reviewed by Andreas Kling.
diff --git a/Source/WebKit/wince/WebCoreSupport/FrameLoaderClientWinCE.cpp b/Source/WebKit/wince/WebCoreSupport/FrameLoaderClientWinCE.cpp
index 2d8812f..648c4a5 100644
--- a/Source/WebKit/wince/WebCoreSupport/FrameLoaderClientWinCE.cpp
+++ b/Source/WebKit/wince/WebCoreSupport/FrameLoaderClientWinCE.cpp
@@ -371,7 +371,7 @@
     notImplemented();
 }
 
-void FrameLoaderClientWinCE::dispatchDidReceiveTitle(const String&)
+void FrameLoaderClientWinCE::dispatchDidReceiveTitle(const StringWithDirection&)
 {
     notImplemented();
 }
@@ -490,7 +490,7 @@
     notImplemented();
 }
 
-void FrameLoaderClientWinCE::setTitle(const String&, const KURL&)
+void FrameLoaderClientWinCE::setTitle(const StringWithDirection&, const KURL&)
 {
     notImplemented();
 }
diff --git a/Source/WebKit/wince/WebCoreSupport/FrameLoaderClientWinCE.h b/Source/WebKit/wince/WebCoreSupport/FrameLoaderClientWinCE.h
index 401225d..61539c5 100644
--- a/Source/WebKit/wince/WebCoreSupport/FrameLoaderClientWinCE.h
+++ b/Source/WebKit/wince/WebCoreSupport/FrameLoaderClientWinCE.h
@@ -76,7 +76,7 @@
     virtual void dispatchWillClose();
     virtual void dispatchDidReceiveIcon();
     virtual void dispatchDidStartProvisionalLoad();
-    virtual void dispatchDidReceiveTitle(const WTF::String&);
+    virtual void dispatchDidReceiveTitle(const WTF::StringWithDirection&);
     virtual void dispatchDidChangeIcons();
     virtual void dispatchDidCommitLoad();
     virtual void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&);
@@ -169,7 +169,7 @@
     virtual void prepareForDataSourceReplacement();
 
     virtual WTF::PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&);
-    virtual void setTitle(const WTF::String& title, const WebCore::KURL&);
+    virtual void setTitle(const WTF::StringWithDirection&, const WebCore::KURL&);
 
     virtual WTF::String userAgent(const WebCore::KURL&);
 
diff --git a/Source/WebKit/wx/ChangeLog b/Source/WebKit/wx/ChangeLog
index 980fa8a..1a0a314 100644
--- a/Source/WebKit/wx/ChangeLog
+++ b/Source/WebKit/wx/ChangeLog
@@ -1,3 +1,17 @@
+2011-03-31  Evan Martin  <evan@chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        <title> should support dir attribute
+        https://bugs.webkit.org/show_bug.cgi?id=50961
+
+        Update to new FrameLoaderClient interface.
+
+        * WebKitSupport/FrameLoaderClientWx.cpp:
+        (WebCore::FrameLoaderClientWx::dispatchDidReceiveTitle):
+        (WebCore::FrameLoaderClientWx::setTitle):
+        * WebKitSupport/FrameLoaderClientWx.h:
+
 2011-03-25  Andy Estes  <aestes@apple.com>
 
         Reviewed by Adele Peterson.
diff --git a/Source/WebKit/wx/WebKitSupport/FrameLoaderClientWx.cpp b/Source/WebKit/wx/WebKitSupport/FrameLoaderClientWx.cpp
index afc255c..b408636 100644
--- a/Source/WebKit/wx/WebKitSupport/FrameLoaderClientWx.cpp
+++ b/Source/WebKit/wx/WebKitSupport/FrameLoaderClientWx.cpp
@@ -295,12 +295,13 @@
 }
 
 
-void FrameLoaderClientWx::dispatchDidReceiveTitle(const String& title)
+void FrameLoaderClientWx::dispatchDidReceiveTitle(const StringWithDirection& title)
 {
     if (m_webView) {
-        m_webView->SetPageTitle(title);
+        // FIXME: use direction of title.
+        m_webView->SetPageTitle(title.string());
         wxWebViewReceivedTitleEvent wkEvent(m_webView);
-        wkEvent.SetTitle(title);
+        wkEvent.SetTitle(title.string());
         m_webView->GetEventHandler()->ProcessEvent(wkEvent);
     }
 }
@@ -525,7 +526,7 @@
 }
 
 
-void FrameLoaderClientWx::setTitle(const String& title, const KURL&)
+void FrameLoaderClientWx::setTitle(const StringWithDirection& title, const KURL&)
 {
     notImplemented();
 }
diff --git a/Source/WebKit/wx/WebKitSupport/FrameLoaderClientWx.h b/Source/WebKit/wx/WebKitSupport/FrameLoaderClientWx.h
index 254f95c..b28d389 100644
--- a/Source/WebKit/wx/WebKitSupport/FrameLoaderClientWx.h
+++ b/Source/WebKit/wx/WebKitSupport/FrameLoaderClientWx.h
@@ -103,7 +103,7 @@
         virtual void dispatchWillClose();
         virtual void dispatchDidReceiveIcon();
         virtual void dispatchDidStartProvisionalLoad();
-        virtual void dispatchDidReceiveTitle(const String& title);
+        virtual void dispatchDidReceiveTitle(const StringWithDirection& title);
         virtual void dispatchDidCommitLoad();
         virtual void dispatchDidFinishDocumentLoad();
         virtual void dispatchDidFinishLoad();
@@ -145,7 +145,7 @@
         virtual void addHistoryItemForFragmentScroll();
         virtual void didFinishLoad();
         virtual void prepareForDataSourceReplacement();
-        virtual void setTitle(const String& title, const KURL&);
+        virtual void setTitle(const StringWithDirection&, const KURL&);
 
         virtual String userAgent(const KURL&);
 
diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog
index 701b013..3181361 100644
--- a/Source/WebKit2/ChangeLog
+++ b/Source/WebKit2/ChangeLog
@@ -1,3 +1,17 @@
+2011-03-31  Evan Martin  <evan@chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        <title> should support dir attribute
+        https://bugs.webkit.org/show_bug.cgi?id=50961
+
+        Update to new FrameLoaderClient interface.
+
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::dispatchDidReceiveTitle):
+        (WebKit::WebFrameLoaderClient::setTitle):
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
+
 2011-03-31  Balazs Kelemen  <kbalazs@webkit.org>
 
         Reviewed by Csaba Osztrogonác.
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
index fa3cdce..1487a35 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
@@ -403,7 +403,7 @@
     webPage->send(Messages::WebPageProxy::DidStartProvisionalLoadForFrame(m_frame->frameID(), url, unreachableURL, InjectedBundleUserMessageEncoder(userData.get())));
 }
 
-void WebFrameLoaderClient::dispatchDidReceiveTitle(const String& title)
+void WebFrameLoaderClient::dispatchDidReceiveTitle(const StringWithDirection& title)
 {
     WebPage* webPage = m_frame->page();
     if (!webPage)
@@ -412,10 +412,11 @@
     RefPtr<APIObject> userData;
 
     // Notify the bundle client.
-    webPage->injectedBundleLoaderClient().didReceiveTitleForFrame(webPage, title, m_frame, userData);
+    // FIXME: use direction of title.
+    webPage->injectedBundleLoaderClient().didReceiveTitleForFrame(webPage, title.string(), m_frame, userData);
 
     // Notify the UIProcess.
-    webPage->send(Messages::WebPageProxy::DidReceiveTitleForFrame(m_frame->frameID(), title, InjectedBundleUserMessageEncoder(userData.get())));
+    webPage->send(Messages::WebPageProxy::DidReceiveTitleForFrame(m_frame->frameID(), title.string(), InjectedBundleUserMessageEncoder(userData.get())));
 }
 
 void WebFrameLoaderClient::dispatchDidChangeIcons()
@@ -846,7 +847,8 @@
 
     WebNavigationDataStore data;
     data.url = loader->urlForHistory().string();
-    data.title = loader->title();
+    // FIXME: use direction of title.
+    data.title = loader->title().string();
 
     WebProcess::shared().connection()->send(Messages::WebContext::DidNavigateWithNavigationData(webPage->pageID(), data, m_frame->frameID()), 0);
 }
@@ -1061,14 +1063,15 @@
     return DocumentLoader::create(request, data);
 }
 
-void WebFrameLoaderClient::setTitle(const String& title, const KURL& url)
+void WebFrameLoaderClient::setTitle(const StringWithDirection& title, const KURL& url)
 {
     WebPage* webPage = m_frame->page();
     if (!webPage)
         return;
 
+    // FIXME: use direction of title.
     WebProcess::shared().connection()->send(Messages::WebContext::DidUpdateHistoryTitle(webPage->pageID(),
-        title, url.string(), m_frame->frameID()), 0);
+        title.string(), url.string(), m_frame->frameID()), 0);
 }
 
 String WebFrameLoaderClient::userAgent(const KURL&)
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
index 1948541..6c83e9d 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
@@ -84,7 +84,7 @@
     virtual void dispatchWillClose();
     virtual void dispatchDidReceiveIcon();
     virtual void dispatchDidStartProvisionalLoad();
-    virtual void dispatchDidReceiveTitle(const String& title);
+    virtual void dispatchDidReceiveTitle(const WebCore::StringWithDirection&);
     virtual void dispatchDidChangeIcons();
     virtual void dispatchDidCommitLoad();
     virtual void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&);
@@ -165,7 +165,7 @@
     virtual void prepareForDataSourceReplacement();
     
     virtual PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&);
-    virtual void setTitle(const String& title, const WebCore::KURL&);
+    virtual void setTitle(const WebCore::StringWithDirection&, const WebCore::KURL&);
     
     virtual String userAgent(const WebCore::KURL&);