Title: [187060] branches/safari-601.1-branch/Source/WebCore
Revision
187060
Author
matthew_han...@apple.com
Date
2015-07-20 21:36:45 -0700 (Mon, 20 Jul 2015)

Log Message

Merge r186890. rdar://problem/21643094

Modified Paths

Diff

Modified: branches/safari-601.1-branch/Source/WebCore/ChangeLog (187059 => 187060)


--- branches/safari-601.1-branch/Source/WebCore/ChangeLog	2015-07-21 04:36:42 UTC (rev 187059)
+++ branches/safari-601.1-branch/Source/WebCore/ChangeLog	2015-07-21 04:36:45 UTC (rev 187060)
@@ -1,5 +1,35 @@
 2015-07-20  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r186890. rdar://problem/21643094
+
+    2015-07-15  Tim Horton  <timothy_hor...@apple.com>
+
+            Move indicator rect uniting code to TextIndicatorWindow instead of TextIndicator
+            https://bugs.webkit.org/show_bug.cgi?id=146992
+            <rdar://problem/21643094>
+
+            Reviewed by Daniel Bates.
+
+            Having to unite all the rects if any overlap is an implementation
+            detail of the Mac TextIndicatorWindow presentation, not a fundamental
+            property of TextIndicator.
+
+            Other TextIndicator presentations might be able to handle overlapping
+            rects more effectively, so we shouldn't lose information unless we need to.
+
+            This also avoids having a second copy of some constants!
+
+            * page/TextIndicator.cpp:
+            (WebCore::outsetIndicatorRectIncludingShadow): Deleted.
+            (WebCore::textIndicatorsForTextRectsOverlap): Deleted.
+            (WebCore::TextIndicator::TextIndicator): Deleted.
+            * page/mac/TextIndicatorWindow.mm:
+            (outsetIndicatorRectIncludingShadow):
+            (textIndicatorsForTextRectsOverlap):
+            (-[WebTextIndicatorView initWithFrame:textIndicator:margin:offset:]):
+
+2015-07-20  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r186875. rdar://problem/21643094
 
     2015-07-15  Brent Fulgham  <bfulg...@apple.com>

Modified: branches/safari-601.1-branch/Source/WebCore/page/TextIndicator.cpp (187059 => 187060)


--- branches/safari-601.1-branch/Source/WebCore/page/TextIndicator.cpp	2015-07-21 04:36:42 UTC (rev 187059)
+++ branches/safari-601.1-branch/Source/WebCore/page/TextIndicator.cpp	2015-07-21 04:36:45 UTC (rev 187060)
@@ -40,52 +40,8 @@
 
 using namespace WebCore;
 
-// These should match the values in TextIndicatorWindow.
-// FIXME: Ideally these would only be in one place.
-#if ENABLE(LEGACY_TEXT_INDICATOR_STYLE)
-const float horizontalBorder = 3;
-const float verticalBorder = 1;
-const float dropShadowBlurRadius = 1.5;
-#else
-const float horizontalBorder = 2;
-const float verticalBorder = 1;
-const float dropShadowBlurRadius = 12;
-#endif
-
 namespace WebCore {
 
-static FloatRect outsetIndicatorRectIncludingShadow(const FloatRect rect)
-{
-    FloatRect outsetRect = rect;
-    outsetRect.inflateX(dropShadowBlurRadius + horizontalBorder);
-    outsetRect.inflateY(dropShadowBlurRadius + verticalBorder);
-    return outsetRect;
-}
-
-static bool textIndicatorsForTextRectsOverlap(const Vector<FloatRect>& textRects)
-{
-    size_t count = textRects.size();
-    if (count <= 1)
-        return false;
-
-    Vector<FloatRect> indicatorRects;
-    indicatorRects.reserveInitialCapacity(count);
-
-    for (size_t i = 0; i < count; ++i) {
-        FloatRect indicatorRect = outsetIndicatorRectIncludingShadow(textRects[i]);
-
-        for (size_t j = indicatorRects.size(); j; ) {
-            --j;
-            if (indicatorRect.intersects(indicatorRects[j]))
-                return true;
-        }
-
-        indicatorRects.uncheckedAppend(indicatorRect);
-    }
-
-    return false;
-}
-
 Ref<TextIndicator> TextIndicator::create(const TextIndicatorData& data)
 {
     return adoptRef(*new TextIndicator(data));
@@ -189,11 +145,6 @@
     : m_data(data)
 {
     ASSERT(m_data.contentImageScaleFactor != 1 || m_data.contentImage->size() == enclosingIntRect(m_data.selectionRectInRootViewCoordinates).size());
-
-    if (textIndicatorsForTextRectsOverlap(m_data.textRectsInBoundingRectCoordinates)) {
-        m_data.textRectsInBoundingRectCoordinates[0] = unionRect(m_data.textRectsInBoundingRectCoordinates);
-        m_data.textRectsInBoundingRectCoordinates.shrink(1);
-    }
 }
 
 TextIndicator::~TextIndicator()

Modified: branches/safari-601.1-branch/Source/WebCore/page/mac/TextIndicatorWindow.mm (187059 => 187060)


--- branches/safari-601.1-branch/Source/WebCore/page/mac/TextIndicatorWindow.mm	2015-07-21 04:36:42 UTC (rev 187059)
+++ branches/safari-601.1-branch/Source/WebCore/page/mac/TextIndicatorWindow.mm	2015-07-21 04:36:45 UTC (rev 187060)
@@ -29,6 +29,7 @@
 #if PLATFORM(MAC)
 
 #import "CoreGraphicsSPI.h"
+#import "GeometryUtilities.h"
 #import "GraphicsContext.h"
 #import "QuartzCoreSPI.h"
 #import "TextIndicator.h"
@@ -91,6 +92,38 @@
 
 @synthesize fadingOut = _fadingOut;
 
+static FloatRect outsetIndicatorRectIncludingShadow(const FloatRect rect)
+{
+    FloatRect outsetRect = rect;
+    outsetRect.inflateX(dropShadowBlurRadius + horizontalBorder);
+    outsetRect.inflateY(dropShadowBlurRadius + verticalBorder);
+    return outsetRect;
+}
+
+static bool textIndicatorsForTextRectsOverlap(const Vector<FloatRect>& textRects)
+{
+    size_t count = textRects.size();
+    if (count <= 1)
+        return false;
+
+    Vector<FloatRect> indicatorRects;
+    indicatorRects.reserveInitialCapacity(count);
+
+    for (size_t i = 0; i < count; ++i) {
+        FloatRect indicatorRect = outsetIndicatorRectIncludingShadow(textRects[i]);
+
+        for (size_t j = indicatorRects.size(); j; ) {
+            --j;
+            if (indicatorRect.intersects(indicatorRects[j]))
+                return true;
+        }
+
+        indicatorRects.uncheckedAppend(indicatorRect);
+    }
+
+    return false;
+}
+
 - (instancetype)initWithFrame:(NSRect)frame textIndicator:(PassRefPtr<TextIndicator>)textIndicator margin:(NSSize)margin offset:(NSPoint)offset
 {
     if (!(self = [super initWithFrame:frame]))
@@ -120,7 +153,13 @@
     RetainPtr<CGColorRef> gradientDarkColor = [NSColor colorWithDeviceRed:.929 green:.8 blue:0 alpha:1].CGColor;
     RetainPtr<CGColorRef> gradientLightColor = [NSColor colorWithDeviceRed:.949 green:.937 blue:0 alpha:1].CGColor;
 
-    for (const auto& textRect : _textIndicator->textRectsInBoundingRectCoordinates()) {
+    Vector<FloatRect> textRectsInBoundingRectCoordinates = _textIndicator->textRectsInBoundingRectCoordinates();
+    if (textIndicatorsForTextRectsOverlap(textRectsInBoundingRectCoordinates)) {
+        textRectsInBoundingRectCoordinates[0] = unionRect(textRectsInBoundingRectCoordinates);
+        textRectsInBoundingRectCoordinates.shrink(1);
+    }
+
+    for (const auto& textRect : textRectsInBoundingRectCoordinates) {
         FloatRect offsetTextRect = textRect;
         offsetTextRect.move(offset.x, offset.y);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to