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

Side by Side Diff: Source/core/css/SVGCSSParser.cpp

Issue 22482004: Add support for the object-fit CSS property. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase for landing Created 7 years, 4 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) 2008 Eric Seidel <eric@webkit.org> 2 Copyright (C) 2008 Eric Seidel <eric@webkit.org>
3 Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 3 Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
4 2004, 2005, 2007, 2010 Rob Buis <buis@kde.org> 4 2004, 2005, 2007, 2010 Rob Buis <buis@kde.org>
5 Copyright (C) 2005, 2006 Apple Computer, Inc. 5 Copyright (C) 2005, 2006 Apple Computer, Inc.
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. 20 Boston, MA 02110-1301, USA.
21 */ 21 */
22 22
23 #include "config.h" 23 #include "config.h"
24 24
25 #include "CSSPropertyNames.h" 25 #include "CSSPropertyNames.h"
26 #include "CSSValueKeywords.h" 26 #include "CSSValueKeywords.h"
27 #include "RuntimeEnabledFeatures.h"
27 #include "core/css/CSSParser.h" 28 #include "core/css/CSSParser.h"
28 #include "core/css/CSSValueList.h" 29 #include "core/css/CSSValueList.h"
29 #include "core/rendering/RenderTheme.h" 30 #include "core/rendering/RenderTheme.h"
30 #include "core/svg/SVGPaint.h" 31 #include "core/svg/SVGPaint.h"
31 32
32 using namespace std; 33 using namespace std;
33 34
34 namespace WebCore { 35 namespace WebCore {
35 36
36 static bool isSystemColor(int id) 37 static bool isSystemColor(int id)
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 else if (id == CSSValueCurrentcolor) 219 else if (id == CSSValueCurrentcolor)
219 parsedValue = SVGColor::createCurrentColor(); 220 parsedValue = SVGColor::createCurrentColor();
220 else // TODO : svgcolor (iccColor) 221 else // TODO : svgcolor (iccColor)
221 parsedValue = parseSVGColor(); 222 parsedValue = parseSVGColor();
222 223
223 if (parsedValue) 224 if (parsedValue)
224 m_valueList->next(); 225 m_valueList->next();
225 226
226 break; 227 break;
227 228
229 case CSSPropertyPaintOrder:
230 if (!RuntimeEnabledFeatures::svgPaintOrderEnabled())
231 return false;
232
233 if (m_valueList->size() == 1 && id == CSSValueNormal)
234 valid_primitive = true;
235 else if ((parsedValue = parsePaintOrder()))
236 m_valueList->next();
237 break;
238
228 case CSSPropertyVectorEffect: // none | non-scaling-stroke | inherit 239 case CSSPropertyVectorEffect: // none | non-scaling-stroke | inherit
229 if (id == CSSValueNone || id == CSSValueNonScalingStroke) 240 if (id == CSSValueNone || id == CSSValueNonScalingStroke)
230 valid_primitive = true; 241 valid_primitive = true;
231 break; 242 break;
232 243
233 case CSSPropertyWritingMode: 244 case CSSPropertyWritingMode:
234 // lr-tb | rl_tb | tb-rl | lr | rl | tb | inherit 245 // lr-tb | rl_tb | tb-rl | lr | rl | tb | inherit
235 if (id == CSSValueLrTb || id == CSSValueRlTb || id == CSSValueTbRl || id == CSSValueLr || id == CSSValueRl || id == CSSValueTb) 246 if (id == CSSValueLrTb || id == CSSValueRlTb || id == CSSValueTbRl || id == CSSValueLr || id == CSSValueRl || id == CSSValueTb)
236 valid_primitive = true; 247 valid_primitive = true;
237 break; 248 break;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 } 359 }
349 360
350 PassRefPtr<CSSValue> CSSParser::parseSVGColor() 361 PassRefPtr<CSSValue> CSSParser::parseSVGColor()
351 { 362 {
352 RGBA32 c = Color::transparent; 363 RGBA32 c = Color::transparent;
353 if (!parseColorFromValue(m_valueList->current(), c)) 364 if (!parseColorFromValue(m_valueList->current(), c))
354 return 0; 365 return 0;
355 return SVGColor::createFromColor(Color(c)); 366 return SVGColor::createFromColor(Color(c));
356 } 367 }
357 368
369 // normal | [ fill || stroke || markers ]
370 PassRefPtr<CSSValue> CSSParser::parsePaintOrder() const
371 {
372 if (m_valueList->size() > 3)
373 return 0;
374
375 CSSParserValue* value = m_valueList->current();
376 if (!value)
377 return 0;
378
379 RefPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSeparated();
380
381 // The default paint-order is: Fill, Stroke, Markers.
382 bool seenFill = false,
383 seenStroke = false,
384 seenMarkers = false;
385
386 do {
387 switch (value->id) {
388 case CSSValueNormal:
389 // normal inside [fill || stroke || markers] not valid
390 return 0;
391 case CSSValueFill:
392 if (seenFill)
393 return 0;
394
395 seenFill = true;
396 break;
397 case CSSValueStroke:
398 if (seenStroke)
399 return 0;
400
401 seenStroke = true;
402 break;
403 case CSSValueMarkers:
404 if (seenMarkers)
405 return 0;
406
407 seenMarkers = true;
408 break;
409 default:
410 return 0;
411 }
412
413 parsedValues->append(CSSPrimitiveValue::createIdentifier(value->id));
414 } while ((value = m_valueList->next()));
415
416 // fill out the rest of the paint order
417 if (!seenFill)
418 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill));
419 if (!seenStroke)
420 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) );
421 if (!seenMarkers)
422 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers ));
423
424 return parsedValues.release();
358 } 425 }
426
427 }
OLDNEW
« no previous file with comments | « Source/core/css/SVGCSSComputedStyleDeclaration.cpp ('k') | Source/core/css/SVGCSSPropertyNames.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698