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

Unified Diff: Source/core/css/resolver/FilterOperationResolver.cpp

Issue 1164573002: CSSValue Immediates: Change CSSValue to an object instead of a pointer (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/resolver/FilterOperationResolver.h ('k') | Source/core/css/resolver/StyleBuilder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/resolver/FilterOperationResolver.cpp
diff --git a/Source/core/css/resolver/FilterOperationResolver.cpp b/Source/core/css/resolver/FilterOperationResolver.cpp
index a1052037cdbbeb9aba5b91cb358e41b4883d854e..348c7a09854c42c3501c04de589a8248fd2c2d48 100644
--- a/Source/core/css/resolver/FilterOperationResolver.cpp
+++ b/Source/core/css/resolver/FilterOperationResolver.cpp
@@ -71,44 +71,41 @@ static FilterOperation::OperationType filterOperationForType(CSSValueID type)
}
}
-bool FilterOperationResolver::createFilterOperations(CSSValue* inValue, const CSSToLengthConversionData& conversionData, FilterOperations& outOperations, StyleResolverState& state)
+bool FilterOperationResolver::createFilterOperations(CSSValue inValue, const CSSToLengthConversionData& conversionData, FilterOperations& outOperations, StyleResolverState& state)
{
ASSERT(outOperations.isEmpty());
- if (!inValue)
- return false;
-
- if (inValue->isPrimitiveValue()) {
- CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(inValue);
- if (primitiveValue->getValueID() == CSSValueNone)
+ if (inValue.isPrimitiveValue()) {
+ CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(inValue);
+ if (primitiveValue.getValueID() == CSSValueNone)
return true;
}
- if (!inValue->isValueList())
+ if (!inValue.isValueList())
return false;
FilterOperations operations;
- for (auto& currValue : toCSSValueList(*inValue)) {
- CSSFunctionValue* filterValue = toCSSFunctionValue(currValue.get());
- FilterOperation::OperationType operationType = filterOperationForType(filterValue->functionType());
+ for (auto& currValue : toCSSValueList(inValue)) {
+ CSSFunctionValue& filterValue = toCSSFunctionValue(currValue);
+ FilterOperation::OperationType operationType = filterOperationForType(filterValue.functionType());
if (operationType == FilterOperation::REFERENCE) {
- if (filterValue->length() != 1)
+ if (filterValue.length() != 1)
continue;
- CSSValue* argument = filterValue->item(0);
+ CSSValue argument = filterValue.item(0);
- if (!argument->isSVGDocumentValue())
+ if (!argument.isSVGDocumentValue())
continue;
- CSSSVGDocumentValue* svgDocumentValue = toCSSSVGDocumentValue(argument);
- KURL url = state.document().completeURL(svgDocumentValue->url());
+ CSSSVGDocumentValue& svgDocumentValue = toCSSSVGDocumentValue(argument);
+ KURL url = state.document().completeURL(svgDocumentValue.url());
- RefPtrWillBeRawPtr<ReferenceFilterOperation> operation = ReferenceFilterOperation::create(svgDocumentValue->url(), AtomicString(url.fragmentIdentifier()));
- if (SVGURIReference::isExternalURIReference(svgDocumentValue->url(), state.document())) {
- if (!svgDocumentValue->loadRequested())
- state.elementStyleResources().addPendingSVGDocument(operation.get(), svgDocumentValue);
- else if (svgDocumentValue->cachedSVGDocument())
- ReferenceFilterBuilder::setDocumentResourceReference(operation.get(), adoptPtr(new DocumentResourceReference(svgDocumentValue->cachedSVGDocument())));
+ RefPtrWillBeRawPtr<ReferenceFilterOperation> operation = ReferenceFilterOperation::create(svgDocumentValue.url(), AtomicString(url.fragmentIdentifier()));
+ if (SVGURIReference::isExternalURIReference(svgDocumentValue.url(), state.document())) {
+ if (!svgDocumentValue.loadRequested())
+ state.elementStyleResources().addPendingSVGDocument(operation.get(), &svgDocumentValue);
+ else if (svgDocumentValue.cachedSVGDocument())
+ ReferenceFilterBuilder::setDocumentResourceReference(operation.get(), adoptPtr(new DocumentResourceReference(svgDocumentValue.cachedSVGDocument())));
}
operations.operations().append(operation);
continue;
@@ -118,8 +115,8 @@ bool FilterOperationResolver::createFilterOperations(CSSValue* inValue, const CS
// exception of drop shadow which has a CSSShadowValue parameter.
if (operationType != FilterOperation::DROP_SHADOW) {
bool haveNonPrimitiveValue = false;
- for (unsigned j = 0; j < filterValue->length(); ++j) {
- if (!filterValue->item(j)->isPrimitiveValue()) {
+ for (unsigned j = 0; j < filterValue.length(); ++j) {
+ if (!filterValue.item(j).isPrimitiveValue()) {
haveNonPrimitiveValue = true;
break;
}
@@ -128,13 +125,13 @@ bool FilterOperationResolver::createFilterOperations(CSSValue* inValue, const CS
continue;
}
- CSSPrimitiveValue* firstValue = filterValue->length() && filterValue->item(0)->isPrimitiveValue() ? toCSSPrimitiveValue(filterValue->item(0)) : 0;
- switch (filterValue->functionType()) {
+ CSSPrimitiveValue* firstValue = filterValue.length() && filterValue.item(0).isPrimitiveValue() ? &toCSSPrimitiveValue(filterValue.item(0)) : 0;
+ switch (filterValue.functionType()) {
case CSSValueGrayscale:
case CSSValueSepia:
case CSSValueSaturate: {
double amount = 1;
- if (filterValue->length() == 1) {
+ if (filterValue.length() == 1) {
amount = firstValue->getDoubleValue();
if (firstValue->isPercentage())
amount /= 100;
@@ -145,7 +142,7 @@ bool FilterOperationResolver::createFilterOperations(CSSValue* inValue, const CS
}
case CSSValueHueRotate: {
double angle = 0;
- if (filterValue->length() == 1)
+ if (filterValue.length() == 1)
angle = firstValue->computeDegrees();
operations.operations().append(BasicColorMatrixFilterOperation::create(angle, operationType));
@@ -155,8 +152,8 @@ bool FilterOperationResolver::createFilterOperations(CSSValue* inValue, const CS
case CSSValueBrightness:
case CSSValueContrast:
case CSSValueOpacity: {
- double amount = (filterValue->functionType() == CSSValueBrightness) ? 0 : 1;
- if (filterValue->length() == 1) {
+ double amount = (filterValue.functionType() == CSSValueBrightness) ? 0 : 1;
+ if (filterValue.length() == 1) {
amount = firstValue->getDoubleValue();
if (firstValue->isPercentage())
amount /= 100;
@@ -167,25 +164,25 @@ bool FilterOperationResolver::createFilterOperations(CSSValue* inValue, const CS
}
case CSSValueBlur: {
Length stdDeviation = Length(0, Fixed);
- if (filterValue->length() >= 1)
+ if (filterValue.length() >= 1)
stdDeviation = firstValue->convertToLength(conversionData);
operations.operations().append(BlurFilterOperation::create(stdDeviation));
break;
}
case CSSValueDropShadow: {
- if (filterValue->length() != 1)
+ if (filterValue.length() != 1)
return false;
- CSSValue* cssValue = filterValue->item(0);
- if (!cssValue->isShadowValue())
+ CSSValue cssValue = filterValue.item(0);
+ if (!cssValue.isShadowValue())
continue;
- CSSShadowValue* item = toCSSShadowValue(cssValue);
- IntPoint location(item->x->computeLength<int>(conversionData), item->y->computeLength<int>(conversionData));
- int blur = item->blur ? item->blur->computeLength<int>(conversionData) : 0;
+ CSSShadowValue& item = toCSSShadowValue(cssValue);
+ IntPoint location(item.x->computeLength<int>(conversionData), item.y->computeLength<int>(conversionData));
+ int blur = item.blur ? item.blur->computeLength<int>(conversionData) : 0;
Color shadowColor = Color::black;
- if (item->color)
- shadowColor = state.document().textLinkColors().colorFromPrimitiveValue(item->color.get(), state.style()->color());
+ if (item.color)
+ shadowColor = state.document().textLinkColors().colorFromPrimitiveValue(*item.color.get(), state.style()->color());
operations.operations().append(DropShadowFilterOperation::create(location, blur, shadowColor));
break;
« no previous file with comments | « Source/core/css/resolver/FilterOperationResolver.h ('k') | Source/core/css/resolver/StyleBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698