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

Side by Side Diff: third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp

Issue 2345893004: Evacuate ComputedStyle references from the CSS*Value hierarchy (Closed)
Patch Set: Include WTFString.h in CSSValuePair.h Created 4 years, 3 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) 2004 Zack Rusin <zack@kde.org> 2 * Copyright (C) 2004 Zack Rusin <zack@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2011 Sencha, Inc. All rights reserved. 6 * Copyright (C) 2011 Sencha, Inc. All rights reserved.
7 * Copyright (C) 2015 Google Inc. All rights reserved. 7 * Copyright (C) 2015 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public 10 * modify it under the terms of the GNU Lesser General Public
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 inline static CSSPrimitiveValue* zoomAdjustedNumberValue(double value, const Com putedStyle& style) 81 inline static CSSPrimitiveValue* zoomAdjustedNumberValue(double value, const Com putedStyle& style)
82 { 82 {
83 return CSSPrimitiveValue::create(value / style.effectiveZoom(), CSSPrimitive Value::UnitType::Number); 83 return CSSPrimitiveValue::create(value / style.effectiveZoom(), CSSPrimitive Value::UnitType::Number);
84 } 84 }
85 85
86 static CSSPrimitiveValue* zoomAdjustedPixelValueForLength(const Length& length, const ComputedStyle& style) 86 static CSSPrimitiveValue* zoomAdjustedPixelValueForLength(const Length& length, const ComputedStyle& style)
87 { 87 {
88 if (length.isFixed()) 88 if (length.isFixed())
89 return zoomAdjustedPixelValue(length.value(), style); 89 return zoomAdjustedPixelValue(length.value(), style);
90 return CSSPrimitiveValue::create(length, style); 90 return CSSPrimitiveValue::create(length, style.effectiveZoom());
91 } 91 }
92 92
93 static CSSPrimitiveValue* pixelValueForUnzoomedLength(const UnzoomedLength& unzo omedLength, const ComputedStyle& style) 93 static CSSPrimitiveValue* pixelValueForUnzoomedLength(const UnzoomedLength& unzo omedLength, const ComputedStyle& style)
94 { 94 {
95 const Length& length = unzoomedLength.length(); 95 const Length& length = unzoomedLength.length();
96 if (length.isFixed()) 96 if (length.isFixed())
97 return CSSPrimitiveValue::create(length.value(), CSSPrimitiveValue::Unit Type::Pixels); 97 return CSSPrimitiveValue::create(length.value(), CSSPrimitiveValue::Unit Type::Pixels);
98 return CSSPrimitiveValue::create(length, style); 98 return CSSPrimitiveValue::create(length, style.effectiveZoom());
99 } 99 }
100 100
101 static CSSValueList* createPositionListForLayer(CSSPropertyID propertyID, const FillLayer& layer, const ComputedStyle& style) 101 static CSSValueList* createPositionListForLayer(CSSPropertyID propertyID, const FillLayer& layer, const ComputedStyle& style)
102 { 102 {
103 CSSValueList* positionList = CSSValueList::createSpaceSeparated(); 103 CSSValueList* positionList = CSSValueList::createSpaceSeparated();
104 if (layer.isBackgroundXOriginSet()) { 104 if (layer.isBackgroundXOriginSet()) {
105 ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPosition || propertyID == CSSPropertyWebkitMaskPosition); 105 ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPosition || propertyID == CSSPropertyWebkitMaskPosition);
106 positionList->append(*CSSPrimitiveValue::create(layer.backgroundXOrigin( ))); 106 positionList->append(*CSSPrimitiveValue::create(layer.backgroundXOrigin( )));
107 } 107 }
108 positionList->append(*zoomAdjustedPixelValueForLength(layer.xPosition(), sty le)); 108 positionList->append(*zoomAdjustedPixelValueForLength(layer.xPosition(), sty le));
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 left = CSSPrimitiveValue::create(image.imageSlices().left(). value(), CSSPrimitiveValue::UnitType::Percentage); 306 left = CSSPrimitiveValue::create(image.imageSlices().left(). value(), CSSPrimitiveValue::UnitType::Percentage);
307 else 307 else
308 left = CSSPrimitiveValue::create(image.imageSlices().left(). value(), CSSPrimitiveValue::UnitType::Number); 308 left = CSSPrimitiveValue::create(image.imageSlices().left(). value(), CSSPrimitiveValue::UnitType::Number);
309 } 309 }
310 } 310 }
311 } 311 }
312 312
313 return CSSBorderImageSliceValue::create(CSSQuadValue::create(top, right, bot tom, left, CSSQuadValue::SerializeAsQuad), image.fill()); 313 return CSSBorderImageSliceValue::create(CSSQuadValue::create(top, right, bot tom, left, CSSQuadValue::SerializeAsQuad), image.fill());
314 } 314 }
315 315
316 static CSSPrimitiveValue* valueForBorderImageLength(const BorderImageLength& bor derImageLength, const ComputedStyle& style)
317 {
318 if (borderImageLength.isNumber())
319 return CSSPrimitiveValue::create(borderImageLength.number(), CSSPrimitiv eValue::UnitType::Number);
320 return CSSPrimitiveValue::create(borderImageLength.length(), style.effective Zoom());
321 }
322
316 static CSSQuadValue* valueForNinePieceImageQuad(const BorderImageLengthBox& box, const ComputedStyle& style) 323 static CSSQuadValue* valueForNinePieceImageQuad(const BorderImageLengthBox& box, const ComputedStyle& style)
317 { 324 {
318 // Create the slices. 325 // Create the slices.
319 CSSPrimitiveValue* top = nullptr; 326 CSSPrimitiveValue* top = nullptr;
320 CSSPrimitiveValue* right = nullptr; 327 CSSPrimitiveValue* right = nullptr;
321 CSSPrimitiveValue* bottom = nullptr; 328 CSSPrimitiveValue* bottom = nullptr;
322 CSSPrimitiveValue* left = nullptr; 329 CSSPrimitiveValue* left = nullptr;
323 330
324 if (box.top().isNumber()) 331 top = valueForBorderImageLength(box.top(), style);
325 top = CSSPrimitiveValue::create(box.top().number(), CSSPrimitiveValue::U nitType::Number);
326 else
327 top = CSSPrimitiveValue::create(box.top().length(), style);
328 332
329 if (box.right() == box.top() && box.bottom() == box.top() && box.left() == b ox.top()) { 333 if (box.right() == box.top() && box.bottom() == box.top() && box.left() == b ox.top()) {
330 right = top; 334 right = top;
331 bottom = top; 335 bottom = top;
332 left = top; 336 left = top;
333 } else { 337 } else {
334 if (box.right().isNumber()) 338 right = valueForBorderImageLength(box.right(), style);
335 right = CSSPrimitiveValue::create(box.right().number(), CSSPrimitive Value::UnitType::Number);
336 else
337 right = CSSPrimitiveValue::create(box.right().length(), style);
338 339
339 if (box.bottom() == box.top() && box.right() == box.left()) { 340 if (box.bottom() == box.top() && box.right() == box.left()) {
340 bottom = top; 341 bottom = top;
341 left = right; 342 left = right;
342 } else { 343 } else {
343 if (box.bottom().isNumber()) 344 bottom = valueForBorderImageLength(box.bottom(), style);
344 bottom = CSSPrimitiveValue::create(box.bottom().number(), CSSPri mitiveValue::UnitType::Number); 345
346 if (box.left() == box.right())
347 left = right;
345 else 348 else
346 bottom = CSSPrimitiveValue::create(box.bottom().length(), style) ; 349 left = valueForBorderImageLength(box.left(), style);
347
348 if (box.left() == box.right()) {
349 left = right;
350 } else {
351 if (box.left().isNumber())
352 left = CSSPrimitiveValue::create(box.left().number(), CSSPri mitiveValue::UnitType::Number);
353 else
354 left = CSSPrimitiveValue::create(box.left().length(), style) ;
355 }
356 } 350 }
357 } 351 }
358
359 return CSSQuadValue::create(top, right, bottom, left, CSSQuadValue::Serializ eAsQuad); 352 return CSSQuadValue::create(top, right, bottom, left, CSSQuadValue::Serializ eAsQuad);
360 } 353 }
361 354
362 static CSSValueID valueForRepeatRule(int rule) 355 static CSSValueID valueForRepeatRule(int rule)
363 { 356 {
364 switch (rule) { 357 switch (rule) {
365 case RepeatImageRule: 358 case RepeatImageRule:
366 return CSSValueRepeat; 359 return CSSValueRepeat;
367 case RoundImageRule: 360 case RoundImageRule:
368 return CSSValueRound; 361 return CSSValueRound;
(...skipping 2283 matching lines...) Expand 10 before | Expand all | Expand 10 after
2652 return valueForCounterDirectives(style, propertyID); 2645 return valueForCounterDirectives(style, propertyID);
2653 case CSSPropertyClipPath: 2646 case CSSPropertyClipPath:
2654 if (ClipPathOperation* operation = style.clipPath()) { 2647 if (ClipPathOperation* operation = style.clipPath()) {
2655 if (operation->type() == ClipPathOperation::SHAPE) 2648 if (operation->type() == ClipPathOperation::SHAPE)
2656 return valueForBasicShape(style, toShapeClipPathOperation(operat ion)->basicShape()); 2649 return valueForBasicShape(style, toShapeClipPathOperation(operat ion)->basicShape());
2657 if (operation->type() == ClipPathOperation::REFERENCE) 2650 if (operation->type() == ClipPathOperation::REFERENCE)
2658 return CSSURIValue::create(toReferenceClipPathOperation(operatio n)->url()); 2651 return CSSURIValue::create(toReferenceClipPathOperation(operatio n)->url());
2659 } 2652 }
2660 return CSSPrimitiveValue::createIdentifier(CSSValueNone); 2653 return CSSPrimitiveValue::createIdentifier(CSSValueNone);
2661 case CSSPropertyShapeMargin: 2654 case CSSPropertyShapeMargin:
2662 return CSSPrimitiveValue::create(style.shapeMargin(), style); 2655 return CSSPrimitiveValue::create(style.shapeMargin(), style.effectiveZoo m());
2663 case CSSPropertyShapeImageThreshold: 2656 case CSSPropertyShapeImageThreshold:
2664 return CSSPrimitiveValue::create(style.shapeImageThreshold(), CSSPrimiti veValue::UnitType::Number); 2657 return CSSPrimitiveValue::create(style.shapeImageThreshold(), CSSPrimiti veValue::UnitType::Number);
2665 case CSSPropertyShapeOutside: 2658 case CSSPropertyShapeOutside:
2666 return valueForShape(style, style.shapeOutside()); 2659 return valueForShape(style, style.shapeOutside());
2667 case CSSPropertyFilter: 2660 case CSSPropertyFilter:
2668 return valueForFilter(style, style.filter()); 2661 return valueForFilter(style, style.filter());
2669 case CSSPropertyBackdropFilter: 2662 case CSSPropertyBackdropFilter:
2670 return valueForFilter(style, style.backdropFilter()); 2663 return valueForFilter(style, style.backdropFilter());
2671 case CSSPropertyMixBlendMode: 2664 case CSSPropertyMixBlendMode:
2672 return CSSPrimitiveValue::create(style.blendMode()); 2665 return CSSPrimitiveValue::create(style.blendMode());
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
3016 case CSSPropertyAll: 3009 case CSSPropertyAll:
3017 return nullptr; 3010 return nullptr;
3018 default: 3011 default:
3019 break; 3012 break;
3020 } 3013 }
3021 ASSERT_NOT_REACHED(); 3014 ASSERT_NOT_REACHED();
3022 return nullptr; 3015 return nullptr;
3023 } 3016 }
3024 3017
3025 } // namespace blink 3018 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698