Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLElement.cpp

Issue 1921823006: Fix parsing of <body link vlink alink> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 929
930 // If the string is a named CSS color or a 3/6-digit hex color, use that. 930 // If the string is a named CSS color or a 3/6-digit hex color, use that.
931 Color parsedColor;
932 if (!parsedColor.setFromString(colorString)) 931 if (!parsedColor.setFromString(colorString))
933 parsedColor.setRGB(parseColorStringWithCrazyLegacyRules(colorString)); 932 parsedColor.setRGB(parseColorStringWithCrazyLegacyRules(colorString));
934 933
934 return true;
935 }
936
937 void HTMLElement::addHTMLColorToStyle(MutableStylePropertySet* style, CSSPropert yID propertyID, const String& attributeValue)
938 {
939 Color parsedColor;
940 if (!parseColorWithLegacyRules(attributeValue, parsedColor))
941 return;
942
935 style->setProperty(propertyID, cssValuePool().createColorValue(parsedColor.r gb())); 943 style->setProperty(propertyID, cssValuePool().createColorValue(parsedColor.r gb()));
936 } 944 }
937 945
938 bool HTMLElement::isInteractiveContent() const 946 bool HTMLElement::isInteractiveContent() const
939 { 947 {
940 return false; 948 return false;
941 } 949 }
942 950
943 HTMLMenuElement* HTMLElement::assignedContextMenu() const 951 HTMLMenuElement* HTMLElement::assignedContextMenu() const
944 { 952 {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 #ifndef NDEBUG 1047 #ifndef NDEBUG
1040 1048
1041 // For use in the debugger 1049 // For use in the debugger
1042 void dumpInnerHTML(blink::HTMLElement*); 1050 void dumpInnerHTML(blink::HTMLElement*);
1043 1051
1044 void dumpInnerHTML(blink::HTMLElement* element) 1052 void dumpInnerHTML(blink::HTMLElement* element)
1045 { 1053 {
1046 printf("%s\n", element->innerHTML().ascii().data()); 1054 printf("%s\n", element->innerHTML().ascii().data());
1047 } 1055 }
1048 #endif 1056 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698