Changeset 266660 in webkit


Ignore:
Timestamp:
Sep 5, 2020 8:45:27 AM (4 years ago)
Author:
Darin Adler
Message:

CSS revert should serialize as "revert", not "Revert"
https://bugs.webkit.org/show_bug.cgi?id=216187

Reviewed by Anders Carlsson.

LayoutTests/imported/w3c:

  • web-platform-tests/css/css-color-adjust/parsing/color-scheme-valid-expected.txt: Expect

one additional test to pass instead of fail.

  • web-platform-tests/css/css-values/unset-value-storage-expected.txt: Expect pass instead of fail.
  • web-platform-tests/css/cssom/css-style-attr-decl-block-expected.txt: Ditto.

Source/WebCore:

Tests: imported/w3c/web-platform-tests/css/css-values/unset-value-storage.html

imported/w3c/web-platform-tests/css/cssom/css-style-attr-decl-block.html

  • css/CSSRevertValue.cpp:

(WebCore::CSSRevertValue::customCSSText const): Use lowercase "revert".

  • css/StyleProperties.cpp:

(WebCore::isCSSWideValueKeyword): Added. Replaces isInitialOrInherit.
(WebCore::StyleProperties::fontValue const): Use isCSSWideValueKeyword rather
than isInitialOrInherit.
(WebCore::StyleProperties::getLayeredShorthandValue const): Ditto. Also
rearranged thee function a bit and shortened some excessively wordy code.
(WebCore::StyleProperties::getShorthandValue const): Ditto.
(WebCore::StyleProperties::borderPropertyValue const): Ditto.
(WebCore::StyleProperties::asText const): Added code to properly handle the
case where both background-position/repeat-x and -y are the same CSS-wide
value keyword as well as cases involving "initial". The general case above
handles these properly, but background-position/repeat have their own code,
which needed to repeat some of the same logic.
(WebCore::StyleProperties::PropertyReference::cssText const): Use makeString
instead of StringBuilder.

  • dom/StyledElement.cpp:

(WebCore::StyledElement::styleAttributeChanged): Removed incorrect code that
detached the CSS object model style wrapper from the element when the style
attribute was removed. This was incorrect behavior; it should stay attached.
This fix happens to be tested by the same file as the "revert"/"Revert" fix
and I wanted the whole file to pass, not just one more test.

  • editing/ApplyStyleCommand.cpp:

(WebCore::ApplyStyleCommand::addBlockStyle): Rewrote for simplicity, but
also so this works properly when inlineStyle is non-null but empty. This case
arises in one test now because of the change to StyledElement above.

LayoutTests:

  • editing/spelling/spelling-dots-position-expected.html: Remove some unneeded style text.

Caught my eye because it uses "background-position: initial".

  • fast/css/background-position-serialize-expected.txt: Updated for a progression.

We now correctly omit "background-position: initial initial; background-repeat: initial initial;".

  • platform/gtk/imported/w3c/web-platform-tests/css/cssom/css-style-attr-decl-block-expected.txt: Removed.
  • platform/ios-wk2/imported/w3c/web-platform-tests/css/cssom/css-style-attr-decl-block-expected.txt: Removed.
  • platform/wpe/imported/w3c/web-platform-tests/css/cssom/css-style-attr-decl-block-expected.txt: Removed.

These were only needed because the failure strings depended on the exact set of attributes.
But the test passes now.

Location:
trunk
Files:
3 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r266658 r266660  
     12020-09-05  Darin Adler  <darin@apple.com>
     2
     3        CSS revert should serialize as "revert", not "Revert"
     4        https://bugs.webkit.org/show_bug.cgi?id=216187
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * editing/spelling/spelling-dots-position-expected.html: Remove some unneeded style text.
     9        Caught my eye because it uses "background-position: initial".
     10
     11        * fast/css/background-position-serialize-expected.txt: Updated for a progression.
     12        We now correctly omit "background-position: initial initial; background-repeat: initial initial;".
     13
     14        * platform/gtk/imported/w3c/web-platform-tests/css/cssom/css-style-attr-decl-block-expected.txt: Removed.
     15        * platform/ios-wk2/imported/w3c/web-platform-tests/css/cssom/css-style-attr-decl-block-expected.txt: Removed.
     16        * platform/wpe/imported/w3c/web-platform-tests/css/cssom/css-style-attr-decl-block-expected.txt: Removed.
     17        These were only needed because the failure strings depended on the exact set of attributes.
     18        But the test passes now.
     19
    1202020-09-05  Commit Queue  <commit-queue@webkit.org>
    221
  • trunk/LayoutTests/editing/spelling/spelling-dots-position-expected.html

    r237893 r266660  
    1111<body>
    1212<div>There should be no misspelling dots visible below (because they're covered up by a div)</div>
    13 <div contenteditable="" id="root" class="editing">wafewerewdfea&nbsp;<span id="test"></span><div style="background-color: black; width: 1px; height: 150px; display: inline-block; background-position: initial initial; background-repeat: initial initial;"></div></div>
     13<div contenteditable="" id="root" class="editing">wafewerewdfea&nbsp;<span id="test"></span><div style="background-color: black; width: 1px; height: 150px; display: inline-block"></div></div>
    1414<script>
    1515    runEditingTest();
    16 </script><div style="background-color: black; position: absolute; left: 8px; top: 179.9726px; width: 237px; height: 4.7689200000000005px; background-position: initial initial; background-repeat: initial initial;"></div>
     16</script><div style="background-color: black; position: absolute; left: 8px; top: 179.9726px; width: 237px; height: 4.76892px"></div>
    1717</body>
    1818</html>
  • trunk/LayoutTests/fast/css/background-position-serialize-expected.txt

    r231359 r266660  
    7373t.style.backgroundPositionY = '50px'
    7474style.cssText =
    75 background-image: url("about:blank"); background-position: 80% 50px; background-repeat: initial initial;
     75background-image: url("about:blank"); background-position: 80% 50px;
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r266659 r266660  
     12020-09-05  Darin Adler  <darin@apple.com>
     2
     3        CSS revert should serialize as "revert", not "Revert"
     4        https://bugs.webkit.org/show_bug.cgi?id=216187
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * web-platform-tests/css/css-color-adjust/parsing/color-scheme-valid-expected.txt: Expect
     9        one additional test to pass instead of fail.
     10
     11        * web-platform-tests/css/css-values/unset-value-storage-expected.txt: Expect pass instead of fail.
     12        * web-platform-tests/css/cssom/css-style-attr-decl-block-expected.txt: Ditto.
     13
    1142020-09-05  Darin Adler  <darin@apple.com>
    215
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/parsing/color-scheme-valid-expected.txt

    r264522 r266660  
    1616PASS e.style['color-scheme'] = "initial" should set the property value
    1717PASS e.style['color-scheme'] = "unset" should set the property value
    18 FAIL e.style['color-scheme'] = "revert" should set the property value assert_equals: serialization should be canonical expected "revert" but got "Revert"
     18PASS e.style['color-scheme'] = "revert" should set the property value
    1919PASS e.style['color-scheme'] = "only" should set the property value
    2020FAIL e.style['color-scheme'] = "only only" should set the property value assert_not_equals: property should be set got disallowed value ""
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/unset-value-storage-expected.txt

    r251521 r266660  
    11
    2 FAIL Storage of "unset" value assert_equals: border is expected to be "unset" expected "unset" but got "unset unset unset"
     2PASS Storage of "unset" value
    33
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom/css-style-attr-decl-block-expected.txt

    r264522 r266660  
    11
    22PASS Style attribute should create CSS declaration block based on its content
    3 FAIL Changes to style attribute should reflect on CSS declaration block assert_equals: CSS declaration block after removing the style attribute expected "" but got "z-index: 21;"
     3PASS Changes to style attribute should reflect on CSS declaration block
    44PASS Changes to CSS declaration block should reflect on style attribute
    55PASS Changes to CSS declaration block should queue mutation record for style attribute
    66PASS Removing non-existing property or setting invalid value on CSS declaration block shouldn't queue mutation record
    77PASS Changes to CSS declaration block after a base URL change
    8 FAIL Expansion of all:unset and all:revert treated identically assert_equals: expected "color: unset; color-scheme: unset; display: unset; font-family: unset; font-feature-settings: unset; font-optical-sizing: unset; font-size: unset; font-stretch: unset; font-style: unset; font-synthesis: unset; font-variant-alternates: unset; font-variant-caps: unset; font-variant-east-asian: unset; font-variant-ligatures: unset; font-variant-numeric: unset; font-variant-position: unset; font-variation-settings: unset; font-weight: unset; text-rendering: unset; writing-mode: unset; zoom: unset; -webkit-font-kerning: unset; -webkit-font-smoothing: unset; -webkit-locale: unset; -webkit-text-orientation: unset; -webkit-text-size-adjust: unset; -webkit-text-zoom: unset; align-content: unset; align-items: unset; align-self: unset; alignment-baseline: unset; alt: unset; animation: unset unset unset unset unset unset unset unset; background-attachment: unset; background-blend-mode: unset; background-clip: unset; background-color: unset; background-image: unset; background-origin: unset; background-size: unset; baseline-shift: unset; block-size: unset; border-block-end-color: unset; border-block-end-style: unset; border-block-end-width: unset; border-block-start-color: unset; border-block-start-style: unset; border-block-start-width: unset; border: unset unset unset; border-bottom-right-radius: unset; border-collapse: unset; border-image-outset: unset; border-image-repeat: unset; border-image-slice: unset; border-image-source: unset; border-image-width: unset; border-inline-end-color: unset; border-inline-end-style: unset; border-inline-end-width: unset; border-inline-start-color: unset; border-inline-start-style: unset; border-inline-start-width: unset; border-top-left-radius: unset; border-top-right-radius: unset; bottom: unset; box-shadow: unset; box-sizing: unset; break-after: unset; break-before: unset; break-inside: unset; buffered-rendering: unset; caption-side: unset; caret-color: unset; clear: unset; clip: unset; clip-path: unset; clip-rule: unset; color-interpolation: unset; color-interpolation-filters: unset; color-profile: unset; color-rendering: unset; column-count: unset; column-fill: unset; column-gap: unset; column-rule-color: unset; column-rule-style: unset; column-rule-width: unset; column-span: unset; column-width: unset; content: unset; counter-increment: unset; counter-reset: unset; cursor: unset; cx: unset; cy: unset; dominant-baseline: unset; empty-cells: unset; enable-background: unset; fill: unset; fill-opacity: unset; fill-rule: unset; filter: unset; flex: unset unset unset; flex-flow: unset unset; float: unset; flood-color: unset; flood-opacity: unset; font-display: unset; glyph-orientation-horizontal: unset; glyph-orientation-vertical: unset; grid-auto-columns: unset; grid-auto-flow: unset; grid-auto-rows: unset; grid-column-end: unset; grid-column-start: unset; grid-row-end: unset; grid-row-start: unset; grid-template-areas: unset; grid-template-columns: unset; grid-template-rows: unset; hanging-punctuation: unset; height: unset; image-orientation: unset; image-rendering: unset; inline-size: unset; isolation: unset; justify-content: unset; justify-items: unset; justify-self: unset; kerning: unset; left: unset; letter-spacing: unset; lighting-color: unset; line-break: unset; line-height: unset; list-style: unset unset unset; margin-block-end: unset; margin-block-start: unset; margin: unset; margin-inline-end: unset; margin-inline-start: unset; marker-end: unset; marker-mid: unset; marker-start: unset; mask: unset; mask-type: unset; max-block-size: unset; max-height: unset; max-inline-size: unset; max-width: unset; min-block-size: unset; min-height: unset; min-inline-size: unset; min-width: unset; mix-blend-mode: unset; object-fit: unset; object-position: unset; opacity: unset; order: unset; orphans: unset; outline: unset unset unset; outline-offset: unset; overflow-wrap: unset; overflow: unset; padding-block-end: unset; padding-block-start: unset; padding: unset; padding-inline-end: unset; padding-inline-start: unset; page: unset; paint-order: unset; perspective: unset; perspective-origin: unset unset; pointer-events: unset; position: unset; quotes: unset; r: unset; resize: unset; right: unset; row-gap: unset; rx: unset; ry: unset; scroll-behavior: unset; scroll-padding: unset; scroll-snap-align: unset; scroll-snap-margin: unset; scroll-snap-type: unset; shape-image-threshold: unset; shape-margin: unset; shape-outside: unset; shape-rendering: unset; size: unset; speak-as: unset; src: unset; stop-color: unset; stop-opacity: unset; stroke: unset; stroke-color: unset; stroke-dasharray: unset; stroke-dashoffset: unset; stroke-linecap: unset; stroke-linejoin: unset; stroke-miterlimit: unset; stroke-opacity: unset; stroke-width: unset; tab-size: unset; table-layout: unset; text-align: unset; text-anchor: unset; text-decoration: unset; text-decoration-color: unset; text-decoration-line: unset; text-decoration-skip: unset; text-decoration-style: unset; text-decoration-thickness: unset; text-indent: unset; text-overflow: unset; text-shadow: unset; text-transform: unset; text-underline-offset: unset; text-underline-position: unset; top: unset; touch-action: unset; transform: unset; transform-box: unset; transform-origin: unset unset unset; transform-style: unset; transition: unset unset unset unset; unicode-range: unset; vector-effect: unset; vertical-align: unset; visibility: unset; white-space: unset; widows: unset; width: unset; will-change: unset; word-break: unset; word-spacing: unset; word-wrap: unset; x: unset; y: unset; z-index: unset; -apple-color-filter: unset; -apple-pay-button-style: unset; -apple-pay-button-type: unset; -apple-trailing-word: unset; -internal-text-autosizing-status: unset; -webkit-appearance: unset; -webkit-aspect-ratio: unset; -webkit-backdrop-filter: unset; -webkit-backface-visibility: unset; -webkit-background-clip: unset; -webkit-background-composite: unset; -webkit-background-origin: unset; -webkit-background-size: unset; -webkit-border-fit: unset; border-spacing: unset; -webkit-border-image: unset; -webkit-box-align: unset; -webkit-box-decoration-break: unset; -webkit-box-direction: unset; -webkit-box-flex: unset; -webkit-box-flex-group: unset; -webkit-box-lines: unset; -webkit-box-ordinal-group: unset; -webkit-box-orient: unset; -webkit-box-pack: unset; -webkit-box-reflect: unset; -webkit-box-shadow: unset; -webkit-column-axis: unset; -webkit-column-progression: unset; -webkit-cursor-visibility: unset; -webkit-font-size-delta: unset; -webkit-hyphenate-character: unset; -webkit-hyphenate-limit-after: unset; -webkit-hyphenate-limit-before: unset; -webkit-hyphenate-limit-lines: unset; -webkit-hyphens: unset; -webkit-initial-letter: unset; -webkit-line-align: unset; -webkit-line-box-contain: unset; -webkit-line-clamp: unset; -webkit-line-grid: unset; -webkit-line-snap: unset; -webkit-margin-after-collapse: unset; -webkit-margin-before-collapse: unset; -webkit-margin-bottom-collapse: unset; -webkit-margin-top-collapse: unset; -webkit-marquee-direction: unset; -webkit-marquee-increment: unset; -webkit-marquee-repetition: unset; -webkit-marquee-speed: unset; -webkit-marquee-style: unset; -webkit-mask-box-image: unset; -webkit-mask-box-image-outset: unset; -webkit-mask-box-image-repeat: unset; -webkit-mask-box-image-slice: unset; -webkit-mask-box-image-source: unset; -webkit-mask-box-image-width: unset; -webkit-mask: unset unset unset unset / unset unset unset unset unset; -webkit-mask-composite: unset; -webkit-mask-size: unset; -webkit-mask-source-type: unset; -webkit-nbsp-mode: unset; -webkit-print-color-adjust: unset; -webkit-rtl-ordering: unset; -webkit-ruby-position: unset; -webkit-text-combine: unset; -webkit-text-decorations-in-effect: unset; -webkit-text-emphasis-color: unset; -webkit-text-emphasis-position: unset; -webkit-text-emphasis-style: unset; -webkit-text-fill-color: unset; -webkit-text-security: unset; -webkit-text-stroke-color: unset; -webkit-text-stroke-width: unset; -webkit-transform-style: unset; -webkit-user-drag: unset; -webkit-user-modify: unset; -webkit-user-select: unset; border-bottom-left-radius: 1px; background-position: unset unset; background-repeat: unset unset;" but got "color: Revert; color-scheme: Revert; display: Revert; font-family: Revert; font-feature-settings: Revert; font-optical-sizing: Revert; font-size: Revert; font-stretch: Revert; font-style: Revert; font-synthesis: Revert; font-variant-alternates: Revert; font-variant-caps: Revert; font-variant-east-asian: Revert; font-variant-ligatures: Revert; font-variant-numeric: Revert; font-variant-position: Revert; font-variation-settings: Revert; font-weight: Revert; text-rendering: Revert; writing-mode: Revert; zoom: Revert; -webkit-font-kerning: Revert; -webkit-font-smoothing: Revert; -webkit-locale: Revert; -webkit-text-orientation: Revert; -webkit-text-size-adjust: Revert; -webkit-text-zoom: Revert; align-content: Revert; align-items: Revert; align-self: Revert; alignment-baseline: Revert; alt: Revert; animation: Revert Revert Revert Revert Revert Revert Revert Revert; background-attachment: Revert; background-blend-mode: Revert; background-clip: Revert; background-color: Revert; background-image: Revert; background-origin: Revert; background-size: Revert; baseline-shift: Revert; block-size: Revert; border-block-end-color: Revert; border-block-end-style: Revert; border-block-end-width: Revert; border-block-start-color: Revert; border-block-start-style: Revert; border-block-start-width: Revert; border: Revert Revert Revert; border-bottom-right-radius: Revert; border-collapse: Revert; border-image-outset: Revert; border-image-repeat: Revert; border-image-slice: Revert; border-image-source: Revert; border-image-width: Revert; border-inline-end-color: Revert; border-inline-end-style: Revert; border-inline-end-width: Revert; border-inline-start-color: Revert; border-inline-start-style: Revert; border-inline-start-width: Revert; border-top-left-radius: Revert; border-top-right-radius: Revert; bottom: Revert; box-shadow: Revert; box-sizing: Revert; break-after: Revert; break-before: Revert; break-inside: Revert; buffered-rendering: Revert; caption-side: Revert; caret-color: Revert; clear: Revert; clip: Revert; clip-path: Revert; clip-rule: Revert; color-interpolation: Revert; color-interpolation-filters: Revert; color-profile: Revert; color-rendering: Revert; column-count: Revert; column-fill: Revert; column-gap: Revert; column-rule-color: Revert; column-rule-style: Revert; column-rule-width: Revert; column-span: Revert; column-width: Revert; content: Revert; counter-increment: Revert; counter-reset: Revert; cursor: Revert; cx: Revert; cy: Revert; dominant-baseline: Revert; empty-cells: Revert; enable-background: Revert; fill: Revert; fill-opacity: Revert; fill-rule: Revert; filter: Revert; flex: Revert Revert Revert; flex-flow: Revert Revert; float: Revert; flood-color: Revert; flood-opacity: Revert; font-display: Revert; glyph-orientation-horizontal: Revert; glyph-orientation-vertical: Revert; grid-auto-columns: Revert; grid-auto-flow: Revert; grid-auto-rows: Revert; grid-column-end: Revert; grid-column-start: Revert; grid-row-end: Revert; grid-row-start: Revert; grid-template-areas: Revert; grid-template-columns: Revert; grid-template-rows: Revert; hanging-punctuation: Revert; height: Revert; image-orientation: Revert; image-rendering: Revert; inline-size: Revert; isolation: Revert; justify-content: Revert; justify-items: Revert; justify-self: Revert; kerning: Revert; left: Revert; letter-spacing: Revert; lighting-color: Revert; line-break: Revert; line-height: Revert; list-style: Revert Revert Revert; margin-block-end: Revert; margin-block-start: Revert; margin: Revert; margin-inline-end: Revert; margin-inline-start: Revert; marker-end: Revert; marker-mid: Revert; marker-start: Revert; mask: Revert; mask-type: Revert; max-block-size: Revert; max-height: Revert; max-inline-size: Revert; max-width: Revert; min-block-size: Revert; min-height: Revert; min-inline-size: Revert; min-width: Revert; mix-blend-mode: Revert; object-fit: Revert; object-position: Revert; opacity: Revert; order: Revert; orphans: Revert; outline: Revert Revert Revert; outline-offset: Revert; overflow-wrap: Revert; overflow: Revert; padding-block-end: Revert; padding-block-start: Revert; padding: Revert; padding-inline-end: Revert; padding-inline-start: Revert; page: Revert; paint-order: Revert; perspective: Revert; perspective-origin: Revert Revert; pointer-events: Revert; position: Revert; quotes: Revert; r: Revert; resize: Revert; right: Revert; row-gap: Revert; rx: Revert; ry: Revert; scroll-behavior: Revert; scroll-padding: Revert; scroll-snap-align: Revert; scroll-snap-margin: Revert; scroll-snap-type: Revert; shape-image-threshold: Revert; shape-margin: Revert; shape-outside: Revert; shape-rendering: Revert; size: Revert; speak-as: Revert; src: Revert; stop-color: Revert; stop-opacity: Revert; stroke: Revert; stroke-color: Revert; stroke-dasharray: Revert; stroke-dashoffset: Revert; stroke-linecap: Revert; stroke-linejoin: Revert; stroke-miterlimit: Revert; stroke-opacity: Revert; stroke-width: Revert; tab-size: Revert; table-layout: Revert; text-align: Revert; text-anchor: Revert; text-decoration: Revert; text-decoration-color: Revert; text-decoration-line: Revert; text-decoration-skip: Revert; text-decoration-style: Revert; text-decoration-thickness: Revert; text-indent: Revert; text-overflow: Revert; text-shadow: Revert; text-transform: Revert; text-underline-offset: Revert; text-underline-position: Revert; top: Revert; touch-action: Revert; transform: Revert; transform-box: Revert; transform-origin: Revert Revert Revert; transform-style: Revert; transition: Revert Revert Revert Revert; unicode-range: Revert; vector-effect: Revert; vertical-align: Revert; visibility: Revert; white-space: Revert; widows: Revert; width: Revert; will-change: Revert; word-break: Revert; word-spacing: Revert; word-wrap: Revert; x: Revert; y: Revert; z-index: Revert; -apple-color-filter: Revert; -apple-pay-button-style: Revert; -apple-pay-button-type: Revert; -apple-trailing-word: Revert; -internal-text-autosizing-status: Revert; -webkit-appearance: Revert; -webkit-aspect-ratio: Revert; -webkit-backdrop-filter: Revert; -webkit-backface-visibility: Revert; -webkit-background-clip: Revert; -webkit-background-composite: Revert; -webkit-background-origin: Revert; -webkit-background-size: Revert; -webkit-border-fit: Revert; border-spacing: Revert; -webkit-border-image: Revert; -webkit-box-align: Revert; -webkit-box-decoration-break: Revert; -webkit-box-direction: Revert; -webkit-box-flex: Revert; -webkit-box-flex-group: Revert; -webkit-box-lines: Revert; -webkit-box-ordinal-group: Revert; -webkit-box-orient: Revert; -webkit-box-pack: Revert; -webkit-box-reflect: Revert; -webkit-box-shadow: Revert; -webkit-column-axis: Revert; -webkit-column-progression: Revert; -webkit-cursor-visibility: Revert; -webkit-font-size-delta: Revert; -webkit-hyphenate-character: Revert; -webkit-hyphenate-limit-after: Revert; -webkit-hyphenate-limit-before: Revert; -webkit-hyphenate-limit-lines: Revert; -webkit-hyphens: Revert; -webkit-initial-letter: Revert; -webkit-line-align: Revert; -webkit-line-box-contain: Revert; -webkit-line-clamp: Revert; -webkit-line-grid: Revert; -webkit-line-snap: Revert; -webkit-margin-after-collapse: Revert; -webkit-margin-before-collapse: Revert; -webkit-margin-bottom-collapse: Revert; -webkit-margin-top-collapse: Revert; -webkit-marquee-direction: Revert; -webkit-marquee-increment: Revert; -webkit-marquee-repetition: Revert; -webkit-marquee-speed: Revert; -webkit-marquee-style: Revert; -webkit-mask-box-image: Revert; -webkit-mask-box-image-outset: Revert; -webkit-mask-box-image-repeat: Revert; -webkit-mask-box-image-slice: Revert; -webkit-mask-box-image-source: Revert; -webkit-mask-box-image-width: Revert; -webkit-mask: Revert Revert Revert Revert / Revert Revert Revert Revert Revert; -webkit-mask-composite: Revert; -webkit-mask-size: Revert; -webkit-mask-source-type: Revert; -webkit-nbsp-mode: Revert; -webkit-print-color-adjust: Revert; -webkit-rtl-ordering: Revert; -webkit-ruby-position: Revert; -webkit-text-combine: Revert; -webkit-text-decorations-in-effect: Revert; -webkit-text-emphasis-color: Revert; -webkit-text-emphasis-position: Revert; -webkit-text-emphasis-style: Revert; -webkit-text-fill-color: Revert; -webkit-text-security: Revert; -webkit-text-stroke-color: Revert; -webkit-text-stroke-width: Revert; -webkit-transform-style: Revert; -webkit-user-drag: Revert; -webkit-user-modify: Revert; -webkit-user-select: Revert; border-bottom-left-radius: 1px; background-position: Revert Revert; background-repeat: Revert Revert;"
     8PASS Expansion of all:unset and all:revert treated identically
    99
  • trunk/Source/WebCore/ChangeLog

    r266659 r266660  
     12020-09-05  Darin Adler  <darin@apple.com>
     2
     3        CSS revert should serialize as "revert", not "Revert"
     4        https://bugs.webkit.org/show_bug.cgi?id=216187
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Tests: imported/w3c/web-platform-tests/css/css-values/unset-value-storage.html
     9               imported/w3c/web-platform-tests/css/cssom/css-style-attr-decl-block.html
     10
     11        * css/CSSRevertValue.cpp:
     12        (WebCore::CSSRevertValue::customCSSText const): Use lowercase "revert".
     13
     14        * css/StyleProperties.cpp:
     15        (WebCore::isCSSWideValueKeyword): Added. Replaces isInitialOrInherit.
     16        (WebCore::StyleProperties::fontValue const): Use isCSSWideValueKeyword rather
     17        than isInitialOrInherit.
     18        (WebCore::StyleProperties::getLayeredShorthandValue const): Ditto. Also
     19        rearranged thee function a bit and shortened some excessively wordy code.
     20        (WebCore::StyleProperties::getShorthandValue const): Ditto.
     21        (WebCore::StyleProperties::borderPropertyValue const): Ditto.
     22        (WebCore::StyleProperties::asText const): Added code to properly handle the
     23        case where both background-position/repeat-x and -y are the same CSS-wide
     24        value keyword as well as cases involving "initial". The general case above
     25        handles these properly, but background-position/repeat have their own code,
     26        which needed to repeat some of the same logic.
     27        (WebCore::StyleProperties::PropertyReference::cssText const): Use makeString
     28        instead of StringBuilder.
     29
     30        * dom/StyledElement.cpp:
     31        (WebCore::StyledElement::styleAttributeChanged): Removed incorrect code that
     32        detached the CSS object model style wrapper from the element when the style
     33        attribute was removed. This was incorrect behavior; it should stay attached.
     34        This fix happens to be tested by the same file as the "revert"/"Revert" fix
     35        and I wanted the whole file to pass, not just one more test.
     36
     37        * editing/ApplyStyleCommand.cpp:
     38        (WebCore::ApplyStyleCommand::addBlockStyle): Rewrote for simplicity, but
     39        also so this works properly when inlineStyle is non-null but empty. This case
     40        arises in one test now because of the change to StyledElement above.
     41
    1422020-09-05  Darin Adler  <darin@apple.com>
    243
  • trunk/Source/WebCore/css/CSSRevertValue.cpp

    r233122 r266660  
    3333String CSSRevertValue::customCSSText() const
    3434{
    35     return "Revert"_s;
     35    return "revert"_s;
    3636}
    3737
  • trunk/Source/WebCore/css/StyleProperties.cpp

    r266659 r266660  
    5959}
    6060
    61 static bool isInitialOrInherit(const String& value)
    62 {
    63     return value.length() == 7 && (value == "initial" || value == "inherit");
     61static bool isCSSWideValueKeyword(StringView value)
     62{
     63    return value == "initial" || value == "inherit" || value == "unset" || value == "revert";
    6464}
    6565
     
    400400        result.append(' ');
    401401    result.append(fontFamilyProperty.value()->cssText());
    402     if (isInitialOrInherit(commonValue))
     402    if (isCSSWideValueKeyword(commonValue))
    403403        return commonValue;
    404404    return result.toString();
     
    504504
    505505    const unsigned size = shorthand.length();
    506     // Begin by collecting the properties into an array.
    507     Vector< RefPtr<CSSValue>> values(size);
     506    Vector<RefPtr<CSSValue>> values(size);
    508507    size_t numLayers = 0;
    509508
     
    513512            // We don't have all longhand properties defined as required for the shorthand
    514513            // property and thus should not serialize to a shorthand value. See spec at
    515             // http://www.w3.org/TR/cssom-1/#serialize-a-css-declaration-block.
     514            // https://www.w3.org/TR/cssom-1/#serialize-a-css-declaration-block
    516515            return String();
    517516        }
     
    523522
    524523    String commonValue;
    525     bool commonValueInitialized = false;
    526 
    527     // Now stitch the properties together. Implicit initial values are flagged as such and
    528     // can safely be omitted.
     524
     525    // Now stitch the properties together.
     526    // Implicit initial values are flagged as such and can safely be omitted.
    529527    for (size_t i = 0; i < numLayers; i++) {
    530528        StringBuilder layerResult;
     
    534532        bool foundPositionYCSSProperty = false;
    535533        for (unsigned j = 0; j < size; j++) {
    536             RefPtr<CSSValue> value;
    537             if (values[j]) {
    538                 if (values[j]->isBaseValueList())
    539                     value = downcast<CSSValueList>(*values[j]).item(i);
     534            auto property = shorthand.properties()[j];
     535
     536            auto value = values[j];
     537            if (value) {
     538                if (value->isBaseValueList())
     539                    value = downcast<CSSValueList>(*value).item(i);
    540540                else {
    541                     value = values[j];
    542 
    543541                    // Color only belongs in the last layer.
    544                     if (shorthand.properties()[j] == CSSPropertyBackgroundColor) {
     542                    if (property == CSSPropertyBackgroundColor) {
    545543                        if (i != numLayers - 1)
    546544                            value = nullptr;
     
    550548            }
    551549
    552             // We need to report background-repeat as it was written in the CSS. If the property is implicit,
    553             // then it was written with only one value. Here we figure out which value that was so we can
    554             // report back correctly.
    555             if ((shorthand.properties()[j] == CSSPropertyBackgroundRepeatX && isPropertyImplicit(shorthand.properties()[j]))
    556                 || (shorthand.properties()[j] == CSSPropertyWebkitMaskRepeatX && isPropertyImplicit(shorthand.properties()[j]))) {
    557 
    558                 // BUG 49055: make sure the value was not reset in the layer check just above.
    559                 if ((j < size - 1 && shorthand.properties()[j + 1] == CSSPropertyBackgroundRepeatY && value)
    560                     || (j < size - 1 && shorthand.properties()[j + 1] == CSSPropertyWebkitMaskRepeatY && value)) {
    561                     RefPtr<CSSValue> yValue;
    562                     RefPtr<CSSValue> nextValue = values[j + 1];
    563                     if (nextValue) {
    564                         if (is<CSSValueList>(*nextValue))
    565                             yValue = downcast<CSSValueList>(*nextValue).itemWithoutBoundsCheck(i);
    566                         else
    567                             yValue = nextValue;
    568 
     550            // We need to report background-repeat as it was written in the CSS.
     551            // If the property is implicit, then it was written with only one value. Here we figure out which value that was so we can report back correctly.
     552            if (value && j < size - 1 && (property == CSSPropertyBackgroundRepeatX || property == CSSPropertyWebkitMaskRepeatX) && isPropertyImplicit(property)) {
     553                // Make sure the value was not reset in the layer check just above.
     554                auto nextProperty = shorthand.properties()[j + 1];
     555                if (nextProperty == CSSPropertyBackgroundRepeatY || nextProperty == CSSPropertyWebkitMaskRepeatY) {
     556                    if (auto yValue = values[j + 1]) {
     557                        if (is<CSSValueList>(*yValue))
     558                            yValue = downcast<CSSValueList>(*yValue).itemWithoutBoundsCheck(i);
    569559                        if (!is<CSSPrimitiveValue>(*value) || !is<CSSPrimitiveValue>(*yValue))
    570560                            continue;
    571561
    572                         CSSValueID xId = downcast<CSSPrimitiveValue>(*value).valueID();
    573                         CSSValueID yId = downcast<CSSPrimitiveValue>(*yValue).valueID();
     562                        auto xId = downcast<CSSPrimitiveValue>(*value).valueID();
     563                        auto yId = downcast<CSSPrimitiveValue>(*yValue).valueID();
    574564                        if (xId != yId) {
    575565                            if (xId == CSSValueRepeat && yId == CSSValueNoRepeat) {
     
    592582                if (!layerResult.isEmpty())
    593583                    layerResult.append(' ');
    594                 if (foundPositionYCSSProperty
    595                     && (shorthand.properties()[j] == CSSPropertyBackgroundSize || shorthand.properties()[j] == CSSPropertyWebkitMaskSize))
     584
     585                if (property == CSSPropertyBackgroundSize || property == CSSPropertyWebkitMaskSize) {
     586                    if (!foundPositionYCSSProperty)
     587                        continue;
    596588                    layerResult.appendLiteral("/ ");
    597                 if (!foundPositionYCSSProperty
    598                     && (shorthand.properties()[j] == CSSPropertyBackgroundSize || shorthand.properties()[j] == CSSPropertyWebkitMaskSize))
    599                     continue;
     589                }
    600590
    601591                if (useRepeatXShorthand) {
     
    612602                }
    613603
    614                 if (shorthand.properties()[j] == CSSPropertyBackgroundPositionY
    615                     || shorthand.properties()[j] == CSSPropertyWebkitMaskPositionY) {
     604                if (property == CSSPropertyBackgroundPositionY || property == CSSPropertyWebkitMaskPositionY)
    616605                    foundPositionYCSSProperty = true;
    617 
    618                     // background-position is a special case: if only the first offset is specified,
    619                     // the second one defaults to "center", not the same value.
    620                     if (commonValueInitialized && commonValue != "initial" && commonValue != "inherit")
    621                         commonValue = String();
    622                 }
    623606            }
    624607
    625             if (!commonValueInitialized) {
     608            if (commonValue.isNull())
    626609                commonValue = valueText;
    627                 commonValueInitialized = true;
    628             } else if (!commonValue.isNull() && commonValue != valueText)
    629                 commonValue = String();
     610            else if (commonValue != valueText)
     611                commonValue = emptyString(); // Could use value here other than a CSS-wide value keyword or the null string.
    630612        }
    631613
    632         if (!layerResult.isEmpty()) {
    633             if (!result.isEmpty())
    634                 result.appendLiteral(", ");
    635             result.append(layerResult);
    636         }
    637     }
    638 
    639     if (isInitialOrInherit(commonValue))
     614        if (!layerResult.isEmpty())
     615            result.append(result.isEmpty() ? "" : ", ", layerResult.toString());
     616    }
     617
     618    if (isCSSWideValueKeyword(commonValue))
    640619        return commonValue;
    641620
    642     if (result.isEmpty())
    643         return String();
    644     return result.toString();
     621    return result.isEmpty() ? String() : result.toString();
    645622}
    646623
     
    672649            commonValue = String();
    673650    }
    674     if (isInitialOrInherit(commonValue))
     651    if (isCSSWideValueKeyword(commonValue))
    675652        return commonValue;
    676653    if (result.isEmpty())
     
    731708        result.append(value);
    732709    }
    733     if (isInitialOrInherit(commonValue))
     710    if (isCSSWideValueKeyword(commonValue))
    734711        return commonValue;
    735712    return result.toString();
     
    12731250            result.append(getPropertyName(propertyID));
    12741251
    1275         result.appendLiteral(": ");
    1276         result.append(value);
    1277         if (property.isImportant())
    1278             result.appendLiteral(" !important");
    1279         result.append(';');
    1280     }
    1281 
    1282     // FIXME: This is a not-so-nice way to turn x/y positions into single background-position in output.
    1283     // It is required because background-position-x/y are non-standard properties and WebKit generated output
    1284     // would not work in Firefox (<rdar://problem/5143183>)
    1285     // It would be a better solution if background-position was CSSUnitType::CSS_PAIR.
    1286     if (positionXPropertyIndex != -1 && positionYPropertyIndex != -1 && propertyAt(positionXPropertyIndex).isImportant() == propertyAt(positionYPropertyIndex).isImportant()) {
    1287         PropertyReference positionXProperty = propertyAt(positionXPropertyIndex);
    1288         PropertyReference positionYProperty = propertyAt(positionYPropertyIndex);
    1289 
    1290         if (numDecls++)
    1291             result.append(' ');
    1292         result.appendLiteral("background-position: ");
    1293         if (positionXProperty.value()->isValueList() || positionYProperty.value()->isValueList())
    1294             result.append(getLayeredShorthandValue(backgroundPositionShorthand()));
    1295         else {
    1296             result.append(positionXProperty.value()->cssText());
    1297             result.append(' ');
    1298             result.append(positionYProperty.value()->cssText());
     1252        result.append(": ", value, property.isImportant() ? " !important" : "", ';');
     1253    }
     1254
     1255    // FIXME: This is a not-so-nice way to turn x/y positions into single background-position/repeat in output.
     1256    // In 2007 we decided this was required because background-position/repeat-x/y are non-standard properties and WebKit generated output would not work in Firefox (<rdar://problem/5143183>).
     1257    auto appendPositionOrProperty = [&] (int xIndex, int yIndex, const char* name, const StylePropertyShorthand& shorthand) {
     1258        if (xIndex != -1 && yIndex != -1 && propertyAt(xIndex).isImportant() == propertyAt(yIndex).isImportant()) {
     1259            String value;
     1260            auto xProperty = propertyAt(xIndex);
     1261            auto yProperty = propertyAt(yIndex);
     1262            if (xProperty.value()->isValueList() || yProperty.value()->isValueList())
     1263                value = getLayeredShorthandValue(shorthand);
     1264            else {
     1265                auto x = xProperty.value()->cssText();
     1266                auto y = yProperty.value()->cssText();
     1267                if (x == y && isCSSWideValueKeyword(x))
     1268                    value = x;
     1269                else
     1270                    value = makeString(x, ' ', y);
     1271            }
     1272            if (value != "initial") {
     1273                result.append(numDecls ? " " : "", name, ": ", value, xProperty.isImportant() ? " !important" : "", ';');
     1274                ++numDecls;
     1275            }
     1276        } else {
     1277            if (xIndex != -1) {
     1278                if (numDecls++)
     1279                    result.append(' ');
     1280                result.append(propertyAt(xIndex).cssText());
     1281            }
     1282            if (yIndex != -1) {
     1283                if (numDecls++)
     1284                    result.append(' ');
     1285                result.append(propertyAt(yIndex).cssText());
     1286            }
    12991287        }
    1300         if (positionXProperty.isImportant())
    1301             result.appendLiteral(" !important");
    1302         result.append(';');
    1303     } else {
    1304         if (positionXPropertyIndex != -1) {
    1305             if (numDecls++)
    1306                 result.append(' ');
    1307             result.append(propertyAt(positionXPropertyIndex).cssText());
    1308         }
    1309         if (positionYPropertyIndex != -1) {
    1310             if (numDecls++)
    1311                 result.append(' ');
    1312             result.append(propertyAt(positionYPropertyIndex).cssText());
    1313         }
    1314     }
    1315 
    1316     // FIXME: We need to do the same for background-repeat.
    1317     if (repeatXPropertyIndex != -1 && repeatYPropertyIndex != -1 && propertyAt(repeatXPropertyIndex).isImportant() == propertyAt(repeatYPropertyIndex).isImportant()) {
    1318         PropertyReference repeatXProperty = propertyAt(repeatXPropertyIndex);
    1319         PropertyReference repeatYProperty = propertyAt(repeatYPropertyIndex);
    1320 
    1321         if (numDecls++)
    1322             result.append(' ');
    1323         result.appendLiteral("background-repeat: ");
    1324         if (repeatXProperty.value()->isValueList() || repeatYProperty.value()->isValueList())
    1325             result.append(getLayeredShorthandValue(backgroundRepeatShorthand()));
    1326         else {
    1327             result.append(repeatXProperty.value()->cssText());
    1328             result.append(' ');
    1329             result.append(repeatYProperty.value()->cssText());
    1330         }
    1331         if (repeatXProperty.isImportant())
    1332             result.appendLiteral(" !important");
    1333         result.append(';');
    1334     } else {
    1335         if (repeatXPropertyIndex != -1) {
    1336             if (numDecls++)
    1337                 result.append(' ');
    1338             result.append(propertyAt(repeatXPropertyIndex).cssText());
    1339         }
    1340         if (repeatYPropertyIndex != -1) {
    1341             if (numDecls++)
    1342                 result.append(' ');
    1343             result.append(propertyAt(repeatYPropertyIndex).cssText());
    1344         }
    1345     }
     1288    };
     1289
     1290    appendPositionOrProperty(positionXPropertyIndex, positionYPropertyIndex, "background-position", backgroundPositionShorthand());
     1291    appendPositionOrProperty(repeatXPropertyIndex, repeatYPropertyIndex, "background-repeat", backgroundRepeatShorthand());
    13461292
    13471293    ASSERT(!numDecls ^ !result.isEmpty());
     
    15921538String StyleProperties::PropertyReference::cssText() const
    15931539{
    1594     StringBuilder result;
    1595     result.append(cssName());
    1596     result.appendLiteral(": ");
    1597     result.append(m_value->cssText());
    1598     if (isImportant())
    1599         result.appendLiteral(" !important");
    1600     result.append(';');
    1601     return result.toString();
     1540    return makeString(cssName(), ": ", m_value->cssText(), isImportant() ? " !important" : "", ';');
    16021541}
    16031542   
  • trunk/Source/WebCore/dom/StyledElement.cpp

    r264963 r266660  
    171171void StyledElement::setInlineStyleFromString(const AtomString& newStyleString)
    172172{
    173     RefPtr<StyleProperties>& inlineStyle = elementData()->m_inlineStyle;
     173    auto& inlineStyle = elementData()->m_inlineStyle;
    174174
    175175    // Avoid redundant work if we're using shared attribute data with already parsed inline style.
     
    193193void StyledElement::styleAttributeChanged(const AtomString& newStyleString, AttributeModificationReason reason)
    194194{
    195     WTF::OrdinalNumber startLineNumber = WTF::OrdinalNumber::beforeFirst();
     195    auto startLineNumber = WTF::OrdinalNumber::beforeFirst();
    196196    if (document().scriptableDocumentParser() && !document().isInDocumentWrite())
    197197        startLineNumber = document().scriptableDocumentParser()->textPosition().m_line;
    198198
    199     if (newStyleString.isNull()) {
    200         if (PropertySetCSSStyleDeclaration* cssomWrapper = inlineStyleCSSOMWrapper())
    201             cssomWrapper->clearParentElement();
    202         ensureUniqueElementData().m_inlineStyle = nullptr;
    203     } else if (reason == ModifiedByCloning || document().contentSecurityPolicy()->allowInlineStyle(document().url().string(), startLineNumber, String(), isInUserAgentShadowTree()))
     199    if (reason == ModifiedByCloning || document().contentSecurityPolicy()->allowInlineStyle(document().url().string(), startLineNumber, String(), isInUserAgentShadowTree()))
    204200        setInlineStyleFromString(newStyleString);
    205201
  • trunk/Source/WebCore/editing/ApplyStyleCommand.cpp

    r266487 r266660  
    13411341}
    13421342
     1343static String joinWithSpace(const String& a, const String& b)
     1344{
     1345    if (a.isEmpty())
     1346        return b;
     1347    if (b.isEmpty())
     1348        return a;
     1349    return makeString(a, ' ', b);
     1350}
     1351
    13431352void ApplyStyleCommand::addBlockStyle(const StyleChange& styleChange, HTMLElement& block)
    13441353{
     1354    // Do not check for legacy styles here. Those styles, like <B> and <I>, only apply for inline content.
    13451355    ASSERT(styleChange.cssStyle());
    1346     // Do not check for legacy styles here. Those styles, like <B> and <I>, only apply for
    1347     // inline content.
    1348        
    1349     String cssStyle = styleChange.cssStyle()->asText();
    1350     StringBuilder cssText;
    1351     cssText.append(cssStyle);
    1352     if (const StyleProperties* decl = block.inlineStyle()) {
    1353         if (!cssStyle.isEmpty())
    1354             cssText.append(' ');
    1355         cssText.append(decl->asText());
    1356     }
    1357     setNodeAttribute(block, styleAttr, cssText.toString());
     1356    setNodeAttribute(block, styleAttr, joinWithSpace(styleChange.cssStyle()->asText(), block.getAttribute(styleAttr)));
    13581357}
    13591358
Note: See TracChangeset for help on using the changeset viewer.