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

Unified Diff: third_party/WebKit/Source/core/css/CSSIdentifierValue.cpp

Issue 2346193002: Split CSSPrimitiveValue into CSSPrimitiveValue and CSSIdentifierValue (Closed)
Patch Set: Rebase please work Created 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/CSSIdentifierValue.cpp
diff --git a/third_party/WebKit/Source/core/css/CSSIdentifierValue.cpp b/third_party/WebKit/Source/core/css/CSSIdentifierValue.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..28f8b9331fc8cfee368fdb1919e69aa27b60febc
--- /dev/null
+++ b/third_party/WebKit/Source/core/css/CSSIdentifierValue.cpp
@@ -0,0 +1,88 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/css/CSSIdentifierValue.h"
+
+#include "core/css/CSSMarkup.h"
+#include "core/css/CSSValuePool.h"
+#include "platform/Length.h"
+#include "wtf/text/StringBuilder.h"
+#include "wtf/text/WTFString.h"
+
+namespace blink {
+
+static const AtomicString& valueName(CSSValueID valueID)
+{
+ DCHECK_GE(valueID, 0);
+ DCHECK_LT(valueID, numCSSValueKeywords);
+
+ if (valueID < 0)
+ return nullAtom;
+
+ static AtomicString* keywordStrings = new AtomicString[numCSSValueKeywords]; // Leaked intentionally.
+ AtomicString& keywordString = keywordStrings[valueID];
+ if (keywordString.isNull())
+ keywordString = getValueName(valueID);
+ return keywordString;
+}
+
+CSSIdentifierValue* CSSIdentifierValue::create(CSSValueID valueID)
+{
+ CSSIdentifierValue* cssValue = cssValuePool().identifierCacheValue(valueID);
+ if (!cssValue)
+ cssValue = cssValuePool().setIdentifierCacheValue(valueID, new CSSIdentifierValue(valueID));
+ return cssValue;
+}
+
+String CSSIdentifierValue::customCSSText() const
+{
+ return valueName(m_valueID);
+}
+
+CSSIdentifierValue::CSSIdentifierValue(CSSValueID valueID)
+ : CSSValue(IdentifierClass)
+ , m_valueID(valueID)
+{
+ // TODO(sashab): Add a DCHECK_NE(valueID, CSSValueInvalid) once no code paths
+ // cause this to happen.
+}
+
+CSSIdentifierValue::CSSIdentifierValue(const Length& length)
+ : CSSValue(IdentifierClass)
+{
+ switch (length.type()) {
+ case Auto:
+ m_valueID = CSSValueAuto;
+ break;
+ case MinContent:
+ m_valueID = CSSValueMinContent;
+ break;
+ case MaxContent:
+ m_valueID = CSSValueMaxContent;
+ break;
+ case FillAvailable:
+ m_valueID = CSSValueWebkitFillAvailable;
+ break;
+ case FitContent:
+ m_valueID = CSSValueFitContent;
+ break;
+ case ExtendToZoom:
+ m_valueID = CSSValueInternalExtendToZoom;
+ case Percent:
+ case Fixed:
+ case Calculated:
+ case DeviceWidth:
+ case DeviceHeight:
+ case MaxSizeNone:
+ NOTREACHED();
+ break;
+ }
+}
+
+DEFINE_TRACE_AFTER_DISPATCH(CSSIdentifierValue)
+{
+ CSSValue::traceAfterDispatch(visitor);
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSIdentifierValue.h ('k') | third_party/WebKit/Source/core/css/CSSMatrix.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698