void Element::inlineStyleChanged() { ASSERT(isStyledElement()); setNeedsStyleRecalc(LocalStyleChange); ASSERT(elementData()); elementData()->m_styleAttributeIsDirty = true; }
void StyledElement::inlineStyleChanged() { setNeedsStyleRecalc(InlineStyleChange); ASSERT(elementData()); elementData()->setStyleAttributeIsDirty(true); InspectorInstrumentation::didInvalidateStyleAttr(document(), *this); }
void Element::synchronizeStyleAttributeInternal() const { ASSERT(isStyledElement()); ASSERT(elementData()); ASSERT(elementData()->m_styleAttributeIsDirty); elementData()->m_styleAttributeIsDirty = false; const StylePropertySet* inlineStyle = this->inlineStyle(); const_cast<Element*>(this)->setSynchronizedLazyAttribute(HTMLNames::styleAttr, inlineStyle ? AtomicString(inlineStyle->asText()) : nullAtom); }
Vector<RefPtr<Attr>> Element::getAttributes() { if (!elementData()) return Vector<RefPtr<Attr>>(); synchronizeAllAttributes(); Vector<RefPtr<Attr>> attributes; for (const Attribute& attribute : elementData()->attributes()) attributes.append(Attr::create(attribute.name(), attribute.value())); return attributes; }
void Element::removeAttribute(const QualifiedName& name) { if (!elementData()) return; size_t index = elementData()->attributes().findIndex(name); if (index == kNotFound) return; removeAttributeInternal(index, NotInSynchronizationOfLazyAttribute); }
bool Element::hasEquivalentAttributes(const Element* other) const { synchronizeAllAttributes(); other->synchronizeAllAttributes(); if (elementData() == other->elementData()) return true; if (elementData()) return elementData()->isEquivalent(other->elementData()); if (other->elementData()) return other->elementData()->isEquivalent(elementData()); return true; }
void Element::classAttributeChanged(const AtomicString& newClassString) { bool testShouldInvalidateStyle = inActiveDocument() && styleChangeType() < SubtreeStyleChange; ASSERT(elementData()); const SpaceSplitString oldClasses = elementData()->classNames(); elementData()->setClass(newClassString, false); const SpaceSplitString& newClasses = elementData()->classNames(); if (testShouldInvalidateStyle && classChangeNeedsStyleRecalc(oldClasses, newClasses)) setNeedsStyleRecalc(LocalStyleChange); if (!newClasses.size()) elementData()->clearClass(); }
void Element::removeAttribute(const AtomicString& localName) { if (!elementData()) return; size_t index = elementData()->attributes().findIndex(localName); if (index == kNotFound) { if (UNLIKELY(localName == HTMLNames::styleAttr) && elementData()->m_styleAttributeIsDirty && isStyledElement()) removeAllInlineStyleProperties(); return; } removeAttributeInternal(index, NotInSynchronizationOfLazyAttribute); }
ALWAYS_INLINE void Element::setAttributeInternal(size_t index, const QualifiedName& name, const AtomicString& newValue, SynchronizationOfLazyAttribute inSynchronizationOfLazyAttribute) { if (newValue.isNull()) { if (index != kNotFound) removeAttributeInternal(index, inSynchronizationOfLazyAttribute); return; } if (index == kNotFound) { appendAttributeInternal(name, newValue, inSynchronizationOfLazyAttribute); return; } const Attribute& existingAttribute = elementData()->attributes().at(index); QualifiedName existingAttributeName = existingAttribute.name(); if (newValue == existingAttribute.value()) return; if (!inSynchronizationOfLazyAttribute) willModifyAttribute(existingAttributeName, existingAttribute.value(), newValue); ensureUniqueElementData().attributes().at(index).setValue(newValue); if (!inSynchronizationOfLazyAttribute) attributeChanged(existingAttributeName, newValue); }
inline void StyledElement::setInlineStyleFromString(const AtomicString& newStyleString) { RefPtr<StyleProperties>& inlineStyle = elementData()->m_inlineStyle; // Avoid redundant work if we're using shared attribute data with already parsed inline style. if (inlineStyle && !elementData()->isUnique()) return; // We reconstruct the property set instead of mutating if there is no CSSOM wrapper. // This makes wrapperless property sets immutable and so cacheable. if (inlineStyle && !is<MutableStyleProperties>(*inlineStyle)) inlineStyle = nullptr; if (!inlineStyle) inlineStyle = CSSParser::parseInlineStyleDeclaration(newStyleString, this); else downcast<MutableStyleProperties>(*inlineStyle).parseDeclaration(newStyleString, &document().elementSheet().contents()); }
void Element::setAttribute(const AtomicString& localName, const AtomicString& value, ExceptionState& exceptionState) { if (!Document::isValidName(localName)) { exceptionState.ThrowDOMException(InvalidCharacterError, "'" + localName + "' is not a valid attribute name."); return; } synchronizeAttribute(localName); if (!elementData()) { setAttributeInternal(kNotFound, QualifiedName(localName), value, NotInSynchronizationOfLazyAttribute); return; } AttributeCollection attributes = elementData()->attributes(); size_t index = attributes.findIndex(localName); const QualifiedName& qName = index != kNotFound ? attributes[index].name() : QualifiedName(localName); setAttributeInternal(index, qName, value, NotInSynchronizationOfLazyAttribute); }
KURL Element::getURLAttribute(const QualifiedName& name) const { #if ENABLE(ASSERT) if (elementData()) { if (const Attribute* attribute = attributes().find(name)) ASSERT(isURLAttribute(*attribute)); } #endif return document().completeURL(stripLeadingAndTrailingHTMLSpaces(getAttribute(name))); }
void StyledElement::attributeChanged(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue, AttributeModificationReason reason) { if (name == styleAttr) styleAttributeChanged(newValue, reason); else if (isPresentationAttribute(name)) { elementData()->setPresentationAttributeStyleIsDirty(true); setNeedsStyleRecalc(InlineStyleChange); } Element::attributeChanged(name, oldValue, newValue, reason); }
void Element::attributeChanged(const QualifiedName& name, const AtomicString& newValue, AttributeModificationReason reason) { bool testShouldInvalidateStyle = inActiveDocument() && styleChangeType() < SubtreeStyleChange; if (isStyledElement() && name == HTMLNames::styleAttr) { styleAttributeChanged(newValue); } if (name == HTMLNames::idAttr) { AtomicString oldId = elementData()->idForStyleResolution(); AtomicString newId = newValue; if (newId != oldId) { elementData()->setIdForStyleResolution(newId); if (testShouldInvalidateStyle && (affectedByIdSelector(oldId) || affectedByIdSelector(newId))) setNeedsStyleRecalc(LocalStyleChange); } } else if (name == HTMLNames::classAttr) { classAttributeChanged(newValue); } }
inline void Element::setInlineStyleFromString(const AtomicString& newStyleString) { ASSERT(isStyledElement()); RefPtr<StylePropertySet>& inlineStyle = elementData()->m_inlineStyle; // Avoid redundant work if we're using shared attribute data with already parsed inline style. if (inlineStyle && !elementData()->isUnique()) return; // We reconstruct the property set instead of mutating if there is no CSSOM wrapper. // This makes wrapperless property sets immutable and so cacheable. if (inlineStyle && !inlineStyle->isMutable()) inlineStyle.clear(); if (!inlineStyle) { inlineStyle = BisonCSSParser::parseInlineStyleDeclaration(newStyleString, this); } else { ASSERT(inlineStyle->isMutable()); static_cast<MutableStylePropertySet*>(inlineStyle.get())->parseDeclaration(newStyleString, document().elementSheet().contents()); } }
KURL Element::getNonEmptyURLAttribute(const QualifiedName& name) const { #if ENABLE(ASSERT) if (elementData()) { if (const Attribute* attribute = attributes().find(name)) ASSERT(isURLAttribute(*attribute)); } #endif String value = stripLeadingAndTrailingHTMLSpaces(getAttribute(name)); if (value.isEmpty()) return KURL(); return document().completeURL(value); }
void Element::styleAttributeChanged(const AtomicString& newStyleString) { ASSERT(isStyledElement()); if (newStyleString.isNull()) { ensureUniqueElementData().m_inlineStyle.clear(); } else { setInlineStyleFromString(newStyleString); } elementData()->m_styleAttributeIsDirty = false; setNeedsStyleRecalc(LocalStyleChange); }
void StyledElement::styleAttributeChanged(const AtomicString& newStyleString, AttributeModificationReason reason) { WTF::OrdinalNumber startLineNumber = WTF::OrdinalNumber::beforeFirst(); if (document().scriptableDocumentParser() && !document().isInDocumentWrite()) startLineNumber = document().scriptableDocumentParser()->textPosition().m_line; if (newStyleString.isNull()) { if (PropertySetCSSStyleDeclaration* cssomWrapper = inlineStyleCSSOMWrapper()) cssomWrapper->clearParentElement(); ensureUniqueElementData().m_inlineStyle = nullptr; } else if (reason == ModifiedByCloning || document().contentSecurityPolicy()->allowInlineStyle(document().url(), startLineNumber, isInUserAgentShadowTree())) setInlineStyleFromString(newStyleString); elementData()->setStyleAttributeIsDirty(false); setNeedsStyleRecalc(InlineStyleChange); InspectorInstrumentation::didInvalidateStyleAttr(document(), *this); }
void StyledElement::addSubresourceAttributeURLs(ListHashSet<URL>& urls) const { if (const StyleProperties* inlineStyle = elementData() ? elementData()->inlineStyle() : 0) inlineStyle->addSubresourceStyleURLs(urls, &document().elementSheet().contents()); }
int LoadPattern::sendSelf(int cTag, Channel &theChannel) { // get my current database tag // NOTE - dbTag equals 0 if not sending to a database OR has not yet been sent int myDbTag = this->getDbTag(); // into an ID we place all info needed to determine state of LoadPattern int numNodLd, numEleLd, numSPs; ID lpData(11); numNodLd = theNodalLoads->getNumComponents(); numEleLd = theElementalLoads->getNumComponents(); numSPs = theSPs->getNumComponents(); lpData(10) = this->getTag(); lpData(0) = currentGeoTag; lpData(1) = numNodLd; lpData(2) = numEleLd; lpData(3) = numSPs; if (dbNod == 0) { dbNod = theChannel.getDbTag(); dbEle = theChannel.getDbTag(); dbSPs = theChannel.getDbTag(); } lpData(4) = dbNod; lpData(5) = dbEle; lpData(6) = dbSPs; lpData(7) = isConstant; if (theSeries != 0) { int dbtag = theSeries->getDbTag(); int classtag = theSeries->getClassTag(); if (dbtag == 0) { dbtag = theChannel.getDbTag(); theSeries->setDbTag(dbtag); } lpData(8) = classtag; lpData(9) = dbtag; } else lpData(8) = -1; // see if we can save sending the vector containing just the load factor // will happen in parallel if sending the loadPattern .. not in database if (theChannel.sendID(myDbTag, cTag, lpData) < 0) { opserr << "LoadPattern::sendSelf - channel failed to send the initial ID\n"; return -1; } if (isConstant == 0) { Vector data(2); data(0) = loadFactor; data(1) = scaleFactor; if (theChannel.sendVector(myDbTag, cTag, data) < 0) { opserr << "LoadPattern::sendSelf - channel failed to send the Vector\n"; return -2; } } if (theSeries != 0) if (theSeries->sendSelf(cTag, theChannel) < 0) { opserr << "LoadPattern::sendSelf - the TimeSeries failed to send\n"; return -3; } // now check if data defining the objects in the LoadPAttern needs to be sent // NOTE THIS APPROACH MAY NEED TO CHANGE FOR VERY LARGE PROBLEMS IF CHANNEL CANNOT // HANDLE VERY LARGE ID OBJECTS. /* if (theChannel.isDatastore() == 1) { static ID theLastSendTag(1); if (theChannel.recvID(myDbTag,0,theLastSendTag) == 0) lastGeoSendTag = theLastSendTag(0); else lastGeoSendTag = -1; } */ if (lastChannel != theChannel.getTag() || lastGeoSendTag != currentGeoTag || theChannel.isDatastore() == 0) { lastChannel = theChannel.getTag(); // // into an ID we are gonna place the class and db tags for each node so can rebuild // this ID we then send to the channel // // create the ID and get the node iter if (numNodLd != 0) { ID nodeData(numNodLd*2); NodalLoad *theNode; NodalLoadIter &theNodes = this->getNodalLoads(); int loc =0; // loop over nodes in domain adding their classTag and dbTag to the ID while ((theNode = theNodes()) != 0) { nodeData(loc) = theNode->getClassTag(); int dbTag = theNode->getDbTag(); // if dbTag still 0 get one from Channel; // if this tag != 0 set the dbTag in node if (dbTag == 0 && myDbTag != 0) {// go get a new tag and setDbTag in ele if this not 0 dbTag = theChannel.getDbTag(); if (dbTag != 0) theNode->setDbTag(dbTag); } nodeData(loc+1) = dbTag; loc+=2; } // now send the ID if (theChannel.sendID(dbNod, currentGeoTag, nodeData) < 0) { opserr << "LoadPattern::sendSelf - channel failed to send the NodalLoads ID\n"; return -4; } } // we do the same for elemental loads as we did for nodal loads above .. see comments above! if (numEleLd != 0) { ID elementData(numEleLd*2); ElementalLoad *theEle; ElementalLoadIter &theElements = this->getElementalLoads(); int loc = 0; while ((theEle = theElements()) != 0) { elementData(loc) = theEle->getClassTag(); int dbTag = theEle->getDbTag(); if (dbTag == 0 && myDbTag != 0) {// go get a new tag and setDbTag in ele if this not 0 dbTag = theChannel.getDbTag(); if (dbTag != 0) theEle->setDbTag(dbTag); } elementData(loc+1) = dbTag; loc+=2; } // now send the ID if (theChannel.sendID(dbEle, currentGeoTag, elementData) < 0) { opserr << "Domain::send - channel failed to send the element ID\n"; return -5; } } // we do the same for SP_Constraints as for NodalLoads above .. see comments above! if (numSPs != 0) { ID spData(numSPs*2); SP_Constraint *theSP; SP_ConstraintIter &theSPs = this->getSPs(); int loc = 0; while ((theSP = theSPs()) != 0) { spData(loc) = theSP->getClassTag(); int dbTag = theSP->getDbTag(); if (dbTag == 0 && myDbTag != 0) {// go get a new tag and setDbTag in ele if this not 0 dbTag = theChannel.getDbTag(); if (dbTag != 0) theSP->setDbTag(dbTag); } spData(loc+1) = dbTag; loc+=2; } if (theChannel.sendID(dbSPs, currentGeoTag, spData) < 0) { opserr << "LoadPAttern::sendSelf - channel failed sending SP_Constraint ID\n"; return -6; } } // set the lst send db tag so we don't have to do all that again lastGeoSendTag = currentGeoTag; if (theChannel.isDatastore() == 1) { static ID theLastSendTag(1); theLastSendTag(0) = lastGeoSendTag; theChannel.sendID(myDbTag,0, theLastSendTag); } } // now we invoke sendSelf on all the NodalLoads, ElementalLoads and SP_Constraints // which have been added to the LoadCase NodalLoad *theNode; NodalLoadIter &theNodes = this->getNodalLoads(); while ((theNode = theNodes()) != 0) { if (theNode->sendSelf(cTag, theChannel) < 0) { opserr << "LoadPattern::sendSelf - node with tag " << theNode->getTag() << " failed in sendSelf\n"; return -7; } } ElementalLoad *theEle; ElementalLoadIter &theElements = this->getElementalLoads(); while ((theEle = theElements()) != 0) { if (theEle->sendSelf(cTag, theChannel) < 0) { opserr << "LoadPattern::sendSelf - element with tag " << theEle->getTag() << " failed in sendSelf\n"; return -8; } } SP_Constraint *theSP; SP_ConstraintIter &theSPs = this->getSPs(); while ((theSP = theSPs()) != 0) { if (theSP->sendSelf(cTag, theChannel) < 0) { opserr << "LoadPattern::sendSelf - SP_Constraint: " << *theSP << " failed sendSelf\n"; return -9; } } // if we get here we are successfull return 0; }
void Element::setSynchronizedLazyAttribute(const QualifiedName& name, const AtomicString& value) { size_t index = elementData() ? elementData()->attributes().findIndex(name) : kNotFound; setAttributeInternal(index, name, value, InSynchronizationOfLazyAttribute); }