Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: trunk/Source/core/css/Pair.h

Issue 23465021: Revert 157745 "Add support for the object-position CSS property." (Closed) Base URL: svn://svn.chromium.org/blink/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 16 matching lines...) Expand all
27 #include "wtf/text/StringBuilder.h" 27 #include "wtf/text/StringBuilder.h"
28 28
29 namespace WebCore { 29 namespace WebCore {
30 30
31 // A primitive value representing a pair. This is useful for properties like bo rder-radius, background-size/position, 31 // A primitive value representing a pair. This is useful for properties like bo rder-radius, background-size/position,
32 // and border-spacing (all of which are space-separated sets of two values). At the moment we are only using it for 32 // and border-spacing (all of which are space-separated sets of two values). At the moment we are only using it for
33 // border-radius and background-size, but (FIXME) border-spacing and background- position could be converted over to use 33 // border-radius and background-size, but (FIXME) border-spacing and background- position could be converted over to use
34 // it (eliminating some extra -webkit- internal properties). 34 // it (eliminating some extra -webkit- internal properties).
35 class Pair : public RefCounted<Pair> { 35 class Pair : public RefCounted<Pair> {
36 public: 36 public:
37 enum IdenticalValuesPolicy { DropIdenticalValues, KeepIdenticalValues };
38
39 static PassRefPtr<Pair> create() 37 static PassRefPtr<Pair> create()
40 { 38 {
41 return adoptRef(new Pair); 39 return adoptRef(new Pair);
42 } 40 }
43 static PassRefPtr<Pair> create(PassRefPtr<CSSPrimitiveValue> first, PassRefP tr<CSSPrimitiveValue> second, IdenticalValuesPolicy identicalValuesPolicy) 41 static PassRefPtr<Pair> create(PassRefPtr<CSSPrimitiveValue> first, PassRefP tr<CSSPrimitiveValue> second)
44 { 42 {
45 return adoptRef(new Pair(first, second, identicalValuesPolicy)); 43 return adoptRef(new Pair(first, second));
46 } 44 }
47 virtual ~Pair() { } 45 virtual ~Pair() { }
48 46
49 CSSPrimitiveValue* first() const { return m_first.get(); } 47 CSSPrimitiveValue* first() const { return m_first.get(); }
50 CSSPrimitiveValue* second() const { return m_second.get(); } 48 CSSPrimitiveValue* second() const { return m_second.get(); }
51 IdenticalValuesPolicy identicalValuesPolicy() const { return m_identicalValu esPolicy; }
52 49
53 void setFirst(PassRefPtr<CSSPrimitiveValue> first) { m_first = first; } 50 void setFirst(PassRefPtr<CSSPrimitiveValue> first) { m_first = first; }
54 void setSecond(PassRefPtr<CSSPrimitiveValue> second) { m_second = second; } 51 void setSecond(PassRefPtr<CSSPrimitiveValue> second) { m_second = second; }
55 void setIdenticalValuesPolicy(IdenticalValuesPolicy identicalValuesPolicy) { m_identicalValuesPolicy = identicalValuesPolicy; }
56 52
57 String cssText() const 53 String cssText() const
58 { 54 {
59 return generateCSSString(first()->cssText(), second()->cssText(), m_iden ticalValuesPolicy); 55
56 return generateCSSString(first()->cssText(), second()->cssText());
60 } 57 }
61 58
62 bool equals(const Pair& other) const 59 bool equals(const Pair& other) const { return compareCSSValuePtr(m_first, ot her.m_first) && compareCSSValuePtr(m_second, other.m_second); }
63 {
64 return compareCSSValuePtr(m_first, other.m_first)
65 && compareCSSValuePtr(m_second, other.m_second)
66 && m_identicalValuesPolicy == other.m_identicalValuesPolicy;
67 }
68 60
69 String serializeResolvingVariables(const HashMap<AtomicString, String>& vari ables) const 61 String serializeResolvingVariables(const HashMap<AtomicString, String>& vari ables) const
70 { 62 {
71 return generateCSSString( 63 return generateCSSString(first()->customSerializeResolvingVariables(vari ables),
72 first()->customSerializeResolvingVariables(variables), 64 second()->customSerializeResolvingVariables(var iables));
73 second()->customSerializeResolvingVariables(variables),
74 m_identicalValuesPolicy);
75 } 65 }
76 66
77 bool hasVariableReference() const { return first()->hasVariableReference() | | second()->hasVariableReference(); } 67 bool hasVariableReference() const { return first()->hasVariableReference() | | second()->hasVariableReference(); }
78 68
79 private: 69 private:
80 Pair() 70 Pair() : m_first(0), m_second(0) { }
81 : m_first(0) 71 Pair(PassRefPtr<CSSPrimitiveValue> first, PassRefPtr<CSSPrimitiveValue> seco nd)
82 , m_second(0) 72 : m_first(first), m_second(second) { }
83 , m_identicalValuesPolicy(DropIdenticalValues) { }
84 73
85 Pair(PassRefPtr<CSSPrimitiveValue> first, PassRefPtr<CSSPrimitiveValue> seco nd, IdenticalValuesPolicy identicalValuesPolicy) 74 static String generateCSSString(const String& first, const String& second)
86 : m_first(first)
87 , m_second(second)
88 , m_identicalValuesPolicy(identicalValuesPolicy) { }
89
90 static String generateCSSString(const String& first, const String& second, I denticalValuesPolicy identicalValuesPolicy)
91 { 75 {
92 if (identicalValuesPolicy == DropIdenticalValues && first == second) 76 if (first == second)
93 return first; 77 return first;
94 return first + ' ' + second; 78 return first + ' ' + second;
95 } 79 }
96 80
97 RefPtr<CSSPrimitiveValue> m_first; 81 RefPtr<CSSPrimitiveValue> m_first;
98 RefPtr<CSSPrimitiveValue> m_second; 82 RefPtr<CSSPrimitiveValue> m_second;
99 IdenticalValuesPolicy m_identicalValuesPolicy;
100 }; 83 };
101 84
102 } // namespace 85 } // namespace
103 86
104 #endif 87 #endif
OLDNEW
« no previous file with comments | « trunk/Source/core/css/CSSPropertyNames.in ('k') | trunk/Source/core/css/resolver/StyleBuilderCustom.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698