[ribbon] Don't generate CSSProperty.

The CSSProperty class itself has no generated code, hence it does not
make sense that it's "generated".

This CL moves the CSSProperty class to regular files.

The global GetCSSFoo()-functions previously generated at the end of
css_property.h.tmpl are now provided directly by css_property_instances.
This eliminates the "Internal" set of global functions, which it turns out
we don't really need.

(correctly) complained that they did not belong in css_property.h.

Note: Some forward declarations had to be moved, because a presubmit check
Change-Id: I8a66371498013defd02443b47c1954f49f576585
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1506793
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Reviewed-by: Morten Stenshorne <mstensho@chromium.org>
Reviewed-by: Xida Chen <xidachen@chromium.org>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#640696}
diff --git a/third_party/blink/renderer/build/scripts/core/css/properties/make_css_property_base.py b/third_party/blink/renderer/build/scripts/core/css/properties/make_css_property_instances.py
similarity index 82%
rename from third_party/blink/renderer/build/scripts/core/css/properties/make_css_property_base.py
rename to third_party/blink/renderer/build/scripts/core/css/properties/make_css_property_instances.py
index d21cd6c9..dc570b7 100755
--- a/third_party/blink/renderer/build/scripts/core/css/properties/make_css_property_base.py
+++ b/third_party/blink/renderer/build/scripts/core/css/properties/make_css_property_instances.py
@@ -22,10 +22,17 @@
         self._outputs = {
             'css_property_instances.h': self.generate_property_instances_header,
             'css_property_instances.cc':
-                self.generate_property_instances_implementation,
-            'css_property.h': self.generate_resolved_property_header,
-            'css_property.cc': self.generate_resolved_property_implementation,
+                self.generate_property_instances_implementation
         }
+        # These files are no longer generated. If the files are present from
+        # a previous build, we remove them. This avoids accidentally #including
+        # a stale generated header.
+        self._cleanup = set([
+            'css_property.cc',
+            'css_property.h',
+            'css_unresolved_property.cc',
+            'css_unresolved_property.h'
+        ])
 
         self._css_properties = css_properties.CSSProperties(json5_file_paths)
 
@@ -99,22 +106,5 @@
             'last_property_id': self._css_properties.last_property_id
         }
 
-    @template_expander.use_jinja(
-        'core/css/properties/templates/css_property.cc.tmpl')
-    def generate_resolved_property_implementation(self):
-        return {
-            'input_files': self._input_files,
-            'property_classes_by_property_id': self._property_classes_by_id,
-            'last_property_id': self._css_properties.last_property_id
-        }
-
-    @template_expander.use_jinja(
-        'core/css/properties/templates/css_property.h.tmpl')
-    def generate_resolved_property_header(self):
-        return {
-            'input_files': self._input_files,
-            'property_classes_by_property_id': self._property_classes_by_id,
-        }
-
 if __name__ == '__main__':
     json5_generator.Maker(CSSPropertyBaseWriter).main()
diff --git a/third_party/blink/renderer/build/scripts/core/css/properties/make_css_property_subclasses.py b/third_party/blink/renderer/build/scripts/core/css/properties/make_css_property_subclasses.py
index 3899bd6..6f84b47 100755
--- a/third_party/blink/renderer/build/scripts/core/css/properties/make_css_property_subclasses.py
+++ b/third_party/blink/renderer/build/scripts/core/css/properties/make_css_property_subclasses.py
@@ -9,7 +9,7 @@
 import template_expander
 
 from collections import namedtuple
-from make_css_property_base import CSSPropertyBaseWriter
+from make_css_property_instances import CSSPropertyBaseWriter
 
 
 class PropertyMethod(namedtuple('PropertyMethod', 'name,return_type,parameters')):
diff --git a/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property.cc.tmpl b/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property.cc.tmpl
deleted file mode 100644
index ccee755..0000000
--- a/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property.cc.tmpl
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2017 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.
-
-{% from 'templates/macros.tmpl' import source_files_for_generated_file %}
-{{source_files_for_generated_file(template_file, input_files)}}
-// clang-format off
-
-#include "third_party/blink/renderer/core/css/properties/css_property.h"
-
-namespace blink {
-
-const CSSProperty& GetCSSPropertyVariable() {
-  return To<CSSProperty>(GetCSSPropertyVariableInternal());
-}
-{% for property_class_data in property_classes_by_property_id %}
-const CSSProperty& Get{{property_class_data.property_id}}() {
-  return To<CSSProperty>(Get{{property_class_data.property_id}}Internal());
-}
-{% endfor %}
-
-const CSSProperty& CSSProperty::Get(CSSPropertyID id) {
-  DCHECK_NE(id, CSSPropertyInvalid);
-  DCHECK_LE(id, {{last_property_id}}); // last property id
-  return To<CSSProperty>(CSSUnresolvedProperty::GetNonAliasProperty(id));
-}
-
-}  // namespace blink
-
diff --git a/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property.h.tmpl b/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property.h.tmpl
deleted file mode 100644
index 57ab241..0000000
--- a/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property.h.tmpl
+++ /dev/null
@@ -1,184 +0,0 @@
-// Copyright 2017 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.
-
-{% from 'templates/macros.tmpl' import source_files_for_generated_file %}
-{{source_files_for_generated_file(template_file, input_files)}}
-// clang-format off
-
-#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTY_H_
-#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTY_H_
-
-#include "third_party/blink/renderer/core/css/css_property_name.h"
-#include "third_party/blink/renderer/core/css/css_value.h"
-#include "third_party/blink/renderer/core/css/properties/css_unresolved_property.h"
-#include "third_party/blink/renderer/core/css/cssom/cross_thread_keyword_value.h"
-#include "third_party/blink/renderer/core/css/cssom/cross_thread_style_value.h"
-#include "third_party/blink/renderer/core/css/cssom/cross_thread_unit_value.h"
-#include "third_party/blink/renderer/core/css/cssom/cross_thread_unsupported_value.h"
-#include "third_party/blink/renderer/core/css/cssom/css_keyword_value.h"
-#include "third_party/blink/renderer/core/css/cssom/css_unit_value.h"
-#include "third_party/blink/renderer/core/css/cssom/style_value_factory.h"
-#include "third_party/blink/renderer/platform/heap/heap_allocator.h"
-#include "third_party/blink/renderer/platform/text/text_direction.h"
-#include "third_party/blink/renderer/platform/text/writing_mode.h"
-#include "third_party/blink/renderer/platform/wtf/casting.h"
-#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
-
-namespace blink {
-
-class ComputedStyle;
-class CSSParserContext;
-class CSSParserLocalContext;
-class CSSParserTokenRange;
-class LayoutObject;
-class Longhand;
-class Shorthand;
-class SVGComputedStyle;
-class StylePropertyShorthand;
-
-enum PhysicalBoxSide { kTopSide, kRightSide, kBottomSide, kLeftSide };
-
-class CSSProperty : public CSSUnresolvedProperty {
- public:
-  CORE_EXPORT static const CSSProperty& Get(CSSPropertyID);
-
-  // For backwards compatibility when passing around CSSUnresolvedProperty
-  // references. In case we need to call a function that hasn't been converted
-  // to using property classes yet.
-  virtual CSSPropertyID PropertyID() const {
-    NOTREACHED();
-    return CSSPropertyInvalid;
-  }
-  virtual CSSPropertyName GetCSSPropertyName() const {
-    return CSSPropertyName(PropertyID());
-  }
-  bool IDEquals(CSSPropertyID id) const { return PropertyID() == id; }
-  bool IsResolvedProperty() const override { return true; }
-  virtual bool IsInterpolable() const { return false; }
-  virtual bool IsInherited() const { return false; }
-  virtual bool IsCompositableProperty() const { return false; }
-  virtual bool IsRepeated() const { return false; }
-  virtual char RepetitionSeparator() const {
-    NOTREACHED();
-    return 0;
-  }
-  virtual bool IsDescriptor() const { return false; }
-  virtual bool SupportsPercentage() const { return false; }
-  virtual bool IsProperty() const { return true; }
-  virtual bool IsAffectedByAll() const { return IsEnabled() && IsProperty(); }
-  virtual bool IsLayoutDependentProperty() const { return false; }
-  virtual bool IsLayoutDependent(const ComputedStyle* style, LayoutObject* layout_object) const { return false; }
-  virtual bool IsValidForVisitedLink() const { return false; }
-
-  // Properties that do not override this method:
-  // CSSPropertyWebkitFontSizeDelta
-  // CSSPropertyWebkitTextEmphasis
-  // CSSPropertyFontDisplay
-  // CSSPropertySrc
-  // CSSPropertyUnicodeRange
-  // CSSPropertyPage
-  // CSSPropertySize
-  // CSSPropertyWebkitMarginCollapse
-  // CSSPropertyWebkitMask
-  // CSSPropertyWebkitMaskRepeatX
-  // CSSPropertyWebkitMaskRepeatY
-  // CSSPropertyWebkitPerspectiveOriginX
-  // CSSPropertyWebkitPerspectiveOriginY
-  // CSSPropertyWebkitTextStroke
-  // CSSPropertyWebkitTransformOriginX
-  // CSSPropertyWebkitTransformOriginY
-  // CSSPropertyWebkitTransformOriginZ
-  // CSSPropertyMaxZoom
-  // CSSPropertyMinZoom
-  // CSSPropertyOrientation
-  // CSSPropertyUserZoom
-  // CSSPropertyMarker
-  // CSSPropertyAll
-  // CSSPropertyVariable (Variables are retrieved via Get(AtomicString))
-  virtual const CSSValue* CSSValueFromComputedStyleInternal(const ComputedStyle&,
-                                                            const SVGComputedStyle&,
-                                                            const LayoutObject*,
-                                                            Node*,
-                                                            bool allow_visited_style) const { return nullptr; }
-  // FIXME: Resolve computed auto alignment in applyProperty/ComputedStyle and
-  // remove this non-const Node parameter.
-  CORE_EXPORT const CSSValue* CSSValueFromComputedStyle(const ComputedStyle&,
-                                                        const LayoutObject*,
-                                                        Node*,
-                                                        bool allow_visited_style) const;
-  CORE_EXPORT virtual std::unique_ptr<CrossThreadStyleValue>
-    CrossThreadStyleValueFromComputedStyle(const ComputedStyle& computed_style,
-                                            const LayoutObject* layout_object,
-                                            Node* node,
-                                            bool allow_visited_style) const {
-    const CSSValue* css_value = CSSValueFromComputedStyle(
-      computed_style, layout_object, node, allow_visited_style);
-    if (!css_value)
-      return std::make_unique<CrossThreadUnsupportedValue>("");
-    CSSStyleValue* style_value = StyleValueFactory::CssValueToStyleValue(
-      GetCSSPropertyName(), *css_value);
-    if (!style_value)
-      return std::make_unique<CrossThreadUnsupportedValue>("");
-    switch (style_value->GetType()) {
-      case CSSStyleValue::StyleValueType::kKeywordType:
-        return std::make_unique<CrossThreadKeywordValue>(
-            To<CSSKeywordValue>(style_value)->value().IsolatedCopy());
-      case CSSStyleValue::StyleValueType::kUnitType:
-        return std::make_unique<CrossThreadUnitValue>(
-            To<CSSUnitValue>(style_value)->value(),
-            To<CSSUnitValue>(style_value)->GetInternalUnit());
-      default:
-        // Make an isolated copy to ensure that it is safe to pass cross thread.
-        return std::make_unique<CrossThreadUnsupportedValue>(
-            css_value->CssText().IsolatedCopy());
-    }
-  }
-  virtual const CSSProperty& ResolveDirectionAwareProperty(
-      TextDirection,
-      WritingMode) const {
-    return *this;
-  }
-  virtual bool IsShorthand() const { return false; }
-  virtual bool IsLonghand() const { return false; }
-  static void FilterEnabledCSSPropertiesIntoVector(const CSSPropertyID*,
-                                                   size_t length,
-                                                   Vector<const CSSProperty*>&);
-
- protected:
-  constexpr CSSProperty() : CSSUnresolvedProperty() {}
-
-  static const StylePropertyShorthand& BorderDirections();
-  static const CSSProperty& ResolveAfterToPhysicalProperty(
-      TextDirection,
-      WritingMode,
-      const StylePropertyShorthand&);
-  static const CSSProperty& ResolveBeforeToPhysicalProperty(
-      TextDirection,
-      WritingMode,
-      const StylePropertyShorthand&);
-  static const CSSProperty& ResolveEndToPhysicalProperty(
-      TextDirection,
-      WritingMode,
-      const StylePropertyShorthand&);
-  static const CSSProperty& ResolveStartToPhysicalProperty(
-      TextDirection,
-      WritingMode,
-      const StylePropertyShorthand&);
-};
-
-template <>
-struct DowncastTraits<CSSProperty> {
-  static bool AllowFrom(const CSSUnresolvedProperty& unresolved) {
-    return unresolved.IsResolvedProperty();
-  }
-};
-
-CORE_EXPORT const CSSProperty& GetCSSPropertyVariable();
-{% for property_class_data in property_classes_by_property_id %}
-CORE_EXPORT const CSSProperty& Get{{property_class_data.property_id}}();
-{% endfor %}
-
-}  // namespace blink
-
-#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTY_H_
diff --git a/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property_instances.cc.tmpl b/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property_instances.cc.tmpl
index 9b501e104..32e1351 100644
--- a/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property_instances.cc.tmpl
+++ b/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property_instances.cc.tmpl
@@ -31,7 +31,7 @@
 } // namespace
 
 {% for property_class_data in property_classes_by_property_id %}
-const CSSUnresolvedProperty& Get{{property_class_data.property_id}}Internal() {
+const CSSProperty& Get{{property_class_data.property_id}}() {
   return property_{{property_class_data.property_id.lower()}};
 }
 {% endfor %}
diff --git a/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property_instances.h.tmpl b/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property_instances.h.tmpl
index af8a707..d9a6c572 100644
--- a/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property_instances.h.tmpl
+++ b/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property_instances.h.tmpl
@@ -12,12 +12,13 @@
 namespace blink {
 
 class CSSUnresolvedProperty;
+class CSSProperty;
 
 const CSSUnresolvedProperty* GetAliasPropertyInternal(CSSPropertyID);
 const CSSUnresolvedProperty& GetNonAliasPropertyInternal(CSSPropertyID);
 
 {% for property_class_data in property_classes_by_property_id %}
-const CSSUnresolvedProperty& Get{{property_class_data.property_id}}Internal();
+CORE_EXPORT const CSSProperty& Get{{property_class_data.property_id}}();
 {% endfor %}
 
 }  // namespace blink
diff --git a/third_party/blink/renderer/build/scripts/json5_generator.py b/third_party/blink/renderer/build/scripts/json5_generator.py
index 7adff45..5aa6b64 100644
--- a/third_party/blink/renderer/build/scripts/json5_generator.py
+++ b/third_party/blink/renderer/build/scripts/json5_generator.py
@@ -226,6 +226,10 @@
     def __init__(self, json5_files, output_dir):
         self._input_files = copy.copy(json5_files)
         self._outputs = {}  # file_name -> generator
+        # A set of filenames that were formerly generated, but aren't anymore.
+        # Files present in this set will be deleted to prevent erroneous
+        # inclusion of stale generated headers for incremental builds.
+        self._cleanup = set()
         self.gperf_path = None
         if json5_files:
             self.json5_file = Json5File.load_from_files(json5_files,
@@ -258,6 +262,12 @@
         for file_name, generator in self._outputs.items():
             self._write_file_if_changed(output_dir, generator(), file_name)
 
+    def cleanup_files(self, output_dir):
+        for file_name in self._cleanup:
+            path = os.path.join(output_dir, file_name)
+            if os.path.exists(path):
+                os.remove(path)
+
     def set_gperf_path(self, gperf_path):
         self.gperf_path = gperf_path
 
@@ -288,3 +298,4 @@
         writer = self._writer_class(args.files, args.output_dir)
         writer.set_gperf_path(args.gperf)
         writer.write_files(args.output_dir)
+        writer.cleanup_files(args.output_dir)
diff --git a/third_party/blink/renderer/build/scripts/json5_generator_unittest.py b/third_party/blink/renderer/build/scripts/json5_generator_unittest.py
index 888ce91..04f01b9 100644
--- a/third_party/blink/renderer/build/scripts/json5_generator_unittest.py
+++ b/third_party/blink/renderer/build/scripts/json5_generator_unittest.py
@@ -2,12 +2,29 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+import contextlib
 import os
+import shutil
+import tempfile
 import unittest
 
-from json5_generator import Json5File
+from json5_generator import Json5File, Writer
 
 
+@contextlib.contextmanager
+def tmp_dir():
+    tmp = tempfile.mkdtemp(prefix='json5_generator_')
+    try:
+        yield tmp
+    finally:
+        shutil.rmtree(tmp)
+
+
+class CleanupWriter(Writer):
+    def __init__(self, output_dir, cleanup):
+        super(CleanupWriter, self).__init__([], output_dir)
+        self._cleanup = cleanup
+
 class Json5FileTest(unittest.TestCase):
     def path_of_test_file(self, file_name):
         return os.path.join(
@@ -36,5 +53,47 @@
         with self.assertRaises(Exception):
             Json5File.load_from_files([self.path_of_test_file('json5_generator_invalid_key.json5')])
 
+    def test_cleanup_multiple_files(self):
+        with tmp_dir() as tmp:
+            path1 = os.path.join(tmp, 'file1.h')
+            path2 = os.path.join(tmp, 'file2.h')
+
+            with open(path1, 'wb') as f:
+                f.write('File1')
+            with open(path2, 'wb') as f:
+                f.write('File2')
+
+            self.assertTrue(os.path.exists(path1))
+            self.assertTrue(os.path.exists(path2))
+            CleanupWriter(tmp, set(['file1.h', 'file2.h'])).cleanup_files(tmp)
+            self.assertFalse(os.path.exists(path1))
+            self.assertFalse(os.path.exists(path2))
+
+    def test_cleanup_partial_files(self):
+        with tmp_dir() as tmp:
+            path1 = os.path.join(tmp, 'file1.h')
+            path2 = os.path.join(tmp, 'file2.h')
+
+            with open(path1, 'wb') as f:
+                f.write('File1')
+            with open(path2, 'wb') as f:
+                f.write('File2')
+
+            self.assertTrue(os.path.exists(path1))
+            self.assertTrue(os.path.exists(path2))
+            CleanupWriter(tmp, set(['file2.h'])).cleanup_files(tmp)
+            self.assertTrue(os.path.exists(path1))
+            self.assertFalse(os.path.exists(path2))
+
+    def test_cleanup_nonexisting(self):
+        with tmp_dir() as tmp:
+            path1 = os.path.join(tmp, 'file1.h')
+            with open(path1, 'wb') as f:
+                f.write('File1')
+            self.assertTrue(os.path.exists(path1))
+            # Don't throw when trying to clean up something that doesn't exist.
+            CleanupWriter(tmp, set(['file1.h', 'file2.h'])).cleanup_files(tmp)
+            self.assertFalse(os.path.exists(path1))
+
 if __name__ == "__main__":
     unittest.main()
diff --git a/third_party/blink/renderer/core/BUILD.gn b/third_party/blink/renderer/core/BUILD.gn
index 723ed20..06b1c1d0 100644
--- a/third_party/blink/renderer/core/BUILD.gn
+++ b/third_party/blink/renderer/core/BUILD.gn
@@ -505,17 +505,13 @@
   ]
 }
 
-css_properties("make_core_generated_css_property_baseclass") {
-  script = "../build/scripts/core/css/properties/make_css_property_base.py"
+css_properties("make_core_generated_css_property_instances") {
+  script = "../build/scripts/core/css/properties/make_css_property_instances.py"
   other_inputs = [
-    "../build/scripts/core/css/properties/templates/css_property.cc.tmpl",
-    "../build/scripts/core/css/properties/templates/css_property.h.tmpl",
     "../build/scripts/core/css/properties/templates/css_property_instances.cc.tmpl",
     "../build/scripts/core/css/properties/templates/css_property_instances.h.tmpl",
   ]
   outputs = [
-    "$blink_core_output_dir/css/properties/css_property.cc",
-    "$blink_core_output_dir/css/properties/css_property.h",
     "$blink_core_output_dir/css/properties/css_property_instances.cc",
     "$blink_core_output_dir/css/properties/css_property_instances.h",
   ]
@@ -1587,8 +1583,8 @@
   ":make_core_generated_computed_style_initial_values",
   ":make_core_generated_computed_style_base",
   ":make_core_generated_css_longhand_property_classes",
-  ":make_core_generated_css_property_baseclass",
   ":make_core_generated_css_property_names",
+  ":make_core_generated_css_property_instances",
   ":make_core_generated_css_shorthand_property_classes",
   ":make_core_generated_css_value_id_mappings",
   ":make_core_generated_cssom_types",
diff --git a/third_party/blink/renderer/core/css/BUILD.gn b/third_party/blink/renderer/core/css/BUILD.gn
index ed1c405..a99c53d 100644
--- a/third_party/blink/renderer/core/css/BUILD.gn
+++ b/third_party/blink/renderer/core/css/BUILD.gn
@@ -418,6 +418,8 @@
     "properties/computed_style_utils.h",
     "properties/css_parsing_utils.cc",
     "properties/css_parsing_utils.h",
+    "properties/css_property.cc",
+    "properties/css_property.h",
     "properties/css_property_base_custom.cc",
     "properties/css_property_ref.cc",
     "properties/css_property_ref.h",
diff --git a/third_party/blink/renderer/core/css/cssom/paint_worklet_style_property_map_test.cc b/third_party/blink/renderer/core/css/cssom/paint_worklet_style_property_map_test.cc
index dbb4a8f2..71691b43 100644
--- a/third_party/blink/renderer/core/css/cssom/paint_worklet_style_property_map_test.cc
+++ b/third_party/blink/renderer/core/css/cssom/paint_worklet_style_property_map_test.cc
@@ -10,6 +10,8 @@
 #include "testing/gtest/include/gtest/gtest.h"
 #include "third_party/blink/renderer/core/css/css_computed_style_declaration.h"
 #include "third_party/blink/renderer/core/css/css_test_helpers.h"
+#include "third_party/blink/renderer/core/css/cssom/css_keyword_value.h"
+#include "third_party/blink/renderer/core/css/cssom/css_unit_value.h"
 #include "third_party/blink/renderer/core/css/cssom/paint_worklet_input.h"
 #include "third_party/blink/renderer/core/dom/element.h"
 #include "third_party/blink/renderer/core/dom/node_computed_style.h"
diff --git a/third_party/blink/renderer/core/css/properties/css_property.cc b/third_party/blink/renderer/core/css/properties/css_property.cc
new file mode 100644
index 0000000..905f389
--- /dev/null
+++ b/third_party/blink/renderer/core/css/properties/css_property.cc
@@ -0,0 +1,56 @@
+// Copyright 2019 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 "third_party/blink/renderer/core/css/properties/css_property.h"
+
+#include "third_party/blink/renderer/core/css/cssom/cross_thread_keyword_value.h"
+#include "third_party/blink/renderer/core/css/cssom/cross_thread_style_value.h"
+#include "third_party/blink/renderer/core/css/cssom/cross_thread_unit_value.h"
+#include "third_party/blink/renderer/core/css/cssom/cross_thread_unsupported_value.h"
+#include "third_party/blink/renderer/core/css/cssom/css_keyword_value.h"
+#include "third_party/blink/renderer/core/css/cssom/css_unit_value.h"
+#include "third_party/blink/renderer/core/css/cssom/style_value_factory.h"
+
+namespace blink {
+
+const CSSProperty& GetCSSPropertyVariable() {
+  return To<CSSProperty>(GetCSSPropertyVariableInternal());
+}
+
+const CSSProperty& CSSProperty::Get(CSSPropertyID id) {
+  DCHECK_NE(id, CSSPropertyInvalid);
+  DCHECK_LE(id, lastCSSProperty);  // last property id
+  return To<CSSProperty>(CSSUnresolvedProperty::GetNonAliasProperty(id));
+}
+
+std::unique_ptr<CrossThreadStyleValue>
+CSSProperty::CrossThreadStyleValueFromComputedStyle(
+    const ComputedStyle& computed_style,
+    const LayoutObject* layout_object,
+    Node* node,
+    bool allow_visited_style) const {
+  const CSSValue* css_value = CSSValueFromComputedStyle(
+      computed_style, layout_object, node, allow_visited_style);
+  if (!css_value)
+    return std::make_unique<CrossThreadUnsupportedValue>("");
+  CSSStyleValue* style_value =
+      StyleValueFactory::CssValueToStyleValue(GetCSSPropertyName(), *css_value);
+  if (!style_value)
+    return std::make_unique<CrossThreadUnsupportedValue>("");
+  switch (style_value->GetType()) {
+    case CSSStyleValue::StyleValueType::kKeywordType:
+      return std::make_unique<CrossThreadKeywordValue>(
+          To<CSSKeywordValue>(style_value)->value().IsolatedCopy());
+    case CSSStyleValue::StyleValueType::kUnitType:
+      return std::make_unique<CrossThreadUnitValue>(
+          To<CSSUnitValue>(style_value)->value(),
+          To<CSSUnitValue>(style_value)->GetInternalUnit());
+    default:
+      // Make an isolated copy to ensure that it is safe to pass cross thread.
+      return std::make_unique<CrossThreadUnsupportedValue>(
+          css_value->CssText().IsolatedCopy());
+  }
+}
+
+}  // namespace blink
diff --git a/third_party/blink/renderer/core/css/properties/css_property.h b/third_party/blink/renderer/core/css/properties/css_property.h
new file mode 100644
index 0000000..f88fd19
--- /dev/null
+++ b/third_party/blink/renderer/core/css/properties/css_property.h
@@ -0,0 +1,125 @@
+// Copyright 2019 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.
+
+#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTIES_CSS_PROPERTY_H_
+#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTIES_CSS_PROPERTY_H_
+
+#include <memory>
+#include "third_party/blink/renderer/core/css/css_property_name.h"
+#include "third_party/blink/renderer/core/css/css_value.h"
+#include "third_party/blink/renderer/core/css/properties/css_unresolved_property.h"
+#include "third_party/blink/renderer/platform/heap/heap_allocator.h"
+#include "third_party/blink/renderer/platform/text/text_direction.h"
+#include "third_party/blink/renderer/platform/text/writing_mode.h"
+#include "third_party/blink/renderer/platform/wtf/casting.h"
+#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
+
+namespace blink {
+
+class ComputedStyle;
+class CrossThreadStyleValue;
+class LayoutObject;
+class StylePropertyShorthand;
+class SVGComputedStyle;
+
+enum PhysicalBoxSide { kTopSide, kRightSide, kBottomSide, kLeftSide };
+
+class CORE_EXPORT CSSProperty : public CSSUnresolvedProperty {
+ public:
+  static const CSSProperty& Get(CSSPropertyID);
+
+  // For backwards compatibility when passing around CSSUnresolvedProperty
+  // references. In case we need to call a function that hasn't been converted
+  // to using property classes yet.
+  virtual CSSPropertyID PropertyID() const {
+    NOTREACHED();
+    return CSSPropertyInvalid;
+  }
+  virtual CSSPropertyName GetCSSPropertyName() const {
+    return CSSPropertyName(PropertyID());
+  }
+  bool IDEquals(CSSPropertyID id) const { return PropertyID() == id; }
+  bool IsResolvedProperty() const override { return true; }
+  virtual bool IsInterpolable() const { return false; }
+  virtual bool IsInherited() const { return false; }
+  virtual bool IsCompositableProperty() const { return false; }
+  virtual bool IsRepeated() const { return false; }
+  virtual char RepetitionSeparator() const {
+    NOTREACHED();
+    return 0;
+  }
+  virtual bool IsDescriptor() const { return false; }
+  virtual bool SupportsPercentage() const { return false; }
+  virtual bool IsProperty() const { return true; }
+  virtual bool IsAffectedByAll() const { return IsEnabled() && IsProperty(); }
+  virtual bool IsLayoutDependentProperty() const { return false; }
+  virtual bool IsLayoutDependent(const ComputedStyle* style,
+                                 LayoutObject* layout_object) const {
+    return false;
+  }
+  virtual bool IsValidForVisitedLink() const { return false; }
+
+  virtual const CSSValue* CSSValueFromComputedStyleInternal(
+      const ComputedStyle&,
+      const SVGComputedStyle&,
+      const LayoutObject*,
+      Node*,
+      bool allow_visited_style) const {
+    return nullptr;
+  }
+  // TODO: Resolve computed auto alignment in applyProperty/ComputedStyle and
+  // remove this non-const Node parameter.
+  const CSSValue* CSSValueFromComputedStyle(const ComputedStyle&,
+                                            const LayoutObject*,
+                                            Node*,
+                                            bool allow_visited_style) const;
+  virtual std::unique_ptr<CrossThreadStyleValue>
+  CrossThreadStyleValueFromComputedStyle(const ComputedStyle& computed_style,
+                                         const LayoutObject* layout_object,
+                                         Node* node,
+                                         bool allow_visited_style) const;
+  virtual const CSSProperty& ResolveDirectionAwareProperty(TextDirection,
+                                                           WritingMode) const {
+    return *this;
+  }
+  virtual bool IsShorthand() const { return false; }
+  virtual bool IsLonghand() const { return false; }
+  static void FilterEnabledCSSPropertiesIntoVector(const CSSPropertyID*,
+                                                   size_t length,
+                                                   Vector<const CSSProperty*>&);
+
+ protected:
+  constexpr CSSProperty() : CSSUnresolvedProperty() {}
+
+  static const StylePropertyShorthand& BorderDirections();
+  static const CSSProperty& ResolveAfterToPhysicalProperty(
+      TextDirection,
+      WritingMode,
+      const StylePropertyShorthand&);
+  static const CSSProperty& ResolveBeforeToPhysicalProperty(
+      TextDirection,
+      WritingMode,
+      const StylePropertyShorthand&);
+  static const CSSProperty& ResolveEndToPhysicalProperty(
+      TextDirection,
+      WritingMode,
+      const StylePropertyShorthand&);
+  static const CSSProperty& ResolveStartToPhysicalProperty(
+      TextDirection,
+      WritingMode,
+      const StylePropertyShorthand&);
+};
+
+template <>
+struct DowncastTraits<CSSProperty> {
+  static bool AllowFrom(const CSSUnresolvedProperty& unresolved) {
+    return unresolved.IsResolvedProperty();
+  }
+};
+
+CORE_EXPORT const CSSProperty& GetCSSPropertyVariable();
+
+}  // namespace blink
+
+#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTIES_CSS_PROPERTY_H_
diff --git a/third_party/blink/renderer/core/css/properties/longhand.h b/third_party/blink/renderer/core/css/properties/longhand.h
index 52a04325..f24246c 100644
--- a/third_party/blink/renderer/core/css/properties/longhand.h
+++ b/third_party/blink/renderer/core/css/properties/longhand.h
@@ -15,6 +15,9 @@
 
 class CSSValue;
 class StyleResolverState;
+class CSSParserContext;
+class CSSParserLocalContext;
+class CSSParserTokenRange;
 
 class Longhand : public CSSProperty {
  public:
diff --git a/third_party/blink/renderer/core/css/properties/shorthand.h b/third_party/blink/renderer/core/css/properties/shorthand.h
index 89d5580..f867152 100644
--- a/third_party/blink/renderer/core/css/properties/shorthand.h
+++ b/third_party/blink/renderer/core/css/properties/shorthand.h
@@ -10,6 +10,9 @@
 
 namespace blink {
 
+class CSSParserContext;
+class CSSParserLocalContext;
+class CSSParserTokenRange;
 class CSSPropertyValue;
 
 class Shorthand : public CSSProperty {