mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:47:45 +00:00
LibWeb: Give SVG geometry elements a position
This makes the selected-in-the-inspector outline appear in the right place. We take the stroke-width into account when producing the bounding box, which makes the fit nice and snug. :^)
This commit is contained in:
parent
ae93aeb414
commit
aba8774c9c
4 changed files with 16 additions and 4 deletions
|
@ -8,12 +8,14 @@
|
|||
|
||||
#include <AK/Vector.h>
|
||||
#include <LibGfx/Color.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
|
||||
namespace Web {
|
||||
|
||||
class SVGContext {
|
||||
public:
|
||||
SVGContext()
|
||||
SVGContext(Gfx::FloatRect svg_element_bounds)
|
||||
: m_svg_element_bounds(svg_element_bounds)
|
||||
{
|
||||
m_states.append(State());
|
||||
}
|
||||
|
@ -26,6 +28,8 @@ public:
|
|||
void set_stroke_color(Gfx::Color color) { state().stroke_color = color; }
|
||||
void set_stroke_width(float width) { state().stroke_width = width; }
|
||||
|
||||
Gfx::FloatPoint svg_element_position() const { return m_svg_element_bounds.top_left(); }
|
||||
|
||||
void save() { m_states.append(m_states.last()); }
|
||||
void restore() { m_states.take_last(); }
|
||||
|
||||
|
@ -39,6 +43,7 @@ private:
|
|||
const State& state() const { return m_states.last(); }
|
||||
State& state() { return m_states.last(); }
|
||||
|
||||
Gfx::FloatRect m_svg_element_bounds;
|
||||
Vector<State> m_states;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue