示例#1
0
void StyleResolver::matchRules(Element& element, ElementRuleCollector& collector)
{
    collector.clearMatchedRules();

    CascadeOrder cascadeOrder = 0;

    collector.collectMatchingRules(MatchRequest(&defaultStyles()), ++cascadeOrder);

    ScopedStyleResolver& resolver = element.treeScope().scopedStyleResolver();
    resolver.collectMatchingAuthorRules(collector, ++cascadeOrder);

    collector.sortAndTransferMatchedRules();

    if (const StylePropertySet* inlineStyle = element.inlineStyle()) {
        // Inline style is immutable as long as there is no CSSOM wrapper.
        bool isInlineStyleCacheable = !inlineStyle->isMutable();
        collector.addElementStyleProperties(inlineStyle, isInlineStyleCacheable);
    }
}
示例#2
0
QMap<QString, ConfigStyle> Config::readStyles( const QString &path )
{
    QMap<QString, ConfigStyle> styles;
    styles = defaultStyles();

    QString family;
    int size = 10;
    bool bold = FALSE, italic = FALSE, underline = FALSE;
    int red = 0, green = 0, blue = 0;

    QString elements[] = {
	QT_TR_NOOP( QString::fromLatin1("Comment") ),
	QT_TR_NOOP( QString::fromLatin1("Number") ),
	QT_TR_NOOP( QString::fromLatin1("String") ),
	QT_TR_NOOP( QString::fromLatin1("Type") ),
	QT_TR_NOOP( QString::fromLatin1("Keyword") ),
	QT_TR_NOOP( QString::fromLatin1("Preprocessor") ),
	QT_TR_NOOP( QString::fromLatin1("Label") ),
	QT_TR_NOOP( QString::fromLatin1("Standard") ),
	QString::null
    };

    for ( int i = 0; elements[ i ] != QString::null; ++i ) {
	QSettings settings;
	bool ok = TRUE;
	for (;;) {
	    family = settings.readEntry( path + elements[ i ] + "/family", QString::null, &ok );
	    if ( !ok )
		break;
	    size = settings.readNumEntry( path + elements[ i ] + "/size", 10, &ok );
	    if ( !ok )
		break;
	    bold = settings.readBoolEntry( path + elements[ i ] + "/bold", FALSE, &ok );
	    if ( !ok )
		break;
	    italic = settings.readBoolEntry( path + elements[ i ] + "/italic", FALSE, &ok );
	    if ( !ok )
		break;
	    underline = settings.readBoolEntry( path + elements[ i ] + "/underline", FALSE, &ok );
	    if ( !ok )
		break;
	    red = settings.readNumEntry( path + elements[ i ] + "/red", 0, &ok );
	    if ( !ok )
		break;
	    green = settings.readNumEntry( path + elements[ i ] + "/green", 0, &ok );
	    if ( !ok )
		break;
	    blue = settings.readNumEntry( path + elements[ i ] + "/blue", 0, &ok );
	    if ( !ok )
		break;
	    break;
	}
	if ( !ok )
	    continue;
	QFont f( family );
	f.setPointSize( size );
	f.setBold( bold );
	f.setItalic( italic );
	f.setUnderline( underline );
	QColor c( red, green, blue );
	ConfigStyle s;
	s.font = f;
	s.color = c;
	styles.remove( elements[ i ] );
	styles.insert( elements[ i ], s );
    }
    return styles;
}