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, 2009, 2010, 2012 Apple Inc. All r
ights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r
ights reserved. |
4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. | 4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. |
5 * Copyright (C) 2013 Intel Corporation. All rights reserved. | 5 * Copyright (C) 2013 Intel Corporation. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 if (!horizontalValue || !verticalValue) | 471 if (!horizontalValue || !verticalValue) |
472 return String(); | 472 return String(); |
473 | 473 |
474 String horizontalValueCSSText = horizontalValue->cssText(); | 474 String horizontalValueCSSText = horizontalValue->cssText(); |
475 String verticalValueCSSText = verticalValue->cssText(); | 475 String verticalValueCSSText = verticalValue->cssText(); |
476 if (horizontalValueCSSText == verticalValueCSSText) | 476 if (horizontalValueCSSText == verticalValueCSSText) |
477 return horizontalValueCSSText; | 477 return horizontalValueCSSText; |
478 return horizontalValueCSSText + ' ' + verticalValueCSSText; | 478 return horizontalValueCSSText + ' ' + verticalValueCSSText; |
479 } | 479 } |
480 | 480 |
481 void StylePropertySerializer::appendFontLonghandValueIfExplicit(CSSPropertyID pr
opertyID, StringBuilder& result, String& commonValue) const | 481 void StylePropertySerializer::appendFontLonghandValueIfNotNormal(CSSPropertyID p
ropertyID, StringBuilder& result, String& commonValue) const |
482 { | 482 { |
483 int foundPropertyIndex = m_propertySet.findPropertyIndex(propertyID); | 483 int foundPropertyIndex = m_propertySet.findPropertyIndex(propertyID); |
484 if (foundPropertyIndex == -1) | 484 if (foundPropertyIndex == -1) |
485 return; // All longhands must have at least implicit values if "font" is
specified. | 485 return; |
486 | 486 |
487 if (m_propertySet.propertyAt(foundPropertyIndex).isImplicit()) { | 487 const CSSValue* val = m_propertySet.propertyAt(foundPropertyIndex).value(); |
| 488 if (val->isPrimitiveValue() && toCSSPrimitiveValue(val)->getValueID() == CSS
ValueNormal) { |
488 commonValue = String(); | 489 commonValue = String(); |
489 return; | 490 return; |
490 } | 491 } |
491 | 492 |
492 char prefix = '\0'; | 493 char prefix = '\0'; |
493 switch (propertyID) { | 494 switch (propertyID) { |
494 case CSSPropertyFontStyle: | 495 case CSSPropertyFontStyle: |
495 break; // No prefix. | 496 break; // No prefix. |
496 case CSSPropertyFontFamily: | 497 case CSSPropertyFontFamily: |
497 case CSSPropertyFontStretch: | 498 case CSSPropertyFontStretch: |
(...skipping 18 matching lines...) Expand all Loading... |
516 | 517 |
517 String StylePropertySerializer::fontValue() const | 518 String StylePropertySerializer::fontValue() const |
518 { | 519 { |
519 int fontSizePropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyFontS
ize); | 520 int fontSizePropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyFontS
ize); |
520 int fontFamilyPropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyFon
tFamily); | 521 int fontFamilyPropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyFon
tFamily); |
521 if (fontSizePropertyIndex == -1 || fontFamilyPropertyIndex == -1) | 522 if (fontSizePropertyIndex == -1 || fontFamilyPropertyIndex == -1) |
522 return emptyString(); | 523 return emptyString(); |
523 | 524 |
524 PropertyValueForSerializer fontSizeProperty = m_propertySet.propertyAt(fontS
izePropertyIndex); | 525 PropertyValueForSerializer fontSizeProperty = m_propertySet.propertyAt(fontS
izePropertyIndex); |
525 PropertyValueForSerializer fontFamilyProperty = m_propertySet.propertyAt(fon
tFamilyPropertyIndex); | 526 PropertyValueForSerializer fontFamilyProperty = m_propertySet.propertyAt(fon
tFamilyPropertyIndex); |
526 if (fontSizeProperty.isImplicit() || fontFamilyProperty.isImplicit()) | |
527 return emptyString(); | |
528 | 527 |
529 String commonValue = fontSizeProperty.value()->cssText(); | 528 String commonValue = fontSizeProperty.value()->cssText(); |
530 StringBuilder result; | 529 StringBuilder result; |
531 appendFontLonghandValueIfExplicit(CSSPropertyFontStyle, result, commonValue)
; | 530 appendFontLonghandValueIfNotNormal(CSSPropertyFontStyle, result, commonValue
); |
532 appendFontLonghandValueIfExplicit(CSSPropertyFontVariant, result, commonValu
e); | 531 appendFontLonghandValueIfNotNormal(CSSPropertyFontVariant, result, commonVal
ue); |
533 appendFontLonghandValueIfExplicit(CSSPropertyFontWeight, result, commonValue
); | 532 appendFontLonghandValueIfNotNormal(CSSPropertyFontWeight, result, commonValu
e); |
534 appendFontLonghandValueIfExplicit(CSSPropertyFontStretch, result, commonValu
e); | 533 appendFontLonghandValueIfNotNormal(CSSPropertyFontStretch, result, commonVal
ue); |
535 if (!result.isEmpty()) | 534 if (!result.isEmpty()) |
536 result.append(' '); | 535 result.append(' '); |
537 result.append(fontSizeProperty.value()->cssText()); | 536 result.append(fontSizeProperty.value()->cssText()); |
538 appendFontLonghandValueIfExplicit(CSSPropertyLineHeight, result, commonValue
); | 537 appendFontLonghandValueIfNotNormal(CSSPropertyLineHeight, result, commonValu
e); |
539 if (!result.isEmpty()) | 538 if (!result.isEmpty()) |
540 result.append(' '); | 539 result.append(' '); |
541 result.append(fontFamilyProperty.value()->cssText()); | 540 result.append(fontFamilyProperty.value()->cssText()); |
542 if (isInitialOrInherit(commonValue)) | 541 if (isInitialOrInherit(commonValue)) |
543 return commonValue; | 542 return commonValue; |
544 return result.toString(); | 543 return result.toString(); |
545 } | 544 } |
546 | 545 |
547 String StylePropertySerializer::get4Values(const StylePropertyShorthand& shortha
nd) const | 546 String StylePropertySerializer::get4Values(const StylePropertyShorthand& shortha
nd) const |
548 { | 547 { |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 isInitialValue = false; | 963 isInitialValue = false; |
965 if (!value->isInheritedValue()) | 964 if (!value->isInheritedValue()) |
966 isInheritedValue = false; | 965 isInheritedValue = false; |
967 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie
s()[i])) | 966 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie
s()[i])) |
968 return false; | 967 return false; |
969 } | 968 } |
970 return isInitialValue || isInheritedValue; | 969 return isInitialValue || isInheritedValue; |
971 } | 970 } |
972 | 971 |
973 } | 972 } |
OLD | NEW |