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

Side by Side Diff: Source/core/css/resolver/FilterOperationResolver.cpp

Issue 64293008: Wrap CSS length conversion arguments in an object (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: don't make it noncopyable ; clang doesn't do the RVO stuffs? Created 7 years 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) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "core/svg/SVGURIReference.h" 43 #include "core/svg/SVGURIReference.h"
44 #include "platform/graphics/filters/custom/CustomFilterArrayParameter.h" 44 #include "platform/graphics/filters/custom/CustomFilterArrayParameter.h"
45 #include "platform/graphics/filters/custom/CustomFilterConstants.h" 45 #include "platform/graphics/filters/custom/CustomFilterConstants.h"
46 #include "platform/graphics/filters/custom/CustomFilterNumberParameter.h" 46 #include "platform/graphics/filters/custom/CustomFilterNumberParameter.h"
47 #include "platform/graphics/filters/custom/CustomFilterParameter.h" 47 #include "platform/graphics/filters/custom/CustomFilterParameter.h"
48 #include "platform/graphics/filters/custom/CustomFilterProgramInfo.h" 48 #include "platform/graphics/filters/custom/CustomFilterProgramInfo.h"
49 #include "platform/graphics/filters/custom/CustomFilterTransformParameter.h" 49 #include "platform/graphics/filters/custom/CustomFilterTransformParameter.h"
50 50
51 namespace WebCore { 51 namespace WebCore {
52 52
53 static Length convertToFloatLength(CSSPrimitiveValue* primitiveValue, const Rend erStyle* style, const RenderStyle* rootStyle, double multiplier)
54 {
55 return primitiveValue ? primitiveValue->convertToLength<FixedConversion | Pe rcentConversion>(style, rootStyle, multiplier) : Length(Undefined);
56 }
57
58 static FilterOperation::OperationType filterOperationForType(CSSFilterValue::Fil terOperationType type) 53 static FilterOperation::OperationType filterOperationForType(CSSFilterValue::Fil terOperationType type)
59 { 54 {
60 switch (type) { 55 switch (type) {
61 case CSSFilterValue::ReferenceFilterOperation: 56 case CSSFilterValue::ReferenceFilterOperation:
62 return FilterOperation::REFERENCE; 57 return FilterOperation::REFERENCE;
63 case CSSFilterValue::GrayscaleFilterOperation: 58 case CSSFilterValue::GrayscaleFilterOperation:
64 return FilterOperation::GRAYSCALE; 59 return FilterOperation::GRAYSCALE;
65 case CSSFilterValue::SepiaFilterOperation: 60 case CSSFilterValue::SepiaFilterOperation:
66 return FilterOperation::SEPIA; 61 return FilterOperation::SEPIA;
67 case CSSFilterValue::SaturateFilterOperation: 62 case CSSFilterValue::SaturateFilterOperation:
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 return 0; 117 return 0;
123 numberParameter->addValue(primitiveValue->getDoubleValue()); 118 numberParameter->addValue(primitiveValue->getDoubleValue());
124 } 119 }
125 return numberParameter.release(); 120 return numberParameter.release();
126 } 121 }
127 122
128 static PassRefPtr<CustomFilterParameter> parseCustomFilterTransformParameter(con st String& name, CSSValueList* values, StyleResolverState& state) 123 static PassRefPtr<CustomFilterParameter> parseCustomFilterTransformParameter(con st String& name, CSSValueList* values, StyleResolverState& state)
129 { 124 {
130 RefPtr<CustomFilterTransformParameter> transformParameter = CustomFilterTran sformParameter::create(name); 125 RefPtr<CustomFilterTransformParameter> transformParameter = CustomFilterTran sformParameter::create(name);
131 TransformOperations operations; 126 TransformOperations operations;
132 TransformBuilder::createTransformOperations(values, state.style(), state.roo tElementStyle(), operations); 127 TransformBuilder::createTransformOperations(values, state.cssToLengthConvers ionData(), operations);
133 transformParameter->setOperations(operations); 128 transformParameter->setOperations(operations);
134 return transformParameter.release(); 129 return transformParameter.release();
135 } 130 }
136 131
137 static PassRefPtr<CustomFilterParameter> parseCustomFilterParameter(const String & name, CSSValue* parameterValue, StyleResolverState& state) 132 static PassRefPtr<CustomFilterParameter> parseCustomFilterParameter(const String & name, CSSValue* parameterValue, StyleResolverState& state)
138 { 133 {
139 // FIXME: Implement other parameters types parsing. 134 // FIXME: Implement other parameters types parsing.
140 // booleans: https://bugs.webkit.org/show_bug.cgi?id=76438 135 // booleans: https://bugs.webkit.org/show_bug.cgi?id=76438
141 // textures: https://bugs.webkit.org/show_bug.cgi?id=71442 136 // textures: https://bugs.webkit.org/show_bug.cgi?id=71442
142 // mat2, mat3, mat4: https://bugs.webkit.org/show_bug.cgi?id=71444 137 // mat2, mat3, mat4: https://bugs.webkit.org/show_bug.cgi?id=71444
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 } 340 }
346 341
347 static PassRefPtr<CustomFilterOperation> createCustomFilterOperation(CSSFilterVa lue* filterValue, StyleResolverState& state) 342 static PassRefPtr<CustomFilterOperation> createCustomFilterOperation(CSSFilterVa lue* filterValue, StyleResolverState& state)
348 { 343 {
349 ASSERT(filterValue->length()); 344 ASSERT(filterValue->length());
350 bool isAtRuleReferenceSyntax = filterValue->itemWithoutBoundsCheck(0)->isPri mitiveValue(); 345 bool isAtRuleReferenceSyntax = filterValue->itemWithoutBoundsCheck(0)->isPri mitiveValue();
351 return isAtRuleReferenceSyntax ? createCustomFilterOperationWithAtRuleRefere nceSyntax(filterValue) : createCustomFilterOperationWithInlineSyntax(filterValue , state); 346 return isAtRuleReferenceSyntax ? createCustomFilterOperationWithAtRuleRefere nceSyntax(filterValue) : createCustomFilterOperationWithInlineSyntax(filterValue , state);
352 } 347 }
353 348
354 349
355 bool FilterOperationResolver::createFilterOperations(CSSValue* inValue, const Re nderStyle* style, const RenderStyle* rootStyle, FilterOperations& outOperations, StyleResolverState& state) 350 bool FilterOperationResolver::createFilterOperations(CSSValue* inValue, const CS SToLengthConversionData& unadjustedConversionData, FilterOperations& outOperatio ns, StyleResolverState& state)
356 { 351 {
357 ASSERT(outOperations.isEmpty()); 352 ASSERT(outOperations.isEmpty());
358 353
359 if (!inValue) 354 if (!inValue)
360 return false; 355 return false;
361 356
362 if (inValue->isPrimitiveValue()) { 357 if (inValue->isPrimitiveValue()) {
363 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(inValue); 358 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(inValue);
364 if (primitiveValue->getValueID() == CSSValueNone) 359 if (primitiveValue->getValueID() == CSSValueNone)
365 return true; 360 return true;
366 } 361 }
367 362
368 if (!inValue->isValueList()) 363 if (!inValue->isValueList())
369 return false; 364 return false;
370 365
371 float zoomFactor = (style ? style->effectiveZoom() : 1) * state.elementStyle Resources().deviceScaleFactor(); 366 float zoomFactor = unadjustedConversionData.zoom() * state.elementStyleResou rces().deviceScaleFactor();
367 const CSSToLengthConversionData& conversionData = unadjustedConversionData.c opyWithAdjustedZoom(zoomFactor);
372 FilterOperations operations; 368 FilterOperations operations;
373 for (CSSValueListIterator i = inValue; i.hasMore(); i.advance()) { 369 for (CSSValueListIterator i = inValue; i.hasMore(); i.advance()) {
374 CSSValue* currValue = i.value(); 370 CSSValue* currValue = i.value();
375 if (!currValue->isFilterValue()) 371 if (!currValue->isFilterValue())
376 continue; 372 continue;
377 373
378 CSSFilterValue* filterValue = toCSSFilterValue(i.value()); 374 CSSFilterValue* filterValue = toCSSFilterValue(i.value());
379 FilterOperation::OperationType operationType = filterOperationForType(fi lterValue->operationType()); 375 FilterOperation::OperationType operationType = filterOperationForType(fi lterValue->operationType());
380 376
381 if (operationType == FilterOperation::VALIDATED_CUSTOM) { 377 if (operationType == FilterOperation::VALIDATED_CUSTOM) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 if (firstValue->isPercentage()) 456 if (firstValue->isPercentage())
461 amount /= 100; 457 amount /= 100;
462 } 458 }
463 459
464 operations.operations().append(BasicComponentTransferFilterOperation ::create(amount, operationType)); 460 operations.operations().append(BasicComponentTransferFilterOperation ::create(amount, operationType));
465 break; 461 break;
466 } 462 }
467 case CSSFilterValue::BlurFilterOperation: { 463 case CSSFilterValue::BlurFilterOperation: {
468 Length stdDeviation = Length(0, Fixed); 464 Length stdDeviation = Length(0, Fixed);
469 if (filterValue->length() >= 1) 465 if (filterValue->length() >= 1)
470 stdDeviation = convertToFloatLength(firstValue, style, rootStyle , zoomFactor); 466 stdDeviation = firstValue->convertToLength<FixedConversion | Per centConversion>(conversionData);
471 if (stdDeviation.isUndefined()) 467 if (stdDeviation.isUndefined())
472 return false; 468 return false;
473 469
474 operations.operations().append(BlurFilterOperation::create(stdDeviat ion)); 470 operations.operations().append(BlurFilterOperation::create(stdDeviat ion));
475 break; 471 break;
476 } 472 }
477 case CSSFilterValue::DropShadowFilterOperation: { 473 case CSSFilterValue::DropShadowFilterOperation: {
478 if (filterValue->length() != 1) 474 if (filterValue->length() != 1)
479 return false; 475 return false;
480 476
481 CSSValue* cssValue = filterValue->itemWithoutBoundsCheck(0); 477 CSSValue* cssValue = filterValue->itemWithoutBoundsCheck(0);
482 if (!cssValue->isShadowValue()) 478 if (!cssValue->isShadowValue())
483 continue; 479 continue;
484 480
485 CSSShadowValue* item = toCSSShadowValue(cssValue); 481 CSSShadowValue* item = toCSSShadowValue(cssValue);
486 IntPoint location(item->x->computeLength<int>(style, rootStyle, zoom Factor), item->y->computeLength<int>(style, rootStyle, zoomFactor)); 482 IntPoint location(item->x->computeLength<int>(conversionData), item- >y->computeLength<int>(conversionData));
487 int blur = item->blur ? item->blur->computeLength<int>(style, rootSt yle, zoomFactor) : 0; 483 int blur = item->blur ? item->blur->computeLength<int>(conversionDat a) : 0;
488 Color shadowColor; 484 Color shadowColor;
489 if (item->color) 485 if (item->color)
490 shadowColor = state.document().textLinkColors().colorFromPrimiti veValue(item->color.get(), state.style()->visitedDependentColor(CSSPropertyColor )); 486 shadowColor = state.document().textLinkColors().colorFromPrimiti veValue(item->color.get(), state.style()->visitedDependentColor(CSSPropertyColor ));
491 487
492 operations.operations().append(DropShadowFilterOperation::create(loc ation, blur, shadowColor.isValid() ? shadowColor : Color::transparent)); 488 operations.operations().append(DropShadowFilterOperation::create(loc ation, blur, shadowColor.isValid() ? shadowColor : Color::transparent));
493 break; 489 break;
494 } 490 }
495 case CSSFilterValue::UnknownFilterOperation: 491 case CSSFilterValue::UnknownFilterOperation:
496 default: 492 default:
497 ASSERT_NOT_REACHED(); 493 ASSERT_NOT_REACHED();
498 break; 494 break;
499 } 495 }
500 } 496 }
501 497
502 outOperations = operations; 498 outOperations = operations;
503 return true; 499 return true;
504 } 500 }
505 501
506 } // namespace WebCore 502 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/resolver/FilterOperationResolver.h ('k') | Source/core/css/resolver/FontBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698