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

Side by Side Diff: Source/core/css/CSSToStyleMap.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
« no previous file with comments | « Source/core/css/CSSToStyleMap.h ('k') | Source/core/css/MediaQueryEvaluator.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) 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 Apple Inc. All r ights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r ights 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 24 matching lines...) Expand all
35 #include "core/css/CSSTimingFunctionValue.h" 35 #include "core/css/CSSTimingFunctionValue.h"
36 #include "core/css/Pair.h" 36 #include "core/css/Pair.h"
37 #include "core/css/Rect.h" 37 #include "core/css/Rect.h"
38 #include "core/css/resolver/StyleResolverState.h" 38 #include "core/css/resolver/StyleResolverState.h"
39 #include "core/platform/animation/CSSAnimationData.h" 39 #include "core/platform/animation/CSSAnimationData.h"
40 #include "core/rendering/style/BorderImageLengthBox.h" 40 #include "core/rendering/style/BorderImageLengthBox.h"
41 #include "core/rendering/style/FillLayer.h" 41 #include "core/rendering/style/FillLayer.h"
42 42
43 namespace WebCore { 43 namespace WebCore {
44 44
45 const RenderStyle* CSSToStyleMap::style() const 45 const CSSToLengthConversionData& CSSToStyleMap::cssToLengthConversionData() cons t
46 { 46 {
47 return m_state.style(); 47 return m_state.cssToLengthConversionData();
48 }
49
50 const RenderStyle* CSSToStyleMap::rootElementStyle() const
51 {
52 return m_state.rootElementStyle();
53 } 48 }
54 49
55 bool CSSToStyleMap::useSVGZoomRules() const 50 bool CSSToStyleMap::useSVGZoomRules() const
56 { 51 {
57 return m_state.useSVGZoomRules(); 52 return m_state.useSVGZoomRules();
58 } 53 }
59 54
60 PassRefPtr<StyleImage> CSSToStyleMap::styleImage(CSSPropertyID propertyId, CSSVa lue* value) 55 PassRefPtr<StyleImage> CSSToStyleMap::styleImage(CSSPropertyID propertyId, CSSVa lue* value)
61 { 56 {
62 return m_elementStyleResources.styleImage(m_state.document().textLinkColors( ), m_state.style()->visitedDependentColor(CSSPropertyColor), propertyId, value); 57 return m_elementStyleResources.styleImage(m_state.document().textLinkColors( ), m_state.style()->visitedDependentColor(CSSPropertyColor), propertyId, value);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 else 193 else
199 layer->setSizeType(SizeLength); 194 layer->setSizeType(SizeLength);
200 195
201 LengthSize b = FillLayer::initialFillSizeLength(layer->type()); 196 LengthSize b = FillLayer::initialFillSizeLength(layer->type());
202 197
203 if (value->isInitialValue() || primitiveValue->getValueID() == CSSValueConta in || primitiveValue->getValueID() == CSSValueCover) { 198 if (value->isInitialValue() || primitiveValue->getValueID() == CSSValueConta in || primitiveValue->getValueID() == CSSValueCover) {
204 layer->setSizeLength(b); 199 layer->setSizeLength(b);
205 return; 200 return;
206 } 201 }
207 202
208 float zoomFactor = style()->effectiveZoom();
209
210 Length firstLength; 203 Length firstLength;
211 Length secondLength; 204 Length secondLength;
212 205
213 if (Pair* pair = primitiveValue->getPairValue()) { 206 if (Pair* pair = primitiveValue->getPairValue()) {
214 firstLength = pair->first()->convertToLength<AnyConversion>(style(), roo tElementStyle(), zoomFactor); 207 firstLength = pair->first()->convertToLength<AnyConversion>(cssToLengthC onversionData());
215 secondLength = pair->second()->convertToLength<AnyConversion>(style(), r ootElementStyle(), zoomFactor); 208 secondLength = pair->second()->convertToLength<AnyConversion>(cssToLengt hConversionData());
216 } else { 209 } else {
217 firstLength = primitiveValue->convertToLength<AnyConversion>(style(), ro otElementStyle(), zoomFactor); 210 firstLength = primitiveValue->convertToLength<AnyConversion>(cssToLength ConversionData());
218 secondLength = Length(); 211 secondLength = Length();
219 } 212 }
220 213
221 if (firstLength.isUndefined() || secondLength.isUndefined()) 214 if (firstLength.isUndefined() || secondLength.isUndefined())
222 return; 215 return;
223 216
224 b.setWidth(firstLength); 217 b.setWidth(firstLength);
225 b.setHeight(secondLength); 218 b.setHeight(secondLength);
226 layer->setSizeLength(b); 219 layer->setSizeLength(b);
227 } 220 }
228 221
229 void CSSToStyleMap::mapFillXPosition(CSSPropertyID propertyID, FillLayer* layer, CSSValue* value) const 222 void CSSToStyleMap::mapFillXPosition(CSSPropertyID propertyID, FillLayer* layer, CSSValue* value) const
230 { 223 {
231 if (!value->isPrimitiveValue()) 224 if (!value->isPrimitiveValue())
232 return; 225 return;
233 226
234 float zoomFactor = style()->effectiveZoom();
235
236 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 227 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
237 Pair* pair = primitiveValue->getPairValue(); 228 Pair* pair = primitiveValue->getPairValue();
238 if (pair) { 229 if (pair) {
239 ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPositionX | | propertyID == CSSPropertyWebkitMaskPositionX); 230 ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPositionX | | propertyID == CSSPropertyWebkitMaskPositionX);
240 primitiveValue = pair->second(); 231 primitiveValue = pair->second();
241 } 232 }
242 233
243 Length length; 234 Length length;
244 if (primitiveValue->isLength()) 235 if (primitiveValue->isLength())
245 length = primitiveValue->computeLength<Length>(style(), rootElementStyle (), zoomFactor); 236 length = primitiveValue->computeLength<Length>(cssToLengthConversionData ());
246 else if (primitiveValue->isPercentage()) 237 else if (primitiveValue->isPercentage())
247 length = Length(primitiveValue->getDoubleValue(), Percent); 238 length = Length(primitiveValue->getDoubleValue(), Percent);
248 else if (primitiveValue->isCalculatedPercentageWithLength()) 239 else if (primitiveValue->isCalculatedPercentageWithLength())
249 length = Length(primitiveValue->cssCalcValue()->toCalcValue(style(), roo tElementStyle(), zoomFactor)); 240 length = Length(primitiveValue->cssCalcValue()->toCalcValue(cssToLengthC onversionData()));
250 else if (primitiveValue->isViewportPercentageLength()) 241 else if (primitiveValue->isViewportPercentageLength())
251 length = primitiveValue->viewportPercentageLength(); 242 length = primitiveValue->viewportPercentageLength();
252 else 243 else
253 return; 244 return;
254 245
255 layer->setXPosition(length); 246 layer->setXPosition(length);
256 if (pair) 247 if (pair)
257 layer->setBackgroundXOrigin(*(pair->first())); 248 layer->setBackgroundXOrigin(*(pair->first()));
258 } 249 }
259 250
260 void CSSToStyleMap::mapFillYPosition(CSSPropertyID propertyID, FillLayer* layer, CSSValue* value) const 251 void CSSToStyleMap::mapFillYPosition(CSSPropertyID propertyID, FillLayer* layer, CSSValue* value) const
261 { 252 {
262 if (!value->isPrimitiveValue()) 253 if (!value->isPrimitiveValue())
263 return; 254 return;
264 255
265 float zoomFactor = style()->effectiveZoom();
266
267 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 256 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
268 Pair* pair = primitiveValue->getPairValue(); 257 Pair* pair = primitiveValue->getPairValue();
269 if (pair) { 258 if (pair) {
270 ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPositionY | | propertyID == CSSPropertyWebkitMaskPositionY); 259 ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPositionY | | propertyID == CSSPropertyWebkitMaskPositionY);
271 primitiveValue = pair->second(); 260 primitiveValue = pair->second();
272 } 261 }
273 262
274 Length length; 263 Length length;
275 if (primitiveValue->isLength()) 264 if (primitiveValue->isLength())
276 length = primitiveValue->computeLength<Length>(style(), rootElementStyle (), zoomFactor); 265 length = primitiveValue->computeLength<Length>(cssToLengthConversionData ());
277 else if (primitiveValue->isPercentage()) 266 else if (primitiveValue->isPercentage())
278 length = Length(primitiveValue->getDoubleValue(), Percent); 267 length = Length(primitiveValue->getDoubleValue(), Percent);
279 else if (primitiveValue->isCalculatedPercentageWithLength()) 268 else if (primitiveValue->isCalculatedPercentageWithLength())
280 length = Length(primitiveValue->cssCalcValue()->toCalcValue(style(), roo tElementStyle(), zoomFactor)); 269 length = Length(primitiveValue->cssCalcValue()->toCalcValue(cssToLengthC onversionData()));
281 else if (primitiveValue->isViewportPercentageLength()) 270 else if (primitiveValue->isViewportPercentageLength())
282 length = primitiveValue->viewportPercentageLength(); 271 length = primitiveValue->viewportPercentageLength();
283 else 272 else
284 return; 273 return;
285 274
286 layer->setYPosition(length); 275 layer->setYPosition(length);
287 if (pair) 276 if (pair)
288 layer->setBackgroundYOrigin(*(pair->first())); 277 layer->setBackgroundYOrigin(*(pair->first()));
289 } 278 }
290 279
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 if (slices->right()->isPercentage()) 592 if (slices->right()->isPercentage())
604 box.m_right = Length(slices->right()->getDoubleValue(), Percent); 593 box.m_right = Length(slices->right()->getDoubleValue(), Percent);
605 else 594 else
606 box.m_right = Length(slices->right()->getIntValue(CSSPrimitiveValue::CSS _NUMBER), Fixed); 595 box.m_right = Length(slices->right()->getIntValue(CSSPrimitiveValue::CSS _NUMBER), Fixed);
607 image.setImageSlices(box); 596 image.setImageSlices(box);
608 597
609 // Set our fill mode. 598 // Set our fill mode.
610 image.setFill(borderImageSlice->m_fill); 599 image.setFill(borderImageSlice->m_fill);
611 } 600 }
612 601
613 static BorderImageLength toBorderImageLength(CSSPrimitiveValue& value, const Ren derStyle* currentStyle, const RenderStyle* rootStyle, float multiplier) 602 static BorderImageLength toBorderImageLength(CSSPrimitiveValue& value, const CSS ToLengthConversionData& conversionData)
614 { 603 {
615 if (value.isNumber()) 604 if (value.isNumber())
616 return value.getDoubleValue(); 605 return value.getDoubleValue();
617 if (value.isPercentage()) 606 if (value.isPercentage())
618 return Length(value.getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), P ercent); 607 return Length(value.getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), P ercent);
619 if (value.getValueID() != CSSValueAuto) 608 if (value.getValueID() != CSSValueAuto)
620 return value.computeLength<Length>(currentStyle, rootStyle, multiplier); 609 return value.computeLength<Length>(conversionData);
621 return Length(Auto); 610 return Length(Auto);
622 } 611 }
623 612
624 BorderImageLengthBox CSSToStyleMap::mapNinePieceImageQuad(CSSValue* value) const 613 BorderImageLengthBox CSSToStyleMap::mapNinePieceImageQuad(CSSValue* value) const
625 { 614 {
626 if (!value || !value->isPrimitiveValue()) 615 if (!value || !value->isPrimitiveValue())
627 return BorderImageLengthBox(Length(Auto)); 616 return BorderImageLengthBox(Length(Auto));
628 617
629 float zoom = useSVGZoomRules() ? 1.0f : style()->effectiveZoom(); 618 float zoom = useSVGZoomRules() ? 1.0f : cssToLengthConversionData().zoom();
630 Quad* slices = toCSSPrimitiveValue(value)->getQuadValue(); 619 Quad* slices = toCSSPrimitiveValue(value)->getQuadValue();
631 620
632 // Set up a border image length box to represent our image slices. 621 // Set up a border image length box to represent our image slices.
622 const CSSToLengthConversionData& conversionData = cssToLengthConversionData( ).copyWithAdjustedZoom(zoom);
633 return BorderImageLengthBox( 623 return BorderImageLengthBox(
634 toBorderImageLength(*slices->top(), style(), rootElementStyle(), zoom), 624 toBorderImageLength(*slices->top(), conversionData),
635 toBorderImageLength(*slices->right(), style(), rootElementStyle(), zoom) , 625 toBorderImageLength(*slices->right(), conversionData),
636 toBorderImageLength(*slices->bottom(), style(), rootElementStyle(), zoom ), 626 toBorderImageLength(*slices->bottom(), conversionData),
637 toBorderImageLength(*slices->left(), style(), rootElementStyle(), zoom)) ; 627 toBorderImageLength(*slices->left(), conversionData));
638 } 628 }
639 629
640 void CSSToStyleMap::mapNinePieceImageRepeat(CSSValue* value, NinePieceImage& ima ge) const 630 void CSSToStyleMap::mapNinePieceImageRepeat(CSSValue* value, NinePieceImage& ima ge) const
641 { 631 {
642 if (!value || !value->isPrimitiveValue()) 632 if (!value || !value->isPrimitiveValue())
643 return; 633 return;
644 634
645 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 635 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
646 Pair* pair = primitiveValue->getPairValue(); 636 Pair* pair = primitiveValue->getPairValue();
647 if (!pair || !pair->first() || !pair->second()) 637 if (!pair || !pair->first() || !pair->second())
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 verticalRule = SpaceImageRule; 669 verticalRule = SpaceImageRule;
680 break; 670 break;
681 default: // CSSValueRepeat 671 default: // CSSValueRepeat
682 verticalRule = RepeatImageRule; 672 verticalRule = RepeatImageRule;
683 break; 673 break;
684 } 674 }
685 image.setVerticalRule(verticalRule); 675 image.setVerticalRule(verticalRule);
686 } 676 }
687 677
688 }; 678 };
OLDNEW
« no previous file with comments | « Source/core/css/CSSToStyleMap.h ('k') | Source/core/css/MediaQueryEvaluator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698