From 2e4a107e7e97a2dc36471cbd795ec94096f1a771 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 4 Dec 2014 11:00:30 +0100 Subject: Ensure that CSS rules are inherited from the parent tags When CSS is set in a head tag then it was not being inherited by the child tags when the CSS specification indicates that the properties are in fact inherited. This ensures that those properties are inherited and the non inheritable ones are unchanged. A test is added to cover the different situations with inheritance and a fix is done for the QTextDocumentFragment test which was passing despite having incorrect defaults. Task-number: QTBUG-28770 Task-number: QTBUG-34153 Change-Id: I55966240845a885852a04ecb82c61926dea9f800 Reviewed-by: Simon Hausmann --- src/gui/text/qcssparser.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/gui/text/qcssparser.cpp') diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index f9e6a7e335..3c98cb568d 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -364,6 +364,29 @@ static quint64 findKnownValue(const QString &name, const QCssKnownValue *start, return prop->id; } +static inline bool isInheritable(Property propertyId) +{ + switch (propertyId) { + case Font: + case FontFamily: + case FontSize: + case FontStyle: + case FontWeight: + case TextIndent: + case Whitespace: + case ListStyleType: + case ListStyle: + case TextAlignment: + case FontVariant: + case TextTransform: + case LineHeight: + return true; + default: + break; + } + return false; +} + /////////////////////////////////////////////////////////////////////////////// // Value Extractor ValueExtractor::ValueExtractor(const QVector &decls, const QPalette &pal) @@ -2317,6 +2340,7 @@ bool Parser::parseProperty(Declaration *decl) { decl->d->property = lexem(); decl->d->propertyId = static_cast(findKnownValue(decl->d->property, properties, NumProperties)); + decl->d->inheritable = isInheritable(decl->d->propertyId); skipSpace(); return true; } -- cgit v1.2.3