@@ -357,21 +357,21 @@ Combining Values: Interpolation, Addition, and Accumulation</h2>
357357 and <a href="https://www.w3.org/TR/css-animations/">animations</a> ,
358358 <dfn export>combine</dfn> two CSS property values.
359359 The following combining operations--
360- on the two <a>computed values</a> <var> V<sub> A </sub></var> and <var> V<sub> B</sub></var>
360+ on the two <a>computed values</a> <var> V<sub> a </sub></var> and <var> V<sub> B</sub></var>
361361 yielding the <a>computed value</a> <var> V<sub> result</sub></var> --
362362 are defined:
363363
364364 <dl export>
365365 <dt> <dfn id="interpolation" lt="interpolation | interpolate | value interpolation | interpolation procedure">interpolation</dfn>
366366 <dd>
367367 Given two property values
368- <var> V<sub> A </sub></var> and <var> V<sub> B</sub></var> ,
368+ <var> V<sub> a </sub></var> and <var> V<sub> B</sub></var> ,
369369 produces an intermediate value
370370 <var> V<sub> result</sub></var>
371371 at a distance of <var> p</var>
372372 along the interval between
373- <var> V<sub> A </sub></var> and <var> V<sub> B</sub></var>
374- such that <var> p</var> = 0 produces <var> V<sub> A </sub></var>
373+ <var> V<sub> a </sub></var> and <var> V<sub> B</sub></var>
374+ such that <var> p</var> = 0 produces <var> V<sub> a </sub></var>
375375 and <var> p</var> = 1 produces <var> V</var><sub> B</sub> .
376376
377377 The range of <var> p</var> is (−∞, ∞)
@@ -382,12 +382,12 @@ Combining Values: Interpolation, Addition, and Accumulation</h2>
382382 <dt> <dfn id="addition" lt="value addition | addition procedure" local-lt="add | addition">addition</dfn>
383383 <dd>
384384 Given two property values
385- <var> V<sub> A </sub></var> and <var> V<sub> B</sub></var> ,
385+ <var> V<sub> a </sub></var> and <var> V<sub> B</sub></var> ,
386386 returns the sum of the two properties,
387387 <var> V</var><sub> result</sub> .
388388 For addition that is not commutative
389389 (for example, matrix multiplication)
390- <var> V<sub> A </sub></var> represents
390+ <var> V<sub> a </sub></var> represents
391391 the first term of the operation and
392392 <var> V<sub> B</sub></var> represents
393393 the second.
@@ -404,14 +404,14 @@ Combining Values: Interpolation, Addition, and Accumulation</h2>
404404 <dt> <dfn id="accumulation" lt="value accumulation | accumulation procedure" local-lt="accumulate | accumulation">accumulation</dfn>
405405 <dd>
406406 Given two property values
407- <var> V<sub> A </sub></var> and <var> V<sub> B</sub></var> ,
407+ <var> V<sub> a </sub></var> and <var> V<sub> B</sub></var> ,
408408 returns the result, <var> V<sub> result</sub></var> ,
409409 of combining the two operands
410410 such that <var> V<sub> B</sub></var>
411- is treated as a <em> delta</em> from <var> V<sub> A </sub></var> .
411+ is treated as a <em> delta</em> from <var> V<sub> a </sub></var> .
412412 For accumulation that is not commutative
413413 (for example, accumulation of mismatched transform lists)
414- <var> V<sub> A </sub></var> represents the first term of the operation
414+ <var> V<sub> a </sub></var> represents the first term of the operation
415415 and <var> V<sub> B</sub></var> represents the second.
416416
417417 <div class="note">
@@ -439,7 +439,7 @@ Combining Values: Interpolation, Addition, and Accumulation</h2>
439439 If a value type does not define a specific procedure for <a>addition</a>
440440 or is defined as <dfn export>not additive</dfn> ,
441441 its <a>addition</a> operation is simply
442- <var> V<sub> result</sub></var> = <var> V<sub> B </sub></var> .
442+ <var> V<sub> result</sub></var> = <var> V<sub> a </sub></var> .
443443
444444 If a value types does not define a specific procedure for <a>accumulation</a> ,
445445 its <a>accumulation</a> operation is identical to <a>addition</a> .
@@ -711,7 +711,7 @@ Relative URLs</h4>
711711<h5 id='local-urls'>
712712Fragment URLs</h5>
713713
714- To work around some common eccentricities in browser URL handling,
714+ To work around some common eccentriticites in browser URL handling,
715715 CSS has special behavior for fragment-only urls.
716716
717717 If a ''url()'' ’s value starts with a U+0023 NUMBER SIGN (<code> #</code> ) character,
@@ -758,7 +758,7 @@ Empty URLs</h4>
758758
759759 Note: This matches the behavior of empty urls for embedded resources elsewhere in the web platform,
760760 and avoids excess traffic re-requesting the stylesheet or host document
761- due to editing mistakes leaving the ''url()'' value empty,
761+ due to editting mistakes leaving the ''url()'' value empty,
762762 which are almost certain to be invalid resources for whatever the ''url()'' shows up in.
763763 Linking on the web platform <em> does</em> allow empty urls,
764764 so if/when CSS gains some functionality to control hyperlinks,
@@ -1087,7 +1087,7 @@ Mixing Percentages and Dimensions</h3>
10871087<h4 id="combine-mixed">
10881088Combination of Percentage and Dimension Mixes</h4>
10891089
1090- <a>Interpolation</a> of percentage -dimension value combinations
1090+ <a>Interpolation</a> of percengage -dimension value combinations
10911091 (e.g. <<length-percentage>> , <<frequency-percentage>> , <<angle-percentage>> , <<time-percentage>>
10921092 or equivalent notations)
10931093 is defined as
@@ -1220,7 +1220,7 @@ Font-relative Lengths: the ''em'', ''ex'', ''cap'', ''ch'', ''ic'', ''rem'', ''l
12201220 or, in the case of ''rem'' and ''rlh'' , the metrics of the root element.
12211221
12221222 <figure>
1223- <img src="images/Typography_Line_Terms.svg" alt="The word 'Sphinx' annotated with various font metrics: ascender height, to the top of the h's serif; cap height, to the visually approximate top of the S; the x height, to the visually approximate top of the x; the baseline, along the bottom of S, h, i, n, and x; and the descender height, to the bottom of the p.">
1223+ <img src="images/Typography_Line_Terms.svg" alt="The word 'Sphinx' annotated with various font metrics: ascender height, to the top of the h's serif; cap height, to the visually approximate top of the S; the x height, to the visually approximate top of the x; the baseline, along the bottom of S, h, i, n, and x; and the descender height, to the bottom fo the p.">
12241224 <figcaption>
12251225 Common typographic metrics
12261226 </figcaption>
@@ -2472,7 +2472,7 @@ Basic Arithmetic: ''calc()''</h3>
24722472 }
24732473 </pre>
24742474
2475- Although '--ar' <em> could</em> have been written as simply
2475+ Altho '--ar' <em> could</em> have been written as simply
24762476 ''--ar: (16 / 9);'' ,
24772477 '--w' is used both on its own (in 'width' )
24782478 and as a ''calc()'' component (in '--h' ),
@@ -3035,7 +3035,7 @@ Syntax</h3>
30353035
30363036 In addition, [=whitespace=]
30373037 is required on both sides of the <css> +</css> and <css> -</css> operators.
3038- (The <css> *</css> and <css> /</css> operators can be used without white space around them.)
3038+ (The <css> *</css> and <css> /</css> operaters can be used without white space around them.)
30393039
30403040 Several of the math functions above have additional constraints
30413041 on what their <<calc-sum>> arguments can contain.
@@ -3273,12 +3273,202 @@ Type Checking</h3>
32733273 and ''width: 5px;''
32743274 are valid.
32753275
3276- Note: Although there are a few properties in which a bare <<number>>
3276+ Note: Altho there are a few properties in which a bare <<number>>
32773277 becomes a <<length>> at used-value time
32783278 (specifically, 'line-height' and 'tab-size' ),
32793279 <<number>> s never become "length-like" in ''calc()'' .
32803280 They always stay as <<number>> s.
32813281
3282+ <h3 id='calc-internal'>
3283+ Internal Representation</h3>
3284+
3285+ The [=internal representation=] of a [=math function=]
3286+ is a <dfn export>calculation tree</dfn> :
3287+ a tree of operator nodes,
3288+ such as Sum, Product, Min, or Cos,
3289+ with plain values
3290+ (numeric values, such as numbers, dimensions, and percentages,
3291+ and non-math functions that resolve to a numeric type) at the leaves.
3292+ [=Math functions=] are turned into [=calculation trees=]
3293+ depending on the function:
3294+
3295+ <dl class=switch>
3296+ : calc()
3297+ :: The [=internal representation=] of a ''calc()'' function
3298+ is the result of [=parsing a calculation=] from its argument.
3299+ : any other [=math function=]
3300+ :: The [=internal representation=]
3301+ is an operator node with the same name as the function,
3302+ whose children are the result of [=parsing a calculation=]
3303+ from each of the function's arguments,
3304+ in the order they appear.
3305+ </dl>
3306+
3307+ <div algorithm>
3308+ To <dfn export lt="parse a calculation|parsing a calculation">parse a calculation</dfn> ,
3309+ given a [=calculation=] |values|
3310+ represented as a list of [=component values=] ,
3311+ and returning a tree of operator nodes:
3312+
3313+ 1. Discard any <<whitespace-token>> s from |values|.
3314+
3315+ 2. An item in |values| is an “operator”
3316+ if it's a <<delim-token>> with the value "+", "-", "*", or "/".
3317+ Otherwise, it's a “value”.
3318+
3319+ 3. Collect children into Product and Invert nodes.
3320+
3321+ For every consecutive run of value items in |values|
3322+ separated by "*" or "/" operators:
3323+
3324+ 1. For each "/" operator in the run,
3325+ replace its right-hand value item |rhs|
3326+ with an Invert node containing |rhs| as its child.
3327+
3328+ 2. Replace the entire run with a Product node
3329+ containing the value items of the run as its children.
3330+
3331+ 4. Collect children into Sum and Negate nodes.
3332+
3333+ 1. For each "-" operator item in |values|,
3334+ replace its right-hand value item |rhs|
3335+ with a Negate node containing |rhs| as its child.
3336+
3337+ 2. If |values| has only one item,
3338+ and it is a Product node
3339+ or a parenthesized [=simple block=] ,
3340+ replace |values| with that item.
3341+
3342+ Otherwise,
3343+ replace |values| with a Sum node
3344+ containing the value items of |values| as its children.
3345+
3346+
3347+ 5. At this point |values| is
3348+ a tree of Sum, Product, Negate, and Invert nodes,
3349+ with other types of values at the leaf nodes.
3350+ Process the leaf nodes.
3351+
3352+ For every leaf node |leaf| in |values|:
3353+
3354+ 1. If |leaf| is a parenthesized [=simple block=] ,
3355+ replace |leaf|
3356+ with the result of [=parsing a calculation=] from |leaf|’s contents.
3357+
3358+ 2. If |leaf| is a [=math function=] ,
3359+ replace |leaf| with the [=internal representation=] of that math function.
3360+
3361+ 6. Return the result of [=simplifying a calculation tree=] from |values|.
3362+ </div>
3363+
3364+ <h4 id='calc-simplification'>
3365+ Simplification</h4>
3366+
3367+ [=Internal representations=] of [=math functions=] are eagerly simplified to the extent possible,
3368+ using standard algebraic simplifications
3369+ (distributing multiplication over sums,
3370+ combining similar units,
3371+ etc.).
3372+
3373+ <div algorithm>
3374+ To <dfn export local-lt="simplify" lt="simplify a calculation tree|simplifying a calculation tree">simplify a calculation tree</dfn> |root|:
3375+
3376+ 1. If |root| is a numeric value:
3377+ 1. If |root| is a percentage that will be resolved against another value,
3378+ and there is enough information available to resolve it,
3379+ do so,
3380+ and express the resulting numeric value
3381+ in the appropriate [=canonical unit=] .
3382+ Return the value.
3383+
3384+ 2. If |root| is a dimension
3385+ that is not expressed in its [=canonical unit=] ,
3386+ and there is enough information available to convert it to the [=canonical unit=] ,
3387+ do so,
3388+ and return the value.
3389+
3390+ 3. Otherwise, return |root|.
3391+
3392+ 2. If |root| is any other leaf node
3393+ (not an operator node):
3394+
3395+ 1. If there is enough information available to determine its numeric value,
3396+ return its value,
3397+ expressed in the value's [=canonical unit=] .
3398+ 2. Otherwise, return |root|.
3399+
3400+ 2. At this point, |root| is an operator node.
3401+ [=Simplify=] all the children of |root|.
3402+
3403+ 3. If |root| is a
3404+ Min, Max, Clamp,
3405+ Sin, Cos, Tan,
3406+ Asin, Acos, Atan, Atan2,
3407+ Pow, Sqrt, or Hypot node,
3408+ and all of its children are numeric values
3409+ with enough information to computed the operation |root| represents,
3410+ return the result of running |root|'s operation
3411+ using its children,
3412+ expressed in the result's [=canonical unit=] .
3413+
3414+ 4. If |root| is a Negate node:
3415+
3416+ 1. If |root|'s child is a numeric value,
3417+ return an equivalent numeric value,
3418+ but with the value negated
3419+ (0 - value).
3420+ 2. If |root|'s child is a Negate node,
3421+ return the child's child.
3422+ 3. Return |root|.
3423+
3424+ 5. If |root| is an Invert node:
3425+
3426+ 1. If |root|'s child is a number
3427+ (not a percentage or dimension)
3428+ return the reciprocal of the child's value.
3429+ 2. If |root|'s child is an Invert node,
3430+ return the child's child.
3431+ 3. Return |root|.
3432+
3433+ 6. If |root| is a Sum node:
3434+
3435+ 1. For each set of |root|'s children
3436+ that are numeric values with identical units,
3437+ remove those children
3438+ and replace them with a single numeric value
3439+ containing the sum of the removed nodes,
3440+ and with the same unit.
3441+
3442+ (E.g. combine numbers, combine percentages,
3443+ combine px values, etc.)
3444+
3445+ 2. If |root| has only a single child at this point,
3446+ return the child.
3447+ Otherwise, return |root|.
3448+
3449+ 7. If |root| is a Product node:
3450+
3451+ 1. If |root| has multiple children that are numbers
3452+ (not percentages or dimensions),
3453+ remove them and replace them with a single number
3454+ containing the product of the removed nodes.
3455+
3456+ 2. If |root| contains only numeric values
3457+ and/or Invert nodes containing numeric values,
3458+ and [=multiply two types|multiplying the types=]
3459+ of all the children
3460+ (noting that the type of an Invert node
3461+ is the [=invert a type|inverse=] of its child's type)
3462+ results in a type that [=CSSNumericValue/matches=]
3463+ any of the types that a [=math function=] can resolve to,
3464+ return the result of multiplying all the values of the children
3465+ (noting that the value of an Invert node
3466+ is the reciprocal of its child's value),
3467+ expressed in the result's [=canonical unit=] .
3468+
3469+ 3. Return |root|.
3470+ </div>
3471+
32823472<h3 id='calc-computed-value'>
32833473Computed Value</h3>
32843474
@@ -3591,7 +3781,7 @@ Registration for the <code>about:invalid</code> URL scheme</h3>
35913781 <th> Intended Usage
35923782 <td>
35933783 The <code> about:invalid</code> URL references a non-existent document with a generic error condition.
3594- It can be used when a URL is necessary, but the default value shouldn't be resolvable as any type of document.
3784+ It can be used when a URL is necessary, but the default value shouldn't be resolveable as any type of document.
35953785 <tr>
35963786 <th> Contact/Change controller
35973787 <td> CSS WG <<a href="mailto:www-style@w3.org">www-style@w3.org</a> > (on behalf of W3C)
@@ -3663,4 +3853,4 @@ Security and Privacy Considerations</h2>
36633853 This specification defines units that expose the user's screen size
36643854 and default font size,
36653855 but both are trivially observable from JS,
3666- so they do not constitute a new privacy risk.
3856+ so they do not constitutate a new privacy risk.
0 commit comments