Title: [219752] trunk/Source/WebCore
Revision
219752
Author
timothy_hor...@apple.com
Date
2017-07-21 16:34:18 -0700 (Fri, 21 Jul 2017)

Log Message

TextIndicator::estimatedTextColorsForRange asserts inside HashSet code (inserting reserved value)
https://bugs.webkit.org/show_bug.cgi?id=174733

Reviewed by Wenson Hsieh.

* page/TextIndicator.cpp:
(WebCore::estimatedTextColorsForRange):
(WebCore::adjustTextIndicatorDataOptionsForEstimatedColorsIfNecessary):
RGBA32 isn't a valid hash key, because we have no traits that define the
empty or deleted values, nor do we have any bits we could feasibly
use -- the full range of RGBA32 is easy to reach with various colors.

Instead, hash Color directly.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (219751 => 219752)


--- trunk/Source/WebCore/ChangeLog	2017-07-21 23:25:21 UTC (rev 219751)
+++ trunk/Source/WebCore/ChangeLog	2017-07-21 23:34:18 UTC (rev 219752)
@@ -1,3 +1,19 @@
+2017-07-21  Timothy Horton  <timothy_hor...@apple.com>
+
+        TextIndicator::estimatedTextColorsForRange asserts inside HashSet code (inserting reserved value)
+        https://bugs.webkit.org/show_bug.cgi?id=174733
+
+        Reviewed by Wenson Hsieh.
+
+        * page/TextIndicator.cpp:
+        (WebCore::estimatedTextColorsForRange):
+        (WebCore::adjustTextIndicatorDataOptionsForEstimatedColorsIfNecessary):
+        RGBA32 isn't a valid hash key, because we have no traits that define the
+        empty or deleted values, nor do we have any bits we could feasibly
+        use -- the full range of RGBA32 is easy to reach with various colors.
+
+        Instead, hash Color directly.
+
 2017-07-21  Nan Wang  <n_w...@apple.com>
 
         AX: Expose form validation on iOS as hint

Modified: trunk/Source/WebCore/page/TextIndicator.cpp (219751 => 219752)


--- trunk/Source/WebCore/page/TextIndicator.cpp	2017-07-21 23:25:21 UTC (rev 219751)
+++ trunk/Source/WebCore/page/TextIndicator.cpp	2017-07-21 23:34:18 UTC (rev 219752)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "TextIndicator.h"
 
+#include "ColorHash.h"
 #include "Document.h"
 #include "Editor.h"
 #include "Element.h"
@@ -209,21 +210,15 @@
     return false;
 }
 
-static Vector<Color> estimatedTextColorsForRange(const Range& range)
+static HashSet<Color> estimatedTextColorsForRange(const Range& range)
 {
-    Vector<Color> colors;
-    HashSet<RGBA32> uniqueRGBValues;
+    HashSet<Color> colors;
     for (TextIterator iterator(&range); !iterator.atEnd(); iterator.advance()) {
         auto* node = iterator.node();
         if (!is<Text>(node) || !is<RenderText>(node->renderer()))
             continue;
 
-        auto& color = node->renderer()->style().color();
-        if (uniqueRGBValues.contains(color.rgb()))
-            continue;
-
-        uniqueRGBValues.add(color.rgb());
-        colors.append(color);
+        colors.add(node->renderer()->style().color());
     }
     return colors;
 }
@@ -264,7 +259,7 @@
     return estimatedBackgroundColor;
 }
 
-static void adjustTextIndicatorDataOptionsForEstimatedColorsIfNecessary(TextIndicatorData& data, const Color& backgroundColor, Vector<Color>&& textColors)
+static void adjustTextIndicatorDataOptionsForEstimatedColorsIfNecessary(TextIndicatorData& data, const Color& backgroundColor, HashSet<Color>&& textColors)
 {
     if (data.options & TextIndicatorOptionPaintAllContent)
         return;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to