Setting foreground color when editing should take color-filter into account, and...
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jul 2018 21:18:27 +0000 (21:18 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jul 2018 21:18:27 +0000 (21:18 +0000)
commita2b7d6cd91b6d3bd77bc662591a800e26e093905
tree41b0fae22de49496632a2d397a901f65e84def9a
parent36c6017db643c120609b2c035a43b0b714f02d83
Setting foreground color when editing should take color-filter into account, and report the correct foreground color for collapsed selections
https://bugs.webkit.org/show_bug.cgi?id=187778

Reviewed by Ryosuke Niwa.
Source/WebCore:

Fix two aspects of editing with color-filter:

1. When setting foreground color, inverse-transform the color through -apple-color-filter so that the user gets the color
   they chose when in Dark Mode. Tested by editing/style/exec-command-foreColor-with-color-filter.html.

2. When retrieving the style of the collapsed selection, take color filter into account so that color picker
   reflects the color the users sees, instead of the content color. Tested by editing/mac/attributed-string/attributed-string-for-typing-with-color-filter.html

Add two additional tests that ensure that -apple-color-filter does not impact the NSAttributedString code
path, since -apple-color-filter should not affect the behavior of Copy.

Tests: editing/mac/attributed-string/attrib-string-colors-with-color-filter.html
       editing/mac/attributed-string/attrib-string-range-with-color-filter.html
       editing/mac/attributed-string/attributed-string-for-typing-with-color-filter.html
       editing/style/exec-command-foreColor-with-color-filter.html

* editing/EditingStyle.cpp:
(WebCore::StyleChange::StyleChange):
(WebCore::StyleChange::extractTextStyles):
* editing/EditingStyle.h:
* editing/cocoa/EditorCocoa.mm:
(WebCore::Editor::fontAttributesForSelectionStart const):
* platform/graphics/filters/FilterOperation.cpp:
(WebCore::InvertLightnessFilterOperation::inverseTransformColor const):
* platform/graphics/filters/FilterOperation.h:
(WebCore::FilterOperation::inverseTransformColor const):
* platform/graphics/filters/FilterOperations.cpp:
(WebCore::FilterOperations::transformColor const):
(WebCore::FilterOperations::inverseTransformColor const):
* platform/graphics/filters/FilterOperations.h:

LayoutTests:

* editing/mac/attributed-string/attrib-string-colors-with-color-filter-expected.txt: Added.
* editing/mac/attributed-string/attrib-string-colors-with-color-filter.html: Added.
* editing/mac/attributed-string/attrib-string-range-with-color-filter-expected.txt: Added.
* editing/mac/attributed-string/attrib-string-range-with-color-filter.html: Added.
* editing/mac/attributed-string/attributed-string-for-typing-with-color-filter-expected.txt: Added.
* editing/mac/attributed-string/attributed-string-for-typing-with-color-filter.html: Added.
* editing/style/exec-command-foreColor-with-color-filter-expected.txt: Added.
* editing/style/exec-command-foreColor-with-color-filter.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234005 268f45cc-cd09-0410-ab3c-d52691b4dbfc
20 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/mac/attributed-string/attrib-string-colors-with-color-filter-expected.txt [new file with mode: 0644]
LayoutTests/editing/mac/attributed-string/attrib-string-colors-with-color-filter.html [new file with mode: 0644]
LayoutTests/editing/mac/attributed-string/attrib-string-range-with-color-filter-expected.txt [new file with mode: 0644]
LayoutTests/editing/mac/attributed-string/attrib-string-range-with-color-filter.html [new file with mode: 0644]
LayoutTests/editing/mac/attributed-string/attributed-string-for-typing-with-color-filter-expected.txt [new file with mode: 0644]
LayoutTests/editing/mac/attributed-string/attributed-string-for-typing-with-color-filter.html [new file with mode: 0644]
LayoutTests/editing/style/exec-command-foreColor-with-color-filter-expected.txt [new file with mode: 0644]
LayoutTests/editing/style/exec-command-foreColor-with-color-filter.html [new file with mode: 0644]
LayoutTests/platform/mac-sierra/editing/mac/attributed-string/attrib-string-colors-with-color-filter-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-sierra/editing/mac/attributed-string/attrib-string-range-with-color-filter-expected.txt [new file with mode: 0644]
LayoutTests/platform/win/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/editing/EditingStyle.cpp
Source/WebCore/editing/EditingStyle.h
Source/WebCore/editing/cocoa/EditorCocoa.mm
Source/WebCore/platform/graphics/filters/FilterOperation.cpp
Source/WebCore/platform/graphics/filters/FilterOperation.h
Source/WebCore/platform/graphics/filters/FilterOperations.cpp
Source/WebCore/platform/graphics/filters/FilterOperations.h