Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Side by Side Diff: chrome/browser/android/vr_shell/textures/url_bar_texture.cc

Issue 2969623004: RenderText: Allow strike-through line thickness to be customized. (Closed)
Patch Set: Address final nits. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/vr_shell/textures/url_bar_texture.h" 5 #include "chrome/browser/android/vr_shell/textures/url_bar_texture.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "cc/paint/skia_paint_canvas.h" 8 #include "cc/paint/skia_paint_canvas.h"
9 #include "chrome/browser/android/vr_shell/color_scheme.h" 9 #include "chrome/browser/android/vr_shell/color_scheme.h"
10 #include "chrome/browser/android/vr_shell/textures/render_text_wrapper.h" 10 #include "chrome/browser/android/vr_shell/textures/render_text_wrapper.h"
(...skipping 15 matching lines...) Expand all
26 static constexpr float kHeight = 0.088; 26 static constexpr float kHeight = 0.088;
27 static constexpr float kFontHeight = 0.027; 27 static constexpr float kFontHeight = 0.027;
28 static constexpr float kBackButtonWidth = kHeight; 28 static constexpr float kBackButtonWidth = kHeight;
29 static constexpr float kBackIconHeight = 0.0375; 29 static constexpr float kBackIconHeight = 0.0375;
30 static constexpr float kBackIconOffset = 0.005; 30 static constexpr float kBackIconOffset = 0.005;
31 static constexpr float kFieldSpacing = 0.014; 31 static constexpr float kFieldSpacing = 0.014;
32 static constexpr float kSecurityIconSize = 0.03; 32 static constexpr float kSecurityIconSize = 0.03;
33 static constexpr float kUrlRightMargin = 0.02; 33 static constexpr float kUrlRightMargin = 0.02;
34 static constexpr float kSeparatorWidth = 0.002; 34 static constexpr float kSeparatorWidth = 0.002;
35 static constexpr float kChipTextLineMargin = kHeight * 0.3; 35 static constexpr float kChipTextLineMargin = kHeight * 0.3;
36 static constexpr SkScalar kStrikeThicknessFactor = (SK_Scalar1 / 9);
36 37
37 using security_state::SecurityLevel; 38 using security_state::SecurityLevel;
38 39
39 // See LocationBarView::GetSecureTextColor(). 40 // See LocationBarView::GetSecureTextColor().
40 SkColor GetSchemeColor(SecurityLevel level, const ColorScheme& color_scheme) { 41 SkColor GetSchemeColor(SecurityLevel level, const ColorScheme& color_scheme) {
41 switch (level) { 42 switch (level) {
42 case SecurityLevel::NONE: 43 case SecurityLevel::NONE:
43 case SecurityLevel::HTTP_SHOW_WARNING: 44 case SecurityLevel::HTTP_SHOW_WARNING:
44 return color_scheme.url_deemphasized; 45 return color_scheme.url_deemphasized;
45 case SecurityLevel::EV_SECURE: 46 case SecurityLevel::EV_SECURE:
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 397
397 // Only SECURE and DANGEROUS levels (pages served over HTTPS or flagged by 398 // Only SECURE and DANGEROUS levels (pages served over HTTPS or flagged by
398 // SafeBrowsing) get a special scheme color treatment. If the security level 399 // SafeBrowsing) get a special scheme color treatment. If the security level
399 // is NONE or HTTP_SHOW_WARNING, we do not override the text style previously 400 // is NONE or HTTP_SHOW_WARNING, we do not override the text style previously
400 // applied to the scheme text range by setEmphasis(). 401 // applied to the scheme text range by setEmphasis().
401 if (scheme_range.IsValid() && security_level != security_state::NONE && 402 if (scheme_range.IsValid() && security_level != security_state::NONE &&
402 security_level != security_state::HTTP_SHOW_WARNING) { 403 security_level != security_state::HTTP_SHOW_WARNING) {
403 render_text->ApplyColor(GetSchemeColor(security_level, color_scheme), 404 render_text->ApplyColor(GetSchemeColor(security_level, color_scheme),
404 scheme_range); 405 scheme_range);
405 if (security_level == SecurityLevel::DANGEROUS) { 406 if (security_level == SecurityLevel::DANGEROUS) {
407 render_text->SetStrikeThicknessFactor(kStrikeThicknessFactor);
406 render_text->ApplyStyle(gfx::TextStyle::STRIKE, true, scheme_range); 408 render_text->ApplyStyle(gfx::TextStyle::STRIKE, true, scheme_range);
407 } 409 }
408 } 410 }
409 } 411 }
410 412
411 gfx::Size UrlBarTexture::GetPreferredTextureSize(int maximum_width) const { 413 gfx::Size UrlBarTexture::GetPreferredTextureSize(int maximum_width) const {
412 return gfx::Size(maximum_width, maximum_width * kHeight / kWidth); 414 return gfx::Size(maximum_width, maximum_width * kHeight / kWidth);
413 } 415 }
414 416
415 gfx::SizeF UrlBarTexture::GetDrawnSize() const { 417 gfx::SizeF UrlBarTexture::GetDrawnSize() const {
416 return size_; 418 return size_;
417 } 419 }
418 420
419 } // namespace vr_shell 421 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698