Title: [223198] trunk/Source/WebCore
- Revision
- 223198
- Author
- dba...@webkit.org
- Date
- 2017-10-11 12:18:09 -0700 (Wed, 11 Oct 2017)
Log Message
Extract logic to paint composition underlines to its own function
https://bugs.webkit.org/show_bug.cgi?id=178038
Reviewed by Zalan Bujtas.
No functionality changed. So, no new tests.
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::paint): Modified to call paintCompositionUnderlines().
(WebCore::InlineTextBox::paintCompositionUnderlines const): Added; extract code
from InlineTextBox::paint() and modernized it.
(WebCore::InlineTextBox::paintCompositionUnderline const): Added.
(WebCore::InlineTextBox::paintCompositionUnderline): Deleted; made const.
* rendering/InlineTextBox.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (223197 => 223198)
--- trunk/Source/WebCore/ChangeLog 2017-10-11 19:13:59 UTC (rev 223197)
+++ trunk/Source/WebCore/ChangeLog 2017-10-11 19:18:09 UTC (rev 223198)
@@ -1,5 +1,22 @@
2017-10-11 Daniel Bates <daba...@apple.com>
+ Extract logic to paint composition underlines to its own function
+ https://bugs.webkit.org/show_bug.cgi?id=178038
+
+ Reviewed by Zalan Bujtas.
+
+ No functionality changed. So, no new tests.
+
+ * rendering/InlineTextBox.cpp:
+ (WebCore::InlineTextBox::paint): Modified to call paintCompositionUnderlines().
+ (WebCore::InlineTextBox::paintCompositionUnderlines const): Added; extract code
+ from InlineTextBox::paint() and modernized it.
+ (WebCore::InlineTextBox::paintCompositionUnderline const): Added.
+ (WebCore::InlineTextBox::paintCompositionUnderline): Deleted; made const.
+ * rendering/InlineTextBox.h:
+
+2017-10-11 Daniel Bates <daba...@apple.com>
+
InlineTextBox::isSelected() should only return true for a non-empty selection
and remove incorrect FIXME from InlineTextBox::localSelectionRect()
https://bugs.webkit.org/show_bug.cgi?id=160786
Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (223197 => 223198)
--- trunk/Source/WebCore/rendering/InlineTextBox.cpp 2017-10-11 19:13:59 UTC (rev 223197)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp 2017-10-11 19:18:09 UTC (rev 223198)
@@ -588,30 +588,8 @@
if (paintInfo.phase == PaintPhaseForeground) {
paintDocumentMarkers(context, boxOrigin, false);
- if (useCustomUnderlines) {
- const Vector<CompositionUnderline>& underlines = renderer().frame().editor().customCompositionUnderlines();
- size_t numUnderlines = underlines.size();
-
- for (size_t index = 0; index < numUnderlines; ++index) {
- const CompositionUnderline& underline = underlines[index];
-
- if (underline.endOffset <= start())
- // underline is completely before this run. This might be an underline that sits
- // before the first run we draw, or underlines that were within runs we skipped
- // due to truncation.
- continue;
-
- if (underline.startOffset <= end()) {
- // underline intersects this run. Paint it.
- paintCompositionUnderline(context, boxOrigin, underline);
- if (underline.endOffset > end() + 1)
- // underline also runs into the next run. Bail now, no more marker advancement.
- break;
- } else
- // underline is completely after this run, bail. A later run will paint it.
- break;
- }
- }
+ if (useCustomUnderlines)
+ paintCompositionUnderlines(context, boxOrigin);
}
if (shouldRotate)
@@ -963,10 +941,34 @@
}
}
-void InlineTextBox::paintCompositionUnderline(GraphicsContext& context, const FloatPoint& boxOrigin, const CompositionUnderline& underline)
+void InlineTextBox::paintCompositionUnderlines(GraphicsContext& context, const FloatPoint& boxOrigin) const
{
if (m_truncation == cFullTruncation)
return;
+
+ for (auto& underline : renderer().frame().editor().customCompositionUnderlines()) {
+ if (underline.endOffset <= m_start) {
+ // Underline is completely before this run. This might be an underline that sits
+ // before the first run we draw, or underlines that were within runs we skipped
+ // due to truncation.
+ continue;
+ }
+
+ if (underline.startOffset > end())
+ break; // Underline is completely after this run, bail. A later run will paint it.
+
+ // Underline intersects this run. Paint it.
+ paintCompositionUnderline(context, boxOrigin, underline);
+
+ if (underline.endOffset > end() + 1)
+ break; // Underline also runs into the next run. Bail now, no more marker advancement.
+ }
+}
+
+void InlineTextBox::paintCompositionUnderline(GraphicsContext& context, const FloatPoint& boxOrigin, const CompositionUnderline& underline) const
+{
+ if (m_truncation == cFullTruncation)
+ return;
float start = 0; // start of line to draw, relative to tx
float width = m_logicalWidth; // how much line to draw
Modified: trunk/Source/WebCore/rendering/InlineTextBox.h (223197 => 223198)
--- trunk/Source/WebCore/rendering/InlineTextBox.h 2017-10-11 19:13:59 UTC (rev 223197)
+++ trunk/Source/WebCore/rendering/InlineTextBox.h 2017-10-11 19:18:09 UTC (rev 223198)
@@ -159,7 +159,8 @@
void paintTextMatchMarker(GraphicsContext&, const FloatPoint& boxOrigin, const MarkerSubrange&, bool isActiveMatch);
void paintCompositionBackground(GraphicsContext&, const FloatPoint& boxOrigin);
- void paintCompositionUnderline(GraphicsContext&, const FloatPoint& boxOrigin, const CompositionUnderline&);
+ void paintCompositionUnderlines(GraphicsContext&, const FloatPoint& boxOrigin) const;
+ void paintCompositionUnderline(GraphicsContext&, const FloatPoint& boxOrigin, const CompositionUnderline&) const;
void paintTextSubrangeBackground(GraphicsContext&, const FloatPoint& boxOrigin, const Color&, unsigned startOffset, unsigned endOffset);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes