Commit b7b69c39 authored by sashab's avatar sashab Committed by Commit bot

Remove the CSS Properties API

Remove the core/css/properties/ folder, since it's currently dead code.
Will re-add when the Ribbon project starts up again.

This is a revert of crrev.com/1431773002.

BUG=545324

Review-Url: https://codereview.chromium.org/2202453002
Cr-Commit-Position: refs/heads/master@{#408915}
parent a5447abb
......@@ -1425,9 +1425,6 @@
'css/parser/MediaQueryParser.cpp',
'css/parser/SizesAttributeParser.cpp',
'css/parser/SizesCalcParser.cpp',
'css/properties/CSSPropertyDescriptor.h',
'css/properties/CSSPropertyDescriptor.cpp',
'css/properties/CSSPropertyFunctions.h',
'css/resolver/AnimatedStyleBuilder.cpp',
'css/resolver/AnimatedStyleBuilder.h',
'css/resolver/CSSToStyleMap.cpp',
......
// Copyright 2015 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"
namespace blink {
namespace {
// This is the maximum number of properties that can be used at any one time.
const static size_t propertyArraySize = lastCSSProperty + 1;
static CSSPropertyDescriptor cssPropertyDescriptorsById[propertyArraySize];
} // namespace
void CSSPropertyDescriptor::add(CSSPropertyDescriptor descriptor)
{
ASSERT(descriptor.m_id >= 0 && static_cast<size_t>(descriptor.m_id) < propertyArraySize);
ASSERT(descriptor.m_valid);
cssPropertyDescriptorsById[descriptor.m_id] = descriptor;
}
const CSSPropertyDescriptor* CSSPropertyDescriptor::get(CSSPropertyID id)
{
static bool arrayInitialized = false;
if (!arrayInitialized) {
for (size_t i = 0; i < propertyArraySize; ++i)
cssPropertyDescriptorsById[i].m_valid = false;
arrayInitialized = true;
}
if (cssPropertyDescriptorsById[id].m_valid)
return &cssPropertyDescriptorsById[id];
return nullptr;
}
} // namespace blink
// Copyright 2015 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 CSSPropertyDescriptor_h
#define CSSPropertyDescriptor_h
#include "core/css/properties/CSSPropertyFunctions.h"
#include <type_traits>
namespace blink {
/**
* The API for a single, non-shorthand property in the CSS style engine. All properties
* in the style engine must implement this API (see CSSPropertyFunctions).
*
* The API is a complete, stateless representation of all the behaviors of a single
* property (e.g. 'width', 'color'). Calls to property logic are directed through the
* CSSPropertyDescriptor object, which stores resolved function pointers.
*
* To add a new property, create a subclass of CSSPropertyFunctions and implement
* all public static methods. Then, call CSSPropertyDescriptor::create<SubclassName>() to get a
* descriptor for the class, which can be registered with CSSPropertyDescriptor::add().
*
* No property-specific logic should exist in the style engine outside of this class.
*/
class CSSPropertyDescriptor {
STACK_ALLOCATED();
public:
// Given a subclass of CSSPropertyFunctions, creates a CSSPropertyDescriptor from its static methods.
template <class T> static CSSPropertyDescriptor create()
{
static_assert(std::is_base_of<T, CSSPropertyFunctions>::value, "Property must inherit from CSSPropertyFunctions");
ASSERT(T::id != CSSPropertyFunctions::id);
ASSERT(T::parseSingleValue != CSSPropertyFunctions::parseSingleValue);
CSSPropertyDescriptor descriptor;
descriptor.m_valid = true;
descriptor.m_id = T::id();
descriptor.m_parseSingleValue = T::parseSingleValue;
return descriptor;
}
static void add(CSSPropertyDescriptor);
// Returns the property's descriptor, or null if that property does not have an API yet.
// TODO(sashab): Change this to return a const& once all properties have an API.
static const CSSPropertyDescriptor* get(CSSPropertyID);
// Accessors to functions on the property API.
CSSPropertyID id() const { return m_id; }
CSSValue* parseSingleValue(CSSParserTokenRange& range, const CSSParserContext& context) const { return m_parseSingleValue(range, context); }
private:
// Used internally to check whether an array entry is filled or not.
bool m_valid;
CSSPropertyID m_id;
CSSPropertyFunctions::parseSingleValueFunction m_parseSingleValue;
};
} // namespace blink
#endif // CSSPropertyDescriptor_h
// Copyright 2015 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 CSSPropertyFunctions_h
#define CSSPropertyFunctions_h
#include "core/CSSPropertyNames.h"
#include "core/css/CSSValue.h"
#include "wtf/PassRefPtr.h"
namespace blink {
class CSSParserContext;
class CSSParserTokenRange;
// The parent class for all properties that implement the CSSPropertyDescriptor API.
// Contains static function signatures as a reference of what needs to be implemented
// in the child classes.
class CSSPropertyFunctions {
STATIC_ONLY(CSSPropertyFunctions);
public:
static CSSPropertyID id();
// Consumes and parses a single value for this property from by the token range,
// returning the corresponding CSSValue. This function does not check for the end
// of the token range. Returns nullptr if the input is invalid.
static CSSValue* parseSingleValue(CSSParserTokenRange&, const CSSParserContext&);
using parseSingleValueFunction = decltype(&parseSingleValue);
};
} // namespace blink
#endif // CSSPropertyFunctions_h
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment