Source/WebCore/ChangeLog

 12014-01-13 Bear Travis <betravis@adobe.com>
 2
 3 [CSS Shapes] Move CSSPrimitiveValue <-> LayoutBox Conversion to CSSPrimitiveValueMappings
 4 https://bugs.webkit.org/show_bug.cgi?id=126719
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 The standard location for conversions to/from CSSPrimitiveValues is CSSPrimitiveValueMappings.
 9 This patch moves the conversion for LayoutBoxes from BasicShapeFunctions to
 10 CSSPrimitiveValueMappings.h.
 11
 12 Refactoring, no new tests.
 13
 14 * css/BasicShapeFunctions.cpp:
 15 (WebCore::valueForBasicShape):
 16 (WebCore::basicShapeForValue):
 17 * css/CSSComputedStyleDeclaration.cpp:
 18 (WebCore::ComputedStyleExtractor::propertyValue):
 19 * css/CSSPrimitiveValueMappings.h:
 20 (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
 21 (WebCore::CSSPrimitiveValue::operator LayoutBox):
 22 * css/DeprecatedStyleBuilder.cpp:
 23 (WebCore::ApplyPropertyClipPath::applyValue):
 24 (WebCore::ApplyPropertyShape::applyValue):
 25
1262014-01-13 Alexey Proskuryakov <ap@apple.com>
227
328 Fix the build more.

Source/WebCore/css/BasicShapeFunctions.cpp

3939
4040namespace WebCore {
4141
42 PassRefPtr<CSSPrimitiveValue> valueForBox(LayoutBox box)
43 {
44  switch (box) {
45  case ContentBox:
46  return cssValuePool().createIdentifierValue(CSSValueContentBox);
47  case PaddingBox:
48  return cssValuePool().createIdentifierValue(CSSValuePaddingBox);
49  case BorderBox:
50  return cssValuePool().createIdentifierValue(CSSValueBorderBox);
51  case MarginBox:
52  return cssValuePool().createIdentifierValue(CSSValueMarginBox);
53  case BoundingBox:
54  return cssValuePool().createIdentifierValue(CSSValueBoundingBox);
55  case BoxMissing:
56  return nullptr;
57  }
58  ASSERT_NOT_REACHED();
59  return nullptr;
60 }
61 
62 LayoutBox boxForValue(const CSSPrimitiveValue* value)
63 {
64  if (!value)
65  return BoxMissing;
66 
67  switch (value->getValueID()) {
68  case CSSValueContentBox:
69  return ContentBox;
70  case CSSValuePaddingBox:
71  return PaddingBox;
72  case CSSValueBorderBox:
73  return BorderBox;
74  case CSSValueMarginBox:
75  return MarginBox;
76  case CSSValueBoundingBox:
77  return BoundingBox;
78  default:
79  ASSERT_NOT_REACHED();
80  return BoxMissing;
81  }
82 }
83 
8442static PassRefPtr<CSSPrimitiveValue> valueForCenterCoordinate(CSSValuePool& pool, const RenderStyle* style, const BasicShapeCenterCoordinate& center)
8543{
8644 CSSValueID keyword = CSSValueInvalid;

@@PassRefPtr<CSSValue> valueForBasicShape(const RenderStyle* style, const BasicSha
230188 break;
231189 }
232190
233  basicShapeValue->setLayoutBox(valueForBox(basicShape->layoutBox()));
 191 if (basicShape->layoutBox() != BoxMissing)
 192 basicShapeValue->setLayoutBox(pool.createValue(basicShape->layoutBox()));
234193
235194 return pool.createValue(basicShapeValue.release());
236195}

@@PassRefPtr<BasicShape> basicShapeForValue(const RenderStyle* style, const Render
460419 break;
461420 }
462421
463  basicShape->setLayoutBox(boxForValue(basicShapeValue->layoutBox()));
 422 if (basicShapeValue->layoutBox())
 423 basicShape->setLayoutBox(LayoutBox(*basicShapeValue->layoutBox()));
464424
465425 return basicShape.release();
466426}

Source/WebCore/css/CSSComputedStyleDeclaration.cpp

@@PassRefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propert
28852885 ShapeClipPathOperation& shapeOperation = toShapeClipPathOperation(*operation);
28862886 list->append(valueForBasicShape(style.get(), shapeOperation.basicShape()));
28872887 if (shapeOperation.referenceBox() != BoxMissing)
2888  list->append(valueForBox(shapeOperation.referenceBox()));
 2888 list->append(cssValuePool().createValue(shapeOperation.referenceBox()));
28892889 }
28902890 if (operation->type() == ClipPathOperation::Box) {
28912891 BoxClipPathOperation& boxOperation = toBoxClipPathOperation(*operation);
2892  list->append(valueForBox(boxOperation.referenceBox()));
 2892 list->append(cssValuePool().createValue(boxOperation.referenceBox()));
28932893 }
28942894 return list.release();
28952895 }

@@PassRefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propert
29222922 if (!style->shapeInside())
29232923 return cssValuePool().createIdentifierValue(CSSValueNone);
29242924 if (style->shapeInside()->type() == ShapeValue::Box)
2925  return valueForBox(style->shapeInside()->layoutBox());
 2925 return cssValuePool().createValue(style->shapeInside()->layoutBox());
29262926 if (style->shapeInside()->type() == ShapeValue::Outside)
29272927 return cssValuePool().createIdentifierValue(CSSValueOutsideShape);
29282928 if (style->shapeInside()->type() == ShapeValue::Image) {

@@PassRefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propert
29362936 if (!style->shapeOutside())
29372937 return cssValuePool().createIdentifierValue(CSSValueNone);
29382938 if (style->shapeOutside()->type() == ShapeValue::Box)
2939  return valueForBox(style->shapeOutside()->layoutBox());
 2939 return cssValuePool().createValue(style->shapeOutside()->layoutBox());
29402940 if (style->shapeOutside()->type() == ShapeValue::Image) {
29412941 if (style->shapeOutside()->image())
29422942 return style->shapeOutside()->image()->cssValue();

Source/WebCore/css/CSSPrimitiveValueMappings.h

@@template<> inline CSSPrimitiveValue::operator ImageOrientationEnum() const
51655165
51665166#endif // ENABLE(CSS_IMAGE_ORIENTATION)
51675167
 5168template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LayoutBox layoutBox)
 5169 : CSSValue(PrimitiveClass)
 5170{
 5171 m_primitiveUnitType = CSS_VALUE_ID;
 5172 switch (layoutBox) {
 5173 case BoundingBox:
 5174 m_value.valueID = CSSValueBoundingBox;
 5175 break;
 5176 case MarginBox:
 5177 m_value.valueID = CSSValueMarginBox;
 5178 break;
 5179 case BorderBox:
 5180 m_value.valueID = CSSValueBorderBox;
 5181 break;
 5182 case PaddingBox:
 5183 m_value.valueID = CSSValuePaddingBox;
 5184 break;
 5185 case ContentBox:
 5186 m_value.valueID = CSSValueContentBox;
 5187 break;
 5188 case BoxMissing:
 5189 ASSERT_NOT_REACHED();
 5190 m_value.valueID = CSSValueNone;
 5191 break;
 5192 }
 5193}
 5194
 5195template<> inline CSSPrimitiveValue::operator LayoutBox() const
 5196{
 5197 switch (getValueID()) {
 5198 case CSSValueBoundingBox:
 5199 return BoundingBox;
 5200 case CSSValueMarginBox:
 5201 return MarginBox;
 5202 case CSSValueBorderBox:
 5203 return BorderBox;
 5204 case CSSValuePaddingBox:
 5205 return PaddingBox;
 5206 case CSSValueContentBox:
 5207 return ContentBox;
 5208 default:
 5209 break;
 5210 }
 5211 ASSERT_NOT_REACHED();
 5212 return BoxMissing;
 5213}
 5214
51685215}
51695216
51705217#endif

Source/WebCore/css/DeprecatedStyleBuilder.cpp

@@public:
21102110 || primitiveValue.getValueID() == CSSValueMarginBox
21112111 || primitiveValue.getValueID() == CSSValueBoundingBox)
21122112 && referenceBox == BoxMissing)
2113  referenceBox = boxForValue(&primitiveValue);
 2113 referenceBox = LayoutBox(primitiveValue);
21142114 else
21152115 return;
21162116 }

@@public:
21442144 || primitiveValue->getValueID() == CSSValueBorderBox
21452145 || primitiveValue->getValueID() == CSSValuePaddingBox
21462146 || primitiveValue->getValueID() == CSSValueMarginBox)
2147  setValue(styleResolver->style(), ShapeValue::createLayoutBoxValue(boxForValue(primitiveValue)));
 2147 setValue(styleResolver->style(), ShapeValue::createLayoutBoxValue(LayoutBox(*primitiveValue)));
21482148 else if (primitiveValue->getValueID() == CSSValueOutsideShape)
21492149 setValue(styleResolver->style(), ShapeValue::createOutsideValue());
21502150 else if (primitiveValue->isShape()) {