diff options
author | Andreas Kling <awesomekling@gmail.com> | 2020-01-13 20:33:15 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2020-01-13 20:33:15 +0100 |
commit | fd64e97c8afb46b5e152bd18d0376c2094c9f3f3 (patch) | |
tree | 678728c143762318a1b09dd8645521f5668feec3 /Libraries/LibHTML | |
parent | 3b2f20ed4d393b93de3dd84cf6290ec5fb089593 (diff) | |
download | serenity-fd64e97c8afb46b5e152bd18d0376c2094c9f3f3.zip |
LibDraw+LibHTML: Make link colors themeable
Add "Link", "ActiveLink" and "VisitedLink" colors to the system theme
definition, and implement support for them in LibHTML.
Note that <body link="foo" alink="bar" vlink="baz"> takes precedence
over the system colors. Author style also takes precedence, since we
only fetch the system color in case the CSS color is -libhtml-link.
Diffstat (limited to 'Libraries/LibHTML')
-rw-r--r-- | Libraries/LibHTML/DOM/Document.cpp | 28 | ||||
-rw-r--r-- | Libraries/LibHTML/DOM/Document.h | 12 |
2 files changed, 34 insertions, 6 deletions
diff --git a/Libraries/LibHTML/DOM/Document.cpp b/Libraries/LibHTML/DOM/Document.cpp index 80acf9713a..dbaed1013d 100644 --- a/Libraries/LibHTML/DOM/Document.cpp +++ b/Libraries/LibHTML/DOM/Document.cpp @@ -12,6 +12,7 @@ #include <LibHTML/DOM/HTMLHtmlElement.h> #include <LibHTML/DOM/HTMLTitleElement.h> #include <LibHTML/Frame.h> +#include <LibHTML/HtmlView.h> #include <LibHTML/Layout/LayoutDocument.h> #include <LibHTML/Layout/LayoutTreeBuilder.h> #include <stdio.h> @@ -275,3 +276,30 @@ Vector<const Element*> Document::get_elements_by_name(const String& name) const }); return elements; } + +Color Document::link_color() const +{ + if (m_link_color.has_value()) + return m_link_color.value(); + if (!frame()) + return Color::Blue; + return frame()->html_view()->palette().link(); +} + +Color Document::active_link_color() const +{ + if (m_active_link_color.has_value()) + return m_active_link_color.value(); + if (!frame()) + return Color::Red; + return frame()->html_view()->palette().active_link(); +} + +Color Document::visited_link_color() const +{ + if (m_visited_link_color.has_value()) + return m_visited_link_color.value(); + if (!frame()) + return Color::Magenta; + return frame()->html_view()->palette().visited_link(); +} diff --git a/Libraries/LibHTML/DOM/Document.h b/Libraries/LibHTML/DOM/Document.h index 022be5ab06..c47ecf583c 100644 --- a/Libraries/LibHTML/DOM/Document.h +++ b/Libraries/LibHTML/DOM/Document.h @@ -64,13 +64,13 @@ public: Color background_color(const Palette&) const; RefPtr<GraphicsBitmap> background_image() const; - Color link_color() const { return m_link_color; } + Color link_color() const; void set_link_color(Color); - Color active_link_color() const { return m_active_link_color; } + Color active_link_color() const; void set_active_link_color(Color); - Color visited_link_color() const { return m_visited_link_color; } + Color visited_link_color() const; void set_visited_link_color(Color); void layout(); @@ -105,9 +105,9 @@ private: RefPtr<LayoutDocument> m_layout_root; - Color m_link_color { Color::Blue }; - Color m_active_link_color { Color::Red }; - Color m_visited_link_color { Color::Magenta }; + Optional<Color> m_link_color; + Optional<Color> m_active_link_color; + Optional<Color> m_visited_link_color; RefPtr<CTimer> m_style_update_timer; |