static PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> createStylePropertySet(const WillBeHeapVector<CSSProperty, 256>& parsedProperties, CSSParserMode mode)
{
    BitArray<numCSSProperties> seenProperties;
    size_t unusedEntries = parsedProperties.size();
    WillBeHeapVector<CSSProperty, 256> results(unusedEntries);

    filterProperties(true, parsedProperties, results, unusedEntries, seenProperties);
    filterProperties(false, parsedProperties, results, unusedEntries, seenProperties);

    return ImmutableStylePropertySet::create(results.data() + unusedEntries, results.size() - unusedEntries, mode);
}
PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> BisonCSSParser::createStylePropertySet()
{
    BitArray<numCSSProperties> seenProperties;
    size_t unusedEntries = m_parsedProperties.size();
    WillBeHeapVector<CSSProperty, 256> results(unusedEntries);

    // Important properties have higher priority, so add them first. Duplicate definitions can then be ignored when found.
    filterProperties(true, m_parsedProperties, results, unusedEntries, seenProperties);
    filterProperties(false, m_parsedProperties, results, unusedEntries, seenProperties);
    if (unusedEntries)
        results.remove(0, unusedEntries);

    CSSParserMode mode = inViewport() ? CSSViewportRuleMode : m_context.mode();

    return ImmutableStylePropertySet::create(results.data(), results.size(), mode);
}
bool CSSParserImpl::parseDeclarationList(MutableStylePropertySet* declaration, const String& string, const CSSParserContext& context)
{
    CSSParserImpl parser(context);
    StyleRule::Type ruleType = StyleRule::Style;
    if (declaration->cssParserMode() == CSSViewportRuleMode)
        ruleType = StyleRule::Viewport;
    CSSTokenizer::Scope scope(string);
    parser.consumeDeclarationList(scope.tokenRange(), ruleType);
    if (parser.m_parsedProperties.isEmpty())
        return false;

    BitArray<numCSSProperties> seenProperties;
    size_t unusedEntries = parser.m_parsedProperties.size();
    WillBeHeapVector<CSSProperty, 256> results(unusedEntries);
    filterProperties(true, parser.m_parsedProperties, results, unusedEntries, seenProperties);
    filterProperties(false, parser.m_parsedProperties, results, unusedEntries, seenProperties);
    if (unusedEntries)
        results.remove(0, unusedEntries);
    return declaration->addParsedProperties(results);
}
Exemple #4
0
void CDiagramItem::toXml(QDomElement &n)
{
	QMetaObject				*meta = NULL;
  QMetaProperty			prop;
	QDomDocument			doc;
	QDomElement				ext, childNode;
	QList<QByteArray>		props;
  QStringList				filtersOut, filtersIn;
	CDiagramSerializable	*inst = NULL;

    filtersIn = filterProperties();
    filtersOut  << "width"
                << "height"
                << "x"
                << "y"
                << "z"
                << "pos"
                << "size"
                << "parent"
                << "effect"
                << "children"
                << "layout"
                << "palette";

	doc = n.ownerDocument();
	ext = doc.createElement( QString("ext") );
	childNode = doc.createElement( QString("children") );

	n.setAttribute( QString("type"), interType());
	n.setAttribute( QString("category"), category() );
	n.setAttribute( QString("name"), name() );
	n.setAttribute( QString("libCategory"), libraryCategory() );
	n.setAttribute( QString("libName"), libraryName() );
	n.setAttribute( QString("id"), QString::number(id()) );
	
	meta = const_cast<QMetaObject*>(metaObject());
	for (int i = 0; i < meta->propertyCount(); ++i)
	{
		QString		propName;
		QByteArray	b;
		QDataStream s(&b, QIODevice::WriteOnly);

		prop = meta->property(i);
		propName = QString(prop.name());
        if (filtersIn.isEmpty())
        {
            if (filtersOut.contains(propName, Qt::CaseInsensitive) || prop.userType() == 0)
            {
                continue;
            }
        }
        else
        {
            if (!filtersIn.contains(propName, Qt::CaseInsensitive))
            {
                continue;
            }
        }
		
		if (prop.isValid() && prop.isReadable())
		{
			s <<  prop.read(this);
			QDomElement	e = doc.createElement(QString("property"));
			e.setAttribute( QString("name"), QString(prop.name()) );
			e.setAttribute( QString("type"), QString(prop.typeName()) );
			e.appendChild( doc.createTextNode( QString(b.toBase64() ) ) );
			n.appendChild(e);
			// qDebug() << "save->name:" << prop.name() << " value:" << prop.read(this);
		}
	}
	
	props = dynamicPropertyNames();
	for (int i = 0; i < props.length(); ++i)
	{
		inst = RS_PROPERTY(props.at(i).constData());
		// inst = property(props.at(i).constData()).value<CDiagramSerializable*>();
		if (inst)
		{
			QDomElement	 c = doc.createElement(QString("child"));
			c.setAttribute( QString("dynamicProperty"), QString(props.at(i).constData()) );
			inst->toXml(c);
			childNode.appendChild(c);
		}
	}
	n.appendChild(childNode);

	extToXml( ext );
	n.appendChild( ext );
}