package css

  1. Overview
  2. Docs

Module Css.CSource

Computing values.

Mapping properties to values

Sourcemodule Computed : sig ... end

A Computed.t maps a 'a property to a value of type 'a, if any.

Sourceval opt : t -> 'a P.prop -> 'a option

opt t p returns the computed value of p in t, if any.

Sourceval get : t -> 'a P.prop -> 'a

opt t p returns the computed value of p in t if present or else returns the initial value of p.

Sourceval add : t -> 'a P.prop -> 'a -> t

add t p v adds binding from p to v in t.

Sourceval filter_inherited : t -> t

filter_inherited t returns bindings of t where the property is inherited.

Sourceval empty : t
Sourceval pp : Format.formatter -> t -> unit
Sourceval comp_global : parent:t -> 'a P.prop -> T.global_kw -> 'a

comp_global ~parent p v returns value of p according to global value v, i.e. it returns the initial value of p, of the value of p in parent.

Sourceval get_p : parent:t -> t -> 'a P.prop -> 'a

get_p ~parent t p returns value of p in t. If p is not mapped in t and p is not inherited, returns initial value of p. If p is inherited, returns its value in parent. If p is not mapped in parent, returns initial value of p.

Computing functions

Sourceval to_px : T.number -> T.abs_length_unit -> float
Sourceval px_of_font_size_kw : (T.font_size -> float) ref
Sourceval color : root:'a -> parent:t -> 'b -> T.color -> T.color
Sourceval accent_color : root:'a -> parent:t -> 'b -> [< `Auto | `Current_color | `Named_color of string | `Rgba of float * float * float * float | `System_color of T.system_color | `Transparent ] -> T.accent_color
Sourceval length_of_font_size : t -> float -> [> `em | `ex | `rem ] -> float option
Sourceval length : root:t -> t -> (T.number * [> `In | `cm | `em | `ex | `mm | `pc | `pt | `px | `q | `rem ] as 'a) -> T.number * 'a
Sourceval font_size : root:t -> parent:t -> 'a -> T.font_size -> T.font_size

Computes font_size in px when possible from absolute size or size relative to parent.

Sourceval font_weight : root:'a -> parent:t -> 'b -> T.font_weight -> T.font_weight
Sourceval size : root:t -> parent:'a -> t -> [> `Length of T.number * [> `In | `cm | `em | `ex | `mm | `pc | `pt | `px | `q | `rem ] ] as 'b -> 'b
Sourceval line_height : root:t -> parent:'a -> t -> [< T.line_height ] -> [> T.line_height ]
Sourceval word_spacing : root:t -> parent:'a -> t -> [< T.word_spacing ] -> [> T.word_spacing ]
Sourceval border_spacing : root:t -> parent:'a -> t -> ((T.number * [> `In | `cm | `em | `ex | `mm | `pc | `pt | `px | `q | `rem ] as 'b) * (T.number * [> `In | `cm | `em | `ex | `mm | `pc | `pt | `px | `q | `rem ] as 'c)) -> (T.number * 'b) * (T.number * 'c)
Sourceval border_width_of_kw : (T.border_width_kw -> float) ref
Sourceval border_width : root:t -> parent:'a -> t -> [> `Length of T.number * [> `In | `cm | `em | `ex | `mm | `pc | `pt | `px | `q | `rem ] | `Medium | `Thick | `Thin ] as 'b -> 'b
Sourceval font_family_of_generic : (T.font_family_generic_kw -> string) ref
Sourceval font_family_ : root:'a -> parent:'b -> 'c -> [< T.font_family_ ] -> [> T.font_family_ ]
Sourceval font_family : root:'a -> parent:'b -> 'c -> [< T.font_family_ ] list -> [> T.font_family_ ] list
Sourceval max_size : root:t -> parent:'a -> t -> [> `Length of T.number * [> `In | `cm | `em | `ex | `mm | `pc | `pt | `px | `q | `rem ] ] as 'b -> 'b
Sourceval margin : root:t -> parent:'a -> t -> [> `Length of T.number * [> `In | `cm | `em | `ex | `mm | `pc | `pt | `px | `q | `rem ] ] as 'b -> 'b
Sourceval padding : root:t -> parent:'a -> t -> [> `Length of T.number * [> `In | `cm | `em | `ex | `mm | `pc | `pt | `px | `q | `rem ] ] as 'b -> 'b
Sourceval vertical_align : root:t -> parent:'a -> t -> [> `Length of T.number * [> `In | `cm | `em | `ex | `mm | `pc | `pt | `px | `q | `rem ] ] as 'b -> 'b

Associating computation functions to properties

Sourcetype binding =
  1. | B : 'a P.prop * ((module P.Prop_space) -> root:t -> parent:t -> t -> 'a P.value -> t) -> binding
Sourceval comp : (root:'a -> parent:t -> t -> 'b -> 'b) -> 'b P.prop -> (module P.Prop_space) -> root:'a -> parent:t -> t -> 'b P.value -> Computed.binding P.M.t

comp f p ~root ~parent t v computes value of property p from its parsed value v, in the context of root and parent maps. f is applied on:

  • the result of recursive expansion if v is a variable,
  • the result of comp_global if v is a global keyword,
  • else v.

The resulting computed value is then added to t for property p.

Sourceval map : root:'a -> parent:'b -> 'c -> 'd -> 'd

map ~root ~parent t v returns v, without any computation. This is the default computation for several properties.

Sourceval register_prop_fun : 'a P.prop -> (root:t -> parent:t -> t -> 'a -> 'a) -> unit

register_prop_fun p f registers f as computation function for values of property p. This can be used to override or specify the computation function of a property.

Computing from declarations

Sourceval compute_decl : (module P.Prop_space) -> root:t -> parent:t -> t -> P.binding -> Computed.binding P.M.t
Sourceval compute_decls : (module P.Prop_space) -> root:t -> parent:t -> t -> P.binding list -> t

compute_decls ~root ~parent t decls performs computations of the given declarations decls in the environment of root computed values, parent computed values and current computed values t.

OCaml

Innovation. Community. Security.