source: webkit/trunk/Source/WebCore/css/CSSBorderImageWidthValue.h

Last change on this file was 292467, checked in by Oriol Brufau, 3 years ago

[css] Turn -webkit-border-image into a shorthand
https://bugs.webkit.org/show_bug.cgi?id=237487

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

Update tests to take into account that '-webkit-border-image' is a shorthand.

  • web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
  • web-platform-tests/css/cssom/getComputedStyle-detached-subtree-expected.txt:

Source/WebCore:

The '-webkit-border-image' property was considered to be a longhand,
sharing computed values with the various 'border-image-*'.

This patch turns it into a shorthand of 'border-image-*'.

Tests: fast/borders/border-image-legacy.html

fast/css/border-image-style-length.html
fast/css/getComputedStyle/computed-style.html
fast/css/getComputedStyle/computed-style-without-renderer.html
fast/css/image-set-parsing.html
fast/css/uri-token-parsing.html
imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml.html
imported/w3c/web-platform-tests/css/cssom/getComputedStyle-detached-subtree.html
svg/css/getComputedStyle-basic.xhtml

  • Sources.txt:

Add the new file CSSBorderImageWidthValue.cpp.

  • WebCore.xcodeproj/project.pbxproj:

Add the new files CSSBorderImageWidthValue.h and
CSSBorderImageWidthValue.cpp.

  • animation/CSSPropertyAnimation.cpp:

(WebCore::blendFunc):
(WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):
When animating border-image-width, take into account that it can come
from -webkit-border-image, and thus override border widths.
Do not interpolate a value a does override border widths with another
value that does not.
Even if border-image-width accepts <length-percentage>, when overriding
border widths do not interpolate between a <length-percentage> and a
plain <length>, since only the latter are valid border widths.

  • css/CSSBorderImageWidthValue.cpp: Added.

(WebCore::CSSBorderImageWidthValue::CSSBorderImageWidthValue):
(WebCore::CSSBorderImageWidthValue::customCSSText const):
(WebCore::CSSBorderImageWidthValue::equals const):

  • css/CSSBorderImageWidthValue.h: Added.

Add CSSBorderImageWidthValue class, based on CSSBorderImageSliceValue.
It's a wrapper for a CSS_QUAD CSSPrimitiveValue, but with a bool that
indicates if the value will override border widths.

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::valueForNinePieceImage):
(WebCore::valueForReflection):
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
Serialize border-image-width as empty string if it overrides border
widths, since its grammar doesn't allow this.
Serialize border-image as empty string if border-image-width overrides
border widths, since its grammar doesn't allow this.
Handle serialization of -webkit-border-image.

  • css/CSSProperties.json:

Turn -webkit-border-image into a shorthand of border-image-source,
border-image-slice, border-image-width, border-image-outset and
border-image-repeat.

  • css/CSSToStyleMap.cpp:

(WebCore::CSSToStyleMap::mapNinePieceImage):
(WebCore::CSSToStyleMap::mapNinePieceImageWidth):
(WebCore::CSSToStyleMap::mapNinePieceImageQuad):

  • css/CSSToStyleMap.h:

Handle CSSBorderImageWidthValue values.
Remove old way of handling -webkit-border-image.

  • css/CSSValue.cpp:

(WebCore::CSSValue::equals const):
(WebCore::CSSValue::cssText const):
(WebCore::CSSValue::destroy):

  • css/CSSValue.h:

(WebCore::CSSValue::isBorderImageWidthValue const):
Handle new CSSBorderImageWidthValue value.

  • css/StyleProperties.cpp:

(WebCore::StyleProperties::getPropertyValue const):
(WebCore::StyleProperties::borderImagePropertyValue const):
(WebCore::StyleProperties::asText const):

  • css/StyleProperties.h:

Serialize border-image as empty string if border-image-width overrides
border widths, since its grammar doesn't allow this.
Handle serialization of -webkit-border-image.
Make cssText choose the right shorthand between border-image and
-webkit-border-image. Prefer the former if both are suitable.

  • css/parser/CSSPropertyParser.cpp:

(WebCore::consumeBorderImageWidth):
(WebCore::consumeBorderImageComponents):
(WebCore::CSSPropertyParser::parseSingleValue):
(WebCore::CSSPropertyParser::consumeBorderImage):
(WebCore::CSSPropertyParser::parseShorthand):
Parse border-image-width as a CSSBorderImageWidthValue.
Parse -webkit-border-image as a shorthand.

  • rendering/RenderTreeAsText.cpp:

(WebCore::RenderTreeAsText::writeRenderObject):
Take into account that border widths may be overridden.

  • rendering/style/BorderData.h:

(WebCore::BorderData::borderLeftWidth const):
(WebCore::BorderData::borderRightWidth const):
(WebCore::BorderData::borderTopWidth const):
(WebCore::BorderData::borderBottomWidth const):
Add logic for overriding border widths. Same approach as 'border-style'
set to 'none' making the border widths compute to '0px'.

  • rendering/style/NinePieceImage.cpp:

(WebCore::NinePieceImage::NinePieceImage):
(WebCore::NinePieceImage::Data::Data):
(WebCore::NinePieceImage::Data::create):
(WebCore::NinePieceImage::Data::operator== const):

  • rendering/style/NinePieceImage.h:

(WebCore::NinePieceImage::overridesBorderWidths const):
(WebCore::NinePieceImage::setOverridesBorderWidths):
(WebCore::NinePieceImage::copyBorderSlicesFrom):
Add flag for overriding border widths.

  • rendering/style/RenderStyle.cpp:

(WebCore::RenderStyle::setBorderImageWidthOverridesBorderWidths):

  • rendering/style/RenderStyle.h:

Add method for setting flag to override border widths.

  • style/PropertyCascade.cpp:

(WebCore::Style::shouldApplyPropertyInParseOrder):
Stop deferring border image properties. That was previously needed since
-webkit-border-image was a longhand sharing a computed value with the
border-image longhands. No longer needed since -webkit-border-image is
now a horthand.

  • style/StyleBuilderConverter.h:

(WebCore::Style::BuilderConverter::convertBorderMask):
(WebCore::Style::BuilderConverter::convertReflection):
(WebCore::Style::BuilderConverter::convertBorderImage): Deleted.
Remove code no longer needed.

  • style/StyleBuilderCustom.h:

(WebCore::Style::ApplyPropertyBorderImageModifier::applyInitialValue):
(WebCore::Style::ApplyPropertyBorderImageModifier::applyValue):
Handle border-image-width as a CSSBorderImageWidthValue.

LayoutTests:

Update tests to take into account that '-webkit-border-image' is a shorthand.

  • fast/borders/border-image-legacy-expected.txt: Added.
  • fast/borders/border-image-legacy.html: Added.
  • fast/css/border-image-style-length-expected.txt:
  • fast/css/border-image-style-length.html:
  • fast/css/getComputedStyle/computed-style-expected.txt:
  • fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
  • fast/css/getComputedStyle/resources/property-names.js:
  • fast/css/image-set-parsing-expected.txt:
  • fast/css/image-set-parsing.html:
  • fast/css/uri-token-parsing-expected.txt:
  • fast/css/uri-token-parsing.html:
  • platform/gtk/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
  • platform/gtk/imported/w3c/web-platform-tests/css/cssom/getComputedStyle-detached-subtree-expected.txt:
  • platform/ios/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
  • platform/ios/imported/w3c/web-platform-tests/css/cssom/getComputedStyle-detached-subtree-expected.txt:
  • platform/wpe/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
  • platform/wpe/imported/w3c/web-platform-tests/css/cssom/getComputedStyle-detached-subtree-expected.txt:
  • svg/css/getComputedStyle-basic-expected.txt:
File size: 2.2 KB
Line 
1/*
2 * Copyright (C) 2022 Igalia S.L. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#pragma once
27
28#include "CSSPrimitiveValue.h"
29#include <wtf/RefPtr.h>
30
31namespace WebCore {
32
33class Rect;
34
35class CSSBorderImageWidthValue final : public CSSValue {
36public:
37 static Ref<CSSBorderImageWidthValue> create(RefPtr<CSSPrimitiveValue>&& widths, bool overridesBorderWidths)
38 {
39 return adoptRef(*new CSSBorderImageWidthValue(WTFMove(widths), overridesBorderWidths));
40 }
41
42 String customCSSText() const;
43
44 Quad* widths() const { return m_widths ? m_widths->quadValue() : nullptr; }
45
46 bool equals(const CSSBorderImageWidthValue&) const;
47
48 RefPtr<CSSPrimitiveValue> m_widths;
49 bool m_overridesBorderWidths;
50
51private:
52 CSSBorderImageWidthValue(RefPtr<CSSPrimitiveValue>&& widths, bool overridesBorderWidths);
53};
54
55} // namespace WebCore
56
57SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSBorderImageWidthValue, isBorderImageWidthValue())
Note: See TracBrowser for help on using the repository browser.