Changeset 248347 in webkit
- Timestamp:
- Aug 6, 2019, 11:52:25 PM (7 years ago)
- Location:
- branches/safari-608.1-branch
- Files:
-
- 2 added
- 8 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/text-indicator/text-indicator-with-low-contrast-text-expected.txt (added)
-
LayoutTests/fast/text-indicator/text-indicator-with-low-contrast-text.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/platform/graphics/ColorUtilities.cpp (modified) (1 diff)
-
Source/WebCore/platform/graphics/ColorUtilities.h (modified) (1 diff)
-
Source/WebCore/rendering/TextPaintStyle.cpp (modified) (2 diffs)
-
Source/WebCore/testing/Internals.cpp (modified) (1 diff)
-
Source/WebCore/testing/Internals.h (modified) (3 diffs)
-
Source/WebCore/testing/Internals.idl (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-608.1-branch/LayoutTests/ChangeLog
r248345 r248347 1 2019-08-06 Kocsen Chung <kocsen_chung@apple.com> 2 3 Cherry-pick r247792. rdar://problem/54017900 4 5 Daring Fireball long press highlights are unnecessarily inflated due to false illegibility 6 https://bugs.webkit.org/show_bug.cgi?id=200064 7 8 Reviewed by Geoff Garen. 9 10 Source/WebCore: 11 12 If we consider text illegible on the given estimated background color, 13 we bail from doing a tightly fitted selection-only TextIndicator and 14 instead just paint the page without modification into the indicator, 15 causing ugly overlap and an excessively inflated indicator. 16 17 Change the mechanism we use to determine illegibility to be based on 18 a standard, instead of a constant chosen by hand 13 years ago. 19 20 Test: fast/text-indicator/text-indicator-with-low-contrast-text.html 21 22 * platform/graphics/ColorUtilities.cpp: 23 (WebCore::luminance): 24 Fix a typo. 25 26 (WebCore::contrastRatio): 27 Add a function that computes the contrast ratio given two colors using 28 the formula from WCAG. 29 30 * platform/graphics/ColorUtilities.h: 31 * rendering/TextPaintStyle.cpp: 32 (WebCore::textColorIsLegibleAgainstBackgroundColor): 33 Make use of WCAG's minimum legible contrast ratio instead of an 34 arbitrary color difference cutoff for determining whether we consider 35 text legible. It seems sensible and also considers the text on DF readable 36 (which it seems to be to me!). 37 38 * testing/Internals.cpp: 39 (WebCore::Internals::TextIndicatorInfo::TextIndicatorInfo): 40 * testing/Internals.h: 41 * testing/Internals.idl: 42 Expose all of the text rects to Internals, not just the bounding rect. 43 Expose some more TextIndicator options to Internals so that we can 44 turn on the legibility mechanism. 45 46 LayoutTests: 47 48 * fast/text-indicator/text-indicator-with-low-contrast-text-expected.txt: Added. 49 * fast/text-indicator/text-indicator-with-low-contrast-text.html: Added. 50 51 52 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247792 268f45cc-cd09-0410-ab3c-d52691b4dbfc 53 54 2019-07-24 Tim Horton <timothy_horton@apple.com> 55 56 Daring Fireball long press highlights are unnecessarily inflated due to false illegibility 57 https://bugs.webkit.org/show_bug.cgi?id=200064 58 59 Reviewed by Geoff Garen. 60 61 * fast/text-indicator/text-indicator-with-low-contrast-text-expected.txt: Added. 62 * fast/text-indicator/text-indicator-with-low-contrast-text.html: Added. 63 1 64 2019-08-06 Kocsen Chung <kocsen_chung@apple.com> 2 65 -
branches/safari-608.1-branch/Source/WebCore/ChangeLog
r248346 r248347 1 2019-08-06 Kocsen Chung <kocsen_chung@apple.com> 2 3 Cherry-pick r247792. rdar://problem/54017900 4 5 Daring Fireball long press highlights are unnecessarily inflated due to false illegibility 6 https://bugs.webkit.org/show_bug.cgi?id=200064 7 8 Reviewed by Geoff Garen. 9 10 Source/WebCore: 11 12 If we consider text illegible on the given estimated background color, 13 we bail from doing a tightly fitted selection-only TextIndicator and 14 instead just paint the page without modification into the indicator, 15 causing ugly overlap and an excessively inflated indicator. 16 17 Change the mechanism we use to determine illegibility to be based on 18 a standard, instead of a constant chosen by hand 13 years ago. 19 20 Test: fast/text-indicator/text-indicator-with-low-contrast-text.html 21 22 * platform/graphics/ColorUtilities.cpp: 23 (WebCore::luminance): 24 Fix a typo. 25 26 (WebCore::contrastRatio): 27 Add a function that computes the contrast ratio given two colors using 28 the formula from WCAG. 29 30 * platform/graphics/ColorUtilities.h: 31 * rendering/TextPaintStyle.cpp: 32 (WebCore::textColorIsLegibleAgainstBackgroundColor): 33 Make use of WCAG's minimum legible contrast ratio instead of an 34 arbitrary color difference cutoff for determining whether we consider 35 text legible. It seems sensible and also considers the text on DF readable 36 (which it seems to be to me!). 37 38 * testing/Internals.cpp: 39 (WebCore::Internals::TextIndicatorInfo::TextIndicatorInfo): 40 * testing/Internals.h: 41 * testing/Internals.idl: 42 Expose all of the text rects to Internals, not just the bounding rect. 43 Expose some more TextIndicator options to Internals so that we can 44 turn on the legibility mechanism. 45 46 LayoutTests: 47 48 * fast/text-indicator/text-indicator-with-low-contrast-text-expected.txt: Added. 49 * fast/text-indicator/text-indicator-with-low-contrast-text.html: Added. 50 51 52 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247792 268f45cc-cd09-0410-ab3c-d52691b4dbfc 53 54 2019-07-24 Tim Horton <timothy_horton@apple.com> 55 56 Daring Fireball long press highlights are unnecessarily inflated due to false illegibility 57 https://bugs.webkit.org/show_bug.cgi?id=200064 58 59 Reviewed by Geoff Garen. 60 61 If we consider text illegible on the given estimated background color, 62 we bail from doing a tightly fitted selection-only TextIndicator and 63 instead just paint the page without modification into the indicator, 64 causing ugly overlap and an excessively inflated indicator. 65 66 Change the mechanism we use to determine illegibility to be based on 67 a standard, instead of a constant chosen by hand 13 years ago. 68 69 Test: fast/text-indicator/text-indicator-with-low-contrast-text.html 70 71 * platform/graphics/ColorUtilities.cpp: 72 (WebCore::luminance): 73 Fix a typo. 74 75 (WebCore::contrastRatio): 76 Add a function that computes the contrast ratio given two colors using 77 the formula from WCAG. 78 79 * platform/graphics/ColorUtilities.h: 80 * rendering/TextPaintStyle.cpp: 81 (WebCore::textColorIsLegibleAgainstBackgroundColor): 82 Make use of WCAG's minimum legible contrast ratio instead of an 83 arbitrary color difference cutoff for determining whether we consider 84 text legible. It seems sensible and also considers the text on DF readable 85 (which it seems to be to me!). 86 87 * testing/Internals.cpp: 88 (WebCore::Internals::TextIndicatorInfo::TextIndicatorInfo): 89 * testing/Internals.h: 90 * testing/Internals.idl: 91 Expose all of the text rects to Internals, not just the bounding rect. 92 Expose some more TextIndicator options to Internals so that we can 93 turn on the legibility mechanism. 94 1 95 2019-08-06 Kocsen Chung <kocsen_chung@apple.com> 2 96 -
branches/safari-608.1-branch/Source/WebCore/platform/graphics/ColorUtilities.cpp
r233877 r248347 105 105 } 106 106 107 float luminance(const FloatComponents& sRGBCompon tents)107 float luminance(const FloatComponents& sRGBComponents) 108 108 { 109 109 // Values from https://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef 110 return 0.2126f * sRGBToLinearColorComponentForLuminance(sRGBCompontents.components[0]) 111 + 0.7152f * sRGBToLinearColorComponentForLuminance(sRGBCompontents.components[1]) 112 + 0.0722f * sRGBToLinearColorComponentForLuminance(sRGBCompontents.components[2]); 110 return 0.2126f * sRGBToLinearColorComponentForLuminance(sRGBComponents.components[0]) 111 + 0.7152f * sRGBToLinearColorComponentForLuminance(sRGBComponents.components[1]) 112 + 0.0722f * sRGBToLinearColorComponentForLuminance(sRGBComponents.components[2]); 113 } 114 115 float contrastRatio(const FloatComponents& componentsA, const FloatComponents& componentsB) 116 { 117 // Uses the WCAG 2.0 definition of contrast ratio. 118 // https://www.w3.org/TR/WCAG20/#contrast-ratiodef 119 float lighterLuminance = luminance(componentsA); 120 float darkerLuminance = luminance(componentsB); 121 122 if (lighterLuminance < darkerLuminance) 123 std::swap(lighterLuminance, darkerLuminance); 124 125 return (lighterLuminance + 0.05) / (darkerLuminance + 0.05); 113 126 } 114 127 -
branches/safari-608.1-branch/Source/WebCore/platform/graphics/ColorUtilities.h
r233877 r248347 163 163 164 164 float luminance(const FloatComponents& sRGBCompontents); 165 float contrastRatio(const FloatComponents&, const FloatComponents&); 165 166 166 167 class ColorMatrix { -
branches/safari-608.1-branch/Source/WebCore/rendering/TextPaintStyle.cpp
r245752 r248347 27 27 #include "TextPaintStyle.h" 28 28 29 #include "ColorUtilities.h" 29 30 #include "FocusController.h" 30 31 #include "Frame.h" … … 61 62 bool textColorIsLegibleAgainstBackgroundColor(const Color& textColor, const Color& backgroundColor) 62 63 { 63 // Semi-arbitrarily chose 65025 (255^2) value here after a few tests. 64 return differenceSquared(textColor, backgroundColor) > 65025; 64 // Uses the WCAG 2.0 definition of legibility: a contrast ratio of 4.5:1 or greater. 65 // https://www.w3.org/TR/WCAG20/#visual-audio-contrast-contrast 66 return contrastRatio(textColor, backgroundColor) > 4.5; 65 67 } 66 68 -
branches/safari-608.1-branch/Source/WebCore/testing/Internals.cpp
r247367 r248347 5110 5110 Internals::TextIndicatorInfo::TextIndicatorInfo(const WebCore::TextIndicatorData& data) 5111 5111 : textBoundingRectInRootViewCoordinates(DOMRect::create(data.textBoundingRectInRootViewCoordinates)) 5112 , textRectsInBoundingRectCoordinates(DOMRectList::create(data.textRectsInBoundingRectCoordinates)) 5112 5113 { 5113 5114 } -
branches/safari-608.1-branch/Source/WebCore/testing/Internals.h
r246917 r248347 836 836 struct TextIndicatorInfo { 837 837 RefPtr<DOMRectReadOnly> textBoundingRectInRootViewCoordinates; 838 RefPtr<DOMRectList> textRectsInBoundingRectCoordinates; 838 839 839 840 TextIndicatorInfo(); … … 844 845 struct TextIndicatorOptions { 845 846 bool useBoundingRectAndPaintAllContentForComplexRanges { false }; 847 bool computeEstimatedBackgroundColor { false }; 848 bool respectTextColor { false }; 846 849 847 850 WebCore::TextIndicatorOptions core() … … 850 853 if (useBoundingRectAndPaintAllContentForComplexRanges) 851 854 options = options | TextIndicatorOptionUseBoundingRectAndPaintAllContentForComplexRanges; 855 if (computeEstimatedBackgroundColor) 856 options = options | TextIndicatorOptionComputeEstimatedBackgroundColor; 857 if (respectTextColor) 858 options = options | TextIndicatorOptionRespectTextColor; 852 859 return options; 853 860 } -
branches/safari-608.1-branch/Source/WebCore/testing/Internals.idl
r246917 r248347 165 165 ] dictionary TextIndicatorInfo { 166 166 DOMRectReadOnly textBoundingRectInRootViewCoordinates; 167 DOMRectList textRectsInBoundingRectCoordinates; 167 168 }; 168 169 … … 172 173 ] dictionary TextIndicatorOptions { 173 174 boolean useBoundingRectAndPaintAllContentForComplexRanges = false; 175 boolean computeEstimatedBackgroundColor = false; 176 boolean respectTextColor = false; 174 177 }; 175 178
Note:
See TracChangeset
for help on using the changeset viewer.