-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-land "Use a standard interface for all StyleColor kinds, and move …
…them each to their own file" https://bugs.webkit.org/show_bug.cgi?id=274029 Reviewed by Matthieu Dubet and Tim Nguyen. In preparation for adding support for relative colors to StyleColor, this change adds explicit types for each StyleColor kind and gives each their own files. This allows the implementation of StyleColor itself to be very simple, just dispatching to whatever kind is resident in the variant. The one complication here is that StyleColorMix (and any relative color support type in the future), wants to have a StyleColor as a member, creating a recursive relationship. This means we have be very careful not to instantiate the ColorKind variant in the StyleColor header at all, as it would lead to undefined type compile errors. Instead, we out-of-line all the operations. With a bunch of StyleColor related files now existing, they also all got moved to the color subdirectory. * Source/WebCore/Headers.cmake: * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: - Added new files, updated for file moves. * Source/WebCore/css/color/CSSColorDescriptors.h: - Add missing #include. * Source/WebCore/css/color/CSSColorMixSerialization.h: - Updated #include to use new StyleColorMix header. * Source/WebCore/css/color/StyleAbsoluteColor.cpp: Added. * Source/WebCore/css/color/StyleAbsoluteColor.h: Added. - Added. Simple wrapper around a Color. * Source/WebCore/css/color/StyleColor.cpp: Renamed from Source/WebCore/css/StyleColor.cpp. * Source/WebCore/css/color/StyleColor.h: Renamed from Source/WebCore/css/StyleColor.h. - Moved. Updated to out-of-line all uses of ColorKind and use generic dispatch in all possible places. * Source/WebCore/css/color/StyleColorMix.cpp: Added. * Source/WebCore/css/color/StyleColorMix.h: Added. - Moved from StyleColor.h/cpp * Source/WebCore/css/color/StyleCurrentColor.cpp: Added. * Source/WebCore/css/color/StyleCurrentColor.h: Added. - Moved from StyleColor.h/cpp Canonical link: https://commits.webkit.org/278652@main
- Loading branch information
Showing
15 changed files
with
584 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright (C) 2024 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
* THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#include "config.h" | ||
#include "StyleAbsoluteColor.h" | ||
|
||
#include "ColorSerialization.h" | ||
#include <wtf/text/TextStream.h> | ||
|
||
namespace WebCore { | ||
|
||
// MARK: Current Color | ||
|
||
bool containsCurrentColor(const StyleAbsoluteColor&) | ||
{ | ||
return false; | ||
} | ||
|
||
// MARK: Resolve | ||
|
||
Color resolveColor(const StyleAbsoluteColor& absoluteColor, const Color&) | ||
{ | ||
return absoluteColor.color; | ||
} | ||
|
||
// MARK: - Serialization | ||
|
||
void serializationForCSS(StringBuilder& builder, const StyleAbsoluteColor& absoluteColor) | ||
{ | ||
builder.append(serializationForCSS(absoluteColor.color)); | ||
} | ||
|
||
String serializationForCSS(const StyleAbsoluteColor& absoluteColor) | ||
{ | ||
return serializationForCSS(absoluteColor.color); | ||
} | ||
|
||
// MARK: - TextStream | ||
|
||
WTF::TextStream& operator<<(WTF::TextStream& ts, const StyleAbsoluteColor& absoluteColor) | ||
{ | ||
ts << "absoluteColor(" << absoluteColor.color.debugDescription() << ")"; | ||
|
||
return ts; | ||
} | ||
|
||
} // namespace WebCore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (C) 2024 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
* THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "Color.h" | ||
#include <wtf/Forward.h> | ||
|
||
namespace WebCore { | ||
|
||
struct StyleAbsoluteColor { | ||
Color color; | ||
|
||
bool operator==(const StyleAbsoluteColor&) const = default; | ||
}; | ||
|
||
Color resolveColor(const StyleAbsoluteColor&, const Color& currentColor); | ||
bool containsCurrentColor(const StyleAbsoluteColor&); | ||
|
||
void serializationForCSS(StringBuilder&, const StyleAbsoluteColor&); | ||
String serializationForCSS(const StyleAbsoluteColor&); | ||
|
||
WTF::TextStream& operator<<(WTF::TextStream&, const StyleAbsoluteColor&); | ||
|
||
} // namespace WebCore |
Oops, something went wrong.