From 245e56693416d64d8720b87a704c3f2a5a5a42fb Mon Sep 17 00:00:00 2001 From: oti Date: Fri, 12 May 2023 05:23:04 +0900 Subject: [PATCH 01/86] Fix the description of the display property according to the CSS specification (#26612) * change: `block element box` -> `block level box` * change: `inline element boxes` -> `inline level boxes` * change: `block element` -> `block level` * change: `inline element` -> `inline level` * fix: `inline/block level box` -> `inline/block box` * change: `inline/block level` -> `inline-level/block-level element` * fix: `block level` -> `block-level element` --- files/en-us/web/css/display/index.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/files/en-us/web/css/display/index.md b/files/en-us/web/css/display/index.md index 9a06d1e32c4585b..66a8ab51d0eb266 100644 --- a/files/en-us/web/css/display/index.md +++ b/files/en-us/web/css/display/index.md @@ -7,7 +7,7 @@ browser-compat: css.properties.display {{CSSRef}} -The **`display`** [CSS](/en-US/docs/Web/CSS) property sets whether an element is treated as a [block or inline element](/en-US/docs/Web/CSS/CSS_Flow_Layout) and the layout used for its children, such as [flow layout](/en-US/docs/Web/CSS/CSS_Flow_Layout), [grid](/en-US/docs/Web/CSS/CSS_Grid_Layout) or [flex](/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout). +The **`display`** [CSS](/en-US/docs/Web/CSS) property sets whether an element is treated as a [block or inline box](/en-US/docs/Web/CSS/CSS_Flow_Layout) and the layout used for its children, such as [flow layout](/en-US/docs/Web/CSS/CSS_Flow_Layout), [grid](/en-US/docs/Web/CSS/CSS_Grid_Layout) or [flex](/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout). Formally, the **`display`** property sets an element's inner and outer _display types_. The outer type sets an element's participation in [flow layout](/en-US/docs/Web/CSS/CSS_Flow_Layout); the inner type sets the layout of children. Some values of `display` are fully defined in their own individual specifications; for example the detail of what happens when `display: flex` is declared is defined in the CSS Flexible Box Model specification. @@ -66,9 +66,9 @@ The keyword values can be grouped into six value categories. - : These keywords specify the element's outer display type, which is essentially its role in flow layout: - `block` - - : The element generates a block element box, generating line breaks both before and after the element when in the normal flow. + - : The element generates a block box, generating line breaks both before and after the element when in the normal flow. - `inline` - - : The element generates one or more inline element boxes that do not generate line breaks before or after themselves. In normal flow, the next element will be on the same line if there is space. + - : The element generates one or more inline boxes that do not generate line breaks before or after themselves. In normal flow, the next element will be on the same line if there is space. > **Note:** Browsers that support the multi-keyword syntax, on finding the outer value only, such as when `display: block` or `display: inline` is specified, will set the inner value to `flow`. > This will result in expected behavior; for example, if you specify an element to be block, you would expect that the children of that element would participate in block and inline normal flow layout. @@ -88,15 +88,15 @@ The keyword values can be grouped into six value categories. Depending on the value of other properties (such as {{CSSxRef("position")}}, {{CSSxRef("float")}}, or {{CSSxRef("overflow")}}) and whether it is itself participating in a block or inline formatting context, it either establishes a new [block formatting context](/en-US/docs/Web/Guide/CSS/Block_formatting_context) (BFC) for its contents or integrates its contents into its parent formatting context. - `flow-root` - - : The element generates a block element box that establishes a new [block formatting context](/en-US/docs/Web/Guide/CSS/Block_formatting_context), defining where the formatting root lies. + - : The element generates a block box that establishes a new [block formatting context](/en-US/docs/Web/Guide/CSS/Block_formatting_context), defining where the formatting root lies. - `table` - : These elements behave like HTML {{HTMLElement("table")}} elements. It defines a block-level box. - `flex` - - : The element behaves like a block element and lays out its content according to the [flexbox model](/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout). + - : The element behaves like a block-level element and lays out its content according to the [flexbox model](/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout). - `grid` - - : The element behaves like a block element and lays out its content according to the [grid model](/en-US/docs/Web/CSS/CSS_Grid_Layout/Basic_Concepts_of_Grid_Layout). + - : The element behaves like a block-level element and lays out its content according to the [grid model](/en-US/docs/Web/CSS/CSS_Grid_Layout/Basic_Concepts_of_Grid_Layout). - `ruby` {{Experimental_Inline}} - - : The element behaves like an inline element and lays out its content according to the ruby formatting model. It behaves like the corresponding HTML {{HTMLElement("ruby")}} elements. + - : The element behaves like an inline-level element and lays out its content according to the ruby formatting model. It behaves like the corresponding HTML {{HTMLElement("ruby")}} elements. > **Note:** Browsers that support the multi-keyword syntax, on finding the inner value only, such as when `display: flex` or `display: grid` is specified, will set their outer value to `block`. > This will result in expected behavior; for example, if you specify an element to be `display: grid`, you would expect that the box created on the grid container would be a block-level box. @@ -168,7 +168,7 @@ This can be used together with {{CSSxRef("list-style-type")}} and {{CSSxRef("lis - `inline-block` - - : The element generates a block element box that will be flowed with surrounding content as if it were a single inline box (behaving much like a replaced element would). + - : The element generates a block box that will be flowed with surrounding content as if it were a single inline box (behaving much like a replaced element would). It is equivalent to `inline flow-root`. @@ -180,13 +180,13 @@ This can be used together with {{CSSxRef("list-style-type")}} and {{CSSxRef("lis - `inline-flex` - - : The element behaves like an inline element and lays out its content according to the flexbox model. + - : The element behaves like an inline-level element and lays out its content according to the flexbox model. It is equivalent to `inline flex`. - `inline-grid` - - : The element behaves like an inline element and lays out its content according to the grid model. + - : The element behaves like an inline-level element and lays out its content according to the grid model. It is equivalent to `inline grid`. From f2b566d968271d16addc71e7e9dda5f52cb65a3a Mon Sep 17 00:00:00 2001 From: yarusome <97945148+yarusome@users.noreply.github.com> Date: Fri, 12 May 2023 04:25:38 +0800 Subject: [PATCH 02/86] Adding missing sections for `container*` (#25739) * Update sections for `container` * Update sections for `container-name` * Update sections for `container-type` * Update files/en-us/web/css/container-name/index.md --------- Co-authored-by: Estelle Weyl Co-authored-by: Estelle Weyl Co-authored-by: Brian Thomas Smith --- files/en-us/web/css/container-name/index.md | 23 +++++++++++++++++++-- files/en-us/web/css/container-type/index.md | 20 +++++++++++++++++- files/en-us/web/css/container/index.md | 21 ++++++++++++++++++- 3 files changed, 60 insertions(+), 4 deletions(-) diff --git a/files/en-us/web/css/container-name/index.md b/files/en-us/web/css/container-name/index.md index e18b0d4137f848c..e0c54ffb70dad61 100644 --- a/files/en-us/web/css/container-name/index.md +++ b/files/en-us/web/css/container-name/index.md @@ -13,8 +13,19 @@ When a containment context is given a name, it can be specifically targeted usin ## Syntax -```plain -container-name: ; +```css +/* A single name */ +container-name: myLayout; + +/* Multiple names */ +container-name: myPageLayout myComponentLibrary; + +/* Global Values */ +container-name: inherit; +container-name: initial; +container-name: revert; +container-name: revert-layer; +container-name: unset; ``` ### Values @@ -30,6 +41,14 @@ container-name: ; - The dashed ident intended to denote author-defined identifiers (e.g., `--container-name`) is permitted. - A list of multiple names separated by a space is allowed. +## Formal definition + +{{CSSInfo}} + +## Formal syntax + +{{CSSSyntax}} + ## Examples ### Using a container name diff --git a/files/en-us/web/css/container-type/index.md b/files/en-us/web/css/container-type/index.md index f579383aad85a01..2d2b8ac855e9d07 100644 --- a/files/en-us/web/css/container-type/index.md +++ b/files/en-us/web/css/container-type/index.md @@ -12,7 +12,17 @@ The **container-type** [CSS](/en-US/docs/Web/CSS) property is used to define the ## Syntax ```css -container-type: ; +/* Keyword values */ +container-type: normal; +container-type: size; +container-type: inline-size; + +/* Global Values */ +container-type: inherit; +container-type: initial; +container-type: revert; +container-type: revert-layer; +container-type: unset; ``` ### Values @@ -32,6 +42,14 @@ container-type: ; > **Note:** to understand what happens when you apply layout, style, and size containment to a box, see the {{cssxref("contain")}} property. +## Formal definition + +{{CSSInfo}} + +## Formal syntax + +{{CSSSyntax}} + ## Example Given the following HTML example which is a card component with an image, a title, and some text: diff --git a/files/en-us/web/css/container/index.md b/files/en-us/web/css/container/index.md index f73fff796e2f745..b511130d8fc9291 100644 --- a/files/en-us/web/css/container/index.md +++ b/files/en-us/web/css/container/index.md @@ -12,7 +12,18 @@ The **container** [shorthand](/en-US/docs/Web/CSS/Shorthand_properties) [CSS](/e ## Syntax ```css -container: / ; +/* */ +container: my-layout; + +/* / */ +container: my-layout / size; + +/* Global Values */ +container: inherit; +container: initial; +container: revert; +container: revert-layer; +container: unset; ``` ### Values @@ -24,6 +35,14 @@ container: / ; - : The type of containment context. More details on the syntax are covered in the {{cssxref("container-type")}} property page. +## Formal definition + +{{CSSInfo}} + +## Formal syntax + +{{CSSSyntax}} + ## Example Given the following HTML example which is a card component with an image, a title, and some text: From e9830ea66151f0c1ff6a32256790e0f24f01a4fa Mon Sep 17 00:00:00 2001 From: Dipika Bhattacharya Date: Thu, 11 May 2023 16:32:19 -0400 Subject: [PATCH 03/86] fix(prefers-reduced-motion): Edit text and improve example (#26630) * edits to page for clarity * improve example explanation * fix review comments * Update files/en-us/web/css/@media/prefers-reduced-motion/index.md --------- Co-authored-by: Estelle Weyl --- .../@media/prefers-reduced-motion/index.md | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/files/en-us/web/css/@media/prefers-reduced-motion/index.md b/files/en-us/web/css/@media/prefers-reduced-motion/index.md index ead01f74f8477d0..e676fb4220d991f 100644 --- a/files/en-us/web/css/@media/prefers-reduced-motion/index.md +++ b/files/en-us/web/css/@media/prefers-reduced-motion/index.md @@ -9,20 +9,22 @@ browser-compat: css.at-rules.media.prefers-reduced-motion > **Warning:** An embedded example at the bottom of this page has a scaling movement that may be problematic for some readers. Readers with vestibular motion disorders may wish to enable the reduce motion feature on their device before viewing the animation. -The **`prefers-reduced-motion`** [CSS](/en-US/docs/Web/CSS) [media feature](/en-US/docs/Web/CSS/Media_Queries/Using_media_queries#media_features) is used to detect if the user has requested that the system either minimize the amount of non-essential motion used or remove animations altogether, depending on available user preference setting. +The **`prefers-reduced-motion`** [CSS](/en-US/docs/Web/CSS) [media feature](/en-US/docs/Web/CSS/@media#media_features) is used to detect if a user has enabled a setting on their device to minimize the amount of non-essential motion. The setting is used to convey to the browser on the device that the user prefers an interface that removes, reduces, or replaces motion-based animations. + +Such animations can trigger discomfort for those with [vestibular motion disorders](https://www.a11yproject.com/posts/understanding-vestibular-disorders/). Animations such as scaling or panning large objects can be vestibular motion triggers. ```css @media (prefers-reduced-motion) { - /* styles to apply if the user's settings are set to reduced motion */ + /* styles to apply if a user's device settings are set to reduced motion */ } ``` ## Syntax - `no-preference` - - : Indicates that the user has made no preference known to the system. + - : Indicates that a user has made no preference known on the device. This keyword value evaluates as false. - `reduce` - - : Indicates that the user has notified the system that they prefer an interface that removes or replaces the types of motion-based animation. + - : Indicates that a user has enabled the setting on their device for reduced motion. This keyword value evaluates as true. ## User preferences @@ -43,32 +45,36 @@ For Firefox, the `reduce` request is honoured if: ## Examples -This example has a scaling animation by default. If Reduce Motion or Remove Animations is enabled in your accessibility preferences, the animation is toned down to a simple dissolve without vestibular motion triggers. +This example uses a scaling animation for the purpose of demonstrating `prefers-reduced-motion`. If you enable the setting for reducing motion in the accessibility preferences on your device, the `prefers-reduced-motion` media query will detect your preference and the CSS within the reduced motion rules, with the same [specificity](/en-US/docs/Web/CSS/Specificity) but coming later in the [CSS source order](/en-US/docs/Learn/CSS/Building_blocks/Cascade_and_inheritance#source_order), will take precedence. As a result, the [animation](/en-US/docs/Web/CSS/CSS_Animations/Using_CSS_animations) on the box will tone down to the `dissolve` animation, which is a more muted animation that is not a vestibular motion trigger. + +### Toning down the animation scaling -### HTML +#### HTML ```html
animated box
``` -### CSS +#### CSS ```css .animation { animation: pulse 1s linear infinite both; + background-color: purple; } -/* Tone down the animation to avoid vestibular motion triggers like scaling or panning large objects. */ +/* Tone down the animation to avoid vestibular motion triggers. */ @media (prefers-reduced-motion) { .animation { - animation: dissolve 2s linear infinite both; + animation: dissolve 4s linear infinite both; + background-color: green; + text-decoration: overline; } } ``` ```css hidden .animation { - background-color: #306; color: #fff; font: 1.2em sans-serif; width: 10em; @@ -100,7 +106,7 @@ This example has a scaling animation by default. If Reduce Motion or Remove Anim opacity: 1; } 50% { - opacity: 0.8; + opacity: 0.3; } 100% { opacity: 1; @@ -108,9 +114,11 @@ This example has a scaling animation by default. If Reduce Motion or Remove Anim } ``` -### Result +#### Result + +{{EmbedLiveSample("Toning down the animation scaling")}} -{{EmbedLiveSample("Examples")}} +You can enable the setting for reducing motion on [your device](#user_preferences) to view the change in animation scaling. This example uses the background color and the line over the text to visually highlight when the keyframe animation switches in response to the setting being enabled or disabled. ## Specifications @@ -122,5 +130,5 @@ This example has a scaling animation by default. If Reduce Motion or Remove Anim ## See also -- [An Introduction to the Reduced Motion Media Query (CSS Tricks)](https://css-tricks.com/introduction-reduced-motion-media-query/) -- [Responsive Design for Motion (WebKit Blog)](https://webkit.org/blog/7551/responsive-design-for-motion/) includes vestibular motion trigger examples. +- [An introduction to the reduced motion media query](https://css-tricks.com/introduction-reduced-motion-media-query/) on CSS-Tricks (April 24, 2019) +- [Responsive design for motion](https://webkit.org/blog/7551/responsive-design-for-motion/) on WebKit Blog (May 15, 2017) From bb3255f7a7ca31f530f4700127d4a9abeee3a4ac Mon Sep 17 00:00:00 2001 From: Ctibor Laky Date: Fri, 12 May 2023 01:39:48 +0200 Subject: [PATCH 04/86] Added info for 'muted' driven emission (#26641) * Added info for 'muted' driven emission Fixing missing information that muting also fires this event. Standard spec: https://html.spec.whatwg.org/multipage/media.html#event-media-volumechange * Update files/en-us/web/api/htmlmediaelement/volumechange_event/index.md * lint --------- Co-authored-by: wbamberg --- .../en-us/web/api/htmlmediaelement/volumechange_event/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/en-us/web/api/htmlmediaelement/volumechange_event/index.md b/files/en-us/web/api/htmlmediaelement/volumechange_event/index.md index d0b068a84de3943..1f9f1f5ec077fa2 100644 --- a/files/en-us/web/api/htmlmediaelement/volumechange_event/index.md +++ b/files/en-us/web/api/htmlmediaelement/volumechange_event/index.md @@ -8,7 +8,7 @@ browser-compat: api.HTMLMediaElement.volumechange_event {{APIRef("HTMLMediaElement")}} -The `volumechange` event is fired when the volume has changed. +The `volumechange` event is fired when either the {{domxref("HTMLMediaElement.volume", "volume")}} attribute or the {{domxref("HTMLMediaElement.muted", "muted")}} attribute has changed. This event is not cancelable and does not bubble. From ae36b1dcba1ff033983c58116d3df1dd72164ab6 Mon Sep 17 00:00:00 2001 From: CanadaHonk <19228318+CanadaHonk@users.noreply.github.com> Date: Fri, 12 May 2023 01:54:21 +0100 Subject: [PATCH 05/86] Add page for prefers-reduced-transparency (#25289) * Add page for prefers-reduced-transparency * Update page for prefers-reduced-transparency Changed text as requested in PR comments. --------- Co-authored-by: Brian Thomas Smith Co-authored-by: Dipika Bhattacharya --- .../prefers-reduced-transparency/index.md | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 files/en-us/web/css/@media/prefers-reduced-transparency/index.md diff --git a/files/en-us/web/css/@media/prefers-reduced-transparency/index.md b/files/en-us/web/css/@media/prefers-reduced-transparency/index.md new file mode 100644 index 000000000000000..325662f3741a2c8 --- /dev/null +++ b/files/en-us/web/css/@media/prefers-reduced-transparency/index.md @@ -0,0 +1,72 @@ +--- +title: prefers-reduced-transparency +slug: Web/CSS/@media/prefers-reduced-transparency +page-type: css-media-feature +status: + - experimental +browser-compat: css.at-rules.media.prefers-reduced-transparency +--- + +{{CSSRef}}{{SeeCompatTable}} + +The **`prefers-reduced-transparency`** [CSS](/en-US/docs/Web/CSS) [media feature](/en-US/docs/Web/CSS/Media_Queries/Using_media_queries#media_features) is used to detect if a user has enabled a setting on their device to reduce the transparent or translucent layer effects used on the device. Switching on such a setting can help improve contrast and readability for some users. + +## Syntax + +- `no-preference` + - : Indicates that a user has made no preference known on the device. This keyword value evaluates as false in the boolean context. +- `reduce` + - : Indicates that a user has enabled the setting on their device to minimize the amount of transparent or translucent layer effects. + +## User preferences + +For Firefox, the `reduce` request is honored if a dedicated system-specific setting exists, otherwise it is enabled if reduced motion is also enabled: + +- In GTK/GNOME: Settings > Accessibility > Seeing > Reduced animation is turned on. + + - In older versions of GNOME, GNOME Tweaks > General tab (or Appearance, depending on version) > Animations is turned off. + - Alternatively, add `gtk-enable-animations = false` to the `[Settings]` block of [the GTK 3 configuration file](https://wiki.archlinux.org/title/GTK#Configuration). + +- In Plasma/KDE: System Settings > Workspace Behavior -> General Behavior > "Animation speed" is set all the way to right to "Instant". +- In Windows 10: Settings > Personalization > Colors > Transparency effects. +- In Windows 11: Settings > Personalization > Colors > Transparency effects. +- In macOS: System Preferences > Accessibility > Display > Reduce transparency. +- In iOS: Settings > Accessibility > Motion. +- In Android 9+: Settings > Accessibility > Remove animations. + +## Examples + +This example has a translucent box by default. If the setting to reduce transparency is enabled in the accessibility preferences on your device, the translucent box becomes more opaque. + +### HTML + +```html +
translucent box
+``` + +### CSS + +```css +.translucent { + opacity: 0.4; +} + +@media (prefers-reduced-transparency) { + .translucent { + opacity: 0.8; + } +} +``` + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- CSS [prefers-reduced-motion](/en-US/docs/Web/CSS/@media/prefers-reduced-motion) media query +- [Using media queries](/en-US/docs/Web/CSS/Media_Queries/Using_media_queries) From 48291f1fb822579ca22d429bde189314abdd99fb Mon Sep 17 00:00:00 2001 From: nintendoit <91181094+nintendoit@users.noreply.github.com> Date: Fri, 12 May 2023 07:42:01 +0530 Subject: [PATCH 06/86] Fix arrow syntax explanation (#26704) * remove bracket around the parameter The example should omit the brackets around the parameter, as described in the explanation above this code. * Update files/en-us/learn/javascript/building_blocks/functions/index.md * Update files/en-us/learn/javascript/building_blocks/functions/index.md * Update index.md --------- Co-authored-by: Joshua Chen --- .../building_blocks/functions/index.md | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/files/en-us/learn/javascript/building_blocks/functions/index.md b/files/en-us/learn/javascript/building_blocks/functions/index.md index 6a9466ead75b034..d75460fab98efb1 100644 --- a/files/en-us/learn/javascript/building_blocks/functions/index.md +++ b/files/en-us/learn/javascript/building_blocks/functions/index.md @@ -234,23 +234,15 @@ textBox.addEventListener("keydown", (event) => { }); ``` -If the function only has one line in the curly brackets, you omit the curly brackets: +If the function only takes one parameter, you can omit the brackets around the parameter: -```js -textBox.addEventListener("keydown", (event) => - console.log(`You pressed "${event.key}".`) -); -``` - -If the function only takes one parameter, you can also omit the brackets around the parameter: - -```js -textBox.addEventListener("keydown", (event) => - console.log(`You pressed "${event.key}".`) -); +```js-nolint +textBox.addEventListener("keydown", event => { + console.log(`You pressed "${event.key}".`); +}); ``` -Finally, if your function needs to return a value, and contains only one line, you can also omit the `return` statement. In the following example we're using the {{jsxref("Array.prototype.map()","map()")}} method of `Array` to double every value in the original array: +Finally, if your function contains only one line that's a `return` statement, you can also omit the braces and the `return` keyword, and implicitly return the expression. In the following example we're using the {{jsxref("Array.prototype.map()","map()")}} method of `Array` to double every value in the original array: ```js const originals = [1, 2, 3]; @@ -270,6 +262,16 @@ function doubleItem(item) { } ``` +You can use the same concise syntax to rewrite the `addEventListener` example. + +```js +textBox.addEventListener("keydown", (event) => + console.log(`You pressed "${event.key}".`) +); +``` + +In this case, the value of `console.log()`, which is `undefined`, is implicitly returned from the callback function. + We recommend that you use arrow functions, as they can make your code shorter and more readable. To learn more, see the [section on arrow functions in the JavaScript guide](/en-US/docs/Web/JavaScript/Guide/Functions#arrow_functions), and our [reference page on arrow functions](/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions). > **Note:** There are some subtle differences between arrow functions and normal functions. They're outside the scope of this introductory guide, and are unlikely to make a difference in the cases we've discussed here. To learn more, see the [arrow function reference documentation](/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions). From 33e054640393bb70c43b0ef92c3017f0aec6c05e Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Fri, 12 May 2023 13:08:55 +1000 Subject: [PATCH 07/86] Add RTCAudioSourceStats (#26667) * Add RTCAudioSourceStats * Update files/en-us/web/api/rtcaudiosourcestats/index.md Co-authored-by: wbamberg * Apply suggestions from code review Co-authored-by: wbamberg * Apply suggestions from code review Co-authored-by: wbamberg * Update files/en-us/web/api/rtcaudiosourcestats/index.md * Add keys for BCD data * Make it clear that the audiolevel can also be calculated --------- Co-authored-by: wbamberg --- .../rtcaudiosourcestats/audiolevel/index.md | 28 ++++ .../web/api/rtcaudiosourcestats/id/index.md | 26 ++++ .../web/api/rtcaudiosourcestats/index.md | 140 ++++++++++++++++++ .../web/api/rtcaudiosourcestats/kind/index.md | 25 ++++ .../rtcaudiosourcestats/timestamp/index.md | 27 ++++ .../totalaudioenergy/index.md | 50 +++++++ .../totalsamplesduration/index.md | 28 ++++ .../trackidentifier/index.md | 23 +++ .../web/api/rtcaudiosourcestats/type/index.md | 26 ++++ files/en-us/web/api/rtcstats/index.md | 3 + files/jsondata/GroupData.json | 1 + 11 files changed, 377 insertions(+) create mode 100644 files/en-us/web/api/rtcaudiosourcestats/audiolevel/index.md create mode 100644 files/en-us/web/api/rtcaudiosourcestats/id/index.md create mode 100644 files/en-us/web/api/rtcaudiosourcestats/index.md create mode 100644 files/en-us/web/api/rtcaudiosourcestats/kind/index.md create mode 100644 files/en-us/web/api/rtcaudiosourcestats/timestamp/index.md create mode 100644 files/en-us/web/api/rtcaudiosourcestats/totalaudioenergy/index.md create mode 100644 files/en-us/web/api/rtcaudiosourcestats/totalsamplesduration/index.md create mode 100644 files/en-us/web/api/rtcaudiosourcestats/trackidentifier/index.md create mode 100644 files/en-us/web/api/rtcaudiosourcestats/type/index.md diff --git a/files/en-us/web/api/rtcaudiosourcestats/audiolevel/index.md b/files/en-us/web/api/rtcaudiosourcestats/audiolevel/index.md new file mode 100644 index 000000000000000..6ccd6d877f989fe --- /dev/null +++ b/files/en-us/web/api/rtcaudiosourcestats/audiolevel/index.md @@ -0,0 +1,28 @@ +--- +title: "RTCAudioSourceStats: audioLevel property" +short-title: audioLevel +slug: Web/API/RTCAudioSourceStats/audioLevel +page-type: web-api-instance-property +browser-compat: api.RTCStatsReport.type_media-source.audioLevel +--- + +{{APIRef("WebRTC")}} + +The {{domxref("RTCAudioSourceStats")}} dictionary's **`audioLevel`** property represents the audio level of the media source. + +The level is averaged over some small implementation-dependent interval. +Users can alternatively calculate the average audio level over some arbitrary duration using the algorithm described in the [`RTCAudioSourceStats` description](/en-US/docs/Web/API/RTCAudioSourceStats#description). + +> **Note:** For audio levels of remotely sourced tracks, see {{domxref("RTCInboundRtpStreamStats.audioLevel")}}. + +## Value + +A number between 0 and 1 (linear), where 1.0 represents 0 dBov ([decibels relative to full scale (DBFS)](https://en.wikipedia.org/wiki/DBFS)), 0 represents silence, and 0.5 represents approximately 6 dB SPL change in the [sound pressure level](https://en.wikipedia.org/wiki/Sound_pressure#Sound_pressure_level) from 0 dBov. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/rtcaudiosourcestats/id/index.md b/files/en-us/web/api/rtcaudiosourcestats/id/index.md new file mode 100644 index 000000000000000..fcb5401930354d6 --- /dev/null +++ b/files/en-us/web/api/rtcaudiosourcestats/id/index.md @@ -0,0 +1,26 @@ +--- +title: "RTCAudioSourceStats: id property" +short-title: id +slug: Web/API/RTCAudioSourceStats/id +page-type: web-api-instance-property +browser-compat: api.RTCStatsReport.type_media-source.id +--- + +{{APIRef("WebRTC")}} + +The **`id`** property of the {{domxref("RTCAudioSourceStats")}} dictionary is a string which uniquely identifies the object +for which this object provides statistics. + +Using the `id`, you can correlate this statistics object with others, in order to monitor statistics over time for a given WebRTC object, such as an {{domxref("RTCPeerConnection")}}, or an {{domxref("RTCDataChannel")}}. + +## Value + +A string that uniquely identifies the object for which this `RTCAudioSourceStats` object provides statistics. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/rtcaudiosourcestats/index.md b/files/en-us/web/api/rtcaudiosourcestats/index.md new file mode 100644 index 000000000000000..6f560866a20ee14 --- /dev/null +++ b/files/en-us/web/api/rtcaudiosourcestats/index.md @@ -0,0 +1,140 @@ +--- +title: RTCAudioSourceStats +slug: Web/API/RTCAudioSourceStats +page-type: web-api-interface +browser-compat: api.RTCStatsReport.type_media-source +--- + +{{APIRef("WebRTC")}} + +The [WebRTC API](/en-US/docs/Web/API/WebRTC_API)'s **`RTCAudioSourceStats`** dictionary provides information about an audio track that is attached to one or more senders. + +These statistics can be obtained by iterating the {{domxref("RTCStatsReport")}} returned by {{domxref("RTCRtpSender.getStats()")}} or {{domxref("RTCPeerConnection.getStats()")}} until you find a report with the [`type`](#type) of `media-source` and a [`kind`](#kind) of `audio`. + +> **Note:** For audio information about remotely sourced tracks (that are being received), see {{domxref("RTCInboundRtpStreamStats")}}. + +## Instance properties + +- {{domxref("RTCAudioSourceStats.audioLevel", "audioLevel")}} + - : A number that represents the audio level of the media source. +- {{domxref("RTCAudioSourceStats.totalAudioEnergy", "totalAudioEnergy")}} + - : A number that represents the total audio energy of the media source over the lifetime of the stats object. +- {{domxref("RTCAudioSourceStats.totalSamplesDuration", "totalSamplesDuration")}} + - : A number that represents the total duration of all samples produced by the media source over the lifetime of the stats object. + +The following properties are present in both `RTCAudioSourceStats` and {{domxref("RTCVideoSourceStats")}}: + +- {{domxref("RTCAudioSourceStats.trackIdentifier", "trackIdentifier")}} + - : A string that contains the [`id`](/en-US/docs/Web/API/MediaStreamTrack/id) value of the [`MediaStreamTrack`](/en-US/docs/Web/API/MediaStreamTrack) associated with the audio source. +- {{domxref("RTCAudioSourceStats.kind", "kind")}} + - : A string indicating whether this object represents stats for a video source or a media source. For an `RTCAudioSourceStats` this will always be `audio`. + +### Common instance properties + +The following properties are common to all statistics objects. + +- {{domxref("RTCAudioSourceStats.id", "id")}} + - : A string that uniquely identifies the object that is being monitored to produce this set of statistics. +- {{domxref("RTCAudioSourceStats.timestamp", "timestamp")}} + - : A {{domxref("DOMHighResTimeStamp")}} object indicating the time at which the sample was taken for this statistics object. +- {{domxref("RTCAudioSourceStats.type", "type")}} + - : A string with the value `"media-source"`, indicating that the object is an instance of either {{domxref("RTCAudioSourceStats")}} or {{domxref("RTCVideoSourceStats")}}. + +## Description + +The interface provides statistics about an audio media source attached to one or more senders. +The information includes the current audio level, averaged over a short (implementation dependent) duration. + +The statistics also include the accumulated total energy and total sample duration, at a particular timestamp. +The totals can be used to determine the average audio level over the lifetime of the stats object. +You can calculate a root mean square (RMS) value in the same units as `audioLevel` using the following formula: + + + + + totalAudioEnergy + totalSamplesDuration + + + + +You can also use the accumulated totals to calculate the average audio level over an arbitrary time period. + +The total audio energy of the stats object is accumulated by adding the energy of every sample over the lifetime of the stats object, while the total duration is accumulated by adding the duration of each sample. +The energy of each sample is determined using the following formula, where `sample_level` is the level of the sample, `max_level` is the highest-intensity encodable value, and `duration` is the duration of the sample in seconds: + + + + duration + + + + ( + + sample_level + max_level + + ) + + 2 + + + + +The average audio level between any two different `getStats()` calls, over any duration, can be calculated using the following equation: + + + + + + + totalAudioEnergy + 2 + + - + + totalAudioEnergy + 1 + + + + + totalSamplesDuration + 2 + + - + + totalSamplesDuration + 1 + + + + + + +## Examples + +This example shows how you might iterate the stats object returned from `RTCRtpSender.getStats()` to get the audio source stats, and then extract the `audioLevel`. + +```js +// where sender is an RTCRtpSender +const stats = await sender.getStats(); +let audioSourceStats = null; + +stats.forEach((report) => { + if (report.type === "media-source" && report.kind==="audio") { + audioSourceStats = report; + break; + } +}); + +const audioLevel = audioSourceStats?.audioLevel; +``` + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/rtcaudiosourcestats/kind/index.md b/files/en-us/web/api/rtcaudiosourcestats/kind/index.md new file mode 100644 index 000000000000000..cd75502f477851f --- /dev/null +++ b/files/en-us/web/api/rtcaudiosourcestats/kind/index.md @@ -0,0 +1,25 @@ +--- +title: "RTCAudioSourceStats: kind property" +short-title: kind +slug: Web/API/RTCAudioSourceStats/kind +page-type: web-api-instance-property +browser-compat: api.RTCStatsReport.type_media-source.kind +--- + +{{APIRef("WebRTC")}} + +The {{domxref("RTCAudioSourceStats")}} dictionary's **`kind`** property is a string value that is used to differentiate `audio` and `video` media sources. + +Along with the {{domxref("RTCAudioSourceStats.type", "type")}}, this identifies the object as an {{domxref("RTCAudioSourceStats")}} object when iterating the {{domxref("RTCStatsReport")}} returned by {{domxref("RTCRtpSender.getStats()")}} or {{domxref("RTCPeerConnection.getStats()")}}. + +## Value + +A string with the value `audio`. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/rtcaudiosourcestats/timestamp/index.md b/files/en-us/web/api/rtcaudiosourcestats/timestamp/index.md new file mode 100644 index 000000000000000..e3a9e1138fdd74d --- /dev/null +++ b/files/en-us/web/api/rtcaudiosourcestats/timestamp/index.md @@ -0,0 +1,27 @@ +--- +title: "RTCAudioSourceStats: timestamp property" +short-title: timestamp +slug: Web/API/RTCAudioSourceStats/timestamp +page-type: web-api-instance-property +browser-compat: api.RTCStatsReport.type_media-source.timestamp +--- + +{{APIRef("WebRTC")}} + +The **`timestamp`** property of the {{domxref("RTCAudioSourceStats")}} dictionary is a {{domxref("DOMHighResTimeStamp")}} object specifying the time at which the data in the object was sampled. + +The time is given in milliseconds elapsed since the first moment of January 1, 1970, UTC (also known as [Unix time](/en-US/docs/Glossary/Unix_time)). + +## Value + +A {{domxref("DOMHighResTimeStamp")}} value indicating the time at which the activity described by the statistics in this object was recorded, in milliseconds elapsed since the beginning of January 1, 1970, UTC. + +The value should be accurate to within a few milliseconds but may not be entirely precise, either because of hardware or operating system limitations or because of [fingerprinting](/en-US/docs/Glossary/Fingerprinting) protection in the form of reduced clock precision or accuracy. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/rtcaudiosourcestats/totalaudioenergy/index.md b/files/en-us/web/api/rtcaudiosourcestats/totalaudioenergy/index.md new file mode 100644 index 000000000000000..773c9f0ffc063ff --- /dev/null +++ b/files/en-us/web/api/rtcaudiosourcestats/totalaudioenergy/index.md @@ -0,0 +1,50 @@ +--- +title: "RTCAudioSourceStats: totalAudioEnergy property" +short-title: totalAudioEnergy +slug: Web/API/RTCAudioSourceStats/totalAudioEnergy +page-type: web-api-instance-property +browser-compat: api.RTCStatsReport.type_media-source.totalAudioEnergy +--- + +{{APIRef("WebRTC")}} + +The {{domxref("RTCAudioSourceStats")}} dictionary's **`totalAudioEnergy`** property represents the total audio energy of the media source over the lifetime of this stats object. + +The total energy across a particular duration can be determined by subtracting the value of this property returned by two different `getStats()` calls. + +> **Note:** For audio energy of remotely sourced tracks, see {{domxref("RTCInboundRtpStreamStats.totalAudioEnergy")}}. + +## Value + +A number produced by summing the energy of every sample over the lifetime of this stats object. + +The energy of each sample is calculated by dividing the sample's value by the highest-intensity encodable value, squaring the result, and then multiplying by the duration of the sample in seconds. +This is shown as an equation below: + + + + duration + + + + ( + + sample_level + max_level + + ) + + 2 + + + + +Note that if multiple audio channels are used, the audio energy of a sample refers to the highest energy of any channel. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/rtcaudiosourcestats/totalsamplesduration/index.md b/files/en-us/web/api/rtcaudiosourcestats/totalsamplesduration/index.md new file mode 100644 index 000000000000000..ce5a55745ccea77 --- /dev/null +++ b/files/en-us/web/api/rtcaudiosourcestats/totalsamplesduration/index.md @@ -0,0 +1,28 @@ +--- +title: "RTCAudioSourceStats: totalSamplesDuration property" +short-title: totalSamplesDuration +slug: Web/API/RTCAudioSourceStats/totalSamplesDuration +page-type: web-api-instance-property +browser-compat: api.RTCStatsReport.type_media-source.totalSamplesDuration +--- + +{{APIRef("WebRTC")}} + +The {{domxref("RTCAudioSourceStats")}} dictionary's **`totalSamplesDuration`** property represents the combined duration of all samples produced by the media source over the lifetime of this stats object, in seconds. +It does not include samples dropped before reaching this media source. + +This can be used with {{domxref("RTCAudioSourceStats.totalAudioEnergy", "totalAudioEnergy")}} to compute an [average audio level over different intervals](/en-US/docs/Web/API/RTCAudioSourceStats#description). + +> **Note:** For audio duration of remotely sourced tracks, see {{domxref("RTCInboundRtpStreamStats.totalSamplesDuration")}}. + +## Value + +A number indicating the total duration of all samples produced by this source over the lifetime this stats object, in seconds. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/rtcaudiosourcestats/trackidentifier/index.md b/files/en-us/web/api/rtcaudiosourcestats/trackidentifier/index.md new file mode 100644 index 000000000000000..24755a4f38773cb --- /dev/null +++ b/files/en-us/web/api/rtcaudiosourcestats/trackidentifier/index.md @@ -0,0 +1,23 @@ +--- +title: "RTCAudioSourceStats: trackIdentifier property" +short-title: trackIdentifier +slug: Web/API/RTCAudioSourceStats/trackIdentifier +page-type: web-api-instance-property +browser-compat: api.RTCStatsReport.type_media-source.trackIdentifier +--- + +{{APIRef("WebRTC")}} + +The {{domxref("RTCAudioSourceStats")}} dictionary's property **`trackIdentifier`** contains the `id` attribute of the associated [`MediaStreamTrack`](/en-US/docs/Web/API/MediaStreamTrack). + +## Value + +A string containing the value of the associated [`MediaStreamTrack.id`](/en-US/docs/Web/API/MediaStreamTrack/id). + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/rtcaudiosourcestats/type/index.md b/files/en-us/web/api/rtcaudiosourcestats/type/index.md new file mode 100644 index 000000000000000..409b3b4db3ef003 --- /dev/null +++ b/files/en-us/web/api/rtcaudiosourcestats/type/index.md @@ -0,0 +1,26 @@ +--- +title: "RTCAudioSourceStats: type property" +short-title: type +slug: Web/API/RTCAudioSourceStats/type +page-type: web-api-instance-property +browser-compat: api.RTCStatsReport.type_media-source.type +--- + +{{APIRef("WebRTC")}} + +The {{domxref("RTCAudioSourceStats")}} dictionary's property **`type`** is a string with value `media-source`. + +The type of `media-source` identifies the type of statistics as either {{domxref("RTCAudioSourceStats")}} or {{domxref("RTCVideoSourceStats")}} when iterating the {{domxref("RTCStatsReport")}} returned by {{domxref("RTCRtpSender.getStats()")}} or {{domxref("RTCPeerConnection.getStats()")}}. +The type of stats can further be differentiated using the {{domxref("RTCAudioSourceStats.kind", "kind")}}, which will be `audio` for `RTCAudioSourceStats`. + +## Value + +A string with the value `media-source`. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/rtcstats/index.md b/files/en-us/web/api/rtcstats/index.md index ae4d3776f04d79c..2024648cc337dcf 100644 --- a/files/en-us/web/api/rtcstats/index.md +++ b/files/en-us/web/api/rtcstats/index.md @@ -38,6 +38,9 @@ The various dictionaries that are used to define the contents of the objects tha - {{domxref("RTCOutboundRtpStreamStats")}} contains statistics about the local sending endpoint of an RTP stream. - {{domxref("RTCRemoteOutboundRtpStreamStats")}} holds statistics related to the remote sending end an RTP stream. + - {{domxref("RTCAudioSourceStats")}} contains statistics about audio media sources. + - {{domxref("RTCVideoSourceStats")}} contains statistics about video media sources. + ## Specifications {{Specifications}} diff --git a/files/jsondata/GroupData.json b/files/jsondata/GroupData.json index 327b806d17ecdb7..85789dc2537dd2e 100644 --- a/files/jsondata/GroupData.json +++ b/files/jsondata/GroupData.json @@ -2035,6 +2035,7 @@ "RTCRemoteOutboundRtpStreamStats", "RTCRtpContributingSourceStats", "RTCPeerConnectionStats", + "RTCAudioSourceStats", "RTCMediaStreamStats", "RTCMediaHandlerStats", "RTCVideoHandlerStats", From b801106c4c7d3acfc086e0e38f4818bf8aaa1d0e Mon Sep 17 00:00:00 2001 From: A1lo Date: Fri, 12 May 2023 14:20:19 +0800 Subject: [PATCH 08/86] correct language tag of code fence (#26738) --- files/en-us/learn/server-side/django/authentication/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files/en-us/learn/server-side/django/authentication/index.md b/files/en-us/learn/server-side/django/authentication/index.md index d9afe17f4a2837f..7a2a59a698d2c11 100644 --- a/files/en-us/learn/server-side/django/authentication/index.md +++ b/files/en-us/learn/server-side/django/authentication/index.md @@ -608,7 +608,7 @@ The very last step is to add a link for this new page into the sidebar. We'll pu Open the base template (**/locallibrary/catalog/templates/base_generic.html**) and add the "My Borrowed" line to the sidebar in the position shown below. -```python +```django