WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
patch for EWS (including patch from bug 243632)
Patch.txt (text/plain), 30.43 KB, created by
alan
on 2022-08-06 18:42:11 PDT
(
hide
)
Description:
patch for EWS (including patch from bug 243632)
Filename:
MIME Type:
Creator:
alan
Created:
2022-08-06 18:42:11 PDT
Size:
30.43 KB
patch
obsolete
>diff --git a/LayoutTests/fast/css/text-decoration-in-second-order-descendants-expected.html b/LayoutTests/fast/css/text-decoration-in-second-order-descendants-expected.html >index 0e2f17d53332..b82b1aef93c9 100644 >--- a/LayoutTests/fast/css/text-decoration-in-second-order-descendants-expected.html >+++ b/LayoutTests/fast/css/text-decoration-in-second-order-descendants-expected.html >@@ -4,4 +4,4 @@ > <p> > <a href="www.example.com" style="text-decoration: none;">As the child of an absolutely positioned block, this link should not be underlined</a> > </div> >-<a href="www.example.com">As the child of a statically positioned block, this link should be underlined</a> >+<a href="www.example.com" style="text-decoration-color: black">As the child of a statically positioned block, this link should be underlined</a> >diff --git a/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm b/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm >index 6fb35a79273c..307c9d83419f 100644 >--- a/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm >+++ b/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm >@@ -843,12 +843,12 @@ static void AXAttributeStringSetStyle(NSMutableAttributedString* attrString, Ren > > if (decor & TextDecorationLine::Underline) { > AXAttributeStringSetNumber(attrString, NSAccessibilityUnderlineTextAttribute, @YES, range); >- AXAttributeStringSetColor(attrString, NSAccessibilityUnderlineColorTextAttribute, cocoaColor(decorationStyles.underlineColor).get(), range); >+ AXAttributeStringSetColor(attrString, NSAccessibilityUnderlineColorTextAttribute, cocoaColor(decorationStyles.underline.color).get(), range); > } > > if (decor & TextDecorationLine::LineThrough) { > AXAttributeStringSetNumber(attrString, NSAccessibilityStrikethroughTextAttribute, @YES, range); >- AXAttributeStringSetColor(attrString, NSAccessibilityStrikethroughColorTextAttribute, cocoaColor(decorationStyles.linethroughColor).get(), range); >+ AXAttributeStringSetColor(attrString, NSAccessibilityStrikethroughColorTextAttribute, cocoaColor(decorationStyles.linethrough.color).get(), range); > } > } > >diff --git a/Source/WebCore/rendering/StyledMarkedText.cpp b/Source/WebCore/rendering/StyledMarkedText.cpp >index 4ffe67216543..f5699d8addce 100644 >--- a/Source/WebCore/rendering/StyledMarkedText.cpp >+++ b/Source/WebCore/rendering/StyledMarkedText.cpp >@@ -58,16 +58,16 @@ static StyledMarkedText resolveStyleForMarkedText(const MarkedText& markedText, > auto decorations = renderStyle->textDecorationsInEffect(); > > if (decorations.contains(TextDecorationLine::Underline)) { >- style.textDecorationStyles.underlineColor = color; >- style.textDecorationStyles.underlineStyle = decorationStyle; >+ style.textDecorationStyles.underline.color = color; >+ style.textDecorationStyles.underline.decorationStyle = decorationStyle; > } > if (decorations.contains(TextDecorationLine::Overline)) { >- style.textDecorationStyles.overlineColor = color; >- style.textDecorationStyles.overlineStyle = decorationStyle; >+ style.textDecorationStyles.overline.color = color; >+ style.textDecorationStyles.overline.decorationStyle = decorationStyle; > } > if (decorations.contains(TextDecorationLine::LineThrough)) { >- style.textDecorationStyles.linethroughColor = color; >- style.textDecorationStyles.linethroughStyle = decorationStyle; >+ style.textDecorationStyles.linethrough.color = color; >+ style.textDecorationStyles.linethrough.decorationStyle = decorationStyle; > } > } > break; >diff --git a/Source/WebCore/rendering/TextBoxPainter.cpp b/Source/WebCore/rendering/TextBoxPainter.cpp >index d74e7a958105..a34dcece8d03 100644 >--- a/Source/WebCore/rendering/TextBoxPainter.cpp >+++ b/Source/WebCore/rendering/TextBoxPainter.cpp >@@ -433,11 +433,9 @@ TextDecorationPainter TextBoxPainter<TextBoxPath>::createDecorationPainter(const > } > > // Create painter >- auto textDecorations = m_style.textDecorationsInEffect(); >- textDecorations.add(TextDecorationPainter::textDecorationsInEffectForStyle(markedText.style.textDecorationStyles)); > auto* shadow = markedText.style.textShadow ? &markedText.style.textShadow.value() : nullptr; > auto* colorFilter = markedText.style.textShadow && m_style.hasAppleColorFilter() ? &m_style.appleColorFilter() : nullptr; >- return { context, textDecorations, m_isFirstLine, fontCascade(), makeIterator(), snappedSelectionRect.width(), shadow, colorFilter, markedText.style.textDecorationStyles }; >+ return { context, fontCascade(), makeIterator(), snappedSelectionRect.width(), shadow, colorFilter, markedText.style.textDecorationStyles }; > } > > template<typename TextBoxPath> >diff --git a/Source/WebCore/rendering/TextDecorationPainter.cpp b/Source/WebCore/rendering/TextDecorationPainter.cpp >index d64f533fbfd6..94f279101d56 100644 >--- a/Source/WebCore/rendering/TextDecorationPainter.cpp >+++ b/Source/WebCore/rendering/TextDecorationPainter.cpp >@@ -185,15 +185,26 @@ static StrokeStyle textDecorationStyleToStrokeStyle(TextDecorationStyle decorati > return strokeStyle; > } > >+static inline OptionSet<TextDecorationLine> textDecorationsInEffectForStyle(const TextDecorationPainter::Styles& style) >+{ >+ OptionSet<TextDecorationLine> decorations; >+ if (style.underline.color.isValid()) >+ decorations.add(TextDecorationLine::Underline); >+ if (style.overline.color.isValid()) >+ decorations.add(TextDecorationLine::Overline); >+ if (style.linethrough.color.isValid()) >+ decorations.add(TextDecorationLine::LineThrough); >+ return decorations; >+} >+ > bool TextDecorationPainter::Styles::operator==(const Styles& other) const > { >- return underlineColor == other.underlineColor && overlineColor == other.overlineColor && linethroughColor == other.linethroughColor >- && underlineStyle == other.underlineStyle && overlineStyle == other.overlineStyle && linethroughStyle == other.linethroughStyle; >+ return underline.color == other.underline.color && overline.color == other.overline.color && linethrough.color == other.linethrough.color >+ && underline.decorationStyle == other.underline.decorationStyle && overline.decorationStyle == other.overline.decorationStyle && linethrough.decorationStyle == other.linethrough.decorationStyle; > } > >-TextDecorationPainter::TextDecorationPainter(GraphicsContext& context, OptionSet<TextDecorationLine> decorations, bool isFirstLine, const FontCascade& font, InlineIterator::TextBoxIterator textBox, float width, const ShadowData* shadow, const FilterOperations* colorFilter, std::optional<Styles> styles) >+TextDecorationPainter::TextDecorationPainter(GraphicsContext& context, const FontCascade& font, InlineIterator::TextBoxIterator textBox, float width, const ShadowData* shadow, const FilterOperations* colorFilter, Styles styleOverride) > : m_context { context } >- , m_decorations { decorations } > , m_wavyOffset { wavyOffsetFromDecoration() } > , m_width(width) > , m_isPrinting { textBox->renderer().document().printing() } >@@ -203,16 +214,18 @@ TextDecorationPainter::TextDecorationPainter(GraphicsContext& context, OptionSet > , m_textBox(textBox) > , m_font { font } > , m_deviceScaleFactor(textBox->renderer().document().deviceScaleFactor()) >- , m_styles { styles ? *WTFMove(styles) : stylesForRenderer(textBox->renderer(), decorations, isFirstLine, PseudoId::None) } >- , m_lineStyle { isFirstLine ? textBox->renderer().firstLineStyle() : textBox->renderer().style() } >+ , m_styles { styleOverride } >+ , m_textBoxStyle { textBox->lineBox()->isFirst() ? textBox->renderer().firstLineStyle() : textBox->renderer().style() } > { >+ m_textBoxDecorations = m_textBoxStyle.textDecorationsInEffect(); >+ m_textBoxDecorations.add(textDecorationsInEffectForStyle(styleOverride)); > } > > // Paint text-shadow, underline, overline > void TextDecorationPainter::paintBackgroundDecorations(const TextRun& textRun, const FloatPoint& textOrigin, const FloatPoint& boxOrigin) > { >- const auto& fontMetrics = m_lineStyle.metricsOfPrimaryFont(); >- auto textDecorationThickness = ceilToDevicePixel(m_lineStyle.textDecorationThickness().resolve(m_lineStyle.computedFontSize(), fontMetrics), m_deviceScaleFactor); >+ const auto& fontMetrics = m_textBoxStyle.metricsOfPrimaryFont(); >+ auto textDecorationThickness = ceilToDevicePixel(m_textBoxStyle.textDecorationThickness().resolve(m_textBoxStyle.computedFontSize(), fontMetrics), m_deviceScaleFactor); > FloatPoint localOrigin = boxOrigin; > > auto paintDecoration = [&] (TextDecorationLine decoration, TextDecorationStyle style, const Color& color, const FloatRect& rect) { >@@ -221,9 +234,9 @@ void TextDecorationPainter::paintBackgroundDecorations(const TextRun& textRun, c > auto strokeStyle = textDecorationStyleToStrokeStyle(style); > > if (style == TextDecorationStyle::Wavy) >- strokeWavyTextDecoration(m_context, rect, m_lineStyle.computedFontPixelSize()); >+ strokeWavyTextDecoration(m_context, rect, m_textBoxStyle.computedFontPixelSize()); > else if (decoration == TextDecorationLine::Underline || decoration == TextDecorationLine::Overline) { >- if ((m_lineStyle.textDecorationSkipInk() == TextDecorationSkipInk::Auto || m_lineStyle.textDecorationSkipInk() == TextDecorationSkipInk::All) && m_isHorizontal) { >+ if ((m_textBoxStyle.textDecorationSkipInk() == TextDecorationSkipInk::Auto || m_textBoxStyle.textDecorationSkipInk() == TextDecorationSkipInk::All) && m_isHorizontal) { > if (!m_context.paintingDisabled()) { > FloatRect underlineBoundingBox = m_context.computeUnderlineBoundsForText(rect, m_isPrinting); > DashArray intersections = m_font.dashesForIntersectionsWithRect(textRun, textOrigin, underlineBoundingBox); >@@ -240,9 +253,9 @@ void TextDecorationPainter::paintBackgroundDecorations(const TextRun& textRun, c > ASSERT_NOT_REACHED(); > }; > >- bool areLinesOpaque = !m_isPrinting && (!m_decorations.contains(TextDecorationLine::Underline) || m_styles.underlineColor.isOpaque()) >- && (!m_decorations.contains(TextDecorationLine::Overline) || m_styles.overlineColor.isOpaque()) >- && (!m_decorations.contains(TextDecorationLine::LineThrough) || m_styles.linethroughColor.isOpaque()); >+ bool areLinesOpaque = !m_isPrinting && (!m_textBoxDecorations.contains(TextDecorationLine::Underline) || m_styles.underline.color.isOpaque()) >+ && (!m_textBoxDecorations.contains(TextDecorationLine::Overline) || m_styles.overline.color.isOpaque()) >+ && (!m_textBoxDecorations.contains(TextDecorationLine::LineThrough) || m_styles.linethrough.color.isOpaque()); > > float extraOffset = 0; > bool clipping = !areLinesOpaque && m_shadow && m_shadow->next(); >@@ -283,24 +296,32 @@ void TextDecorationPainter::paintBackgroundDecorations(const TextRun& textRun, c > } > > // These decorations should match the visual overflows computed in visualOverflowForDecorations(). >- if (m_decorations.contains(TextDecorationLine::Underline)) { >- auto offset = underlineOffsetForTextBoxPainting(m_lineStyle, m_textBox); >- float wavyOffset = m_styles.underlineStyle == TextDecorationStyle::Wavy ? m_wavyOffset : 0; >- FloatRect rect(localOrigin, FloatSize(m_width, textDecorationThickness)); >- rect.move(0, offset + wavyOffset); >- paintDecoration(TextDecorationLine::Underline, m_styles.underlineStyle, m_styles.underlineColor, rect); >+ if (m_textBoxDecorations.contains(TextDecorationLine::Underline)) { >+ auto offsetAndDecoratingBox = underlineOffsetAndDecoratingBoxForTextBoxPainting(m_textBoxStyle, m_textBox); >+ auto styleToUse = [&] { >+ if (&offsetAndDecoratingBox.decoratingBox == m_textBox->renderer().parent()) >+ return m_styles.underline; >+ // FIXME: make thickness part of the decoration style. >+ auto isFirstLine = m_textBox->lineBox()->isFirst(); >+ auto& decoratingBoxStyle = isFirstLine ? offsetAndDecoratingBox.decoratingBox.firstLineStyle() : offsetAndDecoratingBox.decoratingBox.style(); >+ return stylesForRenderer(offsetAndDecoratingBox.decoratingBox, decoratingBoxStyle.textDecorationsInEffect(), isFirstLine).underline; >+ }(); >+ auto wavyOffset = styleToUse.decorationStyle == TextDecorationStyle::Wavy ? m_wavyOffset : 0.f; >+ auto underlineRect = FloatRect { localOrigin, FloatSize(m_width, textDecorationThickness) }; >+ underlineRect.move(0.f, offsetAndDecoratingBox.underlineOffset + wavyOffset); >+ paintDecoration(TextDecorationLine::Underline, styleToUse.decorationStyle, styleToUse.color, underlineRect); > } >- if (m_decorations.contains(TextDecorationLine::Overline)) { >- float wavyOffset = m_styles.overlineStyle == TextDecorationStyle::Wavy ? m_wavyOffset : 0; >+ if (m_textBoxDecorations.contains(TextDecorationLine::Overline)) { >+ float wavyOffset = m_styles.overline.decorationStyle == TextDecorationStyle::Wavy ? m_wavyOffset : 0; > FloatRect rect(localOrigin, FloatSize(m_width, textDecorationThickness)); >- float autoTextDecorationThickness = ceilToDevicePixel(TextDecorationThickness::createWithAuto().resolve(m_lineStyle.computedFontSize(), fontMetrics), m_deviceScaleFactor); >+ float autoTextDecorationThickness = ceilToDevicePixel(TextDecorationThickness::createWithAuto().resolve(m_textBoxStyle.computedFontSize(), fontMetrics), m_deviceScaleFactor); > rect.move(0, autoTextDecorationThickness - textDecorationThickness - wavyOffset); >- paintDecoration(TextDecorationLine::Overline, m_styles.overlineStyle, m_styles.overlineColor, rect); >+ paintDecoration(TextDecorationLine::Overline, m_styles.overline.decorationStyle, m_styles.overline.color, rect); > } > > // We only want to paint the shadow, hence the transparent color, not the actual line-through, > // which will be painted in paintForegroundDecorations(). >- if (shadow && m_decorations.contains(TextDecorationLine::LineThrough)) >+ if (shadow && m_textBoxDecorations.contains(TextDecorationLine::LineThrough)) > paintLineThrough(Color::transparentBlack, textDecorationThickness, localOrigin); > } while (shadow); > >@@ -312,28 +333,28 @@ void TextDecorationPainter::paintBackgroundDecorations(const TextRun& textRun, c > > void TextDecorationPainter::paintForegroundDecorations(const FloatPoint& boxOrigin) > { >- if (!m_decorations.contains(TextDecorationLine::LineThrough)) >+ if (!m_textBoxDecorations.contains(TextDecorationLine::LineThrough)) > return; > >- auto textDecorationThickness = ceilToDevicePixel(m_lineStyle.textDecorationThickness().resolve(m_lineStyle.computedFontSize(), m_lineStyle.metricsOfPrimaryFont()), m_deviceScaleFactor); >- paintLineThrough(m_styles.linethroughColor, textDecorationThickness, boxOrigin); >+ auto textDecorationThickness = ceilToDevicePixel(m_textBoxStyle.textDecorationThickness().resolve(m_textBoxStyle.computedFontSize(), m_textBoxStyle.metricsOfPrimaryFont()), m_deviceScaleFactor); >+ paintLineThrough(m_styles.linethrough.color, textDecorationThickness, boxOrigin); > } > > void TextDecorationPainter::paintLineThrough(const Color& color, float thickness, const FloatPoint& localOrigin) > { >- const auto& fontMetrics = m_lineStyle.metricsOfPrimaryFont(); >+ const auto& fontMetrics = m_textBoxStyle.metricsOfPrimaryFont(); > FloatRect rect(localOrigin, FloatSize(m_width, thickness)); >- auto autoTextDecorationThickness = ceilToDevicePixel(TextDecorationThickness::createWithAuto().resolve(m_lineStyle.computedFontSize(), fontMetrics), m_deviceScaleFactor); >+ auto autoTextDecorationThickness = ceilToDevicePixel(TextDecorationThickness::createWithAuto().resolve(m_textBoxStyle.computedFontSize(), fontMetrics), m_deviceScaleFactor); > auto center = 2 * fontMetrics.floatAscent() / 3 + autoTextDecorationThickness / 2; > rect.move(0, center - thickness / 2); > > m_context.setStrokeColor(color); > >- TextDecorationStyle style = m_styles.linethroughStyle; >+ TextDecorationStyle style = m_styles.linethrough.decorationStyle; > auto strokeStyle = textDecorationStyleToStrokeStyle(style); > > if (style == TextDecorationStyle::Wavy) >- strokeWavyTextDecoration(m_context, rect, m_lineStyle.computedFontPixelSize()); >+ strokeWavyTextDecoration(m_context, rect, m_textBoxStyle.computedFontPixelSize()); > else > m_context.drawLineForText(rect, m_isPrinting, style == TextDecorationStyle::Double, strokeStyle); > } >@@ -349,18 +370,18 @@ static void collectStylesForRenderer(TextDecorationPainter::Styles& result, cons > > if (decorations.contains(TextDecorationLine::Underline)) { > remainingDecorations.remove(TextDecorationLine::Underline); >- result.underlineColor = color; >- result.underlineStyle = decorationStyle; >+ result.underline.color = color; >+ result.underline.decorationStyle = decorationStyle; > } > if (decorations.contains(TextDecorationLine::Overline)) { > remainingDecorations.remove(TextDecorationLine::Overline); >- result.overlineColor = color; >- result.overlineStyle = decorationStyle; >+ result.overline.color = color; >+ result.overline.decorationStyle = decorationStyle; > } > if (decorations.contains(TextDecorationLine::LineThrough)) { > remainingDecorations.remove(TextDecorationLine::LineThrough); >- result.linethroughColor = color; >- result.linethroughStyle = decorationStyle; >+ result.linethrough.color = color; >+ result.linethrough.decorationStyle = decorationStyle; > } > }; > >@@ -400,18 +421,6 @@ Color TextDecorationPainter::decorationColor(const RenderStyle& style) > return style.visitedDependentColorWithColorFilter(CSSPropertyTextDecorationColor); > } > >-OptionSet<TextDecorationLine> TextDecorationPainter::textDecorationsInEffectForStyle(const TextDecorationPainter::Styles& style) >-{ >- OptionSet<TextDecorationLine> decorations; >- if (style.underlineColor.isValid()) >- decorations.add(TextDecorationLine::Underline); >- if (style.overlineColor.isValid()) >- decorations.add(TextDecorationLine::Overline); >- if (style.linethroughColor.isValid()) >- decorations.add(TextDecorationLine::LineThrough); >- return decorations; >-}; >- > auto TextDecorationPainter::stylesForRenderer(const RenderObject& renderer, OptionSet<TextDecorationLine> requestedDecorations, bool firstLineStyle, PseudoId pseudoId) -> Styles > { > if (requestedDecorations.isEmpty()) >diff --git a/Source/WebCore/rendering/TextDecorationPainter.h b/Source/WebCore/rendering/TextDecorationPainter.h >index 4da2e46381a5..ff73cf86f529 100644 >--- a/Source/WebCore/rendering/TextDecorationPainter.h >+++ b/Source/WebCore/rendering/TextDecorationPainter.h >@@ -44,7 +44,7 @@ class TextRun; > class TextDecorationPainter { > public: > struct Styles; >- TextDecorationPainter(GraphicsContext&, OptionSet<TextDecorationLine> decorations, bool isFirstLine, const FontCascade&, InlineIterator::TextBoxIterator, float width, const ShadowData*, const FilterOperations*, std::optional<Styles> = std::nullopt); >+ TextDecorationPainter(GraphicsContext&, const FontCascade&, InlineIterator::TextBoxIterator, float width, const ShadowData*, const FilterOperations*, Styles); > > void paintBackgroundDecorations(const TextRun&, const FloatPoint& textOrigin, const FloatPoint& boxOrigin); > void paintForegroundDecorations(const FloatPoint& boxOrigin); >@@ -53,22 +53,22 @@ public: > bool operator==(const Styles&) const; > bool operator!=(const Styles& other) const { return !(*this == other); } > >- Color underlineColor; >- Color overlineColor; >- Color linethroughColor; >- TextDecorationStyle underlineStyle; >- TextDecorationStyle overlineStyle; >- TextDecorationStyle linethroughStyle; >+ struct DecorationStyleAndColor { >+ Color color; >+ TextDecorationStyle decorationStyle; >+ }; >+ DecorationStyleAndColor underline; >+ DecorationStyleAndColor overline; >+ DecorationStyleAndColor linethrough; > }; > static Color decorationColor(const RenderStyle&); >- static OptionSet<TextDecorationLine> textDecorationsInEffectForStyle(const Styles&); > static Styles stylesForRenderer(const RenderObject&, OptionSet<TextDecorationLine> requestedDecorations, bool firstLineStyle = false, PseudoId = PseudoId::None); > > private: > void paintLineThrough(const Color&, float thickness, const FloatPoint& localOrigin); > > GraphicsContext& m_context; >- OptionSet<TextDecorationLine> m_decorations; >+ OptionSet<TextDecorationLine> m_textBoxDecorations; > float m_wavyOffset { 0 }; > float m_width { 0 }; > FloatPoint m_boxOrigin; >@@ -81,7 +81,7 @@ private: > float m_deviceScaleFactor { 0 }; > > Styles m_styles; >- const RenderStyle& m_lineStyle; >+ const RenderStyle& m_textBoxStyle; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/style/InlineTextBoxStyle.cpp b/Source/WebCore/style/InlineTextBoxStyle.cpp >index 0f9764f14247..ef4fbd128a0a 100644 >--- a/Source/WebCore/style/InlineTextBoxStyle.cpp >+++ b/Source/WebCore/style/InlineTextBoxStyle.cpp >@@ -55,7 +55,7 @@ static bool isAncestorAndWithinBlock(const RenderInline& ancestor, const RenderO > return false; > } > >-static float minLogicalTopForTextDecorationLine(const InlineIterator::LineBoxIterator& lineBox, float textRunLogicalTop, const RenderElement* decorationRenderer) >+static float minLogicalTopForTextDecorationLine(const InlineIterator::LineBoxIterator& lineBox, float textRunLogicalTop, const RenderElement& decoratingBoxRenderer) > { > auto minLogicalTop = textRunLogicalTop; > for (auto run = lineBox->firstLeafBox(); run; run.traverseNextOnLine()) { >@@ -63,9 +63,9 @@ static float minLogicalTopForTextDecorationLine(const InlineIterator::LineBoxIte > continue; // Positioned placeholders don't affect calculations. > > if (!run->style().textDecorationsInEffect().contains(TextDecorationLine::Underline)) >- continue; // If the text decoration isn't in effect on the child, then it must be outside of |decorationRenderer|'s hierarchy. >+ continue; // If the text decoration isn't in effect on the child, then it must be outside of |decoratingBoxRenderer|'s hierarchy. > >- if (decorationRenderer && decorationRenderer->isRenderInline() && !isAncestorAndWithinBlock(downcast<RenderInline>(*decorationRenderer), &run->renderer())) >+ if (decoratingBoxRenderer.isRenderInline() && !isAncestorAndWithinBlock(downcast<RenderInline>(decoratingBoxRenderer), &run->renderer())) > continue; > > if (run->isText() || run->style().textDecorationSkipInk() == TextDecorationSkipInk::None) >@@ -74,7 +74,7 @@ static float minLogicalTopForTextDecorationLine(const InlineIterator::LineBoxIte > return minLogicalTop; > } > >-static float maxLogicalBottomForTextDecorationLine(const InlineIterator::LineBoxIterator& lineBox, float textRunLogicalBottom, const RenderElement* decorationRenderer) >+static float maxLogicalBottomForTextDecorationLine(const InlineIterator::LineBoxIterator& lineBox, float textRunLogicalBottom, const RenderElement& decoratingBoxRenderer) > { > auto maxLogicalBottom = textRunLogicalBottom; > for (auto run = lineBox->firstLeafBox(); run; run.traverseNextOnLine()) { >@@ -82,9 +82,9 @@ static float maxLogicalBottomForTextDecorationLine(const InlineIterator::LineBox > continue; // Positioned placeholders don't affect calculations. > > if (!run->style().textDecorationsInEffect().contains(TextDecorationLine::Underline)) >- continue; // If the text decoration isn't in effect on the child, then it must be outside of |decorationRenderer|'s hierarchy. >+ continue; // If the text decoration isn't in effect on the child, then it must be outside of |decoratingBoxRenderer|'s hierarchy. > >- if (decorationRenderer && decorationRenderer->isRenderInline() && !isAncestorAndWithinBlock(downcast<RenderInline>(*decorationRenderer), &run->renderer())) >+ if (decoratingBoxRenderer.isRenderInline() && !isAncestorAndWithinBlock(downcast<RenderInline>(decoratingBoxRenderer), &run->renderer())) > continue; > > if (run->isText() || run->style().textDecorationSkipInk() == TextDecorationSkipInk::None) >@@ -111,18 +111,19 @@ static const RenderElement* enclosingRendererWithTextDecoration(const RenderText > return current; > } > >+static float textRunOffsetFromBottomMostWithinDecoratingBox(const InlineIterator::LineBoxIterator& lineBox, const RenderElement& decoratingBoxRenderer, bool isFlippedLinesWritingMode, float textBoxLogicalTop, float textBoxLogicalBottom) >+{ >+ if (isFlippedLinesWritingMode) >+ return textBoxLogicalTop - minLogicalTopForTextDecorationLine(lineBox, textBoxLogicalTop, decoratingBoxRenderer); >+ return maxLogicalBottomForTextDecorationLine(lineBox, textBoxLogicalBottom, decoratingBoxRenderer) - textBoxLogicalBottom; >+} >+ > static float textRunOffsetFromBottomMost(const InlineIterator::LineBoxIterator& lineBox, const RenderText& renderer, float textBoxLogicalTop, float textBoxLogicalBottom) > { >- float offset = 0.f; >- auto* decorationRenderer = enclosingRendererWithTextDecoration(renderer, lineBox->isFirst()); >- if (renderer.style().isFlippedLinesWritingMode()) { >- auto minLogicalTop = minLogicalTopForTextDecorationLine(lineBox, textBoxLogicalTop, decorationRenderer); >- offset = textBoxLogicalTop - minLogicalTop; >- } else { >- offset = maxLogicalBottomForTextDecorationLine(lineBox, textBoxLogicalBottom, decorationRenderer); >- offset -= textBoxLogicalBottom; >- } >- return offset; >+ auto* decoratingBoxRenderer = enclosingRendererWithTextDecoration(renderer, lineBox->isFirst()); >+ if (!decoratingBoxRenderer) >+ return 0.f; >+ return textRunOffsetFromBottomMostWithinDecoratingBox(lineBox, *decoratingBoxRenderer, decoratingBoxRenderer->style().isFlippedLinesWritingMode(), textBoxLogicalTop, textBoxLogicalBottom); > } > > static inline float defaultGap(const RenderStyle& style) >@@ -290,18 +291,31 @@ GlyphOverflow visualOverflowForDecorations(const RenderStyle& style) > return computedVisualOverflowForDecorations(style, underlineOffset); > } > >-float underlineOffsetForTextBoxPainting(const RenderStyle& style, const InlineIterator::TextBoxIterator& textBox) >+UnderlineOffsetAndDecoratingBox underlineOffsetAndDecoratingBoxForTextBoxPainting(const RenderStyle& style, const InlineIterator::TextBoxIterator& textBox) > { >+ // 1. Find the decorating box for this text run (for root inline box content, it's the containing block, for text inside an inline box, it's mostly the parent inline box itself) >+ // 2. compute the underline offset. >+ auto& textBoxRenderer = textBox->renderer(); > auto lineBox = textBox->lineBox(); >+ auto isFirstLine = lineBox->isFirst(); >+ auto* decoratingBoxRenderer = enclosingRendererWithTextDecoration(textBoxRenderer, isFirstLine); >+ if (!decoratingBoxRenderer) { >+ ASSERT_NOT_REACHED(); >+ return { 0.f, *textBoxRenderer.parent() }; >+ } >+ > auto textUnderlinePositionUnder = std::optional<TextUnderlinePositionUnder> { }; > auto underlinePositionValue = resolvedUnderlinePosition(style, lineBox->baselineType()); > > if (underlinePositionValue == TextUnderlinePosition::Under) { >- auto textRunOffset = textRunOffsetFromBottomMost(lineBox, textBox->renderer(), textBox->logicalTop(), textBox->logicalBottom()); >+ auto textRunOffset = textRunOffsetFromBottomMost(lineBox, textBoxRenderer, textBox->logicalTop(), textBox->logicalBottom()); > textUnderlinePositionUnder = TextUnderlinePositionUnder { textBox->logicalBottom() - textBox->logicalTop(), textRunOffset }; > } > >- return computedUnderlineOffset({ style, underlinePositionValue, defaultGap(style), textUnderlinePositionUnder }); >+ return { >+ computedUnderlineOffset({ style, underlinePositionValue, defaultGap(style), textUnderlinePositionUnder }), >+ *decoratingBoxRenderer >+ }; > } > > } >diff --git a/Source/WebCore/style/InlineTextBoxStyle.h b/Source/WebCore/style/InlineTextBoxStyle.h >index 3843209d626b..ed889df5b253 100644 >--- a/Source/WebCore/style/InlineTextBoxStyle.h >+++ b/Source/WebCore/style/InlineTextBoxStyle.h >@@ -33,37 +33,42 @@ > namespace WebCore { > > class LegacyInlineTextBox; >+class RenderElement; > class RenderStyle; > class TextUnderlineOffset; > > inline float wavyOffsetFromDecoration() > { >- return 1; >+ return 1.f; > } > > struct WavyStrokeParameters { > // Distance between decoration's axis and Bezier curve's control points. > // The height of the curve is based on this distance. Increases the curve's height > // as fontSize increases to make the curve look better. >- float controlPointDistance { 0 }; >+ float controlPointDistance { 0.f }; > > // Increment used to form the diamond shape between start point (p1), control > // points and end point (p2) along the axis of the decoration. The curve gets > // wider as font size increases. >- float step { 0 }; >+ float step { 0.f }; > }; > WavyStrokeParameters getWavyStrokeParameters(float fontSize); > > struct TextUnderlinePositionUnder { >- float textRunLogicalHeight { 0 }; >+ float textRunLogicalHeight { 0.f }; > // This offset value is the distance between the current text run's logical bottom and the lowest position of all the text runs > // on line that belong to the same decoration box. >- float textRunOffsetFromBottomMost { 0 }; >+ float textRunOffsetFromBottomMost { 0.f }; > }; > GlyphOverflow visualOverflowForDecorations(const RenderStyle&); > GlyphOverflow visualOverflowForDecorations(const RenderStyle&, FontBaseline, TextUnderlinePositionUnder); > GlyphOverflow visualOverflowForDecorations(const InlineIterator::LineBoxIterator&, const RenderText&, float textBoxLogicalTop, float textBoxLogicalBottom); > >-float underlineOffsetForTextBoxPainting(const RenderStyle&, const InlineIterator::TextBoxIterator&); >+struct UnderlineOffsetAndDecoratingBox { >+ float underlineOffset { 0.f }; >+ const RenderElement& decoratingBox; >+}; >+UnderlineOffsetAndDecoratingBox underlineOffsetAndDecoratingBoxForTextBoxPainting(const RenderStyle&, const InlineIterator::TextBoxIterator&); > > } // namespace WebCore
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 243619
:
461434
|
461451
|
461453
|
461454
|
461457
|
461458
|
461459
|
461460