WebKit Bugzilla
Attachment 358172 Details for
Bug 193066
: Handle calc() expressions in gradient color stops
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193066-20190101111918.patch (text/plain), 8.08 KB, created by
Simon Fraser (smfr)
on 2019-01-01 11:19:19 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Simon Fraser (smfr)
Created:
2019-01-01 11:19:19 PST
Size:
8.08 KB
patch
obsolete
>Subversion Revision: 239533 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 24291ccefc4f8271e4ba829b7e3040b12bccf0ba..f73cad043b74b24f4d3144df0ff3c4881886d5f0 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,26 @@ >+2019-01-01 Simon Fraser <simon.fraser@apple.com> >+ >+ Handle calc() expressions in gradient color stops >+ https://bugs.webkit.org/show_bug.cgi?id=193066 >+ rdar://problem/46961985 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Fix two issues that prevented calc() expressions from working in conic-gradient color stops, >+ for the angle or percent value. First, consumeAngleOrPercent() needs to look for CalculationCategory::Percent >+ calc values as well as angle ones. >+ >+ Second, CSSPrimitiveValue::isAngle() needs to use primitiveType() (which takes calc into account), >+ just as isPx() etc do. >+ >+ Test: fast/gradients/conic-calc-stop-position.html >+ >+ * css/CSSPrimitiveValue.h: >+ (WebCore::CSSPrimitiveValue::isAngle const): >+ * css/parser/CSSPropertyParserHelpers.cpp: >+ (WebCore::CSSPropertyParserHelpers::consumeAngleOrPercent): >+ (WebCore::CSSPropertyParserHelpers::consumeGradientColorStops): >+ > 2018-12-21 Youenn Fablet <youenn@apple.com> > > RTCRtpSender.setParameters() does set active parameter >diff --git a/Source/WebCore/css/CSSPrimitiveValue.h b/Source/WebCore/css/CSSPrimitiveValue.h >index 5f423fd78a48927fb0a1089e1c73d2d3e3d169e1..28fdbab26cd328a9dcacf942156de413bb9700ae 100644 >--- a/Source/WebCore/css/CSSPrimitiveValue.h >+++ b/Source/WebCore/css/CSSPrimitiveValue.h >@@ -352,10 +352,11 @@ private: > > inline bool CSSPrimitiveValue::isAngle() const > { >- return m_primitiveUnitType == CSS_DEG >- || m_primitiveUnitType == CSS_RAD >- || m_primitiveUnitType == CSS_GRAD >- || m_primitiveUnitType == CSS_TURN; >+ auto primitiveType = this->primitiveType(); >+ return primitiveType == CSS_DEG >+ || primitiveType == CSS_RAD >+ || primitiveType == CSS_GRAD >+ || primitiveType == CSS_TURN; > } > > inline bool CSSPrimitiveValue::isFontRelativeLength(UnitType type) >diff --git a/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp b/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp >index 03b11ae33ac5512efa12ecf6a31efec49f7cb3d0..0b86bf9f09fc76cdcc425b4ba0544428ff2dff22 100644 >--- a/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp >+++ b/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp >@@ -77,7 +77,6 @@ CSSParserTokenRange consumeFunction(CSSParserTokenRange& range) > > // FIXME: consider pulling in the parsing logic from CSSCalculationValue.cpp. > class CalcParser { >- > public: > explicit CalcParser(CSSParserTokenRange& range, CalculationCategory destinationCategory, ValueRange valueRange = ValueRangeAll) > : m_sourceRange(range) >@@ -376,10 +375,16 @@ static RefPtr<CSSPrimitiveValue> consumeAngleOrPercent(CSSParserTokenRange& rang > if (token.type() == PercentageToken) > return consumePercent(range, valueRange); > >- CalcParser calcParser(range, CalculationCategory::Angle, valueRange); >- if (const CSSCalcValue* calculation = calcParser.value()) { >+ CalcParser angleCalcParser(range, CalculationCategory::Angle, valueRange); >+ if (const CSSCalcValue* calculation = angleCalcParser.value()) { > if (calculation->category() == CalculationCategory::Angle) >- return calcParser.consumeValue(); >+ return angleCalcParser.consumeValue(); >+ } >+ >+ CalcParser percentCalcParser(range, CalculationCategory::Percent, valueRange); >+ if (const CSSCalcValue* calculation = percentCalcParser.value()) { >+ if (calculation->category() == CalculationCategory::Percent) >+ return percentCalcParser.consumeValue(); > } > return nullptr; > } >@@ -967,7 +972,7 @@ static bool consumeGradientColorStops(CSSParserTokenRange& range, CSSParserMode > { > bool supportsColorHints = gradient.gradientType() == CSSLinearGradient || gradient.gradientType() == CSSRadialGradient || gradient.gradientType() == CSSConicGradient; > >- bool isAngularGradient = gradient.gradientType() == CSSConicGradient; >+ bool isConicGradient = gradient.gradientType() == CSSConicGradient; > > // The first color stop cannot be a color hint. > bool previousStopWasColorHint = true; >@@ -983,7 +988,7 @@ static bool consumeGradientColorStops(CSSParserTokenRange& range, CSSParserMode > // FIXME-NEWPARSER: This boolean could be removed. Null checking color would be sufficient. > stop.isMidpoint = !stop.m_color; > >- if (isAngularGradient) >+ if (isConicGradient) > stop.m_position = consumeAngleOrPercent(range, cssParserMode, ValueRangeAll, UnitlessQuirk::Forbid); > else > stop.m_position = consumeLengthOrPercent(range, cssParserMode, ValueRangeAll); >@@ -994,7 +999,7 @@ static bool consumeGradientColorStops(CSSParserTokenRange& range, CSSParserMode > > // See if there is a second color hint, which is optional. > CSSGradientColorStop secondStop; >- if (isAngularGradient) >+ if (isConicGradient) > secondStop.m_position = consumeAngleOrPercent(range, cssParserMode, ValueRangeAll, UnitlessQuirk::Forbid); > else > secondStop.m_position = consumeLengthOrPercent(range, cssParserMode, ValueRangeAll); >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index e4c2fd324354312ffc1696d584b63aa9dfc100be..b41c11350bf5f78583ef9324cc65fcf688e52a1c 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,14 @@ >+2019-01-01 Simon Fraser <simon.fraser@apple.com> >+ >+ Handle calc() expressions in gradient color stops >+ https://bugs.webkit.org/show_bug.cgi?id=193066 >+ rdar://problem/46961985 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * fast/gradients/conic-calc-stop-position-expected.html: Added. >+ * fast/gradients/conic-calc-stop-position.html: Added. >+ > 2018-12-21 Youenn Fablet <youenn@apple.com> > > RTCRtpSender.setParameters() does set active parameter >diff --git a/LayoutTests/fast/gradients/conic-calc-stop-position-expected.html b/LayoutTests/fast/gradients/conic-calc-stop-position-expected.html >new file mode 100644 >index 0000000000000000000000000000000000000000..bed28da3a9c781a237d354dd25e3c0cd84e7c54b >--- /dev/null >+++ b/LayoutTests/fast/gradients/conic-calc-stop-position-expected.html >@@ -0,0 +1,20 @@ >+<html> >+<head> >+ <style> >+ .box { >+ margin: 10px; >+ height: 200px; >+ width: 200px; >+ border: 1px solid black; >+ float: left; >+ } >+ </style> >+</head> >+<body> >+ <p>All boxes should look the same.</p> >+ <div class="box" style="background-image: conic-gradient(green, 90deg, transparent 0)"></div> >+ <div class="box" style="background-image: conic-gradient(green, 90deg, transparent 0)"></div> >+ <div class="box" style="background-image: conic-gradient(green, 90deg, transparent 0)"></div> >+ <div class="box" style="background-image: conic-gradient(green, 90deg, transparent 0)"></div> >+</body> >+</html> >diff --git a/LayoutTests/fast/gradients/conic-calc-stop-position.html b/LayoutTests/fast/gradients/conic-calc-stop-position.html >new file mode 100644 >index 0000000000000000000000000000000000000000..9768cc1a9dec7ada984ca384c09f463b89b355ad >--- /dev/null >+++ b/LayoutTests/fast/gradients/conic-calc-stop-position.html >@@ -0,0 +1,20 @@ >+<html> >+<head> >+ <style> >+ .box { >+ margin: 10px; >+ height: 200px; >+ width: 200px; >+ border: 1px solid black; >+ float: left; >+ } >+ </style> >+</head> >+<body> >+ <p>All boxes should look the same.</p> >+ <div class="box" style="background-image: conic-gradient(green, 25%, transparent 0deg)"></div> >+ <div class="box" style="background-image: conic-gradient(green, 90deg, transparent 0)"></div> >+ <div class="box" style="background-image: conic-gradient(green, calc(1 * 100% / 4), transparent 0)"></div> >+ <div class="box" style="background-image: conic-gradient(green, calc(360deg / 4), transparent 0deg)"></div> >+</body> >+</html>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193066
: 358172