Changeset 250863 in webkit
- Timestamp:
- Oct 8, 2019 2:56:28 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r250861 r250863 1 2019-10-08 Timothy Hatcher <timothy@apple.com> 2 3 Copying white text from dark mode WebKit apps and pasting in a light mode app results in white (invisible) text. 4 https://bugs.webkit.org/show_bug.cgi?id=202662 5 rdar://problem/48677354 6 7 Reviewed by Megan Gardner. 8 9 Covered by new API tests. 10 11 HTMLConverter needs to strip white text colors when the document is in dark mode, like it does for black in light mode. 12 13 * editing/cocoa/HTMLConverter.mm: 14 (normalizedColor): Handle dark mode and ignore white. 15 (HTMLConverterCaches::colorPropertyValueForNode): Pass element to normalizedColor. 16 1 17 2019-10-08 Antti Koivisto <antti@apple.com> 2 18 -
trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm
r248846 r250863 856 856 } 857 857 858 static Color normalizedColor(Color color, bool ignore Black)859 { 860 const double ColorEpsilon = 1 / (2 * (double)255.0);861 862 double red, green, blue, alpha; 863 color.getRGBA(red, green, blue, alpha);864 if ( red < ColorEpsilon && green < ColorEpsilon && blue < ColorEpsilon && (ignoreBlack || alpha < ColorEpsilon))858 static Color normalizedColor(Color color, bool ignoreDefaultColor, Element& element) 859 { 860 if (!ignoreDefaultColor) 861 return color; 862 863 bool useDarkAppearance = element.document().useDarkAppearance(element.existingComputedStyle()); 864 if (useDarkAppearance && Color::isWhiteColor(color)) 865 865 return Color(); 866 866 867 if (!useDarkAppearance && Color::isBlackColor(color)) 868 return Color(); 869 867 870 return color; 868 871 } … … 876 879 } 877 880 881 bool ignoreDefaultColor = propertyId == CSSPropertyColor; 882 878 883 Element& element = downcast<Element>(node); 879 884 if (RefPtr<CSSValue> value = computedStylePropertyForElement(element, propertyId)) { 880 885 if (is<CSSPrimitiveValue>(*value) && downcast<CSSPrimitiveValue>(*value).isRGBColor()) 881 return normalizedColor(Color(downcast<CSSPrimitiveValue>(*value).color().rgb()), propertyId == CSSPropertyColor);886 return normalizedColor(Color(downcast<CSSPrimitiveValue>(*value).color().rgb()), ignoreDefaultColor, element); 882 887 } 883 888 … … 885 890 if (RefPtr<CSSValue> value = inlineStylePropertyForElement(element, propertyId)) { 886 891 if (is<CSSPrimitiveValue>(*value) && downcast<CSSPrimitiveValue>(*value).isRGBColor()) 887 return normalizedColor(Color(downcast<CSSPrimitiveValue>(*value).color().rgb()), propertyId == CSSPropertyColor);892 return normalizedColor(Color(downcast<CSSPrimitiveValue>(*value).color().rgb()), ignoreDefaultColor, element); 888 893 if (value->isInheritedValue()) 889 894 inherit = true; -
trunk/Tools/ChangeLog
r250852 r250863 1 2019-10-08 Timothy Hatcher <timothy@apple.com> 2 3 Copying white text from dark mode WebKit apps and pasting in a light mode app results in white (invisible) text. 4 https://bugs.webkit.org/show_bug.cgi?id=202662 5 rdar://problem/48677354 6 7 Reviewed by Megan Gardner. 8 9 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 10 * TestWebKitAPI/Tests/WebKitCocoa/CopyRTF.mm: Added. 11 (readRTFDataFromPasteboard): 12 (copyAttributedStringFromHTML): 13 (checkColor): 14 (TEST): 15 1 16 2019-10-08 Brady Eidson <beidson@apple.com> 2 17 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r250774 r250863 104 104 1C2B81871C8925A000A5529F /* Ahem.ttf in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1C2B81851C89252300A5529F /* Ahem.ttf */; }; 105 105 1C734B5320788C4800F430EA /* SystemColors.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C734B5220788C4800F430EA /* SystemColors.mm */; }; 106 1C79201C234BDD9B001EAF23 /* CopyRTF.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C79201B234BDD9B001EAF23 /* CopyRTF.mm */; }; 106 107 1C7FEB20207C0F2E00D23278 /* BackgroundColor.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C7FEB1F207C0F2D00D23278 /* BackgroundColor.mm */; }; 107 108 1C90420C2326E03C00BEF91E /* SelectionByWord.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C90420B2326E03C00BEF91E /* SelectionByWord.mm */; }; … … 1536 1537 1C2B81851C89252300A5529F /* Ahem.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = Ahem.ttf; sourceTree = "<group>"; }; 1537 1538 1C734B5220788C4800F430EA /* SystemColors.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SystemColors.mm; sourceTree = "<group>"; }; 1539 1C79201B234BDD9B001EAF23 /* CopyRTF.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CopyRTF.mm; sourceTree = "<group>"; }; 1538 1540 1C7FEB1F207C0F2D00D23278 /* BackgroundColor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BackgroundColor.mm; sourceTree = "<group>"; }; 1539 1541 1C90420B2326E03C00BEF91E /* SelectionByWord.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SelectionByWord.mm; sourceTree = "<group>"; }; … … 2780 2782 9B1056411F9045C700D5583F /* CopyHTML.mm */, 2781 2783 9999108A1F393C8B008AD455 /* Copying.mm */, 2784 1C79201B234BDD9B001EAF23 /* CopyRTF.mm */, 2782 2785 9B7A37C21F8AEBA5004AA228 /* CopyURL.mm */, 2783 2786 46A911582108E66B0078D40D /* CustomUserAgent.mm */, … … 4464 4467 9B1F6F781F90558400B55744 /* CopyHTML.mm in Sources */, 4465 4468 9999108B1F393C96008AD455 /* Copying.mm in Sources */, 4469 1C79201C234BDD9B001EAF23 /* CopyRTF.mm in Sources */, 4466 4470 9B7A37C41F8AEBA5004AA228 /* CopyURL.mm in Sources */, 4467 4471 7CCE7EAC1A411A3400447C4C /* Counters.cpp in Sources */,
Note: See TracChangeset
for help on using the changeset viewer.