Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 } else if (name == draggableAttr) { | 204 } else if (name == draggableAttr) { |
| 205 if (equalIgnoringCase(value, "true")) { | 205 if (equalIgnoringCase(value, "true")) { |
| 206 addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUser Drag, CSSValueElement); | 206 addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUser Drag, CSSValueElement); |
| 207 addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUser Select, CSSValueNone); | 207 addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUser Select, CSSValueNone); |
| 208 } else if (equalIgnoringCase(value, "false")) | 208 } else if (equalIgnoringCase(value, "false")) |
| 209 addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUser Drag, CSSValueNone); | 209 addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUser Drag, CSSValueNone); |
| 210 } else if (name == dirAttr) { | 210 } else if (name == dirAttr) { |
| 211 if (equalIgnoringCase(value, "auto")) | 211 if (equalIgnoringCase(value, "auto")) |
| 212 addPropertyToPresentationAttributeStyle(style, CSSPropertyUnicodeBid i, unicodeBidiAttributeForDirAuto(this)); | 212 addPropertyToPresentationAttributeStyle(style, CSSPropertyUnicodeBid i, unicodeBidiAttributeForDirAuto(this)); |
| 213 else { | 213 else { |
| 214 if (isValidDirAttribute(value)) | 214 if (isValidDirAttribute(value)) { |
| 215 addPropertyToPresentationAttributeStyle(style, CSSPropertyDirect ion, value); | 215 addPropertyToPresentationAttributeStyle(style, CSSPropertyDirect ion, value); |
| 216 else | 216 } else { |
| 217 addPropertyToPresentationAttributeStyle(style, CSSPropertyDirect ion, "ltr"); | 217 const AtomicString& dirValue = determineDirection() == RTL ? "rt l" : "ltr"; |
|
Sunil Ratnu
2014/11/21 12:21:08
Hi tkent, We need to keep this else check here bec
tkent
2014/11/25 01:27:24
I don't think parent lookup is a right solution.
H
Sunil Ratnu
2014/11/25 05:43:25
The above approach does not work here. The above m
tkent
2014/11/25 05:56:09
Please investigate why it didn't work, and find an
| |
| 218 addPropertyToPresentationAttributeStyle(style, CSSPropertyDirect ion, dirValue); | |
| 219 } | |
| 218 if (!hasTagName(bdiTag) && !hasTagName(bdoTag) && !hasTagName(output Tag)) | 220 if (!hasTagName(bdiTag) && !hasTagName(bdoTag) && !hasTagName(output Tag)) |
| 219 addPropertyToPresentationAttributeStyle(style, CSSPropertyUnicod eBidi, CSSValueEmbed); | 221 addPropertyToPresentationAttributeStyle(style, CSSPropertyUnicod eBidi, CSSValueEmbed); |
| 220 } | 222 } |
| 221 } else if (name.matches(XMLNames::langAttr)) | 223 } else if (name.matches(XMLNames::langAttr)) |
| 222 mapLanguageAttributeToLocale(value, style); | 224 mapLanguageAttributeToLocale(value, style); |
| 223 else if (name == langAttr) { | 225 else if (name == langAttr) { |
| 224 // xml:lang has a higher priority than lang. | 226 // xml:lang has a higher priority than lang. |
| 225 if (!fastHasAttribute(XMLNames::langAttr)) | 227 if (!fastHasAttribute(XMLNames::langAttr)) |
| 226 mapLanguageAttributeToLocale(value, style); | 228 mapLanguageAttributeToLocale(value, style); |
| 227 } else | 229 } else |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 708 { | 710 { |
| 709 if (!(selfOrAncestorHasDirAutoAttribute() && hasDirectionAuto())) { | 711 if (!(selfOrAncestorHasDirAutoAttribute() && hasDirectionAuto())) { |
| 710 isAuto = false; | 712 isAuto = false; |
| 711 return LTR; | 713 return LTR; |
| 712 } | 714 } |
| 713 | 715 |
| 714 isAuto = true; | 716 isAuto = true; |
| 715 return directionality(); | 717 return directionality(); |
| 716 } | 718 } |
| 717 | 719 |
| 720 // FIXME: Implement directionality for input type='tel'. | |
| 721 // Spec: http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#th e-directionality. | |
| 722 TextDirection HTMLElement::determineDirection() const | |
|
Sunil Ratnu
2014/11/21 12:21:08
Instead of moving it here, we can also define a ne
| |
| 723 { | |
| 724 for (const HTMLElement* element = this; element; element = Traversal<HTMLEle ment>::firstAncestor(*element)) { | |
| 725 const AtomicString& dirAttributeValue = element->fastGetAttribute(dirAtt r); | |
| 726 if (dirAttributeValue.isNull()) | |
| 727 continue; | |
| 728 | |
| 729 if (equalIgnoringCase(dirAttributeValue, "rtl")) | |
| 730 return RTL; | |
| 731 | |
| 732 if (equalIgnoringCase(dirAttributeValue, "ltr")) | |
| 733 return LTR; | |
| 734 | |
| 735 if (equalIgnoringCase(dirAttributeValue, "auto")) { | |
| 736 bool isAuto; | |
| 737 return element->directionalityIfhasDirAutoAttribute(isAuto); | |
| 738 } | |
| 739 } | |
| 740 | |
| 741 return LTR; | |
| 742 } | |
| 743 | |
| 718 TextDirection HTMLElement::directionality(Node** strongDirectionalityTextNode) c onst | 744 TextDirection HTMLElement::directionality(Node** strongDirectionalityTextNode) c onst |
| 719 { | 745 { |
| 720 if (isHTMLInputElement(*this)) { | 746 if (isHTMLInputElement(*this)) { |
| 721 HTMLInputElement* inputElement = toHTMLInputElement(const_cast<HTMLEleme nt*>(this)); | 747 HTMLInputElement* inputElement = toHTMLInputElement(const_cast<HTMLEleme nt*>(this)); |
| 722 bool hasStrongDirectionality; | 748 bool hasStrongDirectionality; |
| 723 TextDirection textDirection = determineDirectionality(inputElement->valu e(), hasStrongDirectionality); | 749 TextDirection textDirection = determineDirectionality(inputElement->valu e(), hasStrongDirectionality); |
| 724 if (strongDirectionalityTextNode) | 750 if (strongDirectionalityTextNode) |
| 725 *strongDirectionalityTextNode = hasStrongDirectionality ? inputEleme nt : 0; | 751 *strongDirectionalityTextNode = hasStrongDirectionality ? inputEleme nt : 0; |
| 726 return textDirection; | 752 return textDirection; |
| 727 } | 753 } |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1033 #ifndef NDEBUG | 1059 #ifndef NDEBUG |
| 1034 | 1060 |
| 1035 // For use in the debugger | 1061 // For use in the debugger |
| 1036 void dumpInnerHTML(blink::HTMLElement*); | 1062 void dumpInnerHTML(blink::HTMLElement*); |
| 1037 | 1063 |
| 1038 void dumpInnerHTML(blink::HTMLElement* element) | 1064 void dumpInnerHTML(blink::HTMLElement* element) |
| 1039 { | 1065 { |
| 1040 printf("%s\n", element->innerHTML().ascii().data()); | 1066 printf("%s\n", element->innerHTML().ascii().data()); |
| 1041 } | 1067 } |
| 1042 #endif | 1068 #endif |
| OLD | NEW |