Diff
Modified: trunk/Source/WebCore/ChangeLog (275160 => 275161)
--- trunk/Source/WebCore/ChangeLog 2021-03-29 16:30:09 UTC (rev 275160)
+++ trunk/Source/WebCore/ChangeLog 2021-03-29 16:31:48 UTC (rev 275161)
@@ -1,3 +1,54 @@
+2021-03-29 Aditya Keerthi <[email protected]>
+
+ Use enum classes and OptionSets for ControlStates::States
+ https://bugs.webkit.org/show_bug.cgi?id=223647
+
+ Reviewed by Sam Weinig.
+
+ No behavior change.
+
+ * dom/Element.cpp:
+ (WebCore::Element::setActive):
+ (WebCore::Element::setHovered):
+ * editing/FrameSelection.cpp:
+ (WebCore::FrameSelection::focusedOrActiveStateChanged):
+ * html/HTMLFormControlElement.cpp:
+ (WebCore::HTMLFormControlElement::disabledStateChanged):
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::setChecked):
+ (WebCore::HTMLInputElement::setIndeterminate):
+ * html/HTMLOptionElement.cpp:
+ (WebCore::HTMLOptionElement::parseAttribute):
+ * platform/ControlStates.h:
+ (WebCore::ControlStates::ControlStates):
+ (WebCore::ControlStates::states const):
+ (WebCore::ControlStates::setStates):
+ * platform/adwaita/ThemeAdwaita.cpp:
+ (WebCore::ThemeAdwaita::paintCheckbox):
+ (WebCore::ThemeAdwaita::paintRadio):
+ (WebCore::ThemeAdwaita::paintButton):
+ (WebCore::ThemeAdwaita::paintSpinButton):
+ * platform/mac/ThemeMac.mm:
+ (WebCore::updateStates):
+ (WebCore::paintToggleButton):
+ (WebCore::button):
+ (WebCore::paintButton):
+ (WebCore::paintStepper):
+ (WebCore::ThemeMac::ensuredView):
+ (WebCore::paintColorWell):
+ * rendering/RenderTheme.cpp:
+ (WebCore::RenderTheme::stateChanged const):
+ (WebCore::RenderTheme::extractControlStatesForRenderer const):
+ * rendering/RenderTheme.h:
+ * rendering/RenderThemeAdwaita.cpp:
+ (WebCore::RenderThemeAdwaita::paintMenuList):
+ * rendering/RenderThemeIOS.h:
+ * rendering/RenderThemeIOS.mm:
+ (WebCore::RenderThemeIOS::checkboxRadioBackgroundColor):
+ (WebCore::RenderThemeIOS::checkboxRadioIndicatorColor):
+ (WebCore::RenderThemeIOS::paintCheckbox):
+ (WebCore::RenderThemeIOS::paintRadio):
+
2021-03-28 Antoine Quint <[email protected]>
Add support for animating the vertical-align CSS property
Modified: trunk/Source/WebCore/dom/Element.cpp (275160 => 275161)
--- trunk/Source/WebCore/dom/Element.cpp 2021-03-29 16:30:09 UTC (rev 275160)
+++ trunk/Source/WebCore/dom/Element.cpp 2021-03-29 16:31:48 UTC (rev 275161)
@@ -711,7 +711,7 @@
return;
bool reactsToPress = false;
- if (renderer()->style().hasAppearance() && renderer()->theme().stateChanged(*renderer(), ControlStates::PressedState))
+ if (renderer()->style().hasAppearance() && renderer()->theme().stateChanged(*renderer(), ControlStates::States::Pressed))
reactsToPress = true;
// The rest of this function implements a feature that only works if the
@@ -805,7 +805,7 @@
}
if (auto* style = renderStyle(); style && style->hasAppearance())
- renderer()->theme().stateChanged(*renderer(), ControlStates::HoverState);
+ renderer()->theme().stateChanged(*renderer(), ControlStates::States::Hovered);
}
void Element::setBeingDragged(bool flag)
Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (275160 => 275161)
--- trunk/Source/WebCore/editing/FrameSelection.cpp 2021-03-29 16:30:09 UTC (rev 275160)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp 2021-03-29 16:31:48 UTC (rev 275161)
@@ -2079,7 +2079,7 @@
element->invalidateStyleForSubtree();
if (RenderObject* renderer = element->renderer())
if (renderer && renderer->style().hasAppearance())
- renderer->theme().stateChanged(*renderer, ControlStates::FocusState);
+ renderer->theme().stateChanged(*renderer, ControlStates::States::Focused);
}
#endif
}
Modified: trunk/Source/WebCore/html/HTMLFormControlElement.cpp (275160 => 275161)
--- trunk/Source/WebCore/html/HTMLFormControlElement.cpp 2021-03-29 16:30:09 UTC (rev 275160)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.cpp 2021-03-29 16:31:48 UTC (rev 275161)
@@ -183,7 +183,7 @@
updateWillValidateAndValidity();
invalidateStyleForSubtree();
if (renderer() && renderer()->style().hasAppearance())
- renderer()->theme().stateChanged(*renderer(), ControlStates::EnabledState);
+ renderer()->theme().stateChanged(*renderer(), ControlStates::States::Enabled);
}
void HTMLFormControlElement::readOnlyStateChanged()
Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (275160 => 275161)
--- trunk/Source/WebCore/html/HTMLInputElement.cpp 2021-03-29 16:30:09 UTC (rev 275160)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp 2021-03-29 16:31:48 UTC (rev 275161)
@@ -965,7 +965,7 @@
if (RadioButtonGroups* buttons = radioButtonGroups())
buttons->updateCheckedState(*this);
if (renderer() && renderer()->style().hasAppearance())
- renderer()->theme().stateChanged(*renderer(), ControlStates::CheckedState);
+ renderer()->theme().stateChanged(*renderer(), ControlStates::States::Checked);
updateValidity();
// Ideally we'd do this from the render tree (matching
@@ -989,7 +989,7 @@
invalidateStyleForSubtree();
if (renderer() && renderer()->style().hasAppearance())
- renderer()->theme().stateChanged(*renderer(), ControlStates::CheckedState);
+ renderer()->theme().stateChanged(*renderer(), ControlStates::States::Checked);
}
unsigned HTMLInputElement::size() const
Modified: trunk/Source/WebCore/html/HTMLOptionElement.cpp (275160 => 275161)
--- trunk/Source/WebCore/html/HTMLOptionElement.cpp 2021-03-29 16:30:09 UTC (rev 275160)
+++ trunk/Source/WebCore/html/HTMLOptionElement.cpp 2021-03-29 16:31:48 UTC (rev 275161)
@@ -180,7 +180,7 @@
if (oldDisabled != m_disabled) {
invalidateStyleForSubtree();
if (renderer() && renderer()->style().hasAppearance())
- renderer()->theme().stateChanged(*renderer(), ControlStates::EnabledState);
+ renderer()->theme().stateChanged(*renderer(), ControlStates::States::Enabled);
}
} else if (name == selectedAttr) {
invalidateStyleForSubtree();
Modified: trunk/Source/WebCore/platform/ControlStates.h (275160 => 275161)
--- trunk/Source/WebCore/platform/ControlStates.h 2021-03-29 16:30:09 UTC (rev 275160)
+++ trunk/Source/WebCore/platform/ControlStates.h 2021-03-29 16:31:48 UTC (rev 275161)
@@ -26,6 +26,7 @@
#ifndef ControlStates_h
#define ControlStates_h
+#include <wtf/OptionSet.h>
#include <wtf/RetainPtr.h>
#include <wtf/Seconds.h>
@@ -44,34 +45,28 @@
class ControlStates {
WTF_MAKE_FAST_ALLOCATED;
public:
- enum {
- HoverState = 1,
- PressedState = 1 << 1,
- FocusState = 1 << 2,
- EnabledState = 1 << 3,
- CheckedState = 1 << 4,
- DefaultState = 1 << 5,
- WindowInactiveState = 1 << 6,
- IndeterminateState = 1 << 7,
- SpinUpState = 1 << 8, // Sub-state for HoverState and PressedState.
- PresentingState = 1 << 9,
- AllStates = 0xffffffff
+ enum class States : uint16_t {
+ Hovered = 1 << 0,
+ Pressed = 1 << 1,
+ Focused = 1 << 2,
+ Enabled = 1 << 3,
+ Checked = 1 << 4,
+ Default = 1 << 5,
+ WindowInactive = 1 << 6,
+ Indeterminate = 1 << 7,
+ SpinUp = 1 << 8, // Sub-state for HoverState and PressedState.
+ Presenting = 1 << 9,
};
- typedef unsigned States;
-
- ControlStates(States states)
+ ControlStates(OptionSet<States> states)
: m_states(states)
{
}
- ControlStates()
- : ControlStates(0)
- {
- }
+ ControlStates() = default;
- States states() const { return m_states; }
- void setStates(States newStates)
+ OptionSet<States> states() const { return m_states; }
+ void setStates(OptionSet<States> newStates)
{
if (newStates == m_states)
return;
@@ -95,7 +90,7 @@
#endif
private:
- States m_states;
+ OptionSet<States> m_states;
bool m_initialized { false };
bool m_needsRepaint { false };
bool m_isDirty { false };
Modified: trunk/Source/WebCore/platform/adwaita/ThemeAdwaita.cpp (275160 => 275161)
--- trunk/Source/WebCore/platform/adwaita/ThemeAdwaita.cpp 2021-03-29 16:30:09 UTC (rev 275160)
+++ trunk/Source/WebCore/platform/adwaita/ThemeAdwaita.cpp 2021-03-29 16:31:48 UTC (rev 275161)
@@ -257,9 +257,9 @@
path.addRoundedRect(fieldRect, corner);
graphicsContext.setFillRule(WindRule::NonZero);
- if (!(states.states() & ControlStates::EnabledState))
+ if (!states.states().contains(ControlStates::States::Enabled))
graphicsContext.setFillColor(toggleBackgroundDisabledColor);
- else if (states.states() & ControlStates::HoverState)
+ else if (states.states().contains(ControlStates::States::Hovered))
graphicsContext.setFillColor(toggleBackgroundHoveredColor);
else
graphicsContext.setFillColor(toggleBackgroundColor);
@@ -266,11 +266,11 @@
graphicsContext.fillPath(path);
path.clear();
- if (states.states() & (ControlStates::CheckedState | ControlStates::IndeterminateState)) {
+ if (states.states().containsAny({ ControlStates::States::Checked, ControlStates::States::Indeterminate })) {
GraphicsContextStateSaver checkedStateSaver(graphicsContext);
graphicsContext.translate(fieldRect.x(), fieldRect.y());
graphicsContext.scale(FloatSize::narrowPrecision(fieldRect.width() / toggleSize, fieldRect.height() / toggleSize));
- if (states.states() & ControlStates::CheckedState) {
+ if (states.states().contains(ControlStates::States::Checked)) {
path.moveTo({ 2.43, 6.57 });
path.addLineTo({ 7.5, 11.63 });
path.addLineTo({ 14, 5 });
@@ -281,7 +281,7 @@
} else
path.addRoundedRect(FloatRect(2, 5, 10, 4), corner);
- if (!(states.states() & ControlStates::EnabledState))
+ if (!states.states().contains(ControlStates::States::Enabled))
graphicsContext.setFillColor(toggleDisabledColor);
else
graphicsContext.setFillColor(toggleColor);
@@ -290,7 +290,7 @@
path.clear();
}
- if (states.states() & ControlStates::FocusState)
+ if (states.states().contains(ControlStates::States::Focused))
paintFocus(graphicsContext, zoomedRect, toggleFocusOffset);
}
@@ -318,9 +318,9 @@
path.addEllipse(fieldRect);
graphicsContext.setFillRule(WindRule::NonZero);
- if (!(states.states() & ControlStates::EnabledState))
+ if (!states.states().contains(ControlStates::States::Enabled))
graphicsContext.setFillColor(toggleBackgroundDisabledColor);
- else if (states.states() & ControlStates::HoverState)
+ else if (states.states().contains(ControlStates::States::Hovered))
graphicsContext.setFillColor(toggleBackgroundHoveredColor);
else
graphicsContext.setFillColor(toggleBackgroundColor);
@@ -327,10 +327,10 @@
graphicsContext.fillPath(path);
path.clear();
- if (states.states() & ControlStates::CheckedState) {
+ if (states.states().contains(ControlStates::States::Checked)) {
fieldRect.inflate(-(fieldRect.width() - fieldRect.width() * 0.70));
path.addEllipse(fieldRect);
- if (!(states.states() & ControlStates::EnabledState))
+ if (!states.states().contains(ControlStates::States::Enabled))
graphicsContext.setFillColor(toggleDisabledColor);
else
graphicsContext.setFillColor(toggleColor);
@@ -337,7 +337,7 @@
graphicsContext.fillPath(path);
}
- if (states.states() & ControlStates::FocusState)
+ if (states.states().contains(ControlStates::States::Focused))
paintFocus(graphicsContext, zoomedRect, toggleFocusOffset);
}
@@ -359,17 +359,17 @@
path.addRoundedRect(fieldRect, corner);
graphicsContext.setFillRule(WindRule::NonZero);
- if (!(states.states() & ControlStates::EnabledState))
+ if (!states.states().contains(ControlStates::States::Enabled))
graphicsContext.setFillColor(buttonBackgroundDisabledColor);
- else if (states.states() & ControlStates::PressedState)
+ else if (states.states().contains(ControlStates::States::Pressed))
graphicsContext.setFillColor(buttonBackgroundPressedColor);
- else if (states.states() & ControlStates::HoverState)
+ else if (states.states().contains(ControlStates::States::Hovered))
graphicsContext.setFillColor(buttonBackgroundHoveredColor);
else
graphicsContext.setFillColor(buttonBackgroundColor);
graphicsContext.fillPath(path);
- if (states.states() & ControlStates::FocusState)
+ if (states.states().contains(ControlStates::States::Focused))
paintFocus(graphicsContext, zoomedRect, buttonFocusOffset);
}
@@ -398,11 +398,11 @@
FloatRect buttonRect = fieldRect;
buttonRect.setHeight(fieldRect.height() / 2.0);
{
- if (states.states() & ControlStates::SpinUpState) {
+ if (states.states().contains(ControlStates::States::SpinUp)) {
path.addRoundedRect(FloatRoundedRect(buttonRect, corner, corner, { }, { }));
- if (states.states() & ControlStates::PressedState)
+ if (states.states().contains(ControlStates::States::Pressed))
graphicsContext.setFillColor(spinButtonBackgroundPressedColor);
- else if (states.states() & ControlStates::HoverState)
+ else if (states.states().contains(ControlStates::States::Hovered))
graphicsContext.setFillColor(spinButtonBackgroundHoveredColor);
graphicsContext.fillPath(path);
path.clear();
@@ -420,11 +420,11 @@
buttonRect.move(0, buttonRect.height());
{
- if (!(states.states() & ControlStates::SpinUpState)) {
+ if (!states.states().contains(ControlStates::States::SpinUp)) {
path.addRoundedRect(FloatRoundedRect(buttonRect, { }, { }, corner, corner));
- if (states.states() & ControlStates::PressedState)
+ if (states.states().contains(ControlStates::States::Pressed))
graphicsContext.setFillColor(spinButtonBackgroundPressedColor);
- else if (states.states() & ControlStates::HoverState)
+ else if (states.states().contains(ControlStates::States::Hovered))
graphicsContext.setFillColor(spinButtonBackgroundHoveredColor);
graphicsContext.fillPath(path);
path.clear();
Modified: trunk/Source/WebCore/platform/mac/ThemeMac.mm (275160 => 275161)
--- trunk/Source/WebCore/platform/mac/ThemeMac.mm 2021-03-29 16:30:09 UTC (rev 275160)
+++ trunk/Source/WebCore/platform/mac/ThemeMac.mm 2021-03-29 16:31:48 UTC (rev 275161)
@@ -197,13 +197,13 @@
if (AXObjectCache::accessibilityEnhancedUserInterfaceEnabled())
useAnimation = false;
- ControlStates::States states = controlStates.states();
+ auto states = controlStates.states();
// Hover state is not supported by Aqua.
// Pressed state
bool oldPressed = [cell isHighlighted];
- bool pressed = states & ControlStates::PressedState;
+ bool pressed = states.contains(ControlStates::States::Pressed);
if (pressed != oldPressed) {
[(NSButtonCell*)cell _setHighlighted:pressed animated:useAnimation];
}
@@ -210,14 +210,14 @@
// Enabled state
bool oldEnabled = [cell isEnabled];
- bool enabled = states & ControlStates::EnabledState;
+ bool enabled = states.contains(ControlStates::States::Enabled);
if (enabled != oldEnabled)
[cell setEnabled:enabled];
// Checked and Indeterminate
bool oldIndeterminate = [cell state] == NSControlStateValueMixed;
- bool indeterminate = (states & ControlStates::IndeterminateState);
- bool checked = states & ControlStates::CheckedState;
+ bool indeterminate = states.contains(ControlStates::States::Indeterminate);
+ bool checked = states.contains(ControlStates::States::Checked);
bool oldChecked = [cell state] == NSControlStateValueOn;
if (oldIndeterminate != indeterminate || checked != oldChecked) {
NSControlStateValue newState = indeterminate ? NSControlStateValueMixed : (checked ? NSControlStateValueOn : NSControlStateValueOff);
@@ -225,7 +225,7 @@
}
// Presenting state
- if (states & ControlStates::PresentingState)
+ if (states.contains(ControlStates::States::Presenting))
[(NSButtonCell*)cell _setHighlighted:YES animated:NO];
// Window inactive state does not need to be checked explicitly, since we paint parented to
@@ -443,7 +443,7 @@
NSView *view = ThemeMac::ensuredView(scrollView, controlStates, true /* useUnparentedView */);
bool needsRepaint = false;
- bool isCellFocused = controlStates.states() & ControlStates::FocusState;
+ bool isCellFocused = controlStates.states().contains(ControlStates::States::Focused);
if ([toggleButtonCell _stateAnimationRunning]) {
context.translate(inflatedRect.location());
@@ -534,9 +534,9 @@
static NSButtonCell *button(ControlPart part, const ControlStates& controlStates, const IntSize& zoomedSize, float zoomFactor)
{
- ControlStates::States states = controlStates.states();
+ auto states = controlStates.states();
NSButtonCell *cell;
- if (states & ControlStates::DefaultState) {
+ if (states.contains(ControlStates::States::Default)) {
static NeverDestroyed<RetainPtr<NSButtonCell>> defaultCell = buttonCell(DefaultButtonCell);
cell = defaultCell.get().get();
} else {
@@ -552,7 +552,7 @@
BEGIN_BLOCK_OBJC_EXCEPTIONS
// Determine the width and height needed for the control and prepare the cell for painting.
- ControlStates::States states = controlStates.states();
+ auto states = controlStates.states();
NSButtonCell *buttonCell = button(part, controlStates, IntSize(zoomedRect.size()), zoomFactor);
GraphicsContextStateSaver stateSaver(context);
@@ -586,8 +586,8 @@
NSWindow *window = [view window];
NSButtonCell *previousDefaultButtonCell = [window defaultButtonCell];
- bool needsRepaint = ThemeMac::drawCellOrFocusRingWithViewIntoContext(buttonCell, context, inflatedRect, view, true, states & ControlStates::FocusState, deviceScaleFactor);
- if (states & ControlStates::DefaultState)
+ bool needsRepaint = ThemeMac::drawCellOrFocusRingWithViewIntoContext(buttonCell, context, inflatedRect, view, true, states.contains(ControlStates::States::Focused), deviceScaleFactor);
+ if (states.contains(ControlStates::States::Default))
[window setDefaultButtonCell:buttonCell];
else if ([previousDefaultButtonCell isEqual:buttonCell])
[window setDefaultButtonCell:nil];
@@ -633,9 +633,9 @@
NSString *coreUIState;
auto states = controlStates.states();
- if (!(states & ControlStates::EnabledState))
+ if (!states.contains(ControlStates::States::Enabled))
coreUIState = (__bridge NSString *)kCUIStateDisabled;
- else if (states & ControlStates::PressedState)
+ else if (states.contains(ControlStates::States::Pressed))
coreUIState = (__bridge NSString *)kCUIStatePressed;
else
coreUIState = (__bridge NSString *)kCUIStateActive;
@@ -666,7 +666,7 @@
(__bridge NSString *)kCUIWidgetKey: (__bridge NSString *)kCUIWidgetButtonLittleArrows,
(__bridge NSString *)kCUISizeKey: coreUISize,
(__bridge NSString *)kCUIStateKey: coreUIState,
- (__bridge NSString *)kCUIValueKey: (states & ControlStates::SpinUpState) ? @1 : @0,
+ (__bridge NSString *)kCUIValueKey: states.contains(ControlStates::States::SpinUp) ? @1 : @0,
(__bridge NSString *)kCUIIsFlippedKey: @NO,
(__bridge NSString *)kCUIScaleKey: @1,
(__bridge NSString *)kCUIMaskOnlyKey: @NO
@@ -689,7 +689,7 @@
[themeView setAppearance:[NSAppearance currentAppearance]];
ALLOW_DEPRECATED_DECLARATIONS_END
- themeWindowHasKeyAppearance = !(controlStates.states() & ControlStates::WindowInactiveState);
+ themeWindowHasKeyAppearance = !controlStates.states().contains(ControlStates::States::WindowInactive);
return themeView;
}
@@ -750,7 +750,7 @@
BEGIN_BLOCK_OBJC_EXCEPTIONS
// Determine the width and height needed for the control and prepare the cell for painting.
- ControlStates::States states = controlStates.states();
+ auto states = controlStates.states();
NSButtonCell *buttonCell = button(ColorWellPart, controlStates, IntSize(zoomedRect.size()), zoomFactor);
GraphicsContextStateSaver stateSaver(context);
@@ -766,7 +766,7 @@
NSWindow *window = [view window];
NSButtonCell *previousDefaultButtonCell = [window defaultButtonCell];
- bool needsRepaint = ThemeMac::drawCellOrFocusRingWithViewIntoContext(buttonCell, context, inflatedRect, view, true, states & ControlStates::FocusState, deviceScaleFactor);
+ bool needsRepaint = ThemeMac::drawCellOrFocusRingWithViewIntoContext(buttonCell, context, inflatedRect, view, true, states.contains(ControlStates::States::Focused), deviceScaleFactor);
if ([previousDefaultButtonCell isEqual:buttonCell])
[window setDefaultButtonCell:nil];
Modified: trunk/Source/WebCore/rendering/RenderTheme.cpp (275160 => 275161)
--- trunk/Source/WebCore/rendering/RenderTheme.cpp 2021-03-29 16:30:09 UTC (rev 275160)
+++ trunk/Source/WebCore/rendering/RenderTheme.cpp 2021-03-29 16:31:48 UTC (rev 275161)
@@ -767,11 +767,11 @@
bool RenderTheme::stateChanged(const RenderObject& o, ControlStates::States state) const
{
// Default implementation assumes the controls don't respond to changes in :hover state
- if (state == ControlStates::HoverState && !supportsHover(o.style()))
+ if (state == ControlStates::States::Hovered && !supportsHover(o.style()))
return false;
// Assume pressed state is only responded to if the control is enabled.
- if (state == ControlStates::PressedState && !isEnabled(o))
+ if (state == ControlStates::States::Pressed && !isEnabled(o))
return false;
// Repaint the control.
@@ -787,33 +787,33 @@
controlStates.setTimeSinceControlWasFocused(box.page().focusController().timeSinceFocusWasSet());
}
-ControlStates::States RenderTheme::extractControlStatesForRenderer(const RenderObject& o) const
+OptionSet<ControlStates::States> RenderTheme::extractControlStatesForRenderer(const RenderObject& o) const
{
- ControlStates::States states = 0;
+ OptionSet<ControlStates::States> states;
if (isHovered(o)) {
- states |= ControlStates::HoverState;
+ states.add(ControlStates::States::Hovered);
if (isSpinUpButtonPartHovered(o))
- states |= ControlStates::SpinUpState;
+ states.add(ControlStates::States::SpinUp);
}
if (isPressed(o)) {
- states |= ControlStates::PressedState;
+ states.add(ControlStates::States::Pressed);
if (isSpinUpButtonPartPressed(o))
- states |= ControlStates::SpinUpState;
+ states.add(ControlStates::States::SpinUp);
}
if (isFocused(o) && o.style().outlineStyleIsAuto() == OutlineIsAuto::On)
- states |= ControlStates::FocusState;
+ states.add(ControlStates::States::Focused);
if (isEnabled(o))
- states |= ControlStates::EnabledState;
+ states.add(ControlStates::States::Enabled);
if (isChecked(o))
- states |= ControlStates::CheckedState;
+ states.add(ControlStates::States::Checked);
if (isDefault(o))
- states |= ControlStates::DefaultState;
+ states.add(ControlStates::States::Default);
if (!isActive(o))
- states |= ControlStates::WindowInactiveState;
+ states.add(ControlStates::States::WindowInactive);
if (isIndeterminate(o))
- states |= ControlStates::IndeterminateState;
+ states.add(ControlStates::States::Indeterminate);
if (isPresenting(o))
- states |= ControlStates::PresentingState;
+ states.add(ControlStates::States::Presenting);
return states;
}
Modified: trunk/Source/WebCore/rendering/RenderTheme.h (275160 => 275161)
--- trunk/Source/WebCore/rendering/RenderTheme.h 2021-03-29 16:30:09 UTC (rev 275160)
+++ trunk/Source/WebCore/rendering/RenderTheme.h 2021-03-29 16:31:48 UTC (rev 275161)
@@ -403,7 +403,7 @@
public:
void updateControlStatesForRenderer(const RenderBox&, ControlStates&) const;
- ControlStates::States extractControlStatesForRenderer(const RenderObject&) const;
+ OptionSet<ControlStates::States> extractControlStatesForRenderer(const RenderObject&) const;
bool isActive(const RenderObject&) const;
bool isChecked(const RenderObject&) const;
bool isIndeterminate(const RenderObject&) const;
Modified: trunk/Source/WebCore/rendering/RenderThemeAdwaita.cpp (275160 => 275161)
--- trunk/Source/WebCore/rendering/RenderThemeAdwaita.cpp 2021-03-29 16:30:09 UTC (rev 275160)
+++ trunk/Source/WebCore/rendering/RenderThemeAdwaita.cpp 2021-03-29 16:31:48 UTC (rev 275161)
@@ -268,13 +268,13 @@
auto& graphicsContext = paintInfo.context();
GraphicsContextStateSaver stateSaver(graphicsContext);
- ControlStates::States states = 0;
+ OptionSet<ControlStates::States> states;
if (isEnabled(renderObject))
- states |= ControlStates::EnabledState;
+ states.add(ControlStates::States::Enabled);
if (isPressed(renderObject))
- states |= ControlStates::PressedState;
+ states.add(ControlStates::States::Pressed);
if (isHovered(renderObject))
- states |= ControlStates::HoverState;
+ states.add(ControlStates::States::Hovered);
ControlStates controlStates(states);
Theme::singleton().paint(ButtonPart, controlStates, graphicsContext, rect, 1., nullptr, 1., 1., false, false);
Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.h (275160 => 275161)
--- trunk/Source/WebCore/rendering/RenderThemeIOS.h 2021-03-29 16:30:09 UTC (rev 275160)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.h 2021-03-29 16:31:48 UTC (rev 275161)
@@ -114,8 +114,8 @@
void paintSearchFieldDecorations(const RenderObject&, const PaintInfo&, const IntRect&) override;
#if ENABLE(IOS_FORM_CONTROL_REFRESH)
- Color checkboxRadioBackgroundColor(ControlStates::States, OptionSet<StyleColor::Options>);
- Color checkboxRadioIndicatorColor(ControlStates::States, OptionSet<StyleColor::Options>);
+ Color checkboxRadioBackgroundColor(OptionSet<ControlStates::States>, OptionSet<StyleColor::Options>);
+ Color checkboxRadioIndicatorColor(OptionSet<ControlStates::States>, OptionSet<StyleColor::Options>);
bool paintCheckbox(const RenderObject&, const PaintInfo&, const FloatRect&) override;
bool paintRadio(const RenderObject&, const PaintInfo&, const FloatRect&) override;
Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (275160 => 275161)
--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2021-03-29 16:30:09 UTC (rev 275160)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2021-03-29 16:31:48 UTC (rev 275161)
@@ -2008,30 +2008,30 @@
#if ENABLE(IOS_FORM_CONTROL_REFRESH)
-Color RenderThemeIOS::checkboxRadioBackgroundColor(ControlStates::States states, OptionSet<StyleColor::Options> styleColorOptions)
+Color RenderThemeIOS::checkboxRadioBackgroundColor(OptionSet<ControlStates::States> states, OptionSet<StyleColor::Options> styleColorOptions)
{
- if (!(states & ControlStates::EnabledState))
+ if (!states.contains(ControlStates::States::Enabled))
return systemColor(CSSValueAppleSystemSecondaryFillDisabled, styleColorOptions);
Color enabledBackgroundColor;
- if (states & ControlStates::CheckedState || states & ControlStates::IndeterminateState)
+ if (states.containsAny({ ControlStates::States::Checked, ControlStates::States::Indeterminate }))
enabledBackgroundColor = systemColor(CSSValueAppleSystemBlue, styleColorOptions);
else
enabledBackgroundColor = systemColor(CSSValueAppleSystemSecondaryFill, styleColorOptions);
- if (states & ControlStates::PressedState)
+ if (states.contains(ControlStates::States::Pressed))
return enabledBackgroundColor.colorWithAlphaMultipliedBy(pressedStateOpacity);
return enabledBackgroundColor;
}
-Color RenderThemeIOS::checkboxRadioIndicatorColor(ControlStates::States states, OptionSet<StyleColor::Options> styleColorOptions)
+Color RenderThemeIOS::checkboxRadioIndicatorColor(OptionSet<ControlStates::States> states, OptionSet<StyleColor::Options> styleColorOptions)
{
- if (!(states & ControlStates::EnabledState))
+ if (!states.contains(ControlStates::States::Enabled))
return systemColor(CSSValueAppleSystemTertiaryLabel, styleColorOptions);
Color enabledIndicatorColor = systemColor(CSSValueAppleSystemLabel, styleColorOptions | StyleColor::Options::UseDarkAppearance);
- if (states & ControlStates::PressedState)
+ if (states.contains(ControlStates::States::Pressed))
return enabledIndicatorColor.colorWithAlphaMultipliedBy(pressedStateOpacity);
return enabledIndicatorColor;
@@ -2055,8 +2055,8 @@
context.fillRoundedRect(checkboxRect, checkboxRadioBackgroundColor(controlStates, styleColorOptions));
- bool checked = controlStates & ControlStates::CheckedState;
- bool indeterminate = controlStates & ControlStates::IndeterminateState;
+ bool checked = controlStates.contains(ControlStates::States::Checked);
+ bool indeterminate = controlStates.contains(ControlStates::States::Indeterminate);
if (!checked && !indeterminate)
return false;
@@ -2113,7 +2113,7 @@
context.setFillColor(checkboxRadioBackgroundColor(controlStates, styleColorOptions));
context.fillEllipse(rect);
- if (controlStates & ControlStates::CheckedState) {
+ if (controlStates.contains(ControlStates::States::Checked)) {
// The inner circle is 6 / 14 the size of the surrounding circle,
// leaving 8 / 14 around it. (8 / 14) / 2 = 2 / 7.
constexpr float innerInverseRatio = 2 / 7.0f;