Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove RenderSliderThumb
https://bugs.webkit.org/show_bug.cgi?id=240794

Reviewed by Antti Koivisto.

Test: imported/w3c/web-platform-tests/css/css-ui/appearance-cssom-001.html

* Source/WebCore/html/shadow/SliderThumbElement.cpp:
(WebCore::SliderThumbElement::resolveCustomStyle):
(WebCore::SliderContainerElement::resolveCustomStyle):
(WebCore::RenderSliderThumb::RenderSliderThumb): Deleted.
(WebCore::RenderSliderThumb::updateAppearance): Deleted.
(WebCore::RenderSliderThumb::isSliderThumb const): Deleted.
(WebCore::SliderThumbElement::createElementRenderer): Deleted.
* Source/WebCore/html/shadow/SliderThumbElement.h:
* Source/WebCore/rendering/RenderObject.h:
(WebCore::RenderObject::isSlider const):
(WebCore::RenderObject::isSliderThumb const): Deleted.
* Source/WebCore/rendering/RenderSlider.cpp:
(WebCore::RenderSlider::layout): Deleted.
* Source/WebCore/rendering/RenderSlider.h:

Canonical link: https://commits.webkit.org/250906@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294728 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
nt1m committed May 24, 2022
1 parent 263cfc9 commit 0f3a1e2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 68 deletions.
64 changes: 24 additions & 40 deletions Source/WebCore/html/shadow/SliderThumbElement.cpp
Expand Up @@ -63,7 +63,6 @@ using namespace HTMLNames;

WTF_MAKE_ISO_ALLOCATED_IMPL(SliderThumbElement);
WTF_MAKE_ISO_ALLOCATED_IMPL(SliderContainerElement);
WTF_MAKE_ISO_ALLOCATED_IMPL(RenderSliderThumb);

inline static Decimal sliderPosition(HTMLInputElement& element)
{
Expand All @@ -87,36 +86,6 @@ inline static bool hasVerticalAppearance(HTMLInputElement& input)

// --------------------------------

RenderSliderThumb::RenderSliderThumb(SliderThumbElement& element, RenderStyle&& style)
: RenderBlockFlow(element, WTFMove(style))
{
}

void RenderSliderThumb::updateAppearance(const RenderStyle* parentStyle)
{
if (parentStyle->effectiveAppearance() == SliderVerticalPart)
mutableStyle().setEffectiveAppearance(SliderThumbVerticalPart);
else if (parentStyle->effectiveAppearance() == SliderHorizontalPart)
mutableStyle().setEffectiveAppearance(SliderThumbHorizontalPart);
else if (parentStyle->effectiveAppearance() == MediaSliderPart)
mutableStyle().setEffectiveAppearance(MediaSliderThumbPart);
else if (parentStyle->effectiveAppearance() == MediaVolumeSliderPart)
mutableStyle().setEffectiveAppearance(MediaVolumeSliderThumbPart);
else if (parentStyle->effectiveAppearance() == MediaFullScreenVolumeSliderPart)
mutableStyle().setEffectiveAppearance(MediaFullScreenVolumeSliderThumbPart);
if (style().hasEffectiveAppearance()) {
ASSERT(element());
theme().adjustSliderThumbSize(mutableStyle(), element());
}
}

bool RenderSliderThumb::isSliderThumb() const
{
return true;
}

// --------------------------------

// FIXME: Find a way to cascade appearance and adjust heights, and get rid of this class.
// http://webkit.org/b/62535
class RenderSliderContainer final : public RenderFlexibleBox {
Expand Down Expand Up @@ -223,11 +192,6 @@ void SliderThumbElement::setPositionFromValue()
renderer()->setNeedsLayout();
}

RenderPtr<RenderElement> SliderThumbElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
{
return createRenderer<RenderSliderThumb>(*this, WTFMove(style));
}

bool SliderThumbElement::isDisabledFormControl() const
{
auto input = hostInput();
Expand Down Expand Up @@ -586,10 +550,8 @@ RefPtr<HTMLInputElement> SliderThumbElement::hostInput() const
return downcast<HTMLInputElement>(shadowHost());
}

std::optional<Style::ElementStyle> SliderThumbElement::resolveCustomStyle(const Style::ResolutionContext&, const RenderStyle* hostStyle)
std::optional<Style::ElementStyle> SliderThumbElement::resolveCustomStyle(const Style::ResolutionContext& resolutionContext, const RenderStyle* hostStyle)
{
// This doesn't actually compute style. This is just a hack to pick shadow pseudo id when host style is known.

if (!hostStyle)
return std::nullopt;

Expand All @@ -601,9 +563,31 @@ std::optional<Style::ElementStyle> SliderThumbElement::resolveCustomStyle(const
break;
default:
m_shadowPseudoId = ShadowPseudoIds::webkitSliderThumb();
break;
}

return std::nullopt;
auto elementStyle = resolveStyle(resolutionContext);
switch (hostStyle->effectiveAppearance()) {
case MediaSliderPart:
elementStyle.renderStyle->setEffectiveAppearance(MediaSliderThumbPart);
break;
case MediaVolumeSliderPart:
elementStyle.renderStyle->setEffectiveAppearance(MediaVolumeSliderThumbPart);
break;
case MediaFullScreenVolumeSliderPart:
elementStyle.renderStyle->setEffectiveAppearance(MediaFullScreenVolumeSliderThumbPart);
break;
case SliderVerticalPart:
elementStyle.renderStyle->setEffectiveAppearance(SliderThumbVerticalPart);
break;
case SliderHorizontalPart:
elementStyle.renderStyle->setEffectiveAppearance(SliderThumbHorizontalPart);
break;
default:
break;
}

return elementStyle;
}

const AtomString& SliderThumbElement::shadowPseudoId() const
Expand Down
14 changes: 0 additions & 14 deletions Source/WebCore/html/shadow/SliderThumbElement.h
Expand Up @@ -59,8 +59,6 @@ class SliderThumbElement final : public HTMLDivElement {
private:
SliderThumbElement(Document&);

RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;

Ref<Element> cloneElementWithoutAttributesAndChildren(Document&) final;
bool isDisabledFormControl() const final;
bool matchesReadWritePseudoClass() const final;
Expand Down Expand Up @@ -114,18 +112,6 @@ inline Ref<SliderThumbElement> SliderThumbElement::create(Document& document)

// --------------------------------

class RenderSliderThumb final : public RenderBlockFlow {
WTF_MAKE_ISO_ALLOCATED(RenderSliderThumb);
public:
RenderSliderThumb(SliderThumbElement&, RenderStyle&&);
void updateAppearance(const RenderStyle* parentStyle);

private:
bool isSliderThumb() const final;
};

// --------------------------------

class SliderContainerElement final : public HTMLDivElement {
WTF_MAKE_ISO_ALLOCATED(SliderContainerElement);
public:
Expand Down
1 change: 0 additions & 1 deletion Source/WebCore/rendering/RenderObject.h
Expand Up @@ -240,7 +240,6 @@ class RenderObject : public CachedImageClient {
virtual bool isRubyText() const { return false; }

virtual bool isSlider() const { return false; }
virtual bool isSliderThumb() const { return false; }
virtual bool isTable() const { return false; }
virtual bool isTableCell() const { return false; }
virtual bool isRenderTableCol() const { return false; }
Expand Down
12 changes: 0 additions & 12 deletions Source/WebCore/rendering/RenderSlider.cpp
Expand Up @@ -91,18 +91,6 @@ void RenderSlider::computePreferredLogicalWidths()
setPreferredLogicalWidthsDirty(false);
}

void RenderSlider::layout()
{
StackStats::LayoutCheckPoint layoutCheckPoint;

// FIXME: Find a way to cascade appearance. http://webkit.org/b/62535
RenderBox* thumbBox = element().sliderThumbElement()->renderBox();
if (thumbBox && thumbBox->isSliderThumb())
static_cast<RenderSliderThumb*>(thumbBox)->updateAppearance(&style());

RenderFlexibleBox::layout();
}

bool RenderSlider::inDragMode() const
{
return element().sliderThumbElement()->active();
Expand Down
1 change: 0 additions & 1 deletion Source/WebCore/rendering/RenderSlider.h
Expand Up @@ -48,7 +48,6 @@ class RenderSlider final : public RenderFlexibleBox {
LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const override;
void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const override;
void computePreferredLogicalWidths() override;
void layout() override;

bool isFlexibleBoxImpl() const override { return true; }
};
Expand Down

0 comments on commit 0f3a1e2

Please sign in to comment.