From 2614ef550c7b94dbe7c7e0b96622380d1186aea1 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 14 Aug 2020 20:02:46 +0200 Subject: [PATCH] LibWeb: Only paint focus outline when browser window has focus This is communicated through the PaintContext::has_focus() flag. --- Libraries/LibWeb/Layout/LayoutDocument.cpp | 3 ++- Libraries/LibWeb/PageView.cpp | 1 + Libraries/LibWeb/Painting/PaintContext.h | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Libraries/LibWeb/Layout/LayoutDocument.cpp b/Libraries/LibWeb/Layout/LayoutDocument.cpp index 90232cb7c0..541ff7ddd7 100644 --- a/Libraries/LibWeb/Layout/LayoutDocument.cpp +++ b/Libraries/LibWeb/Layout/LayoutDocument.cpp @@ -105,7 +105,8 @@ void LayoutDocument::paint_all_phases(PaintContext& context) paint(context, PaintPhase::Background); paint(context, PaintPhase::Border); paint(context, PaintPhase::Foreground); - paint(context, PaintPhase::FocusOutline); + if (context.has_focus()) + paint(context, PaintPhase::FocusOutline); paint(context, PaintPhase::Overlay); } diff --git a/Libraries/LibWeb/PageView.cpp b/Libraries/LibWeb/PageView.cpp index bb6004e3ad..3bc38f8085 100644 --- a/Libraries/LibWeb/PageView.cpp +++ b/Libraries/LibWeb/PageView.cpp @@ -273,6 +273,7 @@ void PageView::paint_event(GUI::PaintEvent& event) PaintContext context(painter, palette(), { horizontal_scrollbar().value(), vertical_scrollbar().value() }); context.set_should_show_line_box_borders(m_should_show_line_box_borders); context.set_viewport_rect(viewport_rect_in_content_coordinates()); + context.set_has_focus(is_focused()); layout_root()->paint_all_phases(context); } diff --git a/Libraries/LibWeb/Painting/PaintContext.h b/Libraries/LibWeb/Painting/PaintContext.h index 9daaa96467..530338e605 100644 --- a/Libraries/LibWeb/Painting/PaintContext.h +++ b/Libraries/LibWeb/Painting/PaintContext.h @@ -26,9 +26,9 @@ #pragma once +#include #include #include -#include namespace Web { @@ -52,12 +52,16 @@ public: const Gfx::IntPoint& scroll_offset() const { return m_scroll_offset; } + bool has_focus() const { return m_focus; } + void set_has_focus(bool focus) { m_focus = focus; } + private: Gfx::Painter& m_painter; Palette m_palette; Gfx::IntRect m_viewport_rect; Gfx::IntPoint m_scroll_offset; bool m_should_show_line_box_borders { false }; + bool m_focus { false }; }; }