|
Lines 245-250
void TextBoxPainter<TextBoxPath>::paintForegroundAndDecorations()
a/Source/WebCore/rendering/TextBoxPainter.cpp_sec1
|
| 245 |
auto hasTextDecoration = !m_style.textDecorationsInEffect().isEmpty(); |
245 |
auto hasTextDecoration = !m_style.textDecorationsInEffect().isEmpty(); |
| 246 |
auto hasHighlightDecoration = m_document.hasHighlight() && !MarkedText::collectForHighlights(m_renderer, m_selectableRange, MarkedText::PaintPhase::Decoration).isEmpty(); |
246 |
auto hasHighlightDecoration = m_document.hasHighlight() && !MarkedText::collectForHighlights(m_renderer, m_selectableRange, MarkedText::PaintPhase::Decoration).isEmpty(); |
| 247 |
auto hasDecoration = hasTextDecoration || hasHighlightDecoration; |
247 |
auto hasDecoration = hasTextDecoration || hasHighlightDecoration; |
|
|
248 |
auto hasMismatchingContentDirection = m_renderer.containingBlock()->style().direction() != textBox().direction(); |
| 249 |
auto hasBackwardTrunctation = m_selectableRange.truncation && hasMismatchingContentDirection; |
| 248 |
|
250 |
|
| 249 |
auto contentMayNeedStyledMarkedText = [&] { |
251 |
auto contentMayNeedStyledMarkedText = [&] { |
| 250 |
if (hasDecoration) |
252 |
if (hasDecoration) |
|
Lines 257-265
void TextBoxPainter<TextBoxPath>::paintForegroundAndDecorations()
a/Source/WebCore/rendering/TextBoxPainter.cpp_sec2
|
| 257 |
return true; |
259 |
return true; |
| 258 |
return false; |
260 |
return false; |
| 259 |
}; |
261 |
}; |
|
|
262 |
auto startPosition = [&] { |
| 263 |
return !hasBackwardTrunctation ? m_selectableRange.clamp(textBox().start()) : textBox().length() - *m_selectableRange.truncation; |
| 264 |
}; |
| 265 |
auto endPosition = [&] { |
| 266 |
return !hasBackwardTrunctation ? m_selectableRange.clamp(textBox().end()) : textBox().length(); |
| 267 |
}; |
| 260 |
if (!contentMayNeedStyledMarkedText()) { |
268 |
if (!contentMayNeedStyledMarkedText()) { |
| 261 |
auto& lineStyle = m_isFirstLine ? m_renderer.firstLineStyle() : m_renderer.style(); |
269 |
auto& lineStyle = m_isFirstLine ? m_renderer.firstLineStyle() : m_renderer.style(); |
| 262 |
auto markedText = MarkedText { m_selectableRange.clamp(textBox().start()), m_selectableRange.clamp(textBox().end()), MarkedText::Unmarked }; |
270 |
auto markedText = MarkedText { startPosition(), endPosition(), MarkedText::Unmarked }; |
| 263 |
auto styledMarkedText = StyledMarkedText { markedText, StyledMarkedText::computeStyleForUnmarkedMarkedText(m_renderer, lineStyle, m_isFirstLine, m_paintInfo) }; |
271 |
auto styledMarkedText = StyledMarkedText { markedText, StyledMarkedText::computeStyleForUnmarkedMarkedText(m_renderer, lineStyle, m_isFirstLine, m_paintInfo) }; |
| 264 |
paintCompositionForeground(styledMarkedText); |
272 |
paintCompositionForeground(styledMarkedText); |
| 265 |
return; |
273 |
return; |
|
Lines 268-274
void TextBoxPainter<TextBoxPath>::paintForegroundAndDecorations()
a/Source/WebCore/rendering/TextBoxPainter.cpp_sec3
|
| 268 |
Vector<MarkedText> markedTexts; |
276 |
Vector<MarkedText> markedTexts; |
| 269 |
if (m_paintInfo.phase != PaintPhase::Selection) { |
277 |
if (m_paintInfo.phase != PaintPhase::Selection) { |
| 270 |
// The marked texts for the gaps between document markers and selection are implicitly created by subdividing the entire line. |
278 |
// The marked texts for the gaps between document markers and selection are implicitly created by subdividing the entire line. |
| 271 |
markedTexts.append({ m_selectableRange.clamp(textBox().start()), m_selectableRange.clamp(textBox().end()), MarkedText::Unmarked }); |
279 |
markedTexts.append({ startPosition(), endPosition(), MarkedText::Unmarked }); |
| 272 |
|
280 |
|
| 273 |
if (!m_isPrinting) { |
281 |
if (!m_isPrinting) { |
| 274 |
markedTexts.appendVector(MarkedText::collectForDocumentMarkers(m_renderer, m_selectableRange, MarkedText::PaintPhase::Foreground)); |
282 |
markedTexts.appendVector(MarkedText::collectForDocumentMarkers(m_renderer, m_selectableRange, MarkedText::PaintPhase::Foreground)); |
|
Lines 843-867
FloatRect TextBoxPainter<TextBoxPath>::computePaintRect(const LayoutPoint& paint
a/Source/WebCore/rendering/TextBoxPainter.cpp_sec4
|
| 843 |
{ |
851 |
{ |
| 844 |
FloatPoint localPaintOffset(paintOffset); |
852 |
FloatPoint localPaintOffset(paintOffset); |
| 845 |
|
853 |
|
| 846 |
if (m_selectableRange.truncation) { |
|
|
| 847 |
if (m_renderer.containingBlock()->style().direction() != textBox().direction()) { |
| 848 |
// Make the visible fragment of text hug the edge closest to the rest of the run by moving the origin |
| 849 |
// at which we start drawing text. |
| 850 |
// e.g. In the case of LTR text truncated in an RTL Context, the correct behavior is: |
| 851 |
// |Hello|CBA| -> |...He|CBA| |
| 852 |
// In order to draw the fragment "He" aligned to the right edge of it's box, we need to start drawing |
| 853 |
// farther to the right. |
| 854 |
// NOTE: WebKit's behavior differs from that of IE which appears to just overlay the ellipsis on top of the |
| 855 |
// truncated string i.e. |Hello|CBA| -> |...lo|CBA| |
| 856 |
LayoutUnit widthOfVisibleText { m_renderer.width(textBox().start(), *m_selectableRange.truncation, textPosition(), m_isFirstLine) }; |
| 857 |
LayoutUnit widthOfHiddenText { m_logicalRect.width() - widthOfVisibleText }; |
| 858 |
LayoutSize truncationOffset(textBox().direction() == TextDirection::LTR ? widthOfHiddenText : -widthOfHiddenText, 0_lu); |
| 859 |
localPaintOffset.move(textBox().isHorizontal() ? truncationOffset : truncationOffset.transposedSize()); |
| 860 |
} |
| 861 |
} |
| 862 |
|
| 863 |
localPaintOffset.move(0, m_style.isHorizontalWritingMode() ? 0 : -m_logicalRect.height()); |
854 |
localPaintOffset.move(0, m_style.isHorizontalWritingMode() ? 0 : -m_logicalRect.height()); |
| 864 |
|
|
|
| 865 |
auto visualRect = textBox().visualRectIgnoringBlockDirection(); |
855 |
auto visualRect = textBox().visualRectIgnoringBlockDirection(); |
| 866 |
textBox().formattingContextRoot().flipForWritingMode(visualRect); |
856 |
textBox().formattingContextRoot().flipForWritingMode(visualRect); |
| 867 |
|
857 |
|