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 20 matching lines...) Expand all Loading... | |
| 31 #include "core/CSSValueKeywords.h" | 31 #include "core/CSSValueKeywords.h" |
| 32 #include "core/HTMLNames.h" | 32 #include "core/HTMLNames.h" |
| 33 #include "core/V8HTMLElementWrapperFactory.h" // FIXME: should be bindings/core/ v8 | 33 #include "core/V8HTMLElementWrapperFactory.h" // FIXME: should be bindings/core/ v8 |
| 34 #include "core/XMLNames.h" | 34 #include "core/XMLNames.h" |
| 35 #include "core/css/CSSMarkup.h" | 35 #include "core/css/CSSMarkup.h" |
| 36 #include "core/css/CSSValuePool.h" | 36 #include "core/css/CSSValuePool.h" |
| 37 #include "core/css/StylePropertySet.h" | 37 #include "core/css/StylePropertySet.h" |
| 38 #include "core/dom/DocumentFragment.h" | 38 #include "core/dom/DocumentFragment.h" |
| 39 #include "core/dom/ElementTraversal.h" | 39 #include "core/dom/ElementTraversal.h" |
| 40 #include "core/dom/ExceptionCode.h" | 40 #include "core/dom/ExceptionCode.h" |
| 41 #include "core/dom/NodeRenderStyle.h" | |
| 41 #include "core/dom/NodeTraversal.h" | 42 #include "core/dom/NodeTraversal.h" |
| 42 #include "core/dom/Text.h" | 43 #include "core/dom/Text.h" |
| 43 #include "core/dom/shadow/ElementShadow.h" | 44 #include "core/dom/shadow/ElementShadow.h" |
| 44 #include "core/dom/shadow/ShadowRoot.h" | 45 #include "core/dom/shadow/ShadowRoot.h" |
| 45 #include "core/editing/markup.h" | 46 #include "core/editing/markup.h" |
| 46 #include "core/events/EventListener.h" | 47 #include "core/events/EventListener.h" |
| 47 #include "core/events/KeyboardEvent.h" | 48 #include "core/events/KeyboardEvent.h" |
| 48 #include "core/frame/Settings.h" | 49 #include "core/frame/Settings.h" |
| 49 #include "core/html/HTMLBRElement.h" | 50 #include "core/html/HTMLBRElement.h" |
| 50 #include "core/html/HTMLFormElement.h" | 51 #include "core/html/HTMLFormElement.h" |
| 51 #include "core/html/HTMLInputElement.h" | 52 #include "core/html/HTMLInputElement.h" |
| 52 #include "core/html/HTMLMenuElement.h" | 53 #include "core/html/HTMLMenuElement.h" |
| 53 #include "core/html/HTMLTemplateElement.h" | 54 #include "core/html/HTMLTemplateElement.h" |
| 55 #include "core/html/HTMLTextAreaElement.h" | |
| 54 #include "core/html/HTMLTextFormControlElement.h" | 56 #include "core/html/HTMLTextFormControlElement.h" |
| 55 #include "core/html/parser/HTMLParserIdioms.h" | 57 #include "core/html/parser/HTMLParserIdioms.h" |
| 56 #include "core/rendering/RenderObject.h" | 58 #include "core/rendering/RenderObject.h" |
| 57 #include "platform/text/BidiResolver.h" | 59 #include "platform/text/BidiResolver.h" |
| 58 #include "platform/text/BidiTextRun.h" | 60 #include "platform/text/BidiTextRun.h" |
| 59 #include "platform/text/TextRunIterator.h" | 61 #include "platform/text/TextRunIterator.h" |
| 60 #include "wtf/StdLibExtras.h" | 62 #include "wtf/StdLibExtras.h" |
| 61 #include "wtf/text/CString.h" | 63 #include "wtf/text/CString.h" |
| 62 | 64 |
| 63 namespace blink { | 65 namespace blink { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 } else if (name == draggableAttr) { | 184 } else if (name == draggableAttr) { |
| 183 if (equalIgnoringCase(value, "true")) { | 185 if (equalIgnoringCase(value, "true")) { |
| 184 addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUser Drag, CSSValueElement); | 186 addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUser Drag, CSSValueElement); |
| 185 addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUser Select, CSSValueNone); | 187 addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUser Select, CSSValueNone); |
| 186 } else if (equalIgnoringCase(value, "false")) | 188 } else if (equalIgnoringCase(value, "false")) |
| 187 addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUser Drag, CSSValueNone); | 189 addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitUser Drag, CSSValueNone); |
| 188 } else if (name == dirAttr) { | 190 } else if (name == dirAttr) { |
| 189 if (equalIgnoringCase(value, "auto")) | 191 if (equalIgnoringCase(value, "auto")) |
| 190 addPropertyToPresentationAttributeStyle(style, CSSPropertyUnicodeBid i, unicodeBidiAttributeForDirAuto(this)); | 192 addPropertyToPresentationAttributeStyle(style, CSSPropertyUnicodeBid i, unicodeBidiAttributeForDirAuto(this)); |
| 191 else { | 193 else { |
| 192 if (isValidDirAttribute(value)) | 194 if (!isValidDirAttribute(value)) { |
| 195 addPropertyToPresentationAttributeStyle(style, CSSPropertyDirect ion, directionForFormData()); | |
|
tkent
2014/09/09 01:42:28
|ForFormData| is an inappropriate name. FormData
Sunil Ratnu
2014/09/09 03:31:03
Done.
| |
| 196 } else { | |
| 193 addPropertyToPresentationAttributeStyle(style, CSSPropertyDirect ion, value); | 197 addPropertyToPresentationAttributeStyle(style, CSSPropertyDirect ion, value); |
| 194 else | 198 } |
| 195 addPropertyToPresentationAttributeStyle(style, CSSPropertyDirect ion, "ltr"); | |
| 196 if (!hasTagName(bdiTag) && !hasTagName(bdoTag) && !hasTagName(output Tag)) | 199 if (!hasTagName(bdiTag) && !hasTagName(bdoTag) && !hasTagName(output Tag)) |
| 197 addPropertyToPresentationAttributeStyle(style, CSSPropertyUnicod eBidi, CSSValueEmbed); | 200 addPropertyToPresentationAttributeStyle(style, CSSPropertyUnicod eBidi, CSSValueEmbed); |
| 198 } | 201 } |
| 199 } else if (name.matches(XMLNames::langAttr)) | 202 } else if (name.matches(XMLNames::langAttr)) |
| 200 mapLanguageAttributeToLocale(value, style); | 203 mapLanguageAttributeToLocale(value, style); |
| 201 else if (name == langAttr) { | 204 else if (name == langAttr) { |
| 202 // xml:lang has a higher priority than lang. | 205 // xml:lang has a higher priority than lang. |
| 203 if (!fastHasAttribute(XMLNames::langAttr)) | 206 if (!fastHasAttribute(XMLNames::langAttr)) |
| 204 mapLanguageAttributeToLocale(value, style); | 207 mapLanguageAttributeToLocale(value, style); |
| 205 } else | 208 } else |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 677 { | 680 { |
| 678 if (!(selfOrAncestorHasDirAutoAttribute() && hasDirectionAuto())) { | 681 if (!(selfOrAncestorHasDirAutoAttribute() && hasDirectionAuto())) { |
| 679 isAuto = false; | 682 isAuto = false; |
| 680 return LTR; | 683 return LTR; |
| 681 } | 684 } |
| 682 | 685 |
| 683 isAuto = true; | 686 isAuto = true; |
| 684 return directionality(); | 687 return directionality(); |
| 685 } | 688 } |
| 686 | 689 |
| 690 String HTMLElement::directionForFormData() const | |
| 691 { | |
| 692 for (const HTMLElement* element = this; element; element = Traversal<HTMLEle ment>::firstAncestor(*element)) { | |
| 693 const AtomicString& dirAttributeValue = element->fastGetAttribute(dirAtt r); | |
| 694 if (dirAttributeValue.isNull()) | |
| 695 continue; | |
| 696 | |
| 697 if (equalIgnoringCase(dirAttributeValue, "rtl") || equalIgnoringCase(dir AttributeValue, "ltr")) | |
| 698 return dirAttributeValue; | |
| 699 | |
| 700 if (equalIgnoringCase(dirAttributeValue, "auto")) { | |
| 701 bool isAuto; | |
| 702 TextDirection textDirection = element->directionalityIfhasDirAutoAtt ribute(isAuto); | |
| 703 return textDirection == RTL ? "rtl" : "ltr"; | |
| 704 } | |
| 705 } | |
| 706 | |
| 707 return "ltr"; | |
| 708 } | |
| 709 | |
| 687 TextDirection HTMLElement::directionality(Node** strongDirectionalityTextNode) c onst | 710 TextDirection HTMLElement::directionality(Node** strongDirectionalityTextNode) c onst |
| 688 { | 711 { |
| 689 if (isHTMLInputElement(*this)) { | 712 if (isHTMLInputElement(*this)) { |
| 690 HTMLInputElement* inputElement = toHTMLInputElement(const_cast<HTMLEleme nt*>(this)); | 713 HTMLInputElement* inputElement = toHTMLInputElement(const_cast<HTMLEleme nt*>(this)); |
| 714 if (inputElement->isTextField() || inputElement->isSearchField() | |
| 715 || inputElement->isURLField() || inputElement->isEmailField()) { | |
| 716 bool hasStrongDirectionality; | |
| 717 TextDirection textDirection = determineDirectionality(inputElement-> value(), hasStrongDirectionality); | |
| 718 if (strongDirectionalityTextNode) | |
| 719 *strongDirectionalityTextNode = hasStrongDirectionality ? inputE lement : 0; | |
| 720 return textDirection; | |
| 721 } | |
| 722 } else if (isHTMLTextAreaElement(*this)) { | |
| 723 HTMLTextAreaElement* textAreaElement = toHTMLTextAreaElement(const_cast< HTMLElement*>(this)); | |
| 691 bool hasStrongDirectionality; | 724 bool hasStrongDirectionality; |
| 692 TextDirection textDirection = determineDirectionality(inputElement->valu e(), hasStrongDirectionality); | 725 TextDirection textDirection = determineDirectionality(textAreaElement->v alue(), hasStrongDirectionality); |
| 693 if (strongDirectionalityTextNode) | 726 if (strongDirectionalityTextNode) |
| 694 *strongDirectionalityTextNode = hasStrongDirectionality ? inputEleme nt : 0; | 727 *strongDirectionalityTextNode = hasStrongDirectionality ? textAreaEl ement : 0; |
| 695 return textDirection; | 728 return textDirection; |
| 696 } | 729 } |
| 697 | 730 |
| 698 Node* node = firstChild(); | 731 Node* node = firstChild(); |
| 699 while (node) { | 732 while (node) { |
| 700 // Skip bdi, script, style and text form controls. | 733 // Skip bdi, script, style and text form controls. |
| 701 if (equalIgnoringCase(node->nodeName(), "bdi") || isHTMLScriptElement(*n ode) || isHTMLStyleElement(*node) | 734 if (equalIgnoringCase(node->nodeName(), "bdi") || isHTMLScriptElement(*n ode) || isHTMLStyleElement(*node) |
| 702 || (node->isElementNode() && toElement(node)->isTextFormControl())) { | 735 || (node->isElementNode() && toElement(node)->isTextFormControl())) { |
| 703 node = NodeTraversal::nextSkippingChildren(*node, this); | 736 node = NodeTraversal::nextSkippingChildren(*node, this); |
| 704 continue; | 737 continue; |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 995 #ifndef NDEBUG | 1028 #ifndef NDEBUG |
| 996 | 1029 |
| 997 // For use in the debugger | 1030 // For use in the debugger |
| 998 void dumpInnerHTML(blink::HTMLElement*); | 1031 void dumpInnerHTML(blink::HTMLElement*); |
| 999 | 1032 |
| 1000 void dumpInnerHTML(blink::HTMLElement* element) | 1033 void dumpInnerHTML(blink::HTMLElement* element) |
| 1001 { | 1034 { |
| 1002 printf("%s\n", element->innerHTML().ascii().data()); | 1035 printf("%s\n", element->innerHTML().ascii().data()); |
| 1003 } | 1036 } |
| 1004 #endif | 1037 #endif |
| OLD | NEW |