Title: [158750] trunk/Source
Revision
158750
Author
[email protected]
Date
2013-11-06 08:48:17 -0800 (Wed, 06 Nov 2013)

Log Message

Add ENABLE(TEXT_SELECTION)
https://bugs.webkit.org/show_bug.cgi?id=123827

Reviewed by Ryosuke Niwa.

Source/WebCore:

Add compile-time guard, ENABLE(TEXT_SELECTION), to enable or
disable selection painting in WebCore (enabled by default).

On iOS we disable WebCore selection painting and have UIKit
paint the selection.

* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::paintSelection): Only paint selection when
TEXT_SELECTION is enabled.
* rendering/LogicalSelectionOffsetCaches.h:
(WebCore::LogicalSelectionOffsetCaches::LogicalSelectionOffsetCaches):
For now, add a ENABLE(TEXT_SELECTION)-guard around an assertion. Added
a FIXME comment to investigate the callers and either move the assertion
to the appropriate callers or structure the code such that we can remove
the assertion.
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::paintSelection): Only paint selection when
TEXT_SELECTION is enabled.
* rendering/TextPaintStyle.cpp:
(WebCore::computeTextSelectionPaintStyle): Only compute the selection
paint style when TEXT_SELECTION is enabled. Otherwise, return a paint
style identical to the text paint style. Also, substitute nullptr for 0.

Source/WTF:

Enable selection painting by default on all ports except iOS.

* wtf/FeatureDefines.h:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (158749 => 158750)


--- trunk/Source/WTF/ChangeLog	2013-11-06 16:45:28 UTC (rev 158749)
+++ trunk/Source/WTF/ChangeLog	2013-11-06 16:48:17 UTC (rev 158750)
@@ -1,3 +1,14 @@
+2013-11-06  Daniel Bates  <[email protected]>
+
+        Add ENABLE(TEXT_SELECTION)
+        https://bugs.webkit.org/show_bug.cgi?id=123827
+
+        Reviewed by Ryosuke Niwa.
+
+        Enable selection painting by default on all ports except iOS.
+
+        * wtf/FeatureDefines.h:
+
 2013-11-04  Alexey Proskuryakov  <[email protected]>
 
         Implement base64url encoding from RFC 4648

Modified: trunk/Source/WTF/wtf/FeatureDefines.h (158749 => 158750)


--- trunk/Source/WTF/wtf/FeatureDefines.h	2013-11-06 16:45:28 UTC (rev 158749)
+++ trunk/Source/WTF/wtf/FeatureDefines.h	2013-11-06 16:48:17 UTC (rev 158750)
@@ -128,6 +128,10 @@
 #define ENABLE_TEXT_CARET 0
 #endif
 
+#if !defined(ENABLE_TEXT_SELECTION)
+#define ENABLE_TEXT_SELECTION 0
+#endif
+
 #if !defined(ENABLE_TOUCH_EVENTS)
 #define ENABLE_TOUCH_EVENTS 1
 #endif
@@ -787,6 +791,10 @@
 #define ENABLE_TEXT_CARET 1
 #endif
 
+#if !defined(ENABLE_TEXT_SELECTION)
+#define ENABLE_TEXT_SELECTION 1
+#endif
+
 #if !defined(ENABLE_THREADED_HTML_PARSER)
 #define ENABLE_THREADED_HTML_PARSER 0
 #endif

Modified: trunk/Source/WebCore/ChangeLog (158749 => 158750)


--- trunk/Source/WebCore/ChangeLog	2013-11-06 16:45:28 UTC (rev 158749)
+++ trunk/Source/WebCore/ChangeLog	2013-11-06 16:48:17 UTC (rev 158750)
@@ -1,3 +1,33 @@
+2013-11-06  Daniel Bates  <[email protected]>
+
+        Add ENABLE(TEXT_SELECTION)
+        https://bugs.webkit.org/show_bug.cgi?id=123827
+
+        Reviewed by Ryosuke Niwa.
+
+        Add compile-time guard, ENABLE(TEXT_SELECTION), to enable or
+        disable selection painting in WebCore (enabled by default).
+
+        On iOS we disable WebCore selection painting and have UIKit
+        paint the selection.
+
+        * rendering/InlineTextBox.cpp:
+        (WebCore::InlineTextBox::paintSelection): Only paint selection when
+        TEXT_SELECTION is enabled.
+        * rendering/LogicalSelectionOffsetCaches.h:
+        (WebCore::LogicalSelectionOffsetCaches::LogicalSelectionOffsetCaches):
+        For now, add a ENABLE(TEXT_SELECTION)-guard around an assertion. Added
+        a FIXME comment to investigate the callers and either move the assertion
+        to the appropriate callers or structure the code such that we can remove
+        the assertion.
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::paintSelection): Only paint selection when
+        TEXT_SELECTION is enabled.
+        * rendering/TextPaintStyle.cpp:
+        (WebCore::computeTextSelectionPaintStyle): Only compute the selection
+        paint style when TEXT_SELECTION is enabled. Otherwise, return a paint
+        style identical to the text paint style. Also, substitute nullptr for 0.
+
 2013-11-06  Jer Noble  <[email protected]>
 
         Unrevewied Windows build fix after r158736; add InlineElementBox.cpp to the RenderingAllInOne.cpp file.

Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (158749 => 158750)


--- trunk/Source/WebCore/rendering/InlineTextBox.cpp	2013-11-06 16:45:28 UTC (rev 158749)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp	2013-11-06 16:48:17 UTC (rev 158750)
@@ -646,6 +646,7 @@
 
 void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& boxOrigin, const RenderStyle& style, const Font& font, Color textColor)
 {
+#if ENABLE(TEXT_SELECTION)
     if (context->paintingDisabled())
         return;
 
@@ -697,6 +698,13 @@
     context->clip(clipRect);
 
     context->drawHighlightForText(font, textRun, localOrigin, selHeight, c, style.colorSpace(), sPos, ePos);
+#else
+    UNUSED_PARAM(context);
+    UNUSED_PARAM(boxOrigin);
+    UNUSED_PARAM(style);
+    UNUSED_PARAM(font);
+    UNUSED_PARAM(textColor);
+#endif
 }
 
 void InlineTextBox::paintCompositionBackground(GraphicsContext* context, const FloatPoint& boxOrigin, const RenderStyle& style, const Font& font, int startPos, int endPos)

Modified: trunk/Source/WebCore/rendering/LogicalSelectionOffsetCaches.h (158749 => 158750)


--- trunk/Source/WebCore/rendering/LogicalSelectionOffsetCaches.h	2013-11-06 16:45:28 UTC (rev 158749)
+++ trunk/Source/WebCore/rendering/LogicalSelectionOffsetCaches.h	2013-11-06 16:48:17 UTC (rev 158750)
@@ -135,7 +135,11 @@
 
     explicit LogicalSelectionOffsetCaches(RenderBlock& rootBlock)
     {
+#if ENABLE(TEXT_SELECTION)
+        // FIXME: We should either move this assertion to the caller (if applicable) or structure the code
+        // such that we can remove this assertion.
         ASSERT(rootBlock.isSelectionRoot());
+#endif
         auto parent = rootBlock.parent();
 
         // LogicalSelectionOffsetCaches should not be used on an orphaned tree.

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (158749 => 158750)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2013-11-06 16:45:28 UTC (rev 158749)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2013-11-06 16:48:17 UTC (rev 158750)
@@ -2615,6 +2615,7 @@
 
 void RenderBlock::paintSelection(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
+#if ENABLE(TEXT_SELECTION)
     if (shouldPaintSelectionGaps() && paintInfo.phase == PaintPhaseForeground) {
         LogicalSelectionOffsetCaches cache(*this);
         LayoutUnit lastTop = 0;
@@ -2637,6 +2638,10 @@
             }
         }
     }
+#else
+    UNUSED_PARAM(paintInfo);
+    UNUSED_PARAM(paintOffset);
+#endif
 }
 
 static void clipOutPositionedObjects(const PaintInfo* paintInfo, const LayoutPoint& offset, TrackedRendererListHashSet* positionedObjects)

Modified: trunk/Source/WebCore/rendering/TextPaintStyle.cpp (158749 => 158750)


--- trunk/Source/WebCore/rendering/TextPaintStyle.cpp	2013-11-06 16:45:28 UTC (rev 158749)
+++ trunk/Source/WebCore/rendering/TextPaintStyle.cpp	2013-11-06 16:48:17 UTC (rev 158750)
@@ -110,11 +110,11 @@
 {
     paintSelectedTextOnly = (paintInfo.phase == PaintPhaseSelection);
     paintSelectedTextSeparately = false;
-    const ShadowData* textShadow = paintInfo.forceBlackText() ? 0 : lineStyle.textShadow();
+    selectionShadow = paintInfo.forceBlackText() ? nullptr : lineStyle.textShadow();
 
     TextPaintStyle selectionPaintStyle = textPaintStyle;
 
-    selectionShadow = textShadow;
+#if ENABLE(TEXT_SELECTION)
     Color foreground = paintInfo.forceBlackText() ? Color::black : renderer.selectionForegroundColor();
     if (foreground.isValid() && foreground != selectionPaintStyle.fillColor) {
         if (!paintSelectedTextOnly)
@@ -151,6 +151,11 @@
             selectionPaintStyle.strokeColor = stroke;
         }
     }
+#else
+    UNUSED_PARAM(renderer);
+    UNUSED_PARAM(lineStyle);
+    UNUSED_PARAM(paintInfo);
+#endif
     return selectionPaintStyle;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to