diff options
Diffstat (limited to 'src/gui/text')
74 files changed, 928 insertions, 600 deletions
diff --git a/src/gui/text/qabstracttextdocumentlayout.cpp b/src/gui/text/qabstracttextdocumentlayout.cpp index ff2497817e..2278378613 100644 --- a/src/gui/text/qabstracttextdocumentlayout.cpp +++ b/src/gui/text/qabstracttextdocumentlayout.cpp @@ -602,9 +602,32 @@ QTextDocument *QAbstractTextDocumentLayout::document() const */ QString QAbstractTextDocumentLayout::anchorAt(const QPointF& pos) const { + QTextCharFormat fmt = formatAt(pos).toCharFormat(); + return fmt.anchorHref(); +} + +/*! + \since 5.8 + + Returns the source of the image at the given position \a pos, or an empty + string if no image exists at that point. +*/ +QString QAbstractTextDocumentLayout::imageAt(const QPointF &pos) const +{ + QTextImageFormat fmt = formatAt(pos).toImageFormat(); + return fmt.name(); +} + +/*! + \since 5.8 + + Returns the text format at the given position \a pos. +*/ +QTextFormat QAbstractTextDocumentLayout::formatAt(const QPointF &pos) const +{ int cursorPos = hitTest(pos, Qt::ExactHit); if (cursorPos == -1) - return QString(); + return QTextFormat(); // compensate for preedit in the hit text block QTextBlock block = document()->firstBlock(); @@ -623,8 +646,7 @@ QString QAbstractTextDocumentLayout::anchorAt(const QPointF& pos) const QTextDocumentPrivate *pieceTable = qobject_cast<const QTextDocument *>(parent())->docHandle(); QTextDocumentPrivate::FragmentIterator it = pieceTable->find(cursorPos); - QTextCharFormat fmt = pieceTable->formatCollection()->charFormat(it->format); - return fmt.anchorHref(); + return pieceTable->formatCollection()->format(it->format); } /*! diff --git a/src/gui/text/qabstracttextdocumentlayout.h b/src/gui/text/qabstracttextdocumentlayout.h index 01704fe37b..438ad6e70b 100644 --- a/src/gui/text/qabstracttextdocumentlayout.h +++ b/src/gui/text/qabstracttextdocumentlayout.h @@ -40,6 +40,7 @@ #ifndef QABSTRACTTEXTDOCUMENTLAYOUT_H #define QABSTRACTTEXTDOCUMENTLAYOUT_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qobject.h> #include <QtGui/qtextlayout.h> #include <QtGui/qtextdocument.h> @@ -82,7 +83,10 @@ public: virtual void draw(QPainter *painter, const PaintContext &context) = 0; virtual int hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const = 0; + QString anchorAt(const QPointF& pos) const; + QString imageAt(const QPointF &pos) const; + QTextFormat formatAt(const QPointF &pos) const; virtual int pageCount() const = 0; virtual QSizeF documentSize() const = 0; diff --git a/src/gui/text/qabstracttextdocumentlayout_p.h b/src/gui/text/qabstracttextdocumentlayout_p.h index fc39d8ec5c..191c463dc6 100644 --- a/src/gui/text/qabstracttextdocumentlayout_p.h +++ b/src/gui/text/qabstracttextdocumentlayout_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "private/qobject_p.h" #include "QtCore/qhash.h" diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index 966ab3fcdb..cb19a42688 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -403,8 +403,8 @@ ValueExtractor::ValueExtractor(const QVector<Declaration> &decls, const QPalette LengthData ValueExtractor::lengthValue(const Value& v) { - QString s = v.variant.toString(); - s.reserve(s.length()); + const QString str = v.variant.toString(); + QStringRef s(&str); LengthData data; data.unit = LengthData::None; if (s.endsWith(QLatin1String("px"), Qt::CaseInsensitive)) @@ -900,7 +900,7 @@ static QBrush brushFromData(const BrushData& c, const QPalette &pal) } } -static BorderStyle parseStyleValue(QCss::Value v) +static BorderStyle parseStyleValue(const QCss::Value &v) { if (v.type == Value::KnownIdentifier) { switch (v.variant.toInt()) { @@ -1442,11 +1442,13 @@ bool Declaration::realValue(qreal *real, const char *unit) const const Value &v = d->values.at(0); if (unit && v.type != Value::Length) return false; - QString s = v.variant.toString(); + const QString str = v.variant.toString(); + QStringRef s(&str); if (unit) { - if (!s.endsWith(QLatin1String(unit), Qt::CaseInsensitive)) + const QLatin1String unitStr(unit); + if (!s.endsWith(unitStr, Qt::CaseInsensitive)) return false; - s.chop(qstrlen(unit)); + s.chop(unitStr.size()); } bool ok = false; qreal val = s.toDouble(&ok); @@ -1459,11 +1461,13 @@ static bool intValueHelper(const QCss::Value &v, int *i, const char *unit) { if (unit && v.type != Value::Length) return false; - QString s = v.variant.toString(); + const QString str = v.variant.toString(); + QStringRef s(&str); if (unit) { - if (!s.endsWith(QLatin1String(unit), Qt::CaseInsensitive)) + const QLatin1String unitStr(unit); + if (!s.endsWith(unitStr, Qt::CaseInsensitive)) return false; - s.chop(qstrlen(unit)); + s.chop(unitStr.size()); } bool ok = false; int val = s.toInt(&ok); @@ -1867,12 +1871,15 @@ bool StyleSelector::selectorMatches(const Selector &selector, NodePtr node) do { match = basicSelectorMatches(sel, node); if (!match) { - if (sel.relationToNext == BasicSelector::MatchNextSelectorIfParent - || i == selector.basicSelectors.count() - 1) // first element must always match! + if (i == selector.basicSelectors.count() - 1) // first element must always match! + break; + if (sel.relationToNext != BasicSelector::MatchNextSelectorIfAncestor && + sel.relationToNext != BasicSelector::MatchNextSelectorIfIndirectAdjecent) break; } - if (match || sel.relationToNext != BasicSelector::MatchNextSelectorIfAncestor) + if (match || (sel.relationToNext != BasicSelector::MatchNextSelectorIfAncestor && + sel.relationToNext != BasicSelector::MatchNextSelectorIfIndirectAdjecent)) --i; if (i < 0) @@ -1885,16 +1892,18 @@ bool StyleSelector::selectorMatches(const Selector &selector, NodePtr node) NodePtr nextParent = parentNode(node); freeNode(node); node = nextParent; - } else if (sel.relationToNext == BasicSelector::MatchNextSelectorIfPreceeds) { + } else if (sel.relationToNext == BasicSelector::MatchNextSelectorIfDirectAdjecent + || sel.relationToNext == BasicSelector::MatchNextSelectorIfIndirectAdjecent) { NodePtr previousSibling = previousSiblingNode(node); freeNode(node); node = previousSibling; - } + } if (isNullNode(node)) { match = false; break; } - } while (i >= 0 && (match || sel.relationToNext == BasicSelector::MatchNextSelectorIfAncestor)); + } while (i >= 0 && (match || sel.relationToNext == BasicSelector::MatchNextSelectorIfAncestor + || sel.relationToNext == BasicSelector::MatchNextSelectorIfIndirectAdjecent)); freeNode(node); @@ -1914,18 +1923,38 @@ bool StyleSelector::basicSelectorMatches(const BasicSelector &sel, NodePtr node) if (attrValue.isNull()) return false; - if (a.valueMatchCriterium == QCss::AttributeSelector::MatchContains) { + switch (a.valueMatchCriterium) { + case QCss::AttributeSelector::NoMatch: + break; + case QCss::AttributeSelector::MatchEqual: + if (attrValue != a.value) + return false; + break; + case QCss::AttributeSelector::MatchIncludes: { const auto lst = attrValue.splitRef(QLatin1Char(' ')); if (!lst.contains(QStringRef(&a.value))) return false; - } else if ( - (a.valueMatchCriterium == QCss::AttributeSelector::MatchEqual - && attrValue != a.value) - || - (a.valueMatchCriterium == QCss::AttributeSelector::MatchBeginsWith - && !attrValue.startsWith(a.value)) - ) - return false; + break; + } + case QCss::AttributeSelector::MatchDashMatch: { + const QString dashPrefix = a.value + QLatin1Char('-'); + if (attrValue != a.value && !attrValue.startsWith(dashPrefix)) + return false; + break; + } + case QCss::AttributeSelector::MatchBeginsWith: + if (!attrValue.startsWith(a.value)) + return false; + break; + case QCss::AttributeSelector::MatchEndsWith: + if (!attrValue.endsWith(a.value)) + return false; + break; + case QCss::AttributeSelector::MatchContains: + if (!attrValue.contains(a.value)) + return false; + break; + } } } @@ -2082,7 +2111,7 @@ QString Scanner::preprocess(const QString &input, bool *hasEscapeSequences) hexCount = qMin(hexCount, 6); bool ok = false; - ushort code = output.mid(hexStart, hexCount).toUShort(&ok, 16); + ushort code = output.midRef(hexStart, hexCount).toUShort(&ok, 16); if (ok) { output.replace(hexStart - 1, hexCount + 1, QChar(code)); i = hexStart; @@ -2336,9 +2365,11 @@ bool Parser::parseCombinator(BasicSelector::Relation *relation) prev(); } if (test(PLUS)) { - *relation = BasicSelector::MatchNextSelectorIfPreceeds; + *relation = BasicSelector::MatchNextSelectorIfDirectAdjecent; } else if (test(GREATER)) { *relation = BasicSelector::MatchNextSelectorIfParent; + } else if (test(TILDE)) { + *relation = BasicSelector::MatchNextSelectorIfIndirectAdjecent; } skipSpace(); return true; @@ -2439,7 +2470,7 @@ bool Parser::parseSimpleSelector(BasicSelector *basicSel) onceMore = true; AttributeSelector a; a.name = QLatin1String("class"); - a.valueMatchCriterium = AttributeSelector::MatchContains; + a.valueMatchCriterium = AttributeSelector::MatchIncludes; if (!parseClass(&a.value)) return false; basicSel->attributeSelectors.append(a); } else if (testAttrib()) { @@ -2485,9 +2516,15 @@ bool Parser::parseAttrib(AttributeSelector *attr) if (test(EQUAL)) { attr->valueMatchCriterium = AttributeSelector::MatchEqual; } else if (test(INCLUDES)) { - attr->valueMatchCriterium = AttributeSelector::MatchContains; + attr->valueMatchCriterium = AttributeSelector::MatchIncludes; } else if (test(DASHMATCH)) { + attr->valueMatchCriterium = AttributeSelector::MatchDashMatch; + } else if (test(BEGINSWITH)) { attr->valueMatchCriterium = AttributeSelector::MatchBeginsWith; + } else if (test(ENDSWITH)) { + attr->valueMatchCriterium = AttributeSelector::MatchEndsWith; + } else if (test(CONTAINS)) { + attr->valueMatchCriterium = AttributeSelector::MatchContains; } else { return next(RBRACKET); } diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h index 4da7b62dba..9f79e9934e 100644 --- a/src/gui/text/qcssparser_p.h +++ b/src/gui/text/qcssparser_p.h @@ -44,13 +44,14 @@ // W A R N I N G // ------------- // -// This file is not part of the Qt API. It exists for the convenience -// of the QLibrary class. This header file may change from -// version to version without notice, or even be removed. +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. // // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtCore/QStringList> #include <QtCore/QVector> #include <QtCore/QVariant> @@ -538,8 +539,11 @@ struct AttributeSelector enum ValueMatchType { NoMatch, MatchEqual, - MatchContains, - MatchBeginsWith + MatchIncludes, + MatchDashMatch, + MatchBeginsWith, + MatchEndsWith, + MatchContains }; inline AttributeSelector() : valueMatchCriterium(NoMatch) {} @@ -557,7 +561,8 @@ struct BasicSelector NoRelation, MatchNextSelectorIfAncestor, MatchNextSelectorIfParent, - MatchNextSelectorIfPreceeds + MatchNextSelectorIfDirectAdjecent, + MatchNextSelectorIfIndirectAdjecent, }; QString elementName; @@ -678,11 +683,15 @@ enum TokenType { CDC, INCLUDES, DASHMATCH, + BEGINSWITH, + ENDSWITH, + CONTAINS, LBRACE, PLUS, GREATER, COMMA, + TILDE, STRING, INVALID, @@ -782,7 +791,7 @@ public: 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 testCombinator() { return test(PLUS) || test(GREATER) || test(TILDE) || test(S); } inline bool testProperty() { return test(IDENT); } bool testTerm(); inline bool testExpr() { return testTerm(); } diff --git a/src/gui/text/qcssscanner.cpp b/src/gui/text/qcssscanner.cpp index f6b25d50ba..33dc01c8bc 100644 --- a/src/gui/text/qcssscanner.cpp +++ b/src/gui/text/qcssscanner.cpp @@ -88,8 +88,10 @@ int QCssScanner_Generated::lex() goto state_3; if (ch.unicode() == 35) goto state_4; - if (ch.unicode() == 39) + if (ch.unicode() == 36) goto state_5; + if (ch.unicode() == 39) + goto state_6; if (ch.unicode() == 40) { token = QCss::LPAREN; goto found; @@ -98,22 +100,20 @@ int QCssScanner_Generated::lex() token = QCss::RPAREN; goto found; } - if (ch.unicode() == 42) { - token = QCss::STAR; - goto found; - } - if (ch.unicode() == 43) + if (ch.unicode() == 42) goto state_9; - if (ch.unicode() == 44) + if (ch.unicode() == 43) goto state_10; - if (ch.unicode() == 45) + if (ch.unicode() == 44) goto state_11; - if (ch.unicode() == 46) + if (ch.unicode() == 45) goto state_12; - if (ch.unicode() == 47) + if (ch.unicode() == 46) goto state_13; - if (ch.unicode() >= 48 && ch.unicode() <= 57) + if (ch.unicode() == 47) goto state_14; + if (ch.unicode() >= 48 && ch.unicode() <= 57) + goto state_15; if (ch.unicode() == 58) { token = QCss::COLON; goto found; @@ -123,147 +123,167 @@ int QCssScanner_Generated::lex() goto found; } if (ch.unicode() == 60) - goto state_17; + goto state_18; if (ch.unicode() == 61) { token = QCss::EQUAL; goto found; } if (ch.unicode() == 62) - goto state_19; - if (ch.unicode() == 64) goto state_20; + if (ch.unicode() == 64) + goto state_21; if (ch.unicode() == 91) { token = QCss::LBRACKET; goto found; } if (ch.unicode() == 92) - goto state_22; + goto state_23; if (ch.unicode() == 93) { token = QCss::RBRACKET; goto found; } + if (ch.unicode() == 94) + goto state_25; if (ch.unicode() == 95) - goto state_24; + goto state_26; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_24; + goto state_26; if (ch.unicode() == 123) - goto state_25; + goto state_27; if (ch.unicode() == 124) - goto state_26; + goto state_28; if (ch.unicode() == 125) { token = QCss::RBRACE; goto found; } if (ch.unicode() == 126) - goto state_28; + goto state_30; goto out; state_1: lastAcceptingPos = pos; token = QCss::S; ch = next(); if (ch.unicode() >= 9 && ch.unicode() <= 10) - goto state_29; + goto state_31; if (ch.unicode() >= 12 && ch.unicode() <= 13) - goto state_29; + goto state_31; if (ch.unicode() == 32) - goto state_29; + goto state_31; if (ch.unicode() == 43) - goto state_9; - if (ch.unicode() == 44) goto state_10; + if (ch.unicode() == 44) + goto state_11; if (ch.unicode() == 62) - goto state_19; + goto state_20; if (ch.unicode() == 123) - goto state_25; + goto state_27; + if (ch.unicode() == 126) + goto state_32; goto out; state_3: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_30; + goto state_33; if (ch.unicode() == 11) - goto state_30; + goto state_33; if (ch.unicode() >= 14 && ch.unicode() <= 33) - goto state_30; + goto state_33; if (ch.unicode() == 34) - goto state_31; + goto state_34; if (ch.unicode() >= 35 && ch.unicode() <= 91) - goto state_30; + goto state_33; if (ch.unicode() == 92) - goto state_32; + goto state_35; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_30; + goto state_33; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_30; + goto state_33; if (ch.unicode() >= 123) - goto state_30; + goto state_33; goto out; state_4: ch = next(); if (ch.unicode() == 45) - goto state_33; + goto state_36; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_33; + goto state_36; if (ch.unicode() == 92) - goto state_34; + goto state_37; if (ch.unicode() == 95) - goto state_33; + goto state_36; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_33; + goto state_36; goto out; state_5: + ch = next(); + if (ch.unicode() == 61) { + token = QCss::ENDSWITH; + goto found; + } + goto out; + state_6: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_35; + goto state_39; if (ch.unicode() == 11) - goto state_35; + goto state_39; if (ch.unicode() >= 14 && ch.unicode() <= 38) - goto state_35; + goto state_39; if (ch.unicode() == 39) - goto state_36; + goto state_40; if (ch.unicode() >= 40 && ch.unicode() <= 91) - goto state_35; + goto state_39; if (ch.unicode() == 92) - goto state_37; + goto state_41; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_35; + goto state_39; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_35; + goto state_39; if (ch.unicode() >= 123) - goto state_35; + goto state_39; goto out; state_9: lastAcceptingPos = pos; - token = QCss::PLUS; + token = QCss::STAR; + ch = next(); + if (ch.unicode() == 61) { + token = QCss::CONTAINS; + goto found; + } goto out; state_10: lastAcceptingPos = pos; - token = QCss::COMMA; + token = QCss::PLUS; goto out; state_11: lastAcceptingPos = pos; + token = QCss::COMMA; + goto out; + state_12: + lastAcceptingPos = pos; token = QCss::MINUS; ch = next(); if (ch.unicode() == 45) - goto state_38; + goto state_43; if (ch.unicode() == 92) - goto state_22; + goto state_23; if (ch.unicode() == 95) - goto state_24; + goto state_26; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_24; + goto state_26; goto out; - state_12: + state_13: lastAcceptingPos = pos; token = QCss::DOT; ch = next(); if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_39; + goto state_44; goto out; - state_13: + state_14: lastAcceptingPos = pos; token = QCss::SLASH; ch = next(); @@ -272,80 +292,87 @@ int QCssScanner_Generated::lex() goto found; } goto out; - state_14: + state_15: lastAcceptingPos = pos; token = QCss::NUMBER; ch = next(); if (ch.unicode() == 37) - goto state_41; + goto state_46; if (ch.unicode() == 45) - goto state_42; + goto state_47; if (ch.unicode() == 46) - goto state_43; + goto state_48; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_44; + goto state_49; if (ch.unicode() == 92) - goto state_45; + goto state_50; if (ch.unicode() == 95) - goto state_46; + goto state_51; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_46; + goto state_51; goto out; - state_17: + state_18: ch = next(); if (ch.unicode() == 33) - goto state_47; + goto state_52; goto out; - state_19: + state_20: lastAcceptingPos = pos; token = QCss::GREATER; goto out; - state_20: + state_21: ch = next(); if (ch.unicode() == 45) - goto state_48; + goto state_53; if (ch.unicode() == 92) - goto state_49; + goto state_54; if (ch.unicode() == 95) - goto state_50; + goto state_55; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_50; + goto state_55; goto out; - state_22: + state_23: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_51; + goto state_56; if (ch.unicode() == 11) - goto state_51; + goto state_56; if (ch.unicode() >= 14 && ch.unicode() <= 47) - goto state_51; + goto state_56; if (ch.unicode() >= 58 && ch.unicode() <= 96) - goto state_51; + goto state_56; if (ch.unicode() >= 103) - goto state_51; + goto state_56; + goto out; + state_25: + ch = next(); + if (ch.unicode() == 61) { + token = QCss::BEGINSWITH; + goto found; + } goto out; - state_24: + state_26: lastAcceptingPos = pos; token = QCss::IDENT; ch = next(); if (ch.unicode() == 40) - goto state_52; + goto state_58; if (ch.unicode() == 45) - goto state_53; + goto state_59; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_53; + goto state_59; if (ch.unicode() == 92) - goto state_54; + goto state_60; if (ch.unicode() == 95) - goto state_53; + goto state_59; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_53; + goto state_59; goto out; - state_25: + state_27: lastAcceptingPos = pos; token = QCss::LBRACE; goto out; - state_26: + state_28: lastAcceptingPos = pos; token = QCss::OR; ch = next(); @@ -354,782 +381,790 @@ int QCssScanner_Generated::lex() goto found; } goto out; - state_28: + state_30: + lastAcceptingPos = pos; + token = QCss::TILDE; ch = next(); if (ch.unicode() == 61) { token = QCss::INCLUDES; goto found; } goto out; - state_29: + state_31: lastAcceptingPos = pos; token = QCss::S; ch = next(); if (ch.unicode() >= 9 && ch.unicode() <= 10) - goto state_29; + goto state_31; if (ch.unicode() >= 12 && ch.unicode() <= 13) - goto state_29; + goto state_31; if (ch.unicode() == 32) - goto state_29; + goto state_31; if (ch.unicode() == 43) - goto state_9; - if (ch.unicode() == 44) goto state_10; + if (ch.unicode() == 44) + goto state_11; if (ch.unicode() == 62) - goto state_19; + goto state_20; if (ch.unicode() == 123) - goto state_25; + goto state_27; + if (ch.unicode() == 126) + goto state_32; goto out; - state_30: + state_32: + lastAcceptingPos = pos; + token = QCss::TILDE; + goto out; + state_33: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_30; + goto state_33; if (ch.unicode() == 11) - goto state_30; + goto state_33; if (ch.unicode() >= 14 && ch.unicode() <= 33) - goto state_30; + goto state_33; if (ch.unicode() == 34) - goto state_31; + goto state_34; if (ch.unicode() >= 35 && ch.unicode() <= 91) - goto state_30; + goto state_33; if (ch.unicode() == 92) - goto state_32; + goto state_35; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_30; + goto state_33; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_30; + goto state_33; if (ch.unicode() >= 123) - goto state_30; + goto state_33; goto out; - state_31: + state_34: lastAcceptingPos = pos; token = QCss::STRING; goto out; - state_32: + state_35: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_57; + goto state_63; if (ch.unicode() == 10) - goto state_58; + goto state_64; if (ch.unicode() == 11) - goto state_57; + goto state_63; if (ch.unicode() == 12) - goto state_59; + goto state_65; if (ch.unicode() == 13) - goto state_60; + goto state_66; if (ch.unicode() >= 14 && ch.unicode() <= 47) - goto state_57; + goto state_63; if (ch.unicode() >= 58 && ch.unicode() <= 96) - goto state_57; + goto state_63; if (ch.unicode() >= 103) - goto state_57; + goto state_63; goto out; - state_33: + state_36: lastAcceptingPos = pos; token = QCss::HASH; ch = next(); if (ch.unicode() == 45) - goto state_61; + goto state_67; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_61; + goto state_67; if (ch.unicode() == 92) - goto state_62; + goto state_68; if (ch.unicode() == 95) - goto state_61; + goto state_67; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_61; + goto state_67; goto out; - state_34: + state_37: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_63; + goto state_69; if (ch.unicode() == 11) - goto state_63; + goto state_69; if (ch.unicode() >= 14 && ch.unicode() <= 47) - goto state_63; + goto state_69; if (ch.unicode() >= 58 && ch.unicode() <= 96) - goto state_63; + goto state_69; if (ch.unicode() >= 103) - goto state_63; + goto state_69; goto out; - state_35: + state_39: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_35; + goto state_39; if (ch.unicode() == 11) - goto state_35; + goto state_39; if (ch.unicode() >= 14 && ch.unicode() <= 38) - goto state_35; + goto state_39; if (ch.unicode() == 39) - goto state_36; + goto state_40; if (ch.unicode() >= 40 && ch.unicode() <= 91) - goto state_35; + goto state_39; if (ch.unicode() == 92) - goto state_37; + goto state_41; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_35; + goto state_39; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_35; + goto state_39; if (ch.unicode() >= 123) - goto state_35; + goto state_39; goto out; - state_36: + state_40: lastAcceptingPos = pos; token = QCss::STRING; goto out; - state_37: + state_41: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_64; + goto state_70; if (ch.unicode() == 10) - goto state_65; + goto state_71; if (ch.unicode() == 11) - goto state_64; + goto state_70; if (ch.unicode() == 12) - goto state_66; + goto state_72; if (ch.unicode() == 13) - goto state_67; + goto state_73; if (ch.unicode() >= 14 && ch.unicode() <= 47) - goto state_64; + goto state_70; if (ch.unicode() >= 58 && ch.unicode() <= 96) - goto state_64; + goto state_70; if (ch.unicode() >= 103) - goto state_64; + goto state_70; goto out; - state_38: + state_43: ch = next(); if (ch.unicode() == 62) { token = QCss::CDC; goto found; } goto out; - state_39: + state_44: lastAcceptingPos = pos; token = QCss::NUMBER; ch = next(); if (ch.unicode() == 37) - goto state_41; + goto state_46; if (ch.unicode() == 45) - goto state_42; + goto state_47; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_69; + goto state_75; if (ch.unicode() == 92) - goto state_45; + goto state_50; if (ch.unicode() == 95) - goto state_46; + goto state_51; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_46; + goto state_51; goto out; - state_41: + state_46: lastAcceptingPos = pos; token = QCss::PERCENTAGE; goto out; - state_42: + state_47: ch = next(); if (ch.unicode() == 92) - goto state_45; + goto state_50; if (ch.unicode() == 95) - goto state_46; + goto state_51; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_46; + goto state_51; goto out; - state_43: + state_48: ch = next(); if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_39; + goto state_44; goto out; - state_44: + state_49: lastAcceptingPos = pos; token = QCss::NUMBER; ch = next(); if (ch.unicode() == 37) - goto state_41; + goto state_46; if (ch.unicode() == 45) - goto state_42; + goto state_47; if (ch.unicode() == 46) - goto state_43; + goto state_48; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_44; + goto state_49; if (ch.unicode() == 92) - goto state_45; + goto state_50; if (ch.unicode() == 95) - goto state_46; + goto state_51; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_46; + goto state_51; goto out; - state_45: + state_50: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_70; + goto state_76; if (ch.unicode() == 11) - goto state_70; + goto state_76; if (ch.unicode() >= 14 && ch.unicode() <= 47) - goto state_70; + goto state_76; if (ch.unicode() >= 58 && ch.unicode() <= 96) - goto state_70; + goto state_76; if (ch.unicode() >= 103) - goto state_70; + goto state_76; goto out; - state_46: + state_51: lastAcceptingPos = pos; token = QCss::LENGTH; ch = next(); if (ch.unicode() == 45) - goto state_71; + goto state_77; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_71; + goto state_77; if (ch.unicode() == 92) - goto state_72; + goto state_78; if (ch.unicode() == 95) - goto state_71; + goto state_77; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_71; + goto state_77; goto out; - state_47: + state_52: ch = next(); if (ch.unicode() == 45) - goto state_73; + goto state_79; goto out; - state_48: + state_53: ch = next(); if (ch.unicode() == 92) - goto state_49; + goto state_54; if (ch.unicode() == 95) - goto state_50; + goto state_55; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_50; + goto state_55; goto out; - state_49: + state_54: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_74; + goto state_80; if (ch.unicode() == 11) - goto state_74; + goto state_80; if (ch.unicode() >= 14 && ch.unicode() <= 47) - goto state_74; + goto state_80; if (ch.unicode() >= 58 && ch.unicode() <= 96) - goto state_74; + goto state_80; if (ch.unicode() >= 103) - goto state_74; + goto state_80; goto out; - state_50: + state_55: lastAcceptingPos = pos; token = QCss::ATKEYWORD_SYM; ch = next(); if (ch.unicode() == 45) - goto state_75; + goto state_81; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_75; + goto state_81; if (ch.unicode() == 92) - goto state_76; + goto state_82; if (ch.unicode() == 95) - goto state_75; + goto state_81; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_75; + goto state_81; goto out; - state_51: + state_56: lastAcceptingPos = pos; token = QCss::IDENT; ch = next(); if (ch.unicode() == 40) - goto state_52; + goto state_58; if (ch.unicode() == 45) - goto state_53; + goto state_59; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_53; + goto state_59; if (ch.unicode() == 92) - goto state_54; + goto state_60; if (ch.unicode() == 95) - goto state_53; + goto state_59; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_53; + goto state_59; goto out; - state_52: + state_58: lastAcceptingPos = pos; token = QCss::FUNCTION; goto out; - state_53: + state_59: lastAcceptingPos = pos; token = QCss::IDENT; ch = next(); if (ch.unicode() == 40) - goto state_52; + goto state_58; if (ch.unicode() == 45) - goto state_53; + goto state_59; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_53; + goto state_59; if (ch.unicode() == 92) - goto state_54; + goto state_60; if (ch.unicode() == 95) - goto state_53; + goto state_59; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_53; + goto state_59; goto out; - state_54: + state_60: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_77; + goto state_83; if (ch.unicode() == 11) - goto state_77; + goto state_83; if (ch.unicode() >= 14 && ch.unicode() <= 47) - goto state_77; + goto state_83; if (ch.unicode() >= 58 && ch.unicode() <= 96) - goto state_77; + goto state_83; if (ch.unicode() >= 103) - goto state_77; + goto state_83; goto out; - state_57: + state_63: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_30; + goto state_33; if (ch.unicode() == 11) - goto state_30; + goto state_33; if (ch.unicode() >= 14 && ch.unicode() <= 33) - goto state_30; + goto state_33; if (ch.unicode() == 34) - goto state_31; + goto state_34; if (ch.unicode() >= 35 && ch.unicode() <= 91) - goto state_30; + goto state_33; if (ch.unicode() == 92) - goto state_32; + goto state_35; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_30; + goto state_33; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_30; + goto state_33; if (ch.unicode() >= 123) - goto state_30; + goto state_33; goto out; - state_58: + state_64: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_30; + goto state_33; if (ch.unicode() == 11) - goto state_30; + goto state_33; if (ch.unicode() >= 14 && ch.unicode() <= 33) - goto state_30; + goto state_33; if (ch.unicode() == 34) - goto state_31; + goto state_34; if (ch.unicode() >= 35 && ch.unicode() <= 91) - goto state_30; + goto state_33; if (ch.unicode() == 92) - goto state_32; + goto state_35; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_30; + goto state_33; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_30; + goto state_33; if (ch.unicode() >= 123) - goto state_30; + goto state_33; goto out; - state_59: + state_65: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_30; + goto state_33; if (ch.unicode() == 11) - goto state_30; + goto state_33; if (ch.unicode() >= 14 && ch.unicode() <= 33) - goto state_30; + goto state_33; if (ch.unicode() == 34) - goto state_31; + goto state_34; if (ch.unicode() >= 35 && ch.unicode() <= 91) - goto state_30; + goto state_33; if (ch.unicode() == 92) - goto state_32; + goto state_35; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_30; + goto state_33; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_30; + goto state_33; if (ch.unicode() >= 123) - goto state_30; + goto state_33; goto out; - state_60: + state_66: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_30; + goto state_33; if (ch.unicode() == 10) - goto state_78; + goto state_84; if (ch.unicode() == 11) - goto state_30; + goto state_33; if (ch.unicode() >= 14 && ch.unicode() <= 33) - goto state_30; + goto state_33; if (ch.unicode() == 34) - goto state_31; + goto state_34; if (ch.unicode() >= 35 && ch.unicode() <= 91) - goto state_30; + goto state_33; if (ch.unicode() == 92) - goto state_32; + goto state_35; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_30; + goto state_33; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_30; + goto state_33; if (ch.unicode() >= 123) - goto state_30; + goto state_33; goto out; - state_61: + state_67: lastAcceptingPos = pos; token = QCss::HASH; ch = next(); if (ch.unicode() == 45) - goto state_61; + goto state_67; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_61; + goto state_67; if (ch.unicode() == 92) - goto state_62; + goto state_68; if (ch.unicode() == 95) - goto state_61; + goto state_67; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_61; + goto state_67; goto out; - state_62: + state_68: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_79; + goto state_85; if (ch.unicode() == 11) - goto state_79; + goto state_85; if (ch.unicode() >= 14 && ch.unicode() <= 47) - goto state_79; + goto state_85; if (ch.unicode() >= 58 && ch.unicode() <= 96) - goto state_79; + goto state_85; if (ch.unicode() >= 103) - goto state_79; + goto state_85; goto out; - state_63: + state_69: lastAcceptingPos = pos; token = QCss::HASH; ch = next(); if (ch.unicode() == 45) - goto state_61; + goto state_67; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_61; + goto state_67; if (ch.unicode() == 92) - goto state_62; + goto state_68; if (ch.unicode() == 95) - goto state_61; + goto state_67; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_61; + goto state_67; goto out; - state_64: + state_70: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_35; + goto state_39; if (ch.unicode() == 11) - goto state_35; + goto state_39; if (ch.unicode() >= 14 && ch.unicode() <= 38) - goto state_35; + goto state_39; if (ch.unicode() == 39) - goto state_36; + goto state_40; if (ch.unicode() >= 40 && ch.unicode() <= 91) - goto state_35; + goto state_39; if (ch.unicode() == 92) - goto state_37; + goto state_41; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_35; + goto state_39; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_35; + goto state_39; if (ch.unicode() >= 123) - goto state_35; + goto state_39; goto out; - state_65: + state_71: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_35; + goto state_39; if (ch.unicode() == 11) - goto state_35; + goto state_39; if (ch.unicode() >= 14 && ch.unicode() <= 38) - goto state_35; + goto state_39; if (ch.unicode() == 39) - goto state_36; + goto state_40; if (ch.unicode() >= 40 && ch.unicode() <= 91) - goto state_35; + goto state_39; if (ch.unicode() == 92) - goto state_37; + goto state_41; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_35; + goto state_39; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_35; + goto state_39; if (ch.unicode() >= 123) - goto state_35; + goto state_39; goto out; - state_66: + state_72: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_35; + goto state_39; if (ch.unicode() == 11) - goto state_35; + goto state_39; if (ch.unicode() >= 14 && ch.unicode() <= 38) - goto state_35; + goto state_39; if (ch.unicode() == 39) - goto state_36; + goto state_40; if (ch.unicode() >= 40 && ch.unicode() <= 91) - goto state_35; + goto state_39; if (ch.unicode() == 92) - goto state_37; + goto state_41; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_35; + goto state_39; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_35; + goto state_39; if (ch.unicode() >= 123) - goto state_35; + goto state_39; goto out; - state_67: + state_73: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_35; + goto state_39; if (ch.unicode() == 10) - goto state_80; + goto state_86; if (ch.unicode() == 11) - goto state_35; + goto state_39; if (ch.unicode() >= 14 && ch.unicode() <= 38) - goto state_35; + goto state_39; if (ch.unicode() == 39) - goto state_36; + goto state_40; if (ch.unicode() >= 40 && ch.unicode() <= 91) - goto state_35; + goto state_39; if (ch.unicode() == 92) - goto state_37; + goto state_41; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_35; + goto state_39; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_35; + goto state_39; if (ch.unicode() >= 123) - goto state_35; + goto state_39; goto out; - state_69: + state_75: lastAcceptingPos = pos; token = QCss::NUMBER; ch = next(); if (ch.unicode() == 37) - goto state_41; + goto state_46; if (ch.unicode() == 45) - goto state_42; + goto state_47; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_69; + goto state_75; if (ch.unicode() == 92) - goto state_45; + goto state_50; if (ch.unicode() == 95) - goto state_46; + goto state_51; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_46; + goto state_51; goto out; - state_70: + state_76: lastAcceptingPos = pos; token = QCss::LENGTH; ch = next(); if (ch.unicode() == 45) - goto state_71; + goto state_77; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_71; + goto state_77; if (ch.unicode() == 92) - goto state_72; + goto state_78; if (ch.unicode() == 95) - goto state_71; + goto state_77; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_71; + goto state_77; goto out; - state_71: + state_77: lastAcceptingPos = pos; token = QCss::LENGTH; ch = next(); if (ch.unicode() == 45) - goto state_71; + goto state_77; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_71; + goto state_77; if (ch.unicode() == 92) - goto state_72; + goto state_78; if (ch.unicode() == 95) - goto state_71; + goto state_77; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_71; + goto state_77; goto out; - state_72: + state_78: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_81; + goto state_87; if (ch.unicode() == 11) - goto state_81; + goto state_87; if (ch.unicode() >= 14 && ch.unicode() <= 47) - goto state_81; + goto state_87; if (ch.unicode() >= 58 && ch.unicode() <= 96) - goto state_81; + goto state_87; if (ch.unicode() >= 103) - goto state_81; + goto state_87; goto out; - state_73: + state_79: ch = next(); if (ch.unicode() == 45) { token = QCss::CDO; goto found; } goto out; - state_74: + state_80: lastAcceptingPos = pos; token = QCss::ATKEYWORD_SYM; ch = next(); if (ch.unicode() == 45) - goto state_75; + goto state_81; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_75; + goto state_81; if (ch.unicode() == 92) - goto state_76; + goto state_82; if (ch.unicode() == 95) - goto state_75; + goto state_81; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_75; + goto state_81; goto out; - state_75: + state_81: lastAcceptingPos = pos; token = QCss::ATKEYWORD_SYM; ch = next(); if (ch.unicode() == 45) - goto state_75; + goto state_81; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_75; + goto state_81; if (ch.unicode() == 92) - goto state_76; + goto state_82; if (ch.unicode() == 95) - goto state_75; + goto state_81; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_75; + goto state_81; goto out; - state_76: + state_82: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_83; + goto state_89; if (ch.unicode() == 11) - goto state_83; + goto state_89; if (ch.unicode() >= 14 && ch.unicode() <= 47) - goto state_83; + goto state_89; if (ch.unicode() >= 58 && ch.unicode() <= 96) - goto state_83; + goto state_89; if (ch.unicode() >= 103) - goto state_83; + goto state_89; goto out; - state_77: + state_83: lastAcceptingPos = pos; token = QCss::IDENT; ch = next(); if (ch.unicode() == 40) - goto state_52; + goto state_58; if (ch.unicode() == 45) - goto state_53; + goto state_59; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_53; + goto state_59; if (ch.unicode() == 92) - goto state_54; + goto state_60; if (ch.unicode() == 95) - goto state_53; + goto state_59; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_53; + goto state_59; goto out; - state_78: + state_84: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_30; + goto state_33; if (ch.unicode() == 11) - goto state_30; + goto state_33; if (ch.unicode() >= 14 && ch.unicode() <= 33) - goto state_30; + goto state_33; if (ch.unicode() == 34) - goto state_31; + goto state_34; if (ch.unicode() >= 35 && ch.unicode() <= 91) - goto state_30; + goto state_33; if (ch.unicode() == 92) - goto state_32; + goto state_35; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_30; + goto state_33; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_30; + goto state_33; if (ch.unicode() >= 123) - goto state_30; + goto state_33; goto out; - state_79: + state_85: lastAcceptingPos = pos; token = QCss::HASH; ch = next(); if (ch.unicode() == 45) - goto state_61; + goto state_67; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_61; + goto state_67; if (ch.unicode() == 92) - goto state_62; + goto state_68; if (ch.unicode() == 95) - goto state_61; + goto state_67; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_61; + goto state_67; goto out; - state_80: + state_86: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_35; + goto state_39; if (ch.unicode() == 11) - goto state_35; + goto state_39; if (ch.unicode() >= 14 && ch.unicode() <= 38) - goto state_35; + goto state_39; if (ch.unicode() == 39) - goto state_36; + goto state_40; if (ch.unicode() >= 40 && ch.unicode() <= 91) - goto state_35; + goto state_39; if (ch.unicode() == 92) - goto state_37; + goto state_41; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_35; + goto state_39; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_35; + goto state_39; if (ch.unicode() >= 123) - goto state_35; + goto state_39; goto out; - state_81: + state_87: lastAcceptingPos = pos; token = QCss::LENGTH; ch = next(); if (ch.unicode() == 45) - goto state_71; + goto state_77; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_71; + goto state_77; if (ch.unicode() == 92) - goto state_72; + goto state_78; if (ch.unicode() == 95) - goto state_71; + goto state_77; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_71; + goto state_77; goto out; - state_83: + state_89: lastAcceptingPos = pos; token = QCss::ATKEYWORD_SYM; ch = next(); if (ch.unicode() == 45) - goto state_75; + goto state_81; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_75; + goto state_81; if (ch.unicode() == 92) - goto state_76; + goto state_82; if (ch.unicode() == 95) - goto state_75; + goto state_81; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_75; + goto state_81; goto out; found: lastAcceptingPos = pos; diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp index 5a696807b4..933dd1bf54 100644 --- a/src/gui/text/qdistancefield.cpp +++ b/src/gui/text/qdistancefield.cpp @@ -45,6 +45,8 @@ QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(lcDistanceField, "qt.distanceField"); + namespace { enum FillHDir @@ -736,8 +738,40 @@ static bool imageHasNarrowOutlines(const QImage &im) return minHThick == 1 || minVThick == 1; } +static int QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE = 54; +static int QT_DISTANCEFIELD_DEFAULT_SCALE = 16; +static int QT_DISTANCEFIELD_DEFAULT_RADIUS = 80; +static int QT_DISTANCEFIELD_DEFAULT_HIGHGLYPHCOUNT = 2000; + +static void initialDistanceFieldFactor() +{ + static bool initialized = false; + if (initialized) + return; + initialized = true; + + if (qEnvironmentVariableIsSet("QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE")) { + QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE = qEnvironmentVariableIntValue("QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE"); + qCDebug(lcDistanceField) << "set the QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE:" << QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE; + } + + if (qEnvironmentVariableIsSet("QT_DISTANCEFIELD_DEFAULT_SCALE")) { + QT_DISTANCEFIELD_DEFAULT_SCALE = qEnvironmentVariableIntValue("QT_DISTANCEFIELD_DEFAULT_SCALE"); + qCDebug(lcDistanceField) << "set the QT_DISTANCEFIELD_DEFAULT_SCALE:" << QT_DISTANCEFIELD_DEFAULT_SCALE; + } + if (qEnvironmentVariableIsSet("QT_DISTANCEFIELD_DEFAULT_RADIUS")) { + QT_DISTANCEFIELD_DEFAULT_RADIUS = qEnvironmentVariableIntValue("QT_DISTANCEFIELD_DEFAULT_RADIUS"); + qDebug(lcDistanceField) << "set the QT_DISTANCEFIELD_DEFAULT_RADIUS:" << QT_DISTANCEFIELD_DEFAULT_RADIUS; + } + if (qEnvironmentVariableIsSet("QT_DISTANCEFIELD_DEFAULT_HIGHGLYPHCOUNT")) { + QT_DISTANCEFIELD_DEFAULT_HIGHGLYPHCOUNT = qEnvironmentVariableIntValue("QT_DISTANCEFIELD_DEFAULT_HIGHGLYPHCOUNT"); + qCDebug(lcDistanceField) << "set the QT_DISTANCEFIELD_DEFAULT_HIGHGLYPHCOUNT:" << QT_DISTANCEFIELD_DEFAULT_HIGHGLYPHCOUNT; + } +} + bool qt_fontHasNarrowOutlines(QFontEngine *fontEngine) { + initialDistanceFieldFactor(); QFontEngine *fe = fontEngine->cloneWithSize(QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE); if (!fe) return false; @@ -757,6 +791,7 @@ bool qt_fontHasNarrowOutlines(QFontEngine *fontEngine) bool qt_fontHasNarrowOutlines(const QRawFont &f) { QRawFont font = f; + initialDistanceFieldFactor(); font.setPixelSize(QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE); if (!font.isValid()) return false; @@ -769,6 +804,41 @@ bool qt_fontHasNarrowOutlines(const QRawFont &f) QRawFont::PixelAntialiasing)); } +int QT_DISTANCEFIELD_BASEFONTSIZE(bool narrowOutlineFont) +{ + initialDistanceFieldFactor(); + + if (Q_UNLIKELY(narrowOutlineFont)) + return QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE * 2; + else + return QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE; +} + +int QT_DISTANCEFIELD_SCALE(bool narrowOutlineFont) +{ + initialDistanceFieldFactor(); + + if (Q_UNLIKELY(narrowOutlineFont)) + return QT_DISTANCEFIELD_DEFAULT_SCALE / 2; + else + return QT_DISTANCEFIELD_DEFAULT_SCALE; +} + +int QT_DISTANCEFIELD_RADIUS(bool narrowOutlineFont) +{ + initialDistanceFieldFactor(); + + if (Q_UNLIKELY(narrowOutlineFont)) + return QT_DISTANCEFIELD_DEFAULT_RADIUS / 2; + else + return QT_DISTANCEFIELD_DEFAULT_RADIUS; +} + +int QT_DISTANCEFIELD_HIGHGLYPHCOUNT() +{ + initialDistanceFieldFactor(); + return QT_DISTANCEFIELD_DEFAULT_HIGHGLYPHCOUNT; +} QDistanceFieldData::QDistanceFieldData(const QDistanceFieldData &other) : QSharedData(other) diff --git a/src/gui/text/qdistancefield_p.h b/src/gui/text/qdistancefield_p.h index c6c5e6b650..27ab84332c 100644 --- a/src/gui/text/qdistancefield_p.h +++ b/src/gui/text/qdistancefield_p.h @@ -51,30 +51,24 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <qrawfont.h> #include <private/qfontengine_p.h> #include <QtCore/qshareddata.h> +#include <QtCore/qglobal.h> +#include <QLoggingCategory> QT_BEGIN_NAMESPACE -#define QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE 54 -#define QT_DISTANCEFIELD_DEFAULT_SCALE 16 -#define QT_DISTANCEFIELD_DEFAULT_RADIUS 80 -#define QT_DISTANCEFIELD_HIGHGLYPHCOUNT 2000 - -#define QT_DISTANCEFIELD_BASEFONTSIZE(NarrowOutlineFont) \ - (NarrowOutlineFont ? QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE * 2 : \ - QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE) -#define QT_DISTANCEFIELD_SCALE(NarrowOutlineFont) \ - (NarrowOutlineFont ? QT_DISTANCEFIELD_DEFAULT_SCALE / 2 : \ - QT_DISTANCEFIELD_DEFAULT_SCALE) -#define QT_DISTANCEFIELD_RADIUS(NarrowOutlineFont) \ - (NarrowOutlineFont ? QT_DISTANCEFIELD_DEFAULT_RADIUS / 2 : \ - QT_DISTANCEFIELD_DEFAULT_RADIUS) - bool Q_GUI_EXPORT qt_fontHasNarrowOutlines(const QRawFont &f); bool Q_GUI_EXPORT qt_fontHasNarrowOutlines(QFontEngine *fontEngine); +int Q_GUI_EXPORT QT_DISTANCEFIELD_BASEFONTSIZE(bool narrowOutlineFont); +int Q_GUI_EXPORT QT_DISTANCEFIELD_TILESIZE(bool narrowOutlineFont); +int Q_GUI_EXPORT QT_DISTANCEFIELD_SCALE(bool narrowOutlineFont); +int Q_GUI_EXPORT QT_DISTANCEFIELD_RADIUS(bool narrowOutlineFont); +int Q_GUI_EXPORT QT_DISTANCEFIELD_HIGHGLYPHCOUNT(); + class Q_GUI_EXPORT QDistanceFieldData : public QSharedData { public: diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 9e4f61ebee..3b24039ea6 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -1376,6 +1376,7 @@ void QFont::setStyleStrategy(StyleStrategy s) Predefined stretch values that follow the CSS naming convention. The higher the value, the more stretched the text is. + \value AnyStretch 0 Accept any stretch matched using the other QFont properties (added in Qt 5.8) \value UltraCondensed 50 \value ExtraCondensed 62 \value Condensed 75 @@ -1402,20 +1403,25 @@ int QFont::stretch() const /*! Sets the stretch factor for the font. - The stretch factor changes the width of all characters in the font - by \a factor percent. For example, setting \a factor to 150 + The stretch factor matches a condensed or expanded version of the font or + applies a stretch transform that changes the width of all characters + in the font by \a factor percent. For example, setting \a factor to 150 results in all characters in the font being 1.5 times (ie. 150%) - wider. The default stretch factor is 100. The minimum stretch - factor is 1, and the maximum stretch factor is 4000. + wider. The minimum stretch factor is 1, and the maximum stretch factor + is 4000. The default stretch factor is \c AnyStretch, which will accept + any stretch factor and not apply any transform on the font. The stretch factor is only applied to outline fonts. The stretch factor is ignored for bitmap fonts. + \note When matching a font with a native non-default stretch factor, + requesting a stretch of 100 will stretch it back to a medium width font. + \sa stretch(), QFont::Stretch */ void QFont::setStretch(int factor) { - if (factor < 1 || factor > 4000) { + if (factor < 0 || factor > 4000) { qWarning("QFont::setStretch: Parameter '%d' out of range", factor); return; } @@ -2001,7 +2007,7 @@ QString QFont::key() const QString QFont::toString() const { const QChar comma(QLatin1Char(',')); - return family() + comma + + QString fontDescription = family() + comma + QString::number( pointSizeF()) + comma + QString::number( pixelSize()) + comma + QString::number((int) styleHint()) + comma + @@ -2011,6 +2017,12 @@ QString QFont::toString() const QString::number((int) strikeOut()) + comma + QString::number((int)fixedPitch()) + comma + QString::number((int) false); + + QString fontStyle = styleName(); + if (!fontStyle.isEmpty()) + fontDescription += comma + fontStyle; + + return fontDescription; } /*! @@ -2054,7 +2066,7 @@ bool QFont::fromString(const QString &descrip) setUnderline(l[5].toInt()); setStrikeOut(l[6].toInt()); setFixedPitch(l[7].toInt()); - } else if (count == 10) { + } else if (count >= 10) { if (l[2].toInt() > 0) setPixelSize(l[2].toInt()); setStyleHint((StyleHint) l[3].toInt()); @@ -2063,7 +2075,10 @@ bool QFont::fromString(const QString &descrip) setUnderline(l[6].toInt()); setStrikeOut(l[7].toInt()); setFixedPitch(l[8].toInt()); + if (count == 11) + d->request.styleName = l[10].toString(); } + if (count >= 9 && !d->request.fixedPitch) // assume 'false' fixedPitch equals default d->request.ignorePitch = true; diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h index 85a237643c..6f0dd27fbe 100644 --- a/src/gui/text/qfont.h +++ b/src/gui/text/qfont.h @@ -40,6 +40,7 @@ #ifndef QFONT_H #define QFONT_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qwindowdefs.h> #include <QtCore/qstring.h> #include <QtCore/qsharedpointer.h> @@ -112,6 +113,7 @@ public: }; enum Stretch { + AnyStretch = 0, UltraCondensed = 50, ExtraCondensed = 62, Condensed = 75, diff --git a/src/gui/text/qfont_p.h b/src/gui/text/qfont_p.h index 3979bb27ac..9e5d0b4329 100644 --- a/src/gui/text/qfont_p.h +++ b/src/gui/text/qfont_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtGui/qfont.h" #include "QtCore/qmap.h" #include "QtCore/qhash.h" @@ -70,7 +71,7 @@ struct QFontDef inline QFontDef() : pointSize(-1.0), pixelSize(-1), styleStrategy(QFont::PreferDefault), styleHint(QFont::AnyStyle), - weight(50), fixedPitch(false), style(QFont::StyleNormal), stretch(100), + weight(50), fixedPitch(false), style(QFont::StyleNormal), stretch(QFont::AnyStretch), hintingPreference(QFont::PreferDefaultHinting), ignorePitch(true), fixedPitchComputed(0), reserved(0) { diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 283d03f22c..7fcac9b9f2 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -663,11 +663,8 @@ struct QtFontDesc static void initFontDef(const QtFontDesc &desc, const QFontDef &request, QFontDef *fontDef, bool multi) { fontDef->family = desc.family->name; - if (! desc.foundry->name.isEmpty() && desc.family->count > 1) { - fontDef->family += QString::fromLatin1(" ["); - fontDef->family += desc.foundry->name; - fontDef->family += QLatin1Char(']'); - } + if (! desc.foundry->name.isEmpty() && desc.family->count > 1) + fontDef->family += QLatin1String(" [") + desc.foundry->name + QLatin1Char(']'); if (desc.style->smoothScalable || QGuiApplicationPrivate::platformIntegration()->fontDatabase()->fontsAlwaysScalable() @@ -955,12 +952,14 @@ QFontEngine *loadSingleEngine(int script, } } - // If the font data's native stretch matches the requested stretch we need to set stretch to 100 - // to avoid the fontengine synthesizing stretch. If they didn't match exactly we need to calculate - // the new stretch factor. This only done if not matched by styleName. + // To avoid synthesized stretch we need a matching stretch to be 100 after this point. + // If stretch didn't match exactly we need to calculate the new stretch factor. + // This only done if not matched by styleName. if (style->key.stretch != 0 && request.stretch != 0 && (request.styleName.isEmpty() || request.styleName != style->styleName)) { - def.stretch = (request.stretch * 100 + 50) / style->key.stretch; + def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch; + } else { + def.stretch = 100; } engine = pfdb->fontEngine(def, size->handle); @@ -1223,7 +1222,8 @@ static int match(int script, const QFontDef &request, QtFontStyle::Key styleKey; styleKey.style = request.style; styleKey.weight = request.weight; - styleKey.stretch = request.stretch; + // Prefer a stretch closest to 100. + styleKey.stretch = request.stretch ? request.stretch : 100; char pitch = request.ignorePitch ? '*' : request.fixedPitch ? 'm' : 'p'; @@ -2225,10 +2225,18 @@ QString QFontDatabase::writingSystemSample(WritingSystem writingSystem) sample += QChar(0x05D3); break; case Arabic: + sample += QChar(0x0623); + sample += QChar(0x0628); + sample += QChar(0x062C); + sample += QChar(0x062F); + sample += QChar(0x064A); + sample += QChar(0x0629); + sample += QChar(0x0020); + sample += QChar(0x0639); + sample += QChar(0x0631); sample += QChar(0x0628); + sample += QChar(0x064A); sample += QChar(0x0629); - sample += QChar(0x062A); - sample += QChar(0x063A); break; case Syriac: sample += QChar(0x0715); @@ -2431,7 +2439,7 @@ int QFontDatabasePrivate::addAppFont(const QByteArray &fontData, const QString & } if (font.fileName.isEmpty() && !fontData.isEmpty()) - font.fileName = QString::fromLatin1(":qmemoryfonts/") + QString::number(i); + font.fileName = QLatin1String(":qmemoryfonts/") + QString::number(i); registerFont(&font); if (font.families.isEmpty()) @@ -2736,8 +2744,6 @@ void QFontDatabase::load(const QFontPrivate *d, int script) } if (req.pointSize < 0) req.pointSize = req.pixelSize*72.0/d->dpi; - if (req.stretch == 0) - req.stretch = 100; // respect the fallback families that might be passed through the request const QStringList fallBackFamilies = familyList(req); diff --git a/src/gui/text/qfontdatabase.h b/src/gui/text/qfontdatabase.h index 67cf671304..e6aef493bd 100644 --- a/src/gui/text/qfontdatabase.h +++ b/src/gui/text/qfontdatabase.h @@ -40,6 +40,7 @@ #ifndef QFONTDATABASE_H #define QFONTDATABASE_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qwindowdefs.h> #include <QtCore/qstring.h> #include <QtGui/qfont.h> diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 4f0c6d25f7..74ea8d15b7 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -418,6 +418,13 @@ glyph_metrics_t QFontEngine::boundingBox(glyph_t glyph, const QTransform &matrix return metrics; } +QFixed QFontEngine::calculatedCapHeight() const +{ + const glyph_t glyph = glyphIndex('H'); + glyph_metrics_t bb = const_cast<QFontEngine *>(this)->boundingBox(glyph); + return bb.height; +} + QFixed QFontEngine::xHeight() const { const glyph_t glyph = glyphIndex('x'); @@ -1700,6 +1707,11 @@ QFixed QFontEngineBox::ascent() const return _size; } +QFixed QFontEngineBox::capHeight() const +{ + return _size; +} + QFixed QFontEngineBox::descent() const { return 0; @@ -1842,7 +1854,11 @@ QFontEngine *QFontEngineMulti::loadEngine(int at) glyph_t QFontEngineMulti::glyphIndex(uint ucs4) const { glyph_t glyph = engine(0)->glyphIndex(ucs4); - if (glyph == 0 && ucs4 != QChar::LineSeparator) { + if (glyph == 0 + && ucs4 != QChar::LineSeparator + && ucs4 != QChar::LineFeed + && ucs4 != QChar::CarriageReturn + && ucs4 != QChar::ParagraphSeparator) { if (!m_fallbackFamiliesQueried) const_cast<QFontEngineMulti *>(this)->ensureFallbackFamiliesQueried(); for (int x = 1, n = qMin(m_engines.size(), 256); x < n; ++x) { @@ -1880,7 +1896,11 @@ bool QFontEngineMulti::stringToCMap(const QChar *str, int len, QStringIterator it(str, str + len); while (it.hasNext()) { const uint ucs4 = it.peekNext(); - if (glyphs->glyphs[glyph_pos] == 0 && ucs4 != QChar::LineSeparator) { + if (glyphs->glyphs[glyph_pos] == 0 + && ucs4 != QChar::LineSeparator + && ucs4 != QChar::LineFeed + && ucs4 != QChar::CarriageReturn + && ucs4 != QChar::ParagraphSeparator) { if (!m_fallbackFamiliesQueried) const_cast<QFontEngineMulti *>(this)->ensureFallbackFamiliesQueried(); for (int x = 1, n = qMin(m_engines.size(), 256); x < n; ++x) { @@ -2152,6 +2172,9 @@ glyph_metrics_t QFontEngineMulti::boundingBox(glyph_t glyph) QFixed QFontEngineMulti::ascent() const { return engine(0)->ascent(); } +QFixed QFontEngineMulti::capHeight() const +{ return engine(0)->capHeight(); } + QFixed QFontEngineMulti::descent() const { return engine(0)->descent(); } diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 5550dc21db..d6af6d21a2 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -414,6 +414,7 @@ QFontEngine::Properties QFreetypeFace::properties() const p.italicAngle = 0; p.capHeight = p.ascent; p.lineWidth = face->underline_thickness; + return p; } @@ -585,8 +586,7 @@ static void convertRGBToARGB_helper(const uchar *src, uint *dst, int width, int uchar green = src[x + 1]; uchar blue = src[x + 1 + offs]; LcdFilter::filterPixel(red, green, blue); - // alpha = green - *dd++ = (green << 24) | (red << 16) | (green << 8) | blue; + *dd++ = (0xFF << 24) | (red << 16) | (green << 8) | blue; } dst += width; src += src_pitch; @@ -611,8 +611,7 @@ static void convertRGBToARGB_V_helper(const uchar *src, uint *dst, int width, in uchar green = src[x + src_pitch]; uchar blue = src[x + src_pitch + offs]; LcdFilter::filterPixel(red, green, blue); - // alpha = green - *dst++ = (green << 24) | (red << 16) | (green << 8) | blue; + *dst++ = (0XFF << 24) | (red << 16) | (green << 8) | blue; } src += 3*src_pitch; } @@ -782,8 +781,14 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format, FT_Select_Size(face, i); if (face->size->metrics.ascender + face->size->metrics.descender > 0) { + FT_Pos leading = metrics.height - metrics.ascender + metrics.descender; metrics.ascender = face->size->metrics.ascender; metrics.descender = face->size->metrics.descender; + if (metrics.descender > 0 + && QString::fromUtf8(face->family_name) == QLatin1String("Courier New")) { + metrics.descender *= -1; + } + metrics.height = metrics.ascender - metrics.descender + leading; } FT_Set_Char_Size(face, xsize, ysize, 0, 0); @@ -1299,6 +1304,18 @@ QFixed QFontEngineFT::ascent() const return v; } +QFixed QFontEngineFT::capHeight() const +{ + TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(freetype->face, ft_sfnt_os2); + if (os2 && os2->version >= 2) { + lockFace(); + QFixed answer = QFixed::fromFixed(FT_MulFix(os2->sCapHeight, freetype->face->size->metrics.y_scale)); + unlockFace(); + return answer; + } + return calculatedCapHeight(); +} + QFixed QFontEngineFT::descent() const { QFixed v = QFixed::fromFixed(-metrics.descender); @@ -1317,33 +1334,25 @@ QFixed QFontEngineFT::leading() const QFixed QFontEngineFT::xHeight() const { - if (!isScalableBitmap()) { - TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(freetype->face, ft_sfnt_os2); - if (os2 && os2->sxHeight) { - lockFace(); - QFixed answer = QFixed(os2->sxHeight * freetype->face->size->metrics.y_ppem) / emSquareSize(); - unlockFace(); - return answer; - } - } else { - return QFixed(freetype->face->size->metrics.y_ppem) * scalableBitmapScaleFactor; + TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(freetype->face, ft_sfnt_os2); + if (os2 && os2->sxHeight) { + lockFace(); + QFixed answer = QFixed(os2->sxHeight * freetype->face->size->metrics.y_ppem) / emSquareSize(); + unlockFace(); + return answer; } + return QFontEngine::xHeight(); } QFixed QFontEngineFT::averageCharWidth() const { - if (!isScalableBitmap()) { - TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(freetype->face, ft_sfnt_os2); - if (os2 && os2->xAvgCharWidth) { - lockFace(); - QFixed answer = QFixed(os2->xAvgCharWidth * freetype->face->size->metrics.x_ppem) / emSquareSize(); - unlockFace(); - return answer; - } - } else { - const qreal aspectRatio = (qreal)xsize / ysize; - return QFixed::fromReal(fontDef.pixelSize * aspectRatio); + TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(freetype->face, ft_sfnt_os2); + if (os2 && os2->xAvgCharWidth) { + lockFace(); + QFixed answer = QFixed(os2->xAvgCharWidth * freetype->face->size->metrics.x_ppem) / emSquareSize(); + unlockFace(); + return answer; } return QFontEngine::averageCharWidth(); @@ -1842,7 +1851,7 @@ static inline QImage alphaMapFromGlyphData(QFontEngineFT::Glyph *glyph, QFontEng bytesPerLine = (glyph->width + 3) & ~3; break; case QFontEngine::Format_A32: - format = QImage::Format_ARGB32; + format = QImage::Format_RGB32; bytesPerLine = glyph->width * 4; break; default: diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h index 3cdf0cda47..5ca3721c71 100644 --- a/src/gui/text/qfontengine_ft_p.h +++ b/src/gui/text/qfontengine_ft_p.h @@ -209,6 +209,7 @@ private: int synthesized() const Q_DECL_OVERRIDE; QFixed ascent() const Q_DECL_OVERRIDE; + QFixed capHeight() const Q_DECL_OVERRIDE; QFixed descent() const Q_DECL_OVERRIDE; QFixed leading() const Q_DECL_OVERRIDE; QFixed xHeight() const Q_DECL_OVERRIDE; diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 132531f5bc..42610e9b70 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include "QtCore/qglobal.h" +#include <QtGui/private/qtguiglobal_p.h> #include "QtCore/qatomic.h" #include <QtCore/qvarlengtharray.h> #include <QtCore/QLinkedList> @@ -211,6 +211,7 @@ public: glyph_metrics_t tightBoundingBox(const QGlyphLayout &glyphs); virtual QFixed ascent() const = 0; + virtual QFixed capHeight() const = 0; virtual QFixed descent() const = 0; virtual QFixed leading() const = 0; virtual QFixed xHeight() const; @@ -348,6 +349,7 @@ protected: QFixed lastRightBearing(const QGlyphLayout &glyphs, bool round = false); inline void setUserData(const QVariant &userData) { m_userData = userData; } + QFixed calculatedCapHeight() const; private: struct GlyphCacheEntry { @@ -413,6 +415,7 @@ public: virtual QFontEngine *cloneWithSize(qreal pixelSize) const Q_DECL_OVERRIDE; virtual QFixed ascent() const Q_DECL_OVERRIDE; + virtual QFixed capHeight() const Q_DECL_OVERRIDE; virtual QFixed descent() const Q_DECL_OVERRIDE; virtual QFixed leading() const Q_DECL_OVERRIDE; virtual qreal maxCharWidth() const Q_DECL_OVERRIDE; @@ -450,6 +453,7 @@ public: virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0) Q_DECL_OVERRIDE; virtual QFixed ascent() const Q_DECL_OVERRIDE; + virtual QFixed capHeight() const Q_DECL_OVERRIDE; virtual QFixed descent() const Q_DECL_OVERRIDE; virtual QFixed leading() const Q_DECL_OVERRIDE; virtual QFixed xHeight() const Q_DECL_OVERRIDE; diff --git a/src/gui/text/qfontengine_qpf2.cpp b/src/gui/text/qfontengine_qpf2.cpp index 2e4af09550..110d512d39 100644 --- a/src/gui/text/qfontengine_qpf2.cpp +++ b/src/gui/text/qfontengine_qpf2.cpp @@ -459,6 +459,11 @@ QFixed QFontEngineQPF2::ascent() const return QFixed::fromReal(extractHeaderField(fontData, Tag_Ascent).value<qreal>()); } +QFixed QFontEngineQPF2::capHeight() const +{ + return calculatedCapHeight(); +} + QFixed QFontEngineQPF2::descent() const { return QFixed::fromReal(extractHeaderField(fontData, Tag_Descent).value<qreal>()); diff --git a/src/gui/text/qfontengine_qpf2_p.h b/src/gui/text/qfontengine_qpf2_p.h index 50aac245c1..e5c38ffbaf 100644 --- a/src/gui/text/qfontengine_qpf2_p.h +++ b/src/gui/text/qfontengine_qpf2_p.h @@ -172,6 +172,7 @@ public: glyph_metrics_t boundingBox(glyph_t glyph) Q_DECL_OVERRIDE; QFixed ascent() const Q_DECL_OVERRIDE; + QFixed capHeight() const Q_DECL_OVERRIDE; QFixed descent() const Q_DECL_OVERRIDE; QFixed leading() const Q_DECL_OVERRIDE; qreal maxCharWidth() const Q_DECL_OVERRIDE; diff --git a/src/gui/text/qfontengineglyphcache_p.h b/src/gui/text/qfontengineglyphcache_p.h index 54b9af71df..fd5db1ecf5 100644 --- a/src/gui/text/qfontengineglyphcache_p.h +++ b/src/gui/text/qfontengineglyphcache_p.h @@ -52,7 +52,7 @@ // -#include "QtCore/qglobal.h" +#include <QtGui/private/qtguiglobal_p.h> #include "QtCore/qatomic.h" #include <QtCore/qvarlengtharray.h> #include "private/qfont_p.h" diff --git a/src/gui/text/qfontinfo.h b/src/gui/text/qfontinfo.h index ee368e26bd..f5e05775b4 100644 --- a/src/gui/text/qfontinfo.h +++ b/src/gui/text/qfontinfo.h @@ -40,6 +40,7 @@ #ifndef QFONTINFO_H #define QFONTINFO_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qfont.h> #include <QtCore/qsharedpointer.h> diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp index 2189923b25..aca59d0288 100644 --- a/src/gui/text/qfontmetrics.cpp +++ b/src/gui/text/qfontmetrics.cpp @@ -274,6 +274,24 @@ int QFontMetrics::ascent() const return qRound(engine->ascent()); } +/*! + Returns the cap height of the font. + + \since 5.8 + + The cap height of a font is the height of a capital letter above + the baseline. It specifically is the height of capital letters + that are flat - such as H or I - as opposed to round letters such + as O, or pointed letters like A, both of which may display overshoot. + + \sa ascent() +*/ +int QFontMetrics::capHeight() const +{ + QFontEngine *engine = d->engineForScript(QChar::Script_Common); + Q_ASSERT(engine != 0); + return qRound(engine->capHeight()); +} /*! Returns the descent of the font. @@ -1138,6 +1156,24 @@ qreal QFontMetricsF::ascent() const return engine->ascent().toReal(); } +/*! + Returns the cap height of the font. + + \since 5.8 + + The cap height of a font is the height of a capital letter above + the baseline. It specifically is the height of capital letters + that are flat - such as H or I - as opposed to round letters such + as O, or pointed letters like A, both of which may display overshoot. + + \sa ascent() +*/ +qreal QFontMetricsF::capHeight() const +{ + QFontEngine *engine = d->engineForScript(QChar::Script_Common); + Q_ASSERT(engine != 0); + return engine->capHeight().toReal(); +} /*! Returns the descent of the font. diff --git a/src/gui/text/qfontmetrics.h b/src/gui/text/qfontmetrics.h index 1d7241c9f2..3eac309092 100644 --- a/src/gui/text/qfontmetrics.h +++ b/src/gui/text/qfontmetrics.h @@ -40,6 +40,7 @@ #ifndef QFONTMETRICS_H #define QFONTMETRICS_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qfont.h> #include <QtCore/qsharedpointer.h> #ifndef QT_INCLUDE_COMPAT @@ -72,6 +73,7 @@ public: { qSwap(d, other.d); } int ascent() const; + int capHeight() const; int descent() const; int height() const; int leading() const; @@ -145,6 +147,7 @@ public: void swap(QFontMetricsF &other) { qSwap(d, other.d); } qreal ascent() const; + qreal capHeight() const; qreal descent() const; qreal height() const; qreal leading() const; diff --git a/src/gui/text/qfontsubset.cpp b/src/gui/text/qfontsubset.cpp index c8f0393084..92eeaf7919 100644 --- a/src/gui/text/qfontsubset.cpp +++ b/src/gui/text/qfontsubset.cpp @@ -740,7 +740,7 @@ static void convertPath(const QPainterPath &path, QVector<TTF_POINT> *points, QV points->takeLast(); endPoints->append(points->size() - 1); } - // fall through + Q_FALLTHROUGH(); case QPainterPath::LineToElement: p.flags = OnCurve; break; @@ -966,7 +966,7 @@ static QTtfGlyph generateGlyph(int index, const QPainterPath &path, qreal advanc glyph.advanceWidth = qRound(advance * 2048. / ppem); glyph.lsb = qRound(lsb * 2048. / ppem); - if (!path.elementCount()) { + if (path.isEmpty()) { //qDebug("glyph %d is empty", index); lsb = 0; glyph.xMin = glyph.xMax = glyph.yMin = glyph.yMax = 0; diff --git a/src/gui/text/qfontsubset_p.h b/src/gui/text/qfontsubset_p.h index a7328df4ed..e7c6053beb 100644 --- a/src/gui/text/qfontsubset_p.h +++ b/src/gui/text/qfontsubset_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "private/qfontengine_p.h" QT_BEGIN_NAMESPACE diff --git a/src/gui/text/qfragmentmap_p.h b/src/gui/text/qfragmentmap_p.h index b54d7261d0..35f60ac961 100644 --- a/src/gui/text/qfragmentmap_p.h +++ b/src/gui/text/qfragmentmap_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include "QtCore/qglobal.h" +#include <QtGui/private/qtguiglobal_p.h> #include <stdlib.h> #include <private/qtools_p.h> diff --git a/src/gui/text/qglyphrun.h b/src/gui/text/qglyphrun.h index 6016925d27..6182c4f749 100644 --- a/src/gui/text/qglyphrun.h +++ b/src/gui/text/qglyphrun.h @@ -40,6 +40,7 @@ #ifndef QGLYPHRUN_H #define QGLYPHRUN_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qsharedpointer.h> #include <QtCore/qvector.h> #include <QtCore/qpoint.h> diff --git a/src/gui/text/qglyphrun_p.h b/src/gui/text/qglyphrun_p.h index 52fa03f150..5b6bdad648 100644 --- a/src/gui/text/qglyphrun_p.h +++ b/src/gui/text/qglyphrun_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "qglyphrun.h" #include "qrawfont.h" diff --git a/src/gui/text/qharfbuzzng_p.h b/src/gui/text/qharfbuzzng_p.h index 28f20338dd..95a21eedb6 100644 --- a/src/gui/text/qharfbuzzng_p.h +++ b/src/gui/text/qharfbuzzng_p.h @@ -52,6 +52,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtCore/qchar.h> #include <harfbuzz/hb.h> diff --git a/src/gui/text/qplatformfontdatabase.cpp b/src/gui/text/qplatformfontdatabase.cpp index 0d7cb204ff..b83affecdc 100644 --- a/src/gui/text/qplatformfontdatabase.cpp +++ b/src/gui/text/qplatformfontdatabase.cpp @@ -395,10 +395,8 @@ void QPlatformFontDatabase::releaseHandle(void *handle) QString QPlatformFontDatabase::fontDir() const { QString fontpath = QString::fromLocal8Bit(qgetenv("QT_QPA_FONTDIR")); - if (fontpath.isEmpty()) { - fontpath = QLibraryInfo::location(QLibraryInfo::LibrariesPath); - fontpath += QLatin1String("/fonts"); - } + if (fontpath.isEmpty()) + fontpath = QLibraryInfo::location(QLibraryInfo::LibrariesPath) + QLatin1String("/fonts"); return fontpath; } diff --git a/src/gui/text/qplatformfontdatabase.h b/src/gui/text/qplatformfontdatabase.h index 61c892ad8b..13d8cbde60 100644 --- a/src/gui/text/qplatformfontdatabase.h +++ b/src/gui/text/qplatformfontdatabase.h @@ -49,7 +49,7 @@ // source and binary incompatible with future versions of Qt. // -#include <QtCore/qconfig.h> +#include <QtGui/qtguiglobal.h> #include <QtCore/QString> #include <QtCore/QStringList> #include <QtCore/QList> diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp index 88b9e218fb..886cf5ef39 100644 --- a/src/gui/text/qrawfont.cpp +++ b/src/gui/text/qrawfont.cpp @@ -261,9 +261,13 @@ void QRawFont::loadFromData(const QByteArray &fontData, \a glyphIndex in the underlying font, using the \a transform specified. If the QRawFont is not valid, this function will return an invalid QImage. - If \a antialiasingType is set to QRawFont::SubPixelAntialiasing, then the resulting image will be - in QImage::Format_RGB32 and the RGB values of each pixel will represent the subpixel opacities of - the pixel in the rasterization of the glyph. Otherwise, the image will be in the format of + If the font is a color font, then the resulting image will contain the rendered + glyph at the current pixel size. In this case, the \a antialiasingType will be + ignored. + + Otherwise, if \a antialiasingType is set to QRawFont::SubPixelAntialiasing, then the resulting image + will be in QImage::Format_RGB32 and the RGB values of each pixel will represent the subpixel opacities + of the pixel in the rasterization of the glyph. Otherwise, the image will be in the format of QImage::Format_Indexed8 and each pixel will contain the opacity of the pixel in the rasterization. @@ -275,6 +279,9 @@ QImage QRawFont::alphaMapForGlyph(quint32 glyphIndex, AntialiasingType antialias if (!d->isValid()) return QImage(); + if (d->fontEngine->glyphFormat == QFontEngine::Format_ARGB) + return d->fontEngine->bitmapForGlyph(glyphIndex, QFixed(), transform); + if (antialiasingType == SubPixelAntialiasing) return d->fontEngine->alphaRGBMapForGlyph(glyphIndex, QFixed(), transform); @@ -332,6 +339,23 @@ qreal QRawFont::ascent() const } /*! + Returns the cap height of this QRawFont in pixel units. + + \since 5.8 + + The cap height of a font is the height of a capital letter above + the baseline. It specifically is the height of capital letters + that are flat - such as H or I - as opposed to round letters such + as O, or pointed letters like A, both of which may display overshoot. + + \sa QFontMetricsF::capHeight() +*/ +qreal QRawFont::capHeight() const +{ + return d->isValid() ? d->fontEngine->capHeight().toReal() : 0.0; +} + +/*! Returns the descent of this QRawFont in pixel units. The descent is the distance from the base line to the lowest point diff --git a/src/gui/text/qrawfont.h b/src/gui/text/qrawfont.h index aa98363229..0252e62370 100644 --- a/src/gui/text/qrawfont.h +++ b/src/gui/text/qrawfont.h @@ -40,6 +40,7 @@ #ifndef QRAWFONT_H #define QRAWFONT_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qstring.h> #include <QtCore/qiodevice.h> #include <QtCore/qglobal.h> @@ -117,6 +118,7 @@ public: QFont::HintingPreference hintingPreference() const; qreal ascent() const; + qreal capHeight() const; qreal descent() const; qreal leading() const; qreal xHeight() const; diff --git a/src/gui/text/qrawfont_p.h b/src/gui/text/qrawfont_p.h index ee54578cf9..0fc8739bfb 100644 --- a/src/gui/text/qrawfont_p.h +++ b/src/gui/text/qrawfont_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "qrawfont.h" #include "qfontengine_p.h" diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp index a10071490e..dbc2e6e558 100644 --- a/src/gui/text/qstatictext.cpp +++ b/src/gui/text/qstatictext.cpp @@ -622,6 +622,8 @@ void QStaticTextPrivate::paintText(const QPointF &topLeftPosition, QPainter *p) if (textWidth >= 0.0) line.setLineWidth(textWidth); + else + line.setLineWidth(QFIXED_MAX); height += leading; line.setPosition(QPointF(0.0, height)); height += line.height(); diff --git a/src/gui/text/qstatictext.h b/src/gui/text/qstatictext.h index 2da74825a2..00dfccc144 100644 --- a/src/gui/text/qstatictext.h +++ b/src/gui/text/qstatictext.h @@ -40,6 +40,7 @@ #ifndef QSTATICTEXT_H #define QSTATICTEXT_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qsize.h> #include <QtCore/qstring.h> #include <QtCore/qmetatype.h> diff --git a/src/gui/text/qstatictext_p.h b/src/gui/text/qstatictext_p.h index 7fdf46c101..dda566a22b 100644 --- a/src/gui/text/qstatictext_p.h +++ b/src/gui/text/qstatictext_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "qstatictext.h" #include <private/qtextureglyphcache_p.h> diff --git a/src/gui/text/qsyntaxhighlighter.h b/src/gui/text/qsyntaxhighlighter.h index 2ccb3a68b9..d87f89f0fd 100644 --- a/src/gui/text/qsyntaxhighlighter.h +++ b/src/gui/text/qsyntaxhighlighter.h @@ -40,7 +40,7 @@ #ifndef QSYNTAXHIGHLIGHTER_H #define QSYNTAXHIGHLIGHTER_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #ifndef QT_NO_SYNTAXHIGHLIGHTER diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index f824d1b369..f32c31d18e 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -438,7 +438,7 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor if (relativePos < blockIt.length()-1) ++position; - // FALL THROUGH! + Q_FALLTHROUGH(); } case QTextCursor::PreviousWord: case QTextCursor::WordLeft: @@ -590,9 +590,9 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor adjustX = false; break; } - case QTextCursor::NextCell: // fall through - case QTextCursor::PreviousCell: // fall through - case QTextCursor::NextRow: // fall through + case QTextCursor::NextCell: + case QTextCursor::PreviousCell: + case QTextCursor::NextRow: case QTextCursor::PreviousRow: { QTextTable *table = qobject_cast<QTextTable *>(priv->frameAt(position)); if (!table) diff --git a/src/gui/text/qtextcursor.h b/src/gui/text/qtextcursor.h index 9610e61b39..1a00b753ad 100644 --- a/src/gui/text/qtextcursor.h +++ b/src/gui/text/qtextcursor.h @@ -40,6 +40,7 @@ #ifndef QTEXTCURSOR_H #define QTEXTCURSOR_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qstring.h> #include <QtCore/qshareddata.h> #include <QtGui/qtextformat.h> diff --git a/src/gui/text/qtextcursor_p.h b/src/gui/text/qtextcursor_p.h index 84f912a3fa..3569317b6d 100644 --- a/src/gui/text/qtextcursor_p.h +++ b/src/gui/text/qtextcursor_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "qtextcursor.h" #include "qtextdocument.h" #include "qtextdocument_p.h" diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index bb44c19557..07aec6f019 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -94,7 +94,7 @@ bool Qt::mightBeRichText(const QString& text) ++start; // skip a leading <?xml ... ?> as for example with xhtml - if (text.mid(start, 5) == QLatin1String("<?xml")) { + if (text.midRef(start, 5).compare(QLatin1String("<?xml")) == 0) { while (start < text.length()) { if (text.at(start) == QLatin1Char('?') && start + 2 < text.length() @@ -109,12 +109,12 @@ bool Qt::mightBeRichText(const QString& text) ++start; } - if (text.mid(start, 5).toLower() == QLatin1String("<!doc")) + if (text.midRef(start, 5).compare(QLatin1String("<!doc"), Qt::CaseInsensitive) == 0) return true; int open = start; while (open < text.length() && text.at(open) != QLatin1Char('<') && text.at(open) != QLatin1Char('\n')) { - if (text.at(open) == QLatin1Char('&') && text.mid(open+1,3) == QLatin1String("lt;")) + if (text.at(open) == QLatin1Char('&') && text.midRef(open + 1, 3) == QLatin1String("lt;")) return true; // support desperate attempt of user to see <...> ++open; } @@ -3135,7 +3135,7 @@ void QTextHtmlExporter::emitTable(const QTextTable *table) html += QLatin1String("</table>"); } -void QTextHtmlExporter::emitFrame(QTextFrame::Iterator frameIt) +void QTextHtmlExporter::emitFrame(const QTextFrame::Iterator &frameIt) { if (!frameIt.atEnd()) { QTextFrame::Iterator next = frameIt; diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h index 02cfa97bce..1888088f0d 100644 --- a/src/gui/text/qtextdocument.h +++ b/src/gui/text/qtextdocument.h @@ -40,6 +40,7 @@ #ifndef QTEXTDOCUMENT_H #define QTEXTDOCUMENT_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qobject.h> #include <QtCore/qsize.h> #include <QtCore/qrect.h> diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index ffc5d7418b..7107c7c26e 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -131,7 +131,7 @@ static bool isValidBlockSeparator(QChar ch) || ch == QTextEndOfFrame; } -static bool noBlockInString(const QString &str) +static bool noBlockInString(const QStringRef &str) { return !str.contains(QChar::ParagraphSeparator) && !str.contains(QTextBeginningOfFrame) @@ -320,7 +320,7 @@ void QTextDocumentPrivate::setLayout(QAbstractTextDocumentLayout *layout) void QTextDocumentPrivate::insert_string(int pos, uint strPos, uint length, int format, QTextUndoCommand::Operation op) { // ##### optimize when only appending to the fragment! - Q_ASSERT(noBlockInString(text.mid(strPos, length))); + Q_ASSERT(noBlockInString(text.midRef(strPos, length))); split(pos); uint x = fragments.insert_single(pos, length); @@ -476,7 +476,7 @@ void QTextDocumentPrivate::insert(int pos, const QString &str, int format) if (str.size() == 0) return; - Q_ASSERT(noBlockInString(str)); + Q_ASSERT(noBlockInString(QStringRef(&str))); int strPos = text.length(); text.append(str); @@ -494,7 +494,7 @@ int QTextDocumentPrivate::remove_string(int pos, uint length, QTextUndoCommand:: Q_ASSERT(blocks.size(b) > length); Q_ASSERT(x && fragments.position(x) == (uint)pos && fragments.size(x) == length); - Q_ASSERT(noBlockInString(text.mid(fragments.fragment(x)->stringPosition, length))); + Q_ASSERT(noBlockInString(text.midRef(fragments.fragment(x)->stringPosition, length))); blocks.setSize(b, blocks.size(b)-length); @@ -629,7 +629,7 @@ void QTextDocumentPrivate::move(int pos, int to, int length, QTextUndoCommand::O if (key+1 != blocks.position(b)) { // qDebug("remove_string from %d length %d", key, X->size_array[0]); - Q_ASSERT(noBlockInString(text.mid(X->stringPosition, X->size_array[0]))); + Q_ASSERT(noBlockInString(text.midRef(X->stringPosition, X->size_array[0]))); w = remove_string(key, X->size_array[0], op); if (needsInsert) { @@ -1078,8 +1078,9 @@ void QTextDocumentPrivate::appendUndoItem(const QTextUndoCommand &c) const QTextUndoCommand &last = undoStack.at(lastIdx); if ( (last.block_part && c.block_part && !last.block_end) // part of the same block => can merge - || (!c.block_part && !last.block_part)) { // two single undo items => can merge - + || (!c.block_part && !last.block_part) // two single undo items => can merge + || (c.command == QTextUndoCommand::Inserted && last.command == c.command && (last.block_part && !c.block_part))) { + // two sequential inserts that are not part of the same block => can merge if (undoStack[lastIdx].tryMerge(c)) return; } diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h index 34849df0bb..cad9131fbf 100644 --- a/src/gui/text/qtextdocument_p.h +++ b/src/gui/text/qtextdocument_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include "QtCore/qglobal.h" +#include <QtGui/private/qtguiglobal_p.h> #include "QtCore/qstring.h" #include "QtCore/qvector.h" #include "QtCore/qlist.h" @@ -158,7 +158,7 @@ public: }; Q_DECLARE_TYPEINFO(QTextUndoCommand, Q_PRIMITIVE_TYPE); -class Q_AUTOTEST_EXPORT QTextDocumentPrivate : public QObjectPrivate +class Q_GUI_EXPORT QTextDocumentPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QTextDocument) public: @@ -378,7 +378,7 @@ private: enum StyleMode { EmitStyleTag, OmitStyleTag }; enum FrameType { TextFrame, TableFrame, RootFrame }; - void emitFrame(QTextFrame::Iterator frameIt); + void emitFrame(const QTextFrame::Iterator &frameIt); void emitTextFrame(const QTextFrame *frame); void emitBlock(const QTextBlock &block); void emitTable(const QTextTable *table); diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp index 5727b34e86..079b2e01f7 100644 --- a/src/gui/text/qtextdocumentfragment.cpp +++ b/src/gui/text/qtextdocumentfragment.cpp @@ -827,7 +827,7 @@ bool QTextHtmlImporter::closeTag() case Html_div: if (closedNode->children.isEmpty()) break; - // fall through + Q_FALLTHROUGH(); default: if (closedNode->isBlock()) blockTagClosed = true; diff --git a/src/gui/text/qtextdocumentfragment.h b/src/gui/text/qtextdocumentfragment.h index d1c1adfd0a..a56f6d06d6 100644 --- a/src/gui/text/qtextdocumentfragment.h +++ b/src/gui/text/qtextdocumentfragment.h @@ -40,6 +40,7 @@ #ifndef QTEXTDOCUMENTFRAGMENT_H #define QTEXTDOCUMENTFRAGMENT_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qstring.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/text/qtextdocumentfragment_p.h b/src/gui/text/qtextdocumentfragment_p.h index 56dff01149..e8699545f7 100644 --- a/src/gui/text/qtextdocumentfragment_p.h +++ b/src/gui/text/qtextdocumentfragment_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtGui/qtextdocument.h" #include "private/qtexthtmlparser_p.h" #include "private/qtextdocument_p.h" diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index b6cbd9617f..8ad2d85e7c 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -295,7 +295,7 @@ static inline bool isEmptyBlockBeforeTable(const QTextBlock &block, const QTextB ; } -static inline bool isEmptyBlockBeforeTable(QTextFrame::Iterator it) +static inline bool isEmptyBlockBeforeTable(const QTextFrame::Iterator &it) { QTextFrame::Iterator next = it; ++next; if (it.currentFrame()) @@ -419,7 +419,7 @@ static bool operator<(int pos, const QCheckPoint &checkPoint) #endif -static void fillBackground(QPainter *p, const QRectF &rect, QBrush brush, const QPointF &origin, QRectF gradientRect = QRectF()) +static void fillBackground(QPainter *p, const QRectF &rect, QBrush brush, const QPointF &origin, const QRectF &gradientRect = QRectF()) { p->save(); if (brush.style() >= Qt::LinearGradientPattern && brush.style() <= Qt::ConicalGradientPattern) { @@ -1504,7 +1504,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p painter->restore(); } -static QFixed flowPosition(const QTextFrame::iterator it) +static QFixed flowPosition(const QTextFrame::iterator &it) { if (it.atEnd()) return 0; @@ -2921,11 +2921,11 @@ void QTextDocumentLayout::documentChanged(int from, int oldLength, int length) { Q_D(QTextDocumentLayout); - QTextBlock startIt = document()->findBlock(from); + QTextBlock blockIt = document()->findBlock(from); QTextBlock endIt = document()->findBlock(qMax(0, from + length - 1)); if (endIt.isValid()) endIt = endIt.next(); - for (QTextBlock blockIt = startIt; blockIt.isValid() && blockIt != endIt; blockIt = blockIt.next()) + for (; blockIt.isValid() && blockIt != endIt; blockIt = blockIt.next()) blockIt.clearLayout(); if (d->docPrivate->pageSize.isNull()) @@ -2967,9 +2967,6 @@ void QTextDocumentLayout::documentChanged(int from, int oldLength, int length) d->insideDocumentChange = false; - for (QTextBlock blockIt = startIt; blockIt.isValid() && blockIt != endIt; blockIt = blockIt.next()) - emit updateBlock(blockIt); - if (d->showLayoutProgress) { const QSizeF newSize = dynamicDocumentSize(); if (newSize != d->lastReportedSize) { diff --git a/src/gui/text/qtextdocumentlayout_p.h b/src/gui/text/qtextdocumentlayout_p.h index a9cd6cf289..710c49628e 100644 --- a/src/gui/text/qtextdocumentlayout_p.h +++ b/src/gui/text/qtextdocumentlayout_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtGui/qabstracttextdocumentlayout.h" #include "QtGui/qtextoption.h" #include "QtGui/qtextobject.h" diff --git a/src/gui/text/qtextdocumentwriter.cpp b/src/gui/text/qtextdocumentwriter.cpp index a7c58ac2a6..731aaf1fcf 100644 --- a/src/gui/text/qtextdocumentwriter.cpp +++ b/src/gui/text/qtextdocumentwriter.cpp @@ -139,12 +139,9 @@ QTextDocumentWriter::QTextDocumentWriter(QIODevice *device, const QByteArray &fo format by inspecting the extension of \a fileName. */ QTextDocumentWriter::QTextDocumentWriter(const QString &fileName, const QByteArray &format) - : d(new QTextDocumentWriterPrivate(this)) + : QTextDocumentWriter(new QFile(fileName), format) { - QFile *file = new QFile(fileName); - d->device = file; d->deleteDevice = true; - d->format = format; } /*! diff --git a/src/gui/text/qtextdocumentwriter.h b/src/gui/text/qtextdocumentwriter.h index b7917e55a4..0502bf1a96 100644 --- a/src/gui/text/qtextdocumentwriter.h +++ b/src/gui/text/qtextdocumentwriter.h @@ -39,6 +39,7 @@ #ifndef QTEXTDOCUMENTWRITER_H #define QTEXTDOCUMENTWRITER_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qstring.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 4205774ee9..742b01dd1f 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -508,7 +508,7 @@ static bool bidiItemize(QTextEngine *engine, QScriptAnalysis *analysis, QBidiCon case QChar::DirAN: if (eor >= 0) appendItems(analysis, sor, eor, control, dir); - // fall through + Q_FALLTHROUGH(); case QChar::DirR: case QChar::DirAL: dir = QChar::DirR; eor = current; status.eor = QChar::DirR; break; @@ -564,7 +564,7 @@ static bool bidiItemize(QTextEngine *engine, QScriptAnalysis *analysis, QBidiCon status.eor = QChar::DirON; dir = QChar::DirAN; } - // fall through + Q_FALLTHROUGH(); case QChar::DirEN: case QChar::DirL: eor = current; @@ -744,7 +744,7 @@ static bool bidiItemize(QTextEngine *engine, QScriptAnalysis *analysis, QBidiCon status.last = QChar::DirL; break; } - // fall through + Q_FALLTHROUGH(); default: status.last = dirCurrent; } @@ -843,7 +843,7 @@ enum JustificationClass { Adds an inter character justification opportunity after the number or letter character and a space justification opportunity after the space character. */ -static inline void qt_getDefaultJustificationOpportunities(const ushort *string, int length, QGlyphLayout g, ushort *log_clusters, int spaceAs) +static inline void qt_getDefaultJustificationOpportunities(const ushort *string, int length, const QGlyphLayout &g, ushort *log_clusters, int spaceAs) { int str_pos = 0; while (str_pos < length) { @@ -877,7 +877,7 @@ static inline void qt_getDefaultJustificationOpportunities(const ushort *string, } } -static inline void qt_getJustificationOpportunities(const ushort *string, int length, const QScriptItem &si, QGlyphLayout g, ushort *log_clusters) +static inline void qt_getJustificationOpportunities(const ushort *string, int length, const QScriptItem &si, const QGlyphLayout &g, ushort *log_clusters) { Q_ASSERT(length > 0 && g.numGlyphs > 0); @@ -1292,9 +1292,7 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, #ifdef Q_OS_DARWIN if (actualFontEngine->type() == QFontEngine::Mac) { - // CTRunGetPosition has a bug which applies matrix on 10.6, so we disable - // scaling the advances for this particular version - if (QSysInfo::MacintoshVersion != QSysInfo::MV_10_6 && actualFontEngine->fontDef.stretch != 100) { + if (actualFontEngine->fontDef.stretch != 100) { QFixed stretch = QFixed(int(actualFontEngine->fontDef.stretch)) / QFixed(100); for (uint i = 0; i < num_glyphs; ++i) g.advances[i] *= stretch; @@ -1666,7 +1664,7 @@ void QTextEngine::itemize() const analysis->bidiLevel = control.baseLevel(); break; } - // fall through + Q_FALLTHROUGH(); default: analysis->flags = QScriptAnalysis::None; break; @@ -2254,7 +2252,6 @@ void QTextEngine::justify(const QScriptLine &line) case Justification_Prohibited: break; case Justification_Space: - // fall through case Justification_Arabic_Space: if (kashida_pos >= 0) { // qDebug("kashida position at %d in word", kashida_pos); @@ -2267,7 +2264,7 @@ void QTextEngine::justify(const QScriptLine &line) } kashida_pos = -1; kashida_type = Justification_Arabic_Normal; - // fall through + Q_FALLTHROUGH(); case Justification_Character: set(&justificationPoints[nPoints++], justification, g.mid(i), fontEngine(si)); maxJustify = qMax(maxJustify, justification); @@ -2715,7 +2712,7 @@ static QString stringMidRetainingBidiCC(const QString &string, suffix += c; } - return prefix + ellidePrefix + string.mid(midStart, midLength) + ellideSuffix + suffix; + return prefix + ellidePrefix + string.midRef(midStart, midLength) + ellideSuffix + suffix; } QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int flags, int from, int count) const @@ -2878,7 +2875,7 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int if (prevCharJoins(layoutData->string, rightPos)) ellipsisText.append(QChar(0x200d) /* ZWJ */); - return layoutData->string.mid(from, leftPos - from) + ellipsisText + layoutData->string.mid(rightPos, to - rightPos); + return layoutData->string.midRef(from, leftPos - from) + ellipsisText + layoutData->string.midRef(rightPos, to - rightPos); } return layoutData->string.mid(from, to - from); @@ -2970,9 +2967,8 @@ QFixed QTextEngine::calculateTabWidth(int item, QFixed x) const switch (tabSpec.type) { case QTextOption::CenterTab: length /= 2; - // fall through + Q_FALLTHROUGH(); case QTextOption::DelimiterTab: - // fall through case QTextOption::RightTab: tab = QFixed::fromReal(tabSpec.position) * dpiScale - length; if (tab < x) // default to tab taking no space @@ -3520,7 +3516,7 @@ QTextItemInt QTextItemInt::midItem(QFontEngine *fontEngine, int firstGlyphIndex, } -QTransform qt_true_matrix(qreal w, qreal h, QTransform x) +QTransform qt_true_matrix(qreal w, qreal h, const QTransform &x) { QRectF rect = x.mapRect(QRectF(0, 0, w, h)); return x * QTransform::fromTranslate(-rect.x(), -rect.y()); diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index 56c9825cc1..160e9ce490 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include "QtCore/qglobal.h" +#include <QtGui/private/qtguiglobal_p.h> #include "QtCore/qstring.h" #include "QtCore/qvarlengtharray.h" #include "QtCore/qnamespace.h" diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h index 805affd87c..28c3035537 100644 --- a/src/gui/text/qtextformat.h +++ b/src/gui/text/qtextformat.h @@ -40,6 +40,7 @@ #ifndef QTEXTFORMAT_H #define QTEXTFORMAT_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qcolor.h> #include <QtGui/qfont.h> #include <QtCore/qshareddata.h> diff --git a/src/gui/text/qtextformat_p.h b/src/gui/text/qtextformat_p.h index 45a432d2f5..f05bfaff71 100644 --- a/src/gui/text/qtextformat_p.h +++ b/src/gui/text/qtextformat_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtGui/qtextformat.h" #include "QtCore/qvector.h" diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp index d18d432f46..d4c43b3069 100644 --- a/src/gui/text/qtexthtmlparser.cpp +++ b/src/gui/text/qtexthtmlparser.cpp @@ -1872,7 +1872,7 @@ QVector<QCss::Declaration> standardDeclarationForNode(const QTextHtmlParserNode decls << decl; if (node.id == Html_b || node.id == Html_strong) break; - // Delibrate fall through + Q_FALLTHROUGH(); case Html_big: case Html_small: if (node.id != Html_th) { @@ -1893,7 +1893,7 @@ QVector<QCss::Declaration> standardDeclarationForNode(const QTextHtmlParserNode decls << decl; break; } - // Delibrate fall through + Q_FALLTHROUGH(); case Html_center: case Html_td: decl = QCss::Declaration(); @@ -1970,7 +1970,7 @@ QVector<QCss::Declaration> standardDeclarationForNode(const QTextHtmlParserNode } if (node.id != Html_pre) break; - // Delibrate fall through + Q_FALLTHROUGH(); case Html_br: case Html_nobr: decl = QCss::Declaration(); diff --git a/src/gui/text/qtexthtmlparser_p.h b/src/gui/text/qtexthtmlparser_p.h index 38c9108f75..e93d46a59f 100644 --- a/src/gui/text/qtexthtmlparser_p.h +++ b/src/gui/text/qtexthtmlparser_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtCore/qvector.h" #include "QtGui/qbrush.h" #include "QtGui/qcolor.h" diff --git a/src/gui/text/qtextimagehandler.cpp b/src/gui/text/qtextimagehandler.cpp index 18311ed161..f7117bfe0a 100644 --- a/src/gui/text/qtextimagehandler.cpp +++ b/src/gui/text/qtextimagehandler.cpp @@ -61,10 +61,10 @@ static QString resolveFileName(QString fileName, QUrl *url, qreal targetDevicePi // Also, QFile{Info}::exists works only on filepaths (not urls) if (url->isValid()) { - if (url->scheme() == QLatin1Literal("qrc")) { + if (url->scheme() == QLatin1String("qrc")) { fileName = fileName.right(fileName.length() - 3); } - else if (url->scheme() == QLatin1Literal("file")) { + else if (url->scheme() == QLatin1String("file")) { fileName = url->toLocalFile(); } } diff --git a/src/gui/text/qtextimagehandler_p.h b/src/gui/text/qtextimagehandler_p.h index 4bc19d49c3..a22c91ecbf 100644 --- a/src/gui/text/qtextimagehandler_p.h +++ b/src/gui/text/qtextimagehandler_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtCore/qobject.h" #include "QtGui/qabstracttextdocumentlayout.h" diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 3b1ee8ec03..f5827bb683 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -975,7 +975,7 @@ void QTextLayout::setFlags(int flags) } static void addSelectedRegionsToPath(QTextEngine *eng, int lineNumber, const QPointF &pos, QTextLayout::FormatRange *selection, - QPainterPath *region, QRectF boundingRect) + QPainterPath *region, const QRectF &boundingRect) { const QScriptLine &line = eng->lines[lineNumber]; @@ -1326,7 +1326,11 @@ void QTextLayout::drawCursor(QPainter *p, const QPointF &pos, int cursorPosition && (p->transform().type() > QTransform::TxTranslate); if (toggleAntialiasing) p->setRenderHint(QPainter::Antialiasing); + QPainter::CompositionMode origCompositionMode = p->compositionMode(); + if (p->paintEngine()->hasFeature(QPaintEngine::RasterOpModes)) + p->setCompositionMode(QPainter::RasterOp_NotDestination); p->fillRect(QRectF(x, y, qreal(width), (base + descent).toReal()), p->pen().brush()); + p->setCompositionMode(origCompositionMode); if (toggleAntialiasing) p->setRenderHint(QPainter::Antialiasing, false); if (d->layoutData->hasBidi) { diff --git a/src/gui/text/qtextlayout.h b/src/gui/text/qtextlayout.h index 1cbb5ac8d8..980a099b05 100644 --- a/src/gui/text/qtextlayout.h +++ b/src/gui/text/qtextlayout.h @@ -39,6 +39,7 @@ #ifndef QTEXTLAYOUT_H #define QTEXTLAYOUT_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qstring.h> #include <QtCore/qnamespace.h> #include <QtCore/qrect.h> diff --git a/src/gui/text/qtextlist.h b/src/gui/text/qtextlist.h index 71da175a14..3967787f03 100644 --- a/src/gui/text/qtextlist.h +++ b/src/gui/text/qtextlist.h @@ -40,6 +40,7 @@ #ifndef QTEXTLIST_H #define QTEXTLIST_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qtextobject.h> #include <QtCore/qobject.h> diff --git a/src/gui/text/qtextobject.h b/src/gui/text/qtextobject.h index d3f6b3d0ac..a5030de112 100644 --- a/src/gui/text/qtextobject.h +++ b/src/gui/text/qtextobject.h @@ -40,6 +40,7 @@ #ifndef QTEXTOBJECT_H #define QTEXTOBJECT_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qobject.h> #include <QtGui/qtextformat.h> #include <QtGui/qtextlayout.h> diff --git a/src/gui/text/qtextobject_p.h b/src/gui/text/qtextobject_p.h index ffc331e99d..81ab023cc3 100644 --- a/src/gui/text/qtextobject_p.h +++ b/src/gui/text/qtextobject_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtGui/qtextobject.h" #include "private/qobject_p.h" #include "QtGui/qtextdocument.h" diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp index ad537b7126..e228b3c840 100644 --- a/src/gui/text/qtextodfwriter.cpp +++ b/src/gui/text/qtextodfwriter.cpp @@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE static QString pixelToPoint(qreal pixels) { // we hardcode 96 DPI, we do the same in the ODF importer to have a perfect roundtrip. - return QString::number(pixels * 72 / 96) + QString::fromLatin1("pt"); + return QString::number(pixels * 72 / 96) + QLatin1String("pt"); } // strategies @@ -295,7 +295,7 @@ void QTextOdfWriter::writeBlock(QXmlStreamWriter &writer, const QTextBlock &bloc writer.writeStartElement(textNS, QString::fromLatin1("span")); QString fragmentText = frag.fragment().text(); - if (fragmentText.length() == 1 && fragmentText[0] == 0xFFFC) { // its an inline character. + if (fragmentText.length() == 1 && fragmentText[0] == QChar(0xFFFC)) { // its an inline character. writeInlineCharacter(writer, frag.fragment()); writer.writeEndElement(); // span continue; @@ -510,7 +510,7 @@ void QTextOdfWriter::writeBlockFormat(QXmlStreamWriter &writer, QTextBlockFormat case QTextOption::CenterTab: type = QString::fromLatin1("center"); break; } writer.writeAttribute(styleNS, QString::fromLatin1("type"), type); - if (iterator->delimiter != 0) + if (!iterator->delimiter.isNull()) writer.writeAttribute(styleNS, QString::fromLatin1("char"), iterator->delimiter); ++iterator; } diff --git a/src/gui/text/qtextodfwriter_p.h b/src/gui/text/qtextodfwriter_p.h index d4cd91f8a3..d0dd7d2b5c 100644 --- a/src/gui/text/qtextodfwriter_p.h +++ b/src/gui/text/qtextodfwriter_p.h @@ -40,7 +40,7 @@ #ifndef QTEXTODFWRITER_H #define QTEXTODFWRITER_H -#include <QtCore/qglobal.h> +#include <QtGui/private/qtguiglobal_p.h> #ifndef QT_NO_TEXTODFWRITER @@ -48,9 +48,9 @@ // W A R N I N G // ------------- // -// This file is not part of the Qt API. It exists for the convenience -// of the QLibrary class. This header file may change from -// version to version without notice, or even be removed. +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. // // We mean it. // diff --git a/src/gui/text/qtextoption.h b/src/gui/text/qtextoption.h index f9c24ffeaf..9ef9cee9bb 100644 --- a/src/gui/text/qtextoption.h +++ b/src/gui/text/qtextoption.h @@ -40,6 +40,7 @@ #ifndef QTEXTOPTION_H #define QTEXTOPTION_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qnamespace.h> #include <QtCore/qchar.h> #include <QtCore/qmetatype.h> diff --git a/src/gui/text/qtexttable.h b/src/gui/text/qtexttable.h index 14525aae25..ee8e974396 100644 --- a/src/gui/text/qtexttable.h +++ b/src/gui/text/qtexttable.h @@ -40,7 +40,7 @@ #ifndef QTEXTTABLE_H #define QTEXTTABLE_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #include <QtCore/qobject.h> #include <QtGui/qtextobject.h> diff --git a/src/gui/text/qtexttable_p.h b/src/gui/text/qtexttable_p.h index 72d9d8c639..848537272d 100644 --- a/src/gui/text/qtexttable_p.h +++ b/src/gui/text/qtexttable_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "private/qtextobject_p.h" #include "private/qtextdocument_p.h" diff --git a/src/gui/text/qzip.cpp b/src/gui/text/qzip.cpp index 7cb89543ba..b68c36fd9e 100644 --- a/src/gui/text/qzip.cpp +++ b/src/gui/text/qzip.cpp @@ -498,11 +498,13 @@ QZipReader::FileInfo QZipPrivate::fillFileInfo(int index) const // fix the file path, if broken (convert separators, eat leading and trailing ones) fileInfo.filePath = QDir::fromNativeSeparators(fileInfo.filePath); - while (!fileInfo.filePath.isEmpty() && (fileInfo.filePath.at(0) == QLatin1Char('.') || fileInfo.filePath.at(0) == QLatin1Char('/'))) - fileInfo.filePath = fileInfo.filePath.mid(1); - while (!fileInfo.filePath.isEmpty() && fileInfo.filePath.at(fileInfo.filePath.size() - 1) == QLatin1Char('/')) - fileInfo.filePath.chop(1); + QStringRef filePathRef(&fileInfo.filePath); + while (filePathRef.startsWith(QLatin1Char('.')) || filePathRef.startsWith(QLatin1Char('/'))) + filePathRef = filePathRef.mid(1); + while (filePathRef.endsWith(QLatin1Char('/'))) + filePathRef.chop(1); + fileInfo.filePath = filePathRef.toString(); return fileInfo; } diff --git a/src/gui/text/qzipreader_p.h b/src/gui/text/qzipreader_p.h index 5603f0f0d6..eed6ee6a62 100644 --- a/src/gui/text/qzipreader_p.h +++ b/src/gui/text/qzipreader_p.h @@ -40,6 +40,7 @@ #ifndef QZIPREADER_H #define QZIPREADER_H +#include <QtGui/private/qtguiglobal_p.h> #include <QtCore/qglobal.h> #ifndef QT_NO_TEXTODFWRITER diff --git a/src/gui/text/qzipwriter_p.h b/src/gui/text/qzipwriter_p.h index 0a4763855e..433bbab31e 100644 --- a/src/gui/text/qzipwriter_p.h +++ b/src/gui/text/qzipwriter_p.h @@ -39,7 +39,7 @@ #ifndef QZIPWRITER_H #define QZIPWRITER_H -#include <QtCore/qglobal.h> +#include <QtGui/private/qtguiglobal_p.h> #ifndef QT_NO_TEXTODFWRITER diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri index be60ba72cc..3fe47a6645 100644 --- a/src/gui/text/text.pri +++ b/src/gui/text/text.pri @@ -85,7 +85,7 @@ SOURCES += \ HEADERS += \ text/qplatformfontdatabase.h -contains(QT_CONFIG, harfbuzz)|contains(QT_CONFIG, system-harfbuzz) { +qtConfig(harfbuzz)|qtConfig(system-harfbuzz) { DEFINES += QT_ENABLE_HARFBUZZ_NG include($$PWD/../../3rdparty/harfbuzz_dependency.pri) |