Changeset 256580 in webkit
- Timestamp:
- Feb 13, 2020 6:56:32 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r256571 r256580 1 2020-02-13 Ryosuke Niwa <rniwa@webkit.org> 2 3 Dark Mode: In Notes, list item becomes invisible in dark mode after outdenting 4 https://bugs.webkit.org/show_bug.cgi?id=207676 5 6 Reviewed by Wenson Hsieh and Timothy Hatcher. 7 8 The bug was caused by EditingStyle::inverseTransformColorIfNeeded converting -apple-system-label to 9 transparent color in ReplaceSelectionCommand when InsertListCommand invokes moveParagraphs. 10 11 This patch fixes the bug in EditingStyle::inverseTransformColorIfNeeded by treating any semantic color 12 name or semantic RGB color value as if the color was not specified. 13 14 It also fixes the bug that removeStyleFromRulesAndContext was incapable of removing superflous semantic 15 color names that appear in the inline since the context's computed style only contain RGB values by 16 replacing the inline style's color values with that of the computed style. This fix is necessary to 17 eliminate -apple-system-label in the pasted content, which can cause issues when such a content is 18 sync'ed to other devices via iCloud, etc... 19 20 Tests: PasteHTML.TransformColorsOfDarkContentButNotSemanticColor 21 PasteHTML.DoesNotTransformColorsOfLightContentDuringOutdent 22 23 * editing/EditingStyle.cpp: 24 (WebCore::EditingStyle::removeStyleFromRulesAndContext): 25 (WebCore::EditingStyle::inverseTransformColorIfNeeded): 26 1 27 2020-02-13 Brent Fulgham <bfulgham@apple.com> 2 28 -
trunk/Source/WebCore/editing/EditingStyle.cpp
r253959 r256580 1367 1367 computedStyle->m_mutableStyle->setProperty(CSSPropertyBackgroundColor, CSSValueTransparent); 1368 1368 1369 RefPtr<EditingStyle> computedStyleOfElement; 1370 auto replaceSemanticColorWithComputedValue = [&](const CSSPropertyID id) { 1371 auto color = m_mutableStyle->propertyAsColor(id); 1372 if (!color || (color->isVisible() && !color->isSemantic())) 1373 return; 1374 1375 if (!computedStyleOfElement) 1376 computedStyleOfElement = EditingStyle::create(&element, EditingPropertiesInEffect); 1377 1378 if (!computedStyleOfElement->m_mutableStyle) 1379 return; 1380 1381 auto computedValue = computedStyleOfElement->m_mutableStyle->getPropertyValue(id); 1382 if (!computedValue) 1383 return; 1384 1385 m_mutableStyle->setProperty(id, computedValue); 1386 }; 1387 1388 // Replace semantic color identifiers like -apple-system-label with RGB values so that comparsions in getPropertiesNotIn below would work. 1389 replaceSemanticColorWithComputedValue(CSSPropertyColor); 1390 replaceSemanticColorWithComputedValue(CSSPropertyCaretColor); 1391 replaceSemanticColorWithComputedValue(CSSPropertyBackgroundColor); 1392 1369 1393 removePropertiesInStyle(computedStyle->m_mutableStyle.get(), styleFromMatchedRules.get()); 1370 1394 m_mutableStyle = getPropertiesNotIn(*m_mutableStyle, *computedStyle->m_mutableStyle); … … 1588 1612 return *this; 1589 1613 1590 bool hasColor = m_mutableStyle->getPropertyCSSValue(CSSPropertyColor); 1591 bool hasCaretColor = m_mutableStyle->getPropertyCSSValue(CSSPropertyCaretColor); 1592 bool hasBackgroundColor = m_mutableStyle->getPropertyCSSValue(CSSPropertyBackgroundColor); 1593 if (!hasColor && !hasCaretColor && !hasBackgroundColor) 1614 auto colorForPropertyIfInvertible = [&](CSSPropertyID id) -> Optional<Color> { 1615 auto color = m_mutableStyle->propertyAsColor(id); 1616 if (!color || !color->isVisible() || color->isSemantic()) 1617 return WTF::nullopt; 1618 return color; 1619 }; 1620 1621 auto color = colorForPropertyIfInvertible(CSSPropertyColor); 1622 auto caretColor = colorForPropertyIfInvertible(CSSPropertyCaretColor); 1623 auto backgroundColor = colorForPropertyIfInvertible(CSSPropertyBackgroundColor); 1624 if (!color && !caretColor && !backgroundColor) 1594 1625 return *this; 1595 1626 … … 1604 1635 }; 1605 1636 1606 if ( hasColor)1637 if (color) 1607 1638 invertedColor(CSSPropertyColor); 1608 1639 1609 if ( hasCaretColor)1640 if (caretColor) 1610 1641 invertedColor(CSSPropertyCaretColor); 1611 1642 1612 if ( hasBackgroundColor)1643 if (backgroundColor) 1613 1644 invertedColor(CSSPropertyBackgroundColor); 1614 1645 -
trunk/Tools/ChangeLog
r256562 r256580 1 2020-02-13 Ryosuke Niwa <rniwa@webkit.org> 2 3 Dark Mode: In Notes, list item becomes invisible in dark mode after outdenting 4 https://bugs.webkit.org/show_bug.cgi?id=207676 5 6 Reviewed by Wenson Hsieh and Timothy Hatcher. 7 8 Added regression tests for pasting content with -apple-system-label and outdenting content. 9 10 * TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm: 11 (PasteHTML.TransformColorsOfDarkContentButNotSemanticColor): 12 (PasteHTML.DoesNotTransformColorsOfLightContentDuringOutdent): 13 1 14 2020-02-13 Alex Christensen <achristensen@webkit.org> 2 15 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm
r249535 r256580 421 421 } 422 422 423 TEST(PasteHTML, TransformColorsOfDarkContentButNotSemanticColor) 424 { 425 auto webView = createWebViewWithCustomPasteboardDataSetting(true, true); 426 [webView forceDarkMode]; 427 428 [webView synchronouslyLoadTestPageNamed:@"rich-color-filtered"]; 429 430 [webView stringByEvaluatingJavaScript:@"document.body.style.color = '-apple-system-label';"]; 431 writeHTMLToPasteboard(@"<span style='color: -apple-system-label'>hello</span><b style='color: #eee'>world</b>"); 432 433 [webView stringByEvaluatingJavaScript:@"selectRichText()"]; 434 [webView paste:nil]; 435 436 #if USE(APPKIT) 437 EXPECT_WK_STREQ([webView stringByEvaluatingJavaScript:@"rich.innerHTML"], @"hello<b style=\"color: rgb(21, 21, 21);\">world</b>"); 438 #else 439 EXPECT_WK_STREQ([webView stringByEvaluatingJavaScript:@"rich.innerHTML"], 440 @"<span style=\"-webkit-text-size-adjust: auto;\">hello</span><b style=\"-webkit-text-size-adjust: auto; color: rgb(21, 21, 21);\">world</b>"); 441 #endif 442 } 443 444 TEST(PasteHTML, DoesNotTransformColorsOfLightContentDuringOutdent) 445 { 446 auto webView = createWebViewWithCustomPasteboardDataSetting(true, true); 447 [webView forceDarkMode]; 448 449 [webView synchronouslyLoadTestPageNamed:@"rich-color-filtered"]; 450 451 [webView stringByEvaluatingJavaScript:@"document.body.style = `color: -apple-system-label; caret-color: -apple-system-secondary-label; background-color: -apple-system-text-background;`;"]; 452 [webView stringByEvaluatingJavaScript:@"rich.innerHTML = `<ul><li>hello</li><ul><li id='target'>world</li></ul></ul>`;"]; 453 454 [webView stringByEvaluatingJavaScript:@"getSelection().setPosition(target, 0); document.execCommand('outdent');"]; 455 456 EXPECT_WK_STREQ([webView stringByEvaluatingJavaScript:@"rich.innerHTML"], @"<ul><li>hello</li><li>world</li></ul>"); 457 } 458 423 459 #endif // ENABLE(DARK_MODE_CSS) && HAVE(OS_DARK_MODE_SUPPORT) 424 460
Note: See TracChangeset
for help on using the changeset viewer.