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

Unified Diff: third_party/WebKit/Source/core/css/properties/CSSPropertyDescriptor.cpp

Issue 2533673002: Added CSSPropertyAPI and CSS padding properties which implement this API (Closed)
Patch Set: Fixed comments Created 4 years 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/properties/CSSPropertyDescriptor.cpp
diff --git a/third_party/WebKit/Source/core/css/properties/CSSPropertyDescriptor.cpp b/third_party/WebKit/Source/core/css/properties/CSSPropertyDescriptor.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6d4b6c8f6ed954668ca72adadd22b3ecd1a8258b
--- /dev/null
+++ b/third_party/WebKit/Source/core/css/properties/CSSPropertyDescriptor.cpp
@@ -0,0 +1,53 @@
+// 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/properties/CSSPropertyDescriptor.h"
+
+#include "core/css/properties/CSSPropertyAPIPadding.h"
+
+namespace blink {
+
+// Initialises a CSSPropertyDescriptor. When functions are added to
+// CSSPropertyAPI, also add them to the struct initaliser below.
+#define GET_DESCRIPTOR(X) \
+ { X::parseSingleValue, X::id, true }
+
+// Initialises an invalid CSSPropertyDescriptor. When functions are added to
+// CSSPropertyAPI, add a nullptr to represent their function pointers in the
+// struct initaliser.
+#define GET_INVALID_DESCRIPTOR() \
+ { nullptr, CSSPropertyInvalid, false }
+
+static_assert(std::is_pod<CSSPropertyDescriptor>::value,
+ "CSSPropertyDescriptor should be POD.");
sashab 2016/12/06 23:04:28 Maybe change to "CSSPropertyDescriptor must be a
aazzam 2016/12/07 02:16:42 done :)
+
+static CSSPropertyDescriptor cssPropertyDescriptors[] = {
+ GET_INVALID_DESCRIPTOR(),
+ GET_DESCRIPTOR(CSSPropertyAPIWebkitPaddingEnd),
+ GET_DESCRIPTOR(CSSPropertyAPIWebkitPaddingStart),
+ GET_DESCRIPTOR(CSSPropertyAPIWebkitPaddingBefore),
+ GET_DESCRIPTOR(CSSPropertyAPIWebkitPaddingAfter),
+};
+
+const CSSPropertyDescriptor& CSSPropertyDescriptor::get(CSSPropertyID id) {
+ // TODO(aazzam): We are currently using hard-coded indexes for
+ // cssPropertyDescriptor since we have only implemented a few properties.
+ // Later, generate this switch statement, or alternatively return
+ // cssPropertyDescriptors[id], and generate the cssPropertyDescriptors array
+ // to hold invalid descriptors for methods which haven't been implemented yet.
+ switch (id) {
+ case CSSPropertyWebkitPaddingEnd:
+ return cssPropertyDescriptors[1];
+ case CSSPropertyWebkitPaddingStart:
+ return cssPropertyDescriptors[2];
+ case CSSPropertyWebkitPaddingBefore:
+ return cssPropertyDescriptors[3];
+ case CSSPropertyWebkitPaddingAfter:
+ return cssPropertyDescriptors[4];
+ default:
+ return cssPropertyDescriptors[0];
+ }
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698