diff options
author | Armin Berres <armin.berres@basyskom.de> | 2011-01-14 11:01:23 +0100 |
---|---|---|
committer | Armin Berres <armin.berres@basyskom.de> | 2011-01-14 11:07:45 +0100 |
commit | 14791c21b1ad3e8d9b0dec42a2cfd6e855e2f3fa (patch) | |
tree | 4c9aaefd88c81fb32f5fcefe95ec8a9650b3c516 | |
parent | dd75e4363061bd6daffe5c6415c2976d39efeceb (diff) |
Revert: "Changes: replace strings by ids in style classes and style attributes"
This temporarily reverts commmit 007270faed92e3ca9d2631d490c0a757a1f668b4.
MUniqueStringCache does not seem to be thread safe.
-rw-r--r-- | benchmarks/pt_mstylesheet/pt_mstylesheet.pro | 2 | ||||
-rw-r--r-- | src/corelib/style/mstylesheet.cpp | 40 | ||||
-rw-r--r-- | src/corelib/style/mstylesheet_p.h | 4 | ||||
-rw-r--r-- | src/corelib/style/mstylesheetattribute.cpp | 9 | ||||
-rw-r--r-- | src/corelib/style/mstylesheetattribute.h | 9 | ||||
-rw-r--r-- | src/corelib/style/mstylesheetparser.cpp | 92 | ||||
-rw-r--r-- | src/corelib/style/mstylesheetselector.cpp | 107 | ||||
-rw-r--r-- | src/corelib/style/mstylesheetselector.h | 34 | ||||
-rw-r--r-- | src/corelib/style/mstylesheetselector_p.h | 16 | ||||
-rw-r--r-- | src/corelib/style/muniquestringcache.cpp | 296 | ||||
-rw-r--r-- | src/corelib/style/muniquestringcache.h | 37 | ||||
-rw-r--r-- | src/corelib/style/style.pri | 9 | ||||
-rw-r--r-- | tests/ft_mstylesheet/ft_mstylesheet.pro | 4 | ||||
-rw-r--r-- | tests/ft_mstylesheetparser/ft_mstylesheetparser.cpp | 165 | ||||
-rw-r--r-- | tests/ft_mstylesheetparser/ft_mstylesheetparser.pro | 7 | ||||
-rw-r--r-- | tests/ut_mlogicalvalues/ut_mlogicalvalues.pro | 7 |
16 files changed, 222 insertions, 616 deletions
diff --git a/benchmarks/pt_mstylesheet/pt_mstylesheet.pro b/benchmarks/pt_mstylesheet/pt_mstylesheet.pro index 55f80b93..1755cd7f 100644 --- a/benchmarks/pt_mstylesheet/pt_mstylesheet.pro +++ b/benchmarks/pt_mstylesheet/pt_mstylesheet.pro @@ -8,9 +8,7 @@ TARGET = pt_mstylesheet SOURCES += pt_mstylesheet.cpp \ mlogicalvalues.cpp \ mstylesheetattribute.cpp \ - muniquestringcache.cpp HEADERS += pt_mstylesheet.h \ mlogicalvalues.h \ mstylesheetattribute.h \ - muniquestringcache.h diff --git a/src/corelib/style/mstylesheet.cpp b/src/corelib/style/mstylesheet.cpp index 4d3bd20c..95911214 100644 --- a/src/corelib/style/mstylesheet.cpp +++ b/src/corelib/style/mstylesheet.cpp @@ -319,7 +319,7 @@ MStyleSheetPrivate::CacheEntry *MStyleSheetPrivate::buildCacheEntry(const QList< MAttributeList::const_iterator attributesEnd = selector->attributes()->constEnd(); for (MAttributeList::const_iterator j = selector->attributes()->constBegin(); j != attributesEnd; ++j) { - MUniqueStringCache::Index propertyName = j.key(); + QByteArray propertyName = j.key(); CacheEntry::iterator iter = (*entry).find(propertyName); // Check if these settings are already in the list @@ -371,7 +371,7 @@ bool MStyleSheetPrivate::combine(MStyle *style, const CacheEntry &entry, const S // check all the attributes of this selector against the cached entry foreach(MStyleSheetAttribute * attribute, *(info.selector->attributes())) { - MOriginContainer *old = data.value(attribute->getNameID(), NULL); + MOriginContainer *old = data.value(attribute->getName(), NULL); if (old && !isHigherPriority(old, info.selector, info.classPriority, info.parentPriority)) { continue; } @@ -381,7 +381,7 @@ bool MStyleSheetPrivate::combine(MStyle *style, const CacheEntry &entry, const S info.classPriority, info.parentPriority, info.filename, info.stylesheet); - data[attribute->getNameID()] = tempMOriginCont; + data[attribute->getName()] = tempMOriginCont; tempMOriginContainers.append(tempMOriginCont); } } @@ -395,7 +395,7 @@ bool MStyleSheetPrivate::combine(MStyle *style, const CacheEntry &entry, const S bool propertyInitialized = false; // find matching attribute from hash - CacheEntry::iterator iterator = data.find(MUniqueStringCache::stringToIndex(style->metaObject()->property(i).name())); + CacheEntry::iterator iterator = data.find(QByteArray(style->metaObject()->property(i).name())); if (iterator != data.end()) { // get the attribute value @@ -461,32 +461,20 @@ bool MStyleSheetPrivate::isHigherPriority(MOriginContainer *prev, { // At this stage we either have a correct object name or we don't have object name at all. // So, select the one which has it. If both have same name or neither one has it, go further. - - if (selector->objectNameID() != prev->selector->objectNameID()) { - if (selector->objectNameID() != MUniqueStringCache::EmptyStringIndex) { - return true; - } else { - return false; - } - } + int objectName = selector->objectName().length() - prev->selector->objectName().length(); + if (objectName != 0) + return (objectName < 0) ? false : true; // Only other has mode, mode is more important than orientation - if (selector->modeID() != prev->selector->modeID()) { - if (selector->modeID() != MUniqueStringCache::EmptyStringIndex) { - return true; - } else { - return false; - } - } + int mode = selector->mode().length() - prev->selector->mode().length(); + if (mode != 0) + return (mode < 0) ? false : true; // Other one has class type and another doesn't have it - if (selector->classTypeID() != prev->selector->classTypeID()) { - if (selector->classTypeID() != MUniqueStringCache::EmptyStringIndex) { - return true; - } else { - return false; - } - } + int classType = selector->classType().length() - prev->selector->classType().length(); + if (classType != 0) + return (classType < 0) ? false : true; + // The closer one in the scene chain has more priority, 0xffff means no match unsigned int sceneOrder = EXTRACT_SCENEORDER(parentPriority); diff --git a/src/corelib/style/mstylesheet_p.h b/src/corelib/style/mstylesheet_p.h index b17d9e80..5335ab14 100644 --- a/src/corelib/style/mstylesheet_p.h +++ b/src/corelib/style/mstylesheet_p.h @@ -27,8 +27,6 @@ #define EXTRACT_SCENEORDER(priority) (priority >> 16) #define EXTRACT_INHERITANCEORDER(priority) (priority & 0xffff) -#include "muniquestringcache.h" - #include <QObject> #include <QString> #include <QList> @@ -117,7 +115,7 @@ public: const QByteArray &type, M::Orientation orientation); - typedef QHash<MUniqueStringCache::Index, MOriginContainer *> CacheEntry; + typedef QHash<QByteArray, MOriginContainer *> CacheEntry; static QHash<QByteArray, CacheEntry *> EntryCache; static QHash<QByteArray, MStyle *> StyleCache; diff --git a/src/corelib/style/mstylesheetattribute.cpp b/src/corelib/style/mstylesheetattribute.cpp index ab5cf40d..4398ef02 100644 --- a/src/corelib/style/mstylesheetattribute.cpp +++ b/src/corelib/style/mstylesheetattribute.cpp @@ -265,7 +265,7 @@ namespace { static QtDatatypeConverter DataTypeConverter; -MStyleSheetAttribute::MStyleSheetAttribute(MUniqueStringCache::Index name, const QByteArray& value, qint64 position) +MStyleSheetAttribute::MStyleSheetAttribute(const QByteArray& name, const QByteArray& value, qint64 position) : name(name), value(value), position(position) { } @@ -279,11 +279,6 @@ MStyleSheetAttribute::MStyleSheetAttribute(const MStyleSheetAttribute &other) QByteArray MStyleSheetAttribute::getName() { - return MUniqueStringCache::indexToString(name); -} - -MUniqueStringCache::Index MStyleSheetAttribute::getNameID() -{ return name; } @@ -817,7 +812,7 @@ bool MStyleSheetAttribute::writeAttribute(const QString &filename, } } - MStyleSheetParser::outputParseError(filename, "Not a valid attribute(" + QLatin1String(property.typeName()) + "): " + MUniqueStringCache::indexToString(name) + " : " + value, MStyleSheetParser::getLineNum(filename, position)); + MStyleSheetParser::outputParseError(filename, "Not a valid attribute(" + QLatin1String(property.typeName()) + "): " + name + ": " + value, MStyleSheetParser::getLineNum(filename, position)); return false; } diff --git a/src/corelib/style/mstylesheetattribute.h b/src/corelib/style/mstylesheetattribute.h index 6a206bd4..d4954062 100644 --- a/src/corelib/style/mstylesheetattribute.h +++ b/src/corelib/style/mstylesheetattribute.h @@ -29,7 +29,7 @@ #include "mnamespace.h" #include "mstyle.h" #include "mshareddata.h" -#include "muniquestringcache.h" + //! \internal /*! An attribute of a style sheet selector. @@ -46,11 +46,10 @@ class MStyleSheetAttribute }; public: - MStyleSheetAttribute(MUniqueStringCache::Index name, const QByteArray& value, qint64 position); + MStyleSheetAttribute(const QByteArray& name, const QByteArray& value, qint64 position); MStyleSheetAttribute(const MStyleSheetAttribute &other); QByteArray getName(); - MUniqueStringCache::Index getNameID(); QByteArray getValue(); qint64 getPosition(); @@ -80,14 +79,14 @@ private: bool fillProperty(const QMetaProperty &property, MStyle *style, CacheOrientationFlags cacheOrientation, const QVariant &variant, bool cache = true); - MUniqueStringCache::Index name; + QByteArray name; QByteArray value; qint64 position; //used for providing detailed css parse error output (linenumber) friend class MStyleSheetParserPrivate; }; -typedef QMap<MUniqueStringCache::Index, MStyleSheetAttribute *> MAttributeList; +typedef QMap<QByteArray, MStyleSheetAttribute *> MAttributeList; //! \internal_end #endif diff --git a/src/corelib/style/mstylesheetparser.cpp b/src/corelib/style/mstylesheetparser.cpp index fc1d0819..e474fd10 100644 --- a/src/corelib/style/mstylesheetparser.cpp +++ b/src/corelib/style/mstylesheetparser.cpp @@ -31,7 +31,6 @@ #include <QColor> #include <QDir> #include <QDateTime> -#include <QList> #ifndef Q_OS_WIN #include <utime.h> @@ -40,7 +39,7 @@ #include <sys/stat.h> namespace { - const unsigned int FILE_VERSION = 18; + const unsigned int FILE_VERSION = 17; } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -61,7 +60,7 @@ public: bool parse(QFile &file, const QFileInfo &fileInfo, bool validateOnly = false); MStyleSheetSelector *parseSelector(QFile &stream, bool *error, bool validateOnly); - MStyleSheetAttribute* parseAttribute(QFile &stream, QChar &endCharacter, bool validateOnly); + QPair<QByteArray, MStyleSheetAttribute *> parseAttribute(QFile &stream, QChar &endCharacter, bool validateOnly); bool parseAtToken(QFile &stream, bool validateOnly = false); bool importFile(const QByteArray &importedFileName, bool validateOnly = false); int getMatchIndex(const QByteArray &str, const QByteArray &charList, int from = 0) const; @@ -91,7 +90,7 @@ public: void writeStylesheetFileInfo(MStyleSheetParser::StylesheetFileInfo *selector, QDataStream &stream); MStyleSheetParser::StylesheetFileInfo * readStylesheetFileInfo(QDataStream &stream); - MStyleSheetSelector *readSelector(QDataStream &stream); + MStyleSheetSelector *readSelector(const QByteArray &file, QDataStream &stream); void writeSelector(MStyleSheetSelector *selector, QDataStream &stream); static QString getOrientationName(MStyleSheetSelector::Orientation orientation); @@ -118,7 +117,7 @@ public: bool validName(const QByteArray &name); bool validValue(const QByteArray &value); - + //cache for frequently used byte arrays to reduce dynamic memory allocations made //by byte arrays in stylesheet (attributeName, attributeValue, className, selectorName etc.) static QSet<QByteArray> stringCache; @@ -459,10 +458,10 @@ bool MStyleSheetParserPrivate::parse(QFile &file, const QFileInfo &fileInfo, boo bool error; MStyleSheetSelector *selector = parseSelector(file, &error, validateOnly); skipWhiteSpace(file); - if (selector && validateOnly) { - delete selector; - selector = 0; - } + if (selector && validateOnly) { + delete selector; + selector = 0; + } if (!selector && error) { // It wasn't selector.. there was an error.. // we don't really know what it is then so fail. @@ -819,16 +818,16 @@ MStyleSheetSelector *MStyleSheetParserPrivate::parseSelector(QFile &stream, bool qint64 startSelector = startReadPos; - MStyleSheetSelector *selector = new MStyleSheetSelector( - MUniqueStringCache::stringToIndex(objectName), - MUniqueStringCache::stringToIndex(className), - MUniqueStringCache::stringToIndex(classType), + + MStyleSheetSelector *selector = new MStyleSheetSelector(cachedString(objectName), + cachedString(className), + cachedString(classType), getOrientationFromName(cachedString(orientation)), - MUniqueStringCache::stringToIndex(mode), - MUniqueStringCache::stringToIndex(parentName), - MUniqueStringCache::stringToIndex(parentObjectName), - (MStyleSheetSelector::Flags) flags - ); + cachedString(mode), + cachedString(parsedFileName), + cachedString(parentName), + parentObjectName, + (MStyleSheetSelector::Flags) flags); // mDebug("MStyleSheetParserPrivate") << "selector found: " << selector->className() << selector->objectName(); char peek; @@ -853,8 +852,8 @@ MStyleSheetSelector *MStyleSheetParserPrivate::parseSelector(QFile &stream, bool // Parse attribute, if it fails, terminate QChar character; - MStyleSheetAttribute* result = parseAttribute(stream, character, validateOnly); - if (!result) { + QPair<QByteArray, MStyleSheetAttribute *> result = parseAttribute(stream, character, validateOnly); + if (!result.second) { mWarning("MStyleSheetParserPrivate") << "Attribute read failed in selector: " << selector->className() + '[' + selector->classType() + "]#" + selector->objectName(); @@ -866,11 +865,11 @@ MStyleSheetSelector *MStyleSheetParserPrivate::parseSelector(QFile &stream, bool } if (validateOnly) { - delete result; + delete result.second; } else { // Store and parse next - selector->attributes()->insert(result->name, result); + selector->attributes()->insert(result.first, result.second); } // last character was closing the whole selector -> we're done @@ -899,7 +898,7 @@ MStyleSheetSelector *MStyleSheetParserPrivate::parseSelector(QFile &stream, bool return NULL; } -MStyleSheetAttribute* MStyleSheetParserPrivate::parseAttribute(QFile &stream, QChar &character, bool validateOnly) +QPair<QByteArray, MStyleSheetAttribute *> MStyleSheetParserPrivate::parseAttribute(QFile &stream, QChar &character, bool validateOnly) { QByteArray name; QByteArray value; @@ -912,12 +911,13 @@ MStyleSheetAttribute* MStyleSheetParserPrivate::parseAttribute(QFile &stream, QC character = read(stream, ";}", value); if (((character == ';') || (character == '}')) && validValue(value)) { - MStyleSheetAttribute *result = new MStyleSheetAttribute( - MUniqueStringCache::stringToIndex(cachedString(MStyleSheetAttribute::attributeNameToPropertyName(name))), + cachedString(MStyleSheetAttribute::attributeNameToPropertyName(name)), cachedString(value), startReadPos); + //if value contains const references save the original value + //string before replacing const references with real values if (!validateOnly && replaceConsts(result->value)) { result->value = cachedString(result->value); if (!validValue(result->value)) { @@ -925,7 +925,7 @@ MStyleSheetAttribute* MStyleSheetParserPrivate::parseAttribute(QFile &stream, QC } } - return result; + return QPair<QByteArray, MStyleSheetAttribute *>(result->name, result); } else { outputParseError(parsedFileName, "Parse attribute failed, ';' or '}' is missing after value or the value is invalid. Multiline attributes are not supported.", getLineNum(stream, startReadPos)); } @@ -933,7 +933,7 @@ MStyleSheetAttribute* MStyleSheetParserPrivate::parseAttribute(QFile &stream, QC outputParseError(parsedFileName, "Parse attribute failed, ':' is missing after name or the name is invalid.", getLineNum(stream, startReadPos)); } - return 0; + return QPair<QByteArray, MStyleSheetAttribute *> ("", NULL); } QString MStyleSheetParserPrivate::createBinaryFilename(const QString &filename) const @@ -1118,7 +1118,6 @@ bool MStyleSheetParserPrivate::dump(const QString &binaryFilename) QDataStream stream(&file); stream << FILE_VERSION; stream << timestamps; - if (logicalValues) { stream << logicalValues->timestamps(); } else { @@ -1172,23 +1171,23 @@ MStyleSheetParser::StylesheetFileInfo * MStyleSheetParserPrivate::readStylesheet stream >> selectorCount; // read all selectors without parent for (int i = 0; i < selectorCount; ++i) { - MStyleSheetSelector *selector = readSelector(stream); + MStyleSheetSelector *selector = readSelector(fi->filename, stream); fi->selectors.push_back(selector); } // read all selectors with parent stream >> selectorCount; for (int i = 0; i < selectorCount; ++i) { - MStyleSheetSelector *selector = readSelector(stream); + MStyleSheetSelector *selector = readSelector(fi->filename, stream); fi->parentSelectors.push_back(selector); } return fi; } -MStyleSheetSelector *MStyleSheetParserPrivate::readSelector(QDataStream &stream) +MStyleSheetSelector *MStyleSheetParserPrivate::readSelector(const QByteArray &file, QDataStream &stream) { - MUniqueStringCache::Index parentName, parentObjectName, objectName, className, classType, mode; + QByteArray parentName, parentObjectName, objectName, className, classType, mode; int flags, orientation; stream >> parentName; @@ -1200,12 +1199,18 @@ MStyleSheetSelector *MStyleSheetParserPrivate::readSelector(QDataStream &stream) stream >> orientation; stream >> mode; - MStyleSheetSelector *selector = new MStyleSheetSelector( - objectName, + parentName = cachedString(parentName); + objectName = cachedString(objectName); + className = cachedString(className); + classType = cachedString(classType); + mode = cachedString(mode); + + MStyleSheetSelector *selector = new MStyleSheetSelector(objectName, className, classType, (MStyleSheetSelector::Orientation) orientation, mode, + file, parentName, parentObjectName, (MStyleSheetSelector::Flags) flags); @@ -1217,8 +1222,7 @@ MStyleSheetSelector *MStyleSheetParserPrivate::readSelector(QDataStream &stream) // read attributes one by one for (int attributeIndex = 0; attributeIndex < attributeCount; ++attributeIndex) { - - MUniqueStringCache::Index name; + QByteArray name; stream >> name; QByteArray value; stream >> value; @@ -1226,7 +1230,7 @@ MStyleSheetSelector *MStyleSheetParserPrivate::readSelector(QDataStream &stream) stream >> position; MStyleSheetAttribute *attribute = new MStyleSheetAttribute( - name, + cachedString(name), cachedString(value), position); @@ -1238,14 +1242,14 @@ MStyleSheetSelector *MStyleSheetParserPrivate::readSelector(QDataStream &stream) void MStyleSheetParserPrivate::writeSelector(MStyleSheetSelector *selector, QDataStream &stream) { - stream << selector->parentNameID(); - stream << selector->parentObjectNameID(); + stream << selector->parentName(); + stream << selector->parentObjectName(); stream << (int) selector->flags(); - stream << selector->objectNameID(); - stream << selector->classNameID(); - stream << selector->classTypeID(); + stream << selector->objectName(); + stream << selector->className(); + stream << selector->classType(); stream << (int) selector->orientation(); - stream << selector->modeID(); + stream << selector->mode(); stream << selector->attributes()->count(); @@ -1257,11 +1261,13 @@ void MStyleSheetParserPrivate::writeSelector(MStyleSheetSelector *selector, QDat << __FILE__ << "line:" << __LINE__ << "function:" << __PRETTY_FUNCTION__; } + MAttributeList::const_iterator attributesEnd = selector->attributes()->constEnd(); for (MAttributeList::const_iterator attributeIterator = selector->attributes()->constBegin(); attributeIterator != attributesEnd; ++attributeIterator) { + stream << attributeIterator.value()->name; stream << attributeIterator.value()->value; stream << attributeIterator.value()->position; diff --git a/src/corelib/style/mstylesheetselector.cpp b/src/corelib/style/mstylesheetselector.cpp index e8e50556..e7ee7e27 100644 --- a/src/corelib/style/mstylesheetselector.cpp +++ b/src/corelib/style/mstylesheetselector.cpp @@ -23,19 +23,20 @@ void MStyleSheetSelectorPrivate::operator=(const MStyleSheetSelectorPrivate &other) { - objectName = other.objectName; - className = other.className; - classType = other.classType; + objName = other.objName; + clName = other.clName; + clType = other.clType; screenOrientation = other.screenOrientation; objectMode = other.objectMode; + filename = other.filename; parentName = other.parentName; parentObjectName = other.parentObjectName; flags = other.flags; // copy attributes - MAttributeList::const_iterator otherAttributesEnd = other.attributes.constEnd(); + MAttributeList::const_iterator otherDataEnd = other.data.constEnd(); - for (MAttributeList::const_iterator iterator = other.attributes.begin(); iterator != otherAttributesEnd; ++iterator) { + for (MAttributeList::const_iterator iterator = other.data.begin(); iterator != otherDataEnd; ++iterator) { // attribute to copy MStyleSheetAttribute *source = *iterator; @@ -43,47 +44,51 @@ void MStyleSheetSelectorPrivate::operator=(const MStyleSheetSelectorPrivate &oth MStyleSheetAttribute *copy = new MStyleSheetAttribute(*source); // add copy of attribute to data list - attributes.insert(iterator.key(), copy); + data.insert(iterator.key(), copy); } } -MStyleSheetSelector::MStyleSheetSelector(const MUniqueStringCache::Index objectName, - const MUniqueStringCache::Index className, - const MUniqueStringCache::Index classType, +MStyleSheetSelector::MStyleSheetSelector(const QByteArray &objectName, + const QByteArray &className, + const QByteArray &classType, const Orientation orientation, - const MUniqueStringCache::Index mode, - const MUniqueStringCache::Index parentName, + const QByteArray &mode, + const QByteArray &filename, + const QByteArray &parentName, Flags flags) : d_ptr(new MStyleSheetSelectorPrivate) { Q_D(MStyleSheetSelector); - d->objectName = objectName; - d->className = className; - d->classType = classType; + d->objName = objectName; + d->clName = className; + d->clType = classType; d->screenOrientation = orientation; d->objectMode = mode; + d->filename = filename; d->parentName = parentName; - d->parentObjectName = MUniqueStringCache::UndefinedIndex; + d->parentObjectName = QByteArray(); d->flags = flags; } -MStyleSheetSelector::MStyleSheetSelector(const MUniqueStringCache::Index objectName, - const MUniqueStringCache::Index className, - const MUniqueStringCache::Index classType, +MStyleSheetSelector::MStyleSheetSelector(const QByteArray &objectName, + const QByteArray &className, + const QByteArray &classType, const Orientation orientation, - const MUniqueStringCache::Index mode, - const MUniqueStringCache::Index parentName, - const MUniqueStringCache::Index parentObjectName, + const QByteArray &mode, + const QByteArray &filename, + const QByteArray &parentName, + const QByteArray &parentObjectName, Flags flags) : d_ptr(new MStyleSheetSelectorPrivate) { Q_D(MStyleSheetSelector); - d->objectName = objectName; - d->className = className; - d->classType = classType; + d->objName = objectName; + d->clName = className; + d->clType = classType; d->screenOrientation = orientation; d->objectMode = mode; + d->filename = filename; d->parentName = parentName; d->parentObjectName = parentObjectName; d->flags = flags; @@ -99,8 +104,8 @@ MStyleSheetSelector::~MStyleSheetSelector() { Q_D(MStyleSheetSelector); - qDeleteAll(d->attributes); - d->attributes.clear(); + qDeleteAll(d->data); + d->data.clear(); delete d_ptr; } @@ -108,37 +113,37 @@ MStyleSheetSelector::~MStyleSheetSelector() MAttributeList *MStyleSheetSelector::attributes() { Q_D(MStyleSheetSelector); - return &d->attributes; + return &d->data; } QByteArray MStyleSheetSelector::parentName() const { Q_D(const MStyleSheetSelector); - return MUniqueStringCache::indexToString(d->parentName); + return d->parentName; } QByteArray MStyleSheetSelector::parentObjectName() const { Q_D(const MStyleSheetSelector); - return MUniqueStringCache::indexToString(d->parentObjectName); + return d->parentObjectName; } QByteArray MStyleSheetSelector::objectName() const { Q_D(const MStyleSheetSelector); - return MUniqueStringCache::indexToString(d->objectName); + return d->objName; } QByteArray MStyleSheetSelector::className() const { Q_D(const MStyleSheetSelector); - return MUniqueStringCache::indexToString(d->className); + return d->clName; } QByteArray MStyleSheetSelector::classType() const { Q_D(const MStyleSheetSelector); - return MUniqueStringCache::indexToString(d->classType); + return d->clType; } MStyleSheetSelector::Orientation MStyleSheetSelector::orientation() const @@ -150,7 +155,7 @@ MStyleSheetSelector::Orientation MStyleSheetSelector::orientation() const QByteArray MStyleSheetSelector::mode() const { Q_D(const MStyleSheetSelector); - return MUniqueStringCache::indexToString(d->objectMode); + return d->objectMode; } MStyleSheetSelector::Flags MStyleSheetSelector::flags() const @@ -159,40 +164,4 @@ MStyleSheetSelector::Flags MStyleSheetSelector::flags() const return d->flags; } -MUniqueStringCache::Index MStyleSheetSelector::objectNameID() const -{ - Q_D(const MStyleSheetSelector); - return d->objectName; -} - -MUniqueStringCache::Index MStyleSheetSelector::classNameID() const -{ - Q_D(const MStyleSheetSelector); - return d->className; -} - -MUniqueStringCache::Index MStyleSheetSelector::classTypeID() const -{ - Q_D(const MStyleSheetSelector); - return d->classType; -} - -MUniqueStringCache::Index MStyleSheetSelector::modeID() const -{ - Q_D(const MStyleSheetSelector); - return d->objectMode; -} - -MUniqueStringCache::Index MStyleSheetSelector::parentNameID() const -{ - Q_D(const MStyleSheetSelector); - return d->parentName; -} - -MUniqueStringCache::Index MStyleSheetSelector::parentObjectNameID() const -{ - Q_D(const MStyleSheetSelector); - return d->parentObjectName; -} - diff --git a/src/corelib/style/mstylesheetselector.h b/src/corelib/style/mstylesheetselector.h index e9cfda21..a3f051ae 100644 --- a/src/corelib/style/mstylesheetselector.h +++ b/src/corelib/style/mstylesheetselector.h @@ -22,7 +22,6 @@ #include "mexport.h" #include "mstylesheetattribute.h" -#include "muniquestringcache.h" #include <QByteArray> #include <QVariant> @@ -68,15 +67,16 @@ public: * \param subclasses A flag indicating whether the su * \deprecated Please use the new constructor */ - explicit MStyleSheetSelector(MUniqueStringCache::Index objectName = MUniqueStringCache::UndefinedIndex, - MUniqueStringCache::Index className = MUniqueStringCache::UndefinedIndex, - MUniqueStringCache::Index classType = MUniqueStringCache::UndefinedIndex, + + explicit MStyleSheetSelector(const QByteArray &objectName = "", + const QByteArray &className = "", + const QByteArray &classType = "", const Orientation orientation = UndefinedOrientation, - MUniqueStringCache::Index mode = MUniqueStringCache::UndefinedIndex, - MUniqueStringCache::Index parentName = MUniqueStringCache::UndefinedIndex, + const QByteArray &mode = "", + const QByteArray &filename = "", + const QByteArray &parentName = "", Flags flags = (Flags) 0); - /*! * MStyleSheetSelector constructor * \param objectName target object name of this selector, can be empty @@ -93,20 +93,16 @@ public: * \param subclasses A flag indicating whether the su */ - explicit MStyleSheetSelector(MUniqueStringCache::Index objectName, - MUniqueStringCache::Index className, - MUniqueStringCache::Index classType, + explicit MStyleSheetSelector(const QByteArray &objectName, + const QByteArray &className, + const QByteArray &classType, const Orientation orientation, - MUniqueStringCache::Index mode, - MUniqueStringCache::Index parentName, - MUniqueStringCache::Index parentObjectName, + const QByteArray &mode, + const QByteArray &filename, + const QByteArray &parentName, + const QByteArray &parentObjectName, Flags flags = (Flags) 0); - MUniqueStringCache::Index objectNameID() const; - MUniqueStringCache::Index classNameID() const; - MUniqueStringCache::Index classTypeID() const; - MUniqueStringCache::Index modeID() const; - MUniqueStringCache::Index parentNameID() const; - MUniqueStringCache::Index parentObjectNameID() const; + /*! * Copy constructor diff --git a/src/corelib/style/mstylesheetselector_p.h b/src/corelib/style/mstylesheetselector_p.h index ee04304c..0f41615d 100644 --- a/src/corelib/style/mstylesheetselector_p.h +++ b/src/corelib/style/mstylesheetselector_p.h @@ -27,23 +27,23 @@ class MStyleSheetSelectorPrivate { public: //! Parent class name, represented by this selector. - MUniqueStringCache::Index parentName; + QByteArray parentName; //! Parent class object name, represented by this selector. - MUniqueStringCache::Index parentObjectName; + QByteArray parentObjectName; //! Object name, represented by this selector. - MUniqueStringCache::Index objectName; + QByteArray objName; //! Class name, represented by this selector. - MUniqueStringCache::Index className; + QByteArray clName; //! Type, represented by this selector. - MUniqueStringCache::Index classType; + QByteArray clType; //! Screen orientation type, represented by this selector. MStyleSheetSelector::Orientation screenOrientation; //! Object mode, represented by this selector. - MUniqueStringCache::Index objectMode; + QByteArray objectMode; //! Attribute list of this selector (ClassName#ObjectName.Orientation:Mode). - MAttributeList attributes; + MAttributeList data; //! Name of the css file where the selector was created. - MUniqueStringCache::Index fileName; + QByteArray filename; //! Flags indicating whether this is a special kind of selector. MStyleSheetSelector::Flags flags; diff --git a/src/corelib/style/muniquestringcache.cpp b/src/corelib/style/muniquestringcache.cpp deleted file mode 100644 index a2eb504d..00000000 --- a/src/corelib/style/muniquestringcache.cpp +++ /dev/null @@ -1,296 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (directui@nokia.com) -** -** This file is part of libmeegotouch. -** -** If you have questions regarding the use of this file, please contact -** Nokia at directui@nokia.com. -** -** This library is free software; you can redistribute it and/or -** modify it under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation -** and appearing in the file LICENSE.LGPL included in the packaging -** of this file. -** -****************************************************************************/ - -#include "muniquestringcache.h" - -#include "mdebug.h" - -#include <QFile> -#include <QFileInfo> -#include <QDir> -#include <QSystemSemaphore> -#include <QHash> -#include <QByteArray> -#include <QElapsedTimer> -#include <QCoreApplication> - -const int MAX_CACHE_SIZE = 1024*1024; -#define CACHE_NAME "MTF_UNIQUE_STRING_CACHE" - -class UniqueStringCacheMappedMemory -{ -public: - UniqueStringCacheMappedMemory() - : cacheFile(createCacheFileName()), - accessSemaphore(QLatin1String(CACHE_NAME "_SEMAPHORE"), 1), - attached(false) - { - if (!accessSemaphore.acquire()) { - qWarning() << "Unable to aquire semaphore:" << accessSemaphore.errorString(); - return; - } - - attachToCache(); - - accessSemaphore.release(); - } - - bool isAttached() const { return attached; } - - uchar* data() { return rawMappedMemory; } - QString errorString() { return accessSemaphore.errorString(); } - - ~UniqueStringCacheMappedMemory() - { - } - -private: - friend class UniqueStringCacheMappedMemoryLocker; - bool lock() { return accessSemaphore.acquire(); } - bool unlock() { return accessSemaphore.release(); } - - void attachToCache() - { - if (!cacheFile.exists()) { - if (!initializeCache()) { - attached = false; - return; - } - } - - if (!cacheFile.open(QIODevice::ReadWrite)) { - mWarning("UniqueStringCacheMappedMemory") << "Could not open" << - cacheFile.fileName(); - return; - } - - if (cacheFile.size() != MAX_CACHE_SIZE) { - mWarning("UniqueStringCacheMappedMemory") << "Wrong cache file size" << - cacheFile.size() << "Expected:" << MAX_CACHE_SIZE; - return; - } - - rawMappedMemory = cacheFile.map(0, MAX_CACHE_SIZE); - - attached = true; - - cacheFile.close(); - } - - bool initializeCache() { - if (!cacheFile.open(QFile::WriteOnly)) { - //Maybe it failed because the directory doesn't exist - QDir().mkpath(QFileInfo(cacheFile.fileName()).absolutePath()); - if (!cacheFile.open(QFile::WriteOnly)) { - mWarning("UniqueStringCacheMappedMemory") << - "Wrong permissions for cache directory. Cannot create" << - cacheFile.fileName(); - return false; - } - } - cacheFile.resize(MAX_CACHE_SIZE); - cacheFile.close(); - return true; - } - - QString createCacheFileName() { - QString cacheDir; -#ifdef Q_OS_WIN - QDir appDir(QCoreApplication::applicationDirPath()); - appDir.cdUp(); - - cacheDir = appDir.absolutePath() - + QDir::separator() + "var" - + QDir::separator() + "cache" - + QDir::separator() + "meegotouch"; -#else - cacheDir = QString(CACHEDIR); -#endif - cacheDir = cacheDir - + QDir::separator() + "css" - + QDir::separator() + CACHE_NAME; - - return cacheDir; - } - - QFile cacheFile; - QSystemSemaphore accessSemaphore; - uchar* rawMappedMemory; - bool attached; -}; - -Q_GLOBAL_STATIC(UniqueStringCacheMappedMemory, uniqueStringCacheMappedMemory) - - -class UniqueStringCacheMappedMemoryLocker -{ -public: - UniqueStringCacheMappedMemoryLocker(UniqueStringCacheMappedMemory *cache) - : cache(cache->lock() ? cache : (UniqueStringCacheMappedMemory *)0) - { - if (!cache) { - mWarning("UniqueStringCacheMappedMemoryLocker") << "Unable to lock unique string cache" << cache->errorString(); - } - } - - bool isLocked() const - { - return cache; - } - - ~UniqueStringCacheMappedMemoryLocker() - { - if (!cache) { - return; - } - if (!cache->unlock()) { - mWarning("UniqueStringCacheMappedMemoryLocker") << "Unable to unlock unique string cache" << cache->errorString(); - } - } - -private: - UniqueStringCacheMappedMemory *cache; -}; - -// mapping id => string -typedef QVector<QByteArray> IdToStringCache; -Q_GLOBAL_STATIC(IdToStringCache, idToStringCache) -// mapping string => id -typedef QHash<QByteArray, int> StringToIdCache; -Q_GLOBAL_STATIC(StringToIdCache, stringToIdCache) -static int offset = sizeof(int); - -int insert_string_to_cache(const QByteArray &string); - -// fills our datastructures from memory -// this method can be called several times to update the internal representation -// if the cache has been changed by another application -void fill_unique_string_cache() { - uchar *rawCache = uniqueStringCacheMappedMemory()->data(); - int elementsInCache = *reinterpret_cast<int*>(rawCache); - int oldSize = idToStringCache()->count(); - idToStringCache()->resize(elementsInCache); - - for (int i = oldSize; i < elementsInCache; ++i) { - uchar *stringAdress = rawCache + offset; - int stringLength = *reinterpret_cast<int*>(stringAdress); - // TODO: figure out if we can delay creating the actual byte arrays. as long as stringForId() - // is not called we do not need to actually create them. - // first: check if this makes a difference at all - QByteArray string = QByteArray::fromRawData(reinterpret_cast<const char*>(stringAdress + sizeof(int)), stringLength); - offset += sizeof(int) + stringLength; - - (*idToStringCache())[i] = string; - stringToIdCache()->insert(string, i); - } - if (elementsInCache == 0) { - // we want the empty string as first element - insert_string_to_cache(QByteArray()); - } - - qWarning() << "elements in cache:" << elementsInCache << ", " << (float)offset/MAX_CACHE_SIZE*100 << "% filled cache"; -} - -// insert one string into the cache, makes sure to handle it gracefully when the cache has -// changed before it has been locked -int insert_string_to_cache(const QByteArray &string) { - uchar *rawCache = uniqueStringCacheMappedMemory()->data(); - int elementsInCache = *reinterpret_cast<int*>(rawCache); - if (elementsInCache != idToStringCache()->count()) { - // cache has changed, check if the string has been added - // in the meanwhile - fill_unique_string_cache(); - StringToIdCache::const_iterator it = stringToIdCache()->constFind(string); - if (it != stringToIdCache()->constEnd()) { - return *it; - } - } - - ++*reinterpret_cast<int*>(rawCache); - - uchar *stringAdress = rawCache + offset; - *reinterpret_cast<int*>(stringAdress) = string.length(); - memcpy(stringAdress + sizeof(int), string.constData(), string.length()); - - offset += sizeof(int) + string.length(); - if (offset >= MAX_CACHE_SIZE) { - qFatal("unique string cache is full"); - } - - idToStringCache()->append(string); - stringToIdCache()->insert(string, idToStringCache()->count() - 1); - - return idToStringCache()->count() - 1; -} - -// triggers initialization of our data structures from the cache if this -// did not happen yet -void initially_fill_cache() { - static bool cacheFilled = false; - if (!cacheFilled) { - QElapsedTimer timer; - timer.start(); - UniqueStringCacheMappedMemoryLocker locker(uniqueStringCacheMappedMemory()); - if (!locker.isLocked()) { - return; - } - fill_unique_string_cache(); - - cacheFilled = true; - } -} - -bool MUniqueStringCache::isAttached() -{ - UniqueStringCacheMappedMemoryLocker locker(uniqueStringCacheMappedMemory()); - if (!locker.isLocked()) { - return false; - } - return uniqueStringCacheMappedMemory()->isAttached(); -} - -MUniqueStringCache::Index MUniqueStringCache::stringToIndex(const QByteArray& string) -{ - initially_fill_cache(); - StringToIdCache::const_iterator it = stringToIdCache()->constFind(string); - if (it != stringToIdCache()->constEnd()) { - return *it; - } - - // string is unknown, we need to add it to the cache - UniqueStringCacheMappedMemoryLocker locker(uniqueStringCacheMappedMemory()); - if (!locker.isLocked()) { - return UndefinedIndex; - } - - return insert_string_to_cache(string); -} - -QByteArray MUniqueStringCache::indexToString(Index id) -{ - initially_fill_cache(); - if (id < 0) { - return QByteArray(); - } else if (id >= idToStringCache()->count()) { - mWarning("MUniqueStringCache::indexToString") << "Id" << id << "is unknown. Has the string cache been deleted?"; - return QByteArray(); - } - - return idToStringCache()->at(id); -} diff --git a/src/corelib/style/muniquestringcache.h b/src/corelib/style/muniquestringcache.h deleted file mode 100644 index 7a4349c7..00000000 --- a/src/corelib/style/muniquestringcache.h +++ /dev/null @@ -1,37 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (directui@nokia.com) -** -** This file is part of libmeegotouch. -** -** If you have questions regarding the use of this file, please contact -** Nokia at directui@nokia.com. -** -** This library is free software; you can redistribute it and/or -** modify it under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation -** and appearing in the file LICENSE.LGPL included in the packaging -** of this file. -** -****************************************************************************/ - -#ifndef MUNIQUESTRINGCACHE_H -#define MUNIQUESTRINGCACHE_H - -#include <QByteArray> - -class MUniqueStringCache -{ -public: - typedef int Index; - static const Index UndefinedIndex = -1; - static const Index EmptyStringIndex = 0; - - static bool isAttached(); - static Index stringToIndex(const QByteArray& string); - static QByteArray indexToString(Index id); -}; - -#endif // MUNIQUESTRINGCACHE_H diff --git a/src/corelib/style/style.pri b/src/corelib/style/style.pri index 93cb86b2..2b8ca2ee 100644 --- a/src/corelib/style/style.pri +++ b/src/corelib/style/style.pri @@ -15,8 +15,7 @@ PRIVATE_HEADERS += \ $$STYLE_SRC_DIR/mstylesheetselector.h \ $$STYLE_SRC_DIR/mstylesheetattribute.h \ $$STYLE_SRC_DIR/mstylesheet.h \ - $$STYLE_SRC_DIR/mstylesheetselector_p.h \ - $$STYLE_SRC_DIR/muniquestringcache.h + $$STYLE_SRC_DIR/mstylesheetselector_p.h STYLE_HEADERS += \ $$STYLE_SRC_DIR/mstyle.h \ @@ -49,7 +48,7 @@ STYLE_HEADERS += \ $$STYLE_SRC_DIR/mcontentfadeandslideanimationstyle.h \ PUBLIC_HEADERS += \ - $$STYLE_HEADERS + $$STYLE_HEADERS \ SOURCES += \ $$STYLE_SRC_DIR/mstyle.cpp \ @@ -57,6 +56,4 @@ SOURCES += \ $$STYLE_SRC_DIR/mstylesheet.cpp \ $$STYLE_SRC_DIR/mstylesheetparser.cpp \ $$STYLE_SRC_DIR/mstylesheetselector.cpp \ - $$STYLE_SRC_DIR/mstylesheetattribute.cpp \ - $$STYLE_SRC_DIR/muniquestringcache.cpp \ - + $$STYLE_SRC_DIR/mstylesheetattribute.cpp diff --git a/tests/ft_mstylesheet/ft_mstylesheet.pro b/tests/ft_mstylesheet/ft_mstylesheet.pro index 1207f2b6..78f8a940 100644 --- a/tests/ft_mstylesheet/ft_mstylesheet.pro +++ b/tests/ft_mstylesheet/ft_mstylesheet.pro @@ -11,8 +11,7 @@ STYLE_HEADERS += testobjectstyle.h testobject2style.h testobject3style.h SOURCES += \ ft_mstylesheet.cpp \ $$MSRCDIR/corelib/theme/mlogicalvalues.cpp \ - $$MSRCDIR/corelib/style/mstylesheetattribute.cpp \ - $$MSRCDIR/corelib/style/muniquestringcache.cpp + $$MSRCDIR/corelib/style/mstylesheetattribute.cpp HEADERS += \ ft_mstylesheet.h \ @@ -24,7 +23,6 @@ HEADERS += \ testwidget3.h \ $$MSRCDIR/corelib/theme/mlogicalvalues.h \ $$MSRCDIR/corelib/style/mstylesheetattribute.h \ - $$MSRCDIR/corelib/style/muniquestringcache.h \ $$STYLE_HEADERS support_files.files += \ diff --git a/tests/ft_mstylesheetparser/ft_mstylesheetparser.cpp b/tests/ft_mstylesheetparser/ft_mstylesheetparser.cpp index fff45d74..154f7125 100644 --- a/tests/ft_mstylesheetparser/ft_mstylesheetparser.cpp +++ b/tests/ft_mstylesheetparser/ft_mstylesheetparser.cpp @@ -28,7 +28,7 @@ // include this to get theme profiling support //#include "../../src/corelib/theme/mtheme_p.h" -const int NUMBER_OF_LOOPS = 10000; +const int NUMBER_OF_LOOPS = 100; Ft_MStyleSheetParser::Ft_MStyleSheetParser() : m_logicalValues(NULL), @@ -444,51 +444,50 @@ void Ft_MStyleSheetParser::test_constants() info = m_subject->fileInfoList()[1]; QCOMPARE(info->selectors.count(), 1); QCOMPARE(info->selectors[0]->attributes()->count(), 1); - info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex("attr-width"), NULL); - QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-width")), NULL)); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-width")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-width"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-width")))->getValue(), QByteArray("10px")); + info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-width"), NULL); + QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-width"), NULL)); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-width"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-width"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-width"))->getValue(), QByteArray("10px")); info = m_subject->fileInfoList()[2]; QCOMPARE(info->selectors.count(), 1); QCOMPARE(info->selectors[0]->attributes()->count(), 13); - QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-int")), NULL)); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-int")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-int"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-int")))->getValue(), QByteArray("10")); - QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1")), NULL)); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1"))); - - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1")))->getValue(), QByteArray("\"name\"")); - QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2")), NULL)); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2")))->getValue(), QByteArray("\"this is a string with constant \"name\"\" 10 1.0")); - QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool")), NULL)); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool")))->getValue(), QByteArray("true")); - QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1")), NULL)); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1")))->getValue(), QByteArray("10px 15px")); - QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2")), NULL)); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2")))->getValue(), QByteArray("17px 11px")); - QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1")), NULL)); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1")))->getValue(), QByteArray("sans 12px")); - QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2")), NULL)); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2")))->getValue(), QByteArray("arial 10px")); - QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-color")), NULL)); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-color")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-color"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-color")))->getValue(), QByteArray("#0abba0")); - QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid")), NULL)); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid")))->getValue(), QByteArray("")); - QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-void")), NULL)); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-void")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-void"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-void")))->getValue(), QByteArray("")); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-black")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-black"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-black")))->getValue(), QByteArray("#000000")); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-green")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-green"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-green")))->getValue(), QByteArray("#00ff00")); + QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-int"), NULL)); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-int"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-int"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-int"))->getValue(), QByteArray("10")); + QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1"), NULL)); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1"))->getValue(), QByteArray("\"name\"")); + QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2"), NULL)); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2"))->getValue(), QByteArray("\"this is a string with constant \"name\"\" 10 1.0")); + QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool"), NULL)); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool"))->getValue(), QByteArray("true")); + QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1"), NULL)); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1"))->getValue(), QByteArray("10px 15px")); + QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2"), NULL)); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2"))->getValue(), QByteArray("17px 11px")); + QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1"), NULL)); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1"))->getValue(), QByteArray("sans 12px")); + QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2"), NULL)); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2"))->getValue(), QByteArray("arial 10px")); + QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-color"), NULL)); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-color"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-color"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-color"))->getValue(), QByteArray("#0abba0")); + QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid"), NULL)); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid"))->getValue(), QByteArray("")); + QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-void"), NULL)); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-void"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-void"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-void"))->getValue(), QByteArray("")); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-black"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-black"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-black"))->getValue(), QByteArray("#000000")); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-green"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-green"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-green"))->getValue(), QByteArray("#00ff00")); } void Ft_MStyleSheetParser::test_constants_binary() @@ -514,49 +513,49 @@ void Ft_MStyleSheetParser::test_constants_binary() info = m_subject->fileInfoList()[1]; QCOMPARE(info->selectors.count(), 1); QCOMPARE(info->selectors[0]->attributes()->count(), 1); - QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-width")), NULL)); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-width")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-width"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-width")))->getValue(), QByteArray("10px")); + QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-width"), NULL)); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-width"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-width"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-width"))->getValue(), QByteArray("10px")); info = m_subject->fileInfoList()[2]; QCOMPARE(info->selectors.count(), 1); QCOMPARE(info->selectors[0]->attributes()->count(), 13); - QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-int")), NULL)); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-int")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-int"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-int")))->getValue(), QByteArray("10")); - QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1")), NULL)); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1")))->getValue(), QByteArray("\"name\"")); - QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2")), NULL)); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2")))->getValue(), QByteArray("\"this is a string with constant \"name\"\" 10 1.0")); - QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool")), NULL)); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool")))->getValue(), QByteArray("true")); - QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1")), NULL)); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1")))->getValue(), QByteArray("10px 15px")); - QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2")), NULL)); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2")))->getValue(), QByteArray("17px 11px")); - QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1")), NULL)); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1")))->getValue(), QByteArray("sans 12px")); - QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2")), NULL)); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2")))->getValue(), QByteArray("arial 10px")); - QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-color")), NULL)); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-color")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-color"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-color")))->getValue(), QByteArray("#0abba0")); - QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid")), NULL)); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid")))->getValue(), QByteArray("")); - QVERIFY(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-void")), NULL)); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-void")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-void"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-void")))->getValue(), QByteArray("")); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-black")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-black"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-black")))->getValue(), QByteArray("#000000")); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-green")))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-green"))); - QCOMPARE(info->selectors[0]->attributes()->value(MUniqueStringCache::stringToIndex(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-green")))->getValue(), QByteArray("#00ff00")); + QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-int"), NULL)); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-int"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-int"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-int"))->getValue(), QByteArray("10")); + QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1"), NULL)); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-string1"))->getValue(), QByteArray("\"name\"")); + QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2"), NULL)); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-string2"))->getValue(), QByteArray("\"this is a string with constant \"name\"\" 10 1.0")); + QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool"), NULL)); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-bool"))->getValue(), QByteArray("true")); + QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1"), NULL)); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos1"))->getValue(), QByteArray("10px 15px")); + QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2"), NULL)); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-pos2"))->getValue(), QByteArray("17px 11px")); + QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1"), NULL)); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-font1"))->getValue(), QByteArray("sans 12px")); + QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2"), NULL)); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-font2"))->getValue(), QByteArray("arial 10px")); + QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-color"), NULL)); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-color"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-color"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-color"))->getValue(), QByteArray("#0abba0")); + QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid"), NULL)); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-invalid"))->getValue(), QByteArray("")); + QVERIFY(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-void"), NULL)); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-void"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-void"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-void"))->getValue(), QByteArray("")); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-black"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-black"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-black"))->getValue(), QByteArray("#000000")); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-green"))->getName(), QByteArray(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-green"))); + QCOMPARE(info->selectors[0]->attributes()->value(MStyleSheetAttribute::attributeNameToPropertyName("attr-logical-green"))->getValue(), QByteArray("#00ff00")); } void Ft_MStyleSheetParser::test_binary_equality() diff --git a/tests/ft_mstylesheetparser/ft_mstylesheetparser.pro b/tests/ft_mstylesheetparser/ft_mstylesheetparser.pro index efcf1ff3..afe434f6 100644 --- a/tests/ft_mstylesheetparser/ft_mstylesheetparser.pro +++ b/tests/ft_mstylesheetparser/ft_mstylesheetparser.pro @@ -8,14 +8,13 @@ INCLUDEPATH += $$MSRCDIR/corelib/core/ SOURCES += \ ft_mstylesheetparser.cpp \ $$MSRCDIR/corelib/theme/mlogicalvalues.cpp \ - $$MSRCDIR/corelib/style/muniquestringcache.cpp \ - $$MSRCDIR/corelib/style/mstylesheetattribute.cpp \ + $$MSRCDIR/corelib/style/mstylesheetattribute.cpp + HEADERS += \ ft_mstylesheetparser.h \ $$MSRCDIR/corelib/theme/mlogicalvalues.h \ - $$MSRCDIR/corelib/style/muniquestringcache.h \ - $$MSRCDIR/corelib/style/mstylesheetattribute.h \ + $$MSRCDIR/corelib/style/mstylesheetattribute.h support_files.files += \ *.css \ diff --git a/tests/ut_mlogicalvalues/ut_mlogicalvalues.pro b/tests/ut_mlogicalvalues/ut_mlogicalvalues.pro index a8366e99..a47f1440 100644 --- a/tests/ut_mlogicalvalues/ut_mlogicalvalues.pro +++ b/tests/ut_mlogicalvalues/ut_mlogicalvalues.pro @@ -8,16 +8,13 @@ INCLUDEPATH += $$MSRCDIR/corelib/core/ SOURCES += \ ut_mlogicalvalues.cpp \ $$MSRCDIR/corelib/theme/mlogicalvalues.cpp \ - $$MSRCDIR/corelib/style/mstylesheetattribute.cpp \ - $$MSRCDIR/corelib/style/muniquestringcache.cpp + $$MSRCDIR/corelib/style/mstylesheetattribute.cpp HEADERS += \ ut_mlogicalvalues.h \ $$MSRCDIR/corelib/theme/mlogicalvalues.h \ $$MSRCDIR/corelib/theme/mlogicalvalues_p.h \ - $$MSRCDIR/corelib/style/mstylesheetattribute.h \ - $$MSRCDIR/corelib/style/muniquestringcache.h - + $$MSRCDIR/corelib/style/mstylesheetattribute.h support_files.files += *.ini |