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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUser Modify, CSSValueReadOnly); | 178 addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUser Modify, CSSValueReadOnly); |
| 179 } else if (name == hiddenAttr) { | 179 } else if (name == hiddenAttr) { |
| 180 addPropertyToPresentationAttributeStyle(style, CSSPropertyDisplay, CSSVa lueNone); | 180 addPropertyToPresentationAttributeStyle(style, CSSPropertyDisplay, CSSVa lueNone); |
| 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)) { |
| 192 const AtomicString& dirValue = determineDirection() == RTL ? "rt l" : "ltr"; | |
|
tkent
2014/09/10 01:08:52
I realized that we didn't need to compute directio
Sunil Ratnu
2014/09/10 04:33:00
Done.
| |
| 193 addPropertyToPresentationAttributeStyle(style, CSSPropertyDirect ion, dirValue); | |
| 194 } else { | |
| 192 addPropertyToPresentationAttributeStyle(style, CSSPropertyDirect ion, value); | 195 addPropertyToPresentationAttributeStyle(style, CSSPropertyDirect ion, value); |
|
tkent
2014/09/10 01:08:52
This can set "auto" to "direction" CSS property.
Sunil Ratnu
2014/09/10 04:33:00
We don't have this code part now since whenever we
| |
| 193 else | 196 } |
| 194 addPropertyToPresentationAttributeStyle(style, CSSPropertyDirect ion, "ltr"); | |
| 195 if (!hasTagName(bdiTag) && !hasTagName(bdoTag) && !hasTagName(output Tag)) | 197 if (!hasTagName(bdiTag) && !hasTagName(bdoTag) && !hasTagName(output Tag)) |
| 196 addPropertyToPresentationAttributeStyle(style, CSSPropertyUnicod eBidi, CSSValueEmbed); | 198 addPropertyToPresentationAttributeStyle(style, CSSPropertyUnicod eBidi, CSSValueEmbed); |
| 197 } | 199 } |
| 198 } else if (name.matches(XMLNames::langAttr)) | 200 } else if (name.matches(XMLNames::langAttr)) |
| 199 mapLanguageAttributeToLocale(value, style); | 201 mapLanguageAttributeToLocale(value, style); |
| 200 else if (name == langAttr) { | 202 else if (name == langAttr) { |
| 201 // xml:lang has a higher priority than lang. | 203 // xml:lang has a higher priority than lang. |
| 202 if (!fastHasAttribute(XMLNames::langAttr)) | 204 if (!fastHasAttribute(XMLNames::langAttr)) |
| 203 mapLanguageAttributeToLocale(value, style); | 205 mapLanguageAttributeToLocale(value, style); |
| 204 } else | 206 } else |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 676 { | 678 { |
| 677 if (!(selfOrAncestorHasDirAutoAttribute() && hasDirectionAuto())) { | 679 if (!(selfOrAncestorHasDirAutoAttribute() && hasDirectionAuto())) { |
| 678 isAuto = false; | 680 isAuto = false; |
| 679 return LTR; | 681 return LTR; |
| 680 } | 682 } |
| 681 | 683 |
| 682 isAuto = true; | 684 isAuto = true; |
| 683 return directionality(); | 685 return directionality(); |
| 684 } | 686 } |
| 685 | 687 |
| 688 // FIXME: Implement directionality for input type='tel' when it is supported | |
| 689 // [Currently it is not supported in any of the browsers]. | |
| 690 // Spec: http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#th e-directionality | |
| 691 TextDirection HTMLElement::determineDirection() const | |
| 692 { | |
| 693 for (const HTMLElement* element = this; element; element = Traversal<HTMLEle ment>::firstAncestor(*element)) { | |
| 694 const AtomicString& dirAttributeValue = element->fastGetAttribute(dirAtt r); | |
| 695 if (dirAttributeValue.isNull()) | |
| 696 continue; | |
| 697 | |
| 698 if (equalIgnoringCase(dirAttributeValue, "rtl")) | |
| 699 return RTL; | |
| 700 | |
| 701 if (equalIgnoringCase(dirAttributeValue, "ltr")) | |
| 702 return LTR; | |
| 703 | |
| 704 if (equalIgnoringCase(dirAttributeValue, "auto")) { | |
| 705 bool isAuto; | |
| 706 return element->directionalityIfhasDirAutoAttribute(isAuto); | |
| 707 } | |
| 708 } | |
| 709 | |
| 710 return LTR; | |
| 711 } | |
| 712 | |
| 713 // FIXME: This implementation deviates from the spec in case of 'textarea' havin g 'auto' attribute. | |
| 714 // Spec: http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#th e-directionality | |
| 686 TextDirection HTMLElement::directionality(Node** strongDirectionalityTextNode) c onst | 715 TextDirection HTMLElement::directionality(Node** strongDirectionalityTextNode) c onst |
| 687 { | 716 { |
| 688 if (isHTMLInputElement(*this)) { | 717 if (isHTMLInputElement(*this)) { |
| 689 HTMLInputElement* inputElement = toHTMLInputElement(const_cast<HTMLEleme nt*>(this)); | 718 HTMLInputElement* inputElement = toHTMLInputElement(const_cast<HTMLEleme nt*>(this)); |
| 690 bool hasStrongDirectionality; | 719 bool hasStrongDirectionality; |
| 691 TextDirection textDirection = determineDirectionality(inputElement->valu e(), hasStrongDirectionality); | 720 TextDirection textDirection = determineDirectionality(inputElement->valu e(), hasStrongDirectionality); |
| 692 if (strongDirectionalityTextNode) | 721 if (strongDirectionalityTextNode) |
| 693 *strongDirectionalityTextNode = hasStrongDirectionality ? inputEleme nt : 0; | 722 *strongDirectionalityTextNode = hasStrongDirectionality ? inputEleme nt : 0; |
| 694 return textDirection; | 723 return textDirection; |
| 695 } | 724 } |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 994 #ifndef NDEBUG | 1023 #ifndef NDEBUG |
| 995 | 1024 |
| 996 // For use in the debugger | 1025 // For use in the debugger |
| 997 void dumpInnerHTML(blink::HTMLElement*); | 1026 void dumpInnerHTML(blink::HTMLElement*); |
| 998 | 1027 |
| 999 void dumpInnerHTML(blink::HTMLElement* element) | 1028 void dumpInnerHTML(blink::HTMLElement* element) |
| 1000 { | 1029 { |
| 1001 printf("%s\n", element->innerHTML().ascii().data()); | 1030 printf("%s\n", element->innerHTML().ascii().data()); |
| 1002 } | 1031 } |
| 1003 #endif | 1032 #endif |
| OLD | NEW |