summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qcssparser_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/text/qcssparser_p.h')
-rw-r--r--src/gui/text/qcssparser_p.h111
1 files changed, 66 insertions, 45 deletions
diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h
index 4738b0f584..5e853c40d0 100644
--- a/src/gui/text/qcssparser_p.h
+++ b/src/gui/text/qcssparser_p.h
@@ -69,6 +69,11 @@ QT_END_NAMESPACE
# undef Value
#endif
+#define QT_CSS_DECLARE_TYPEINFO(Class, Type) \
+ } /* namespace QCss */ \
+ Q_DECLARE_TYPEINFO(QCss:: Class, Type); \
+ namespace QCss {
+
QT_BEGIN_NAMESPACE
namespace QCss
@@ -345,7 +350,7 @@ enum StyleFeature {
NumKnownStyleFeatures = 4
};
-struct Q_GUI_EXPORT Value
+struct Value
{
enum Type {
Unknown,
@@ -364,8 +369,10 @@ struct Q_GUI_EXPORT Value
inline Value() : type(Unknown) { }
Type type;
QVariant variant;
- QString toString() const;
+
+ Q_GUI_EXPORT QString toString() const;
};
+QT_CSS_DECLARE_TYPEINFO(Value, Q_MOVABLE_TYPE)
struct ColorData {
ColorData() : role(QPalette::NoRole), type(Invalid) {}
@@ -375,6 +382,7 @@ struct ColorData {
QPalette::ColorRole role;
enum { Invalid, Color, Role} type;
};
+QT_CSS_DECLARE_TYPEINFO(ColorData, Q_MOVABLE_TYPE)
struct BrushData {
BrushData() : role(QPalette::NoRole), type(Invalid) {}
@@ -384,6 +392,7 @@ struct BrushData {
QPalette::ColorRole role;
enum { Invalid, Brush, Role, DependsOnThePalette } type;
};
+QT_CSS_DECLARE_TYPEINFO(BrushData, Q_MOVABLE_TYPE)
struct BackgroundData {
BrushData brush;
@@ -391,17 +400,20 @@ struct BackgroundData {
Repeat repeat;
Qt::Alignment alignment;
};
+QT_CSS_DECLARE_TYPEINFO(BackgroundData, Q_MOVABLE_TYPE)
struct LengthData {
qreal number;
enum { None, Px, Ex, Em } unit;
};
+QT_CSS_DECLARE_TYPEINFO(LengthData, Q_PRIMITIVE_TYPE)
struct BorderData {
LengthData width;
BorderStyle style;
BrushData color;
};
+QT_CSS_DECLARE_TYPEINFO(BorderData, Q_MOVABLE_TYPE)
// 1. StyleRule - x:hover, y:clicked > z:checked { prop1: value1; prop2: value2; }
@@ -451,6 +463,7 @@ struct Q_GUI_EXPORT Declaration
void borderImageValue(QString *image, int *cuts, TileMode *h, TileMode *v) const;
};
+QT_CSS_DECLARE_TYPEINFO(Declaration, Q_MOVABLE_TYPE)
const quint64 PseudoClass_Unknown = Q_UINT64_C(0x0000000000000000);
const quint64 PseudoClass_Enabled = Q_UINT64_C(0x0000000000000001);
@@ -510,6 +523,7 @@ struct Pseudo
QString function;
bool negated;
};
+QT_CSS_DECLARE_TYPEINFO(Pseudo, Q_MOVABLE_TYPE)
struct AttributeSelector
{
@@ -525,6 +539,7 @@ struct AttributeSelector
QString value;
ValueMatchType valueMatchCriterium;
};
+QT_CSS_DECLARE_TYPEINFO(AttributeSelector, Q_MOVABLE_TYPE)
struct BasicSelector
{
@@ -545,6 +560,7 @@ struct BasicSelector
Relation relationToNext;
};
+QT_CSS_DECLARE_TYPEINFO(BasicSelector, Q_MOVABLE_TYPE)
struct Q_GUI_EXPORT Selector
{
@@ -553,45 +569,7 @@ struct Q_GUI_EXPORT Selector
quint64 pseudoClass(quint64 *negated = 0) const;
QString pseudoElement() const;
};
-
-struct StyleRule;
-struct MediaRule;
-struct PageRule;
-struct ImportRule;
-
-struct Q_GUI_EXPORT ValueExtractor
-{
- ValueExtractor(const QVector<Declaration> &declarations, const QPalette & = QPalette());
-
- bool extractFont(QFont *font, int *fontSizeAdjustment);
- bool extractBackground(QBrush *, QString *, Repeat *, Qt::Alignment *, QCss::Origin *, QCss::Attachment *,
- QCss::Origin *);
- bool extractGeometry(int *w, int *h, int *minw, int *minh, int *maxw, int *maxh);
- bool extractPosition(int *l, int *t, int *r, int *b, QCss::Origin *, Qt::Alignment *,
- QCss::PositionMode *, Qt::Alignment *);
- bool extractBox(int *margins, int *paddings, int *spacing = 0);
- bool extractBorder(int *borders, QBrush *colors, BorderStyle *Styles, QSize *radii);
- bool extractOutline(int *borders, QBrush *colors, BorderStyle *Styles, QSize *radii, int *offsets);
- bool extractPalette(QBrush *fg, QBrush *sfg, QBrush *sbg, QBrush *abg);
- int extractStyleFeatures();
- bool extractImage(QIcon *icon, Qt::Alignment *a, QSize *size);
-
- int lengthValue(const Declaration &decl);
-
-private:
- void extractFont();
- void borderValue(const Declaration &decl, int *width, QCss::BorderStyle *style, QBrush *color);
- LengthData lengthValue(const Value& v);
- void lengthValues(const Declaration &decl, int *m);
- QSize sizeValue(const Declaration &decl);
- void sizeValues(const Declaration &decl, QSize *radii);
-
- QVector<Declaration> declarations;
- QFont f;
- int adjustment;
- int fontExtracted;
- QPalette pal;
-};
+QT_CSS_DECLARE_TYPEINFO(Selector, Q_MOVABLE_TYPE)
struct StyleRule
{
@@ -600,24 +578,28 @@ struct StyleRule
QVector<Declaration> declarations;
int order;
};
+QT_CSS_DECLARE_TYPEINFO(StyleRule, Q_MOVABLE_TYPE)
struct MediaRule
{
QStringList media;
QVector<StyleRule> styleRules;
};
+QT_CSS_DECLARE_TYPEINFO(MediaRule, Q_MOVABLE_TYPE)
struct PageRule
{
QString selector;
QVector<Declaration> declarations;
};
+QT_CSS_DECLARE_TYPEINFO(PageRule, Q_MOVABLE_TYPE)
struct ImportRule
{
QString href;
QStringList media;
};
+QT_CSS_DECLARE_TYPEINFO(ImportRule, Q_MOVABLE_TYPE)
enum StyleSheetOrigin {
StyleSheetOrigin_Unspecified,
@@ -627,7 +609,7 @@ enum StyleSheetOrigin {
StyleSheetOrigin_Inline
};
-struct Q_GUI_EXPORT StyleSheet
+struct StyleSheet
{
StyleSheet() : origin(StyleSheetOrigin_Unspecified), depth(0) { }
QVector<StyleRule> styleRules; //only contains rules that are not indexed
@@ -638,8 +620,11 @@ struct Q_GUI_EXPORT StyleSheet
int depth; // applicable only for inline style sheets
QMultiHash<QString, StyleRule> nameIndex;
QMultiHash<QString, StyleRule> idIndex;
- void buildIndexes(Qt::CaseSensitivity nameCaseSensitivity = Qt::CaseSensitive);
+
+ Q_GUI_EXPORT void buildIndexes(Qt::CaseSensitivity nameCaseSensitivity = Qt::CaseSensitive);
};
+QT_CSS_DECLARE_TYPEINFO(StyleSheet, Q_MOVABLE_TYPE)
+
class Q_GUI_EXPORT StyleSelector
{
@@ -724,14 +709,15 @@ enum TokenType {
OR
};
-struct Q_GUI_EXPORT Symbol
+struct Symbol
{
inline Symbol() : token(NONE), start(0), len(-1) {}
TokenType token;
QString text;
int start, len;
- QString lexem() const;
+ Q_GUI_EXPORT QString lexem() const;
};
+QT_CSS_DECLARE_TYPEINFO(Symbol, Q_MOVABLE_TYPE)
class Q_GUI_EXPORT Scanner
{
@@ -827,6 +813,40 @@ public:
QString sourcePath;
};
+struct Q_GUI_EXPORT ValueExtractor
+{
+ ValueExtractor(const QVector<Declaration> &declarations, const QPalette & = QPalette());
+
+ bool extractFont(QFont *font, int *fontSizeAdjustment);
+ bool extractBackground(QBrush *, QString *, Repeat *, Qt::Alignment *, QCss::Origin *, QCss::Attachment *,
+ QCss::Origin *);
+ bool extractGeometry(int *w, int *h, int *minw, int *minh, int *maxw, int *maxh);
+ bool extractPosition(int *l, int *t, int *r, int *b, QCss::Origin *, Qt::Alignment *,
+ QCss::PositionMode *, Qt::Alignment *);
+ bool extractBox(int *margins, int *paddings, int *spacing = 0);
+ bool extractBorder(int *borders, QBrush *colors, BorderStyle *Styles, QSize *radii);
+ bool extractOutline(int *borders, QBrush *colors, BorderStyle *Styles, QSize *radii, int *offsets);
+ bool extractPalette(QBrush *fg, QBrush *sfg, QBrush *sbg, QBrush *abg);
+ int extractStyleFeatures();
+ bool extractImage(QIcon *icon, Qt::Alignment *a, QSize *size);
+
+ int lengthValue(const Declaration &decl);
+
+private:
+ void extractFont();
+ void borderValue(const Declaration &decl, int *width, QCss::BorderStyle *style, QBrush *color);
+ LengthData lengthValue(const Value& v);
+ void lengthValues(const Declaration &decl, int *m);
+ QSize sizeValue(const Declaration &decl);
+ void sizeValues(const Declaration &decl, QSize *radii);
+
+ QVector<Declaration> declarations;
+ QFont f;
+ int adjustment;
+ int fontExtracted;
+ QPalette pal;
+};
+
} // namespace QCss
QT_END_NAMESPACE
@@ -835,6 +855,7 @@ Q_DECLARE_METATYPE( QCss::BackgroundData )
Q_DECLARE_METATYPE( QCss::LengthData )
Q_DECLARE_METATYPE( QCss::BorderData )
+#undef QT_CSS_DECLARE_TYPEINFO
#endif // QT_NO_CSSPARSER