| 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 Apple Computer, Inc. | 3 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. |
| 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 19 matching lines...) Expand all Loading... |
| 30 namespace blink { | 30 namespace blink { |
| 31 | 31 |
| 32 // A primitive value representing a pair. This is useful for properties like bo
rder-radius, background-size/position, | 32 // A primitive value representing a pair. This is useful for properties like bo
rder-radius, background-size/position, |
| 33 // and border-spacing (all of which are space-separated sets of two values). At
the moment we are only using it for | 33 // and border-spacing (all of which are space-separated sets of two values). At
the moment we are only using it for |
| 34 // border-radius and background-size, but (FIXME) border-spacing and background-
position could be converted over to use | 34 // border-radius and background-size, but (FIXME) border-spacing and background-
position could be converted over to use |
| 35 // it (eliminating some extra -webkit- internal properties). | 35 // it (eliminating some extra -webkit- internal properties). |
| 36 class CORE_EXPORT Pair final : public RefCountedWillBeGarbageCollectedFinalized<
Pair> { | 36 class CORE_EXPORT Pair final : public RefCountedWillBeGarbageCollectedFinalized<
Pair> { |
| 37 public: | 37 public: |
| 38 enum IdenticalValuesPolicy { DropIdenticalValues, KeepIdenticalValues }; | 38 enum IdenticalValuesPolicy { DropIdenticalValues, KeepIdenticalValues }; |
| 39 | 39 |
| 40 static PassRefPtrWillBeRawPtr<Pair> create(CSSPrimitiveValue first, CSSPrimi
tiveValue second, | 40 static PassRefPtrWillBeRawPtr<Pair> create(const CSSPrimitiveValue& first, c
onst CSSPrimitiveValue& second, |
| 41 IdenticalValuesPolicy identicalValuesPolicy) | 41 IdenticalValuesPolicy identicalValuesPolicy) |
| 42 { | 42 { |
| 43 return adoptRefWillBeNoop(new Pair(first, second, identicalValuesPolicy)
); | 43 return adoptRefWillBeNoop(new Pair(first, second, identicalValuesPolicy)
); |
| 44 } | 44 } |
| 45 | 45 |
| 46 NullableCSSValue first() const { return m_first; } | 46 const CSSPrimitiveValue& first() const { return toCSSPrimitiveValue(m_first)
; } |
| 47 NullableCSSValue second() const { return m_second; } | 47 const CSSPrimitiveValue& second() const { return toCSSPrimitiveValue(m_secon
d); } |
| 48 | 48 |
| 49 String cssText() const | 49 String cssText() const |
| 50 { | 50 { |
| 51 return generateCSSString(first()->cssText(), second()->cssText(), m_iden
ticalValuesPolicy); | 51 return generateCSSString(first().cssText(), second().cssText(), m_identi
calValuesPolicy); |
| 52 } | 52 } |
| 53 | 53 |
| 54 bool equals(const Pair& other) const | 54 bool equals(const Pair& other) const |
| 55 { | 55 { |
| 56 return m_first == other.m_first | 56 return m_first.equals(other.m_first) |
| 57 && m_second == other.m_second | 57 && m_second.equals(other.m_second) |
| 58 && m_identicalValuesPolicy == other.m_identicalValuesPolicy; | 58 && m_identicalValuesPolicy == other.m_identicalValuesPolicy; |
| 59 } | 59 } |
| 60 | 60 |
| 61 DECLARE_TRACE(); | 61 DECLARE_TRACE(); |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 Pair(CSSPrimitiveValue first, CSSPrimitiveValue second, IdenticalValuesPolic
y identicalValuesPolicy) | 64 Pair(const CSSPrimitiveValue& first, const CSSPrimitiveValue& second, Identi
calValuesPolicy identicalValuesPolicy) |
| 65 : m_first(first) | 65 : m_first(first) |
| 66 , m_second(second) | 66 , m_second(second) |
| 67 , m_identicalValuesPolicy(identicalValuesPolicy) { } | 67 , m_identicalValuesPolicy(identicalValuesPolicy) { } |
| 68 | 68 |
| 69 static String generateCSSString(const String& first, const String& second, I
denticalValuesPolicy identicalValuesPolicy) | 69 static String generateCSSString(const String& first, const String& second, I
denticalValuesPolicy identicalValuesPolicy) |
| 70 { | 70 { |
| 71 if (identicalValuesPolicy == DropIdenticalValues && first == second) | 71 if (identicalValuesPolicy == DropIdenticalValues && first == second) |
| 72 return first; | 72 return first; |
| 73 return first + ' ' + second; | 73 return first + ' ' + second; |
| 74 } | 74 } |
| 75 | 75 |
| 76 NullableCSSValue m_first; | 76 CSSValue m_first; |
| 77 NullableCSSValue m_second; | 77 CSSValue m_second; |
| 78 IdenticalValuesPolicy m_identicalValuesPolicy; | 78 IdenticalValuesPolicy m_identicalValuesPolicy; |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 } // namespace | 81 } // namespace |
| 82 | 82 |
| 83 #endif | 83 #endif |
| OLD | NEW |