OLD | NEW |
1 /* | 1 /* |
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2012 Apple Inc. All rights reserv
ed. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2012 Apple Inc. All rights reserv
ed. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 case CSSValueWebkitText: | 152 case CSSValueWebkitText: |
153 case CSSValueWebkitLink: | 153 case CSSValueWebkitLink: |
154 case CSSValueWebkitActivelink: | 154 case CSSValueWebkitActivelink: |
155 case CSSValueCurrentcolor: | 155 case CSSValueCurrentcolor: |
156 return true; | 156 return true; |
157 default: | 157 default: |
158 return false; | 158 return false; |
159 } | 159 } |
160 } | 160 } |
161 | 161 |
162 typedef HashMap<const CSSPrimitiveValue*, String> CSSTextCache; | 162 typedef HashMap<const CSSPrimitiveValue::CSSLargePrimitiveValue*, String> CSSTex
tCache; |
163 static CSSTextCache& cssTextCache() | 163 static CSSTextCache& cssTextCache() |
164 { | 164 { |
165 AtomicallyInitializedStaticReference(ThreadSpecific<CSSTextCache>, cache, ne
w ThreadSpecific<CSSTextCache>()); | 165 AtomicallyInitializedStaticReference(ThreadSpecific<CSSTextCache>, cache, ne
w ThreadSpecific<CSSTextCache>()); |
166 return *cache; | 166 return *cache; |
167 } | 167 } |
168 | 168 |
169 CSSPrimitiveValue::UnitType CSSPrimitiveValue::primitiveType() const | 169 CSSPrimitiveValue::UnitType CSSPrimitiveValue::primitiveType() const |
170 { | 170 { |
171 if (m_primitiveUnitType == CSS_PROPERTY_ID || m_primitiveUnitType == CSS_VAL
UE_ID) | 171 if (type() == CSS_PROPERTY_ID || type() == CSS_VALUE_ID) |
172 return CSS_IDENT; | 172 return CSS_IDENT; |
173 | 173 |
174 if (m_primitiveUnitType != CSS_CALC) | 174 if (type() != CSS_CALC) |
175 return static_cast<UnitType>(m_primitiveUnitType); | 175 return type(); |
176 | 176 |
177 switch (m_value.calc->category()) { | 177 switch (value().calc->category()) { |
178 case CalcAngle: | 178 case CalcAngle: |
179 return CSS_DEG; | 179 return CSS_DEG; |
180 case CalcFrequency: | 180 case CalcFrequency: |
181 return CSS_HZ; | 181 return CSS_HZ; |
182 case CalcNumber: | 182 case CalcNumber: |
183 return CSS_NUMBER; | 183 return CSS_NUMBER; |
184 case CalcPercent: | 184 case CalcPercent: |
185 return CSS_PERCENTAGE; | 185 return CSS_PERCENTAGE; |
186 case CalcLength: | 186 case CalcLength: |
187 return CSS_PX; | 187 return CSS_PX; |
(...skipping 22 matching lines...) Expand all Loading... |
210 if (valueID < 0) | 210 if (valueID < 0) |
211 return nullAtom; | 211 return nullAtom; |
212 | 212 |
213 static AtomicString* keywordStrings = new AtomicString[numCSSValueKeywords];
// Leaked intentionally. | 213 static AtomicString* keywordStrings = new AtomicString[numCSSValueKeywords];
// Leaked intentionally. |
214 AtomicString& keywordString = keywordStrings[valueID]; | 214 AtomicString& keywordString = keywordStrings[valueID]; |
215 if (keywordString.isNull()) | 215 if (keywordString.isNull()) |
216 keywordString = getValueName(valueID); | 216 keywordString = getValueName(valueID); |
217 return keywordString; | 217 return keywordString; |
218 } | 218 } |
219 | 219 |
220 CSSPrimitiveValue::CSSPrimitiveValue(CSSValueID valueID) | 220 CSSPrimitiveValue::CSSLargePrimitiveValue::CSSLargePrimitiveValue(CSSValueID val
ueID) |
221 : CSSValueObject(PrimitiveClass) | 221 : CSSValueObject(PrimitiveClass) |
222 { | 222 { |
223 m_primitiveUnitType = CSS_VALUE_ID; | 223 m_primitiveUnitType = CSS_VALUE_ID; |
224 m_value.valueID = valueID; | 224 m_value.valueID = valueID; |
225 } | 225 } |
226 | 226 |
227 CSSPrimitiveValue::CSSPrimitiveValue(CSSPropertyID propertyID) | 227 CSSPrimitiveValue::CSSLargePrimitiveValue::CSSLargePrimitiveValue(CSSPropertyID
propertyID) |
228 : CSSValueObject(PrimitiveClass) | 228 : CSSValueObject(PrimitiveClass) |
229 { | 229 { |
230 m_primitiveUnitType = CSS_PROPERTY_ID; | 230 m_primitiveUnitType = CSS_PROPERTY_ID; |
231 m_value.propertyID = propertyID; | 231 m_value.propertyID = propertyID; |
232 } | 232 } |
233 | 233 |
234 CSSPrimitiveValue::CSSPrimitiveValue(double num, UnitType type) | 234 CSSPrimitiveValue::CSSLargePrimitiveValue::CSSLargePrimitiveValue(double num, Un
itType type) |
235 : CSSValueObject(PrimitiveClass) | 235 : CSSValueObject(PrimitiveClass) |
236 { | 236 { |
237 m_primitiveUnitType = type; | 237 m_primitiveUnitType = type; |
238 ASSERT(std::isfinite(num)); | 238 ASSERT(std::isfinite(num)); |
239 m_value.num = num; | 239 m_value.num = num; |
240 } | 240 } |
241 | 241 |
242 CSSPrimitiveValue::CSSPrimitiveValue(const String& str, UnitType type) | 242 CSSPrimitiveValue::CSSLargePrimitiveValue::CSSLargePrimitiveValue(double num, Un
itType type, bool isQuirkValue) |
243 : CSSValueObject(PrimitiveClass) | 243 : CSSValueObject(PrimitiveClass) |
244 { | 244 { |
245 m_primitiveUnitType = type; | 245 m_primitiveUnitType = type; |
| 246 m_isQuirkValue = true; |
| 247 ASSERT(std::isfinite(num)); |
| 248 m_value.num = num; |
| 249 } |
| 250 |
| 251 CSSPrimitiveValue::CSSLargePrimitiveValue::CSSLargePrimitiveValue(const String&
str, UnitType type) |
| 252 : CSSValueObject(PrimitiveClass) |
| 253 { |
| 254 m_primitiveUnitType = type; |
246 m_value.string = str.impl(); | 255 m_value.string = str.impl(); |
247 if (m_value.string) | 256 if (m_value.string) |
248 m_value.string->ref(); | 257 m_value.string->ref(); |
249 } | 258 } |
250 | 259 |
251 CSSPrimitiveValue::CSSPrimitiveValue(const LengthSize& lengthSize, const Compute
dStyle& style) | 260 CSSPrimitiveValue::CSSLargePrimitiveValue::CSSLargePrimitiveValue(const LengthSi
ze& lengthSize, const ComputedStyle& style) |
252 : CSSValueObject(PrimitiveClass) | 261 : CSSValueObject(PrimitiveClass) |
253 { | 262 { |
254 init(lengthSize, style); | 263 init(lengthSize, style); |
255 } | 264 } |
256 | 265 |
257 CSSPrimitiveValue::CSSPrimitiveValue(RGBA32 color) | 266 CSSPrimitiveValue::CSSLargePrimitiveValue::CSSLargePrimitiveValue(RGBA32 color) |
258 : CSSValueObject(PrimitiveClass) | 267 : CSSValueObject(PrimitiveClass) |
259 { | 268 { |
260 m_primitiveUnitType = CSS_RGBCOLOR; | 269 m_primitiveUnitType = CSS_RGBCOLOR; |
261 m_value.rgbcolor = color; | 270 m_value.rgbcolor = color; |
262 } | 271 } |
263 | 272 |
264 CSSPrimitiveValue::CSSPrimitiveValue(const Length& length, float zoom) | 273 CSSPrimitiveValue::CSSLargePrimitiveValue::CSSLargePrimitiveValue(const Length&
length, float zoom) |
265 : CSSValueObject(PrimitiveClass) | 274 : CSSValueObject(PrimitiveClass) |
266 { | 275 { |
267 switch (length.type()) { | 276 switch (length.type()) { |
268 case Auto: | 277 case Auto: |
269 m_primitiveUnitType = CSS_VALUE_ID; | 278 m_primitiveUnitType = CSS_VALUE_ID; |
270 m_value.valueID = CSSValueAuto; | 279 m_value.valueID = CSSValueAuto; |
271 break; | 280 break; |
272 case Intrinsic: | 281 case Intrinsic: |
273 m_primitiveUnitType = CSS_VALUE_ID; | 282 m_primitiveUnitType = CSS_VALUE_ID; |
274 m_value.valueID = CSSValueIntrinsic; | 283 m_value.valueID = CSSValueIntrinsic; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 break; | 335 break; |
327 } | 336 } |
328 case DeviceWidth: | 337 case DeviceWidth: |
329 case DeviceHeight: | 338 case DeviceHeight: |
330 case MaxSizeNone: | 339 case MaxSizeNone: |
331 ASSERT_NOT_REACHED(); | 340 ASSERT_NOT_REACHED(); |
332 break; | 341 break; |
333 } | 342 } |
334 } | 343 } |
335 | 344 |
336 void CSSPrimitiveValue::init(const LengthSize& lengthSize, const ComputedStyle&
style) | 345 void CSSPrimitiveValue::CSSLargePrimitiveValue::init(const LengthSize& lengthSiz
e, const ComputedStyle& style) |
337 { | 346 { |
338 m_primitiveUnitType = CSS_PAIR; | 347 m_primitiveUnitType = CSS_PAIR; |
339 m_hasCachedCSSText = false; | 348 m_hasCachedCSSText = false; |
340 m_value.pair = Pair::create(create(lengthSize.width(), style.effectiveZoom()
), create(lengthSize.height(), style.effectiveZoom()), Pair::KeepIdenticalValues
).leakRef(); | 349 m_value.pair = Pair::create(create(lengthSize.width(), style.effectiveZoom()
), create(lengthSize.height(), style.effectiveZoom()), Pair::KeepIdenticalValues
).leakRef(); |
341 } | 350 } |
342 | 351 |
343 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<Counter> c) | 352 void CSSPrimitiveValue::CSSLargePrimitiveValue::init(PassRefPtrWillBeRawPtr<Coun
ter> c) |
344 { | 353 { |
345 m_primitiveUnitType = CSS_COUNTER; | 354 m_primitiveUnitType = CSS_COUNTER; |
346 m_hasCachedCSSText = false; | 355 m_hasCachedCSSText = false; |
347 m_value.counter = c.leakRef(); | 356 m_value.counter = c.leakRef(); |
348 } | 357 } |
349 | 358 |
350 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<Rect> r) | 359 void CSSPrimitiveValue::CSSLargePrimitiveValue::init(PassRefPtrWillBeRawPtr<Rect
> r) |
351 { | 360 { |
352 m_primitiveUnitType = CSS_RECT; | 361 m_primitiveUnitType = CSS_RECT; |
353 m_hasCachedCSSText = false; | 362 m_hasCachedCSSText = false; |
354 m_value.rect = r.leakRef(); | 363 m_value.rect = r.leakRef(); |
355 } | 364 } |
356 | 365 |
357 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<Quad> quad) | 366 void CSSPrimitiveValue::CSSLargePrimitiveValue::init(PassRefPtrWillBeRawPtr<Quad
> quad) |
358 { | 367 { |
359 m_primitiveUnitType = CSS_QUAD; | 368 m_primitiveUnitType = CSS_QUAD; |
360 m_hasCachedCSSText = false; | 369 m_hasCachedCSSText = false; |
361 m_value.quad = quad.leakRef(); | 370 m_value.quad = quad.leakRef(); |
362 } | 371 } |
363 | 372 |
364 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<Pair> p) | 373 void CSSPrimitiveValue::CSSLargePrimitiveValue::init(PassRefPtrWillBeRawPtr<Pair
> p) |
365 { | 374 { |
366 m_primitiveUnitType = CSS_PAIR; | 375 m_primitiveUnitType = CSS_PAIR; |
367 m_hasCachedCSSText = false; | 376 m_hasCachedCSSText = false; |
368 m_value.pair = p.leakRef(); | 377 m_value.pair = p.leakRef(); |
369 } | 378 } |
370 | 379 |
371 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<CSSCalcValue> c) | 380 void CSSPrimitiveValue::CSSLargePrimitiveValue::init(PassRefPtrWillBeRawPtr<CSSC
alcValue> c) |
372 { | 381 { |
373 m_primitiveUnitType = CSS_CALC; | 382 m_primitiveUnitType = CSS_CALC; |
374 m_hasCachedCSSText = false; | 383 m_hasCachedCSSText = false; |
375 m_value.calc = c.leakRef(); | 384 m_value.calc = c.leakRef(); |
376 } | 385 } |
377 | 386 |
378 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<CSSBasicShape> shape) | 387 void CSSPrimitiveValue::CSSLargePrimitiveValue::init(PassRefPtrWillBeRawPtr<CSSB
asicShape> shape) |
379 { | 388 { |
380 m_primitiveUnitType = CSS_SHAPE; | 389 m_primitiveUnitType = CSS_SHAPE; |
381 m_hasCachedCSSText = false; | 390 m_hasCachedCSSText = false; |
382 m_value.shape = shape.leakRef(); | 391 m_value.shape = shape.leakRef(); |
383 } | 392 } |
384 | 393 |
385 CSSPrimitiveValue::~CSSPrimitiveValue() | 394 CSSPrimitiveValue::CSSLargePrimitiveValue::~CSSLargePrimitiveValue() |
386 { | 395 { |
387 cleanup(); | 396 cleanup(); |
388 } | 397 } |
389 | 398 |
390 void CSSPrimitiveValue::cleanup() | 399 void CSSPrimitiveValue::CSSLargePrimitiveValue::cleanup() |
391 { | 400 { |
392 switch (static_cast<UnitType>(m_primitiveUnitType)) { | 401 switch (m_primitiveUnitType) { |
393 case CSS_CUSTOM_IDENT: | 402 case CSS_CUSTOM_IDENT: |
394 case CSS_STRING: | 403 case CSS_STRING: |
395 case CSS_URI: | 404 case CSS_URI: |
396 case CSS_ATTR: | 405 case CSS_ATTR: |
397 if (m_value.string) | 406 if (m_value.string) |
398 m_value.string->deref(); | 407 m_value.string->deref(); |
399 break; | 408 break; |
400 case CSS_COUNTER: | 409 case CSS_COUNTER: |
401 // We must not call deref() when oilpan is enabled because m_value.count
er is traced. | 410 // We must not call deref() when oilpan is enabled because m_value.count
er is traced. |
402 #if !ENABLE(OILPAN) | 411 #if !ENABLE(OILPAN) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 m_primitiveUnitType = 0; | 486 m_primitiveUnitType = 0; |
478 if (m_hasCachedCSSText) { | 487 if (m_hasCachedCSSText) { |
479 cssTextCache().remove(this); | 488 cssTextCache().remove(this); |
480 m_hasCachedCSSText = false; | 489 m_hasCachedCSSText = false; |
481 } | 490 } |
482 } | 491 } |
483 | 492 |
484 double CSSPrimitiveValue::computeSeconds() | 493 double CSSPrimitiveValue::computeSeconds() |
485 { | 494 { |
486 ASSERT(isTime() || (isCalculated() && cssCalcValue()->category() == CalcTime
)); | 495 ASSERT(isTime() || (isCalculated() && cssCalcValue()->category() == CalcTime
)); |
487 UnitType currentType = isCalculated() ? cssCalcValue()->expressionNode()->pr
imitiveType() : static_cast<UnitType>(m_primitiveUnitType); | 496 UnitType currentType = isCalculated() ? cssCalcValue()->expressionNode()->pr
imitiveType() : type(); |
488 if (currentType == CSS_S) | 497 if (currentType == CSS_S) |
489 return getDoubleValue(); | 498 return getDoubleValue(); |
490 if (currentType == CSS_MS) | 499 if (currentType == CSS_MS) |
491 return getDoubleValue() / 1000; | 500 return getDoubleValue() / 1000; |
492 ASSERT_NOT_REACHED(); | 501 ASSERT_NOT_REACHED(); |
493 return 0; | 502 return 0; |
494 } | 503 } |
495 | 504 |
496 double CSSPrimitiveValue::computeDegrees() const | 505 double CSSPrimitiveValue::computeDegrees() const |
497 { | 506 { |
498 ASSERT(isAngle() || (isCalculated() && cssCalcValue()->category() == CalcAng
le)); | 507 ASSERT(isAngle() || (isCalculated() && cssCalcValue()->category() == CalcAng
le)); |
499 UnitType currentType = isCalculated() ? cssCalcValue()->expressionNode()->pr
imitiveType() : static_cast<UnitType>(m_primitiveUnitType); | 508 UnitType currentType = isCalculated() ? cssCalcValue()->expressionNode()->pr
imitiveType() : type(); |
500 switch (currentType) { | 509 switch (currentType) { |
501 case CSS_DEG: | 510 case CSS_DEG: |
502 return getDoubleValue(); | 511 return getDoubleValue(); |
503 case CSS_RAD: | 512 case CSS_RAD: |
504 return rad2deg(getDoubleValue()); | 513 return rad2deg(getDoubleValue()); |
505 case CSS_GRAD: | 514 case CSS_GRAD: |
506 return grad2deg(getDoubleValue()); | 515 return grad2deg(getDoubleValue()); |
507 case CSS_TURN: | 516 case CSS_TURN: |
508 return turn2deg(getDoubleValue()); | 517 return turn2deg(getDoubleValue()); |
509 default: | 518 default: |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 template<> double CSSPrimitiveValue::computeLength(const CSSToLengthConversionDa
ta& conversionData) | 554 template<> double CSSPrimitiveValue::computeLength(const CSSToLengthConversionDa
ta& conversionData) |
546 { | 555 { |
547 return computeLengthDouble(conversionData); | 556 return computeLengthDouble(conversionData); |
548 } | 557 } |
549 | 558 |
550 double CSSPrimitiveValue::computeLengthDouble(const CSSToLengthConversionData& c
onversionData) | 559 double CSSPrimitiveValue::computeLengthDouble(const CSSToLengthConversionData& c
onversionData) |
551 { | 560 { |
552 // The logic in this function is duplicated in MediaValues::computeLength | 561 // The logic in this function is duplicated in MediaValues::computeLength |
553 // because MediaValues::computeLength needs nearly identical logic, but we h
aven't found a way to make | 562 // because MediaValues::computeLength needs nearly identical logic, but we h
aven't found a way to make |
554 // CSSPrimitiveValue::computeLengthDouble more generic (to solve both cases)
without hurting performance. | 563 // CSSPrimitiveValue::computeLengthDouble more generic (to solve both cases)
without hurting performance. |
555 if (m_primitiveUnitType == CSS_CALC) | 564 if (type() == CSS_CALC) |
556 return m_value.calc->computeLengthPx(conversionData); | 565 return value().calc->computeLengthPx(conversionData); |
557 | 566 |
558 double factor; | 567 double factor; |
559 | 568 |
560 switch (primitiveType()) { | 569 switch (primitiveType()) { |
561 case CSS_EMS: | 570 case CSS_EMS: |
562 factor = conversionData.emFontSize(); | 571 factor = conversionData.emFontSize(); |
563 break; | 572 break; |
564 case CSS_EXS: | 573 case CSS_EXS: |
565 factor = conversionData.exFontSize(); | 574 factor = conversionData.exFontSize(); |
566 break; | 575 break; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 if (isFontRelativeLength()) | 625 if (isFontRelativeLength()) |
617 return result; | 626 return result; |
618 | 627 |
619 return result * conversionData.zoom(); | 628 return result * conversionData.zoom(); |
620 } | 629 } |
621 | 630 |
622 void CSSPrimitiveValue::accumulateLengthArray(CSSLengthArray& lengthArray, CSSLe
ngthTypeArray& lengthTypeArray, double multiplier) const | 631 void CSSPrimitiveValue::accumulateLengthArray(CSSLengthArray& lengthArray, CSSLe
ngthTypeArray& lengthTypeArray, double multiplier) const |
623 { | 632 { |
624 ASSERT(lengthArray.size() == LengthUnitTypeCount); | 633 ASSERT(lengthArray.size() == LengthUnitTypeCount); |
625 | 634 |
626 if (m_primitiveUnitType == CSS_CALC) { | 635 if (type() == CSS_CALC) { |
627 cssCalcValue()->accumulateLengthArray(lengthArray, lengthTypeArray, mult
iplier); | 636 cssCalcValue()->accumulateLengthArray(lengthArray, lengthTypeArray, mult
iplier); |
628 return; | 637 return; |
629 } | 638 } |
630 | 639 |
631 LengthUnitType lengthType; | 640 LengthUnitType lengthType; |
632 if (unitTypeToLengthUnitType(static_cast<UnitType>(m_primitiveUnitType), len
gthType)) { | 641 if (unitTypeToLengthUnitType(type(), lengthType)) { |
633 lengthArray.at(lengthType) += m_value.num * conversionToCanonicalUnitsSc
aleFactor(static_cast<UnitType>(m_primitiveUnitType)) * multiplier; | 642 lengthArray.at(lengthType) += value().num * conversionToCanonicalUnitsSc
aleFactor(type()) * multiplier; |
634 lengthTypeArray.set(lengthType); | 643 lengthTypeArray.set(lengthType); |
635 } | 644 } |
636 } | 645 } |
637 | 646 |
638 void CSSPrimitiveValue::accumulateLengthArray(CSSLengthArray& lengthArray, doubl
e multiplier) const | 647 void CSSPrimitiveValue::accumulateLengthArray(CSSLengthArray& lengthArray, doubl
e multiplier) const |
639 { | 648 { |
640 CSSLengthTypeArray lengthTypeArray; | 649 CSSLengthTypeArray lengthTypeArray; |
641 lengthTypeArray.resize(CSSPrimitiveValue::LengthUnitTypeCount); | 650 lengthTypeArray.resize(CSSPrimitiveValue::LengthUnitTypeCount); |
642 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; ++i) | 651 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; ++i) |
643 lengthTypeArray.clear(i); | 652 lengthTypeArray.clear(i); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 if (isLength()) | 710 if (isLength()) |
702 return computeLength<Length>(conversionData); | 711 return computeLength<Length>(conversionData); |
703 if (isPercentage()) | 712 if (isPercentage()) |
704 return Length(getDoubleValue(), Percent); | 713 return Length(getDoubleValue(), Percent); |
705 ASSERT(isCalculated()); | 714 ASSERT(isCalculated()); |
706 return Length(cssCalcValue()->toCalcValue(conversionData)); | 715 return Length(cssCalcValue()->toCalcValue(conversionData)); |
707 } | 716 } |
708 | 717 |
709 double CSSPrimitiveValue::getDoubleValue() const | 718 double CSSPrimitiveValue::getDoubleValue() const |
710 { | 719 { |
711 return m_primitiveUnitType != CSS_CALC ? m_value.num : m_value.calc->doubleV
alue(); | 720 return type() != CSS_CALC ? value().num : value().calc->doubleValue(); |
712 } | 721 } |
713 | 722 |
714 CSSPrimitiveValue::UnitType CSSPrimitiveValue::canonicalUnitTypeForCategory(Unit
Category category) | 723 CSSPrimitiveValue::UnitType CSSPrimitiveValue::canonicalUnitTypeForCategory(Unit
Category category) |
715 { | 724 { |
716 // The canonical unit type is chosen according to the way CSSPropertyParser:
:validUnit() chooses the default unit | 725 // The canonical unit type is chosen according to the way CSSPropertyParser:
:validUnit() chooses the default unit |
717 // in each category (based on unitflags). | 726 // in each category (based on unitflags). |
718 switch (category) { | 727 switch (category) { |
719 case UNumber: | 728 case UNumber: |
720 return CSS_NUMBER; | 729 return CSS_NUMBER; |
721 case ULength: | 730 case ULength: |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 return CSSPrimitiveValue::CSS_VMAX; | 812 return CSSPrimitiveValue::CSS_VMAX; |
804 case LengthUnitTypeCount: | 813 case LengthUnitTypeCount: |
805 break; | 814 break; |
806 } | 815 } |
807 ASSERT_NOT_REACHED(); | 816 ASSERT_NOT_REACHED(); |
808 return CSSPrimitiveValue::CSS_UNKNOWN; | 817 return CSSPrimitiveValue::CSS_UNKNOWN; |
809 } | 818 } |
810 | 819 |
811 String CSSPrimitiveValue::getStringValue() const | 820 String CSSPrimitiveValue::getStringValue() const |
812 { | 821 { |
813 switch (m_primitiveUnitType) { | 822 switch (type()) { |
814 case CSS_CUSTOM_IDENT: | 823 case CSS_CUSTOM_IDENT: |
815 case CSS_STRING: | 824 case CSS_STRING: |
816 case CSS_ATTR: | 825 case CSS_ATTR: |
817 case CSS_URI: | 826 case CSS_URI: |
818 return m_value.string; | 827 return value().string; |
819 case CSS_VALUE_ID: | 828 case CSS_VALUE_ID: |
820 return valueName(m_value.valueID); | 829 return valueName(value().valueID); |
821 case CSS_PROPERTY_ID: | 830 case CSS_PROPERTY_ID: |
822 return propertyName(m_value.propertyID); | 831 return propertyName(value().propertyID); |
823 default: | 832 default: |
824 break; | 833 break; |
825 } | 834 } |
826 | 835 |
827 return String(); | 836 return String(); |
828 } | 837 } |
829 | 838 |
830 static String formatNumber(double number, const char* suffix, unsigned suffixLen
gth) | 839 static String formatNumber(double number, const char* suffix, unsigned suffixLen
gth) |
831 { | 840 { |
832 #if OS(WIN) && _MSC_VER < 1900 | 841 #if OS(WIN) && _MSC_VER < 1900 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 case CSS_CALC_PERCENTAGE_WITH_LENGTH: | 939 case CSS_CALC_PERCENTAGE_WITH_LENGTH: |
931 case CSS_QEM: | 940 case CSS_QEM: |
932 break; | 941 break; |
933 }; | 942 }; |
934 ASSERT_NOT_REACHED(); | 943 ASSERT_NOT_REACHED(); |
935 return ""; | 944 return ""; |
936 } | 945 } |
937 | 946 |
938 String CSSPrimitiveValue::customCSSText() const | 947 String CSSPrimitiveValue::customCSSText() const |
939 { | 948 { |
940 if (m_hasCachedCSSText) { | 949 if (hasCachedCSSText()) { |
941 ASSERT(cssTextCache().contains(this)); | 950 ASSERT(cssTextCache().contains(m_rawValue)); |
942 return cssTextCache().get(this); | 951 return cssTextCache().get(m_rawValue); |
943 } | 952 } |
944 | 953 |
945 String text; | 954 String text; |
946 switch (m_primitiveUnitType) { | 955 switch (type()) { |
947 case CSS_UNKNOWN: | 956 case CSS_UNKNOWN: |
948 // FIXME | 957 // FIXME |
949 break; | 958 break; |
950 case CSS_INTEGER: | 959 case CSS_INTEGER: |
951 text = String::format("%d", getIntValue()); | 960 text = String::format("%d", getIntValue()); |
952 break; | 961 break; |
953 case CSS_NUMBER: | 962 case CSS_NUMBER: |
954 case CSS_PERCENTAGE: | 963 case CSS_PERCENTAGE: |
955 case CSS_EMS: | 964 case CSS_EMS: |
956 case CSS_EXS: | 965 case CSS_EXS: |
(...skipping 14 matching lines...) Expand all Loading... |
971 case CSS_MS: | 980 case CSS_MS: |
972 case CSS_S: | 981 case CSS_S: |
973 case CSS_HZ: | 982 case CSS_HZ: |
974 case CSS_KHZ: | 983 case CSS_KHZ: |
975 case CSS_TURN: | 984 case CSS_TURN: |
976 case CSS_FR: | 985 case CSS_FR: |
977 case CSS_VW: | 986 case CSS_VW: |
978 case CSS_VH: | 987 case CSS_VH: |
979 case CSS_VMIN: | 988 case CSS_VMIN: |
980 case CSS_VMAX: | 989 case CSS_VMAX: |
981 text = formatNumber(m_value.num, unitTypeToString((UnitType)m_primit
iveUnitType)); | 990 text = formatNumber(value().num, unitTypeToString((UnitType)type()))
; |
982 break; | 991 break; |
983 case CSS_CUSTOM_IDENT: | 992 case CSS_CUSTOM_IDENT: |
984 text = quoteCSSStringIfNeeded(m_value.string); | 993 text = quoteCSSStringIfNeeded(value().string); |
985 break; | 994 break; |
986 case CSS_STRING: { | 995 case CSS_STRING: { |
987 text = serializeString(m_value.string); | 996 text = serializeString(value().string); |
988 break; | 997 break; |
989 } | 998 } |
990 case CSS_URI: | 999 case CSS_URI: |
991 text = "url(" + quoteCSSURLIfNeeded(m_value.string) + ")"; | 1000 text = "url(" + quoteCSSURLIfNeeded(value().string) + ")"; |
992 break; | 1001 break; |
993 case CSS_VALUE_ID: | 1002 case CSS_VALUE_ID: |
994 text = valueName(m_value.valueID); | 1003 text = valueName(value().valueID); |
995 break; | 1004 break; |
996 case CSS_PROPERTY_ID: | 1005 case CSS_PROPERTY_ID: |
997 text = propertyName(m_value.propertyID); | 1006 text = propertyName(value().propertyID); |
998 break; | 1007 break; |
999 case CSS_ATTR: { | 1008 case CSS_ATTR: { |
1000 StringBuilder result; | 1009 StringBuilder result; |
1001 result.reserveCapacity(6 + m_value.string->length()); | 1010 result.reserveCapacity(6 + value().string->length()); |
1002 result.appendLiteral("attr("); | 1011 result.appendLiteral("attr("); |
1003 result.append(m_value.string); | 1012 result.append(value().string); |
1004 result.append(')'); | 1013 result.append(')'); |
1005 | 1014 |
1006 text = result.toString(); | 1015 text = result.toString(); |
1007 break; | 1016 break; |
1008 } | 1017 } |
1009 case CSS_COUNTER: { | 1018 case CSS_COUNTER: { |
1010 StringBuilder result; | 1019 StringBuilder result; |
1011 String separator = m_value.counter->separator(); | 1020 String separator = value().counter->separator(); |
1012 if (separator.isEmpty()) | 1021 if (separator.isEmpty()) |
1013 result.appendLiteral("counter("); | 1022 result.appendLiteral("counter("); |
1014 else | 1023 else |
1015 result.appendLiteral("counters("); | 1024 result.appendLiteral("counters("); |
1016 | 1025 |
1017 result.append(m_value.counter->identifier()); | 1026 result.append(value().counter->identifier()); |
1018 if (!separator.isEmpty()) { | 1027 if (!separator.isEmpty()) { |
1019 result.appendLiteral(", "); | 1028 result.appendLiteral(", "); |
1020 result.append(serializeString(separator)); | 1029 result.append(serializeString(separator)); |
1021 } | 1030 } |
1022 String listStyle = m_value.counter->listStyle(); | 1031 String listStyle = value().counter->listStyle(); |
1023 bool isDefaultListStyle = m_value.counter->listStyleIdent() == CSSVa
lueDecimal; | 1032 bool isDefaultListStyle = value().counter->listStyleIdent() == CSSVa
lueDecimal; |
1024 if (!listStyle.isEmpty() && !isDefaultListStyle) { | 1033 if (!listStyle.isEmpty() && !isDefaultListStyle) { |
1025 result.appendLiteral(", "); | 1034 result.appendLiteral(", "); |
1026 result.append(listStyle); | 1035 result.append(listStyle); |
1027 } | 1036 } |
1028 result.append(')'); | 1037 result.append(')'); |
1029 | 1038 |
1030 text = result.toString(); | 1039 text = result.toString(); |
1031 break; | 1040 break; |
1032 } | 1041 } |
1033 case CSS_RECT: | 1042 case CSS_RECT: |
1034 text = getRectValue()->cssText(); | 1043 text = getRectValue()->cssText(); |
1035 break; | 1044 break; |
1036 case CSS_QUAD: | 1045 case CSS_QUAD: |
1037 text = getQuadValue()->cssText(); | 1046 text = getQuadValue()->cssText(); |
1038 break; | 1047 break; |
1039 case CSS_RGBCOLOR: { | 1048 case CSS_RGBCOLOR: { |
1040 text = Color(m_value.rgbcolor).serializedAsCSSComponentValue(); | 1049 text = Color(value().rgbcolor).serializedAsCSSComponentValue(); |
1041 break; | 1050 break; |
1042 } | 1051 } |
1043 case CSS_PAIR: | 1052 case CSS_PAIR: |
1044 text = getPairValue()->cssText(); | 1053 text = getPairValue()->cssText(); |
1045 break; | 1054 break; |
1046 case CSS_CALC: | 1055 case CSS_CALC: |
1047 text = m_value.calc->cssText(); | 1056 text = value().calc->cssText(); |
1048 break; | 1057 break; |
1049 case CSS_SHAPE: | 1058 case CSS_SHAPE: |
1050 text = m_value.shape->cssText(); | 1059 text = value().shape->cssText(); |
| 1060 break; |
| 1061 default: |
1051 break; | 1062 break; |
1052 } | 1063 } |
1053 | 1064 |
1054 ASSERT(!cssTextCache().contains(this)); | 1065 ASSERT(!cssTextCache().contains(m_rawValue)); |
1055 cssTextCache().set(this, text); | 1066 cssTextCache().set(m_rawValue, text); |
1056 m_hasCachedCSSText = true; | 1067 setHasCachedCSSText(true); |
1057 return text; | 1068 return text; |
1058 } | 1069 } |
1059 | 1070 |
1060 bool CSSPrimitiveValue::equals(const CSSPrimitiveValue& other) const | 1071 bool CSSPrimitiveValue::equals(const CSSPrimitiveValue other) const |
1061 { | 1072 { |
1062 if (m_primitiveUnitType != other.m_primitiveUnitType) | 1073 if (type() != other.type()) |
1063 return false; | 1074 return false; |
1064 | 1075 |
1065 switch (m_primitiveUnitType) { | 1076 switch (type()) { |
1066 case CSS_UNKNOWN: | 1077 case CSS_UNKNOWN: |
1067 return false; | 1078 return false; |
1068 case CSS_NUMBER: | 1079 case CSS_NUMBER: |
1069 case CSS_PERCENTAGE: | 1080 case CSS_PERCENTAGE: |
1070 case CSS_EMS: | 1081 case CSS_EMS: |
1071 case CSS_EXS: | 1082 case CSS_EXS: |
1072 case CSS_REMS: | 1083 case CSS_REMS: |
1073 case CSS_PX: | 1084 case CSS_PX: |
1074 case CSS_CM: | 1085 case CSS_CM: |
1075 case CSS_DPPX: | 1086 case CSS_DPPX: |
1076 case CSS_DPI: | 1087 case CSS_DPI: |
1077 case CSS_DPCM: | 1088 case CSS_DPCM: |
1078 case CSS_MM: | 1089 case CSS_MM: |
1079 case CSS_IN: | 1090 case CSS_IN: |
1080 case CSS_PT: | 1091 case CSS_PT: |
1081 case CSS_PC: | 1092 case CSS_PC: |
1082 case CSS_DEG: | 1093 case CSS_DEG: |
1083 case CSS_RAD: | 1094 case CSS_RAD: |
1084 case CSS_GRAD: | 1095 case CSS_GRAD: |
1085 case CSS_MS: | 1096 case CSS_MS: |
1086 case CSS_S: | 1097 case CSS_S: |
1087 case CSS_HZ: | 1098 case CSS_HZ: |
1088 case CSS_KHZ: | 1099 case CSS_KHZ: |
1089 case CSS_TURN: | 1100 case CSS_TURN: |
1090 case CSS_VW: | 1101 case CSS_VW: |
1091 case CSS_VH: | 1102 case CSS_VH: |
1092 case CSS_VMIN: | 1103 case CSS_VMIN: |
1093 case CSS_VMAX: | 1104 case CSS_VMAX: |
1094 case CSS_FR: | 1105 case CSS_FR: |
1095 return m_value.num == other.m_value.num; | 1106 return value().num == other.value().num; |
1096 case CSS_PROPERTY_ID: | 1107 case CSS_PROPERTY_ID: |
1097 return m_value.propertyID == other.m_value.propertyID; | 1108 return value().propertyID == other.value().propertyID; |
1098 case CSS_VALUE_ID: | 1109 case CSS_VALUE_ID: |
1099 return m_value.valueID == other.m_value.valueID; | 1110 return value().valueID == other.value().valueID; |
1100 case CSS_CUSTOM_IDENT: | 1111 case CSS_CUSTOM_IDENT: |
1101 case CSS_STRING: | 1112 case CSS_STRING: |
1102 case CSS_URI: | 1113 case CSS_URI: |
1103 case CSS_ATTR: | 1114 case CSS_ATTR: |
1104 return equal(m_value.string, other.m_value.string); | 1115 return equal(value().string, other.value().string); |
1105 case CSS_COUNTER: | 1116 case CSS_COUNTER: |
1106 return m_value.counter && other.m_value.counter && m_value.counter->equa
ls(*other.m_value.counter); | 1117 return value().counter && other.value().counter && value().counter->equa
ls(*other.value().counter); |
1107 case CSS_RECT: | 1118 case CSS_RECT: |
1108 return m_value.rect && other.m_value.rect && m_value.rect->equals(*other
.m_value.rect); | 1119 return value().rect && other.value().rect && value().rect->equals(*other
.value().rect); |
1109 case CSS_QUAD: | 1120 case CSS_QUAD: |
1110 return m_value.quad && other.m_value.quad && m_value.quad->equals(*other
.m_value.quad); | 1121 return value().quad && other.value().quad && value().quad->equals(*other
.value().quad); |
1111 case CSS_RGBCOLOR: | 1122 case CSS_RGBCOLOR: |
1112 return m_value.rgbcolor == other.m_value.rgbcolor; | 1123 return value().rgbcolor == other.value().rgbcolor; |
1113 case CSS_PAIR: | 1124 case CSS_PAIR: |
1114 return m_value.pair && other.m_value.pair && m_value.pair->equals(*other
.m_value.pair); | 1125 return value().pair && other.value().pair && value().pair->equals(*other
.value().pair); |
1115 case CSS_CALC: | 1126 case CSS_CALC: |
1116 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other
.m_value.calc); | 1127 return value().calc && other.value().calc && value().calc->equals(*other
.value().calc); |
1117 case CSS_SHAPE: | 1128 case CSS_SHAPE: |
1118 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot
her.m_value.shape); | 1129 return value().shape && other.value().shape && value().shape->equals(*ot
her.value().shape); |
| 1130 default: |
| 1131 break; |
1119 } | 1132 } |
1120 return false; | 1133 return false; |
1121 } | 1134 } |
1122 | 1135 |
1123 DEFINE_TRACE_AFTER_DISPATCH(CSSPrimitiveValue) | 1136 DEFINE_TRACE_AFTER_DISPATCH(CSSPrimitiveValue::CSSLargePrimitiveValue) |
1124 { | 1137 { |
1125 #if ENABLE(OILPAN) | 1138 #if ENABLE(OILPAN) |
1126 switch (m_primitiveUnitType) { | 1139 switch (m_primitiveUnitType) { |
1127 case CSS_COUNTER: | 1140 case CSS_COUNTER: |
1128 visitor->trace(m_value.counter); | 1141 visitor->trace(m_value.counter); |
1129 break; | 1142 break; |
1130 case CSS_RECT: | 1143 case CSS_RECT: |
1131 visitor->trace(m_value.rect); | 1144 visitor->trace(m_value.rect); |
1132 break; | 1145 break; |
1133 case CSS_QUAD: | 1146 case CSS_QUAD: |
1134 visitor->trace(m_value.quad); | 1147 visitor->trace(m_value.quad); |
1135 break; | 1148 break; |
1136 case CSS_PAIR: | 1149 case CSS_PAIR: |
1137 visitor->trace(m_value.pair); | 1150 visitor->trace(m_value.pair); |
1138 break; | 1151 break; |
1139 case CSS_CALC: | 1152 case CSS_CALC: |
1140 visitor->trace(m_value.calc); | 1153 visitor->trace(m_value.calc); |
1141 break; | 1154 break; |
1142 case CSS_SHAPE: | 1155 case CSS_SHAPE: |
1143 visitor->trace(m_value.shape); | 1156 visitor->trace(m_value.shape); |
1144 break; | 1157 break; |
1145 default: | 1158 default: |
1146 break; | 1159 break; |
1147 } | 1160 } |
1148 #endif | 1161 #endif |
1149 CSSValueObject::traceAfterDispatch(visitor); | 1162 CSSValueObject::traceAfterDispatch(visitor); |
1150 } | 1163 } |
1151 | 1164 |
1152 } // namespace blink | 1165 } // namespace blink |
OLD | NEW |