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

Side by Side Diff: Source/core/html/HTMLElement.cpp

Issue 524593003: Resolve direction correctly when dir attribute is not in a defined state Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Let style resolver take care of direction Created 6 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2004-2008, 2013, 2014 Apple Inc. All rights reserved. 4 * Copyright (C) 2004-2008, 2013, 2014 Apple Inc. All rights reserved.
5 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 5 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
6 * Copyright (C) 2011 Motorola Mobility. All rights reserved. 6 * Copyright (C) 2011 Motorola Mobility. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } else if (name == draggableAttr) { 181 } else if (name == draggableAttr) {
182 if (equalIgnoringCase(value, "true")) { 182 if (equalIgnoringCase(value, "true")) {
183 addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUser Drag, CSSValueElement); 183 addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUser Drag, CSSValueElement);
184 addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUser Select, CSSValueNone); 184 addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUser Select, CSSValueNone);
185 } else if (equalIgnoringCase(value, "false")) 185 } else if (equalIgnoringCase(value, "false"))
186 addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUser Drag, CSSValueNone); 186 addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUser Drag, CSSValueNone);
187 } else if (name == dirAttr) { 187 } else if (name == dirAttr) {
188 if (equalIgnoringCase(value, "auto")) 188 if (equalIgnoringCase(value, "auto"))
189 addPropertyToPresentationAttributeStyle(style, CSSPropertyUnicodeBid i, unicodeBidiAttributeForDirAuto(this)); 189 addPropertyToPresentationAttributeStyle(style, CSSPropertyUnicodeBid i, unicodeBidiAttributeForDirAuto(this));
190 else { 190 else {
191 if (isValidDirAttribute(value)) 191 if (isValidDirAttribute(value))
tkent 2014/09/12 06:33:55 If |value| is "auto", this code sets it to directi
Sunil Ratnu 2014/09/12 07:16:12 I don't think the flow will come here for value 'a
tkent 2014/11/07 01:01:53 Why is it in the else block? Did you look at the
Sunil Ratnu 2014/11/12 13:49:32 Yes, I did take a look at the isValidDirAttribute
tkent 2014/11/19 03:32:19 Ah, you're right. We check "auto" at line 188. S
192 addPropertyToPresentationAttributeStyle(style, CSSPropertyDirect ion, value); 192 addPropertyToPresentationAttributeStyle(style, CSSPropertyDirect ion, value);
193 else
194 addPropertyToPresentationAttributeStyle(style, CSSPropertyDirect ion, "ltr");
195 if (!hasTagName(bdiTag) && !hasTagName(bdoTag) && !hasTagName(output Tag)) 193 if (!hasTagName(bdiTag) && !hasTagName(bdoTag) && !hasTagName(output Tag))
196 addPropertyToPresentationAttributeStyle(style, CSSPropertyUnicod eBidi, CSSValueEmbed); 194 addPropertyToPresentationAttributeStyle(style, CSSPropertyUnicod eBidi, CSSValueEmbed);
197 } 195 }
198 } else if (name.matches(XMLNames::langAttr)) 196 } else if (name.matches(XMLNames::langAttr))
199 mapLanguageAttributeToLocale(value, style); 197 mapLanguageAttributeToLocale(value, style);
200 else if (name == langAttr) { 198 else if (name == langAttr) {
201 // xml:lang has a higher priority than lang. 199 // xml:lang has a higher priority than lang.
202 if (!fastHasAttribute(XMLNames::langAttr)) 200 if (!fastHasAttribute(XMLNames::langAttr))
203 mapLanguageAttributeToLocale(value, style); 201 mapLanguageAttributeToLocale(value, style);
204 } else 202 } else
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 { 674 {
677 if (!(selfOrAncestorHasDirAutoAttribute() && hasDirectionAuto())) { 675 if (!(selfOrAncestorHasDirAutoAttribute() && hasDirectionAuto())) {
678 isAuto = false; 676 isAuto = false;
679 return LTR; 677 return LTR;
680 } 678 }
681 679
682 isAuto = true; 680 isAuto = true;
683 return directionality(); 681 return directionality();
684 } 682 }
685 683
684 // FIXME: Implement directionality for input type='tel' when it is supported
tkent 2014/11/19 03:38:34 type=tel is supported by Google Chrome, IE, Firefo
685 // [Currently it is not supported in any of the browsers].
686 // Spec: http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#th e-directionality
687 TextDirection HTMLElement::determineDirection() const
688 {
689 for (const HTMLElement* element = this; element; element = Traversal<HTMLEle ment>::firstAncestor(*element)) {
690 const AtomicString& dirAttributeValue = element->fastGetAttribute(dirAtt r);
691 if (dirAttributeValue.isNull())
692 continue;
693
694 if (equalIgnoringCase(dirAttributeValue, "rtl"))
695 return RTL;
696
697 if (equalIgnoringCase(dirAttributeValue, "ltr"))
698 return LTR;
699
700 if (equalIgnoringCase(dirAttributeValue, "auto")) {
701 bool isAuto;
702 return element->directionalityIfhasDirAutoAttribute(isAuto);
703 }
704 }
705
706 return LTR;
707 }
708
709 // FIXME: This implementation deviates from the spec in case of 'textarea' havin g 'auto' attribute.
710 // Spec: http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#th e-directionality
686 TextDirection HTMLElement::directionality(Node** strongDirectionalityTextNode) c onst 711 TextDirection HTMLElement::directionality(Node** strongDirectionalityTextNode) c onst
687 { 712 {
688 if (isHTMLInputElement(*this)) { 713 if (isHTMLInputElement(*this)) {
689 HTMLInputElement* inputElement = toHTMLInputElement(const_cast<HTMLEleme nt*>(this)); 714 HTMLInputElement* inputElement = toHTMLInputElement(const_cast<HTMLEleme nt*>(this));
690 bool hasStrongDirectionality; 715 bool hasStrongDirectionality;
691 TextDirection textDirection = determineDirectionality(inputElement->valu e(), hasStrongDirectionality); 716 TextDirection textDirection = determineDirectionality(inputElement->valu e(), hasStrongDirectionality);
692 if (strongDirectionalityTextNode) 717 if (strongDirectionalityTextNode)
693 *strongDirectionalityTextNode = hasStrongDirectionality ? inputEleme nt : 0; 718 *strongDirectionalityTextNode = hasStrongDirectionality ? inputEleme nt : 0;
694 return textDirection; 719 return textDirection;
695 } 720 }
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 #ifndef NDEBUG 1019 #ifndef NDEBUG
995 1020
996 // For use in the debugger 1021 // For use in the debugger
997 void dumpInnerHTML(blink::HTMLElement*); 1022 void dumpInnerHTML(blink::HTMLElement*);
998 1023
999 void dumpInnerHTML(blink::HTMLElement* element) 1024 void dumpInnerHTML(blink::HTMLElement* element)
1000 { 1025 {
1001 printf("%s\n", element->innerHTML().ascii().data()); 1026 printf("%s\n", element->innerHTML().ascii().data());
1002 } 1027 }
1003 #endif 1028 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698