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

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: Added comments and made code neater Created 4 years, 1 month 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..99a2b578421ad334d71bdb59fc7908b1e77bcef8
--- /dev/null
+++ b/third_party/WebKit/Source/core/css/properties/CSSPropertyDescriptor.cpp
@@ -0,0 +1,59 @@
+// 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/CSSPropertyNames.h"
+#include "core/css/properties/CSSPaddingProperties.h"
+
+namespace blink {
+
+namespace {
+
+CSSPropertyDescriptor getInvalidDescriptor() {
+ CSSPropertyDescriptor a;
+ a.isValidProperty = false;
+ return a;
+}
+}
+
+static CSSPropertyDescriptor cssPropertyDescriptors[lastUnresolvedCSSProperty];
+
+static void registerDescriptors() {
+ // Static isCalled flag is used to sure that the descriptors are only created
+ // once
+ static bool isCalled = false;
+ if (isCalled)
+ return;
+ isCalled = true;
+
+ // cssPropertyDescriptors will hold an invalid descriptor for all elements
+ // which haven't been implemented yet
+ for (int i = 0; i < lastUnresolvedCSSProperty; i++) {
+ cssPropertyDescriptors[i] = getInvalidDescriptor();
+ }
+
+ // TODO(aazzam): Generate this function
+ CSSPropertyDescriptor::add(getDescriptor<CSSPropertyAPIWebkitPaddingEnd>(),
+ CSSPropertyWebkitPaddingEnd);
+ CSSPropertyDescriptor::add(getDescriptor<CSSPropertyAPIWebkitPaddingStart>(),
+ CSSPropertyWebkitPaddingStart);
+ CSSPropertyDescriptor::add(getDescriptor<CSSPropertyAPIWebkitPaddingBefore>(),
+ CSSPropertyWebkitPaddingBefore);
+ CSSPropertyDescriptor::add(getDescriptor<CSSPropertyAPIWebkitPaddingAfter>(),
+ CSSPropertyWebkitPaddingAfter);
+}
+
+void CSSPropertyDescriptor::add(CSSPropertyDescriptor descriptor,
+ CSSPropertyID id) {
+ DCHECK_GE(id, 0);
+ DCHECK(id < lastUnresolvedCSSProperty);
+ cssPropertyDescriptors[id] = descriptor;
+}
+
+const CSSPropertyDescriptor& CSSPropertyDescriptor::get(CSSPropertyID id) {
+ registerDescriptors();
+ return cssPropertyDescriptors[id];
+}
+}

Powered by Google App Engine
This is Rietveld 408576698