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 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
789 node = NodeTraversal::nextSkippingChildren(node, firstNode); | 789 node = NodeTraversal::nextSkippingChildren(node, firstNode); |
790 continue; | 790 continue; |
791 } | 791 } |
792 node->setSelfOrAncestorHasDirAutoAttribute(flag); | 792 node->setSelfOrAncestorHasDirAutoAttribute(flag); |
793 if (node == lastNode) | 793 if (node == lastNode) |
794 return; | 794 return; |
795 node = NodeTraversal::next(node, firstNode); | 795 node = NodeTraversal::next(node, firstNode); |
796 } | 796 } |
797 } | 797 } |
798 | 798 |
799 void HTMLElement::childrenChanged(bool changedByParser, Node* beforeChange, Node * afterChange, int childCountDelta) | 799 void HTMLElement::childrenChanged(bool changedByParser, const Handle<Node>& befo reChange, const Handle<Node>& afterChange, int childCountDelta) |
800 { | 800 { |
801 StyledElement::childrenChanged(changedByParser, beforeChange, afterChange, c hildCountDelta); | 801 StyledElement::childrenChanged(changedByParser, beforeChange, afterChange, c hildCountDelta); |
802 | 802 |
803 if (!selfOrAncestorHasDirAutoAttribute()) | 803 if (!selfOrAncestorHasDirAutoAttribute()) |
804 return; | 804 return; |
805 | 805 |
806 for (Element* ancestor = this; ancestor; ancestor = ancestor->parentElement( )) { | 806 for (Element* ancestor = this; ancestor; ancestor = ancestor->parentElement( )) { |
807 if (!elementAffectsDirectionality(ancestor)) | 807 if (!elementAffectsDirectionality(ancestor)) |
808 continue; | 808 continue; |
809 toHTMLElement(ancestor)->calculateAndAdjustDirectionality(); | 809 toHTMLElement(ancestor)->calculateAndAdjustDirectionality(); |
(...skipping 27 matching lines...) Expand all Loading... | |
837 { | 837 { |
838 if (!(selfOrAncestorHasDirAutoAttribute() && hasDirectionAuto())) { | 838 if (!(selfOrAncestorHasDirAutoAttribute() && hasDirectionAuto())) { |
839 isAuto = false; | 839 isAuto = false; |
840 return LTR; | 840 return LTR; |
841 } | 841 } |
842 | 842 |
843 isAuto = true; | 843 isAuto = true; |
844 return directionality(); | 844 return directionality(); |
845 } | 845 } |
846 | 846 |
847 TextDirection HTMLElement::directionality(Node** strongDirectionalityTextNode) c onst | 847 TextDirection HTMLElement::directionality(Handle<Node>* strongDirectionalityText Node) const |
haraken
2013/08/06 01:32:50
Could you change Handle<Node>* to Handle<Node>& ?
| |
848 { | 848 { |
849 if (isHTMLTextFormControlElement(this)) { | 849 if (isHTMLTextFormControlElement(this)) { |
850 Handle<HTMLTextFormControlElement> textElement = toHTMLTextFormControlEl ement(const_cast<HTMLElement*>(this)); | 850 Handle<HTMLTextFormControlElement> textElement = toHTMLTextFormControlEl ement(const_cast<HTMLElement*>(this)); |
851 bool hasStrongDirectionality; | 851 bool hasStrongDirectionality; |
852 Unicode::Direction textDirection = textElement->value().defaultWritingDi rection(&hasStrongDirectionality); | 852 Unicode::Direction textDirection = textElement->value().defaultWritingDi rection(&hasStrongDirectionality); |
853 if (strongDirectionalityTextNode) | 853 if (strongDirectionalityTextNode) |
854 *strongDirectionalityTextNode = hasStrongDirectionality ? textElemen t.raw() : 0; | 854 *strongDirectionalityTextNode = hasStrongDirectionality ? textElemen t : nullptr; |
855 return (textDirection == Unicode::LeftToRight) ? LTR : RTL; | 855 return (textDirection == Unicode::LeftToRight) ? LTR : RTL; |
856 } | 856 } |
857 | 857 |
858 Node* node = firstChild(); | 858 Node* node = firstChild(); |
859 while (node) { | 859 while (node) { |
860 // Skip bdi, script, style and text form controls. | 860 // Skip bdi, script, style and text form controls. |
861 if (equalIgnoringCase(node->nodeName(), "bdi") || node->hasTagName(scrip tTag) || node->hasTagName(styleTag) | 861 if (equalIgnoringCase(node->nodeName(), "bdi") || node->hasTagName(scrip tTag) || node->hasTagName(styleTag) |
862 || (node->isElementNode() && toElement(node)->isTextFormControl())) { | 862 || (node->isElementNode() && toElement(node)->isTextFormControl())) { |
863 node = NodeTraversal::nextSkippingChildren(node, this); | 863 node = NodeTraversal::nextSkippingChildren(node, this); |
864 continue; | 864 continue; |
865 } | 865 } |
866 | 866 |
867 // Skip elements with valid dir attribute | 867 // Skip elements with valid dir attribute |
868 if (node->isElementNode()) { | 868 if (node->isElementNode()) { |
869 AtomicString dirAttributeValue = toElement(node)->fastGetAttribute(d irAttr); | 869 AtomicString dirAttributeValue = toElement(node)->fastGetAttribute(d irAttr); |
870 if (equalIgnoringCase(dirAttributeValue, "rtl") || equalIgnoringCase (dirAttributeValue, "ltr") || equalIgnoringCase(dirAttributeValue, "auto")) { | 870 if (equalIgnoringCase(dirAttributeValue, "rtl") || equalIgnoringCase (dirAttributeValue, "ltr") || equalIgnoringCase(dirAttributeValue, "auto")) { |
871 node = NodeTraversal::nextSkippingChildren(node, this); | 871 node = NodeTraversal::nextSkippingChildren(node, this); |
872 continue; | 872 continue; |
873 } | 873 } |
874 } | 874 } |
875 | 875 |
876 if (node->isTextNode()) { | 876 if (node->isTextNode()) { |
877 bool hasStrongDirectionality; | 877 bool hasStrongDirectionality; |
878 WTF::Unicode::Direction textDirection = node->textContent(true).defa ultWritingDirection(&hasStrongDirectionality); | 878 WTF::Unicode::Direction textDirection = node->textContent(true).defa ultWritingDirection(&hasStrongDirectionality); |
879 if (hasStrongDirectionality) { | 879 if (hasStrongDirectionality) { |
880 if (strongDirectionalityTextNode) | 880 if (strongDirectionalityTextNode) |
881 *strongDirectionalityTextNode = node; | 881 *strongDirectionalityTextNode = adoptRawResult(node); |
882 return (textDirection == WTF::Unicode::LeftToRight) ? LTR : RTL; | 882 return (textDirection == WTF::Unicode::LeftToRight) ? LTR : RTL; |
883 } | 883 } |
884 } | 884 } |
885 node = NodeTraversal::next(node, this); | 885 node = NodeTraversal::next(node, this); |
886 } | 886 } |
887 if (strongDirectionalityTextNode) | 887 if (strongDirectionalityTextNode) |
888 *strongDirectionalityTextNode = 0; | 888 *strongDirectionalityTextNode = nullptr; |
889 return LTR; | 889 return LTR; |
890 } | 890 } |
891 | 891 |
892 void HTMLElement::dirAttributeChanged(const AtomicString& value) | 892 void HTMLElement::dirAttributeChanged(const AtomicString& value) |
893 { | 893 { |
894 Element* parent = parentElement(); | 894 Element* parent = parentElement(); |
895 | 895 |
896 if (parent && parent->isHTMLElement() && parent->selfOrAncestorHasDirAutoAtt ribute()) | 896 if (parent && parent->isHTMLElement() && parent->selfOrAncestorHasDirAutoAtt ribute()) |
897 toHTMLElement(parent)->adjustDirectionalityIfNeededAfterChildAttributeCh anged(this); | 897 toHTMLElement(parent)->adjustDirectionalityIfNeededAfterChildAttributeCh anged(this); |
898 | 898 |
899 if (equalIgnoringCase(value, "auto")) | 899 if (equalIgnoringCase(value, "auto")) |
900 calculateAndAdjustDirectionality(); | 900 calculateAndAdjustDirectionality(); |
901 } | 901 } |
902 | 902 |
903 void HTMLElement::adjustDirectionalityIfNeededAfterChildAttributeChanged(Element * child) | 903 void HTMLElement::adjustDirectionalityIfNeededAfterChildAttributeChanged(Element * child) |
904 { | 904 { |
905 ASSERT(selfOrAncestorHasDirAutoAttribute()); | 905 ASSERT(selfOrAncestorHasDirAutoAttribute()); |
906 Node* strongDirectionalityTextNode; | 906 TextDirection textDirection = directionality(); |
907 TextDirection textDirection = directionality(&strongDirectionalityTextNode); | |
908 setHasDirAutoFlagRecursively(child, false); | 907 setHasDirAutoFlagRecursively(child, false); |
909 if (renderer() && renderer()->style() && renderer()->style()->direction() != textDirection) { | 908 if (renderer() && renderer()->style() && renderer()->style()->direction() != textDirection) { |
910 Element* elementToAdjust = this; | 909 Element* elementToAdjust = this; |
911 for (; elementToAdjust; elementToAdjust = elementToAdjust->parentElement ()) { | 910 for (; elementToAdjust; elementToAdjust = elementToAdjust->parentElement ()) { |
912 if (elementAffectsDirectionality(elementToAdjust)) { | 911 if (elementAffectsDirectionality(elementToAdjust)) { |
913 elementToAdjust->setNeedsStyleRecalc(); | 912 elementToAdjust->setNeedsStyleRecalc(); |
914 return; | 913 return; |
915 } | 914 } |
916 } | 915 } |
917 } | 916 } |
918 } | 917 } |
919 | 918 |
920 void HTMLElement::calculateAndAdjustDirectionality() | 919 void HTMLElement::calculateAndAdjustDirectionality() |
921 { | 920 { |
922 Node* strongDirectionalityTextNode; | 921 Handle<Node> strongDirectionalityTextNode; |
923 TextDirection textDirection = directionality(&strongDirectionalityTextNode); | 922 TextDirection textDirection = directionality(&strongDirectionalityTextNode); |
924 setHasDirAutoFlagRecursively(this, true, strongDirectionalityTextNode); | 923 setHasDirAutoFlagRecursively(this, true, strongDirectionalityTextNode.raw()) ; |
925 if (renderer() && renderer()->style() && renderer()->style()->direction() != textDirection) | 924 if (renderer() && renderer()->style() && renderer()->style()->direction() != textDirection) |
926 setNeedsStyleRecalc(); | 925 setNeedsStyleRecalc(); |
927 } | 926 } |
928 | 927 |
929 void HTMLElement::addHTMLLengthToStyle(Handle<MutableStylePropertySet> style, CS SPropertyID propertyID, const String& value) | 928 void HTMLElement::addHTMLLengthToStyle(Handle<MutableStylePropertySet> style, CS SPropertyID propertyID, const String& value) |
930 { | 929 { |
931 // FIXME: This function should not spin up the CSS parser, but should instea d just figure out the correct | 930 // FIXME: This function should not spin up the CSS parser, but should instea d just figure out the correct |
932 // length unit and make the appropriate parsed value. | 931 // length unit and make the appropriate parsed value. |
933 | 932 |
934 // strip attribute garbage.. | 933 // strip attribute garbage.. |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1047 #ifndef NDEBUG | 1046 #ifndef NDEBUG |
1048 | 1047 |
1049 // For use in the debugger | 1048 // For use in the debugger |
1050 void dumpInnerHTML(WebCore::HTMLElement*); | 1049 void dumpInnerHTML(WebCore::HTMLElement*); |
1051 | 1050 |
1052 void dumpInnerHTML(WebCore::HTMLElement* element) | 1051 void dumpInnerHTML(WebCore::HTMLElement* element) |
1053 { | 1052 { |
1054 printf("%s\n", element->innerHTML().ascii().data()); | 1053 printf("%s\n", element->innerHTML().ascii().data()); |
1055 } | 1054 } |
1056 #endif | 1055 #endif |
OLD | NEW |