mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
Add ElementResizeAction to Page (maybe there's a better place). It's just a mousemove delegate that updates styles on the target element. Add ChromeMetrics for zoom-invariant chrome like scrollbar thumb thickness, resize gripper size, paddings, etc. It's not user-stylable but separates basic concerns in a way that a visually gifted designer unlike myself can adjust to taste. These values are pre-divided by zoom factor so that PaintableBox can continue using device_pixels_per_css_pixel calls as normal. The adjusted metrics are computed on demand from Page multiple times per paint cycle, which is not ideal but avoids lifetime management and atomics. Maybe someone with more surety about the painting flow control can improve this, but it won't be a huge win. If profiling shows this slowing paints, then Ladybird is in good shape. Update PaintableBox to draw the resize gripper and deconflict the scrollbars. Set apropriate cursors for scrollbars and gripper in mousemove. We override EventHandler's cursor handling because nothing should ever come between a man and his resize gripper. Chrome metrics use the CSSPixels class. This is good because it's broadly compatible but bad because they're actually different units when zoom is not 1.0. If that's a problem, we could make a new type or just use double.
32 lines
646 B
C++
32 lines
646 B
C++
/*
|
|
* Copyright (c) 2025, Jonathan Gamble <gamblej@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibGC/Cell.h>
|
|
#include <LibWeb/Forward.h>
|
|
#include <LibWeb/PixelUnits.h>
|
|
|
|
// https://drafts.csswg.org/css-ui#resize
|
|
|
|
namespace Web {
|
|
|
|
class ElementResizeAction {
|
|
public:
|
|
ElementResizeAction(GC::Ref<DOM::Element> element, CSSPixelPoint pointer_down_origin);
|
|
|
|
void handle_pointer_move(CSSPixelPoint pointer_position);
|
|
|
|
void visit_edges(GC::Cell::Visitor&) const;
|
|
|
|
private:
|
|
GC::Ref<DOM::Element> m_element;
|
|
CSSPixelPoint m_pointer_down_origin;
|
|
CSSPixelSize m_initial_border_box_size;
|
|
};
|
|
|
|
}
|