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

Side by Side Diff: Source/core/css/Rect.h

Issue 1304993002: Change Rect and Quad to be CSSValues (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@split_counter_out_attempt_3
Patch Set: Review feedback Created 5 years, 4 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
« no previous file with comments | « Source/core/css/ComputedStyleCSSValueMapping.cpp ('k') | Source/core/css/Rect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
Timothy Loh 2015/08/24 06:41:38 not sure if you actually deleted this file, rietve
2 * Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21 #ifndef Rect_h
22 #define Rect_h
23
24 #include "core/CoreExport.h"
25 #include "core/css/CSSPrimitiveValue.h"
26 #include "wtf/RefPtr.h"
27 #include "wtf/text/StringBuilder.h"
28
29 namespace blink {
30
31 class CORE_EXPORT RectBase : public RefCountedWillBeGarbageCollected<RectBase> {
32 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(RectBase);
33 public:
34 CSSPrimitiveValue* top() const { return m_top.get(); }
35 CSSPrimitiveValue* right() const { return m_right.get(); }
36 CSSPrimitiveValue* bottom() const { return m_bottom.get(); }
37 CSSPrimitiveValue* left() const { return m_left.get(); }
38
39 void setTop(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> top) { m_top = top; }
40 void setRight(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> right) { m_right = r ight; }
41 void setBottom(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> bottom) { m_bottom = bottom; }
42 void setLeft(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> left) { m_left = left ; }
43
44 bool equals(const RectBase& other) const
45 {
46 return compareCSSValuePtr(m_top, other.m_top)
47 && compareCSSValuePtr(m_right, other.m_right)
48 && compareCSSValuePtr(m_left, other.m_left)
49 && compareCSSValuePtr(m_bottom, other.m_bottom);
50 }
51
52 DECLARE_TRACE();
53
54 protected:
55 RectBase() { }
56
57 private:
58 RefPtrWillBeMember<CSSPrimitiveValue> m_top;
59 RefPtrWillBeMember<CSSPrimitiveValue> m_right;
60 RefPtrWillBeMember<CSSPrimitiveValue> m_bottom;
61 RefPtrWillBeMember<CSSPrimitiveValue> m_left;
62 };
63
64 class Rect : public RectBase {
65 public:
66 static PassRefPtrWillBeRawPtr<Rect> create() { return adoptRefWillBeNoop(new Rect); }
67
68 String cssText() const
69 {
70 return generateCSSString(top()->cssText(), right()->cssText(), bottom()- >cssText(), left()->cssText());
71 }
72
73 private:
74 Rect() { }
75 static String generateCSSString(const String& top, const String& right, cons t String& bottom, const String& left)
76 {
77 return "rect(" + top + ' ' + right + ' ' + bottom + ' ' + left + ')';
78 }
79
80 // NOTE: If adding fields to this class please make the RectBase trace
81 // method virtual and add a trace method in this subclass tracing the new
82 // fields.
83 };
84
85 class Quad : public RectBase {
86 public:
87 static PassRefPtrWillBeRawPtr<Quad> create() { return adoptRefWillBeNoop(new Quad); }
88
89 String cssText() const
90 {
91 return generateCSSString(top()->cssText(), right()->cssText(), bottom()- >cssText(), left()->cssText());
92 }
93
94 private:
95 Quad() { }
96 static String generateCSSString(const String& top, const String& right, cons t String& bottom, const String& left)
97 {
98 StringBuilder result;
99 // reserve space for the four strings, plus three space separator charac ters.
100 result.reserveCapacity(top.length() + right.length() + bottom.length() + left.length() + 3);
101 result.append(top);
102 if (right != top || bottom != top || left != top) {
103 result.append(' ');
104 result.append(right);
105 if (bottom != top || right != left) {
106 result.append(' ');
107 result.append(bottom);
108 if (left != right) {
109 result.append(' ');
110 result.append(left);
111 }
112 }
113 }
114 return result.toString();
115 }
116
117 // NOTE: If adding fields to this class please make the RectBase trace
118 // method virtual and add a trace method in this subclass tracing the new
119 // fields.
120 };
121
122 } // namespace blink
123
124 #endif // Rect_h
OLDNEW
« no previous file with comments | « Source/core/css/ComputedStyleCSSValueMapping.cpp ('k') | Source/core/css/Rect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698