Changeset 271350 in webkit
- Timestamp:
- Jan 10, 2021 10:09:09 AM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r271348 r271350 1 2021-01-10 Antti Koivisto <antti@apple.com> 2 3 [LFC][Integration] Factor marked text style collection code out of InlineTextBox 4 https://bugs.webkit.org/show_bug.cgi?id=220249 5 6 Reviewed by Zalan Bujtas. 7 8 * TestExpectations: 9 10 Mark http/wpt/css/css-highlight-api/highlight-text-cascade.html failing. 11 12 This test requires CSS4 highlight pseudo element inheritance (https://bugs.webkit.org/show_bug.cgi?id=220325) 13 which we (or anyone else) don't support. 14 15 It was passing by accident because the code was getting '::highlight' pseudo element style from a wrong element 16 (containing block instead of inline element) in certain cases. Renderer was found via InlineBox parent() which doesn't 17 match render tree parent in case inline culling optimization is active. The correct way is to use render tree parent. 18 1 19 2021-01-09 Zalan Bujtas <zalan@apple.com> 2 20 -
trunk/LayoutTests/TestExpectations
r271293 r271350 4595 4595 webkit.org/b/217931 imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/move-back-iframe-success-external-module.html [ Pass Failure ] 4596 4596 webkit.org/b/217931 imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/move-back-iframe-success-inline-classic.html [ Pass Failure ] 4597 4598 webkit.org/b/220325 http/wpt/css/css-highlight-api/highlight-text-cascade.html [ ImageOnlyFailure ] -
trunk/Source/WebCore/ChangeLog
r271349 r271350 1 2021-01-10 Antti Koivisto <antti@apple.com> 2 3 [LFC][Integration] Factor marked text style collection code out of InlineTextBox 4 https://bugs.webkit.org/show_bug.cgi?id=220249 5 6 Reviewed by Zalan Bujtas. 7 8 This makes it possible to use the code from LFC painting. 9 10 * Sources.txt: 11 * WebCore.xcodeproj/project.pbxproj: 12 * rendering/InlineTextBox.cpp: 13 (WebCore::InlineTextBox::paint): 14 (WebCore::InlineTextBox::MarkedTextStyle::areBackgroundMarkedTextStylesEqual): Deleted. 15 (WebCore::InlineTextBox::MarkedTextStyle::areForegroundMarkedTextStylesEqual): Deleted. 16 (WebCore::InlineTextBox::MarkedTextStyle::areDecorationMarkedTextStylesEqual): Deleted. 17 (WebCore::InlineTextBox::StyledMarkedText::StyledMarkedText): Deleted. 18 (WebCore::InlineTextBox::computeStyleForUnmarkedMarkedText const): Deleted. 19 (WebCore::InlineTextBox::resolveStyleForMarkedText): Deleted. 20 (WebCore::InlineTextBox::subdivideAndResolveStyle): Deleted. 21 (WebCore::InlineTextBox::coalesceAdjacentMarkedTexts): Deleted. 22 * rendering/InlineTextBox.h: 23 * rendering/MarkedTextStyle.cpp: Added. 24 (WebCore::resolveStyleForMarkedText): 25 (WebCore::computeStyleForUnmarkedMarkedText): 26 (WebCore::subdivideAndResolveStyle): 27 (WebCore::coalesceAdjacentMarkedTexts): 28 * rendering/MarkedTextStyle.h: Added. 29 (WebCore::MarkedTextStyle::areBackgroundMarkedTextStylesEqual): 30 (WebCore::MarkedTextStyle::areForegroundMarkedTextStylesEqual): 31 (WebCore::MarkedTextStyle::areDecorationMarkedTextStylesEqual): 32 (WebCore::StyledMarkedText::StyledMarkedText): 33 1 34 2021-01-10 Antti Koivisto <antti@apple.com> 2 35 -
trunk/Source/WebCore/Sources.txt
r271137 r271350 2196 2196 rendering/LayoutRepainter.cpp 2197 2197 rendering/MarkedText.cpp 2198 rendering/MarkedTextStyle.cpp 2198 2199 rendering/OrderIterator.cpp 2199 2200 rendering/PointerEventsHitRules.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r271270 r271350 5091 5091 E43AF8E71AC5B7EC00CA717E /* CacheValidation.h in Headers */ = {isa = PBXBuildFile; fileRef = E43AF8E51AC5B7DD00CA717E /* CacheValidation.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5092 5092 E440AA961C68420800A265CC /* ElementAndTextDescendantIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E440AA951C68420800A265CC /* ElementAndTextDescendantIterator.h */; }; 5093 E440FD5325A4AFDF00F7C849 /* MarkedTextStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = E440FD5125A4AFDF00F7C849 /* MarkedTextStyle.h */; }; 5093 5094 E44613A20CD6331000FADA75 /* HTMLAudioElement.h in Headers */ = {isa = PBXBuildFile; fileRef = E44613900CD6331000FADA75 /* HTMLAudioElement.h */; }; 5094 5095 E44613A50CD6331000FADA75 /* HTMLMediaElement.h in Headers */ = {isa = PBXBuildFile; fileRef = E44613930CD6331000FADA75 /* HTMLMediaElement.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 16233 16234 E43AF8E51AC5B7DD00CA717E /* CacheValidation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CacheValidation.h; sourceTree = "<group>"; }; 16234 16235 E440AA951C68420800A265CC /* ElementAndTextDescendantIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementAndTextDescendantIterator.h; sourceTree = "<group>"; }; 16236 E440FD5125A4AFDF00F7C849 /* MarkedTextStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MarkedTextStyle.h; sourceTree = "<group>"; }; 16237 E440FD5425A4AFEE00F7C849 /* MarkedTextStyle.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MarkedTextStyle.cpp; sourceTree = "<group>"; }; 16235 16238 E4451077202C7E0100657D33 /* CompiledSelector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CompiledSelector.h; sourceTree = "<group>"; }; 16236 16239 E446138F0CD6331000FADA75 /* HTMLAudioElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLAudioElement.cpp; sourceTree = "<group>"; }; … … 29648 29651 CE1866421F72E5B400A0CAB6 /* MarkedText.cpp */, 29649 29652 CE1866431F72E5B400A0CAB6 /* MarkedText.h */, 29653 E440FD5425A4AFEE00F7C849 /* MarkedTextStyle.cpp */, 29654 E440FD5125A4AFDF00F7C849 /* MarkedTextStyle.h */, 29650 29655 CDE7FC42181904B1002BBB77 /* OrderIterator.cpp */, 29651 29656 CDE7FC43181904B1002BBB77 /* OrderIterator.h */, … … 33042 33047 CDF756A3215C29E900EFCB50 /* JSMediaKeyEncryptionScheme.h in Headers */, 33043 33048 2D9BF7281DBFDB0D007A7D99 /* JSMediaKeyMessageEvent.h in Headers */, 33049 E440FD5325A4AFDF00F7C849 /* MarkedTextStyle.h in Headers */, 33044 33050 2D9BF7291DBFDB10007A7D99 /* JSMediaKeys.h in Headers */, 33045 33051 2D9BF72A1DBFDB13007A7D99 /* JSMediaKeySession.h in Headers */, -
trunk/Source/WebCore/rendering/InlineTextBox.cpp
r270585 r271350 41 41 #include "ImageBuffer.h" 42 42 #include "InlineTextBoxStyle.h" 43 #include "MarkedText .h"43 #include "MarkedTextStyle.h" 44 44 #include "Page.h" 45 45 #include "PaintInfo.h" … … 434 434 } 435 435 436 struct InlineTextBox::MarkedTextStyle {437 static bool areBackgroundMarkedTextStylesEqual(const MarkedTextStyle& a, const MarkedTextStyle& b)438 {439 return a.backgroundColor == b.backgroundColor;440 }441 static bool areForegroundMarkedTextStylesEqual(const MarkedTextStyle& a, const MarkedTextStyle& b)442 {443 return a.textStyles == b.textStyles && a.textShadow == b.textShadow && a.alpha == b.alpha;444 }445 static bool areDecorationMarkedTextStylesEqual(const MarkedTextStyle& a, const MarkedTextStyle& b)446 {447 return a.textDecorationStyles == b.textDecorationStyles && a.textShadow == b.textShadow && a.alpha == b.alpha;448 }449 450 Color backgroundColor;451 TextPaintStyle textStyles;452 TextDecorationPainter::Styles textDecorationStyles;453 Optional<ShadowData> textShadow;454 float alpha;455 };456 457 struct InlineTextBox::StyledMarkedText : MarkedText {458 StyledMarkedText(const MarkedText& marker)459 : MarkedText { marker }460 {461 }462 463 MarkedTextStyle style;464 };465 466 436 static MarkedText createMarkedTextFromSelectionInBox(const InlineTextBox& box) 467 437 { … … 545 515 bool useCustomUnderlines = containsComposition && renderer().frame().editor().compositionUsesCustomUnderlines(); 546 516 547 MarkedTextStyle unmarkedStyle = computeStyleForUnmarkedMarkedText(paintInfo);548 549 517 // 1. Paint backgrounds behind text if needed. Examples of such backgrounds include selection 550 518 // and composition underlines. … … 564 532 } 565 533 #endif 566 auto styledMarkedTexts = subdivideAndResolveStyle(markedTexts, unmarkedStyle, paintInfo);534 auto styledMarkedTexts = subdivideAndResolveStyle(markedTexts, renderer(), isFirstLine(), paintInfo); 567 535 568 536 // Coalesce styles of adjacent marked texts to minimize the number of drawing commands. … … 612 580 } 613 581 614 auto styledMarkedTexts = subdivideAndResolveStyle(markedTexts, unmarkedStyle, paintInfo);582 auto styledMarkedTexts = subdivideAndResolveStyle(markedTexts, renderer(), isFirstLine(), paintInfo); 615 583 616 584 // ... now remove the selection marked text if we are excluding selection. … … 795 763 bounds.moveBy(boxOrigin); 796 764 context.drawDotsForDocumentMarker(bounds, lineStyleForMarkedTextType()); 797 }798 799 auto InlineTextBox::computeStyleForUnmarkedMarkedText(const PaintInfo& paintInfo) const -> MarkedTextStyle800 {801 auto& lineStyle = this->lineStyle();802 803 MarkedTextStyle style;804 style.textDecorationStyles = TextDecorationPainter::stylesForRenderer(renderer(), lineStyle.textDecorationsInEffect(), isFirstLine());805 style.textStyles = computeTextPaintStyle(renderer().frame(), lineStyle, paintInfo);806 style.textShadow = ShadowData::clone(paintInfo.forceTextColor() ? nullptr : lineStyle.textShadow());807 style.alpha = 1;808 return style;809 }810 811 auto InlineTextBox::resolveStyleForMarkedText(const MarkedText& markedText, const MarkedTextStyle& baseStyle, const PaintInfo& paintInfo) -> StyledMarkedText812 {813 MarkedTextStyle style = baseStyle;814 switch (markedText.type) {815 case MarkedText::Correction:816 case MarkedText::DictationAlternatives:817 #if PLATFORM(IOS_FAMILY)818 // FIXME: See <rdar://problem/8933352>. Also, remove the PLATFORM(IOS_FAMILY)-guard.819 case MarkedText::DictationPhraseWithAlternatives:820 #endif821 case MarkedText::GrammarError:822 case MarkedText::SpellingError:823 case MarkedText::Unmarked:824 break;825 case MarkedText::Highlight:826 if (auto renderStyle = parent()->renderer().getUncachedPseudoStyle({ PseudoId::Highlight, markedText.highlightName }, &parent()->renderer().style())) {827 style.backgroundColor = renderStyle->backgroundColor();828 style.textStyles.fillColor = renderStyle->computedStrokeColor();829 style.textStyles.strokeColor = renderStyle->computedStrokeColor();830 831 auto color = TextDecorationPainter::decorationColor(*renderStyle.get());832 auto decorationStyle = renderStyle->textDecorationStyle();833 auto decorations = renderStyle->textDecorationsInEffect();834 835 if (decorations.contains(TextDecoration::Underline)) {836 style.textDecorationStyles.underlineColor = color;837 style.textDecorationStyles.underlineStyle = decorationStyle;838 }839 if (decorations.contains(TextDecoration::Overline)) {840 style.textDecorationStyles.overlineColor = color;841 style.textDecorationStyles.overlineStyle = decorationStyle;842 }843 if (decorations.contains(TextDecoration::LineThrough)) {844 style.textDecorationStyles.linethroughColor = color;845 style.textDecorationStyles.linethroughStyle = decorationStyle;846 }847 }848 break;849 #if ENABLE(APP_HIGHLIGHTS)850 case MarkedText::AppHighlight: {851 OptionSet<StyleColor::Options> styleColorOptions = { StyleColor::Options::UseSystemAppearance };852 style.backgroundColor = renderer().theme().appHighlightColor(styleColorOptions);853 break;854 }855 #endif856 case MarkedText::DraggedContent:857 style.alpha = 0.25;858 break;859 case MarkedText::Selection: {860 style.textStyles = computeTextSelectionPaintStyle(style.textStyles, renderer(), lineStyle(), paintInfo, style.textShadow);861 862 Color selectionBackgroundColor = renderer().selectionBackgroundColor();863 style.backgroundColor = selectionBackgroundColor;864 if (selectionBackgroundColor.isValid() && selectionBackgroundColor.isVisible() && style.textStyles.fillColor == selectionBackgroundColor)865 style.backgroundColor = selectionBackgroundColor.invertedColorWithAlpha(1.0);866 break;867 }868 case MarkedText::TextMatch: {869 // Text matches always use the light system appearance.870 OptionSet<StyleColor::Options> styleColorOptions = { StyleColor::Options::UseSystemAppearance };871 #if PLATFORM(MAC)872 style.textStyles.fillColor = renderer().theme().systemColor(CSSValueAppleSystemLabel, styleColorOptions);873 #endif874 style.backgroundColor = renderer().theme().textSearchHighlightColor(styleColorOptions);875 break;876 }877 }878 StyledMarkedText styledMarkedText = markedText;879 styledMarkedText.style = WTFMove(style);880 return styledMarkedText;881 }882 883 auto InlineTextBox::subdivideAndResolveStyle(const Vector<MarkedText>& textsToSubdivide, const MarkedTextStyle& baseStyle, const PaintInfo& paintInfo) -> Vector<StyledMarkedText>884 {885 if (textsToSubdivide.isEmpty())886 return { };887 888 auto markedTexts = subdivide(textsToSubdivide);889 ASSERT(!markedTexts.isEmpty());890 if (UNLIKELY(markedTexts.isEmpty()))891 return { };892 893 // Compute frontmost overlapping styled marked texts.894 Vector<StyledMarkedText> frontmostMarkedTexts;895 frontmostMarkedTexts.reserveInitialCapacity(markedTexts.size());896 frontmostMarkedTexts.uncheckedAppend(resolveStyleForMarkedText(markedTexts[0], baseStyle, paintInfo));897 for (auto it = markedTexts.begin() + 1, end = markedTexts.end(); it != end; ++it) {898 StyledMarkedText& previousStyledMarkedText = frontmostMarkedTexts.last();899 if (previousStyledMarkedText.startOffset == it->startOffset && previousStyledMarkedText.endOffset == it->endOffset) {900 // Marked texts completely cover each other.901 previousStyledMarkedText = resolveStyleForMarkedText(*it, previousStyledMarkedText.style, paintInfo);902 continue;903 }904 frontmostMarkedTexts.uncheckedAppend(resolveStyleForMarkedText(*it, baseStyle, paintInfo));905 }906 907 return frontmostMarkedTexts;908 }909 910 auto InlineTextBox::coalesceAdjacentMarkedTexts(const Vector<StyledMarkedText>& textsToCoalesce, MarkedTextStylesEqualityFunction areMarkedTextStylesEqual) -> Vector<StyledMarkedText>911 {912 if (textsToCoalesce.isEmpty())913 return { };914 915 auto areAdjacentMarkedTextsWithSameStyle = [&] (const StyledMarkedText& a, const StyledMarkedText& b) {916 return a.endOffset == b.startOffset && areMarkedTextStylesEqual(a.style, b.style);917 };918 919 Vector<StyledMarkedText> styledMarkedTexts;920 styledMarkedTexts.reserveInitialCapacity(textsToCoalesce.size());921 styledMarkedTexts.uncheckedAppend(textsToCoalesce[0]);922 for (auto it = textsToCoalesce.begin() + 1, end = textsToCoalesce.end(); it != end; ++it) {923 StyledMarkedText& previousStyledMarkedText = styledMarkedTexts.last();924 if (areAdjacentMarkedTextsWithSameStyle(previousStyledMarkedText, *it)) {925 previousStyledMarkedText.endOffset = it->endOffset;926 continue;927 }928 styledMarkedTexts.uncheckedAppend(*it);929 }930 931 return styledMarkedTexts;932 765 } 933 766 -
trunk/Source/WebCore/rendering/InlineTextBox.h
r269726 r271350 34 34 struct CompositionUnderline; 35 35 struct MarkedText; 36 struct StyledMarkedText; 36 37 struct TextPaintStyle; 37 38 … … 165 166 166 167 private: 167 struct MarkedTextStyle;168 struct StyledMarkedText;169 170 168 enum class TextPaintPhase { Background, Foreground, Decoration }; 171 169 … … 173 171 Vector<MarkedText> collectMarkedTextsForDocumentMarkers(TextPaintPhase) const; 174 172 Vector<MarkedText> collectMarkedTextsForHighlights(TextPaintPhase) const; 175 176 MarkedTextStyle computeStyleForUnmarkedMarkedText(const PaintInfo&) const;177 StyledMarkedText resolveStyleForMarkedText(const MarkedText&, const MarkedTextStyle& baseStyle, const PaintInfo&);178 Vector<StyledMarkedText> subdivideAndResolveStyle(const Vector<MarkedText>&, const MarkedTextStyle& baseStyle, const PaintInfo&);179 180 using MarkedTextStylesEqualityFunction = bool (*)(const MarkedTextStyle&, const MarkedTextStyle&);181 Vector<StyledMarkedText> coalesceAdjacentMarkedTexts(const Vector<StyledMarkedText>&, MarkedTextStylesEqualityFunction);182 173 183 174 FloatPoint textOriginFromBoxRect(const FloatRect&) const;
Note: See TracChangeset
for help on using the changeset viewer.