Skip to content
Permalink
Browse files
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 0f3a1e26e86fc75749c4cb93736c8677fea00ebb
Showing 5 changed files with 24 additions and 68 deletions.
@@ -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)
{
@@ -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 {
@@ -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();
@@ -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;

@@ -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
@@ -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;
@@ -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:
@@ -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; }
@@ -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();
@@ -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; }
};

0 comments on commit 0f3a1e2

Please sign in to comment.