CSSPropertySourceData.h [plain text]
#pragma once
#include "StyleRule.h"
#include <utility>
#include <wtf/Forward.h>
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class StyleRuleBase;
struct SourceRange {
SourceRange();
SourceRange(unsigned start, unsigned end);
unsigned length() const;
unsigned start;
unsigned end;
};
struct CSSPropertySourceData {
CSSPropertySourceData(const String& name, const String& value, bool important, bool disabled, bool parsedOk, const SourceRange&);
CSSPropertySourceData(const CSSPropertySourceData& other);
CSSPropertySourceData();
String toString() const;
unsigned hash() const;
String name;
String value;
bool important;
bool disabled;
bool parsedOk;
SourceRange range;
};
struct CSSStyleSourceData : public RefCounted<CSSStyleSourceData> {
static Ref<CSSStyleSourceData> create()
{
return adoptRef(*new CSSStyleSourceData);
}
Vector<CSSPropertySourceData> propertyData;
};
struct CSSRuleSourceData;
typedef Vector<Ref<CSSRuleSourceData>> RuleSourceDataList;
typedef Vector<SourceRange> SelectorRangeList;
struct CSSRuleSourceData : public RefCounted<CSSRuleSourceData> {
static Ref<CSSRuleSourceData> create(StyleRule::Type type)
{
return adoptRef(*new CSSRuleSourceData(type));
}
static Ref<CSSRuleSourceData> createUnknown()
{
return adoptRef(*new CSSRuleSourceData(StyleRule::Unknown));
}
CSSRuleSourceData(StyleRule::Type type)
: type(type)
{
if (type == StyleRule::Style || type == StyleRule::FontFace || type == StyleRule::Page)
styleSourceData = CSSStyleSourceData::create();
}
StyleRule::Type type;
SourceRange ruleHeaderRange;
SourceRange ruleBodyRange;
SelectorRangeList selectorRanges;
RefPtr<CSSStyleSourceData> styleSourceData;
RuleSourceDataList childRules;
};
}