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/HTMLNames.h" | 31 #include "core/HTMLNames.h" |
32 #include "core/XMLNames.h" | 32 #include "core/XMLNames.h" |
33 #include "core/css/CSSMarkup.h" | 33 #include "core/css/CSSMarkup.h" |
34 #include "core/css/CSSValuePool.h" | 34 #include "core/css/CSSValuePool.h" |
35 #include "core/css/StylePropertySet.h" | 35 #include "core/css/StylePropertySet.h" |
36 #include "core/dom/DocumentFragment.h" | 36 #include "core/dom/DocumentFragment.h" |
37 #include "core/dom/ElementTraversal.h" | 37 #include "core/dom/ElementTraversal.h" |
38 #include "core/dom/ExceptionCode.h" | 38 #include "core/dom/ExceptionCode.h" |
39 #include "core/dom/NodeTraversal.h" | 39 #include "core/dom/NodeTraversal.h" |
40 #include "core/dom/Text.h" | 40 #include "core/dom/Text.h" |
41 #include "core/dom/shadow/ComposedTreeTraversal.h" | |
42 #include "core/dom/shadow/ElementShadow.h" | 41 #include "core/dom/shadow/ElementShadow.h" |
| 42 #include "core/dom/shadow/FlatTreeTraversal.h" |
43 #include "core/dom/shadow/ShadowRoot.h" | 43 #include "core/dom/shadow/ShadowRoot.h" |
44 #include "core/editing/serializers/Serialization.h" | 44 #include "core/editing/serializers/Serialization.h" |
45 #include "core/events/EventListener.h" | 45 #include "core/events/EventListener.h" |
46 #include "core/events/KeyboardEvent.h" | 46 #include "core/events/KeyboardEvent.h" |
47 #include "core/frame/Settings.h" | 47 #include "core/frame/Settings.h" |
48 #include "core/frame/UseCounter.h" | 48 #include "core/frame/UseCounter.h" |
49 #include "core/html/HTMLBRElement.h" | 49 #include "core/html/HTMLBRElement.h" |
50 #include "core/html/HTMLFormElement.h" | 50 #include "core/html/HTMLFormElement.h" |
51 #include "core/html/HTMLInputElement.h" | 51 #include "core/html/HTMLInputElement.h" |
52 #include "core/html/HTMLMenuElement.h" | 52 #include "core/html/HTMLMenuElement.h" |
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 { | 722 { |
723 if (isHTMLInputElement(*this)) { | 723 if (isHTMLInputElement(*this)) { |
724 HTMLInputElement* inputElement = toHTMLInputElement(const_cast<HTMLEleme
nt*>(this)); | 724 HTMLInputElement* inputElement = toHTMLInputElement(const_cast<HTMLEleme
nt*>(this)); |
725 bool hasStrongDirectionality; | 725 bool hasStrongDirectionality; |
726 TextDirection textDirection = determineDirectionality(inputElement->valu
e(), &hasStrongDirectionality); | 726 TextDirection textDirection = determineDirectionality(inputElement->valu
e(), &hasStrongDirectionality); |
727 if (strongDirectionalityTextNode) | 727 if (strongDirectionalityTextNode) |
728 *strongDirectionalityTextNode = hasStrongDirectionality ? inputEleme
nt : 0; | 728 *strongDirectionalityTextNode = hasStrongDirectionality ? inputEleme
nt : 0; |
729 return textDirection; | 729 return textDirection; |
730 } | 730 } |
731 | 731 |
732 Node* node = ComposedTreeTraversal::firstChild(*this); | 732 Node* node = FlatTreeTraversal::firstChild(*this); |
733 while (node) { | 733 while (node) { |
734 // Skip bdi, script, style and text form controls. | 734 // Skip bdi, script, style and text form controls. |
735 if (equalIgnoringCase(node->nodeName(), "bdi") || isHTMLScriptElement(*n
ode) || isHTMLStyleElement(*node) | 735 if (equalIgnoringCase(node->nodeName(), "bdi") || isHTMLScriptElement(*n
ode) || isHTMLStyleElement(*node) |
736 || (node->isElementNode() && toElement(node)->isTextFormControl()))
{ | 736 || (node->isElementNode() && toElement(node)->isTextFormControl()))
{ |
737 node = ComposedTreeTraversal::nextSkippingChildren(*node, this); | 737 node = FlatTreeTraversal::nextSkippingChildren(*node, this); |
738 continue; | 738 continue; |
739 } | 739 } |
740 | 740 |
741 // Skip elements with valid dir attribute | 741 // Skip elements with valid dir attribute |
742 if (node->isElementNode()) { | 742 if (node->isElementNode()) { |
743 AtomicString dirAttributeValue = toElement(node)->fastGetAttribute(d
irAttr); | 743 AtomicString dirAttributeValue = toElement(node)->fastGetAttribute(d
irAttr); |
744 if (isValidDirAttribute(dirAttributeValue)) { | 744 if (isValidDirAttribute(dirAttributeValue)) { |
745 node = ComposedTreeTraversal::nextSkippingChildren(*node, this); | 745 node = FlatTreeTraversal::nextSkippingChildren(*node, this); |
746 continue; | 746 continue; |
747 } | 747 } |
748 } | 748 } |
749 | 749 |
750 if (node->isTextNode()) { | 750 if (node->isTextNode()) { |
751 bool hasStrongDirectionality; | 751 bool hasStrongDirectionality; |
752 TextDirection textDirection = determineDirectionality(node->textCont
ent(true), &hasStrongDirectionality); | 752 TextDirection textDirection = determineDirectionality(node->textCont
ent(true), &hasStrongDirectionality); |
753 if (hasStrongDirectionality) { | 753 if (hasStrongDirectionality) { |
754 if (strongDirectionalityTextNode) | 754 if (strongDirectionalityTextNode) |
755 *strongDirectionalityTextNode = node; | 755 *strongDirectionalityTextNode = node; |
756 return textDirection; | 756 return textDirection; |
757 } | 757 } |
758 } | 758 } |
759 node = ComposedTreeTraversal::next(*node, this); | 759 node = FlatTreeTraversal::next(*node, this); |
760 } | 760 } |
761 if (strongDirectionalityTextNode) | 761 if (strongDirectionalityTextNode) |
762 *strongDirectionalityTextNode = 0; | 762 *strongDirectionalityTextNode = 0; |
763 return LTR; | 763 return LTR; |
764 } | 764 } |
765 | 765 |
766 bool HTMLElement::selfOrAncestorHasDirAutoAttribute() const | 766 bool HTMLElement::selfOrAncestorHasDirAutoAttribute() const |
767 { | 767 { |
768 return layoutObject() && layoutObject()->style() && layoutObject()->style()-
>selfOrAncestorHasDirAutoAttribute(); | 768 return layoutObject() && layoutObject()->style() && layoutObject()->style()-
>selfOrAncestorHasDirAutoAttribute(); |
769 } | 769 } |
770 | 770 |
771 void HTMLElement::dirAttributeChanged(const AtomicString& value) | 771 void HTMLElement::dirAttributeChanged(const AtomicString& value) |
772 { | 772 { |
773 // If an ancestor has dir=auto, and this node has the first character, | 773 // If an ancestor has dir=auto, and this node has the first character, |
774 // changes to dir attribute may affect the ancestor. | 774 // changes to dir attribute may affect the ancestor. |
775 updateDistribution(); | 775 updateDistribution(); |
776 Element* parent = ComposedTreeTraversal::parentElement(*this); | 776 Element* parent = FlatTreeTraversal::parentElement(*this); |
777 if (parent && parent->isHTMLElement() && toHTMLElement(parent)->selfOrAncest
orHasDirAutoAttribute()) | 777 if (parent && parent->isHTMLElement() && toHTMLElement(parent)->selfOrAncest
orHasDirAutoAttribute()) |
778 toHTMLElement(parent)->adjustDirectionalityIfNeededAfterChildAttributeCh
anged(this); | 778 toHTMLElement(parent)->adjustDirectionalityIfNeededAfterChildAttributeCh
anged(this); |
779 | 779 |
780 if (equalIgnoringCase(value, "auto")) | 780 if (equalIgnoringCase(value, "auto")) |
781 calculateAndAdjustDirectionality(); | 781 calculateAndAdjustDirectionality(); |
782 } | 782 } |
783 | 783 |
784 void HTMLElement::adjustDirectionalityIfNeededAfterChildAttributeChanged(Element
* child) | 784 void HTMLElement::adjustDirectionalityIfNeededAfterChildAttributeChanged(Element
* child) |
785 { | 785 { |
786 ASSERT(selfOrAncestorHasDirAutoAttribute()); | 786 ASSERT(selfOrAncestorHasDirAutoAttribute()); |
787 TextDirection textDirection = directionality(); | 787 TextDirection textDirection = directionality(); |
788 if (layoutObject() && layoutObject()->style() && layoutObject()->style()->di
rection() != textDirection) { | 788 if (layoutObject() && layoutObject()->style() && layoutObject()->style()->di
rection() != textDirection) { |
789 Element* elementToAdjust = this; | 789 Element* elementToAdjust = this; |
790 for (; elementToAdjust; elementToAdjust = ComposedTreeTraversal::parentE
lement(*elementToAdjust)) { | 790 for (; elementToAdjust; elementToAdjust = FlatTreeTraversal::parentEleme
nt(*elementToAdjust)) { |
791 if (elementAffectsDirectionality(elementToAdjust)) { | 791 if (elementAffectsDirectionality(elementToAdjust)) { |
792 elementToAdjust->setNeedsStyleRecalc(SubtreeStyleChange, StyleCh
angeReasonForTracing::create(StyleChangeReason::WritingModeChange)); | 792 elementToAdjust->setNeedsStyleRecalc(SubtreeStyleChange, StyleCh
angeReasonForTracing::create(StyleChangeReason::WritingModeChange)); |
793 return; | 793 return; |
794 } | 794 } |
795 } | 795 } |
796 } | 796 } |
797 } | 797 } |
798 | 798 |
799 void HTMLElement::calculateAndAdjustDirectionality() | 799 void HTMLElement::calculateAndAdjustDirectionality() |
800 { | 800 { |
801 TextDirection textDirection = directionality(); | 801 TextDirection textDirection = directionality(); |
802 if (layoutObject() && layoutObject()->style() && layoutObject()->style()->di
rection() != textDirection) | 802 if (layoutObject() && layoutObject()->style() && layoutObject()->style()->di
rection() != textDirection) |
803 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::cre
ate(StyleChangeReason::WritingModeChange)); | 803 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::cre
ate(StyleChangeReason::WritingModeChange)); |
804 } | 804 } |
805 | 805 |
806 void HTMLElement::adjustDirectionalityIfNeededAfterChildrenChanged(const Childre
nChange& change) | 806 void HTMLElement::adjustDirectionalityIfNeededAfterChildrenChanged(const Childre
nChange& change) |
807 { | 807 { |
808 if (!selfOrAncestorHasDirAutoAttribute()) | 808 if (!selfOrAncestorHasDirAutoAttribute()) |
809 return; | 809 return; |
810 | 810 |
811 updateDistribution(); | 811 updateDistribution(); |
812 | 812 |
813 for (Element* elementToAdjust = this; elementToAdjust; elementToAdjust = Com
posedTreeTraversal::parentElement(*elementToAdjust)) { | 813 for (Element* elementToAdjust = this; elementToAdjust; elementToAdjust = Fla
tTreeTraversal::parentElement(*elementToAdjust)) { |
814 if (elementAffectsDirectionality(elementToAdjust)) { | 814 if (elementAffectsDirectionality(elementToAdjust)) { |
815 toHTMLElement(elementToAdjust)->calculateAndAdjustDirectionality(); | 815 toHTMLElement(elementToAdjust)->calculateAndAdjustDirectionality(); |
816 return; | 816 return; |
817 } | 817 } |
818 } | 818 } |
819 } | 819 } |
820 | 820 |
821 void HTMLElement::addHTMLLengthToStyle(MutableStylePropertySet* style, CSSProper
tyID propertyID, const String& value) | 821 void HTMLElement::addHTMLLengthToStyle(MutableStylePropertySet* style, CSSProper
tyID propertyID, const String& value) |
822 { | 822 { |
823 // FIXME: This function should not spin up the CSS parser, but should instea
d just figure out the correct | 823 // FIXME: This function should not spin up the CSS parser, but should instea
d just figure out the correct |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1036 #ifndef NDEBUG | 1036 #ifndef NDEBUG |
1037 | 1037 |
1038 // For use in the debugger | 1038 // For use in the debugger |
1039 void dumpInnerHTML(blink::HTMLElement*); | 1039 void dumpInnerHTML(blink::HTMLElement*); |
1040 | 1040 |
1041 void dumpInnerHTML(blink::HTMLElement* element) | 1041 void dumpInnerHTML(blink::HTMLElement* element) |
1042 { | 1042 { |
1043 printf("%s\n", element->innerHTML().ascii().data()); | 1043 printf("%s\n", element->innerHTML().ascii().data()); |
1044 } | 1044 } |
1045 #endif | 1045 #endif |
OLD | NEW |