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

Side by Side Diff: Source/core/css/parser/BisonCSSParser-in.cpp

Issue 164803002: Handle CSSImageValue URLs in inline styles in templates correctly (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Removed template usage Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/CSSImageValue.cpp ('k') | Source/core/dom/Element.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
9 * Copyright (C) 2012 Intel Corporation. All rights reserved. 9 * Copyright (C) 2012 Intel Corporation. All rights reserved.
10 * 10 *
(...skipping 1797 matching lines...) Expand 10 before | Expand all | Expand 10 after
1808 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | ew-resize | 1808 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | ew-resize |
1809 // ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | tex t | wait | help | 1809 // ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | tex t | wait | help |
1810 // vertical-text | cell | context-menu | alias | copy | no-drop | not-al lowed | -webkit-zoom-in 1810 // vertical-text | cell | context-menu | alias | copy | no-drop | not-al lowed | -webkit-zoom-in
1811 // -webkit-zoom-out | all-scroll | -webkit-grab | -webkit-grabbing ] ] | inherit 1811 // -webkit-zoom-out | all-scroll | -webkit-grab | -webkit-grabbing ] ] | inherit
1812 RefPtrWillBeRawPtr<CSSValueList> list; 1812 RefPtrWillBeRawPtr<CSSValueList> list;
1813 while (value) { 1813 while (value) {
1814 RefPtrWillBeRawPtr<CSSValue> image = nullptr; 1814 RefPtrWillBeRawPtr<CSSValue> image = nullptr;
1815 if (value->unit == CSSPrimitiveValue::CSS_URI) { 1815 if (value->unit == CSSPrimitiveValue::CSS_URI) {
1816 String uri = value->string; 1816 String uri = value->string;
1817 if (!uri.isNull()) 1817 if (!uri.isNull())
1818 image = CSSImageValue::create(completeURL(uri)); 1818 image = CSSImageValue::create(uri, completeURL(uri));
1819 } else if (value->unit == CSSParserValue::Function && equalIgnoringC ase(value->function->name, "-webkit-image-set(")) { 1819 } else if (value->unit == CSSParserValue::Function && equalIgnoringC ase(value->function->name, "-webkit-image-set(")) {
1820 image = parseImageSet(m_valueList.get()); 1820 image = parseImageSet(m_valueList.get());
1821 if (!image) 1821 if (!image)
1822 break; 1822 break;
1823 } else 1823 } else
1824 break; 1824 break;
1825 1825
1826 Vector<int> coords; 1826 Vector<int> coords;
1827 value = m_valueList->next(); 1827 value = m_valueList->next();
1828 while (value && value->unit == CSSPrimitiveValue::CSS_NUMBER) { 1828 while (value && value->unit == CSSPrimitiveValue::CSS_NUMBER) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1924 } 1924 }
1925 case CSSPropertyObjectPosition: 1925 case CSSPropertyObjectPosition:
1926 return RuntimeEnabledFeatures::objectFitPositionEnabled() && parseObject Position(important); 1926 return RuntimeEnabledFeatures::objectFitPositionEnabled() && parseObject Position(important);
1927 case CSSPropertyListStyleImage: // <uri> | none | inherit 1927 case CSSPropertyListStyleImage: // <uri> | none | inherit
1928 case CSSPropertyBorderImageSource: 1928 case CSSPropertyBorderImageSource:
1929 case CSSPropertyWebkitMaskBoxImageSource: 1929 case CSSPropertyWebkitMaskBoxImageSource:
1930 if (id == CSSValueNone) { 1930 if (id == CSSValueNone) {
1931 parsedValue = cssValuePool().createIdentifierValue(CSSValueNone); 1931 parsedValue = cssValuePool().createIdentifierValue(CSSValueNone);
1932 m_valueList->next(); 1932 m_valueList->next();
1933 } else if (value->unit == CSSPrimitiveValue::CSS_URI) { 1933 } else if (value->unit == CSSPrimitiveValue::CSS_URI) {
1934 parsedValue = CSSImageValue::create(completeURL(value->string)); 1934 parsedValue = CSSImageValue::create(value->string, completeURL(value ->string));
1935 m_valueList->next(); 1935 m_valueList->next();
1936 } else if (isGeneratedImageValue(value)) { 1936 } else if (isGeneratedImageValue(value)) {
1937 if (parseGeneratedImage(m_valueList.get(), parsedValue)) 1937 if (parseGeneratedImage(m_valueList.get(), parsedValue))
1938 m_valueList->next(); 1938 m_valueList->next();
1939 else 1939 else
1940 return false; 1940 return false;
1941 } 1941 }
1942 else if (value->unit == CSSParserValue::Function && equalIgnoringCase(va lue->function->name, "-webkit-image-set(")) { 1942 else if (value->unit == CSSParserValue::Function && equalIgnoringCase(va lue->function->name, "-webkit-image-set(")) {
1943 parsedValue = parseImageSet(m_valueList.get()); 1943 parsedValue = parseImageSet(m_valueList.get());
1944 if (!parsedValue) 1944 if (!parsedValue)
(...skipping 1491 matching lines...) Expand 10 before | Expand all | Expand 10 after
3436 // in CSS 2.1 this got somewhat reduced: 3436 // in CSS 2.1 this got somewhat reduced:
3437 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu ote ]+ | inherit 3437 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu ote ]+ | inherit
3438 bool CSSPropertyParser::parseContent(CSSPropertyID propId, bool important) 3438 bool CSSPropertyParser::parseContent(CSSPropertyID propId, bool important)
3439 { 3439 {
3440 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated (); 3440 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated ();
3441 3441
3442 while (CSSParserValue* val = m_valueList->current()) { 3442 while (CSSParserValue* val = m_valueList->current()) {
3443 RefPtrWillBeRawPtr<CSSValue> parsedValue; 3443 RefPtrWillBeRawPtr<CSSValue> parsedValue;
3444 if (val->unit == CSSPrimitiveValue::CSS_URI) { 3444 if (val->unit == CSSPrimitiveValue::CSS_URI) {
3445 // url 3445 // url
3446 parsedValue = CSSImageValue::create(completeURL(val->string)); 3446 parsedValue = CSSImageValue::create(val->string, completeURL(val->st ring));
3447 } else if (val->unit == CSSParserValue::Function) { 3447 } else if (val->unit == CSSParserValue::Function) {
3448 // attr(X) | counter(X [,Y]) | counters(X, Y, [,Z]) | -webkit-gradie nt(...) 3448 // attr(X) | counter(X [,Y]) | counters(X, Y, [,Z]) | -webkit-gradie nt(...)
3449 CSSParserValueList* args = val->function->args.get(); 3449 CSSParserValueList* args = val->function->args.get();
3450 if (!args) 3450 if (!args)
3451 return false; 3451 return false;
3452 if (equalIgnoringCase(val->function->name, "attr(")) { 3452 if (equalIgnoringCase(val->function->name, "attr(")) {
3453 parsedValue = parseAttr(args); 3453 parsedValue = parseAttr(args);
3454 if (!parsedValue) 3454 if (!parsedValue)
3455 return false; 3455 return false;
3456 } else if (equalIgnoringCase(val->function->name, "counter(")) { 3456 } else if (equalIgnoringCase(val->function->name, "counter(")) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
3540 return parseColor(); 3540 return parseColor();
3541 } 3541 }
3542 3542
3543 bool CSSPropertyParser::parseFillImage(CSSParserValueList* valueList, RefPtrWill BeRawPtr<CSSValue>& value) 3543 bool CSSPropertyParser::parseFillImage(CSSParserValueList* valueList, RefPtrWill BeRawPtr<CSSValue>& value)
3544 { 3544 {
3545 if (valueList->current()->id == CSSValueNone) { 3545 if (valueList->current()->id == CSSValueNone) {
3546 value = cssValuePool().createIdentifierValue(CSSValueNone); 3546 value = cssValuePool().createIdentifierValue(CSSValueNone);
3547 return true; 3547 return true;
3548 } 3548 }
3549 if (valueList->current()->unit == CSSPrimitiveValue::CSS_URI) { 3549 if (valueList->current()->unit == CSSPrimitiveValue::CSS_URI) {
3550 value = CSSImageValue::create(completeURL(valueList->current()->string)) ; 3550 value = CSSImageValue::create(valueList->current()->string, completeURL( valueList->current()->string));
3551 return true; 3551 return true;
3552 } 3552 }
3553 3553
3554 if (isGeneratedImageValue(valueList->current())) 3554 if (isGeneratedImageValue(valueList->current()))
3555 return parseGeneratedImage(valueList, value); 3555 return parseGeneratedImage(valueList, value);
3556 3556
3557 if (valueList->current()->unit == CSSParserValue::Function && equalIgnoringC ase(valueList->current()->function->name, "-webkit-image-set(")) { 3557 if (valueList->current()->unit == CSSParserValue::Function && equalIgnoringC ase(valueList->current()->function->name, "-webkit-image-set(")) {
3558 value = parseImageSet(m_valueList.get()); 3558 value = parseImageSet(m_valueList.get());
3559 if (value) 3559 if (value)
3560 return true; 3560 return true;
(...skipping 3490 matching lines...) Expand 10 before | Expand all | Expand 10 after
7051 { 7051 {
7052 CSSPropertyParser::ShorthandScope scope(&parser, propId); 7052 CSSPropertyParser::ShorthandScope scope(&parser, propId);
7053 while (CSSParserValue* val = parser.m_valueList->current()) { 7053 while (CSSParserValue* val = parser.m_valueList->current()) {
7054 context.setCanAdvance(false); 7054 context.setCanAdvance(false);
7055 7055
7056 if (!context.canAdvance() && context.allowForwardSlashOperator() && isFo rwardSlashOperator(val)) 7056 if (!context.canAdvance() && context.allowForwardSlashOperator() && isFo rwardSlashOperator(val))
7057 context.commitForwardSlashOperator(); 7057 context.commitForwardSlashOperator();
7058 7058
7059 if (!context.canAdvance() && context.allowImage()) { 7059 if (!context.canAdvance() && context.allowImage()) {
7060 if (val->unit == CSSPrimitiveValue::CSS_URI) { 7060 if (val->unit == CSSPrimitiveValue::CSS_URI) {
7061 context.commitImage(CSSImageValue::create(parser.m_context.compl eteURL(val->string))); 7061 context.commitImage(CSSImageValue::create(val->string, parser.m_ context.completeURL(val->string)));
7062 } else if (isGeneratedImageValue(val)) { 7062 } else if (isGeneratedImageValue(val)) {
7063 RefPtrWillBeRawPtr<CSSValue> value; 7063 RefPtrWillBeRawPtr<CSSValue> value;
7064 if (parser.parseGeneratedImage(parser.m_valueList.get(), value)) 7064 if (parser.parseGeneratedImage(parser.m_valueList.get(), value))
7065 context.commitImage(value.release()); 7065 context.commitImage(value.release());
7066 else 7066 else
7067 return false; 7067 return false;
7068 } else if (val->unit == CSSParserValue::Function && equalIgnoringCas e(val->function->name, "-webkit-image-set(")) { 7068 } else if (val->unit == CSSParserValue::Function && equalIgnoringCas e(val->function->name, "-webkit-image-set(")) {
7069 RefPtrWillBeRawPtr<CSSValue> value = parser.parseImageSet(parser .m_valueList.get()); 7069 RefPtrWillBeRawPtr<CSSValue> value = parser.parseImageSet(parser .m_valueList.get());
7070 if (value) 7070 if (value)
7071 context.commitImage(value.release()); 7071 context.commitImage(value.release());
(...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after
8333 if (!functionArgs || !functionArgs->size() || !functionArgs->current()) 8333 if (!functionArgs || !functionArgs->size() || !functionArgs->current())
8334 return nullptr; 8334 return nullptr;
8335 8335
8336 RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create(); 8336 RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create();
8337 8337
8338 CSSParserValue* arg = functionArgs->current(); 8338 CSSParserValue* arg = functionArgs->current();
8339 while (arg) { 8339 while (arg) {
8340 if (arg->unit != CSSPrimitiveValue::CSS_URI) 8340 if (arg->unit != CSSPrimitiveValue::CSS_URI)
8341 return nullptr; 8341 return nullptr;
8342 8342
8343 RefPtrWillBeRawPtr<CSSImageValue> image = CSSImageValue::create(complete URL(arg->string)); 8343 RefPtrWillBeRawPtr<CSSImageValue> image = CSSImageValue::create(arg->str ing, completeURL(arg->string));
8344 imageSet->append(image); 8344 imageSet->append(image);
8345 8345
8346 arg = functionArgs->next(); 8346 arg = functionArgs->next();
8347 if (!arg || arg->unit != CSSPrimitiveValue::CSS_DIMENSION) 8347 if (!arg || arg->unit != CSSPrimitiveValue::CSS_DIMENSION)
8348 return nullptr; 8348 return nullptr;
8349 8349
8350 double imageScaleFactor = 0; 8350 double imageScaleFactor = 0;
8351 const String& string = arg->string; 8351 const String& string = arg->string;
8352 unsigned length = string.length(); 8352 unsigned length = string.length();
8353 if (!length) 8353 if (!length)
(...skipping 1811 matching lines...) Expand 10 before | Expand all | Expand 10 after
10165 { 10165 {
10166 // The tokenizer checks for the construct of an+b. 10166 // The tokenizer checks for the construct of an+b.
10167 // However, since the {ident} rule precedes the {nth} rule, some of those 10167 // However, since the {ident} rule precedes the {nth} rule, some of those
10168 // tokens are identified as string literal. Furthermore we need to accept 10168 // tokens are identified as string literal. Furthermore we need to accept
10169 // "odd" and "even" which does not match to an+b. 10169 // "odd" and "even" which does not match to an+b.
10170 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 10170 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
10171 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 10171 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
10172 } 10172 }
10173 10173
10174 } 10174 }
OLDNEW
« no previous file with comments | « Source/core/css/CSSImageValue.cpp ('k') | Source/core/dom/Element.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698