#ifndef CSSPropertySourceData_h
#define CSSPropertySourceData_h
#include "heap/Handle.h"
#include "wtf/Forward.h"
#include "wtf/RefCounted.h"
#include "wtf/Vector.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
class StyleRuleBase;
struct SourceRange {
ALLOW_ONLY_INLINE_ALLOCATION();
public:
SourceRange();
SourceRange(unsigned start, unsigned end);
unsigned length() const;
void trace(Visitor*) { }
unsigned start;
unsigned end;
};
struct CSSPropertySourceData {
ALLOW_ONLY_INLINE_ALLOCATION();
public:
CSSPropertySourceData(const String& name, const String& value, bool important, bool disabled, bool parsedOk, const SourceRange& range);
CSSPropertySourceData(const CSSPropertySourceData& other);
CSSPropertySourceData();
String toString() const;
unsigned hash() const;
void trace(Visitor* visitor) { visitor->trace(range); }
String name;
String value;
bool important;
bool disabled;
bool parsedOk;
SourceRange range;
};
struct CSSStyleSourceData : public RefCountedWillBeGarbageCollected<CSSStyleSourceData> {
static PassRefPtrWillBeRawPtr<CSSStyleSourceData> create()
{
return adoptRefWillBeNoop(new CSSStyleSourceData());
}
void trace(Visitor* visitor) { visitor->trace(propertyData); }
WillBeHeapVector<CSSPropertySourceData> propertyData;
};
struct CSSRuleSourceData;
typedef WillBeHeapVector<RefPtrWillBeMember<CSSRuleSourceData> > RuleSourceDataList;
typedef WillBeHeapVector<SourceRange> SelectorRangeList;
struct CSSRuleSourceData : public RefCountedWillBeGarbageCollected<CSSRuleSourceData> {
enum Type {
UNKNOWN_RULE,
STYLE_RULE,
CHARSET_RULE,
IMPORT_RULE,
MEDIA_RULE,
FONT_FACE_RULE,
PAGE_RULE,
KEYFRAMES_RULE,
VIEWPORT_RULE,
SUPPORTS_RULE,
FILTER_RULE
};
static PassRefPtrWillBeRawPtr<CSSRuleSourceData> create(Type type)
{
return adoptRefWillBeNoop(new CSSRuleSourceData(type));
}
static PassRefPtrWillBeRawPtr<CSSRuleSourceData> createUnknown()
{
return adoptRefWillBeNoop(new CSSRuleSourceData(UNKNOWN_RULE));
}
CSSRuleSourceData(Type type)
: type(type)
{
if (type == STYLE_RULE || type == FONT_FACE_RULE || type == PAGE_RULE)
styleSourceData = CSSStyleSourceData::create();
}
void trace(Visitor*);
Type type;
SourceRange ruleHeaderRange;
SourceRange ruleBodyRange;
SelectorRangeList selectorRanges;
RefPtrWillBeMember<CSSStyleSourceData> styleSourceData;
RuleSourceDataList childRules;
};
}
namespace WTF {
template <> struct VectorTraits<WebCore::SourceRange> : VectorTraitsBase<WebCore::SourceRange> {
static const bool canInitializeWithMemset = true;
static const bool canMoveWithMemcpy = true;
};
template <> struct VectorTraits<WebCore::CSSPropertySourceData> : VectorTraitsBase<WebCore::CSSPropertySourceData> {
static const bool canInitializeWithMemset = true;
static const bool canMoveWithMemcpy = true;
};
}
#endif