Explorar el Código

LibGUI+LibWeb: Use 'decrease_slider_by_steps()' method

This method allow us to avoid repeating the pattern
'set_value(value() - step() * step_number)'.
Elyse hace 3 años
padre
commit
8d1fb299b1

+ 1 - 1
Userland/Libraries/LibGUI/Scrollbar.cpp

@@ -228,7 +228,7 @@ void Scrollbar::paint_event(PaintEvent& event)
 void Scrollbar::on_automatic_scrolling_timer_fired()
 {
     if (m_pressed_component == Component::DecrementButton && component_at_position(m_last_mouse_position) == Component::DecrementButton) {
-        set_value(value() - step());
+        decrease_slider_by_steps(1);
         return;
     }
     if (m_pressed_component == Component::IncrementButton && component_at_position(m_last_mouse_position) == Component::IncrementButton) {

+ 2 - 2
Userland/Libraries/LibWeb/InProcessWebView.cpp

@@ -257,13 +257,13 @@ void InProcessWebView::keydown_event(GUI::KeyEvent& event)
             vertical_scrollbar().increase_slider_by_steps(1);
             break;
         case Key_Up:
-            vertical_scrollbar().set_value(vertical_scrollbar().value() - vertical_scrollbar().step());
+            vertical_scrollbar().decrease_slider_by_steps(1);
             break;
         case Key_Left:
             horizontal_scrollbar().increase_slider_by_steps(1);
             break;
         case Key_Right:
-            horizontal_scrollbar().set_value(horizontal_scrollbar().value() - horizontal_scrollbar().step());
+            horizontal_scrollbar().decrease_slider_by_steps(1);
             break;
         case Key_PageDown:
             vertical_scrollbar().increase_slider_by(frame_inner_rect().height());