mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 09:49:15 +03:00
LibWeb: Paint inspection outline for InlineNodes :^)
This iterates the fragments of the containing block, and paints their outlines if they are descendants of the InlineNode. If multiple fragments are adjacent, eg: ```html <span><b>Well</b> hello <i>friends!</i></span> ``` ...then we get a double-thick outline between "Well", " hello " and "friends!", but we can come back to this after we implement non-rectangular outlines for the `outline` CSS property.
This commit is contained in:
parent
37f060b873
commit
226fe4b57d
Notes:
sideshowbarker
2024-07-18 05:20:48 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/226fe4b57d9 Pull-request: https://github.com/SerenityOS/serenity/pull/9474 Issue: https://github.com/SerenityOS/serenity/issues/8936
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
#include <LibWeb/Layout/BlockBox.h>
|
||||
#include <LibWeb/Layout/InlineFormattingContext.h>
|
||||
@ -48,4 +49,20 @@ void InlineNode::paint_fragment(PaintContext& context, const LineBoxFragment& fr
|
||||
}
|
||||
}
|
||||
|
||||
void InlineNode::paint(PaintContext& context, PaintPhase phase)
|
||||
{
|
||||
auto& painter = context.painter();
|
||||
|
||||
if (phase == PaintPhase::Foreground && document().inspected_node() == dom_node()) {
|
||||
// FIXME: This paints a double-thick border between adjacent fragments, where ideally there
|
||||
// would be none. Once we implement non-rectangular outlines for the `outline` CSS
|
||||
// property, we can use that here instead.
|
||||
containing_block()->for_each_fragment([&](auto& fragment) {
|
||||
if (is_inclusive_ancestor_of(fragment.layout_node()))
|
||||
painter.draw_rect(enclosing_int_rect(fragment.absolute_rect()), Color::Magenta);
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ public:
|
||||
InlineNode(DOM::Document&, DOM::Element&, NonnullRefPtr<CSS::StyleProperties>);
|
||||
virtual ~InlineNode() override;
|
||||
|
||||
virtual void paint(PaintContext&, PaintPhase) override;
|
||||
virtual void paint_fragment(PaintContext&, const LineBoxFragment&, PaintPhase) const override;
|
||||
|
||||
virtual void split_into_lines(InlineFormattingContext&, LayoutMode) override;
|
||||
|
Loading…
Reference in New Issue
Block a user