diff options
author | bptato <nincsnevem662@gmail.com> | 2024-02-17 00:54:02 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-02-17 01:12:08 +0100 |
commit | 6ec8abb19214835348bb96575455b0a65079741e (patch) | |
tree | db7025ce171d1114d591aca12abb3d03c8d5d42a /src/css | |
parent | 6604bd6dc1fd9ad110fc5ff1f01f3b8b4c787ed8 (diff) | |
download | chawan-6ec8abb19214835348bb96575455b0a65079741e.tar.gz |
layout: use html/body bgcolor as canvas bgcolor
This is required by the standard. (Without this, lots of websites have incorrect background colors, because they set the body height to 100% of the viewport.)
Diffstat (limited to 'src/css')
-rw-r--r-- | src/css/cascade.nim | 5 | ||||
-rw-r--r-- | src/css/values.nim | 14 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/css/cascade.nim b/src/css/cascade.nim index 88f0c211..7741f80a 100644 --- a/src/css/cascade.nim +++ b/src/css/cascade.nim @@ -198,6 +198,8 @@ func calcPresentationalHints(element: Element): CSSComputedValues = of "disc": set_cv "list-style-type", LIST_STYLE_TYPE_DISC of "circle": set_cv "list-style-type", LIST_STYLE_TYPE_CIRCLE of "square": set_cv "list-style-type", LIST_STYLE_TYPE_SQUARE + template set_bgcolor_is_canvas = + set_cv "-cha-bgcolor-is-canvas", true case element.tagType of TAG_DIV: @@ -225,7 +227,10 @@ func calcPresentationalHints(element: Element): CSSComputedValues = of TAG_IMG, TAG_CANVAS: map_width map_height + of TAG_HTML: + set_bgcolor_is_canvas of TAG_BODY: + set_bgcolor_is_canvas map_bgcolor map_text of TAG_TEXTAREA: diff --git a/src/css/values.nim b/src/css/values.nim index 0bf57675..93864212 100644 --- a/src/css/values.nim +++ b/src/css/values.nim @@ -41,7 +41,7 @@ type PROPERTY_MIN_WIDTH, PROPERTY_MIN_HEIGHT, PROPERTY_BACKGROUND_IMAGE, PROPERTY_CHA_COLSPAN, PROPERTY_CHA_ROWSPAN, PROPERTY_FLOAT, PROPERTY_VISIBILITY, PROPERTY_BOX_SIZING, PROPERTY_CLEAR, - PROPERTY_TEXT_TRANSFORM + PROPERTY_TEXT_TRANSFORM, PROPERTY_BGCOLOR_IS_CANVAS CSSValueType* = enum VALUE_NONE, VALUE_LENGTH, VALUE_COLOR, VALUE_CONTENT, VALUE_DISPLAY, @@ -50,7 +50,7 @@ type VALUE_TEXT_ALIGN, VALUE_LIST_STYLE_POSITION, VALUE_POSITION, VALUE_CAPTION_SIDE, VALUE_LENGTH2, VALUE_BORDER_COLLAPSE, VALUE_QUOTES, VALUE_COUNTER_RESET, VALUE_IMAGE, VALUE_FLOAT, VALUE_VISIBILITY, - VALUE_BOX_SIZING, VALUE_CLEAR, VALUE_TEXT_TRANSFORM + VALUE_BOX_SIZING, VALUE_CLEAR, VALUE_TEXT_TRANSFORM, VALUE_BGCOLOR_IS_CANVAS CSSGlobalValueType* = enum VALUE_NOGLOBAL, VALUE_INITIAL, VALUE_INHERIT, VALUE_REVERT, VALUE_UNSET @@ -224,6 +224,8 @@ type clear*: CSSClear of VALUE_TEXT_TRANSFORM: texttransform*: CSSTextTransform + of VALUE_BGCOLOR_IS_CANVAS: + bgcoloriscanvas*: bool of VALUE_NONE: discard CSSComputedValues* = ref array[CSSPropertyType, CSSComputedValue] @@ -300,7 +302,8 @@ const PropertyNames = { "visibility": PROPERTY_VISIBILITY, "box-sizing": PROPERTY_BOX_SIZING, "clear": PROPERTY_CLEAR, - "text-transform": PROPERTY_TEXT_TRANSFORM + "text-transform": PROPERTY_TEXT_TRANSFORM, + "-cha-bgcolor-is-canvas": PROPERTY_BGCOLOR_IS_CANVAS }.toTable() const ValueTypes* = [ @@ -351,7 +354,8 @@ const ValueTypes* = [ PROPERTY_VISIBILITY: VALUE_VISIBILITY, PROPERTY_BOX_SIZING: VALUE_BOX_SIZING, PROPERTY_CLEAR: VALUE_CLEAR, - PROPERTY_TEXT_TRANSFORM: VALUE_TEXT_TRANSFORM + PROPERTY_TEXT_TRANSFORM: VALUE_TEXT_TRANSFORM, + PROPERTY_BGCOLOR_IS_CANVAS: VALUE_BGCOLOR_IS_CANVAS ] const InheritedProperties = { @@ -1196,6 +1200,8 @@ proc getValueFromDecl(val: CSSComputedValue, d: CSSDeclaration, val.clear = ?cssClear(cval) of VALUE_TEXT_TRANSFORM: val.texttransform = ?cssTextTransform(cval) + of VALUE_BGCOLOR_IS_CANVAS: + return err() # internal value of VALUE_NONE: discard return ok() |