| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 return tagQName().hasPrefix() | 117 return tagQName().hasPrefix() |
| 118 ? Element::nodeName().upper() | 118 ? Element::nodeName().upper() |
| 119 : tagQName().localName().upper(); | 119 : tagQName().localName().upper(); |
| 120 } | 120 } |
| 121 return Element::nodeName(); | 121 return Element::nodeName(); |
| 122 } | 122 } |
| 123 | 123 |
| 124 String HTMLElement::nodeName() const | 124 String HTMLElement::nodeName() const |
| 125 { | 125 { |
| 126 // localNameUpper may intern and cache an AtomicString. | 126 // localNameUpper may intern and cache an AtomicString. |
| 127 ASSERT(isMainThread()); | 127 DCHECK(isMainThread()); |
| 128 | 128 |
| 129 // FIXME: Would be nice to have an atomicstring lookup based off uppercase | 129 // FIXME: Would be nice to have an atomicstring lookup based off uppercase |
| 130 // chars that does not have to copy the string on a hit in the hash. | 130 // chars that does not have to copy the string on a hit in the hash. |
| 131 // FIXME: We should have a way to detect XHTML elements and replace the hasP
refix() check with it. | 131 // FIXME: We should have a way to detect XHTML elements and replace the hasP
refix() check with it. |
| 132 if (document().isHTMLDocument()) { | 132 if (document().isHTMLDocument()) { |
| 133 if (!tagQName().hasPrefix()) | 133 if (!tagQName().hasPrefix()) |
| 134 return tagQName().localNameUpper(); | 134 return tagQName().localNameUpper(); |
| 135 return Element::nodeName().upper(); | 135 return Element::nodeName().upper(); |
| 136 } | 136 } |
| 137 return Element::nodeName(); | 137 return Element::nodeName(); |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 return TranslateAttributeNo; | 683 return TranslateAttributeNo; |
| 684 | 684 |
| 685 return TranslateAttributeInherit; | 685 return TranslateAttributeInherit; |
| 686 } | 686 } |
| 687 | 687 |
| 688 bool HTMLElement::translate() const | 688 bool HTMLElement::translate() const |
| 689 { | 689 { |
| 690 for (const HTMLElement* element = this; element; element = Traversal<HTMLEle
ment>::firstAncestor(*element)) { | 690 for (const HTMLElement* element = this; element; element = Traversal<HTMLEle
ment>::firstAncestor(*element)) { |
| 691 TranslateAttributeMode mode = element->translateAttributeMode(); | 691 TranslateAttributeMode mode = element->translateAttributeMode(); |
| 692 if (mode != TranslateAttributeInherit) { | 692 if (mode != TranslateAttributeInherit) { |
| 693 ASSERT(mode == TranslateAttributeYes || mode == TranslateAttributeNo
); | 693 DCHECK(mode == TranslateAttributeYes || mode == TranslateAttributeNo
); |
| 694 return mode == TranslateAttributeYes; | 694 return mode == TranslateAttributeYes; |
| 695 } | 695 } |
| 696 } | 696 } |
| 697 | 697 |
| 698 // Default on the root element is translate=yes. | 698 // Default on the root element is translate=yes. |
| 699 return true; | 699 return true; |
| 700 } | 700 } |
| 701 | 701 |
| 702 void HTMLElement::setTranslate(bool enable) | 702 void HTMLElement::setTranslate(bool enable) |
| 703 { | 703 { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 Element* parent = FlatTreeTraversal::parentElement(*this); | 826 Element* parent = FlatTreeTraversal::parentElement(*this); |
| 827 if (parent && parent->isHTMLElement() && toHTMLElement(parent)->selfOrAncest
orHasDirAutoAttribute()) | 827 if (parent && parent->isHTMLElement() && toHTMLElement(parent)->selfOrAncest
orHasDirAutoAttribute()) |
| 828 toHTMLElement(parent)->adjustDirectionalityIfNeededAfterChildAttributeCh
anged(this); | 828 toHTMLElement(parent)->adjustDirectionalityIfNeededAfterChildAttributeCh
anged(this); |
| 829 | 829 |
| 830 if (equalIgnoringCase(value, "auto")) | 830 if (equalIgnoringCase(value, "auto")) |
| 831 calculateAndAdjustDirectionality(); | 831 calculateAndAdjustDirectionality(); |
| 832 } | 832 } |
| 833 | 833 |
| 834 void HTMLElement::adjustDirectionalityIfNeededAfterChildAttributeChanged(Element
* child) | 834 void HTMLElement::adjustDirectionalityIfNeededAfterChildAttributeChanged(Element
* child) |
| 835 { | 835 { |
| 836 ASSERT(selfOrAncestorHasDirAutoAttribute()); | 836 DCHECK(selfOrAncestorHasDirAutoAttribute()); |
| 837 TextDirection textDirection = directionality(); | 837 TextDirection textDirection = directionality(); |
| 838 if (layoutObject() && layoutObject()->style() && layoutObject()->style()->di
rection() != textDirection) { | 838 if (layoutObject() && layoutObject()->style() && layoutObject()->style()->di
rection() != textDirection) { |
| 839 Element* elementToAdjust = this; | 839 Element* elementToAdjust = this; |
| 840 for (; elementToAdjust; elementToAdjust = FlatTreeTraversal::parentEleme
nt(*elementToAdjust)) { | 840 for (; elementToAdjust; elementToAdjust = FlatTreeTraversal::parentEleme
nt(*elementToAdjust)) { |
| 841 if (elementAffectsDirectionality(elementToAdjust)) { | 841 if (elementAffectsDirectionality(elementToAdjust)) { |
| 842 elementToAdjust->setNeedsStyleRecalc(LocalStyleChange, StyleChan
geReasonForTracing::create(StyleChangeReason::WritingModeChange)); | 842 elementToAdjust->setNeedsStyleRecalc(LocalStyleChange, StyleChan
geReasonForTracing::create(StyleChangeReason::WritingModeChange)); |
| 843 return; | 843 return; |
| 844 } | 844 } |
| 845 } | 845 } |
| 846 } | 846 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 return Color::black; | 930 return Color::black; |
| 931 | 931 |
| 932 // Pad the buffer out to at least the next multiple of three in size. | 932 // Pad the buffer out to at least the next multiple of three in size. |
| 933 digitBuffer.append('0'); | 933 digitBuffer.append('0'); |
| 934 digitBuffer.append('0'); | 934 digitBuffer.append('0'); |
| 935 | 935 |
| 936 if (digitBuffer.size() < 6) | 936 if (digitBuffer.size() < 6) |
| 937 return makeRGB(toASCIIHexValue(digitBuffer[0]), toASCIIHexValue(digitBuf
fer[1]), toASCIIHexValue(digitBuffer[2])); | 937 return makeRGB(toASCIIHexValue(digitBuffer[0]), toASCIIHexValue(digitBuf
fer[1]), toASCIIHexValue(digitBuffer[2])); |
| 938 | 938 |
| 939 // Split the digits into three components, then search the last 8 digits of
each component. | 939 // Split the digits into three components, then search the last 8 digits of
each component. |
| 940 ASSERT(digitBuffer.size() >= 6); | 940 DCHECK_GE(digitBuffer.size(), 6u); |
| 941 size_t componentLength = digitBuffer.size() / 3; | 941 size_t componentLength = digitBuffer.size() / 3; |
| 942 size_t componentSearchWindowLength = min<size_t>(componentLength, 8); | 942 size_t componentSearchWindowLength = min<size_t>(componentLength, 8); |
| 943 size_t redIndex = componentLength - componentSearchWindowLength; | 943 size_t redIndex = componentLength - componentSearchWindowLength; |
| 944 size_t greenIndex = componentLength * 2 - componentSearchWindowLength; | 944 size_t greenIndex = componentLength * 2 - componentSearchWindowLength; |
| 945 size_t blueIndex = componentLength * 3 - componentSearchWindowLength; | 945 size_t blueIndex = componentLength * 3 - componentSearchWindowLength; |
| 946 // Skip digits until one of them is non-zero, or we've only got two digits l
eft in the component. | 946 // Skip digits until one of them is non-zero, or we've only got two digits l
eft in the component. |
| 947 while (digitBuffer[redIndex] == '0' && digitBuffer[greenIndex] == '0' && dig
itBuffer[blueIndex] == '0' && (componentLength - redIndex) > 2) { | 947 while (digitBuffer[redIndex] == '0' && digitBuffer[greenIndex] == '0' && dig
itBuffer[blueIndex] == '0' && (componentLength - redIndex) > 2) { |
| 948 redIndex++; | 948 redIndex++; |
| 949 greenIndex++; | 949 greenIndex++; |
| 950 blueIndex++; | 950 blueIndex++; |
| 951 } | 951 } |
| 952 ASSERT(redIndex + 1 < componentLength); | 952 DCHECK_LT(redIndex + 1, componentLength); |
| 953 ASSERT(greenIndex >= componentLength); | 953 DCHECK_GE(greenIndex, componentLength); |
| 954 ASSERT(greenIndex + 1 < componentLength * 2); | 954 DCHECK_LT(greenIndex + 1, componentLength * 2); |
| 955 ASSERT(blueIndex >= componentLength * 2); | 955 DCHECK_GE(blueIndex, componentLength * 2); |
| 956 ASSERT_WITH_SECURITY_IMPLICATION(blueIndex + 1 < digitBuffer.size()); | 956 SECURITY_DCHECK(blueIndex + 1 < digitBuffer.size()); |
| 957 | 957 |
| 958 int redValue = toASCIIHexValue(digitBuffer[redIndex], digitBuffer[redIndex +
1]); | 958 int redValue = toASCIIHexValue(digitBuffer[redIndex], digitBuffer[redIndex +
1]); |
| 959 int greenValue = toASCIIHexValue(digitBuffer[greenIndex], digitBuffer[greenI
ndex + 1]); | 959 int greenValue = toASCIIHexValue(digitBuffer[greenIndex], digitBuffer[greenI
ndex + 1]); |
| 960 int blueValue = toASCIIHexValue(digitBuffer[blueIndex], digitBuffer[blueInde
x + 1]); | 960 int blueValue = toASCIIHexValue(digitBuffer[blueIndex], digitBuffer[blueInde
x + 1]); |
| 961 return makeRGB(redValue, greenValue, blueValue); | 961 return makeRGB(redValue, greenValue, blueValue); |
| 962 } | 962 } |
| 963 | 963 |
| 964 // Color parsing that matches HTML's "rules for parsing a legacy color value" | 964 // Color parsing that matches HTML's "rules for parsing a legacy color value" |
| 965 bool HTMLElement::parseColorWithLegacyRules(const String& attributeValue, Color&
parsedColor) | 965 bool HTMLElement::parseColorWithLegacyRules(const String& attributeValue, Color&
parsedColor) |
| 966 { | 966 { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1147 #ifndef NDEBUG | 1147 #ifndef NDEBUG |
| 1148 | 1148 |
| 1149 // For use in the debugger | 1149 // For use in the debugger |
| 1150 void dumpInnerHTML(blink::HTMLElement*); | 1150 void dumpInnerHTML(blink::HTMLElement*); |
| 1151 | 1151 |
| 1152 void dumpInnerHTML(blink::HTMLElement* element) | 1152 void dumpInnerHTML(blink::HTMLElement* element) |
| 1153 { | 1153 { |
| 1154 printf("%s\n", element->innerHTML().ascii().data()); | 1154 printf("%s\n", element->innerHTML().ascii().data()); |
| 1155 } | 1155 } |
| 1156 #endif | 1156 #endif |
| OLD | NEW |