Commit 95ec31dd authored by tasak@google.com's avatar tasak@google.com

Make blink classes and structures in core/css fast-allocated

Added STATIC_ONLY, STACK_ALLOCATED, DISALLOW_ALLOCATION, or ALLOW_ONLY_INLINE_ALLOCATION
instead of WTF_MAKE_FAST_ALLOCATED(_WILL_BE_REMOVED) if possible.

BUG=523249

Review URL: https://codereview.chromium.org/1304623002

git-svn-id: svn://svn.chromium.org/blink/trunk@200982 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 297900a7
......@@ -24,6 +24,7 @@
#define CSSDefaultStyleSheets_h
#include "platform/heap/Handle.h"
#include "wtf/Allocator.h"
namespace blink {
......@@ -32,6 +33,8 @@ class RuleSet;
class StyleSheetContents;
class CSSDefaultStyleSheets : public NoBaseWillBeGarbageCollected<CSSDefaultStyleSheets> {
WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(CSSDefaultStyleSheets);
WTF_MAKE_NONCOPYABLE(CSSDefaultStyleSheets);
public:
static CSSDefaultStyleSheets& instance();
......
......@@ -42,6 +42,7 @@ class RemoteFontFaceSource;
class SimpleFontData;
class CORE_EXPORT CSSFontFace final : public NoBaseWillBeGarbageCollectedFinalized<CSSFontFace> {
WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(CSSFontFace);
WTF_MAKE_NONCOPYABLE(CSSFontFace);
public:
struct UnicodeRange;
......@@ -73,6 +74,7 @@ public:
PassRefPtr<SimpleFontData> getFontData(const FontDescription&);
struct UnicodeRange {
ALLOW_ONLY_INLINE_ALLOCATION();
UnicodeRange(UChar32 from, UChar32 to)
: m_from(from)
, m_to(to)
......@@ -91,6 +93,7 @@ public:
};
class CORE_EXPORT UnicodeRangeSet {
ALLOW_ONLY_INLINE_ALLOCATION();
public:
explicit UnicodeRangeSet(const Vector<UnicodeRange>&);
bool contains(UChar32) const;
......
......@@ -27,6 +27,7 @@
#define CSSFontFaceSource_h
#include "platform/heap/Handle.h"
#include "wtf/Allocator.h"
#include "wtf/HashMap.h"
namespace blink {
......@@ -37,6 +38,8 @@ class FontDescription;
class SimpleFontData;
class CSSFontFaceSource : public NoBaseWillBeGarbageCollectedFinalized<CSSFontFaceSource> {
WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(CSSFontFaceSource);
WTF_MAKE_NONCOPYABLE(CSSFontFaceSource);
public:
virtual ~CSSFontFaceSource();
......
......@@ -29,6 +29,7 @@
#include "core/css/CSSValueList.h"
#include "core/fetch/ResourceLoaderOptions.h"
#include "platform/weborigin/Referrer.h"
#include "wtf/Allocator.h"
namespace blink {
......@@ -56,6 +57,7 @@ public:
bool isPending() const { return !m_accessedBestFitImage; }
struct ImageWithScale {
ALLOW_ONLY_INLINE_ALLOCATION();
String imageURL;
Referrer referrer;
float scaleFactor;
......
......@@ -27,12 +27,14 @@
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/text/TextDirection.h"
#include "platform/text/WritingMode.h"
#include "wtf/Allocator.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefPtr.h"
namespace blink {
struct StylePropertyMetadata {
DISALLOW_ALLOCATION();
StylePropertyMetadata(CSSPropertyID propertyID, bool isSetFromShorthand, int indexInShorthandsVector, bool important, bool implicit, bool inherited)
: m_propertyID(propertyID)
, m_isSetFromShorthand(isSetFromShorthand)
......
......@@ -6,10 +6,12 @@
#define CSSPropertyMetadata_h
#include "core/CSSPropertyNames.h"
#include "wtf/Allocator.h"
namespace blink {
class CSSPropertyMetadata {
STATIC_ONLY(CSSPropertyMetadata);
public:
static bool isEnabledProperty(CSSPropertyID);
static bool isInterpolableProperty(CSSPropertyID);
......
......@@ -31,6 +31,7 @@
#define CSSTestHelper_h
#include "core/css/RuleSet.h"
#include "wtf/Allocator.h"
#include "wtf/RefPtr.h"
namespace blink {
......@@ -46,6 +47,7 @@ class CSSStyleSheet;
// ... examine RuleSet to find the rule and test properties on it.
class CSSTestHelper {
STACK_ALLOCATED();
public:
CSSTestHelper();
~CSSTestHelper();
......
......@@ -32,6 +32,7 @@
#define CSSToLengthConversionData_h
#include "core/CoreExport.h"
#include "wtf/Allocator.h"
#include "wtf/Assertions.h"
#include "wtf/MathExtras.h"
#include <limits>
......@@ -43,9 +44,11 @@ class LayoutView;
class Font;
class CORE_EXPORT CSSToLengthConversionData {
DISALLOW_ALLOCATION();
public:
class FontSizes {
DISALLOW_ALLOCATION();
public:
FontSizes() : m_em(0), m_rem(0), m_font(nullptr) { }
FontSizes(float em, float rem, const Font*);
......@@ -62,6 +65,7 @@ public:
};
class ViewportSize {
DISALLOW_ALLOCATION();
public:
ViewportSize() : m_width(0), m_height(0) { }
ViewportSize(double width, double height) : m_width(width), m_height(height) { }
......
......@@ -7,6 +7,7 @@
#include "core/CSSPropertyNames.h"
#include "core/css/CSSValue.h"
#include "wtf/Allocator.h"
namespace blink {
......@@ -19,6 +20,7 @@ class StyleColor;
class Node;
class ComputedStyleCSSValueMapping {
STATIC_ONLY(ComputedStyleCSSValueMapping);
public:
// FIXME: Resolve computed auto alignment in applyProperty/ComputedStyle and remove this non-const styledNode parameter.
static PassRefPtrWillBeRawPtr<CSSValue> get(CSSPropertyID, const ComputedStyle&, const LayoutObject* = nullptr, Node* styledNode = nullptr, bool allowVisitedStyle = false);
......
......@@ -27,6 +27,7 @@
#define DocumentFontFaceSet_h
#include "platform/heap/Handle.h"
#include "wtf/Allocator.h"
#include "wtf/PassRefPtr.h"
namespace blink {
......@@ -35,6 +36,7 @@ class Document;
class FontFaceSet;
class DocumentFontFaceSet {
STATIC_ONLY(DocumentFontFaceSet);
public:
static PassRefPtrWillBeRawPtr<FontFaceSet> fonts(Document&);
};
......
......@@ -34,6 +34,7 @@
#include "core/events/EventTarget.h"
#include "platform/AsyncMethodRunner.h"
#include "platform/RefCountedSupplement.h"
#include "wtf/Allocator.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefCounted.h"
#include "wtf/Vector.h"
......@@ -117,6 +118,7 @@ private:
}
class FontLoadHistogram {
DISALLOW_ALLOCATION();
public:
enum Status { NoWebFonts, HadBlankText, DidNotHaveBlankText, Reported };
FontLoadHistogram() : m_status(NoWebFonts), m_count(0), m_recorded(false) { }
......
......@@ -23,6 +23,7 @@
#define FontSize_h
#include "core/CSSValueKeywords.h"
#include "wtf/Allocator.h"
namespace blink {
......@@ -31,11 +32,7 @@ class Document;
enum ESmartMinimumForFontSize { DoNotUseSmartMinimumForFontSize, UseSmartMinimumForFontFize };
class FontSize {
private:
FontSize()
{
}
STATIC_ONLY(FontSize);
public:
static float getComputedSizeFromSpecifiedSize(const Document*, float zoomFactor, bool isAbsoluteSize, float specifiedSize, ESmartMinimumForFontSize = UseSmartMinimumForFontFize);
......
......@@ -20,14 +20,18 @@
#ifndef HashTools_h
#define HashTools_h
#include "wtf/Allocator.h"
namespace blink {
struct Property {
DISALLOW_ALLOCATION();
int nameOffset;
int id;
};
struct Value {
DISALLOW_ALLOCATION();
int nameOffset;
int id;
};
......
......@@ -6,6 +6,7 @@
#define LocalFontFaceSource_h
#include "core/css/CSSFontFaceSource.h"
#include "wtf/Allocator.h"
#include "wtf/text/AtomicString.h"
namespace blink {
......@@ -20,6 +21,7 @@ private:
PassRefPtr<SimpleFontData> createFontData(const FontDescription&) override;
class LocalFontHistograms {
DISALLOW_ALLOCATION();
public:
LocalFontHistograms() : m_reported(false) { }
void record(bool loadSuccess);
......
......@@ -34,6 +34,7 @@
#include "core/MediaFeatureNames.h"
#include "core/css/CSSPrimitiveValue.h"
#include "core/css/CSSValue.h"
#include "wtf/Allocator.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/RefPtr.h"
......@@ -42,6 +43,7 @@ namespace blink {
class CSSParserToken;
struct MediaQueryExpValue {
DISALLOW_ALLOCATION();
CSSValueID id;
double value;
CSSPrimitiveValue::UnitType unit;
......
......@@ -13,6 +13,7 @@ namespace blink {
class CORE_EXPORT MediaValuesCached final : public MediaValues {
public:
struct MediaValuesCachedData {
DISALLOW_ALLOCATION();
// Members variables must be thread safe, since they're copied to the parser thread
int viewportWidth;
int viewportHeight;
......
......@@ -8,6 +8,7 @@
#include "core/css/CSSFontFaceSource.h"
#include "core/fetch/FontResource.h"
#include "core/fetch/ResourcePtr.h"
#include "wtf/Allocator.h"
namespace blink {
......@@ -42,6 +43,7 @@ protected:
private:
class FontLoadHistograms {
DISALLOW_ALLOCATION();
public:
FontLoadHistograms() : m_loadStartTime(0), m_fallbackPaintTime(0) { }
void loadStarted();
......
......@@ -105,6 +105,7 @@ private:
using PseudoTypeInvalidationSetMap = WillBeHeapHashMap<CSSSelector::PseudoType, RefPtrWillBeMember<DescendantInvalidationSet>, WTF::IntHash<unsigned>, WTF::UnsignedWithZeroKeyHashTraits<unsigned>>;
struct FeatureMetadata {
DISALLOW_ALLOCATION();
FeatureMetadata()
: usesFirstLineRules(false)
, usesWindowInactiveSelector(false)
......@@ -131,6 +132,7 @@ private:
void updateInvalidationSetsForContentAttribute(const RuleData&);
struct InvalidationSetFeatures {
DISALLOW_ALLOCATION();
InvalidationSetFeatures()
: customPseudoElement(false)
, hasBeforeOrAfter(false)
......
......@@ -110,6 +110,7 @@ private:
};
struct SameSizeAsRuleData {
DISALLOW_ALLOCATION();
void* a;
unsigned b;
unsigned c;
......
......@@ -32,10 +32,12 @@
#define StyleColor_h
#include "platform/graphics/Color.h"
#include "wtf/Allocator.h"
namespace blink {
class StyleColor {
DISALLOW_ALLOCATION();
public:
StyleColor(Color color) : m_color(color), m_currentColor(false) { }
static StyleColor currentColor() { return StyleColor(); }
......
......@@ -59,6 +59,7 @@ private:
// NOTE: We put the StyleSheetResourceClient in a member instead of inheriting from it
// to avoid adding a vptr to StyleRuleImport.
class ImportedStyleSheetClient final : public StyleSheetResourceClient {
DISALLOW_ALLOCATION();
public:
ImportedStyleSheetClient(StyleRuleImport* ownerRule) : m_ownerRule(ownerRule) { }
~ImportedStyleSheetClient() override { }
......
......@@ -9,6 +9,7 @@
#include "core/CSSValueKeywords.h"
#include "platform/graphics/Color.h"
#include "platform/heap/Handle.h"
#include "wtf/Allocator.h"
#include "wtf/Forward.h"
namespace blink {
......@@ -16,6 +17,7 @@ namespace blink {
class CSSValue;
class CSSParserFastPaths {
STATIC_ONLY(CSSParserFastPaths);
public:
// Parses simple values like '10px' or 'green', but makes no guarantees
// about handling any property completely.
......
......@@ -6,6 +6,7 @@
#define CSSParserObserverWrapper_h
#include "core/css/parser/CSSParserObserver.h"
#include "wtf/Allocator.h"
namespace blink {
......@@ -42,6 +43,7 @@ private:
CSSParserToken* m_firstParserToken;
struct CommentPosition {
ALLOW_ONLY_INLINE_ALLOCATION();
unsigned startOffset;
unsigned endOffset;
unsigned tokensBefore;
......
......@@ -21,12 +21,14 @@
#ifndef CSSParserString_h
#define CSSParserString_h
#include "wtf/Allocator.h"
#include "wtf/text/AtomicString.h"
#include "wtf/text/WTFString.h"
namespace blink {
struct CSSParserString {
STACK_ALLOCATED();
void init(const LChar* characters, unsigned length)
{
m_data.characters8 = characters;
......
......@@ -8,6 +8,7 @@
#include "core/CoreExport.h"
#include "core/css/CSSPrimitiveValue.h"
#include "core/css/parser/CSSParserString.h"
#include "wtf/Allocator.h"
namespace blink {
......@@ -64,6 +65,7 @@ enum HashTokenType {
};
class CORE_EXPORT CSSParserToken {
WTF_MAKE_FAST_ALLOCATED(CSSParserToken);
public:
enum BlockType {
NotBlock,
......@@ -145,6 +147,7 @@ private:
namespace WTF {
template <>
struct IsTriviallyMoveAssignable<blink::CSSParserToken> {
STATIC_ONLY(IsTriviallyMoveAssignable);
static const bool value = true;
};
}
......
......@@ -7,6 +7,7 @@
#include "core/CoreExport.h"
#include "core/css/parser/CSSParserToken.h"
#include "wtf/Allocator.h"
#include "wtf/Vector.h"
namespace blink {
......@@ -17,6 +18,7 @@ CORE_EXPORT extern const CSSParserToken& staticEOFToken;
// Accessing outside of the range will return an endless stream of EOF tokens.
// This class refers to half-open intervals [first, last).
class CORE_EXPORT CSSParserTokenRange {
DISALLOW_ALLOCATION();
public:
CSSParserTokenRange(const Vector<CSSParserToken>& vector)
: m_first(vector.begin())
......
......@@ -27,6 +27,7 @@
#include "core/css/CSSValueList.h"
#include "core/css/parser/CSSParserString.h"
#include "core/css/parser/CSSParserTokenRange.h"
#include "wtf/Allocator.h"
namespace blink {
......@@ -37,6 +38,7 @@ struct CSSParserCalcFunction;
class CSSParserValueList;
struct CSSParserValue {
ALLOW_ONLY_INLINE_ALLOCATION();
CSSValueID id;
bool isInt;
union {
......
......@@ -8,6 +8,7 @@
#include "core/CoreExport.h"
#include "core/css/parser/CSSParserToken.h"
#include "core/html/parser/InputStreamPreprocessor.h"
#include "wtf/Allocator.h"
#include "wtf/text/WTFString.h"
#include <climits>
......@@ -24,6 +25,7 @@ class CORE_EXPORT CSSTokenizer {
WTF_MAKE_FAST_ALLOCATED(CSSTokenizer);
public:
class CORE_EXPORT Scope {
DISALLOW_ALLOCATION();
public:
Scope(const String&);
Scope(const String&, CSSParserObserverWrapper&); // For the inspector
......
......@@ -6,14 +6,15 @@
#define MediaQueryBlockWatcher_h
#include "core/CoreExport.h"
#include "wtf/Allocator.h"
namespace blink {
class CSSParserToken;
class CORE_EXPORT MediaQueryBlockWatcher {
STACK_ALLOCATED();
public:
MediaQueryBlockWatcher();
void handleToken(const CSSParserToken&);
unsigned blockLevel() const { return m_blockLevel; }
......
......@@ -32,6 +32,7 @@
#define AnimatedStyleBuilder_h
#include "core/CSSPropertyNames.h"
#include "wtf/Allocator.h"
namespace blink {
......@@ -39,6 +40,7 @@ class AnimatableValue;
class StyleResolverState;
class AnimatedStyleBuilder {
STATIC_ONLY(AnimatedStyleBuilder);
public:
static void applyProperty(CSSPropertyID, StyleResolverState&, const AnimatableValue*);
};
......
......@@ -6,6 +6,7 @@
#define CSSPropertyPriority_h
#include "core/CSSPropertyNames.h"
#include "wtf/Allocator.h"
namespace blink {
......@@ -20,6 +21,7 @@ enum CSSPropertyPriority {
template <CSSPropertyPriority priority>
class CSSPropertyPriorityData {
STATIC_ONLY(CSSPropertyPriorityData);
public:
static inline CSSPropertyID first();
static inline CSSPropertyID last();
......
......@@ -27,6 +27,7 @@
#include "core/animation/css/CSSTransitionData.h"
#include "core/style/ComputedStyleConstants.h"
#include "platform/animation/TimingFunction.h"
#include "wtf/Allocator.h"
namespace blink {
......@@ -37,6 +38,7 @@ class NinePieceImage;
class BorderImageLengthBox;
class CSSToStyleMap {
STATIC_ONLY(CSSToStyleMap);
public:
static void mapFillAttachment(StyleResolverState&, FillLayer*, CSSValue*);
static void mapFillClip(StyleResolverState&, FillLayer*, CSSValue*);
......
......@@ -37,7 +37,7 @@ class ComputedStyle;
class StyleResolverState;
class CachedMatchedProperties final : public NoBaseWillBeGarbageCollectedFinalized<CachedMatchedProperties> {
WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(CachedMatchedProperties);
public:
WillBeHeapVector<MatchedProperties> matchedProperties;
RefPtr<ComputedStyle> computedStyle;
......
......@@ -39,6 +39,7 @@
#include "platform/LengthSize.h"
#include "platform/fonts/FontDescription.h"
#include "platform/text/TabSize.h"
#include "wtf/Allocator.h"
namespace blink {
......@@ -48,6 +49,7 @@ class ScaleTransformOperation;
// Note that we assume the parser only allows valid CSSValue types.
class StyleBuilderConverter {
STATIC_ONLY(StyleBuilderConverter);
public:
static PassRefPtr<StyleReflection> convertBoxReflect(StyleResolverState&, CSSValue*);
static AtomicString convertFragmentIdentifier(StyleResolverState&, CSSValue*);
......
......@@ -38,6 +38,7 @@
namespace blink {
class StyleResolverStats {
WTF_MAKE_FAST_ALLOCATED(StyleResolverStats);
public:
static PassOwnPtr<StyleResolverStats> create()
{
......
......@@ -44,6 +44,7 @@ class MutableStylePropertySet;
class StyleRuleViewport;
class CORE_EXPORT ViewportStyleResolver : public NoBaseWillBeGarbageCollected<ViewportStyleResolver> {
WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(ViewportStyleResolver);
DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(ViewportStyleResolver);
public:
static PassOwnPtrWillBeRawPtr<ViewportStyleResolver> create(Document* document)
......
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