Changeset 295455 in webkit
- Timestamp:
- Jun 10, 2022 10:09:37 AM (2 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/rendering/style/RenderStyle.cpp
r295211 r295455 686 686 if (textUnderlinePosition() == TextUnderlinePosition::Under || other.textUnderlinePosition() == TextUnderlinePosition::Under) 687 687 return true; 688 return visualOverflowForDecorations(*this , { }) != visualOverflowForDecorations(other, { });688 return visualOverflowForDecorations(*this) != visualOverflowForDecorations(other); 689 689 } 690 690 -
trunk/Source/WebCore/style/InlineTextBoxStyle.cpp
r295453 r295455 173 173 } 174 174 175 GlyphOverflow visualOverflowForDecorations(const RenderStyle& lineStyle, const InlineIterator::TextBoxIterator& textRun) 176 { 177 ASSERT(!textRun || textRun->style() == lineStyle); 178 175 GlyphOverflow visualOverflowForDecorations(const RenderStyle& lineStyle, std::optional<float> underlineOffset) 176 { 179 177 auto decoration = lineStyle.textDecorationsInEffect(); 180 178 if (decoration.isEmpty()) … … 184 182 WavyStrokeParameters wavyStrokeParameters; 185 183 float wavyOffset = 0; 186 184 187 185 TextDecorationStyle decorationStyle = lineStyle.textDecorationStyle(); 188 186 float height = lineStyle.fontCascade().metricsOfPrimaryFont().floatHeight(); 189 187 GlyphOverflow overflowResult; 190 188 191 189 if (decorationStyle == TextDecorationStyle::Wavy) { 192 190 wavyStrokeParameters = getWavyStrokeParameters(lineStyle.computedFontPixelSize()); … … 199 197 // FIXME: Share the code in TextDecorationPainter::paintBackgroundDecorations() so we can just query it for the painted geometry. 200 198 if (decoration & TextDecorationLine::Underline) { 201 // Compensate for the integral ceiling in GraphicsContext::computeLineBoundsAndAntialiasingModeForText() 202 int underlineOffset = 1; 203 float textDecorationBaseFontSize = 16; 204 auto defaultGap = lineStyle.computedFontSize() / textDecorationBaseFontSize; 205 // FIXME: RenderStyle calls us with empty textRun but only when TextUnderlinePosition is not Under. 206 ASSERT(textRun || lineStyle.textUnderlinePosition() != TextUnderlinePosition::Under); 207 if (!textRun) 208 underlineOffset += computeUnderlineOffset({ lineStyle, defaultGap }); 209 else { 210 underlineOffset += computeUnderlineOffset({ lineStyle 211 , defaultGap 212 , UnderlineOffsetArguments::TextUnderlinePositionUnder { textRun->lineBox()->baselineType(), textRun->logicalBottom() - textRun->logicalTop(), textRunLogicalOffsetFromLineBottom(textRun) } 213 }); 214 } 215 199 ASSERT(underlineOffset); 216 200 if (decorationStyle == TextDecorationStyle::Wavy) { 217 overflowResult.extendBottom( underlineOffset + wavyOffset + wavyStrokeParameters.controlPointDistance + strokeThickness - height);218 overflowResult.extendTop(-( underlineOffset + wavyOffset - wavyStrokeParameters.controlPointDistance - strokeThickness));201 overflowResult.extendBottom(*underlineOffset + wavyOffset + wavyStrokeParameters.controlPointDistance + strokeThickness - height); 202 overflowResult.extendTop(-(*underlineOffset + wavyOffset - wavyStrokeParameters.controlPointDistance - strokeThickness)); 219 203 } else { 220 overflowResult.extendBottom( underlineOffset + strokeThickness - height);221 overflowResult.extendTop(- underlineOffset);204 overflowResult.extendBottom(*underlineOffset + strokeThickness - height); 205 overflowResult.extendTop(-*underlineOffset); 222 206 } 223 207 } … … 251 235 return overflowResult; 252 236 } 237 238 GlyphOverflow visualOverflowForDecorations(const RenderStyle& lineStyle, const InlineIterator::TextBoxIterator& textRun) 239 { 240 ASSERT(!textRun || textRun->style() == lineStyle); 241 242 if (!lineStyle.textDecorationsInEffect().contains(TextDecorationLine::Underline)) 243 return visualOverflowForDecorations(lineStyle, std::optional<float> { }); 244 245 // Compensate for the integral ceiling in GraphicsContext::computeLineBoundsAndAntialiasingModeForText() 246 int underlineOffset = 1; 247 float textDecorationBaseFontSize = 16; 248 auto defaultGap = lineStyle.computedFontSize() / textDecorationBaseFontSize; 249 // FIXME: RenderStyle calls us with empty textRun but only when TextUnderlinePosition is not Under. 250 ASSERT(textRun || lineStyle.textUnderlinePosition() != TextUnderlinePosition::Under); 251 if (!textRun) 252 underlineOffset += computeUnderlineOffset({ lineStyle, defaultGap }); 253 else { 254 underlineOffset += computeUnderlineOffset({ lineStyle 255 , defaultGap 256 , UnderlineOffsetArguments::TextUnderlinePositionUnder { textRun->lineBox()->baselineType(), textRun->logicalBottom() - textRun->logicalTop(), textRunLogicalOffsetFromLineBottom(textRun) } 257 }); 258 } 259 return visualOverflowForDecorations(lineStyle, underlineOffset); 260 } 261 262 GlyphOverflow visualOverflowForDecorations(const RenderStyle& lineStyle) 263 { 264 return visualOverflowForDecorations(lineStyle, InlineIterator::TextBoxIterator { }); 265 } 253 266 254 267 } -
trunk/Source/WebCore/style/InlineTextBoxStyle.h
r295453 r295455 54 54 }; 55 55 WavyStrokeParameters getWavyStrokeParameters(float fontSize); 56 GlyphOverflow visualOverflowForDecorations(const RenderStyle& lineStyle); 56 57 GlyphOverflow visualOverflowForDecorations(const RenderStyle& lineStyle, const InlineIterator::TextBoxIterator&); 58 GlyphOverflow visualOverflowForDecorations(const RenderStyle& lineStyle, std::optional<float> underlineOffset); 57 59 58 60 struct UnderlineOffsetArguments {
Note: See TracChangeset
for help on using the changeset viewer.