1. 序論
この仕様は`~level 4$ に対する差分~仕様である。 ◎ This is a diff spec over [css-images-4].
2. ~2D画像~値: `image^t 型
… ◎ ...
2.1. 画像の~fallbackと注釈: `image$f 記法
`~level 4$ は、 単純な形をとる `image$f 関数を定義する — それは、 単色かつ寸法を伴わない画像を生成する。 この~levelは、 この関数に いくつか追加的な機能を導入する。 ◎ [css-images-4] defines a simple form of the image() function, which generates a solid-color dimensionless image. This level introduces a number of additional functions.
`image$f 関数は、 次を作者に許容する: ◎ The image() function allows an author to:
- `媒体~素片$を利用して, 画像を成すある部位を切抜く。 ◎ use media fragments to clip out a portion of an image
- 単色を画像として利用する。 ◎ use a solid color as an image
- 指定された~URLにある画像が[ ~downloadできない/復号できない ]ときの,単色~画像への~fallbackを指定する。 ◎ fallback to a solid-color image, when the image at the specified url can’t be downloaded or decoded
- 画像の~metadata内に指定された[ 画像の方位 ]に自動的に従うようにする。 ◎ automatically respect the image orientation specified in the image’s metadata
`image$f 記法は、 次で定義される: ◎ The image() notation is defined as:
`image@f = image( `image-tags$t? [ `image-src$t? , `color$t? ]! ) `image-tags@t = ltr | rtl `image-src@t = `url$t | `string$t
`image$f 内で利用される `string$t は、 `url$t を表現する。 ~CSSにおける通例の~URLと同じく、 `image$f 値に指定された相対~URLは, 算出d値を得るときに ( `CSS-VALUES-3$r に述べられるとおりに) 絶対~URLに解決される。 ◎ A <string> used in image() represents a <url>. As usual for URLs in CSS, relative URLs are resolved to an absolute URL (as described in Values & Units [CSS-VALUES-3]) when a specified image() value is computed.
画像の~metadata — EXIF など — 内に方位が指定されていた場合、 ~UAは,指定されたとおりに[ 画像を回転したり裏返して,正しく方位させる ]モノトスル。 ◎ If the image has an orientation specified in its metadata, such as EXIF, the UA must rotate or flip the image to correctly orient it as the metadata specifies.
2.1.1. 画像の~fallback
`image$f 関数に~URLが指定されていて,~URLが[ `無効な画像$/`読込n中の画像$ ]を表現するときは、 その関数は: ◎ ↓
- `color$t も指定されていた場合、 ~URLが元々指定されていなかったかのように`単色~画像@#color-images$を描画する。 ◎ If both a URL and a <color> are specified in image(), then whenever the URL represents an invalid image or loading image, the image() function renders as if the URL were not specified at all; it generates a solid-color image as specified in § 2.1.3 Solid-color Images.
- 他の場合、 同じ[ `無効な画像$/`読込n中の画像$ ]を表現する。 ◎ If just a URL is specified (no <color>) and it represents an invalid image or loading image, the image() function represents the same.
~fallback色を利用すれば、 画像の読込nに失敗したときでも,少なくとも~textは読めるようになる。 例えば次の旧来~codeは、 画像が透明度を伴わない矩形であるならば,~~問題なく働く。 ◎ The fallback color can be used to ensure that text is still readable even when the image fails to load. For example, the following legacy code works fine if the image is rectangular and has no transparency:
body { color: black; background: white; }
p.special { color: white; background: url("dark.png") black; }
画像を読込めないときでも、 背景~色により,白な~textは読める。 しかしながら,画像に透明度がある場合、 背後の黒が可視になり,おそらく欲されない結果になる。 `image$f 関数は、 これに取組む: ◎ When the image doesn’t load, the background color is still there to ensure that the white text is readable. However, if the image has some transparency, the black will be visible behind it, which is probably not desired. The image() function addresses this:
body { color: black; background: white; }
p.special { color: white; background: image("dark.png", black); }
今度は、 画像を読込めたときには黒はまったく示されなくなる一方、 何らかの理由で画像の読込nに失敗した場合には黒がそれに代わり, 白な背景に白な~textが設定されることを防止できる。 ◎ Now, the black won’t show at all if the image loads, but if for whatever reason the image fails, it’ll pop in and prevent the white text from being set against a white background.
2.1.2. 画像~断片
`image$f に指定された~URLが, (例:`媒体~素片~識別子$の利用により) ある資源を成すある部位を表現するとき、 その部位は,その文脈から切抜かれた上で自立的な画像として利用されるようになる。 ◎ When a URL specified in image() represents a portion of a resource (e.g. by the use of media fragment identifiers) that portion is clipped out of its context and used as a standalone image.
例えば,次の画像と~CSSが与えられたとする: ◎ For example, given the following image and CSS:
黒な部分が次第に増える 9 個の円 ◎ [9 circles, with 0 to 8 eighths filled in]
background-image: image('sprites.svg#xywh=80,0,40,40')【!40,0,20,20】
当の要素の背景は、 この画像の, ( 80px【!40px】, 0px ) の所から,右下へ高さ幅ともに 40px【!20px】 を占める部位(画像の中では黒な四分円) で埋尽くされることになる。 ◎ ...the background of the element will be the portion of the image that starts at (40px,0px) and is 20px wide and tall, which is just the circle with a quarter filled in.
作者が[ ~CSSの前方-互換な構文解析~規則の利点を活かして,画像~slice用の~fallbackを供せる ]ようにするため、 `image$f 記法を~supportする実装は,[ `image$f を介して指定された画像 ]用には[ `xywh=#,#,#,#^c の形をとる`媒体~素片~識別子$ `MEDIA-FRAGS$r ]を~supportする`モノトスル^em。 ◎ So that authors can take advantage of CSS’s forwards-compatible parsing rules to provide a fallback for image slices, implementations that support the image() notation must support the xywh=#,#,#,# form of media fragment identifiers for images specified via image(). [MEDIA-FRAGS]
画像~断片は `url$f 記法でも利用し得ることに注意。 しかしながら、 `媒体~素片$の記法を解せない旧来の~UAは,[ 素片を無視して,単純に画像~全体を表示する ]ことになる。 ◎ Note that image fragments can also be used with the url() notation. However, a legacy UA that doesn’t understand the media fragments notation will ignore the fragment and simply display the entirety of the image.
`image$f 記法は,~UAによる`媒体~素片$の~supportを要するので、 作者は,画像~素片~URLを利用するときに[ ~fallbackを供する~CSSの前方-互換な構文解析~規則 ]の利点を活かせる: ◎ Since the image() notation requires UAs to support media fragments, authors can take advantage of CSS’s forward-compatible parsing rules to provide a fallback when using an image fragment URL:
background-image: url('swirl.png'); /* 旧~UA */
background-image: image('sprites.png#xywh=80,0,40,40')【!10,30,60,20】; /* 新~UA */
~URLに利用された素片~識別子の構文が[ 実装が解せない/当の画像~型において妥当でない ]場合、 その~URLは,`無効な画像$を表現しているものとして扱うモノトスル。 ◎ If a URL uses a fragment identifier syntax that the implementation does not understand, or does not consider valid for that type of image, the URL must be treated as representing an invalid image.
注記: 旧来との互換性の理由から、 この~errorの取扱いは, ~URL自体の定義ではなく, `image$f 【の中の~URL】に限られる。 ◎ Note: This error-handling is limited to image(), and not in the definition of URL, for legacy compat reasons.
2.1.3. 単色~画像
`image$f 関数の引数に(~URLなしで) `color$t のみが指定された場合、 `生来な寸法$を伴わない,指定された色による単色~画像を表現する。 ◎ If the image() function is specified with only a <color> argument (no URL), it represents a solid-color image of the specified color with no natural dimensions.
例えば、 他の画像の上層に半透明な色を重ねて背景~画像を “淡く染める” 単純な仕方として利用できる: ◎ For example, one can use this as a simple way to "tint" a background image, by overlaying a partially-transparent color over the top of the other image:
background-image: image(rgba(0,0,255,.5)), url("bg-image.png");
`background-color$p は、 これに対しては働かない。 それが生成する単色は、 常に,すべての背景~画像の`~~背後に回る^emので。 ◎ background-color does not work for this, as the solid color it generates always lies beneath all the background images.
2.1.4. 双向性に応じる画像
作者は、 `image$f 内の `image-src$t の前に,画像~用の方向性( `image-tags$t )を指定してもヨイ — これは、 ~HTML要素に `dir$a 属性を追加することに類似する。 [ 要素に対し/要素~内で ]逆~方向の `direction$p を伴う画像が利用された場合、 その画像は,行内~方向に裏返されるモノトスル (行内~方向が X 軸なら、 例えば `scaleX(-1)^v で変形されたかのように)。 ◎ Before listing any <image-src>s, the author may specify a directionality for the image, similar to adding a dir attribute to an element in HTML. If a directional image is used on or in an element with opposite direction, the image must be flipped in the inline direction (as if it was transformed by, e.g., scaleX(-1), if the inline direction is the X axis).
注記: この宣言が無い場合の既定では、 画像の方向性はまったくないので,周囲の要素の方向性にも応じない。 ◎ Note: Absent this declaration, images default to no directionality at all, and thus don’t care about the directionality of the surrounding element.
ある~listが~bulletとして[ 内容の中を指す矢印 ]を利用していて,[ 左横書きの~textを包含する~list~item, 右横書きのそれ ]が混在している場合、 ~bulletは,左端にも右端にも生じる。 その結果、 一方の側では~textの中を指すよう設計された画像は,他方の側では~textの外を指すことになる。 これは、 次の様な~codeで修正できる: ◎ A list may use an arrow for a bullet that points into the content. If the list can contain both LTR and RTL text, though, the bullet may be on the left or the right, and an image designed to point into the text on one side will point out of the text on the other side. This can be fixed with code like:
<ul style="list-style-image: image(ltr 'arrow.png');"> <li dir='ltr'>~bulletは左にあります。</li> <li dir='rtl'>~bulletは右にあります。</li> </ul>
これは、 次の様に描画されるべきである: ◎ This should render something like:
☞ ~bulletは左にあります。 。すまりあに右は~tellub ☜
【 右横書き呈示を明瞭にする都合により, この例は日本語~textを利用しているが、 実際には,左横書き言語の~textが このように右横書きで呈示されることはない — `bdo^e 要素を利用して右横書きに強制された場合は別として。 】
当の画像は、 左横書き~list~itemにおいては そのまま利用され, 右横書き~list~itemにおいては内容を指すよう行内~方向に裏返されることになる。 ◎ In LTR list items, the image will be used as-is. In the RTL list items, however, it will be flipped in the inline direction, so it still points into the content.
3. ~CSSにおける画像と~objの~sizing
3.1. ~view~boxの設定-法: `object-view-box^p ~prop
`object-view-box$p ~propは、 要素~用の~view~boxを指定する — それは、 当の要素の内容を[ ~zoomする/~panする ]ことを許容する。 それは、 ~SVGにおいては `viewBox$a 属性に対応付けられる。 `SVG2$r ◎ The object-view-box property specifies a "view box" over an element, which allows zooming or panning over the element’s contents. It maps to the <svg viewBox> attribute in SVG. [SVG2]
挙動が`~SVGと適正に整合する@~CSSissue/7058#issuecomment-1057553833$ことを~~確保する。 ◎ Make sure behavior is properly consistent for SVG.
- `none@v
- 当の要素は、 ~view~boxを有さない。 ◎ The element does not have a view box.
- `basic-shape-rect$t
- 当の要素が[ `生来な横幅$, `生来な縦幅$ ]どちらも有さない場合、 この値による効果は無く, `none$v と類似になる。 ◎ If the element does not have both a natural width and a natural height, this value has no effect, similar to none.
-
他の場合、 当の要素~用の~view~boxを指定する: ◎ Otherwise, specifies a view box for the element.
- ~view~boxは、 `basic-shape-rect$t を[ 当の要素の`生来な~size$により形成される`基準~box$ ]を~~基準に解決することにより得される。 ◎ First, resolve the <basic-shape-rect> against a reference box formed by the element’s natural sizes to obtain the element’s view box.
- 当の要素の`生来な~size$は、 すべての目的において,~view~boxの[ 横幅, 縦幅 ]に等しいものとして扱われる。 当の要素が`生来な縦横比$を有する場合、 代わりに~view~boxと同じ比率を有するものとして扱われる。 `object-position$p や `object-fit$p などによる, 当の要素を成す内容の[ ~size/位置 ]に対する更なる調整は、 代わりに,~view~boxに対し遂行される。 ◎ For all purposes, the element is now treated as having natural sizes equal to the view box’s width and height. If the element had a natural aspect ratio, it’s now treated as instead having the same ratio as the view box. Further adjustments to the size/position of the element’s contents, such as object-position or object-fit, are similarly performed on the view box instead.
- 当の要素が塗られるときには、 その内容は,元の`生来な~size$から~view~boxの~sizeへ拡縮され、 更なる調整(前項)があれば,それに則って拡縮され, 並進される。 ◎ When the element is painted, its contents are scaled and translated such that the element’s contents retain the same position and size, relative to the view box’s final size and position, that they had when the view box was determined (above).
~view~boxの面積が 0 の場合に何が起こるかは、 まだ定義されていない。 それは~error事例なので、 精確な挙動は重要でない — [ 実装が,それについて何を行うよう求める ]かを調べる必要があるだけである。 ◎ Have not yet defined what happens if the view box is zero-area. It’s an error case, so precise behavior isn’t important; just need to see what impls want to do about it.
注記: `置換され$る要素には、 組込みの “~view~box” の観念を有するものもある — `svg$e 要素など。 他が指定されない限り、 この~propには,そのような観念との相互作用は無い。 当の組込みの観念には、 通常通り効果があり,当の要素を`生来な~size$で生産する — それから、 この~propが,その上層に適用される。 ◎ Note: Some replaced elements might have a built-in notion of a "view box", such as the svg element. Unless otherwise specified, this property does not interact with such notions; the built-in notion has its effect as normal, producing a replaced element with natural sizes, then this property applies on top of that.
課題: ここに基本的な例を与える必要がある。 ~zoom時における拡大縮小や `object-fit$p との相互作用を明らかにして、 当の~view~boxの外側にある各部がどう塗られ得るかを表示するような。 ◎ Issue: example here. Need a basic one showing off zooming in, one showing off zooming out, and one showing off interaction with object-fit to display how the parts outside the viewbox can still be painted.
~privacyの考慮点
この仕様に対し報告された,新たな~privacyの考慮点は、 無い。 ◎ No new privacy considerations have been reported on this specification.
~securityの考慮点
この仕様に対し報告された,新たな~securityの考慮点は、 無い。 ◎ No new security considerations have been reported on this specification.