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..3a24a835bf5a2712f0460bbd5f53b699b9887c17 |
--- /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; |
alancutter (OOO until 2018)
2016/11/29 06:51:49
Avoid names like "a" as mentioned before.
aazzam
2016/11/30 23:32:53
done
|
+ a.m_isValidProperty = false; |
+ return a; |
+} |
+} |
alancutter (OOO until 2018)
2016/11/29 06:51:50
End braces of namespaces should have a comment wit
aazzam
2016/11/30 23:32:53
done
|
+ |
+static CSSPropertyDescriptor cssPropertyDescriptors[lastUnresolvedCSSProperty]; |
+ |
+static void registerDescriptors() { |
alancutter (OOO until 2018)
2016/11/29 06:51:49
Rename to ensureDescriptorsRegistered().
aazzam
2016/11/30 23:32:53
done
|
+ // Static isCalled flag is used to sure that the descriptors are only created |
+ // once |
alancutter (OOO until 2018)
2016/11/29 06:51:49
Blink style for comments is for sentences to end i
aazzam
2016/11/30 23:32:53
done
|
+ static bool isCalled = false; |
+ if (isCalled) |
+ return; |
+ isCalled = true; |
+ |
+ // cssPropertyDescriptors will hold an invalid descriptor for all elements |
+ // which haven't been implemented yet |
alancutter (OOO until 2018)
2016/11/29 06:51:49
I don't think this comment is necessary.
Comments
aazzam
2016/11/30 23:32:53
done
|
+ for (int i = 0; i < lastUnresolvedCSSProperty; i++) { |
+ cssPropertyDescriptors[i] = getInvalidDescriptor(); |
+ } |
+ |
+ // TODO(aazzam): Generate this function |
alancutter (OOO until 2018)
2016/11/29 06:51:49
I'd extend the TODO to be: Generate this function
aazzam
2016/11/30 23:32:53
done - added the macros
|
+ 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]; |
+} |
+} |