MCPcopy Create free account
hub / github.com/Snapchat/Valdi / applyCss

Method applyCss

valdi/src/valdi/runtime/CSS/CSSNode.cpp:300–325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

298}
299
300void CSSNode::applyCss(ViewTransactionScope& viewTransactionScope,
301 const CSSDocument& cssDocument,
302 AttributesApplier& attributesApplier,
303 const SharedAnimator& animator) {
304 auto bestStyleDeclarationByKey = CSSNode::newStyleDeclarationMap();
305
306 insertDeclarations(cssDocument, cssDocument.getRootNode(), attributesApplier, *bestStyleDeclarationByKey);
307
308 if (_lastStyleDeclarations != nullptr) {
309 for (const auto& it : *_lastStyleDeclarations) {
310 if (bestStyleDeclarationByKey->find(it.first) == bestStyleDeclarationByKey->end()) {
311 // If our applied CSS attribute is not among the new CSS attributes
312 // we remove it.
313 attributesApplier.removeAttribute(viewTransactionScope, it.first, this, animator);
314 }
315 }
316 CSSNode::releaseStyleDeclarationMap(std::move(_lastStyleDeclarations));
317 }
318
319 for (const auto& tuple : *bestStyleDeclarationByKey) {
320 const auto& property = tuple.first;
321
322 setAttributeFromDeclaration(viewTransactionScope, property, attributesApplier, tuple.second, animator);
323 }
324 _lastStyleDeclarations = std::move(bestStyleDeclarationByKey);
325}
326
327CSSNode* CSSNode::resolveParent(const CSSDocument& cssDocument) const {
328 if (_parentResolver == nullptr) {

Callers 1

updateCSSMethod · 0.80

Calls 3

endMethod · 0.65
removeAttributeMethod · 0.65
findMethod · 0.45

Tested by

no test coverage detected