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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/ComputedStyleCSSValueMapping.cpp ('k') | Source/core/css/Rect.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/Rect.h
diff --git a/Source/core/css/Rect.h b/Source/core/css/Rect.h
index d8190b1293709b31c36dd945e73712e1f670b8fe..19ae8213424a6db617d6b71ea2c49af15b5d1bf2 100644
--- a/Source/core/css/Rect.h
+++ b/Source/core/css/Rect.h
@@ -23,14 +23,25 @@
#include "core/CoreExport.h"
#include "core/css/CSSPrimitiveValue.h"
+#include "core/css/CSSValue.h"
#include "wtf/RefPtr.h"
#include "wtf/text/StringBuilder.h"
namespace blink {
-class CORE_EXPORT RectBase : public RefCountedWillBeGarbageCollected<RectBase> {
- DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(RectBase);
+// TODO rename to CSSQuadValue.
+class CORE_EXPORT CSSQuadValue : public CSSValue {
esprehn 2015/08/21 09:57:15 copy pasta error?
sashab 2015/08/24 01:56:59 Oops, thanks :) This file should be removed.
public:
+ static PassRefPtrWillBeRawPtr<CSSQuadValue> createQuad(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> top, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> right, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> bottom, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> left)
+ {
+ return adoptRefWillBeNoop(new CSSQuadValue(top, right, bottom, left, false));
+ }
+
+ static PassRefPtrWillBeRawPtr<CSSQuadValue> createRect(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> top, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> right, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> bottom, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> left)
+ {
+ return adoptRefWillBeNoop(new CSSQuadValue(top, right, bottom, left, true));
+ }
+
CSSPrimitiveValue* top() const { return m_top.get(); }
CSSPrimitiveValue* right() const { return m_right.get(); }
CSSPrimitiveValue* bottom() const { return m_bottom.get(); }
@@ -41,7 +52,31 @@ public:
void setBottom(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> bottom) { m_bottom = bottom; }
void setLeft(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> left) { m_left = left; }
- bool equals(const RectBase& other) const
+ String customCSSText() const
+ {
+ if (m_serializeAsRect)
+ return "rect(" + top()->cssText() + ' ' + right()->cssText() + ' ' + bottom()->cssText() + ' ' + left()->cssText() + ')';
+
+ StringBuilder result;
+ // reserve space for the four strings, plus three space separator characters.
+ result.reserveCapacity(top().length() + right().length() + bottom().length() + left().length() + 3);
+ result.append(top());
+ if (right() != top() || bottom() != top() || left() != top()) {
+ result.append(' ');
+ result.append(right());
+ if (bottom() != top() || right() != left()) {
+ result.append(' ');
+ result.append(bottom());
+ if (left() != right()) {
+ result.append(' ');
+ result.append(left());
+ }
+ }
+ }
+ return result.toString();
+ }
+
+ bool equals(const CSSQuadValue& other) const
{
return compareCSSValuePtr(m_top, other.m_top)
&& compareCSSValuePtr(m_right, other.m_right)
@@ -52,9 +87,22 @@ public:
DECLARE_TRACE();
protected:
- RectBase() { }
+ CSSQuadValue(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> top, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> right, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> bottom, PassRefPtrWillBeRawPtr<CSSPrimitiveValue> left, bool serializeAsRect)
+ : CSSValue(QuadClass)
+ , m_serializeAsRect(serializeAsRect)
+ , m_top(top)
+ , m_right(right)
+ , m_bottom(bottom)
+ , m_left(left) { }
private:
+ bool m_serializeAsRect;
+
+ static String generateCSSString(const String& top, const String& right, const String& bottom, const String& left)
+ {
+
+ }
+
RefPtrWillBeMember<CSSPrimitiveValue> m_top;
RefPtrWillBeMember<CSSPrimitiveValue> m_right;
RefPtrWillBeMember<CSSPrimitiveValue> m_bottom;
@@ -88,31 +136,12 @@ public:
String cssText() const
{
- return generateCSSString(top()->cssText(), right()->cssText(), bottom()->cssText(), left()->cssText());
+
}
private:
Quad() { }
- static String generateCSSString(const String& top, const String& right, const String& bottom, const String& left)
- {
- StringBuilder result;
- // reserve space for the four strings, plus three space separator characters.
- result.reserveCapacity(top.length() + right.length() + bottom.length() + left.length() + 3);
- result.append(top);
- if (right != top || bottom != top || left != top) {
- result.append(' ');
- result.append(right);
- if (bottom != top || right != left) {
- result.append(' ');
- result.append(bottom);
- if (left != right) {
- result.append(' ');
- result.append(left);
- }
- }
- }
- return result.toString();
- }
+
// NOTE: If adding fields to this class please make the RectBase trace
// method virtual and add a trace method in this subclass tracing the new
« 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