ASSIGNED180620
Improve ExtendedColor support
https://bugs.webkit.org/show_bug.cgi?id=180620
Summary Improve ExtendedColor support
Darin Adler
Reported 2017-12-08 21:19:43 PST
Improve ExtendedColor support
Attachments
Patch (127.78 KB, patch)
2017-12-08 22:24 PST, Darin Adler
no flags
Patch (315.54 KB, patch)
2017-12-11 00:58 PST, Darin Adler
no flags
Patch (315.54 KB, patch)
2017-12-11 01:00 PST, Darin Adler
no flags
Patch (338.42 KB, patch)
2017-12-11 20:39 PST, Darin Adler
no flags
Patch (354.00 KB, patch)
2017-12-11 21:37 PST, Darin Adler
no flags
Archive of layout-test-results from ews103 for mac-elcapitan (370.18 KB, application/zip)
2017-12-11 22:23 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews107 for mac-elcapitan-wk2 (371.40 KB, application/zip)
2017-12-11 22:28 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews114 for mac-elcapitan (383.10 KB, application/zip)
2017-12-11 22:31 PST, EWS Watchlist
no flags
Patch (470.42 KB, patch)
2017-12-17 10:05 PST, Darin Adler
no flags
Patch (470.09 KB, patch)
2017-12-17 10:28 PST, Darin Adler
no flags
Patch (470.09 KB, patch)
2017-12-17 10:41 PST, Darin Adler
no flags
Patch (470.14 KB, patch)
2017-12-17 11:08 PST, Darin Adler
no flags
Patch (471.54 KB, patch)
2017-12-17 11:40 PST, Darin Adler
no flags
Patch (490.31 KB, patch)
2017-12-17 12:44 PST, Darin Adler
no flags
Patch (493.61 KB, patch)
2017-12-17 13:18 PST, Darin Adler
no flags
Archive of layout-test-results from ews105 for mac-elcapitan-wk2 (2.53 MB, application/zip)
2017-12-17 14:36 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews121 for ios-simulator-wk2 (2.89 MB, application/zip)
2017-12-17 14:52 PST, EWS Watchlist
no flags
Patch (560.29 KB, patch)
2017-12-17 19:36 PST, Darin Adler
no flags
Archive of layout-test-results from ews122 for ios-simulator-wk2 (2.14 MB, application/zip)
2017-12-17 21:07 PST, EWS Watchlist
no flags
Patch (569.25 KB, patch)
2017-12-17 21:12 PST, Darin Adler
no flags
Archive of layout-test-results from ews102 for mac-elcapitan (2.87 MB, application/zip)
2017-12-17 22:17 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews106 for mac-elcapitan-wk2 (3.20 MB, application/zip)
2017-12-17 22:29 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews124 for ios-simulator-wk2 (2.98 MB, application/zip)
2017-12-17 22:44 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews117 for mac-elcapitan (3.58 MB, application/zip)
2017-12-17 22:47 PST, EWS Watchlist
no flags
Patch (531.14 KB, patch)
2018-01-10 22:40 PST, Darin Adler
no flags
Patch (533.23 KB, patch)
2018-01-10 23:30 PST, Darin Adler
no flags
Patch (510.09 KB, patch)
2018-01-11 08:54 PST, Darin Adler
no flags
Patch (533.19 KB, patch)
2018-01-11 19:52 PST, Darin Adler
no flags
Patch (534.56 KB, patch)
2018-01-11 20:39 PST, Darin Adler
no flags
Darin Adler
Comment 1 2017-12-08 22:24:18 PST Comment hidden (obsolete)
Darin Adler
Comment 2 2017-12-11 00:58:33 PST Comment hidden (obsolete)
Darin Adler
Comment 3 2017-12-11 01:00:34 PST Comment hidden (obsolete)
Darin Adler
Comment 4 2017-12-11 20:39:03 PST Comment hidden (obsolete)
Darin Adler
Comment 5 2017-12-11 21:37:52 PST Comment hidden (obsolete)
EWS Watchlist
Comment 6 2017-12-11 22:23:01 PST Comment hidden (obsolete)
EWS Watchlist
Comment 7 2017-12-11 22:23:02 PST Comment hidden (obsolete)
EWS Watchlist
Comment 8 2017-12-11 22:28:47 PST Comment hidden (obsolete)
EWS Watchlist
Comment 9 2017-12-11 22:28:48 PST Comment hidden (obsolete)
EWS Watchlist
Comment 10 2017-12-11 22:31:54 PST Comment hidden (obsolete)
EWS Watchlist
Comment 11 2017-12-11 22:31:55 PST Comment hidden (obsolete)
Darin Adler
Comment 12 2017-12-17 10:05:20 PST Comment hidden (obsolete)
Darin Adler
Comment 13 2017-12-17 10:28:34 PST Comment hidden (obsolete)
Darin Adler
Comment 14 2017-12-17 10:41:16 PST Comment hidden (obsolete)
Darin Adler
Comment 15 2017-12-17 11:08:48 PST Comment hidden (obsolete)
Darin Adler
Comment 16 2017-12-17 11:40:48 PST Comment hidden (obsolete)
Darin Adler
Comment 17 2017-12-17 12:44:43 PST Comment hidden (obsolete)
Darin Adler
Comment 18 2017-12-17 13:18:28 PST Comment hidden (obsolete)
EWS Watchlist
Comment 19 2017-12-17 14:36:11 PST Comment hidden (obsolete)
EWS Watchlist
Comment 20 2017-12-17 14:36:13 PST Comment hidden (obsolete)
EWS Watchlist
Comment 21 2017-12-17 14:52:14 PST Comment hidden (obsolete)
EWS Watchlist
Comment 22 2017-12-17 14:52:16 PST Comment hidden (obsolete)
Darin Adler
Comment 23 2017-12-17 19:36:14 PST Comment hidden (obsolete)
EWS Watchlist
Comment 24 2017-12-17 21:07:38 PST Comment hidden (obsolete)
EWS Watchlist
Comment 25 2017-12-17 21:07:40 PST Comment hidden (obsolete)
Darin Adler
Comment 26 2017-12-17 21:12:21 PST Comment hidden (obsolete)
EWS Watchlist
Comment 27 2017-12-17 22:17:16 PST Comment hidden (obsolete)
EWS Watchlist
Comment 28 2017-12-17 22:17:18 PST Comment hidden (obsolete)
EWS Watchlist
Comment 29 2017-12-17 22:29:55 PST Comment hidden (obsolete)
EWS Watchlist
Comment 30 2017-12-17 22:29:57 PST Comment hidden (obsolete)
EWS Watchlist
Comment 31 2017-12-17 22:44:42 PST Comment hidden (obsolete)
EWS Watchlist
Comment 32 2017-12-17 22:44:43 PST Comment hidden (obsolete)
EWS Watchlist
Comment 33 2017-12-17 22:47:34 PST Comment hidden (obsolete)
EWS Watchlist
Comment 34 2017-12-17 22:47:36 PST Comment hidden (obsolete)
Darin Adler
Comment 35 2018-01-10 22:40:23 PST Comment hidden (obsolete)
Darin Adler
Comment 36 2018-01-10 23:30:51 PST Comment hidden (obsolete)
Darin Adler
Comment 37 2018-01-11 08:54:02 PST Comment hidden (obsolete)
Darin Adler
Comment 38 2018-01-11 08:54:43 PST
I think the patch is ready for review now; but I could land it in much smaller pieces if reviewers think I should. Would probably make the process take weeks, but that’s OK with me.
Darin Adler
Comment 39 2018-01-11 19:52:30 PST Comment hidden (obsolete)
Darin Adler
Comment 40 2018-01-11 19:55:27 PST
(Accidentally uploaded a patch without the new files last time.)
Darin Adler
Comment 41 2018-01-11 20:39:04 PST
Darin Adler
Comment 42 2018-02-01 09:21:26 PST
Dean, Simon, anyone, would love to get your feedback on this patch eventually; finally got it all working three weeks ago. Some combination of: 1) Review and encouragement to finish and land. 2) Comments about what seems wrong or better ideas you may have, so I can continue to refine this or decide to abandon it. 3) Specific suggestion about the need to break it into smaller pieces. I am open to any of that.
Simon Fraser (smfr)
Comment 43 2018-02-01 10:52:43 PST
Comment on attachment 331165 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=331165&action=review I ran out of time half-way though, but I really thing this needs to be broken up in to probably many pieces. > Source/WebCore/css/CSSValuePool.cpp:134 > + return *m_fontFamilyValueCache.ensure({ familyName, isFromSystemID }, [&familyName, isFromSystemID] { > + return CSSPrimitiveValue::create(CSSFontFamily { familyName, isFromSystemID }); > + }).iterator->value; Not color-related. Do in separate patch. > Source/WebCore/css/CSSValuePool.cpp:151 > + return m_fontFaceValueCache.ensure(string, [&string] () -> RefPtr<CSSValueList> { > + auto result = CSSParser::parseSingleValue(CSSPropertyFontFamily, string); > + if (!is<CSSValueList>(result)) > + return nullptr; > + // FIXME: Make downcast work on RefPtr, remove the get() below, and save one reference count churn. > + return downcast<CSSValueList>(result.get()); > + }).iterator->value; Not color-related. Do in separate patch. > Source/WebCore/css/parser/CSSParserFastPaths.cpp:462 > +static std::optional<SimpleColor> finishParsingHexColor(uint32_t value, unsigned length) > +{ > + switch (length) { > + case 3: > + // #abc converts to #aabbcc > + return SimpleColor { 0xFF000000 > + | (value & 0xF00) << 12 | (value & 0xF00) << 8 > + | (value & 0xF0) << 8 | (value & 0xF0) << 4 > + | (value & 0xF) << 4 | (value & 0xF) }; > + case 4: > + // #abcd converts to ddaabbcc since alpha bytes are the high bytes. > + return SimpleColor { (value & 0xF) << 28 | (value & 0xF) << 24 > + | (value & 0xF000) << 8 | (value & 0xF000) << 4 > + | (value & 0xF00) << 4 | (value & 0xF00) > + | (value & 0xF0) | (value & 0xF0) >> 4 }; > + case 6: > + return SimpleColor { 0xFF000000 | value }; > + case 8: > + // We parsed the values into RGBA order, but we store them in ARGB order. > + return SimpleColor { value << 24 | value >> 8 }; > + } > + return std::nullopt; > +} > + > +template<typename CharacterType> static std::optional<SimpleColor> fastParseHexColor(const CharacterType* characters, unsigned length) Would be nice to land parsing changes separately from the other color stuff is possible, to make it easier to determine whether regressions are parsing regressions or other. > Source/WebCore/css/parser/CSSParserFastPaths.cpp:577 > + if (auto color = fastParseNumericColor(characters, length, inQuirksMode)) > + return color; > + return fastParseNamedColor(characters, length); I'm glad we're not trying named colors first now. This makes much more sense. > Source/WebCore/css/parser/CSSParserFastPaths.cpp:1403 > - RefPtr<CSSValue> result = parseSimpleLengthValue(propertyID, string, parserMode); > - if (result) > + if (auto result = parseSimpleLengthValue(propertyID, string, parserMode)) > return result; > if (propertyID == CSSPropertyCaretColor) > return parseCaretColor(string, parserMode); > if (isColorPropertyID(propertyID)) > return parseColor(string, parserMode); > - result = parseKeywordValue(propertyID, string, parserMode); > - if (result) > - return result; > - result = parseSimpleTransform(propertyID, string); > - if (result) > + if (auto result = parseKeywordValue(propertyID, string, parserMode)) > return result; > - return nullptr; > + return parseSimpleTransform(propertyID, string); Not color-related. Do in separate patch. > Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp:-65 > -#include "FloatQuad.h" > -#include "HTMLImageElement.h" > -#include "HTMLVideoElement.h" > -#include "ImageBitmap.h" > #include "ImageBuffer.h" > #include "ImageData.h" > #include "InspectorInstrumentation.h" > #include "Path2D.h" > -#include "RenderElement.h" > -#include "RenderImage.h" > -#include "RenderLayer.h" > #include "RenderTheme.h" > -#include "SecurityOrigin.h" > -#include "StrokeStyleApplier.h" > #include "StyleProperties.h" > #include "StyleResolver.h" > #include "TextMetrics.h" > #include "TextRun.h" > #include <wtf/CheckedArithmetic.h> > #include <wtf/MathExtras.h> > -#include <wtf/NeverDestroyed.h> > #include <wtf/text/StringBuilder.h> > -#include <wtf/text/TextStream.h> > - > -#if USE(CG) && !PLATFORM(IOS) > -#include <ApplicationServices/ApplicationServices.h> > -#endif ! > Source/WebCore/inspector/InspectorCanvas.cpp:163 > - m_currentActions->addItem(action); > + m_currentActions->addItem(action.ptr()); > > #if ENABLE(WEBGL) > if (is<WebGLRenderingContext>(m_context) && shouldSnapshotWebGLAction(name)) > - m_actionNeedingSnapshot = action; > + m_actionNeedingSnapshot = WTFMove(action); > #endif More stuff that should land separately. > Source/WebCore/inspector/InspectorCanvas.cpp:417 > -static RefPtr<JSON::ArrayOf<double>> buildArrayForAffineTransform(const AffineTransform& affineTransform) > +static Ref<JSON::ArrayOf<double>> buildArrayForAffineTransform(const AffineTransform& affineTransform) > { > - RefPtr<JSON::ArrayOf<double>> array = JSON::ArrayOf<double>::create(); > + auto array = JSON::ArrayOf<double>::create(); This whole set of changes is just auto stuff and cleanup. Should be separate. > Source/WebCore/inspector/InspectorCanvas.h:104 > - RefPtr<Inspector::Protocol::Recording::InitialState> buildInitialState(); > - RefPtr<JSON::ArrayOf<JSON::Value>> buildAction(const String&, Vector<RecordCanvasActionVariant>&& = { }); > - RefPtr<JSON::ArrayOf<JSON::Value>> buildArrayForCanvasGradient(const CanvasGradient&); > - RefPtr<JSON::ArrayOf<JSON::Value>> buildArrayForCanvasPattern(const CanvasPattern&); > - RefPtr<JSON::ArrayOf<JSON::Value>> buildArrayForImageData(const ImageData&); > + Ref<Inspector::Protocol::Recording::InitialState> buildInitialState(); > + Ref<JSON::ArrayOf<JSON::Value>> buildAction(const String&, Vector<RecordCanvasActionVariant>&& = { }); > + Ref<JSON::ArrayOf<JSON::Value>> buildArrayForCanvasGradient(const CanvasGradient&); > + Ref<JSON::ArrayOf<JSON::Value>> buildArrayForCanvasPattern(const CanvasPattern&); > + Ref<JSON::ArrayOf<JSON::Value>> buildArrayForImageData(const ImageData&); Land separately.
Darin Adler
Comment 44 2018-02-17 11:31:03 PST
OK, started by excerpting all the things Simon called out above (except the CSS parser part, bigger job to do that) and other independent tweaks into a new patch/bug.
Darin Adler
Comment 45 2020-05-22 16:53:13 PDT
This patch has lots of different ideas about improving Color. Some of them are things done already recently by Sam and others. Some of them are things where we did something better. But other things here are still good ideas.
Sam Weinig
Comment 46 2020-05-31 09:13:29 PDT
(In reply to Darin Adler from comment #45) > This patch has lots of different ideas about improving Color. Some of them > are things done already recently by Sam and others. Some of them are things > where we did something better. But other things here are still good ideas. Oh man, so much overlap! I did a pass of it and here are some things I think we should still do from it (I am probably missing some, but I wanted to write them down so I wouldn't forget): - Rename makeSimpleColor to makeSimpleColorFromRGBABytes (for 0-255 based input) - Rename makeSimpleColorFromFloats to makeSimpleColorFromRGBA (for 0.0f-1.0f based input) - Add non-clamping version of makeSimpleColorFromRGBABytes that takes uint8_ts - Move roundAndClampColorChannel to SVGAnimatedColor.cpp - Remove uses of code that requires NSDeviceRGBColorSpace, replacing with colorFromNSColor() in most cases - Lots of the API tests can be added as is (or slightly modified for different names - Use same overall structure for nsColor()/CSSValuePool::createColorValue() as leakCGColor() (e.g. switch + TinyLRUCache) - Split makePremultipliedSimpleColor into makePremultipliedFlooringSimpleColor/makePremultipliedCeilingSimpleColor Additional things I think we should do that weren't in the patch directly: - Time to replace uses of nextafter(256, 0) base conversion to int (chop and truncates) with 255 based conversion (clamp and round). - Move color modifying functions (e.g. blend, invert, lighten, etc.) outside of the Color class itself and into ColorUtilities. - Requiring passing the "working space" colorspace to blending / gradient / animation code - Remove makeSimpleColorFromHSLA and makeSimpleColorFromCMYKA, move / use conversion code in ColorUtilities - Consolidate/rationalize all the vaiious methods of determing relative differences (e.g. isDark(), lightness(), differenceSquared()) - Need to add encoding/decoding of semantic bit to Color coder - Should delegate to ExtendedColor/SimpleColor for coding - Rename colorWithAlpha to colorWithOverriddenAlpha
Darin Adler
Comment 47 2020-07-10 22:04:13 PDT
Seems like I should close this soon. I think almost everything has been done same or better by Sam or some earlier smaller patches by me.
Note You need to log in before you can comment on or make changes to this bug.