| 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 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 ASSERT(blueIndex >= componentLength * 2); | 908 ASSERT(blueIndex >= componentLength * 2); |
| 909 ASSERT_WITH_SECURITY_IMPLICATION(blueIndex + 1 < digitBuffer.size()); | 909 ASSERT_WITH_SECURITY_IMPLICATION(blueIndex + 1 < digitBuffer.size()); |
| 910 | 910 |
| 911 int redValue = toASCIIHexValue(digitBuffer[redIndex], digitBuffer[redIndex +
1]); | 911 int redValue = toASCIIHexValue(digitBuffer[redIndex], digitBuffer[redIndex +
1]); |
| 912 int greenValue = toASCIIHexValue(digitBuffer[greenIndex], digitBuffer[greenI
ndex + 1]); | 912 int greenValue = toASCIIHexValue(digitBuffer[greenIndex], digitBuffer[greenI
ndex + 1]); |
| 913 int blueValue = toASCIIHexValue(digitBuffer[blueIndex], digitBuffer[blueInde
x + 1]); | 913 int blueValue = toASCIIHexValue(digitBuffer[blueIndex], digitBuffer[blueInde
x + 1]); |
| 914 return makeRGB(redValue, greenValue, blueValue); | 914 return makeRGB(redValue, greenValue, blueValue); |
| 915 } | 915 } |
| 916 | 916 |
| 917 // Color parsing that matches HTML's "rules for parsing a legacy color value" | 917 // Color parsing that matches HTML's "rules for parsing a legacy color value" |
| 918 void HTMLElement::addHTMLColorToStyle(MutableStylePropertySet* style, CSSPropert
yID propertyID, const String& attributeValue) | 918 bool HTMLElement::parseColorWithLegacyRules(const String& attributeValue, Color&
parsedColor) |
| 919 { | 919 { |
| 920 // An empty string doesn't apply a color. (One containing only whitespace do
es, which is why this check occurs before stripping.) | 920 // An empty string doesn't apply a color. (One containing only whitespace do
es, which is why this check occurs before stripping.) |
| 921 if (attributeValue.isEmpty()) | 921 if (attributeValue.isEmpty()) |
| 922 return; | 922 return false; |
| 923 | 923 |
| 924 String colorString = attributeValue.stripWhiteSpace(); | 924 String colorString = attributeValue.stripWhiteSpace(); |
| 925 | 925 |
| 926 // "transparent" doesn't apply a color either. | 926 // "transparent" doesn't apply a color either. |
| 927 if (equalIgnoringCase(colorString, "transparent")) | 927 if (equalIgnoringCase(colorString, "transparent")) |
| 928 return; | 928 return false; |
| 929 | |
| 930 Color color; | |
| 931 | 929 |
| 932 // If the string is a 3/6-digit hex color or a named CSS color, use that. Ap
ply legacy rules otherwise. Note color.setFromString() | 930 // If the string is a 3/6-digit hex color or a named CSS color, use that. Ap
ply legacy rules otherwise. Note color.setFromString() |
| 933 // accepts 4/8-digit hex color, so restrict its use with length checks here
to support legacy HTML attributes. | 931 // accepts 4/8-digit hex color, so restrict its use with length checks here
to support legacy HTML attributes. |
| 934 | 932 |
| 935 bool success = false; | 933 bool success = false; |
| 936 if ((colorString.length() == 4 || colorString.length() == 7) && colorString[
0] == '#') | 934 if ((colorString.length() == 4 || colorString.length() == 7) && colorString[
0] == '#') |
| 937 success = color.setFromString(colorString); | 935 success = parsedColor.setFromString(colorString); |
| 938 if (!success) | 936 if (!success) |
| 939 success = color.setNamedColor(colorString); | 937 success = parsedColor.setNamedColor(colorString); |
| 940 if (!success) | 938 if (!success) { |
| 941 color.setRGB(parseColorStringWithCrazyLegacyRules(colorString)); | 939 parsedColor.setRGB(parseColorStringWithCrazyLegacyRules(colorString)); |
| 940 success = true; |
| 941 } |
| 942 | 942 |
| 943 style->setProperty(propertyID, cssValuePool().createColorValue(color.rgb()))
; | 943 return success; |
| 944 } |
| 945 |
| 946 void HTMLElement::addHTMLColorToStyle(MutableStylePropertySet* style, CSSPropert
yID propertyID, const String& attributeValue) |
| 947 { |
| 948 Color parsedColor; |
| 949 if (!parseColorWithLegacyRules(attributeValue, parsedColor)) |
| 950 return; |
| 951 |
| 952 style->setProperty(propertyID, cssValuePool().createColorValue(parsedColor.r
gb())); |
| 944 } | 953 } |
| 945 | 954 |
| 946 bool HTMLElement::isInteractiveContent() const | 955 bool HTMLElement::isInteractiveContent() const |
| 947 { | 956 { |
| 948 return false; | 957 return false; |
| 949 } | 958 } |
| 950 | 959 |
| 951 HTMLMenuElement* HTMLElement::assignedContextMenu() const | 960 HTMLMenuElement* HTMLElement::assignedContextMenu() const |
| 952 { | 961 { |
| 953 if (HTMLMenuElement* menu = contextMenu()) | 962 if (HTMLMenuElement* menu = contextMenu()) |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1047 #ifndef NDEBUG | 1056 #ifndef NDEBUG |
| 1048 | 1057 |
| 1049 // For use in the debugger | 1058 // For use in the debugger |
| 1050 void dumpInnerHTML(blink::HTMLElement*); | 1059 void dumpInnerHTML(blink::HTMLElement*); |
| 1051 | 1060 |
| 1052 void dumpInnerHTML(blink::HTMLElement* element) | 1061 void dumpInnerHTML(blink::HTMLElement* element) |
| 1053 { | 1062 { |
| 1054 printf("%s\n", element->innerHTML().ascii().data()); | 1063 printf("%s\n", element->innerHTML().ascii().data()); |
| 1055 } | 1064 } |
| 1056 #endif | 1065 #endif |
| OLD | NEW |