mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 20:45:14 +00:00
LibWeb: Apply input range accent color not when appearance: none;
This commit is contained in:
parent
51f5c4a718
commit
9fbf5039a6
Notes:
github-actions[bot]
2024-09-23 15:05:43 +00:00
Author: https://github.com/bplaat Commit: https://github.com/LadybirdBrowser/ladybird/commit/9fbf5039a63 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1365 Reviewed-by: https://github.com/trflynn89
2 changed files with 19 additions and 12 deletions
|
@ -80,8 +80,9 @@ void HTMLInputElement::visit_edges(Cell::Visitor& visitor)
|
|||
visitor.visit(m_file_label);
|
||||
visitor.visit(m_legacy_pre_activation_behavior_checked_element_in_group);
|
||||
visitor.visit(m_selected_files);
|
||||
visitor.visit(m_slider_thumb);
|
||||
visitor.visit(m_slider_runnable_track);
|
||||
visitor.visit(m_slider_progress_element);
|
||||
visitor.visit(m_slider_thumb);
|
||||
visitor.visit(m_resource_request);
|
||||
}
|
||||
|
||||
|
@ -995,9 +996,9 @@ void HTMLInputElement::create_range_input_shadow_tree()
|
|||
auto shadow_root = heap().allocate<DOM::ShadowRoot>(realm(), document(), *this, Bindings::ShadowRootMode::Closed);
|
||||
set_shadow_root(shadow_root);
|
||||
|
||||
auto slider_runnable_track = MUST(DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML));
|
||||
slider_runnable_track->set_use_pseudo_element(CSS::Selector::PseudoElement::Type::SliderRunnableTrack);
|
||||
MUST(shadow_root->append_child(slider_runnable_track));
|
||||
m_slider_runnable_track = MUST(DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML));
|
||||
m_slider_runnable_track->set_use_pseudo_element(CSS::Selector::PseudoElement::Type::SliderRunnableTrack);
|
||||
MUST(shadow_root->append_child(*m_slider_runnable_track));
|
||||
|
||||
m_slider_progress_element = MUST(DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML));
|
||||
MUST(m_slider_progress_element->set_attribute(HTML::AttributeNames::style, R"~~~(
|
||||
|
@ -1005,11 +1006,12 @@ void HTMLInputElement::create_range_input_shadow_tree()
|
|||
position: absolute;
|
||||
height: 100%;
|
||||
)~~~"_string));
|
||||
MUST(slider_runnable_track->append_child(*m_slider_progress_element));
|
||||
MUST(m_slider_runnable_track->append_child(*m_slider_progress_element));
|
||||
|
||||
m_slider_thumb = MUST(DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML));
|
||||
m_slider_thumb->set_use_pseudo_element(CSS::Selector::PseudoElement::Type::SliderThumb);
|
||||
MUST(slider_runnable_track->append_child(*m_slider_thumb));
|
||||
MUST(m_slider_runnable_track->append_child(*m_slider_thumb));
|
||||
|
||||
update_slider_shadow_tree_elements();
|
||||
|
||||
auto keydown_callback_function = JS::NativeFunction::create(
|
||||
|
@ -1035,8 +1037,8 @@ void HTMLInputElement::create_range_input_shadow_tree()
|
|||
|
||||
auto wheel_callback_function = JS::NativeFunction::create(
|
||||
realm(), [this](JS::VM& vm) {
|
||||
auto deltaY = MUST(vm.argument(0).get(vm, "deltaY")).as_i32();
|
||||
if (deltaY > 0) {
|
||||
auto delta_y = MUST(vm.argument(0).get(vm, "deltaY")).as_i32();
|
||||
if (delta_y > 0) {
|
||||
MUST(step_down());
|
||||
} else {
|
||||
MUST(step_up());
|
||||
|
@ -1094,6 +1096,10 @@ void HTMLInputElement::create_range_input_shadow_tree()
|
|||
|
||||
void HTMLInputElement::computed_css_values_changed()
|
||||
{
|
||||
auto appearance = computed_css_values()->appearance();
|
||||
if (!appearance.has_value() || *appearance == CSS::Appearance::None)
|
||||
return;
|
||||
|
||||
auto palette = document().page().palette();
|
||||
auto accent_color = palette.color(ColorRole::Accent).to_string();
|
||||
|
||||
|
@ -1131,11 +1137,11 @@ void HTMLInputElement::update_slider_shadow_tree_elements()
|
|||
double maximum = *max();
|
||||
double position = (value - minimum) / (maximum - minimum) * 100;
|
||||
|
||||
if (m_slider_thumb)
|
||||
MUST(m_slider_thumb->style_for_bindings()->set_property(CSS::PropertyID::MarginLeft, MUST(String::formatted("{}%", position))));
|
||||
|
||||
if (m_slider_progress_element)
|
||||
MUST(m_slider_progress_element->style_for_bindings()->set_property(CSS::PropertyID::Width, MUST(String::formatted("{}%", position))));
|
||||
|
||||
if (m_slider_thumb)
|
||||
MUST(m_slider_thumb->style_for_bindings()->set_property(CSS::PropertyID::MarginLeft, MUST(String::formatted("{}%", position))));
|
||||
}
|
||||
|
||||
void HTMLInputElement::did_receive_focus()
|
||||
|
|
|
@ -305,8 +305,9 @@ private:
|
|||
JS::GCPtr<DOM::Element> m_file_label;
|
||||
|
||||
void update_slider_shadow_tree_elements();
|
||||
JS::GCPtr<DOM::Element> m_slider_thumb;
|
||||
JS::GCPtr<DOM::Element> m_slider_runnable_track;
|
||||
JS::GCPtr<DOM::Element> m_slider_progress_element;
|
||||
JS::GCPtr<DOM::Element> m_slider_thumb;
|
||||
|
||||
JS::GCPtr<DecodedImageData> image_data() const;
|
||||
JS::GCPtr<SharedResourceRequest> m_resource_request;
|
||||
|
|
Loading…
Add table
Reference in a new issue