| 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, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "core/editing/markup.h" | 45 #include "core/editing/markup.h" |
| 46 #include "core/html/HTMLBRElement.h" | 46 #include "core/html/HTMLBRElement.h" |
| 47 #include "core/html/HTMLFormElement.h" | 47 #include "core/html/HTMLFormElement.h" |
| 48 #include "core/html/HTMLInputElement.h" | 48 #include "core/html/HTMLInputElement.h" |
| 49 #include "core/html/HTMLTemplateElement.h" | 49 #include "core/html/HTMLTemplateElement.h" |
| 50 #include "core/html/HTMLTextFormControlElement.h" | 50 #include "core/html/HTMLTextFormControlElement.h" |
| 51 #include "core/html/parser/HTMLParserIdioms.h" | 51 #include "core/html/parser/HTMLParserIdioms.h" |
| 52 #include "core/loader/FrameLoader.h" | 52 #include "core/loader/FrameLoader.h" |
| 53 #include "core/page/Frame.h" | 53 #include "core/page/Frame.h" |
| 54 #include "core/page/Settings.h" | 54 #include "core/page/Settings.h" |
| 55 #include "core/platform/graphics/TextRunIterator.h" |
| 56 #include "core/platform/text/BidiResolver.h" |
| 55 #include "core/rendering/RenderWordBreak.h" | 57 #include "core/rendering/RenderWordBreak.h" |
| 56 #include "wtf/StdLibExtras.h" | 58 #include "wtf/StdLibExtras.h" |
| 57 #include "wtf/text/CString.h" | 59 #include "wtf/text/CString.h" |
| 58 | 60 |
| 59 namespace WebCore { | 61 namespace WebCore { |
| 60 | 62 |
| 61 using namespace HTMLNames; | 63 using namespace HTMLNames; |
| 62 using namespace WTF; | 64 using namespace WTF; |
| 63 | 65 |
| 64 using std::min; | 66 using std::min; |
| (...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 { | 843 { |
| 842 if (!(selfOrAncestorHasDirAutoAttribute() && hasDirectionAuto())) { | 844 if (!(selfOrAncestorHasDirAutoAttribute() && hasDirectionAuto())) { |
| 843 isAuto = false; | 845 isAuto = false; |
| 844 return LTR; | 846 return LTR; |
| 845 } | 847 } |
| 846 | 848 |
| 847 isAuto = true; | 849 isAuto = true; |
| 848 return directionality(); | 850 return directionality(); |
| 849 } | 851 } |
| 850 | 852 |
| 853 static TextDirection determineDirectionality(const String& value, bool& hasStron
gDirectionality) |
| 854 { |
| 855 TextRun run(value); |
| 856 BidiResolver<TextRunIterator, BidiCharacterRun> bidiResolver; |
| 857 bidiResolver.setStatus(BidiStatus(run.direction(), run.directionalOverride()
)); |
| 858 bidiResolver.setPositionIgnoringNestedIsolates(TextRunIterator(&run, 0)); |
| 859 return bidiResolver.determineParagraphDirectionality(&hasStrongDirectionalit
y); |
| 860 } |
| 861 |
| 851 TextDirection HTMLElement::directionality(Node** strongDirectionalityTextNode) c
onst | 862 TextDirection HTMLElement::directionality(Node** strongDirectionalityTextNode) c
onst |
| 852 { | 863 { |
| 853 if (hasTagName(inputTag)) { | 864 if (hasTagName(inputTag)) { |
| 854 HTMLInputElement* inputElement = toHTMLInputElement(const_cast<HTMLEleme
nt*>(this)); | 865 HTMLInputElement* inputElement = toHTMLInputElement(const_cast<HTMLEleme
nt*>(this)); |
| 855 bool hasStrongDirectionality; | 866 bool hasStrongDirectionality; |
| 856 Unicode::Direction textDirection = inputElement->value().defaultWritingD
irection(&hasStrongDirectionality); | 867 TextDirection textDirection = determineDirectionality(inputElement->valu
e(), hasStrongDirectionality); |
| 857 if (strongDirectionalityTextNode) | 868 if (strongDirectionalityTextNode) |
| 858 *strongDirectionalityTextNode = hasStrongDirectionality ? inputEleme
nt : 0; | 869 *strongDirectionalityTextNode = hasStrongDirectionality ? inputEleme
nt : 0; |
| 859 return (textDirection == Unicode::LeftToRight) ? LTR : RTL; | 870 return textDirection; |
| 860 } | 871 } |
| 861 | 872 |
| 862 Node* node = firstChild(); | 873 Node* node = firstChild(); |
| 863 while (node) { | 874 while (node) { |
| 864 // Skip bdi, script, style and text form controls. | 875 // Skip bdi, script, style and text form controls. |
| 865 if (equalIgnoringCase(node->nodeName(), "bdi") || node->hasTagName(scrip
tTag) || node->hasTagName(styleTag) | 876 if (equalIgnoringCase(node->nodeName(), "bdi") || node->hasTagName(scrip
tTag) || node->hasTagName(styleTag) |
| 866 || (node->isElementNode() && toElement(node)->isTextFormControl()))
{ | 877 || (node->isElementNode() && toElement(node)->isTextFormControl()))
{ |
| 867 node = NodeTraversal::nextSkippingChildren(node, this); | 878 node = NodeTraversal::nextSkippingChildren(node, this); |
| 868 continue; | 879 continue; |
| 869 } | 880 } |
| 870 | 881 |
| 871 // Skip elements with valid dir attribute | 882 // Skip elements with valid dir attribute |
| 872 if (node->isElementNode()) { | 883 if (node->isElementNode()) { |
| 873 AtomicString dirAttributeValue = toElement(node)->fastGetAttribute(d
irAttr); | 884 AtomicString dirAttributeValue = toElement(node)->fastGetAttribute(d
irAttr); |
| 874 if (equalIgnoringCase(dirAttributeValue, "rtl") || equalIgnoringCase
(dirAttributeValue, "ltr") || equalIgnoringCase(dirAttributeValue, "auto")) { | 885 if (equalIgnoringCase(dirAttributeValue, "rtl") || equalIgnoringCase
(dirAttributeValue, "ltr") || equalIgnoringCase(dirAttributeValue, "auto")) { |
| 875 node = NodeTraversal::nextSkippingChildren(node, this); | 886 node = NodeTraversal::nextSkippingChildren(node, this); |
| 876 continue; | 887 continue; |
| 877 } | 888 } |
| 878 } | 889 } |
| 879 | 890 |
| 880 if (node->isTextNode()) { | 891 if (node->isTextNode()) { |
| 881 bool hasStrongDirectionality; | 892 bool hasStrongDirectionality; |
| 882 WTF::Unicode::Direction textDirection = node->textContent(true).defa
ultWritingDirection(&hasStrongDirectionality); | 893 TextDirection textDirection = determineDirectionality(node->textCont
ent(true), hasStrongDirectionality); |
| 883 if (hasStrongDirectionality) { | 894 if (hasStrongDirectionality) { |
| 884 if (strongDirectionalityTextNode) | 895 if (strongDirectionalityTextNode) |
| 885 *strongDirectionalityTextNode = node; | 896 *strongDirectionalityTextNode = node; |
| 886 return (textDirection == WTF::Unicode::LeftToRight) ? LTR : RTL; | 897 return textDirection; |
| 887 } | 898 } |
| 888 } | 899 } |
| 889 node = NodeTraversal::next(node, this); | 900 node = NodeTraversal::next(node, this); |
| 890 } | 901 } |
| 891 if (strongDirectionalityTextNode) | 902 if (strongDirectionalityTextNode) |
| 892 *strongDirectionalityTextNode = 0; | 903 *strongDirectionalityTextNode = 0; |
| 893 return LTR; | 904 return LTR; |
| 894 } | 905 } |
| 895 | 906 |
| 896 void HTMLElement::dirAttributeChanged(const AtomicString& value) | 907 void HTMLElement::dirAttributeChanged(const AtomicString& value) |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 #ifndef NDEBUG | 1113 #ifndef NDEBUG |
| 1103 | 1114 |
| 1104 // For use in the debugger | 1115 // For use in the debugger |
| 1105 void dumpInnerHTML(WebCore::HTMLElement*); | 1116 void dumpInnerHTML(WebCore::HTMLElement*); |
| 1106 | 1117 |
| 1107 void dumpInnerHTML(WebCore::HTMLElement* element) | 1118 void dumpInnerHTML(WebCore::HTMLElement* element) |
| 1108 { | 1119 { |
| 1109 printf("%s\n", element->innerHTML().ascii().data()); | 1120 printf("%s\n", element->innerHTML().ascii().data()); |
| 1110 } | 1121 } |
| 1111 #endif | 1122 #endif |
| OLD | NEW |