| 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 15 matching lines...) Expand all Loading... |
| 26 #include "wtf/PassRefPtr.h" | 26 #include "wtf/PassRefPtr.h" |
| 27 #include "wtf/RefCounted.h" | 27 #include "wtf/RefCounted.h" |
| 28 #include "wtf/text/StringBuilder.h" | 28 #include "wtf/text/StringBuilder.h" |
| 29 | 29 |
| 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 RefCountedWillBeGarbageCollected<Pair> { | 36 class CORE_EXPORT Pair final : public RefCounted<Pair> { |
| 37 public: | 37 public: |
| 38 enum IdenticalValuesPolicy { DropIdenticalValues, KeepIdenticalValues }; | 38 enum IdenticalValuesPolicy { DropIdenticalValues, KeepIdenticalValues }; |
| 39 | 39 |
| 40 static PassRefPtrWillBeRawPtr<Pair> create(PassRefPtrWillBeRawPtr<CSSPrimiti
veValue> first, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> second, | 40 static PassRefPtr<Pair> create(PassRefPtr<CSSPrimitiveValue> first, PassRefP
tr<CSSPrimitiveValue> second, |
| 41 IdenticalValuesPolicy identicalValuesPolicy) | 41 IdenticalValuesPolicy identicalValuesPolicy) |
| 42 { | 42 { |
| 43 return adoptRefWillBeNoop(new Pair(first, second, identicalValuesPolicy)
); | 43 return adoptRef(new Pair(first, second, identicalValuesPolicy)); |
| 44 } | 44 } |
| 45 | 45 |
| 46 CSSPrimitiveValue* first() const { return m_first.get(); } | 46 CSSPrimitiveValue* first() const { return m_first.get(); } |
| 47 CSSPrimitiveValue* second() const { return m_second.get(); } | 47 CSSPrimitiveValue* second() const { return m_second.get(); } |
| 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_iden
ticalValuesPolicy); |
| 52 } | 52 } |
| 53 | 53 |
| 54 bool equals(const Pair& other) const | 54 bool equals(const Pair& other) const |
| 55 { | 55 { |
| 56 return compareCSSValuePtr(m_first, other.m_first) | 56 return compareCSSValuePtr(m_first, other.m_first) |
| 57 && compareCSSValuePtr(m_second, other.m_second) | 57 && compareCSSValuePtr(m_second, other.m_second) |
| 58 && m_identicalValuesPolicy == other.m_identicalValuesPolicy; | 58 && m_identicalValuesPolicy == other.m_identicalValuesPolicy; |
| 59 } | 59 } |
| 60 | 60 |
| 61 DECLARE_TRACE(); | |
| 62 | |
| 63 private: | 61 private: |
| 64 Pair(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> first, PassRefPtrWillBeRawPtr
<CSSPrimitiveValue> second, IdenticalValuesPolicy identicalValuesPolicy) | 62 Pair(PassRefPtr<CSSPrimitiveValue> first, PassRefPtr<CSSPrimitiveValue> seco
nd, IdenticalValuesPolicy identicalValuesPolicy) |
| 65 : m_first(first) | 63 : m_first(first) |
| 66 , m_second(second) | 64 , m_second(second) |
| 67 , m_identicalValuesPolicy(identicalValuesPolicy) { } | 65 , m_identicalValuesPolicy(identicalValuesPolicy) { } |
| 68 | 66 |
| 69 static String generateCSSString(const String& first, const String& second, I
denticalValuesPolicy identicalValuesPolicy) | 67 static String generateCSSString(const String& first, const String& second, I
denticalValuesPolicy identicalValuesPolicy) |
| 70 { | 68 { |
| 71 if (identicalValuesPolicy == DropIdenticalValues && first == second) | 69 if (identicalValuesPolicy == DropIdenticalValues && first == second) |
| 72 return first; | 70 return first; |
| 73 return first + ' ' + second; | 71 return first + ' ' + second; |
| 74 } | 72 } |
| 75 | 73 |
| 76 RefPtrWillBeMember<CSSPrimitiveValue> m_first; | 74 RefPtr<CSSPrimitiveValue> m_first; |
| 77 RefPtrWillBeMember<CSSPrimitiveValue> m_second; | 75 RefPtr<CSSPrimitiveValue> m_second; |
| 78 IdenticalValuesPolicy m_identicalValuesPolicy; | 76 IdenticalValuesPolicy m_identicalValuesPolicy; |
| 79 }; | 77 }; |
| 80 | 78 |
| 81 } // namespace | 79 } // namespace |
| 82 | 80 |
| 83 #endif | 81 #endif |
| OLD | NEW |