-
Notifications
You must be signed in to change notification settings - Fork 920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added theme change support in speedreader. #14307
Conversation
A Storybook has been deployed to preview UI for the latest push |
A Storybook has been deployed to preview UI for the latest push |
@@ -82,6 +87,7 @@ a[href] { | |||
#article { | |||
text-rendering: optimizeLegibility; | |||
font-family: "Georgia", "Times New Roman", Times, serif; | |||
user-select: unset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we disabling user's ability to select text in the article?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the entire speedreader-desktop.css file from the downloadable components. I don't know why :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UPD: This rule doesn't disable text selection. It should be 'none' to disable, am i wrong ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, right. still not sure which value it's unsetting from or why it's needed
@@ -281,6 +282,11 @@ pub fn extract_dom<S: ::std::hash::BuildHasher>( | |||
let title_blob = format!("<title>{}</title>", &meta.title); | |||
content = title_blob + &content; | |||
} | |||
|
|||
if let Some(theme) = theme { | |||
content = format!("<html theme-data=\"{}\">", theme) + &content + "</html>"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
custom attributes are prefixed with data-*
A Storybook has been deployed to preview UI for the latest push |
A Storybook has been deployed to preview UI for the latest push |
std::string GetSystemTheme(); | ||
void SetTheme(Theme theme); | ||
Theme GetTheme(); | ||
std::string GetThemeName(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need ::GetThemeName
here again? We're probably using the service method or is this a left over?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, should be deleted.
@@ -11,6 +11,14 @@ class HostContentSettingsMap; | |||
|
|||
namespace speedreader { | |||
|
|||
// Enum is used in prefs. Be careful when changing or extending. | |||
enum class Theme { | |||
kDefault = 0, // Use browser's theme |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be kNone
which implies the user hasn't set a theme.
case Theme::kDark: | ||
return "dark"; | ||
} | ||
NOTREACHED(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why NOTREACHED
and not a default:
switch case? a default switch case will always fallback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switch (s) {
// cases
default: return {};
}
// nothing needed here
A Storybook has been deployed to preview UI for the latest push |
A Storybook has been deployed to preview UI for the latest push |
8f632cb
to
137bd35
Compare
A Storybook has been deployed to preview UI for the latest push |
A Storybook has been deployed to preview UI for the latest push |
A Storybook has been deployed to preview UI for the latest push |
@@ -291,7 +291,7 @@ void SpeedreaderTabHelper::SetTheme(Theme theme) { | |||
Theme SpeedreaderTabHelper::GetTheme() { | |||
const Theme theme = | |||
SpeedreaderServiceFactory::GetForProfile(GetProfile())->GetTheme(); | |||
if (theme == Theme::kDefault) { | |||
if (theme == Theme::kNone) { | |||
switch (dark_mode::GetActiveBraveDarkModeType()) { | |||
case dark_mode::BraveDarkModeType::BRAVE_DARK_MODE_TYPE_DARK: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is ::BRAVE_DARK_MODE_TYPE_DEFAULT
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// DEFAULT type acts as two ways depends on system theme mode.
// If system dark mode is not supported, we override it with channel based
// policy. In this case, user can see dark or light option in settings.
// Otherwise, it acts like system dark mode mode. It respects system's dark
// mode. In this case, user can see all three options in theme settings.
GetActiveBraveDarkModeType never returns default.
A Storybook has been deployed to preview UI for the latest push |
@@ -7,6 +7,7 @@ | |||
|
|||
#include "base/feature_list.h" | |||
#include "base/metrics/histogram_macros.h" | |||
#include "base/notreached.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not used
#include "brave/browser/speedreader/speedreader_tab_helper.h" | ||
#include "brave/components/speedreader/speedreader_throttle.h" | ||
#include "brave/components/speedreader/speedreader_util.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
used in line 744
A Storybook has been deployed to preview UI for the latest push |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Resolves brave/brave-browser#23447
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
,npm run lint
,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan:
NOTE: Downloadable component isn't updated yet. So to check this PR you should use built-in css stylesheet.
Make sure the component with id 'jicbkmdloagakknpihibphagfckhjdih' is removed from the profile before running browser for testing.
NOTE: If something goes wrong, check component 'jicbkmdloagakknpihibphagfckhjdih' is not downloaded.