From kde-commits Mon Apr 05 17:02:49 2010 From: Maks Orlovich Date: Mon, 05 Apr 2010 17:02:49 +0000 To: kde-commits Subject: KDE/kdelibs/khtml/css Message-Id: <20100405170249.BD825AC857 () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=127048764925596 SVN commit 1111438 by orlovich: Implement application of system font keywords. Also make parsing of them not fall-through to list-style (ooops). Brain bootup confirmed :) BUG: 197544 M +1 -0 cssparser.cpp M +45 -0 cssstyleselector.cpp --- trunk/KDE/kdelibs/khtml/css/cssparser.cpp #1111437:1111438 @@ -1156,6 +1156,7 @@ valid_primitive = true; else return parseFont(important); + break; case CSS_PROP_LIST_STYLE: { --- trunk/KDE/kdelibs/khtml/css/cssstyleselector.cpp #1111437:1111438 @@ -3931,6 +3931,51 @@ applyRule( CSS_PROP_LINE_HEIGHT, font->lineHeight ); applyRule( CSS_PROP_FONT_FAMILY, font->family ); + } else if (primitiveValue) { + // Handle system fonts. We extract out properties from a QFont + // into the RenderStyle. + QFont f; + switch (primitiveValue->getIdent()) { + case CSS_VAL_ICON: + f = KGlobalSettings::toolBarFont(); + break; + + case CSS_VAL_MENU: + f = KGlobalSettings::menuFont(); + break; + + case CSS_VAL_SMALL_CAPTION: + f = KGlobalSettings::smallestReadableFont(); + break; + + case CSS_VAL_CAPTION: + case CSS_VAL_MESSAGE_BOX: + case CSS_VAL_STATUS_BAR: + f = KGlobalSettings::generalFont(); + break; + default: + return; + } + + FontDef fontDef = style->htmlFont().fontDef; + fontDef.family = f.family(); + fontDef.italic = f.italic(); + fontDef.smallCaps = (f.capitalization() == QFont::SmallCaps); + fontDef.weight = f.weight(); + fontDirty |= style->setFontDef( fontDef ); + + // Use applyRule to apply height, so it can convert + // point sizes, and cap pixel sizes appropriately. + if (f.pixelSize() != -1) { + CSSPrimitiveValueImpl size( f.pixelSize(), CSSPrimitiveValue::CSS_PX ); + applyRule( CSS_PROP_FONT_SIZE, &size ); + } else { + CSSPrimitiveValueImpl size( f.pointSize(), CSSPrimitiveValue::CSS_PT ); + applyRule( CSS_PROP_FONT_SIZE, &size ); + } + + // line-height just gets default. + style->setLineHeight(RenderStyle::initialLineHeight()); } return;