Changeset 295444 in webkit
- Timestamp:
- Jun 9, 2022 8:08:10 PM (2 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/rendering/TextDecorationPainter.cpp
r293217 r295444 29 29 #include "HTMLAnchorElement.h" 30 30 #include "HTMLFontElement.h" 31 #include "InlineIteratorLineBox.h" 31 32 #include "InlineTextBoxStyle.h" 32 33 #include "RenderBlock.h" … … 280 281 float textDecorationBaseFontSize = 16; 281 282 auto defaultGap = m_lineStyle.computedFontSize() / textDecorationBaseFontSize; 282 float offset = computeUnderlineOffset(m_lineStyle.textUnderlinePosition(), m_lineStyle.textUnderlineOffset(), m_lineStyle.metricsOfPrimaryFont(), m_textBox, defaultGap); 283 float offset = computeUnderlineOffset({ m_lineStyle 284 , defaultGap 285 , &m_textBox->renderer() 286 , m_textBox->lineBox()->baselineType() 287 , m_textBox->logicalTop() 288 , m_textBox->logicalBottom() 289 , m_textBox->lineBox() 290 }); 283 291 float wavyOffset = m_styles.underlineStyle == TextDecorationStyle::Wavy ? m_wavyOffset : 0; 284 292 FloatRect rect(localOrigin, FloatSize(m_width, textDecorationThickness)); -
trunk/Source/WebCore/style/InlineTextBoxStyle.cpp
r291548 r295444 30 30 #include "HTMLAnchorElement.h" 31 31 #include "HTMLNames.h" 32 #include "InlineIteratorLineBox.h"33 32 #include "InlineIteratorTextBox.h" 34 33 #include "LegacyInlineTextBox.h" … … 102 101 } 103 102 104 float computeUnderlineOffset( TextUnderlinePosition underlinePosition, TextUnderlineOffset underlineOffset, const FontMetrics& fontMetrics, const InlineIterator::TextBoxIterator& textRun, float defaultGap)103 float computeUnderlineOffset(const UnderlineOffsetArguments& context) 105 104 { 106 105 // This represents the gap between the baseline and the closest edge of the underline. 107 float gap = std::max<int>(1, std::ceil( defaultGap / 2.0f));106 float gap = std::max<int>(1, std::ceil(context.defaultGap / 2.0f)); 108 107 109 108 // FIXME: The code for visual overflow detection passes in a null inline text box. This means it is now … … 116 115 // vertical text, since we already determined the baseline type to be ideographic in that 117 116 // case. 118 117 auto underlinePosition = context.lineStyle.textUnderlinePosition(); 118 auto underlineOffset = context.lineStyle.textUnderlineOffset(); 119 auto& fontMetrics = context.lineStyle.metricsOfPrimaryFont(); 120 119 121 auto resolvedUnderlinePosition = underlinePosition; 120 122 if (resolvedUnderlinePosition == TextUnderlinePosition::Auto && underlineOffset.isAuto()) { 121 if ( textRun)122 resolvedUnderlinePosition = textRun->lineBox()->baselineType()== IdeographicBaseline ? TextUnderlinePosition::Under : TextUnderlinePosition::Auto;123 if (context.renderer) 124 resolvedUnderlinePosition = context.baselineType == IdeographicBaseline ? TextUnderlinePosition::Under : TextUnderlinePosition::Auto; 123 125 else 124 126 resolvedUnderlinePosition = TextUnderlinePosition::Auto; … … 133 135 return fontMetrics.ascent() + fontMetrics.underlinePosition() + underlineOffset.lengthOr(0); 134 136 case TextUnderlinePosition::Under: { 135 ASSERT( textRun);137 ASSERT(context.lineBox && context.renderer); 136 138 // Position underline relative to the bottom edge of the lowest element's content box. 137 auto lineBox = textRun->lineBox(); 138 auto* decorationRenderer = enclosingRendererWithTextDecoration(textRun->renderer(), TextDecorationLine::Underline, lineBox->isFirst()); 139 auto* decorationRenderer = enclosingRendererWithTextDecoration(*context.renderer, TextDecorationLine::Underline, context.lineBox->isFirst()); 139 140 140 141 float offset; 141 if ( textRun->renderer().style().isFlippedLinesWritingMode()) {142 offset = textRun->logicalTop();143 minLogicalTopForTextDecorationLine( lineBox, offset, decorationRenderer, TextDecorationLine::Underline);144 offset = textRun->logicalTop()- offset;142 if (context.renderer->style().isFlippedLinesWritingMode()) { 143 offset = context.textRunLogicalTop; 144 minLogicalTopForTextDecorationLine(context.lineBox, offset, decorationRenderer, TextDecorationLine::Underline); 145 offset = context.textRunLogicalTop - offset; 145 146 } else { 146 offset = textRun->logicalBottom(); 147 maxLogicalBottomForTextDecorationLine(lineBox, offset, decorationRenderer, TextDecorationLine::Underline); 148 offset -= textRun->logicalBottom(); 149 } 150 auto desiredOffset = textRun->logicalHeight() + gap + std::max(offset, 0.0f) + underlineOffset.lengthOr(0); 147 offset = context.textRunLogicalBottom; 148 maxLogicalBottomForTextDecorationLine(context.lineBox, offset, decorationRenderer, TextDecorationLine::Underline); 149 offset -= context.textRunLogicalBottom; 150 } 151 auto textRunLogicalHeight = context.textRunLogicalBottom - context.textRunLogicalTop; 152 auto desiredOffset = textRunLogicalHeight + gap + std::max(offset, 0.0f) + underlineOffset.lengthOr(0); 151 153 return std::max<float>(desiredOffset, fontMetrics.ascent()); 152 154 } … … 196 198 float textDecorationBaseFontSize = 16; 197 199 auto defaultGap = lineStyle.computedFontSize() / textDecorationBaseFontSize; 198 underlineOffset += computeUnderlineOffset(lineStyle.textUnderlinePosition(), lineStyle.textUnderlineOffset(), lineStyle.metricsOfPrimaryFont(), textRun, defaultGap); 200 // FIXME: RenderStyle calls us with empty textRun but only when TextUnderlinePosition is not Under. 201 ASSERT(textRun || lineStyle.textUnderlinePosition() != TextUnderlinePosition::Under); 202 if (!textRun) 203 underlineOffset += computeUnderlineOffset({ lineStyle, defaultGap }); 204 else { 205 underlineOffset += computeUnderlineOffset({ lineStyle 206 , defaultGap 207 , &textRun->renderer() 208 , textRun->lineBox()->baselineType() 209 , textRun->logicalTop() 210 , textRun->logicalBottom() 211 , textRun->lineBox() 212 }); 213 } 214 199 215 if (decorationStyle == TextDecorationStyle::Wavy) { 200 216 overflowResult.extendBottom(underlineOffset + wavyOffset + wavyStrokeParameters.controlPointDistance + strokeThickness - height); -
trunk/Source/WebCore/style/InlineTextBoxStyle.h
r283443 r295444 28 28 #include "FontCascade.h" 29 29 #include "InlineIteratorBox.h" 30 #include "InlineIteratorLineBox.h" 30 31 #include "RenderStyleConstants.h" 31 32 … … 54 55 WavyStrokeParameters getWavyStrokeParameters(float fontSize); 55 56 GlyphOverflow visualOverflowForDecorations(const RenderStyle& lineStyle, const InlineIterator::TextBoxIterator&); 56 float computeUnderlineOffset(TextUnderlinePosition, TextUnderlineOffset, const FontMetrics&, const InlineIterator::TextBoxIterator&, float textDecorationThickness); 57 58 struct UnderlineOffsetArguments { 59 const RenderStyle& lineStyle; 60 float defaultGap { 0 }; 61 const RenderText* renderer { nullptr }; 62 FontBaseline baselineType { AlphabeticBaseline }; 63 float textRunLogicalTop { 0 }; 64 float textRunLogicalBottom { 0 }; 65 InlineIterator::LineBoxIterator lineBox { }; 66 }; 67 float computeUnderlineOffset(const UnderlineOffsetArguments&); 57 68 58 69 } // namespace WebCore
Note: See TracChangeset
for help on using the changeset viewer.