📄 qcssparser_p.h
字号:
void borderImageValue(QString *image, int *cuts, TileMode *h, TileMode *v) const;};enum PseudoClass{ PseudoClass_Unknown = 0x00000000, PseudoClass_Enabled = 0x00000001, PseudoClass_Disabled = 0x00000002, PseudoClass_Pressed = 0x00000004, PseudoClass_Focus = 0x00000008, PseudoClass_Hover = 0x00000010, PseudoClass_Checked = 0x00000020, PseudoClass_On = PseudoClass_Checked, PseudoClass_Unchecked = 0x00000040, PseudoClass_Off = PseudoClass_Unchecked, PseudoClass_Indeterminate = 0x00000080, PseudoClass_Editable = PseudoClass_Indeterminate, PseudoClass_Unspecified = 0x00000100, PseudoClass_Selected = 0x00000200, PseudoClass_Horizontal = 0x00000400, PseudoClass_Vertical = 0x00000800, PseudoClass_Open = 0x00001000, PseudoClass_Children = 0x00002000, PseudoClass_Sibling = 0x00004000, PseudoClass_Default = 0x00008000, PseudoClass_Item = PseudoClass_Default, PseudoClass_First = 0x00010000, PseudoClass_Last = 0x00020000, PseudoClass_Middle = 0x00040000, PseudoClass_OnlyOne = 0x00080000, PseudoClass_PreviousSelected = 0x00100000, PseudoClass_NextSelected = 0x00200000, PseudoClass_Flat = 0x00400000, PseudoClass_Left = 0x00800000, PseudoClass_Right = 0x01000000, PseudoClass_Top = 0x02000000, PseudoClass_Bottom = 0x04000000, PseudoClass_Exclusive = 0x08000000, PseudoClass_NonExclusive = 0x10000000, PseudoClass_Frameless = 0x20000000, PseudoClass_ReadOnly = 0x40000000, PseudoClass_Closed = 0x80000000, NumPseudos = 36};struct Q_GUI_EXPORT Pseudo{ Pseudo() : negated(false) { } PseudoClass type; QString name; QString function; bool negated;};struct Q_GUI_EXPORT AttributeSelector{ enum ValueMatchType { NoMatch, MatchEqual, MatchContains, MatchBeginsWith }; inline AttributeSelector() : valueMatchCriterium(NoMatch) {} QString name; QString value; ValueMatchType valueMatchCriterium;};struct Q_GUI_EXPORT BasicSelector{ inline BasicSelector() : relationToNext(NoRelation) {} enum Relation { NoRelation, MatchNextSelectorIfAncestor, MatchNextSelectorIfParent, MatchNextSelectorIfPreceeds }; QString elementName; QStringList ids; QVector<Pseudo> pseudos; QVector<AttributeSelector> attributeSelectors; Relation relationToNext;};struct Q_GUI_EXPORT Selector{ QVector<BasicSelector> basicSelectors; int specificity() const; int pseudoClass(int *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 extractPalette(QBrush *fg, QBrush *sfg, QBrush *sbg, QBrush *abg); int extractStyleFeatures(); bool extractImage(QIcon *icon, Qt::Alignment *a, QSize *size);private: void extractFont(); void borderValue(const Declaration &decl, int *width, QCss::BorderStyle *style, QBrush *color); int lengthValue(const Declaration &decl); int 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;};struct Q_GUI_EXPORT StyleRule{ QVector<Selector> selectors; QVector<Declaration> declarations;};struct Q_GUI_EXPORT MediaRule{ QStringList media; QVector<StyleRule> styleRules;};struct Q_GUI_EXPORT PageRule{ QString selector; QVector<Declaration> declarations;};struct Q_GUI_EXPORT ImportRule{ QString href; QStringList media;};enum StyleSheetOrigin { StyleSheetOrigin_Unspecified, StyleSheetOrigin_UserAgent, StyleSheetOrigin_User, StyleSheetOrigin_Author, StyleSheetOrigin_Inline};struct Q_GUI_EXPORT StyleSheet{ StyleSheet() : origin(StyleSheetOrigin_Unspecified), depth(0) { } QVector<StyleRule> styleRules; QVector<MediaRule> mediaRules; QVector<PageRule> pageRules; QVector<ImportRule> importRules; StyleSheetOrigin origin; int depth; // applicable only for inline style sheets};class Q_GUI_EXPORT StyleSelector{public: virtual ~StyleSelector(); union NodePtr { void *ptr; int id; }; QVector<StyleRule> styleRulesForNode(NodePtr node); QVector<Declaration> declarationsForNode(NodePtr node, const char *extraPseudo = 0); virtual bool nodeNameEquals(NodePtr node, const QString& nodeName) const = 0; virtual QString attribute(NodePtr node, const QString &name) const = 0; virtual bool hasAttribute(NodePtr node, const QString &name) const = 0; virtual bool hasAttributes(NodePtr node) const = 0; virtual QStringList nodeIds(NodePtr node) const; virtual bool isNullNode(NodePtr node) const = 0; virtual NodePtr parentNode(NodePtr node) const = 0; virtual NodePtr previousSiblingNode(NodePtr node) const = 0; virtual NodePtr duplicateNode(NodePtr node) const = 0; virtual void freeNode(NodePtr node) const = 0; QVector<StyleSheet> styleSheets; QString medium;private: void matchRules(NodePtr node, const QVector<StyleRule> &rules, StyleSheetOrigin origin, int depth, QVector<QPair<int, StyleRule> > *weightedRules); bool selectorMatches(const Selector &rule, NodePtr node); bool basicSelectorMatches(const BasicSelector &rule, NodePtr node);};enum TokenType { NONE, S, CDO, CDC, INCLUDES, DASHMATCH, LBRACE, PLUS, GREATER, COMMA, STRING, INVALID, IDENT, HASH, ATKEYWORD_SYM, EXCLAMATION_SYM, LENGTH, PERCENTAGE, NUMBER, FUNCTION, COLON, SEMICOLON, RBRACE, SLASH, MINUS, DOT, STAR, LBRACKET, RBRACKET, EQUAL, LPAREN, RPAREN, OR};struct Q_GUI_EXPORT Symbol{ inline Symbol() : start(0), len(-1) {} TokenType token; QString text; int start, len; QString lexem() const;};class Q_AUTOTEST_EXPORT Scanner{public: static QString preprocess(const QString &input, bool *hasEscapeSequences = 0); static void scan(const QString &preprocessedInput, QVector<Symbol> *symbols); static const char *tokenName(TokenType t);};class Q_GUI_EXPORT Parser{public: Parser(); Parser(QString css, bool file = false); void init(const QString &css); bool parse(StyleSheet *styleSheet); Symbol errorSymbol(); bool parseImport(ImportRule *importRule); bool parseMedia(MediaRule *mediaRule); bool parseMedium(QStringList *media); bool parsePage(PageRule *pageRule); bool parsePseudoPage(QString *selector); bool parseNextOperator(Value *value); bool parseCombinator(BasicSelector::Relation *relation); bool parseProperty(Declaration *decl); bool parseRuleset(StyleRule *styleRule); bool parseSelector(Selector *sel); bool parseSimpleSelector(BasicSelector *basicSel); bool parseClass(QString *name); bool parseElementName(QString *name); bool parseAttrib(AttributeSelector *attr); bool parsePseudo(Pseudo *pseudo); bool parseNextDeclaration(Declaration *declaration); bool parsePrio(Declaration *declaration); bool parseExpr(QVector<Value> *values); bool parseTerm(Value *value); bool parseFunction(QString *name, QString *args); bool parseHexColor(QColor *col); bool testAndParseUri(QString *uri); inline bool testRuleset() { return testSelector(); } inline bool testSelector() { return testSimpleSelector(); } inline bool parseNextSelector(Selector *sel) { if (!testSelector()) return recordError(); return parseSelector(sel); } bool testSimpleSelector(); inline bool parseNextSimpleSelector(BasicSelector *basicSel) { if (!testSimpleSelector()) return recordError(); return parseSimpleSelector(basicSel); } inline bool testElementName() { return test(IDENT) || test(STAR); } inline bool testClass() { return test(DOT); } inline bool testAttrib() { return test(LBRACKET); } inline bool testPseudo() { return test(COLON); } inline bool testMedium() { return test(IDENT); } inline bool parseNextMedium(QStringList *media) { if (!testMedium()) return recordError(); return parseMedium(media); } inline bool testPseudoPage() { return test(COLON); } inline bool testImport() { return testTokenAndEndsWith(ATKEYWORD_SYM, QLatin1String("import")); } inline bool testMedia() { return testTokenAndEndsWith(ATKEYWORD_SYM, QLatin1String("media")); } inline bool testPage() { return testTokenAndEndsWith(ATKEYWORD_SYM, QLatin1String("page")); } inline bool testCombinator() { return test(PLUS) || test(GREATER) || test(S); } inline bool testProperty() { return test(IDENT); } bool testTerm(); inline bool testExpr() { return testTerm(); } inline bool parseNextExpr(QVector<Value> *values) { if (!testExpr()) return recordError(); return parseExpr(values); } bool testPrio(); inline bool testHexColor() { return test(HASH); } inline bool testFunction() { return test(FUNCTION); } inline bool parseNextFunction(QString *name, QString *args) { if (!testFunction()) return recordError(); return parseFunction(name, args); } inline bool lookupElementName() const { return lookup() == IDENT || lookup() == STAR; } inline void skipSpace() { while (test(S)); } inline bool hasNext() const { return index < symbols.count(); } inline TokenType next() { return symbols.at(index++).token; } bool next(TokenType t); bool test(TokenType t); inline void prev() { index--; } inline const Symbol &symbol() const { return symbols.at(index - 1); } inline QString lexem() const { return symbol().lexem(); } QString unquotedLexem() const; QString lexemUntil(TokenType t); bool until(TokenType target, TokenType target2 = NONE); inline TokenType lookup() const { return (index - 1) < symbols.count() ? symbols.at(index - 1).token : NONE; } bool testTokenAndEndsWith(TokenType t, const QLatin1String &str); inline bool recordError() { errorIndex = index; return false; } QVector<Symbol> symbols; int index; int errorIndex; bool hasEscapeSequences; QString sourcePath;};}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -