mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:37:35 +00:00
LibWeb: Paint list markers antialiased
This commit is contained in:
parent
177d9b2a5a
commit
a705741be3
1 changed files with 5 additions and 7 deletions
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibGfx/AntiAliasingPainter.h>
|
||||
#include <LibGfx/StylePainter.h>
|
||||
#include <LibWeb/Layout/ListItemMarkerBox.h>
|
||||
#include <LibWeb/Painting/MarkerPaintable.h>
|
||||
|
@ -43,20 +44,17 @@ void MarkerPaintable::paint(PaintContext& context, PaintPhase phase) const
|
|||
Gfx::IntRect marker_rect { 0, 0, marker_width, marker_width };
|
||||
marker_rect.center_within(enclosing);
|
||||
|
||||
Gfx::AntiAliasingPainter aa_painter { context.painter() };
|
||||
|
||||
switch (layout_box().list_style_type()) {
|
||||
case CSS::ListStyleType::Square:
|
||||
context.painter().fill_rect(marker_rect, color);
|
||||
break;
|
||||
case CSS::ListStyleType::Circle:
|
||||
// For some reason for draw_ellipse() the ellipse is outside of the rect while for fill_ellipse() the ellipse is inside.
|
||||
// Scale the marker_rect with sqrt(2) to get an ellipse arc (circle) that appears as if it was inside of the marker_rect.
|
||||
marker_rect.set_height(marker_rect.height() / 1.41);
|
||||
marker_rect.set_width(marker_rect.width() / 1.41);
|
||||
marker_rect.center_within(enclosing);
|
||||
context.painter().draw_ellipse_intersecting(marker_rect, color);
|
||||
aa_painter.draw_ellipse(marker_rect, color, 1);
|
||||
break;
|
||||
case CSS::ListStyleType::Disc:
|
||||
context.painter().fill_ellipse(marker_rect, color);
|
||||
aa_painter.fill_ellipse(marker_rect, color);
|
||||
break;
|
||||
case CSS::ListStyleType::Decimal:
|
||||
case CSS::ListStyleType::DecimalLeadingZero:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue