From 582fe7aed624b981e9f381623c81fafec45593d5 Mon Sep 17 00:00:00 2001 From: Johannes Wilm Date: Wed, 30 Jan 2019 21:33:15 +0100 Subject: [PATCH 1/4] do not download resources separately --- .eslintrc.js | 1 + resources/user-agent-page.css | 121 ---- src/adapt/cssvalid.js | 17 +- src/adapt/ops.js | 13 +- src/adapt/vgen.js | 3 + .../resources/css.js | 137 +++- src/resources/txt.js | 609 ++++++++++++++++++ .../user-agent.xml => src/resources/xml.js | 7 +- src/source-list.js | 1 + tools/build.js | 1 + 10 files changed, 762 insertions(+), 148 deletions(-) delete mode 100644 resources/user-agent-page.css rename resources/user-agent-base.css => src/resources/css.js (80%) create mode 100644 src/resources/txt.js rename resources/user-agent.xml => src/resources/xml.js (84%) diff --git a/.eslintrc.js b/.eslintrc.js index e97f2109f..c78b7a7d1 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -25,6 +25,7 @@ module.exports = { "adapt": false, "goog": false, "vivliostyle": false, + "resources": false, "DataView": false }, // "extends": "eslint:recommended", diff --git a/resources/user-agent-page.css b/resources/user-agent-page.css deleted file mode 100644 index 402028d92..000000000 --- a/resources/user-agent-page.css +++ /dev/null @@ -1,121 +0,0 @@ -@namespace html "http://www.w3.org/1999/xhtml"; -@namespace fb2 "http://www.gribuser.ru/xml/fictionbook/2.0"; - -html|body, fb2|body { - hyphens: -epubx-expr(pref-hyphenate?"auto":"manual"); -} - -@-adapt-footnote-area { - display: block; - margin-block-start: 0.5em; - margin-block-end: 0.5em; -} - -@-adapt-footnote-area ::before { - display: block; - border-block-start-width: 1px; - border-block-start-style: solid; - border-block-start-color: black; - margin-block-end: 0.4em; - margin-inline-start: 0; - margin-inline-end: 60%; -} - -/* default page master */ -@-epubx-page-master :background-host { - @-epubx-partition :layout-host { - -epubx-flow-from: body; - top: -epubx-expr(header.margin-bottom-edge); - bottom: -epubx-expr(page-height - footer.margin-top-edge); - left: 0px; - right: 0px; - column-width: 25em; - } - @-epubx-partition footer :oeb-page-foot { - writing-mode: horizontal-tb; - -epubx-flow-from: oeb-page-foot; - bottom: 0px; - left: 0px; - right: 0px; - } - @-epubx-partition header :oeb-page-head { - writing-mode: horizontal-tb; - -epubx-flow-from: oeb-page-head; - top: 0px; - left: 0px; - right: 0px; - } -} - -@page { - @top-left-corner { - text-align: right; - vertical-align: middle; - } - @top-left { - text-align: left; - vertical-align: middle; - } - @top-center { - text-align: center; - vertical-align: middle; - } - @top-right { - text-align: right; - vertical-align: middle; - } - @top-right-corner { - text-align: left; - vertical-align: middle; - } - @left-top { - text-align: center; - vertical-align: top; - } - @left-middle { - text-align: center; - vertical-align: middle; - } - @left-bottom { - text-align: center; - vertical-align: bottom; - } - @right-top { - text-align: center; - vertical-align: top; - } - @right-middle { - text-align: center; - vertical-align: middle; - } - @right-bottom { - text-align: center; - vertical-align: bottom; - } - @bottom-left-corner { - text-align: right; - vertical-align: middle; - } - @bottom-left { - text-align: left; - vertical-align: middle; - } - @bottom-center { - text-align: center; - vertical-align: middle; - } - @bottom-right { - text-align: right; - vertical-align: middle; - } - @bottom-right-corner { - text-align: left; - vertical-align: middle; - } -} - -@media print { - @page { - margin: 10%; - } -} diff --git a/src/adapt/cssvalid.js b/src/adapt/cssvalid.js index f9a82729c..cc9dd9261 100644 --- a/src/adapt/cssvalid.js +++ b/src/adapt/cssvalid.js @@ -28,6 +28,7 @@ goog.require('adapt.css'); goog.require('adapt.csstok'); goog.require('adapt.cssparse'); goog.require('adapt.expr'); +goog.require('resources.txt'); /** * @interface @@ -2227,22 +2228,10 @@ adapt.cssvalid.ValidatorSet.prototype.validatePropertyAndHandleShorthand = adapt.cssvalid.validatorFetcher = new adapt.taskutil.Fetcher(() => { /** @type {!adapt.task.Frame.} */ const frame = adapt.task.newFrame("loadValidatorSet.load"); - const url = adapt.base.resolveURL("validation.txt", adapt.base.resourceBaseURL); - const result = adapt.net.ajax(url); const validatorSet = new adapt.cssvalid.ValidatorSet(); validatorSet.initBuiltInValidators(); - result.then(xhr => { - try { - if (xhr.responseText) { - validatorSet.parse(xhr.responseText); - } else { - vivliostyle.logging.logger.error("Error: missing", url); - } - } catch (err) { - vivliostyle.logging.logger.error(err, "Error:"); - } - frame.finish(validatorSet); - }); + validatorSet.parse(resources.txt.validation); + frame.finish(validatorSet); return frame.result(); }, "validatorFetcher"); diff --git a/src/adapt/ops.js b/src/adapt/ops.js index 305011836..242972e00 100644 --- a/src/adapt/ops.js +++ b/src/adapt/ops.js @@ -43,6 +43,8 @@ goog.require('adapt.font'); goog.require('vivliostyle.break'); goog.require('vivliostyle.page'); goog.require('vivliostyle.column'); +goog.require('resources.css'); +goog.require('resources.xml'); /** * @type {adapt.taskutil.Fetcher.} @@ -56,7 +58,7 @@ adapt.ops.uaStylesheetBaseFetcher = new adapt.taskutil.Fetcher(() => { validatorSet, true); handler.startStylesheet(adapt.cssparse.StylesheetFlavor.USER_AGENT); adapt.csscasc.uaBaseCascade = handler.cascade; - adapt.cssparse.parseStylesheetFromURL(url, handler, null, null).thenFinish(frame); + adapt.cssparse.parseStylesheetFromText(resources.css.userAgentBase, handler, url, null, null).thenFinish(frame); }); return frame.result(); }, "uaStylesheetBaseFetcher"); @@ -1573,10 +1575,9 @@ adapt.ops.OPSDocStore.prototype.init = function(authorStyleSheets, userStyleShee adapt.cssvalid.loadValidatorSet().then(validatorSet => { self.validatorSet = validatorSet; adapt.ops.loadUABase().then(() => { - self.load(userAgentXML).then(() => { - self.triggerSingleDocumentPreprocessing = true; - frame.finish(true); - }); + this.resources[userAgentXML] = resources.xml.userAgent; + self.triggerSingleDocumentPreprocessing = true; + frame.finish(true); }); }); return frame.result(); @@ -1683,7 +1684,7 @@ adapt.ops.OPSDocStore.prototype.parseOPSResource = function(response) { self.triggersByDocURL[url] = triggers; const sources = /** @type {Array.} */ ([]); const userAgentURL = adapt.base.resolveURL("user-agent-page.css", adapt.base.resourceBaseURL); - sources.push({url: userAgentURL, text:null, + sources.push({url: userAgentURL, text: resources.css.userAgentPage, flavor:adapt.cssparse.StylesheetFlavor.USER_AGENT, classes: null, media: null}); const head = xmldoc.head; if (head) { diff --git a/src/adapt/vgen.js b/src/adapt/vgen.js index d1b7e7928..0630ae0e1 100644 --- a/src/adapt/vgen.js +++ b/src/adapt/vgen.js @@ -457,6 +457,9 @@ adapt.vgen.ViewFactory.prototype.createShadows = function(element, isRoot, cascS cont1.then(shadow => { if (computedStyle["display"] === adapt.css.ident.table_cell) { const url = adapt.base.resolveURL("user-agent.xml#table-cell", adapt.base.resourceBaseURL); + // FIXME: + // What we need here is '
' + // I'm not sure how I can avoid it downloading from the web. cont2 = self.createRefShadow(url, adapt.vtree.ShadowType.ROOTLESS, element, shadowContext, shadow); } else { cont2 = adapt.task.newResult(shadow); diff --git a/resources/user-agent-base.css b/src/resources/css.js similarity index 80% rename from resources/user-agent-base.css rename to src/resources/css.js index 62fc3a490..76329f48b 100644 --- a/resources/user-agent-base.css +++ b/src/resources/css.js @@ -1,3 +1,6 @@ +goog.provide('resources.css'); + +resources.css.userAgentBase = ` @namespace html "http://www.w3.org/1999/xhtml"; html|html, html|address, html|blockquote, html|body, html|dd, html|div, @@ -9,7 +12,7 @@ html|figure, html|figcaption, html|main { display: block; unicode-bidi: normal; } -html|li { +html|li { display: list-item; } html|head { @@ -122,7 +125,7 @@ html|sub { html|sup { vertical-align: super; } -html|table { +html|table { border-spacing: 2px; } html|thead, html|tbody, html|tfoot { @@ -145,7 +148,7 @@ html|ol, html|ul, html|dir, html|menu, html|dd { margin: 0px; margin-inline-start: 40px; } -html|ol { +html|ol { list-style-type: decimal; } html|ol html|ul, html|ul html|ol, html|ul html|ul, html|ol html|ol { @@ -539,7 +542,7 @@ fb2|a[type="note"] { vertical-align: super; line-height: 0.01; text-decoration: none; - -adapt-template: url(user-agent.xml#footnote); + -adapt-template: url(user-agent.xml#footnote); } fb2|body[name="notes"] { @@ -549,7 +552,7 @@ fb2|body[name="notes"] { fb2|body[name="notes"] fb2|title { display: inline; vertical-align: super; - line-height: 0.01; + line-height: 0.01; text-align: left; font-size: 0.75em; font-weight: bold; @@ -577,4 +580,128 @@ fb2|body[name="notes"] fb2|section { } * { text-justify: inherit; +}`; + + +resources.css.userAgentPage = ` +@namespace html "http://www.w3.org/1999/xhtml"; +@namespace fb2 "http://www.gribuser.ru/xml/fictionbook/2.0"; + +html|body, fb2|body { + hyphens: -epubx-expr(pref-hyphenate?"auto":"manual"); } + +@-adapt-footnote-area { + display: block; + margin-block-start: 0.5em; + margin-block-end: 0.5em; +} + +@-adapt-footnote-area ::before { + display: block; + border-block-start-width: 1px; + border-block-start-style: solid; + border-block-start-color: black; + margin-block-end: 0.4em; + margin-inline-start: 0; + margin-inline-end: 60%; +} + +/* default page master */ +@-epubx-page-master :background-host { + @-epubx-partition :layout-host { + -epubx-flow-from: body; + top: -epubx-expr(header.margin-bottom-edge); + bottom: -epubx-expr(page-height - footer.margin-top-edge); + left: 0px; + right: 0px; + column-width: 25em; + } + @-epubx-partition footer :oeb-page-foot { + writing-mode: horizontal-tb; + -epubx-flow-from: oeb-page-foot; + bottom: 0px; + left: 0px; + right: 0px; + } + @-epubx-partition header :oeb-page-head { + writing-mode: horizontal-tb; + -epubx-flow-from: oeb-page-head; + top: 0px; + left: 0px; + right: 0px; + } +} + +@page { + @top-left-corner { + text-align: right; + vertical-align: middle; + } + @top-left { + text-align: left; + vertical-align: middle; + } + @top-center { + text-align: center; + vertical-align: middle; + } + @top-right { + text-align: right; + vertical-align: middle; + } + @top-right-corner { + text-align: left; + vertical-align: middle; + } + @left-top { + text-align: center; + vertical-align: top; + } + @left-middle { + text-align: center; + vertical-align: middle; + } + @left-bottom { + text-align: center; + vertical-align: bottom; + } + @right-top { + text-align: center; + vertical-align: top; + } + @right-middle { + text-align: center; + vertical-align: middle; + } + @right-bottom { + text-align: center; + vertical-align: bottom; + } + @bottom-left-corner { + text-align: right; + vertical-align: middle; + } + @bottom-left { + text-align: left; + vertical-align: middle; + } + @bottom-center { + text-align: center; + vertical-align: middle; + } + @bottom-right { + text-align: right; + vertical-align: middle; + } + @bottom-right-corner { + text-align: left; + vertical-align: middle; + } +} + +@media print { + @page { + margin: 10%; + } +}`; diff --git a/src/resources/txt.js b/src/resources/txt.js new file mode 100644 index 000000000..b15ead228 --- /dev/null +++ b/src/resources/txt.js @@ -0,0 +1,609 @@ +goog.provide('resources.txt'); + +resources.txt.validation = `/* + * Copyright 2013 Google, Inc. + * Copyright 2015 Trim-marks Inc. + * + * Vivliostyle.js is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Vivliostyle.js is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Vivliostyle.js. If not, see . + * + * CSS property validation. + */ +NUM = POS_NUM | ZERO | NEGATIVE; +NNEG_NUM = POS_NUM | ZERO; +INT = POS_INT | ZERO | NEGATIVE; +NNEG_INT = POS_INT | ZERO; +PERCENTAGE = POS_PERCENTAGE | ZERO | NEGATIVE; +STRICT_PERCENTAGE = POS_PERCENTAGE | ZERO_PERCENTAGE | NEGATIVE; +NNEG_PERCENTAGE = POS_PERCENTAGE | ZERO; +LENGTH = POS_LENGTH | ZERO | NEGATIVE; +NNEG_LENGTH = POS_LENGTH | ZERO | NEGATIVE; +PLENGTH = LENGTH | PERCENTAGE; +PPLENGTH = POS_LENGTH | ZERO | POS_PERCENTAGE; +ALENGTH = LENGTH | auto; +APLENGTH = PLENGTH | auto; +PAPLENGTH = PPLENGTH | auto; +ANGLE = POS_ANGLE | ZERO | NEGATIVE; +LENGTH_OR_NUM = LENGTH | NUM; +ANGLE_OR_NUM = ANGLE | NUM; +SCOLOR = HASHCOLOR | aliceblue: #F0F8FF | antiquewhite: #FAEBD7 | aqua: #00FFFF | aquamarine: #7FFFD4 | azure: #F0FFFF | + beige: #F5F5DC | bisque: #FFE4C4 | black: #000000 | blanchedalmond: #FFEBCD | blue: #0000FF | blueviolet: #8A2BE2 | brown: #A52A2A | + burlywood: #DEB887 | cadetblue: #5F9EA0 | chartreuse: #7FFF00 | chocolate: #D2691E | coral: #FF7F50 | cornflowerblue: #6495ED | + cornsilk: #FFF8DC | crimson: #DC143C | cyan: #00FFFF | darkblue: #00008B | darkcyan: #008B8B | darkgoldenrod: #B8860B | + darkgray: #A9A9A9 | darkgreen: #006400 | darkgrey: #A9A9A9 | darkkhaki: #BDB76B | darkmagenta: #8B008B | darkolivegreen: #556B2F | + darkorange: #FF8C00 | darkorchid: #9932CC | darkred: #8B0000 | darksalmon: #E9967A | darkseagreen: #8FBC8F | darkslateblue: #483D8B | + darkslategray: #2F4F4F | darkslategrey: #2F4F4F | darkturquoise: #00CED1 | darkviolet: #9400D3 | deeppink: #FF1493 | + deepskyblue: #00BFFF | dimgray: #696969 | dimgrey: #696969 | dodgerblue: #1E90FF | firebrick: #B22222 | floralwhite: #FFFAF0 | + forestgreen: #228B22 | fuchsia: #FF00FF | gainsboro: #DCDCDC | ghostwhite: #F8F8FF | gold: #FFD700 | goldenrod: #DAA520 | + gray: #808080 | green: #008000 | greenyellow: #ADFF2F | grey: #808080 | honeydew: #F0FFF0 | hotpink: #FF69B4 | indianred: #CD5C5C | + indigo: #4B0082 | ivory: #FFFFF0 | khaki: #F0E68C | lavender: #E6E6FA | lavenderblush: #FFF0F5 | lawngreen: #7CFC00 | + lemonchiffon: #FFFACD | lightblue: #ADD8E6 | lightcoral: #F08080 | lightcyan: #E0FFFF | lightgoldenrodyellow: #FAFAD2 | + lightgray: #D3D3D3 | lightgreen: #90EE90 | lightgrey: #D3D3D3 | lightpink: #FFB6C1 | lightsalmon: #FFA07A | lightseagreen: #20B2AA | + lightskyblue: #87CEFA | lightslategray: #778899 | lightslategrey: #778899 | lightsteelblue: #B0C4DE | lightyellow: #FFFFE0 | + lime: #00FF00 | limegreen: #32CD32 | linen: #FAF0E6 | magenta: #FF00FF | maroon: #800000 | mediumaquamarine: #66CDAA | + mediumblue: #0000CD | mediumorchid: #BA55D3 | mediumpurple: #9370DB | mediumseagreen: #3CB371 | mediumslateblue: #7B68EE | + mediumspringgreen: #00FA9A | mediumturquoise: #48D1CC | mediumvioletred: #C71585 | midnightblue: #191970 | mintcream: #F5FFFA | + mistyrose: #FFE4E1 | moccasin: #FFE4B5 | navajowhite: #FFDEAD | navy: #000080 | oldlace: #FDF5E6 | olive: #808000 | + olivedrab: #6B8E23 | orange: #FFA500 | orangered: #FF4500 | orchid: #DA70D6 | palegoldenrod: #EEE8AA | palegreen: #98FB98 | + paleturquoise: #AFEEEE | palevioletred: #DB7093 | papayawhip: #FFEFD5 | peachpuff: #FFDAB9 | peru: #CD853F | pink: #FFC0CB | + plum: #DDA0DD | powderblue: #B0E0E6 | purple: #800080 | red: #FF0000 | rosybrown: #BC8F8F | royalblue: #4169E1 | + saddlebrown: #8B4513 | salmon: #FA8072 | sandybrown: #F4A460 | seagreen: #2E8B57 | seashell: #FFF5EE | sienna: #A0522D | + silver: #C0C0C0 | skyblue: #87CEEB | slateblue: #6A5ACD | slategray: #708090 | slategrey: #708090 | snow: #FFFAFA | + springgreen: #00FF7F | steelblue: #4682B4 | tan: #D2B48C | teal: #008080 | thistle: #D8BFD8 | tomato: #FF6347 | + turquoise: #40E0D0 | violet: #EE82EE | wheat: #F5DEB3 | white: #FFFFFF | whitesmoke: #F5F5F5 | yellow: #FFFF00 | + yellowgreen: #9ACD32 | transparent | currentcolor; +RGBCOLOR = rgb(INT{3}) | rgb(STRICT_PERCENTAGE{3}); +RGBACOLOR = rgba(NUM{4}) | rgba(STRICT_PERCENTAGE{3} NUM); +HSLCOLOR = hsl(NUM PERCENTAGE{2}); +HSLACOLOR = hsl(NUM PERCENTAGE{2} NUM); +COLOR = SCOLOR | RGBCOLOR | RGBACOLOR | HSLCOLOR | HSLACOLOR; +BG_POSITION_TERM = PLENGTH | left | center | right | top | bottom; +SIDE_OR_CORNER = [left | right] || [top | bottom]; +COLOR_STOP = SPACE(COLOR [PERCENTAGE | LENGTH]?); +LINEAR_GRADIENT = linear-gradient([ANGLE | SPACE(to SIDE_OR_CORNER)]? COLOR_STOP+) | + repeating-linear-gradient([ANGLE | SPACE(to SIDE_OR_CORNER)]? COLOR_STOP+) |; +GRADIENT_EXTENT = closest-corner | closest-side | farthest-corner | farthest-side; +GRADIENT_POSITION = at BG_POSITION_TERM{1,4}; +GRADIENT_SHAPE = SPACE(circle LENGTH? GRADIENT_POSITION?) | SPACE(ellipse PLENGTH{2}? GRADIENT_POSITION?)| SPACE([circle | ellipse] GRADIENT_EXTENT? GRADIENT_POSITION?); +RADIAL_GRADIENT = radial-gradient([GRADIENT_SHAPE | SPACE(GRADIENT_POSITION)]? COLOR_STOP+) | + repeating-radial-gradient([GRADIENT_SHAPE | SPACE(GRADIENT_POSITION)]? COLOR_STOP+); +URI_OR_NONE = URI | none; +IMAGE = URI | LINEAR_GRADIENT | RADIAL_GRADIENT | none; +azimuth = ANGLE | [[ left-side | far-left | left | center-left | center | center-right | right | far-right | right-side ] || behind ] | leftwards | rightwards; +background-attachment = COMMA( [scroll | fixed | local]+ ); +background-color = COLOR; +background-image = COMMA( IMAGE+ ); +background-position = COMMA( SPACE(BG_POSITION_TERM{1,4})+ ); /* relaxed */ +background-repeat = COMMA( [repeat | repeat-x | repeat-y | no-repeat]+ ); +border-collapse = collapse | separate; +BORDER_SIDE_COLOR = COLOR; +BORDER_SIDE_STYLE = none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset; +BORDER_SIDE_WIDTH = thin: 1px | medium: 3px | thick: 5px | NNEG_LENGTH; +border-spacing = LENGTH LENGTH?; +border-top-color = BORDER_SIDE_COLOR; +border-right-color = BORDER_SIDE_COLOR; +border-bottom-color = BORDER_SIDE_COLOR; +border-left-color = BORDER_SIDE_COLOR; +border-top-style = BORDER_SIDE_STYLE; +border-right-style = BORDER_SIDE_STYLE; +border-bottom-style = BORDER_SIDE_STYLE; +border-left-style = BORDER_SIDE_STYLE; +border-top-width = BORDER_SIDE_WIDTH; +border-right-width = BORDER_SIDE_WIDTH; +border-bottom-width = BORDER_SIDE_WIDTH; +border-left-width = BORDER_SIDE_WIDTH; +BORDER_RADIUS = PLENGTH{1,2}; +border-top-left-radius = BORDER_RADIUS; +border-top-right-radius = BORDER_RADIUS; +border-bottom-right-radius = BORDER_RADIUS; +border-bottom-left-radius = BORDER_RADIUS; +border-image-source = IMAGE; +border-image-slice = [NUM | PERCENTAGE]{1,4} || fill; /* relaxed */ +border-image-width = [NUM | PLENGTH | auto]{1,4}; +border-image-outset = [NUM | LENGTH]{1,4}; +border-image-repeat = [ stretch | repeat | round | space ]{1,2}; +bottom = APLENGTH; +caption-side = top | bottom; +clear = none | left | right | top | bottom | both | all | same; +clip = rect(ALENGTH{4}) | rect(SPACE(ALENGTH{4})) | auto; +color = COLOR; +LIST_STYLE_TYPE = disc | circle | square | decimal | decimal-leading-zero | lower-roman | + upper-roman | lower-greek | lower-latin | upper-latin | armenian | georgian | lower-alpha | + upper-alpha | russian | upper-russian | lower-russian | cjk-ideographic | trad-chinese-informal | + hebrew | none; +TYPE_OR_UNIT_IN_ATTR = string | color | url | integer | number | length | angle | time | frequency; +ATTR = attr(SPACE(IDENT TYPE_OR_UNIT_IN_ATTR?) [ STRING | IDENT | COLOR | INT | NUM | PLENGTH | ANGLE | POS_TIME | FREQUENCY]?); +CONTENT = normal | none | + [ STRING | URI | counter(IDENT LIST_STYLE_TYPE?) | + counters(IDENT STRING LIST_STYLE_TYPE?) | ATTR | + target-counter([ STRING | URI ] IDENT LIST_STYLE_TYPE?) | + target-counter(ATTR IDENT LIST_STYLE_TYPE?) | + target-counters([ STRING | URI ] IDENT STRING LIST_STYLE_TYPE?) | + target-counters(ATTR IDENT STRING LIST_STYLE_TYPE?) | + open-quote | close-quote | no-open-quote | no-close-quote ]+; +content = CONTENT; +COUNTER = [ IDENT INT? ]+ | none; +counter-increment = COUNTER; +counter-reset = COUNTER; +counter-set = COUNTER; +cue-after = URI_OR_NONE; +cue-before = URI_OR_NONE; +cursor = COMMA(URI* [ auto | crosshair | default | pointer | move | e-resize | ne-resize | nw-resize | + n-resize | se-resize | sw-resize | s-resize | w-resize | text | wait | help | progress ]); +direction = ltr | rtl; +display = inline | block | list-item | inline-block | table | inline-table | table-row-group | + table-header-group | table-footer-group | table-row | table-column-group | table-column | + table-cell | table-caption | none | oeb-page-head | oeb-page-foot | flex | inline-flex | + ruby | ruby-base | ruby-text | ruby-base-container | ruby-text-container | run-in | compact | marker; +elevation = ANGLE | below | level | above | higher | lower; +empty-cells = show | hide; +FAMILY = SPACE(IDENT+) | STRING; +FAMILY_LIST = COMMA( FAMILY+ ); +font-family = FAMILY_LIST; +font-size = xx-small | x-small | small | medium | large | x-large | xx-large | larger | smaller | PPLENGTH | POS_NUM; +font-style = normal | italic | oblique; +font-variant = normal | small-caps; +font-weight = normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900; +height = PAPLENGTH | POS_NUM ; +left = APLENGTH; +letter-spacing = normal | LENGTH_OR_NUM; +line-height = normal | POS_NUM | PPLENGTH; +list-style-image = IMAGE; +list-style-position = inside | outside; +list-style-type = LIST_STYLE_TYPE; +margin-right = APLENGTH; +margin-left = APLENGTH; +margin-top = APLENGTH; +margin-bottom = APLENGTH; +NPLENGTH = none | PLENGTH; +max-height = NPLENGTH; +max-width = NPLENGTH; +min-height = auto | PLENGTH; +min-width = auto | PLENGTH; +orphans = POS_INT; +outline-offset = LENGTH; +outline-color = COLOR | invert; +outline-style = BORDER_SIDE_STYLE; +outline-width = BORDER_SIDE_WIDTH; +overflow = visible | hidden | scroll | auto; +padding-right = PPLENGTH; +padding-left = PPLENGTH; +padding-top = PPLENGTH; +padding-bottom = PPLENGTH; +PAGE_BREAK = auto | always | avoid | left | right | recto | verso; +page-break-after = PAGE_BREAK; +page-break-before = PAGE_BREAK; +page-break-inside = avoid | auto; +PAUSE = POS_TIME | ZERO | POS_PERCENTAGE; +pause-after = PAUSE; +pause-before = PAUSE; +pitch-range = NUM; +pitch = FREQUENCY | x-low | low | medium | high | x-high; +play-during = [URI [ mix || repeat ]?] | auto | none; +position = static | relative | absolute | fixed; +quotes = [STRING STRING]+ | none; +richness = NUM; +right = APLENGTH; +speak-header = once | always; +speak-numeral = digits | continuous; +speak-punctuation = code | none; +speech-rate = NUM | x-slow | slow | medium | fast | x-fast | faster | slower; +stress = NUM; +table-layout = auto | fixed; +text-align = left | right | center | justify | start | end; +text-decoration = none | [ underline || overline || line-through || blink ]; +text-indent = PLENGTH; +text-transform = capitalize | uppercase | lowercase | none; +top = APLENGTH; +vertical-align = baseline | sub | super | top | text-top | middle | bottom | text-bottom | PLENGTH; +visibility = visible | hidden | collapse; +voice-family = FAMILY_LIST; +volume = NUM | PERCENTAGE | silent | x-soft | soft | medium | loud | x-loud; +white-space = normal | pre | nowrap | pre-wrap | pre-line; +widows = POS_INT; +width = PAPLENGTH | POS_NUM ; +word-spacing = normal | LENGTH_OR_NUM; +z-index = auto | INT; + +[epub,moz,ms,webkit]hyphens = auto | manual | none; +[webkit]hyphenate-character = auto | STRING; + +/* css-logical */ +margin-block-start = APLENGTH; +margin-block-end = APLENGTH; +margin-inline-start = APLENGTH; +margin-inline-end = APLENGTH; +padding-block-start = APLENGTH; +padding-block-end = APLENGTH; +padding-inline-start = APLENGTH; +padding-inline-end = APLENGTH; +border-block-start-color = BORDER_SIDE_COLOR; +border-block-end-color = BORDER_SIDE_COLOR; +border-inline-start-color = BORDER_SIDE_COLOR; +border-inline-end-color = BORDER_SIDE_COLOR; +border-block-start-style = BORDER_SIDE_STYLE; +border-block-end-style = BORDER_SIDE_STYLE; +border-inline-start-style = BORDER_SIDE_STYLE; +border-inline-end-style = BORDER_SIDE_STYLE; +border-block-start-width = BORDER_SIDE_WIDTH; +border-block-end-width = BORDER_SIDE_WIDTH; +border-inline-start-width = BORDER_SIDE_WIDTH; +border-inline-end-width = BORDER_SIDE_WIDTH; +block-start = APLENGTH; +block-end = APLENGTH; +inline-start = APLENGTH; +inline-end = APLENGTH; +block-size = PAPLENGTH | POS_NUM; +inline-size = PAPLENGTH | POS_NUM; +max-block-size = NPLENGTH; +max-inline-size = NPLENGTH; +min-block-size = auto | PLENGTH; +min-inline-size = auto | PLENGTH; + +SHAPE = auto | rectangle( PLENGTH{4} ) | ellipse( PLENGTH{4} ) | circle( PLENGTH{3} ) | + polygon( SPACE(PLENGTH+)+ ); +[epubx]shape-inside = SHAPE; +[epubx,webkit]shape-outside = SHAPE; +[epubx,ms]wrap-flow = auto | both | start | end | maximum | clear | around /* epub al */; + +TRANSFORM_FUNCTION = matrix(NUM{6}) | translate(PLENGTH{1,2}) | translateX(PLENGTH) | translateY(PLENGTH) | + scale(NUM{1,2}) | scaleX(NUM) | scaleY(NUM) | rotate(ANGLE) | skewX(ANGLE) | skewY(ANGLE); +[epub,ms]transform = none | TRANSFORM_FUNCTION+; +[epub,ms]transform-origin = [[[ top | bottom | left | right] PLENGTH?] | center | PLENGTH]{1,2}; /* relaxed */ + +BOX = border-box | padding-box | content-box; +SHADOW = SPACE(inset || LENGTH{2,4} || COLOR); /* relaxed */ +[webkit]background-size = COMMA( SPACE( [PLENGTH | auto ]{1,2} | cover | contain)+ ); +[webkit]background-origin = COMMA( BOX+ ); +[webkit]background-clip = COMMA( BOX+ ); +[webkit]box-shadow = none | COMMA( SHADOW+ ); +text-shadow = none | COMMA( SHADOW+ ); +[webkit]box-decoration-break = slice | clone; +FILTER_FUNCTION = blur(LENGTH) | brightness(NUM | PERCENTAGE) | contrast(NUM | PERCENTAGE) | drop-shadow(SPACE(LENGTH{2,3} COLOR?)) + | grayscale(NUM | PERCENTAGE) | hue-rotate(ANGLE) | invert(NUM | PERCENTAGE) | opacity(NUM | PERCENTAGE) + | saturate(NUM | PERCENTAGE) | sepia(NUM | PERCENTAGE); +FILTER_FUNCTION_LIST = FILTER_FUNCTION+; +[webkit]filter = none | FILTER_FUNCTION_LIST; + +opacity = NUM; + +[moz,webkit]column-width = LENGTH | auto; +[moz,webkit]column-count = INT | auto; +[moz,webkit]column-gap = LENGTH | normal; +[moz,webkit]column-rule-color = COLOR; +[moz,webkit]column-rule-style = BORDER_SIDE_STYLE; +[moz,webkit]column-rule-width = BORDER_SIDE_WIDTH; +BREAK = auto | avoid | avoid-page | page | left | right | recto | verso | avoid-column | column | avoid-region | region; +break-before = BREAK; +break-after = BREAK; +break-inside = auto | avoid | avoid-page | avoid-column | avoid-region; +[webkit]column-span = none | auto | all; +[moz]column-fill = auto | balance | balance-all; + +src = COMMA([SPACE(URI format(STRING+)?) | local(FAMILY)]+); /* for font-face */ + +[epubx,webkit]flow-from = IDENT; +[epubx,webkit]flow-into = IDENT; +[epubx]flow-linger = INT | none; +[epubx]flow-priority = INT; +[epubx]flow-options = none | [ exclusive || last || static ]; +[epubx]page = INT | auto; +[epubx]min-page-width = LENGTH; +[epubx]min-page-height = LENGTH; +[epubx]required = true | false; +[epubx]enabled = true | false; +[epubx]conflicting-partitions = COMMA(IDENT+); +[epubx]required-partitions = COMMA(IDENT+); +[epubx]snap-height = LENGTH | none; +[epubx]snap-width = LENGTH | none; +[epubx]flow-consume = all | some; +[epubx]utilization = NUM; +[epubx]text-zoom = font-size | scale; + +[adapt]template = URI_OR_NONE; +[adapt]behavior = IDENT; + +/* CSS Fonts */ +font-size-adjust = none | NNEG_NUM; +[webkit]font-kerning = auto | normal | none; +font-variant-east-asian = normal | [[ jis78 | jis83 | jis90 | jis04 | simplified | traditional ] || [ full-width | proportional-width ] || ruby]; +font-feature-settings = COMMA( SPACE( STRING [ on | off | INT ]? )+ ); +font-stretch = normal | wider | narrower | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded; + +/* CSS Images */ +image-resolution = RESOLUTION; +object-fit = fill | contain | cover | none | scale-down; +object-position = COMMA( SPACE(BG_POSITION_TERM{1,4})+ ); /* relaxed */ + +/* CSS Paged Media */ +PAGE_SIZE = a5 | a4 | a3 | b5 | b4 | jis-b5 | jis-b4 | letter | legal | ledger; +bleed = auto | LENGTH; +marks = none | [ crop || cross ]; +size = POS_LENGTH{1,2} | auto | [ PAGE_SIZE || [ portrait | landscape ] ]; + +/* CSS Page Floats */ +float-reference = inline | column | region | page; +float = block-start | block-end | inline-start | inline-end | snap-block | snap-inline | left | right | top | bottom | none | footnote; +float-min-wrap-block = PPLENGTH; + +/* CSS Ruby */ +ruby-align = start | center | space-between | space-around; +ruby-position = over | under | inter-character; + +/* CSS Size Adjust */ +[moz,ms]text-size-adjust = auto | none | POS_PERCENTAGE; + +/* CSS Text */ +[ms,webkit]line-break = auto | loose | normal | strict; +overflow-wrap = normal | break-word; +[moz]tab-size = NNEG_INT | NNEG_LENGTH; +[moz,ms]text-align-last = auto | start | end | left | right | center | justify; +[ms]text-justify = auto | none | inter-word | inter-character | inter-ideograph /* specified in UA stylesheet for IE */; +[ms]word-break = normal | keep-all | break-all | break-word; +[ms]word-wrap = normal | break-word; + +/* CSS Text Decoration */ +[webkit]text-decoration-color = COLOR; +[webkit]text-decoration-line = none | [ underline || overline || line-through || blink ]; +[webkit]text-decoration-skip = none | [ objects || spaces || ink || edges || box-decoration ]; +[webkit]text-decoration-style = solid | double | dotted | dashed | wavy; +[epub,webkit]text-emphasis-color = COLOR; +[webkit]text-emphasis-position = [ over | under ] [ right | left ]; +[epub,webkit]text-emphasis-style = none | [[ filled | open ] || [ dot | circle | double-circle | triangle | sesame ]] | STRING; +[ms,webkit]text-underline-position = auto | [ under || [ left | right ]]; + +/* CSS Transforms */ +[ms,webkit]backface-visibility = visible | hidden; + +/* CSS UI */ +box-sizing = content-box | padding-box | border-box; +[ms]text-overflow = [clip | ellipsis | STRING]{1,2}; + +/* CSS Writing Modes */ +[webkit]text-combine = none | horizontal; +[epub,ms]text-combine-horizontal = none | all | [ digits POS_INT? ]; /* relaxed */ +text-combine-upright = none | all | [ digits POS_INT? ]; /* relaxed */ +[epub,webkit]text-orientation = mixed | upright | sideways-right | sideways-left | sideways | use-glyph-orientation /* the following values are kept for backward-compatibility */ | vertical-right | rotate-right | rotate-left | rotate-normal | auto; +unicode-bidi = normal | embed | isolate | bidi-override | isolate-override | plaintext; +[epub,webkit]writing-mode = horizontal-tb | vertical-rl | lr-tb | rl-tb | tb-rl | lr | rl | tb; + +/* CSS Flex box */ +FLEX_BASIS = content | PAPLENGTH; +flex-direction = row | row-reverse | column | column-reverse; +flex-wrap = nowrap | wrap | wrap-reverse; +order = INT; +flex-grow = NNEG_NUM; +flex-shrink = NNEG_NUM; +flex-basis = FLEX_BASIS; +flex = none | [ [ NNEG_NUM NNEG_NUM? ] || FLEX_BASIS ]; +justify-content = flex-start | flex-end | center | space-between | space-around; +align-items = flex-start | flex-end | center | baseline | stretch; +align-self = auto | flex-start | flex-end | center | baseline | stretch; +align-content = flex-start | flex-end | center | space-between | space-around | stretch; + +/* Pointer Events */ +[ms]touch-action = auto | none | [ pan-x || pan-y ] | manipulation; + +/* SVG 2 */ +OPACITY_VALUE = NUM | PERCENTAGE; +DASH_ARRAY = COMMA( SPACE( [ LENGTH | PERCENTAGE | NUM ]+ )+ ); +PAINT = none | child | child(INT) | COLOR | SPACE( URI [none | COLOR]? ) | context-fill | context-stroke; +color-interpolation = auto | sRGB | linearRGB; +color-rendering = auto | optimizeSpeed | optimizeQuality; +fill = PAINT; +fill-opacity = OPACITY_VALUE; +fill-rule = nonzero | evenodd; +glyph-orientation-vertical = auto | NUM | ANGLE; +image-rendering = auto | optimizeSpeed | optimizeQuality | crisp-edges | pixelated; +marker-start = none | URI; +marker-mid = none | URI; +marker-end = none | URI; +pointer-events = bounding-box | visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all | none; +paint-order = normal | [ fill || stroke || markers ]; +shape-rendering = auto | optimizeSpeed | crispEdges | geometricPrecision; +stop-color = COLOR; +stop-opacity = OPACITY_VALUE; +stroke = PAINT; +stroke-dasharray = none | DASH_ARRAY; +stroke-dashoffset = PERCENTAGE | LENGTH_OR_NUM; +stroke-linecap = butt | round | square; +stroke-linejoin = miter | round | bevel; +stroke-miterlimit = NUM; +stroke-opacity = OPACITY_VALUE; +stroke-width = PERCENTAGE | LENGTH_OR_NUM; +text-anchor = start | middle | end; +text-rendering = auto | optimizeSpeed | optimizeLegibility | geometricPrecision; +vector-effect = none | SPACE( [ non-scaling-stroke | non-scaling-size | non-rotation | fixed-position ]+ [ viewport | screen ]? ); + +/* SVG 1.1 */ +alignment-baseline = auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical; +baseline-shift = baseline | sub | super | PERCENTAGE | LENGTH_OR_NUM; +dominant-baseline = auto | use-script | no-change | reset-size | ideographic | alphabetic | hanging | mathematical | central | middle | text-after-edge | text-before-edge; +mask = none | URI; + +/* css-masking-1 */ +SHAPE_RADIUS = PLENGTH | closest-side | farthest-side; +FILL_RULE = nonzero | evenodd; +SHAPE_BOX = BOX | margin-box; +GEOMETRY_BOX = SHAPE_BOX | fill-box | stroke-box | view-box; +BASIC_SHAPE = + inset( SPACE( PLENGTH{1,4} [ round PLENGTH{1,4} [ SLASH PLENGTH{1,4} ]? ]? ) ) + | circle( SPACE( [SHAPE_RADIUS]? [at BG_POSITION_TERM{1,4}]? ) ) + | ellipse( SPACE( SHAPE_RADIUS{2}? [at BG_POSITION_TERM{1,4}]? ) ) + | polygon( FILL_RULE? COMMA( SPACE( PLENGTH{2} )+ )+ ); +[webkit]clip-path = none | URI | [ BASIC_SHAPE || GEOMETRY_BOX ]; +clip-rule = nonzero | evenodd; + +/* filters */ +flood-color = COLOR; +flood-opacity = OPACITY_VALUE; +lighting-color = COLOR; + +/* compositing-1 */ +BLEND_MODE = normal | multiply | screen | overlay | darken | lighten | color-dodge | color-burn | hard-light | soft-light | difference | exclusion | hue | saturation | color | luminosity; +mix-blend-mode = BLEND_MODE; +isolation = auto | isolate; +background-blend-mode = COMMA( BLEND_MODE+ ); + +/* CSS GCPM */ +footnote-policy = auto | line; + +[viv]repeat-on-break = auto | none | header | footer; + +DEFAULTS + +background-attachment: scroll; +background-color: transparent; +background-image: none; +background-repeat: repeat; +background-position: 0% 0%; +background-clip: border-box; +background-origin: padding-box; +background-size: auto; +border-top-color: currentColor; +border-right-color: currentColor; +border-bottom-color: currentColor; +border-left-color: currentColor; +border-top-style: none; +border-right-style: none; +border-bottom-style: none; +border-left-style: none; +border-top-width: 3px; +border-right-width: 3px; +border-bottom-width: 3px; +border-left-width: 3px; +border-top-left-radius: 0; +border-top-right-radius: 0; +border-bottom-right-radius: 0; +border-bottom-left-radius: 0; +border-image-source: none; +border-image-slice: 100%; +border-image-width: 1; +border-image-outset: 0; +border-image-repeat: stretch; +column-count: auto; +column-gap: normal; +column-width: auto; +column-rule-color: currentColor; +column-rule-style: none; +column-rule-width: 3px; +column-fill: balance; +outline-color: currentColor; +outline-style: none; +outline-width: 3px; +flex-direction: row; +flex-wrap: nowrap; +font-family: serif; +font-style: normal; +font-size: medium; +font-variant: normal; +font-weight: normal; +font-stretch: normal; +line-height: normal; +list-style-image: none; +list-style-position: outside; +list-style-type: disc; +margin-bottom: auto; +margin-left: auto; +margin-right: auto; +margin-top: auto; +padding-bottom: auto; +padding-left: auto; +padding-right: auto; +padding-top: auto; +text-emphasis-color: currentColor; +text-emphasis-style: none; +marker-start: none; +marker-mid: none; +marker-end: none; + + +SHORTHANDS + +background = COMMA background-image [background-position [ / background-size ]] background-repeat + background-attachment [background-origin background-clip] background-color; /* background-color is a special case, see the code */ +border-top = border-top-width border-top-style border-top-color; +border-right = border-right-width border-right-style border-right-color; +border-bottom = border-bottom-width border-bottom-style border-bottom-color; +border-left = border-left-width border-left-style border-left-color; +border-width = INSETS border-top-width border-right-width border-bottom-width border-left-width; +border-style = INSETS border-top-style border-right-style border-bottom-style border-left-style; +border-color = INSETS border-top-color border-right-color border-bottom-color border-left-color; +border = border-width border-style border-color; +border-image = border-image-source border-image-slice [ / border-image-width [ / border-image-outset ] ] + border-image-repeat; +border-radius = INSETS_SLASH border-top-left-radius border-top-right-radius + border-bottom-right-radius border-bottom-left-radius; +[moz,webkit]columns = column-width column-count; +[moz,webkit]column-rule = column-rule-width column-rule-style column-rule-color; +flex-flow = flex-direction flex-wrap; +oeb-column-number = column-count; +outline = outline-width outline-style outline-color; +list-style = list-style-type list-style-position list-style-image; +margin = INSETS margin-top margin-right margin-bottom margin-left; +padding = INSETS padding-top padding-right padding-bottom padding-left; +pause = INSETS pause-before pause-after; +font = FONT font-style font-variant font-weight font-stretch /* font-size line-height font-family are special-cased */; +[epub,webkit]text-emphasis = text-emphasis-style text-emphasis-color; +marker = INSETS marker-start marker-mid marker-end; + +/* css-logical */ +margin-block = INSETS margin-block-start margin-block-end; +margin-inline = INSETS margin-inline-start margin-inline-end; +padding-block = INSETS padding-block-start padding-block-end; +padding-inline = INSETS padding-inline-start padding-inline-end; +border-block-width = INSETS border-block-start-width border-block-end-width; +border-block-style = INSETS border-block-start-style border-block-end-style; +border-block-color = INSETS border-block-start-color border-block-end-color; +border-inline-width = INSETS border-inline-start-width border-inline-end-width; +border-inline-style = INSETS border-inline-start-style border-inline-end-style; +border-inline-color = INSETS border-inline-start-color border-inline-end-color; +border-block = border-block-width border-block-style border-block-color; +border-inline = border-inline-width border-inline-style border-inline-color; +border-block-start = border-block-start-width border-block-start-style border-block-start-color; +border-block-end = border-block-end-width border-block-end-style border-block-end-color; +border-inline-start = border-inline-start-width border-inline-start-style border-inline-start-color; +border-inline-end = border-inline-end-width border-inline-end-style border-inline-end-color; +inset-block-start = block-start; +inset-block-end = block-end; +inset-inline-start = inline-start; +inset-inline-end = inline-end; +inset-block = INSETS block-start block-end; +inset-inline = INSETS inline-start inline-end; + +/* old names */ +[adapt,webkit]margin-before = margin-block-start; +[adapt,webkit]margin-after = margin-block-end; +[adapt,webkit]margin-start = margin-inline-start; +[adapt,webkit]margin-end = margin-inline-end; +[adapt,webkit]padding-before = padding-block-start; +[adapt,webkit]padding-after = padding-block-end; +[adapt,webkit]padding-start = padding-inline-start; +[adapt,webkit]padding-end = padding-inline-end; +[adapt,webkit]border-before-color = border-block-start-color; +[adapt,webkit]border-after-color = border-block-end-color; +[adapt,webkit]border-start-color = border-inline-start-color; +[adapt,webkit]border-end-color = border-inline-end-color; +[adapt,webkit]border-before-style = border-block-start-style; +[adapt,webkit]border-after-style = border-block-end-style; +[adapt,webkit]border-start-style = border-inline-start-style; +[adapt,webkit]border-end-style = border-inline-end-style; +[adapt,webkit]border-before-width = border-block-start-width; +[adapt,webkit]border-after-width = border-block-end-width; +[adapt,webkit]border-start-width = border-inline-start-width; +[adapt,webkit]border-end-width = border-inline-end-width; +[adapt,webkit]before = block-start; +[adapt,webkit]after = block-end; +[adapt,webkit]start = inline-start; +[adapt,webkit]end = inline-end; +`; diff --git a/resources/user-agent.xml b/src/resources/xml.js similarity index 84% rename from resources/user-agent.xml rename to src/resources/xml.js index e3feebb1a..3ceb3bddb 100644 --- a/resources/user-agent.xml +++ b/src/resources/xml.js @@ -1,4 +1,7 @@ - +goog.provide('resources.xml'); + + +resources.xml.userAgent = `