소스 검색

LibWeb: Use PaintableBox::is_scrollable() while dispatching wheel event

With this change we use the same function to determine whether to render
scroll thumb and whether box wants to accept scroll UI events.
Aliaksandr Kalenik 10 달 전
부모
커밋
97066f09f4
3개의 변경된 파일2개의 추가작업 그리고 13개의 파일을 삭제
  1. 0 6
      Userland/Libraries/LibWeb/Layout/Box.cpp
  2. 0 2
      Userland/Libraries/LibWeb/Layout/Box.h
  3. 2 5
      Userland/Libraries/LibWeb/Painting/PaintableBox.cpp

+ 0 - 6
Userland/Libraries/LibWeb/Layout/Box.cpp

@@ -60,12 +60,6 @@ bool Box::is_scroll_container() const
         || overflow_value_makes_box_a_scroll_container(computed_values().overflow_y());
         || overflow_value_makes_box_a_scroll_container(computed_values().overflow_y());
 }
 }
 
 
-bool Box::is_user_scrollable() const
-{
-    // FIXME: Support horizontal scroll as well (overflow-x)
-    return computed_values().overflow_y() == CSS::Overflow::Scroll || computed_values().overflow_y() == CSS::Overflow::Auto;
-}
-
 bool Box::is_body() const
 bool Box::is_body() const
 {
 {
     return dom_node() && dom_node() == document().body();
     return dom_node() && dom_node() == document().body();

+ 0 - 2
Userland/Libraries/LibWeb/Layout/Box.h

@@ -52,8 +52,6 @@ public:
 
 
     bool is_scroll_container() const;
     bool is_scroll_container() const;
 
 
-    bool is_user_scrollable() const;
-
     void add_contained_abspos_child(JS::NonnullGCPtr<Node> child) { m_contained_abspos_children.append(child); }
     void add_contained_abspos_child(JS::NonnullGCPtr<Node> child) { m_contained_abspos_children.append(child); }
     void clear_contained_abspos_children() { m_contained_abspos_children.clear(); }
     void clear_contained_abspos_children() { m_contained_abspos_children.clear(); }
     Vector<JS::NonnullGCPtr<Node>> const& contained_abspos_children() const { return m_contained_abspos_children; }
     Vector<JS::NonnullGCPtr<Node>> const& contained_abspos_children() const { return m_contained_abspos_children; }

+ 2 - 5
Userland/Libraries/LibWeb/Painting/PaintableBox.cpp

@@ -775,12 +775,9 @@ Paintable::DispatchEventOfSameName PaintableBox::handle_mousemove(Badge<EventHan
 
 
 bool PaintableBox::handle_mousewheel(Badge<EventHandler>, CSSPixelPoint, unsigned, unsigned, int wheel_delta_x, int wheel_delta_y)
 bool PaintableBox::handle_mousewheel(Badge<EventHandler>, CSSPixelPoint, unsigned, unsigned, int wheel_delta_x, int wheel_delta_y)
 {
 {
-    if (!layout_box().is_user_scrollable())
-        return false;
-
-    // TODO: Vertical and horizontal scroll overflow should be handled seperately.
-    if (!has_scrollable_overflow())
+    if (!is_scrollable()) {
         return false;
         return false;
+    }
 
 
     scroll_by(wheel_delta_x, wheel_delta_y);
     scroll_by(wheel_delta_x, wheel_delta_y);
     return true;
     return true;