Modified: trunk/Source/WebKit2/UIProcess/FindIndicator.cpp (170623 => 170624)
--- trunk/Source/WebKit2/UIProcess/FindIndicator.cpp 2014-07-01 00:45:50 UTC (rev 170623)
+++ trunk/Source/WebKit2/UIProcess/FindIndicator.cpp 2014-07-01 00:50:07 UTC (rev 170624)
@@ -33,8 +33,15 @@
#include <WebCore/IntRect.h>
#include <WebCore/Path.h>
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101000
+#define ENABLE_LEGACY_FIND_INDICATOR_STYLE 1
+#else
+#define ENABLE_LEGACY_FIND_INDICATOR_STYLE 0
+#endif
+
using namespace WebCore;
+#if ENABLE(LEGACY_FIND_INDICATOR_STYLE)
static const float cornerRadius = 3.0;
static const float shadowOffsetX = 0.0;
@@ -75,6 +82,14 @@
static const int gradientLightGreen = 239;
static const int gradientLightBlue = 0;
static const int gradientLightAlpha = 255;
+#else
+const float flatStyleHorizontalBorder = 2;
+const float flatStyleVerticalBorder = 1;
+const float flatShadowOffsetX = 0;
+const float flatShadowOffsetY = 5;
+const float flatShadowBlurRadius = 25;
+const float flatRimShadowBlurRadius = 2;
+#endif
namespace WebKit {
@@ -88,6 +103,26 @@
return adoptRef(new FindIndicator(selectionRectInWindowCoordinates, textRectsInSelectionRectCoordinates, contentImageScaleFactor, contentImage.release()));
}
+static FloatRect inflateRect(const FloatRect& rect, float inflateX, float inflateY)
+{
+ FloatRect inflatedRect = rect;
+ inflatedRect.inflateX(inflateX);
+ inflatedRect.inflateY(inflateY);
+ return inflatedRect;
+}
+
+static FloatRect outsetIndicatorRectIncludingShadow(const FloatRect rect)
+{
+#if ENABLE(LEGACY_FIND_INDICATOR_STYLE)
+ FloatRect outsetRect = rect;
+ outsetRect.move(-leftBorderThickness, -topBorderThickness);
+ outsetRect.expand(leftBorderThickness + rightBorderThickness, topBorderThickness + bottomBorderThickness);
+ return outsetRect;
+#else
+ return inflateRect(rect, flatShadowBlurRadius + flatStyleHorizontalBorder, flatShadowBlurRadius + flatStyleVerticalBorder);
+#endif
+}
+
static bool findIndicatorsForTextRectsOverlap(const Vector<FloatRect>& textRects)
{
size_t count = textRects.size();
@@ -98,9 +133,7 @@
indicatorRects.reserveInitialCapacity(count);
for (size_t i = 0; i < count; ++i) {
- FloatRect indicatorRect = textRects[i];
- indicatorRect.move(-leftBorderThickness, -topBorderThickness);
- indicatorRect.expand(leftBorderThickness + rightBorderThickness, topBorderThickness + bottomBorderThickness);
+ FloatRect indicatorRect = outsetIndicatorRectIncludingShadow(textRects[i]);
for (size_t j = indicatorRects.size(); j; ) {
--j;
@@ -130,38 +163,28 @@
{
}
-static FloatRect inflateRect(const FloatRect& rect, float inflateX, float inflateY)
-{
- FloatRect inflatedRect = rect;
- inflatedRect.inflateX(inflateX);
- inflatedRect.inflateY(inflateY);
-
- return inflatedRect;
-}
-
FloatRect FindIndicator::frameRect() const
{
- return FloatRect(m_selectionRectInWindowCoordinates.x() - leftBorderThickness, m_selectionRectInWindowCoordinates.y() - topBorderThickness,
- m_selectionRectInWindowCoordinates.width() + rightBorderThickness + leftBorderThickness,
- m_selectionRectInWindowCoordinates.height() + topBorderThickness + bottomBorderThickness);
+ return outsetIndicatorRectIncludingShadow(m_selectionRectInWindowCoordinates);
}
-static Color lightBorderColor()
+#if ENABLE(LEGACY_FIND_INDICATOR_STYLE)
+static inline Color lightBorderColor()
{
return Color(lightBorderRed, lightBorderGreen, lightBorderBlue, lightBorderAlpha);
}
-static Color shadowColor()
+static inline Color shadowColor()
{
return Color(shadowRed, shadowGreen, shadowBlue, shadowAlpha);
}
-static Color gradientLightColor()
+static inline Color gradientLightColor()
{
return Color(gradientLightRed, gradientLightGreen, gradientLightBlue, gradientLightAlpha);
}
-static Color gradientDarkColor()
+static inline Color gradientDarkColor()
{
return Color(gradientDarkRed, gradientDarkGreen, gradientDarkBlue, gradientDarkAlpha);
}
@@ -173,9 +196,26 @@
return path;
}
+#else
+static inline Color flatHighlightColor()
+{
+ return Color(255, 255, 0, 255);
+}
+
+static inline Color flatRimShadowColor()
+{
+ return Color(0, 0, 0, 38);
+}
+
+static inline Color flatDropShadowColor()
+{
+ return Color(0, 0, 0, 51);
+}
+#endif
void FindIndicator::draw(GraphicsContext& graphicsContext, const IntRect& /*dirtyRect*/)
{
+#if ENABLE(LEGACY_FIND_INDICATOR_STYLE)
for (size_t i = 0; i < m_textRectsInSelectionRectCoordinates.size(); ++i) {
FloatRect textRect = m_textRectsInSelectionRectCoordinates[i];
textRect.move(leftBorderThickness, topBorderThickness);
@@ -208,6 +248,30 @@
m_contentImage->paint(graphicsContext, m_contentImageScaleFactor, contentImageRect.location(), contentImageRect);
}
}
+#else
+ for (auto& textRect : m_textRectsInSelectionRectCoordinates) {
+ FloatRect blurRect = textRect;
+ blurRect.move(flatShadowBlurRadius + flatStyleHorizontalBorder, flatShadowBlurRadius + flatStyleVerticalBorder);
+ FloatRect outerPathRect = inflateRect(blurRect, flatStyleHorizontalBorder, flatStyleVerticalBorder);
+
+ {
+ GraphicsContextStateSaver stateSaver(graphicsContext);
+ graphicsContext.setShadow(FloatSize(), flatRimShadowBlurRadius, flatRimShadowColor(), ColorSpaceSRGB);
+ graphicsContext.setFillColor(flatHighlightColor(), ColorSpaceSRGB);
+ graphicsContext.fillRect(outerPathRect);
+ graphicsContext.setShadow(FloatSize(flatShadowOffsetX, flatShadowOffsetY), flatShadowBlurRadius, flatDropShadowColor(), ColorSpaceSRGB);
+ graphicsContext.fillRect(outerPathRect);
+ }
+
+ {
+ GraphicsContextStateSaver stateSaver(graphicsContext);
+ graphicsContext.translate(FloatSize(flatShadowBlurRadius + flatStyleHorizontalBorder, flatShadowBlurRadius + flatStyleVerticalBorder));
+
+ IntRect contentImageRect = enclosingIntRect(textRect);
+ m_contentImage->paint(graphicsContext, m_contentImageScaleFactor, contentImageRect.location(), contentImageRect);
+ }
+ }
+#endif
}
} // namespace WebKit
Modified: trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp (170623 => 170624)
--- trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp 2014-07-01 00:45:50 UTC (rev 170623)
+++ trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp 2014-07-01 00:50:07 UTC (rev 170624)
@@ -44,6 +44,12 @@
using namespace WebCore;
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101000
+#define ENABLE_LEGACY_FIND_INDICATOR_STYLE 1
+#else
+#define ENABLE_LEGACY_FIND_INDICATOR_STYLE 0
+#endif
+
namespace WebKit {
static WebCore::FindOptions core(FindOptions options)
@@ -266,6 +272,8 @@
if (!findIndicatorTextBackingStore)
return false;
+ // FIXME: We should consider using subpixel antialiasing for the snapshot
+ // if we're compositing this image onto a solid color (the modern find indicator style).
auto graphicsContext = findIndicatorTextBackingStore->createGraphicsContext();
graphicsContext->scale(FloatSize(deviceScaleFactor, deviceScaleFactor));
@@ -448,18 +456,15 @@
{
}
+#if ENABLE(LEGACY_FIND_INDICATOR_STYLE)
static const float shadowOffsetX = 0.0;
static const float shadowOffsetY = 1.0;
static const float shadowBlurRadius = 2.0;
+#endif
-static const float overlayBackgroundRed = 0.1;
-static const float overlayBackgroundGreen = 0.1;
-static const float overlayBackgroundBlue = 0.1;
-static const float overlayBackgroundAlpha = 0.25;
-
void FindController::drawRect(PageOverlay*, GraphicsContext& graphicsContext, const IntRect& dirtyRect)
{
- Color overlayBackgroundColor(overlayBackgroundRed, overlayBackgroundGreen, overlayBackgroundBlue, overlayBackgroundAlpha);
+ Color overlayBackgroundColor(0.1f, 0.1f, 0.1f, 0.25f);
Vector<IntRect> rects = rectsForTextMatches();
@@ -469,20 +474,22 @@
{
GraphicsContextStateSaver stateSaver(graphicsContext);
+#if ENABLE(LEGACY_FIND_INDICATOR_STYLE)
graphicsContext.setShadow(FloatSize(shadowOffsetX, shadowOffsetY), shadowBlurRadius, Color::black, ColorSpaceSRGB);
+#endif
graphicsContext.setFillColor(Color::white, ColorSpaceSRGB);
// Draw white frames around the holes.
- for (size_t i = 0; i < rects.size(); ++i) {
- IntRect whiteFrameRect = rects[i];
+ for (auto& rect : rects) {
+ IntRect whiteFrameRect = rect;
whiteFrameRect.inflate(1);
graphicsContext.fillRect(whiteFrameRect);
}
}
// Clear out the holes.
- for (size_t i = 0; i < rects.size(); ++i)
- graphicsContext.clearRect(rects[i]);
+ for (auto& rect : rects)
+ graphicsContext.clearRect(rect);
if (!m_isShowingFindIndicator)
return;