summaryrefslogtreecommitdiffstats
path: root/Source/WebKit2/WebProcess/WebPage/FindController.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/WebProcess/WebPage/FindController.cpp')
-rw-r--r--Source/WebKit2/WebProcess/WebPage/FindController.cpp49
1 files changed, 36 insertions, 13 deletions
diff --git a/Source/WebKit2/WebProcess/WebPage/FindController.cpp b/Source/WebKit2/WebProcess/WebPage/FindController.cpp
index 3e7b268..49f5786 100644
--- a/Source/WebKit2/WebProcess/WebPage/FindController.cpp
+++ b/Source/WebKit2/WebProcess/WebPage/FindController.cpp
@@ -38,6 +38,7 @@
#include <WebCore/GraphicsContext.h>
#include <WebCore/Page.h>
+using namespace std;
using namespace WebCore;
namespace WebKit {
@@ -64,9 +65,16 @@ FindController::~FindController()
void FindController::countStringMatches(const String& string, FindOptions options, unsigned maxMatchCount)
{
- unsigned matchCount = m_webPage->corePage()->markAllMatchesForText(string, core(options), false, maxMatchCount);
+ if (maxMatchCount == numeric_limits<unsigned>::max())
+ --maxMatchCount;
+
+ unsigned matchCount = m_webPage->corePage()->markAllMatchesForText(string, core(options), false, maxMatchCount + 1);
m_webPage->corePage()->unmarkAllTextMatches();
+ // Check if we have more matches than allowed.
+ if (matchCount > maxMatchCount)
+ matchCount = static_cast<unsigned>(kWKMoreThanMaximumMatchCount);
+
m_webPage->send(Messages::WebPageProxy::DidCountStringMatches(string, matchCount));
}
@@ -102,6 +110,9 @@ void FindController::findString(const String& string, FindOptions options, unsig
shouldShowOverlay = options & FindOptionsShowOverlay;
if (shouldShowOverlay) {
+ if (maxMatchCount == numeric_limits<unsigned>::max())
+ --maxMatchCount;
+
unsigned matchCount = m_webPage->corePage()->markAllMatchesForText(string, core(options), false, maxMatchCount + 1);
// Check if we have more matches than allowed.
@@ -122,7 +133,7 @@ void FindController::findString(const String& string, FindOptions options, unsig
if (!shouldShowOverlay) {
if (m_findPageOverlay) {
// Get rid of the overlay.
- m_webPage->uninstallPageOverlay(m_findPageOverlay);
+ m_webPage->uninstallPageOverlay(m_findPageOverlay, false);
}
ASSERT(!m_findPageOverlay);
@@ -142,7 +153,7 @@ void FindController::findString(const String& string, FindOptions options, unsig
void FindController::hideFindUI()
{
if (m_findPageOverlay)
- m_webPage->uninstallPageOverlay(m_findPageOverlay);
+ m_webPage->uninstallPageOverlay(m_findPageOverlay, true);
hideFindIndicator();
}
@@ -259,27 +270,39 @@ static const float shadowOffsetY = 1.0;
static const float shadowBlurRadius = 2.0;
static const float whiteFrameThickness = 1.0;
-static const int overlayBackgroundRed = 25;
-static const int overlayBackgroundGreen = 25;
-static const int overlayBackgroundBlue = 25;
-static const int overlayBackgroundAlpha = 63;
+static const float overlayBackgroundRed = 0.1;
+static const float overlayBackgroundGreen = 0.1;
+static const float overlayBackgroundBlue = 0.1;
+static const float overlayBackgroundAlpha = 0.25;
+
+static Color overlayBackgroundColor(float fractionFadedIn)
+{
+ return Color(overlayBackgroundRed, overlayBackgroundGreen, overlayBackgroundBlue, overlayBackgroundAlpha * fractionFadedIn);
+}
-static Color overlayBackgroundColor()
+static Color holeShadowColor(float fractionFadedIn)
{
- return Color(overlayBackgroundRed, overlayBackgroundGreen, overlayBackgroundBlue, overlayBackgroundAlpha);
+ return Color(0.0f, 0.0f, 0.0f, fractionFadedIn);
}
-void FindController::drawRect(PageOverlay*, GraphicsContext& graphicsContext, const IntRect& dirtyRect)
+static Color holeFillColor(float fractionFadedIn)
{
+ return Color(1.0f, 1.0f, 1.0f, fractionFadedIn);
+}
+
+void FindController::drawRect(PageOverlay* pageOverlay, GraphicsContext& graphicsContext, const IntRect& dirtyRect)
+{
+ float fractionFadedIn = pageOverlay->fractionFadedIn();
+
Vector<IntRect> rects = rectsForTextMatches();
// Draw the background.
- graphicsContext.fillRect(dirtyRect, overlayBackgroundColor(), ColorSpaceSRGB);
+ graphicsContext.fillRect(dirtyRect, overlayBackgroundColor(fractionFadedIn), ColorSpaceSRGB);
graphicsContext.save();
- graphicsContext.setShadow(FloatSize(shadowOffsetX, shadowOffsetY), shadowBlurRadius, Color::black, ColorSpaceSRGB);
+ graphicsContext.setShadow(FloatSize(shadowOffsetX, shadowOffsetY), shadowBlurRadius, holeShadowColor(fractionFadedIn), ColorSpaceSRGB);
- graphicsContext.setFillColor(Color::white, ColorSpaceSRGB);
+ graphicsContext.setFillColor(holeFillColor(fractionFadedIn), ColorSpaceSRGB);
// Draw white frames around the holes.
for (size_t i = 0; i < rects.size(); ++i) {