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

Unified Diff: third_party/WebKit/Source/core/dom/Element.cpp

Issue 1898403002: [WIP] Implement :dir() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase... other changes too probably Created 4 years, 7 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
Index: third_party/WebKit/Source/core/dom/Element.cpp
diff --git a/third_party/WebKit/Source/core/dom/Element.cpp b/third_party/WebKit/Source/core/dom/Element.cpp
index 4ae2e5d3a125ab92f99efd46fe859e6352e0f4ae..eba4c90a4be4051a48900e0134e01947de043c12 100644
--- a/third_party/WebKit/Source/core/dom/Element.cpp
+++ b/third_party/WebKit/Source/core/dom/Element.cpp
@@ -3640,6 +3640,31 @@ bool Element::supportsStyleSharing() const
return true;
}
+TextDirection Element::directionality() const
+{
+ if (isHTMLElement() && toHTMLElement(this)->hasDirectionAuto()) {
+ CachedTextDirection direction = const_cast<Element*>(this)->ensureUniqueElementData().directionality();
+ if (direction == CachedTextDirection::NotAutoOrNotCached) {
+ toHTMLElement(this)->cacheDirectionalityForDirAuto();
+ direction = elementData()->directionality();
+ DCHECK(direction != CachedTextDirection::NotAutoOrNotCached);
+ }
+ if (direction == CachedTextDirection::AutoLTR)
+ return LTR;
+ return RTL;
+ }
+
+ if (equalIgnoringCase(fastGetAttribute(dirAttr), "ltr"))
+ return LTR;
+ if (equalIgnoringCase(fastGetAttribute(dirAttr), "rtl"))
+ return RTL;
+
+ const Element* parent = FlatTreeTraversal::parentElement(*this);
+ if (parent)
+ return parent->directionality();
+ return LTR;
+}
+
void Element::logAddElementIfIsolatedWorldAndInDocument(const char element[], const QualifiedName& attr1)
{
if (!inShadowIncludingDocument())

Powered by Google App Engine
This is Rietveld 408576698