void StyleBaseImpl::setParsedValue(int propId, const CSSValueImpl *parsedValue, bool important, bool nonCSSHint, TQPtrList<CSSProperty> *propList) { TQPtrListIterator<CSSProperty> propIt(*propList); propIt.toLast(); // just remove the top one - not sure what should happen if we have multiple instances of the property while (propIt.current() && ( propIt.current()->m_id != propId || propIt.current()->nonCSSHint != nonCSSHint || propIt.current()->m_important != important) ) --propIt; if (propIt.current()) propList->removeRef(propIt.current()); CSSProperty *prop = new CSSProperty(); prop->m_id = propId; prop->setValue((CSSValueImpl *) parsedValue); prop->m_important = important; prop->nonCSSHint = nonCSSHint; propList->append(prop); #ifdef CSS_DEBUG kdDebug( 6080 ) << "added property: " << getPropertyName(propId).string() // non implemented yet << ", value: " << parsedValue->cssText().string() << " important: " << prop->m_important << " nonCSS: " << prop->nonCSSHint << endl; #endif }
void StyleBaseImpl::setParsedValue(int propId, const CSSValueImpl *parsedValue, bool important, QList<CSSProperty*> *propList) { QMutableListIterator<CSSProperty*> propIt(*propList); propIt.toBack(); // just remove the top one - not sure what should happen if we have multiple instances of the property CSSProperty* p; while (propIt.hasPrevious()) { p = propIt.previous(); if (p->m_id == propId && p->m_important == important ) { delete propIt.value(); propIt.remove(); break; } } CSSProperty *prop = new CSSProperty(); prop->m_id = propId; prop->setValue(const_cast<CSSValueImpl *>(parsedValue)); prop->m_important = important; propList->append(prop); #ifdef CSS_DEBUG kDebug( 6080 ) << "added property: " << getPropertyName(propId).string() // non implemented yet << ", value: " << parsedValue->cssText().string() << " important: " << prop->m_important; #endif }
bool StylePropertySet::removeProperty(CSSPropertyID propertyID, String* returnText) { if (removeShorthandProperty(propertyID)) { // FIXME: Return an equivalent shorthand when possible. if (returnText) *returnText = ""; return true; } CSSProperty* foundProperty = findPropertyWithId(propertyID); if (!foundProperty) { if (returnText) *returnText = ""; return false; } if (returnText) *returnText = foundProperty->value()->cssText(); // A more efficient removal strategy would involve marking entries as empty // and sweeping them when the vector grows too big. m_properties.remove(foundProperty - m_properties.data()); return true; }
void StylePropertySet::setPrefixingVariantProperty(const CSSProperty& property) { CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(property.id()); CSSProperty* toReplace = findMutableCSSPropertyWithID(prefixingVariant); if (toReplace) *toReplace = CSSProperty(prefixingVariant, property.value(), property.isImportant(), property.shorthandID(), property.metadata().m_implicit); }
bool MutableStylePropertySet::addRespectingCascade(const CSSProperty& property) { // Only add properties that have no !important counterpart present if (!propertyIsImportant(property.id()) || property.isImportant()) return setProperty(property); return false; }
void MutableStylePropertySet::setPrefixingVariantProperty(const CSSProperty& property) { CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(property.id()); CSSProperty* toReplace = findCSSPropertyWithID(prefixingVariant); if (toReplace && prefixingVariant != property.id()) *toReplace = CSSProperty(prefixingVariant, property.value(), property.isImportant(), property.isSetFromShorthand(), getIndexInShorthandVectorForPrefixingVariant(property, prefixingVariant), property.metadata().m_implicit); }
void StylePropertySet::addParsedProperty(const CSSProperty& property) { ASSERT(isMutable()); // Only add properties that have no !important counterpart present if (!propertyIsImportant(property.id()) || property.isImportant()) setProperty(property); }
void StylePropertySet::appendPrefixingVariantProperty(const CSSProperty& property) { mutablePropertyVector().append(property); CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(property.id()); if (prefixingVariant == property.id()) return; mutablePropertyVector().append(CSSProperty(prefixingVariant, property.value(), property.isImportant(), property.shorthandID(), property.metadata().m_implicit)); }
void StylePropertySet::addParsedProperty(const CSSProperty& property) { // Only add properties that have no !important counterpart present if (!propertyIsImportant(property.id()) || property.isImportant()) { removeProperty(property.id()); m_properties.append(property); } }
void MutableStylePropertySet::appendPrefixingVariantProperty(const CSSProperty& property) { m_propertyVector.append(property); CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(property.id()); if (prefixingVariant == property.id()) return; m_propertyVector.append(CSSProperty(prefixingVariant, property.value(), property.isImportant(), property.isSetFromShorthand(), getIndexInShorthandVectorForPrefixingVariant(property, prefixingVariant), property.metadata().m_implicit)); }
unsigned getIndexInShorthandVectorForPrefixingVariant(const CSSProperty& property, CSSPropertyID prefixingVariant) { if (!property.isSetFromShorthand()) return 0; CSSPropertyID prefixedShorthand = prefixingVariantForPropertyId(property.shorthandID()); Vector<StylePropertyShorthand, 4> shorthands; getMatchingShorthandsForLonghand(prefixingVariant, &shorthands); return indexOfShorthandForLonghand(prefixedShorthand, shorthands); }
void CSSMutableStyleDeclaration::addParsedProperty(const CSSProperty& property) { ASSERT(!m_iteratorCount); // Only add properties that have no !important counterpart present if (!getPropertyPriority(property.id()) || property.isImportant()) { removeProperty(property.id(), false); m_properties.append(property); } }
void StylePropertySet::setProperty(const CSSProperty& property, CSSProperty* slot) { if (!removeShorthandProperty(property.id())) { CSSProperty* toReplace = slot ? slot : findPropertyWithId(property.id()); if (toReplace) { *toReplace = property; return; } } m_properties.append(property); }
CSSValueImpl *CSSStyleDeclarationImpl::getPropertyCSSValue( int propertyID ) const { if(!m_lstValues) return 0; QPtrListIterator<CSSProperty> lstValuesIt(*m_lstValues); CSSProperty *current; for ( lstValuesIt.toLast(); (current = lstValuesIt.current()); --lstValuesIt ) if (current->m_id == propertyID && !current->nonCSSHint) return current->value(); return 0; }
void StylePropertySet::setProperty(const CSSProperty& property, CSSProperty* slot) { ASSERT(isMutable()); if (!removeShorthandProperty(property.id())) { CSSProperty* toReplace = slot ? slot : findMutableCSSPropertyWithID(property.id()); if (toReplace) { *toReplace = property; return; } } mutablePropertyVector().append(property); }
void MutableStylePropertySet::setProperty(const CSSProperty& property, CSSProperty* slot) { if (!removeShorthandProperty(property.id())) { CSSProperty* toReplace = slot ? slot : findCSSPropertyWithID(property.id()); if (toReplace) { *toReplace = property; setPrefixingVariantProperty(property); return; } } appendPrefixingVariantProperty(property); }
void CSSMutableStyleDeclaration::setPropertyInternal(const CSSProperty& property, CSSProperty* slot) { ASSERT(!m_iteratorCount); if (!removeShorthandProperty(property.id(), false)) { CSSProperty* toReplace = slot ? slot : findPropertyWithId(property.id()); if (toReplace) { *toReplace = property; return; } } m_properties.append(property); }
void StylePropertySet::merge(const StylePropertySet* other, bool argOverridesOnConflict) { unsigned size = other->m_properties.size(); for (unsigned n = 0; n < size; ++n) { const CSSProperty& toMerge = other->m_properties[n]; CSSProperty* old = findPropertyWithId(toMerge.id()); if (old) { if (!argOverridesOnConflict && old->value()) continue; setProperty(toMerge, old); } else m_properties.append(toMerge); } }
bool MutableStylePropertySet::setProperty(const CSSProperty& property, CSSProperty* slot) { if (!removeShorthandProperty(property.id())) { const AtomicString& name = (property.id() == CSSPropertyVariable) ? toCSSCustomPropertyDeclaration(property.value())->name() : nullAtom; CSSProperty* toReplace = slot ? slot : findCSSPropertyWithID(property.id(), name); if (toReplace && *toReplace == property) return false; if (toReplace) { *toReplace = property; return true; } } m_propertyVector.append(property); return true; }
DOMString CSSStyleDeclarationImpl::removeProperty( int propertyID, bool NonCSSHint ) { if(!m_lstValues) return DOMString(); DOMString value; QPtrListIterator<CSSProperty> lstValuesIt(*m_lstValues); CSSProperty *current; for ( lstValuesIt.toLast(); (current = lstValuesIt.current()); --lstValuesIt ) if (current->m_id == propertyID && NonCSSHint == current->nonCSSHint) { value = current->value()->cssText(); m_lstValues->removeRef(current); setChanged(); break; } return value; }
void CSSMutableStyleDeclaration::merge(const CSSMutableStyleDeclaration* other, bool argOverridesOnConflict) { ASSERT(!m_iteratorCount); unsigned size = other->m_properties.size(); for (unsigned n = 0; n < size; ++n) { const CSSProperty& toMerge = other->m_properties[n]; CSSProperty* old = findPropertyWithId(toMerge.id()); if (old) { if (!argOverridesOnConflict && old->value()) continue; setPropertyInternal(toMerge, old); } else m_properties.append(toMerge); } // FIXME: This probably should have a call to setNeedsStyleRecalc() if something changed. We may also wish to add // a notifyChanged argument to this function to follow the model of other functions in this class. }
CSSStyleProperties::CSSStyleProperties(const std::string &style_string, const std::string &base_uri) : impl(new CSSStyleProperties_Impl()) { static CSSPropertyParsers parsers; // To do: this isn't a very nice way of doing it! CSSTokenizer tokenizer(style_string); CSSToken token; while (true) { tokenizer.read(token, true); if (token.type == CSSToken::type_ident) { std::string property_name = token.value; tokenizer.read(token, true); if (token.type == CSSToken::type_colon) { tokenizer.read(token, true); CSSProperty property; property.set_name(property_name); CSSDocumentSheet::read_property_value(tokenizer, token, property, base_uri); if (!property.get_value_tokens().empty()) { parsers.parse(property, impl->values); } } else { bool end_of_scope = CSSDocumentSheet::read_end_of_statement(tokenizer, token); if (end_of_scope) break; } } else if (token.type == CSSToken::type_null) { break; } } std::reverse(impl->values.begin(), impl->values.end()); }
void CSSStyleDeclarationImpl::setLengthProperty(int id, const DOMString &value, bool important, bool nonCSSHint) { strictParsing = false; setProperty( id, value, important, nonCSSHint); strictParsing = true; #if 0 // ### FIXME after 2.0 if(!value.unicode() || value.length() == 0) return; if(!m_lstValues) { m_lstValues = new QList<CSSProperty>; m_lstValues->setAutoDelete(true); } CSSValueImpl *v = parseUnit(value.unicode(), value.unicode()+value.length(), INTEGER | PERCENT | LENGTH, ); if(!v) { kdDebug( 6080 ) << "invalid length" << endl; return; } CSSPrimitiveValueImpl *p = static_cast<CSSPrimitiveValueImpl *>(v); if(p->primitiveType() == CSSPrimitiveValue::CSS_NUMBER) { // set the parsed number in pixels p->setPrimitiveType(CSSPrimitiveValue::CSS_PX); } CSSProperty *prop = new CSSProperty(); prop->m_id = id; prop->setValue(v); prop->m_bImportant = important; prop->nonCSSHint = nonCSSHint; m_lstValues->append(prop); #endif }
String CSSMutableStyleDeclaration::removeProperty(int propertyID, bool notifyChanged, bool returnText) { ASSERT(!m_iteratorCount); if (removeShorthandProperty(propertyID, notifyChanged)) { // FIXME: Return an equivalent shorthand when possible. return String(); } CSSProperty* foundProperty = findPropertyWithId(propertyID); if (!foundProperty) return String(); String value = returnText ? foundProperty->value()->cssText() : String(); // A more efficient removal strategy would involve marking entries as empty // and sweeping them when the vector grows too big. m_properties.remove(foundProperty - m_properties.data()); if (notifyChanged) setNeedsStyleRecalc(); return value; }
void CSSMutableStyleDeclaration::addParsedProperty(const CSSProperty& property) { removeProperty(property.id(), false); m_values.append(property); }