Chromium Code Reviews| 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. |
| 11 * | 11 * |
| 12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
| 16 * | 16 * |
| 17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
| 18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
| 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 #include "core/css/StylePropertySerializer.h" | 23 #include "core/css/StylePropertySerializer.h" |
| 24 | 24 |
| 25 #include "core/CSSValueKeywords.h" | 25 #include "core/CSSValueKeywords.h" |
| 26 #include "core/StylePropertyShorthand.h" | 26 #include "core/StylePropertyShorthand.h" |
| 27 #include "core/css/CSSCustomPropertyDeclaration.h" | 27 #include "core/css/CSSCustomPropertyDeclaration.h" |
| 28 #include "core/css/CSSPendingSubstitutionValue.h" | 28 #include "core/css/CSSPendingSubstitutionValue.h" |
| 29 #include "core/css/CSSPropertyMetadata.h" | 29 #include "core/css/CSSPropertyMetadata.h" |
| 30 #include "core/css/CSSValuePair.h" | |
| 30 #include "core/css/CSSValuePool.h" | 31 #include "core/css/CSSValuePool.h" |
| 31 #include "wtf/StdLibExtras.h" | 32 #include "wtf/StdLibExtras.h" |
| 32 #include "wtf/text/StringBuilder.h" | 33 #include "wtf/text/StringBuilder.h" |
| 33 #include <bitset> | 34 #include <bitset> |
| 34 | 35 |
| 35 namespace blink { | 36 namespace blink { |
| 36 | 37 |
| 37 StylePropertySerializer::StylePropertySetForSerializer::StylePropertySetForSeria lizer(const StylePropertySet& properties) | 38 StylePropertySerializer::StylePropertySetForSerializer::StylePropertySetForSeria lizer(const StylePropertySet& properties) |
| 38 : m_propertySet(&properties) | 39 : m_propertySet(&properties) |
| 39 , m_allIndex(m_propertySet->findPropertyIndex(CSSPropertyAll)) | 40 , m_allIndex(m_propertySet->findPropertyIndex(CSSPropertyAll)) |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 450 return getShorthandValue(gridGapShorthand()); | 451 return getShorthandValue(gridGapShorthand()); |
| 451 case CSSPropertyFont: | 452 case CSSPropertyFont: |
| 452 return fontValue(); | 453 return fontValue(); |
| 453 case CSSPropertyFontVariant: | 454 case CSSPropertyFontVariant: |
| 454 return fontVariantValue(); | 455 return fontVariantValue(); |
| 455 case CSSPropertyMargin: | 456 case CSSPropertyMargin: |
| 456 return get4Values(marginShorthand()); | 457 return get4Values(marginShorthand()); |
| 457 case CSSPropertyMotion: | 458 case CSSPropertyMotion: |
| 458 return getShorthandValue(motionShorthand()); | 459 return getShorthandValue(motionShorthand()); |
| 459 case CSSPropertyOffset: | 460 case CSSPropertyOffset: |
| 460 return getShorthandValue(offsetShorthand()); | 461 return offsetValue(); |
| 461 case CSSPropertyWebkitMarginCollapse: | 462 case CSSPropertyWebkitMarginCollapse: |
| 462 return getShorthandValue(webkitMarginCollapseShorthand()); | 463 return getShorthandValue(webkitMarginCollapseShorthand()); |
| 463 case CSSPropertyOverflow: | 464 case CSSPropertyOverflow: |
| 464 return getCommonValue(overflowShorthand()); | 465 return getCommonValue(overflowShorthand()); |
| 465 case CSSPropertyPadding: | 466 case CSSPropertyPadding: |
| 466 return get4Values(paddingShorthand()); | 467 return get4Values(paddingShorthand()); |
| 467 case CSSPropertyTransition: | 468 case CSSPropertyTransition: |
| 468 return getLayeredShorthandValue(transitionShorthand()); | 469 return getLayeredShorthandValue(transitionShorthand()); |
| 469 case CSSPropertyListStyle: | 470 case CSSPropertyListStyle: |
| 470 return getShorthandValue(listStyleShorthand()); | 471 return getShorthandValue(listStyleShorthand()); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 539 && val->isPrimitiveValue() | 540 && val->isPrimitiveValue() |
| 540 && toCSSPrimitiveValue(val)->getValueID() == CSSValueNone) { | 541 && toCSSPrimitiveValue(val)->getValueID() == CSSValueNone) { |
| 541 value = "no-common-ligatures no-discretionary-ligatures no-historical-li gatures no-contextual"; | 542 value = "no-common-ligatures no-discretionary-ligatures no-historical-li gatures no-contextual"; |
| 542 } else { | 543 } else { |
| 543 value = m_propertySet.propertyAt(foundPropertyIndex).value()->cssText(); | 544 value = m_propertySet.propertyAt(foundPropertyIndex).value()->cssText(); |
| 544 } | 545 } |
| 545 | 546 |
| 546 result.append(value); | 547 result.append(value); |
| 547 } | 548 } |
| 548 | 549 |
| 550 String StylePropertySerializer::offsetValue() const | |
|
Timothy Loh
2016/09/27 08:17:48
This is going to do the wrong thing when the ancho
Eric Willigers
2016/09/29 03:53:18
Now changed to never read them if not enabled.
| |
| 551 { | |
| 552 int offsetPositionPropertyIndex = m_propertySet.findPropertyIndex(CSSPropert yOffsetPosition); | |
| 553 int offsetPathPropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyOff setPath); | |
| 554 int offsetDistancePropertyIndex = m_propertySet.findPropertyIndex(CSSPropert yOffsetDistance); | |
| 555 int offsetRotationPropertyIndex = m_propertySet.findPropertyIndex(CSSPropert yOffsetRotation); | |
| 556 int offsetAnchorPropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyO ffsetAnchor); | |
| 557 DCHECK_NE(offsetPositionPropertyIndex, -1); | |
| 558 DCHECK_NE(offsetPathPropertyIndex, -1); | |
| 559 DCHECK_NE(offsetDistancePropertyIndex, -1); | |
| 560 DCHECK_NE(offsetRotationPropertyIndex, -1); | |
| 561 DCHECK_NE(offsetAnchorPropertyIndex, -1); | |
| 562 | |
| 563 PropertyValueForSerializer offsetPositionProperty = m_propertySet.propertyAt (offsetPositionPropertyIndex); | |
| 564 PropertyValueForSerializer offsetPathProperty = m_propertySet.propertyAt(off setPathPropertyIndex); | |
| 565 PropertyValueForSerializer offsetDistanceProperty = m_propertySet.propertyAt (offsetDistancePropertyIndex); | |
| 566 PropertyValueForSerializer offsetRotationProperty = m_propertySet.propertyAt (offsetRotationPropertyIndex); | |
| 567 PropertyValueForSerializer offsetAnchorProperty = m_propertySet.propertyAt(o ffsetAnchorPropertyIndex); | |
| 568 | |
| 569 const CSSValue* offsetPositionValue = offsetPositionProperty.value(); | |
|
Timothy Loh
2016/09/27 08:17:48
= m_propertySet.getPropertyCSSValue(CSSPropertyOff
Eric Willigers
2016/09/29 03:53:18
Done.
| |
| 570 const CSSValue* offsetPathValue = offsetPathProperty.value(); | |
| 571 const CSSValue* offsetDistanceValue = offsetDistanceProperty.value(); | |
| 572 const CSSValue* offsetRotationValue = offsetRotationProperty.value(); | |
| 573 const CSSValue* offsetAnchorValue = offsetAnchorProperty.value(); | |
| 574 | |
| 575 StringBuilder result; | |
| 576 if (offsetPositionValue->isValuePair()) { | |
| 577 result.append(offsetPositionValue->cssText()); | |
| 578 result.append(' '); | |
| 579 } | |
| 580 result.append(offsetPathValue->cssText()); | |
| 581 result.append(' '); | |
| 582 result.append(offsetDistanceValue->cssText()); | |
| 583 result.append(' '); | |
| 584 result.append(offsetRotationValue->cssText()); | |
| 585 | |
| 586 bool anchorIsCentre = false; | |
| 587 if (offsetAnchorValue->isValuePair()) { | |
| 588 const CSSValuePair* pair = toCSSValuePair(offsetAnchorValue); | |
| 589 const CSSPrimitiveValue& first = toCSSPrimitiveValue(pair->first()); | |
| 590 const CSSPrimitiveValue& second = toCSSPrimitiveValue(pair->second()); | |
| 591 anchorIsCentre = first.isPercentage() && first.getDoubleValue() == 50 && second.isPercentage() && second.getDoubleValue() == 50; | |
| 592 } | |
| 593 if (!anchorIsCentre) { | |
| 594 result.append('/'); | |
| 595 result.append(offsetAnchorValue->cssText()); | |
| 596 } | |
| 597 return result.toString(); | |
| 598 } | |
| 599 | |
| 549 String StylePropertySerializer::fontValue() const | 600 String StylePropertySerializer::fontValue() const |
| 550 { | 601 { |
| 551 int fontSizePropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyFontS ize); | 602 int fontSizePropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyFontS ize); |
| 552 int fontFamilyPropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyFon tFamily); | 603 int fontFamilyPropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyFon tFamily); |
| 553 int fontVariantCapsPropertyIndex = m_propertySet.findPropertyIndex(CSSProper tyFontVariantCaps); | 604 int fontVariantCapsPropertyIndex = m_propertySet.findPropertyIndex(CSSProper tyFontVariantCaps); |
| 554 int fontVariantLigaturesPropertyIndex = m_propertySet.findPropertyIndex(CSSP ropertyFontVariantLigatures); | 605 int fontVariantLigaturesPropertyIndex = m_propertySet.findPropertyIndex(CSSP ropertyFontVariantLigatures); |
| 555 int fontVariantNumericPropertyIndex = m_propertySet.findPropertyIndex(CSSPro pertyFontVariantNumeric); | 606 int fontVariantNumericPropertyIndex = m_propertySet.findPropertyIndex(CSSPro pertyFontVariantNumeric); |
| 556 DCHECK_NE(fontSizePropertyIndex, -1); | 607 DCHECK_NE(fontSizePropertyIndex, -1); |
| 557 DCHECK_NE(fontFamilyPropertyIndex, -1); | 608 DCHECK_NE(fontFamilyPropertyIndex, -1); |
| 558 DCHECK_NE(fontVariantCapsPropertyIndex, -1); | 609 DCHECK_NE(fontVariantCapsPropertyIndex, -1); |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 870 builder.append(", "); | 921 builder.append(", "); |
| 871 | 922 |
| 872 const CSSValue& xValue = repeatXList ? repeatXList->item(i % repeatXList ->length()) : repeatX; | 923 const CSSValue& xValue = repeatXList ? repeatXList->item(i % repeatXList ->length()) : repeatX; |
| 873 const CSSValue& yValue = repeatYList ? repeatYList->item(i % repeatYList ->length()) : repeatY; | 924 const CSSValue& yValue = repeatYList ? repeatYList->item(i % repeatYList ->length()) : repeatY; |
| 874 appendBackgroundRepeatValue(builder, xValue, yValue); | 925 appendBackgroundRepeatValue(builder, xValue, yValue); |
| 875 } | 926 } |
| 876 return builder.toString(); | 927 return builder.toString(); |
| 877 } | 928 } |
| 878 | 929 |
| 879 } // namespace blink | 930 } // namespace blink |
| OLD | NEW |