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

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

Issue 1318543010: Change first() and second() in CSSPairValue to return const references (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Review feedback Created 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/BasicShapeFunctions.cpp ('k') | Source/core/css/CSSGradientValue.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) 2011 Adobe Systems Incorporated. All rights reserved. 2 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above 8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following 9 * copyright notice, this list of conditions and the following
10 * disclaimer. 10 * disclaimer.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 result.append(centerX); 58 result.append(centerX);
59 result.appendLiteral(separator); 59 result.appendLiteral(separator);
60 result.append(centerY); 60 result.append(centerY);
61 } 61 }
62 result.append(')'); 62 result.append(')');
63 return result.toString(); 63 return result.toString();
64 } 64 }
65 65
66 static String serializePositionOffset(const CSSValuePair& offset, const CSSValue Pair& other) 66 static String serializePositionOffset(const CSSValuePair& offset, const CSSValue Pair& other)
67 { 67 {
68 if ((toCSSPrimitiveValue(offset.first())->getValueID() == CSSValueLeft && to CSSPrimitiveValue(other.first())->getValueID() == CSSValueTop) 68 if ((toCSSPrimitiveValue(offset.first()).getValueID() == CSSValueLeft && toC SSPrimitiveValue(other.first()).getValueID() == CSSValueTop)
69 || (toCSSPrimitiveValue(offset.first())->getValueID() == CSSValueTop && toCSSPrimitiveValue(other.first())->getValueID() == CSSValueLeft)) 69 || (toCSSPrimitiveValue(offset.first()).getValueID() == CSSValueTop && t oCSSPrimitiveValue(other.first()).getValueID() == CSSValueLeft))
70 return offset.second()->cssText(); 70 return offset.second().cssText();
71 return offset.cssText(); 71 return offset.cssText();
72 } 72 }
73 73
74 static PassRefPtrWillBeRawPtr<CSSValuePair> buildSerializablePositionOffset(Pass RefPtrWillBeRawPtr<CSSValue> offset, CSSValueID defaultSide) 74 static PassRefPtrWillBeRawPtr<CSSValuePair> buildSerializablePositionOffset(Pass RefPtrWillBeRawPtr<CSSValue> offset, CSSValueID defaultSide)
75 { 75 {
76 CSSValueID side = defaultSide; 76 CSSValueID side = defaultSide;
77 RefPtrWillBeRawPtr<CSSPrimitiveValue> amount = nullptr; 77 RefPtrWillBeRawPtr<CSSPrimitiveValue> amount = nullptr;
78 78
79 if (!offset) { 79 if (!offset) {
80 side = CSSValueCenter; 80 side = CSSValueCenter;
81 } else if (offset->isPrimitiveValue() && toCSSPrimitiveValue(offset.get())-> isValueID()) { 81 } else if (offset->isPrimitiveValue() && toCSSPrimitiveValue(offset.get())-> isValueID()) {
82 side = toCSSPrimitiveValue(offset.get())->getValueID(); 82 side = toCSSPrimitiveValue(offset.get())->getValueID();
83 } else if (offset->isValuePair()) { 83 } else if (offset->isValuePair()) {
84 side = toCSSPrimitiveValue(toCSSValuePair(offset.get())->first())->getVa lueID(); 84 side = toCSSPrimitiveValue(toCSSValuePair(*offset).first()).getValueID() ;
85 amount = toCSSPrimitiveValue(toCSSValuePair(offset.get())->second()); 85 amount = &toCSSPrimitiveValue(toCSSValuePair(*offset).second());
86 } else { 86 } else {
87 amount = toCSSPrimitiveValue(offset.get()); 87 amount = toCSSPrimitiveValue(offset.get());
88 } 88 }
89 89
90 if (side == CSSValueCenter) { 90 if (side == CSSValueCenter) {
91 side = defaultSide; 91 side = defaultSide;
92 amount = cssValuePool().createValue(50, CSSPrimitiveValue::UnitType::Per centage); 92 amount = cssValuePool().createValue(50, CSSPrimitiveValue::UnitType::Per centage);
93 } else if ((side == CSSValueRight || side == CSSValueBottom) 93 } else if ((side == CSSValueRight || side == CSSValueBottom)
94 && amount->isPercentage()) { 94 && amount->isPercentage()) {
95 side = defaultSide; 95 side = defaultSide;
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 result.append(verticalRadii[i]); 347 result.append(verticalRadii[i]);
348 } 348 }
349 } 349 }
350 } 350 }
351 } 351 }
352 result.append(')'); 352 result.append(')');
353 353
354 return result.toString(); 354 return result.toString();
355 } 355 }
356 356
357 static inline void updateCornerRadiusWidthAndHeight(CSSValuePair* cornerRadius, String& width, String& height) 357 static inline void updateCornerRadiusWidthAndHeight(const CSSValuePair* cornerRa dius, String& width, String& height)
358 { 358 {
359 if (!cornerRadius) 359 if (!cornerRadius)
360 return; 360 return;
361 361
362 width = cornerRadius->first() ? cornerRadius->first()->cssText() : String("0 "); 362 width = cornerRadius->first().cssText();
363 if (cornerRadius->second()) 363 height = cornerRadius->second().cssText();
364 height = cornerRadius->second()->cssText();
365 } 364 }
366 365
367 String CSSBasicShapeInset::cssText() const 366 String CSSBasicShapeInset::cssText() const
368 { 367 {
369 String topLeftRadiusWidth; 368 String topLeftRadiusWidth;
370 String topLeftRadiusHeight; 369 String topLeftRadiusHeight;
371 String topRightRadiusWidth; 370 String topRightRadiusWidth;
372 String topRightRadiusHeight; 371 String topRightRadiusHeight;
373 String bottomRightRadiusWidth; 372 String bottomRightRadiusWidth;
374 String bottomRightRadiusHeight; 373 String bottomRightRadiusHeight;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 visitor->trace(m_left); 417 visitor->trace(m_left);
419 visitor->trace(m_topLeftRadius); 418 visitor->trace(m_topLeftRadius);
420 visitor->trace(m_topRightRadius); 419 visitor->trace(m_topRightRadius);
421 visitor->trace(m_bottomRightRadius); 420 visitor->trace(m_bottomRightRadius);
422 visitor->trace(m_bottomLeftRadius); 421 visitor->trace(m_bottomLeftRadius);
423 CSSBasicShape::trace(visitor); 422 CSSBasicShape::trace(visitor);
424 } 423 }
425 424
426 } // namespace blink 425 } // namespace blink
427 426
OLDNEW
« no previous file with comments | « Source/core/css/BasicShapeFunctions.cpp ('k') | Source/core/css/CSSGradientValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698