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

Method doUpdateViewTree

valdi/src/valdi/runtime/Context/ViewNode.cpp:394–572  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

392
393 if (_scrollState != nullptr) {
394 _scrollState->setNeedsSyncWithView(true);
395 }
396
397 if (hasView()) {
398 _attributesApplier.didAddView(viewTransactionScope, animator);
399
400 callViewCallbackIfNeeded(_onViewCreatedCallback);
401 if (_flags[kLayoutDidCompleteOnceFlag]) {
402 setViewFrameNeedsUpdate();
403 }
404 }
405
406 callViewChangedIfNeeded();
407 }
408}
409
410bool ViewNode::removeView(ViewTransactionScope& viewTransactionScope) {
411 return removeView(viewTransactionScope, true);
412}
413
414bool ViewNode::removeView(ViewTransactionScope& viewTransactionScope, bool safeRemove) {
415 if (hasView()) {
416 if (safeRemove) {
417 // To ensure that we are not going to enqueue a view that has children,
418 // we explicitly remove all the view children from this view.
419 for (auto i = getChildCount(); i > 0; i--) {
420 getChildAt(i - 1)->removeViewFromParent(viewTransactionScope, false);
421 }
422 }
423 setView(viewTransactionScope, nullptr, nullptr);
424 return true;
425 } else {
426 return false;
427 }
428}
429
430bool ViewNode::createView(ViewTransactionScope& viewTransactionScope, const Ref<Animator>& animator) {
431 if (hasView() || isLayout() || _viewNodeTree == nullptr || _viewFactory == nullptr) {
432 return false;
433 }
434
435 bool reusedFromPool = false;
436 auto allowReuse = !_flags[kDisallowViewReuseFlag];
437 auto view = _viewFactory->createView(_viewNodeTree, this, /*allowPool*/ allowReuse, &reusedFromPool);
438
439 if (view != nullptr) {
440 if (!allowReuse) {
441 // allowReuse={false}: the view is new, and it is dropped instead of pooled when removed.
442 view->setCanBeReused(false);
443 }
444 _viewNodeTree->recordViewPoolCreate(reusedFromPool);
445 viewTransactionScope.transaction().moveViewToTree(view, _viewNodeTree, this);
446 setView(viewTransactionScope, view, animator);
447 _flags[kViewFromFactoryFlag] = true;
448 return true;
449 } else {
450 VALDI_WARN(getLogger(), "{} Could not create view with class {}", getLoggerFormatPrefix(), getViewClassName());
451 return false;

Callers

nothing calls this directly

Calls 6

weakRefFunction · 0.85
createViewFunction · 0.85
appendCompletionMethod · 0.80
onFinishedAnimatingMethod · 0.80
lockMethod · 0.45
insertChildViewMethod · 0.45

Tested by

no test coverage detected