|
libcss
|
#include "libcss/hint.h"#include "select/calc.h"#include "select/helpers.h"#include "select/unit.h"#include "utils/utils.h"Macros | |
| #define | DEFAULT_STACK_SIZE 32 |
| #define | CANARY "A css_calculator has leaked" |
| #define | CANARY_SLEN SLEN(CANARY) |
| #define | CALC_PUSH(unit, value) |
| #define | CALC_POP(unit, value) |
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) |
| #define CALC_POP | ( | unit, | |
| value | |||
| ) |
| #define CALC_PUSH | ( | unit, | |
| value | |||
| ) |
| #define CANARY "A css_calculator has leaked" |
| #define DEFAULT_STACK_SIZE 32 |
The default number of entries on a calculator stack
| 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 |