| 47 | AttributeHandler::~AttributeHandler() = default; |
| 48 | |
| 49 | Result<Void> AttributeHandler::applyAttribute(ViewTransactionScope& viewTransactionScope, |
| 50 | ViewNode& viewNode, |
| 51 | const Valdi::Value& value, |
| 52 | const SharedAnimator& animator) const { |
| 53 | SC_ASSERT(!requiresView() || viewNode.hasView()); |
| 54 | |
| 55 | Result<Void> result; |
| 56 | auto postprocessedValue = postprocess(viewNode, value); |
| 57 | if (postprocessedValue) { |
| 58 | SC_ASSERT(_delegate != nullptr, "AttributeHandler::applyAttribute called with null delegate"); |
| 59 | if (_delegate == nullptr) { |
| 60 | return Error("AttributeHandler::applyAttribute called with null delegate"); |
| 61 | } |
| 62 | result = _delegate->onApply( |
| 63 | viewTransactionScope, viewNode, viewNode.getView(), _name, postprocessedValue.value(), animator); |
| 64 | } else { |
| 65 | result = postprocessedValue.moveError(); |
| 66 | } |
| 67 | |
| 68 | if (!result) { |
| 69 | return result.error().rethrow(STRING_FORMAT("Failed to apply value {}", value.toString())); |
| 70 | } |
| 71 | |
| 72 | return result; |
| 73 | } |
| 74 | |
| 75 | Result<Value> AttributeHandler::preprocessWithoutCache(const Value& value) const { |
| 76 | auto current = value; |