diff options
Diffstat (limited to 'src/gui/text/qcssparser_p.h')
-rw-r--r-- | src/gui/text/qcssparser_p.h | 108 |
1 files changed, 40 insertions, 68 deletions
diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h index f340a23cde..c1cfb1ac9b 100644 --- a/src/gui/text/qcssparser_p.h +++ b/src/gui/text/qcssparser_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QCSSPARSER_P_H #define QCSSPARSER_P_H @@ -55,7 +19,6 @@ #include <QtCore/QStringList> #include <QtCore/QList> #include <QtCore/QVariant> -#include <QtCore/QPair> #include <QtCore/QSize> #include <QtCore/QMultiHash> #include <QtGui/QFont> @@ -199,6 +162,14 @@ enum Property { FontKerning, QtForegroundTextureCacheKey, QtIcon, + LetterSpacing, + WordSpacing, + TextDecorationColor, + QtPlaceHolderTextColor, + QtAccent, + QtStrokeWidth, + QtStrokeColor, + QtForeground, NumProperties }; @@ -389,7 +360,7 @@ struct Value Q_GUI_EXPORT QString toString() const; }; -QT_CSS_DECLARE_TYPEINFO(Value, Q_MOVABLE_TYPE) +QT_CSS_DECLARE_TYPEINFO(Value, Q_RELOCATABLE_TYPE) struct ColorData { ColorData() : role(QPalette::NoRole), type(Invalid) {} @@ -399,7 +370,7 @@ struct ColorData { QPalette::ColorRole role; enum { Invalid, Color, Role} type; }; -QT_CSS_DECLARE_TYPEINFO(ColorData, Q_MOVABLE_TYPE) +QT_CSS_DECLARE_TYPEINFO(ColorData, Q_RELOCATABLE_TYPE) struct BrushData { BrushData() : role(QPalette::NoRole), type(Invalid) {} @@ -409,7 +380,7 @@ struct BrushData { QPalette::ColorRole role; enum { Invalid, Brush, Role, DependsOnThePalette } type; }; -QT_CSS_DECLARE_TYPEINFO(BrushData, Q_MOVABLE_TYPE) +QT_CSS_DECLARE_TYPEINFO(BrushData, Q_RELOCATABLE_TYPE) struct BackgroundData { BrushData brush; @@ -417,7 +388,7 @@ struct BackgroundData { Repeat repeat; Qt::Alignment alignment; }; -QT_CSS_DECLARE_TYPEINFO(BackgroundData, Q_MOVABLE_TYPE) +QT_CSS_DECLARE_TYPEINFO(BackgroundData, Q_RELOCATABLE_TYPE) struct LengthData { qreal number; @@ -430,7 +401,7 @@ struct BorderData { BorderStyle style; BrushData color; }; -QT_CSS_DECLARE_TYPEINFO(BorderData, Q_MOVABLE_TYPE) +QT_CSS_DECLARE_TYPEINFO(BorderData, Q_RELOCATABLE_TYPE) // 1. StyleRule - x:hover, y:clicked > z:checked { prop1: value1; prop2: value2; } // 2. QList<Selector> - x:hover, y:clicked z:checked @@ -481,7 +452,7 @@ struct Q_GUI_EXPORT Declaration void borderImageValue(QString *image, int *cuts, TileMode *h, TileMode *v) const; bool borderCollapseValue() const; }; -QT_CSS_DECLARE_TYPEINFO(Declaration, Q_MOVABLE_TYPE) +QT_CSS_DECLARE_TYPEINFO(Declaration, Q_RELOCATABLE_TYPE) const quint64 PseudoClass_Unknown = Q_UINT64_C(0x0000000000000000); const quint64 PseudoClass_Enabled = Q_UINT64_C(0x0000000000000001); @@ -541,7 +512,7 @@ struct Pseudo QString function; bool negated; }; -QT_CSS_DECLARE_TYPEINFO(Pseudo, Q_MOVABLE_TYPE) +QT_CSS_DECLARE_TYPEINFO(Pseudo, Q_RELOCATABLE_TYPE) struct AttributeSelector { @@ -554,13 +525,12 @@ struct AttributeSelector MatchEndsWith, MatchContains }; - inline AttributeSelector() : valueMatchCriterium(NoMatch) {} QString name; QString value; - ValueMatchType valueMatchCriterium; + ValueMatchType valueMatchCriterium = NoMatch; }; -QT_CSS_DECLARE_TYPEINFO(AttributeSelector, Q_MOVABLE_TYPE) +QT_CSS_DECLARE_TYPEINFO(AttributeSelector, Q_RELOCATABLE_TYPE) struct BasicSelector { @@ -582,7 +552,7 @@ struct BasicSelector Relation relationToNext; }; -QT_CSS_DECLARE_TYPEINFO(BasicSelector, Q_MOVABLE_TYPE) +QT_CSS_DECLARE_TYPEINFO(BasicSelector, Q_RELOCATABLE_TYPE) struct Q_GUI_EXPORT Selector { @@ -591,7 +561,7 @@ struct Q_GUI_EXPORT Selector quint64 pseudoClass(quint64 *negated = nullptr) const; QString pseudoElement() const; }; -QT_CSS_DECLARE_TYPEINFO(Selector, Q_MOVABLE_TYPE) +QT_CSS_DECLARE_TYPEINFO(Selector, Q_RELOCATABLE_TYPE) struct StyleRule { @@ -600,28 +570,28 @@ struct StyleRule QList<Declaration> declarations; int order; }; -QT_CSS_DECLARE_TYPEINFO(StyleRule, Q_MOVABLE_TYPE) +QT_CSS_DECLARE_TYPEINFO(StyleRule, Q_RELOCATABLE_TYPE) struct MediaRule { QStringList media; QList<StyleRule> styleRules; }; -QT_CSS_DECLARE_TYPEINFO(MediaRule, Q_MOVABLE_TYPE) +QT_CSS_DECLARE_TYPEINFO(MediaRule, Q_RELOCATABLE_TYPE) struct PageRule { QString selector; QList<Declaration> declarations; }; -QT_CSS_DECLARE_TYPEINFO(PageRule, Q_MOVABLE_TYPE) +QT_CSS_DECLARE_TYPEINFO(PageRule, Q_RELOCATABLE_TYPE) struct ImportRule { QString href; QStringList media; }; -QT_CSS_DECLARE_TYPEINFO(ImportRule, Q_MOVABLE_TYPE) +QT_CSS_DECLARE_TYPEINFO(ImportRule, Q_RELOCATABLE_TYPE) enum StyleSheetOrigin { StyleSheetOrigin_Unspecified, @@ -645,7 +615,7 @@ struct StyleSheet Q_GUI_EXPORT void buildIndexes(Qt::CaseSensitivity nameCaseSensitivity = Qt::CaseSensitive); }; -QT_CSS_DECLARE_TYPEINFO(StyleSheet, Q_MOVABLE_TYPE) +QT_CSS_DECLARE_TYPEINFO(StyleSheet, Q_RELOCATABLE_TYPE) class Q_GUI_EXPORT StyleSelector @@ -663,7 +633,7 @@ public: QList<Declaration> declarationsForNode(NodePtr node, const char *extraPseudo = nullptr); virtual bool nodeNameEquals(NodePtr node, const QString& nodeName) const; - virtual QString attribute(NodePtr node, const QString &name) const = 0; + virtual QString attributeValue(NodePtr node, const QCss::AttributeSelector &aSelector) const = 0; virtual bool hasAttributes(NodePtr node) const = 0; virtual QStringList nodeIds(NodePtr node) const; virtual QStringList nodeNames(NodePtr node) const = 0; @@ -743,7 +713,7 @@ struct Symbol int start, len; Q_GUI_EXPORT QString lexem() const; }; -QT_CSS_DECLARE_TYPEINFO(Symbol, Q_MOVABLE_TYPE) +QT_CSS_DECLARE_TYPEINFO(Symbol, Q_RELOCATABLE_TYPE) class Q_GUI_EXPORT Scanner { @@ -797,9 +767,9 @@ public: 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 testImport() { return testTokenAndEndsWith(ATKEYWORD_SYM, QLatin1StringView("import")); } + inline bool testMedia() { return testTokenAndEndsWith(ATKEYWORD_SYM, QLatin1StringView("media")); } + inline bool testPage() { return testTokenAndEndsWith(ATKEYWORD_SYM, QLatin1StringView("page")); } inline bool testCombinator() { return test(PLUS) || test(GREATER) || test(TILDE) || test(S); } inline bool testProperty() { return test(IDENT); } bool testTerm(); @@ -819,7 +789,7 @@ public: inline void skipSpace() { while (test(S)) {}; } - inline bool hasNext() const { return index < symbols.count(); } + inline bool hasNext() const { return index < symbols.size(); } inline TokenType next() { return symbols.at(index++).token; } bool next(TokenType t); bool test(TokenType t); @@ -830,10 +800,10 @@ public: 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; + return (index - 1) < symbols.size() ? symbols.at(index - 1).token : NONE; } - bool testTokenAndEndsWith(TokenType t, QLatin1String str); + bool testTokenAndEndsWith(TokenType t, QLatin1StringView str); inline bool recordError() { errorIndex = index; return false; } @@ -857,7 +827,9 @@ struct Q_GUI_EXPORT ValueExtractor bool extractBox(int *margins, int *paddings, int *spacing = nullptr); 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); + bool extractPalette(QBrush *foreground, QBrush *selectedForeground, QBrush *selectedBackground, + QBrush *alternateBackground, QBrush *placeHolderTextForeground, + QBrush *accent); int extractStyleFeatures(); bool extractImage(QIcon *icon, Qt::Alignment *a, QSize *size); bool extractIcon(QIcon *icon, QSize *size); @@ -883,9 +855,9 @@ private: QT_END_NAMESPACE -Q_DECLARE_METATYPE( QCss::BackgroundData ) -Q_DECLARE_METATYPE( QCss::LengthData ) -Q_DECLARE_METATYPE( QCss::BorderData ) +QT_DECL_METATYPE_EXTERN_TAGGED(QCss::BackgroundData, QCss__BackgroundData, Q_GUI_EXPORT) +QT_DECL_METATYPE_EXTERN_TAGGED(QCss::LengthData, QCss__LengthData, Q_GUI_EXPORT) +QT_DECL_METATYPE_EXTERN_TAGGED(QCss::BorderData, QCss__BorderData, Q_GUI_EXPORT) #undef QT_CSS_DECLARE_TYPEINFO |