|
libcss
|
#include <stdint.h>#include "bytecode/bytecode.h"#include "libcss/errors.h"#include "libcss/unit.h"Go to the source code of this file.
Classes | |
| struct | css_calculator_stack_entry |
| struct | css_calculator |
Functions | |
| css_error | css_calculator_create (css_calculator **out) |
| css_calculator * | css_calculator_ref (css_calculator *calc) |
| void | css_calculator_unref (css_calculator *calc) |
| css_error | css_calculator_calculate (css_calculator *calc, const css_unit_ctx *unit_ctx, int32_t available, lwc_string *expr, const css_computed_style *style, css_unit *unit_out, css_fixed *value_out) |
| css_error css_calculator_calculate | ( | css_calculator * | calc, |
| const css_unit_ctx * | unit_ctx, | ||
| int32_t | available, | ||
| lwc_string * | expr, | ||
| const css_computed_style * | style, | ||
| css_unit * | unit_out, | ||
| css_fixed * | value_out | ||
| ) |
Perform a calculation
To resolve the value of a calc() property, call this function. This will interpret the bytecode in the given expression, with the given display context and available space, and will fill out the computed unit and value.
| calc | The calculator to use |
| unit_ctx | The display context for resolving units |
| available | The available space (for percentages) |
| style | The style from which the expression was derived |
| expr | The expression to compute |
| unit_out | The computed unit is placed here |
| value_out | The computed value is placed here |
| css_error css_calculator_create | ( | css_calculator ** | out | ) |
Create a new CSS calculator
This creates a new CSS calculator with a reference count of one.
The caller is responsible for calling css_calculator_unref when it is done with this calculator.
| out | The created calculator in saved here |
| css_calculator * css_calculator_ref | ( | css_calculator * | calc | ) |
Add a ref to a CSS calculator
If you are storing a calculator in more than one place you should ref it when storing it into a new place. You will neeed to call css_calculator_unref to match any call to this.
| calc | The calculator to add a reference to |
| void css_calculator_unref | ( | css_calculator * | calc | ) |
Unref a CSS calculator
Every call to css_calculator_create or css_calculator_ref must be matched with a call to this function. When the last ref is removed then the underlying calculator is freed.
| calc | The calculator to unref |