Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1087)

Unified Diff: Source/core/html/HTMLElement.cpp

Issue 23456046: Implement unicode bidi P2 and P3 rules in BidiResolver (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/platform/graphics/TextRunIterator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLElement.cpp
diff --git a/Source/core/html/HTMLElement.cpp b/Source/core/html/HTMLElement.cpp
index d82d6d52a443b61c99b33bdd6da9ca818b0f964e..89a19ea4570ea56f1fe39eaa9cf39fee923347ba 100644
--- a/Source/core/html/HTMLElement.cpp
+++ b/Source/core/html/HTMLElement.cpp
@@ -52,6 +52,8 @@
#include "core/loader/FrameLoader.h"
#include "core/page/Frame.h"
#include "core/page/Settings.h"
+#include "core/platform/graphics/TextRunIterator.h"
+#include "core/platform/text/BidiResolver.h"
#include "core/rendering/RenderWordBreak.h"
#include "wtf/StdLibExtras.h"
#include "wtf/text/CString.h"
@@ -848,15 +850,24 @@ TextDirection HTMLElement::directionalityIfhasDirAutoAttribute(bool& isAuto) con
return directionality();
}
+static TextDirection determineDirectionality(const String& value, bool& hasStrongDirectionality)
+{
+ TextRun run(value);
+ BidiResolver<TextRunIterator, BidiCharacterRun> bidiResolver;
+ bidiResolver.setStatus(BidiStatus(run.direction(), run.directionalOverride()));
+ bidiResolver.setPositionIgnoringNestedIsolates(TextRunIterator(&run, 0));
+ return bidiResolver.determineParagraphDirectionality(&hasStrongDirectionality);
+}
+
TextDirection HTMLElement::directionality(Node** strongDirectionalityTextNode) const
{
if (hasTagName(inputTag)) {
HTMLInputElement* inputElement = toHTMLInputElement(const_cast<HTMLElement*>(this));
bool hasStrongDirectionality;
- Unicode::Direction textDirection = inputElement->value().defaultWritingDirection(&hasStrongDirectionality);
+ TextDirection textDirection = determineDirectionality(inputElement->value(), hasStrongDirectionality);
if (strongDirectionalityTextNode)
*strongDirectionalityTextNode = hasStrongDirectionality ? inputElement : 0;
- return (textDirection == Unicode::LeftToRight) ? LTR : RTL;
+ return textDirection;
}
Node* node = firstChild();
@@ -879,11 +890,11 @@ TextDirection HTMLElement::directionality(Node** strongDirectionalityTextNode) c
if (node->isTextNode()) {
bool hasStrongDirectionality;
- WTF::Unicode::Direction textDirection = node->textContent(true).defaultWritingDirection(&hasStrongDirectionality);
+ TextDirection textDirection = determineDirectionality(node->textContent(true), hasStrongDirectionality);
if (hasStrongDirectionality) {
if (strongDirectionalityTextNode)
*strongDirectionalityTextNode = node;
- return (textDirection == WTF::Unicode::LeftToRight) ? LTR : RTL;
+ return textDirection;
}
}
node = NodeTraversal::next(node, this);
« no previous file with comments | « no previous file | Source/core/platform/graphics/TextRunIterator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698