[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

andersca at apple.com andersca at apple.com
Wed Dec 22 15:38:22 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 493019adce613f31c18b6edbd9dff97a36cdfe15
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Nov 9 20:03:49 2010 +0000

    Move the find page overlay code to FindController
    https://bugs.webkit.org/show_bug.cgi?id=49266
    
    Reviewed by John Sullivan.
    
    * WebProcess/WebPage/FindController.cpp:
    (WebKit::FindController::~FindController):
    (WebKit::FindController::rectsForTextMatches):
    (WebKit::overlayBackgroundColor):
    (WebKit::FindController::drawRect):
    (WebKit::FindController::mouseEvent):
    * WebProcess/WebPage/FindController.h:
    * WebProcess/WebPage/FindPageOverlay.cpp:
    (WebKit::FindPageOverlay::drawRect):
    (WebKit::FindPageOverlay::mouseEvent):
    * WebProcess/WebPage/FindPageOverlay.h:
    * WebProcess/WebPage/PageOverlay.cpp:
    (WebKit::PageOverlay::bounds):
    (WebKit::PageOverlay::drawRect):
    (WebKit::PageOverlay::mouseEvent):
    * WebProcess/WebPage/PageOverlay.h:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71665 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 2bad18b..7f9885c 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -99,6 +99,30 @@
 
         Reviewed by John Sullivan.
 
+        Move the find page overlay code to FindController
+        https://bugs.webkit.org/show_bug.cgi?id=49266
+
+        * WebProcess/WebPage/FindController.cpp:
+        (WebKit::FindController::~FindController):
+        (WebKit::FindController::rectsForTextMatches):
+        (WebKit::overlayBackgroundColor):
+        (WebKit::FindController::drawRect):
+        (WebKit::FindController::mouseEvent):
+        * WebProcess/WebPage/FindController.h:
+        * WebProcess/WebPage/FindPageOverlay.cpp:
+        (WebKit::FindPageOverlay::drawRect):
+        (WebKit::FindPageOverlay::mouseEvent):
+        * WebProcess/WebPage/FindPageOverlay.h:
+        * WebProcess/WebPage/PageOverlay.cpp:
+        (WebKit::PageOverlay::bounds):
+        (WebKit::PageOverlay::drawRect):
+        (WebKit::PageOverlay::mouseEvent):
+        * WebProcess/WebPage/PageOverlay.h:
+
+2010-11-09  Anders Carlsson  <andersca at apple.com>
+
+        Reviewed by John Sullivan.
+
         Add a PageOverlay::Client object in preparation of not allowing subclassing of PageOverlay
         https://bugs.webkit.org/show_bug.cgi?id=49263
 
diff --git a/WebKit2/WebProcess/WebPage/FindController.cpp b/WebKit2/WebProcess/WebPage/FindController.cpp
index 775b8b8..7b747dc 100644
--- a/WebKit2/WebProcess/WebPage/FindController.cpp
+++ b/WebKit2/WebProcess/WebPage/FindController.cpp
@@ -48,6 +48,10 @@ FindController::FindController(WebPage* webPage)
 {
 }
 
+FindController::~FindController()
+{
+}
+
 void FindController::countStringMatches(const String& string, bool caseInsensitive, unsigned maxMatchCount)
 {
     unsigned matchCount = m_webPage->corePage()->markAllMatchesForText(string, caseInsensitive ? TextCaseInsensitive : TextCaseSensitive, false, maxMatchCount);
@@ -195,5 +199,91 @@ void FindController::hideFindIndicator()
     m_isShowingFindIndicator = false;
 }
 
+Vector<IntRect> FindController::rectsForTextMatches()
+{
+    Vector<IntRect> rects;
+
+    for (Frame* frame = m_webPage->corePage()->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
+        Document* document = frame->document();
+        if (!document)
+            continue;
+
+        IntRect visibleRect = frame->view()->visibleContentRect();
+        Vector<IntRect> frameRects = document->markers()->renderedRectsForMarkers(DocumentMarker::TextMatch);
+        IntPoint frameOffset(-frame->view()->scrollOffset().width(), -frame->view()->scrollOffset().height());
+        frameOffset = frame->view()->convertToContainingWindow(frameOffset);
+
+        for (Vector<IntRect>::iterator it = frameRects.begin(), end = frameRects.end(); it != end; ++it) {
+            it->intersect(visibleRect);
+            it->move(frameOffset.x(), frameOffset.y());
+            rects.append(*it);
+        }
+    }
+
+    return rects;
+}
+
+static const float shadowOffsetX = 0.0;
+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 Color overlayBackgroundColor()
+{
+    return Color(overlayBackgroundRed, overlayBackgroundGreen, overlayBackgroundBlue, overlayBackgroundAlpha);
+}
+
+void FindController::drawRect(PageOverlay*, GraphicsContext& graphicsContext, const IntRect& dirtyRect)
+{
+    Vector<IntRect> rects = rectsForTextMatches();
+    ASSERT(!rects.isEmpty());
+
+    graphicsContext.beginTransparencyLayer(1);
+    graphicsContext.setCompositeOperation(CompositeCopy);
+
+    // Draw the background.
+    graphicsContext.fillRect(dirtyRect, overlayBackgroundColor(), ColorSpaceSRGB);
+
+    graphicsContext.save();
+    graphicsContext.setShadow(FloatSize(shadowOffsetX, shadowOffsetY), shadowBlurRadius, Color::black, ColorSpaceSRGB);
+
+    graphicsContext.setFillColor(Color::white, ColorSpaceSRGB);
+
+    // Draw white frames around the holes.
+    for (size_t i = 0; i < rects.size(); ++i) {
+        IntRect whiteFrameRect = rects[i];
+        whiteFrameRect.inflate(1);
+
+        graphicsContext.fillRect(whiteFrameRect);
+    }
+
+    graphicsContext.restore();
+
+    graphicsContext.save();
+    graphicsContext.setFillColor(Color::transparent, ColorSpaceSRGB);
+
+    // Clear out the holes.
+    for (size_t i = 0; i < rects.size(); ++i)
+        graphicsContext.fillRect(rects[i]);
+
+    graphicsContext.restore();
+    graphicsContext.endTransparencyLayer();
+}
+
+bool FindController::mouseEvent(PageOverlay* pageOverlay, const WebMouseEvent& mouseEvent)
+{
+    // If we get a mouse down event inside the page overlay we should hide the find UI.
+    if (mouseEvent.type() == WebEvent::MouseDown) {
+        // Dismiss the overlay.
+        hideFindUI();
+    }
+
+    return false;
+}
 
 } // namespace WebKit
diff --git a/WebKit2/WebProcess/WebPage/FindController.h b/WebKit2/WebProcess/WebPage/FindController.h
index 7a54d34..a0e726e 100644
--- a/WebKit2/WebProcess/WebPage/FindController.h
+++ b/WebKit2/WebProcess/WebPage/FindController.h
@@ -27,11 +27,14 @@
 #define FindController_h
 
 #include "FindOptions.h"
+#include "PageOverlay.h"
 #include <wtf/Forward.h>
 #include <wtf/Noncopyable.h>
+#include <wtf/Vector.h>
 
 namespace WebCore {
     class Frame;
+    class IntRect;
 }
 
 namespace WebKit {
@@ -44,6 +47,7 @@ class FindController {
 
 public:
     explicit FindController(WebPage*);
+    virtual ~FindController();
 
     void findString(const String&, FindDirection, FindOptions, unsigned maxMatchCount);
     void hideFindUI();
@@ -55,7 +59,15 @@ public:
 
 private:
     bool updateFindIndicator(WebCore::Frame* selectedFrame, bool isShowingOverlay);
-    
+
+    // FIXME: These three member functions should be private once FindPageOverlay has been removed.
+public:
+    Vector<WebCore::IntRect> rectsForTextMatches();
+    // PageOverlay::Client.
+    virtual bool mouseEvent(PageOverlay*, const WebMouseEvent&);
+    virtual void drawRect(PageOverlay*, WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRect);
+
+private:
     WebPage* m_webPage;
     FindPageOverlay* m_findPageOverlay;
 
diff --git a/WebKit2/WebProcess/WebPage/FindPageOverlay.cpp b/WebKit2/WebProcess/WebPage/FindPageOverlay.cpp
index b18c940..3e57473 100644
--- a/WebKit2/WebProcess/WebPage/FindPageOverlay.cpp
+++ b/WebKit2/WebProcess/WebPage/FindPageOverlay.cpp
@@ -36,16 +36,6 @@ using namespace WebCore;
 
 namespace WebKit {
 
-static const float shadowOffsetX = 0.0;
-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;
-
 PassOwnPtr<FindPageOverlay> FindPageOverlay::create(FindController* findController)
 {
     return adoptPtr(new FindPageOverlay(findController));
@@ -62,100 +52,14 @@ FindPageOverlay::~FindPageOverlay()
     m_findController->findPageOverlayDestroyed();
 }
 
-Vector<IntRect> FindPageOverlay::rectsForTextMatches()
-{
-    Vector<IntRect> rects;
-
-    for (Frame* frame = webPage()->corePage()->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
-        Document* document = frame->document();
-        if (!document)
-            continue;
-
-        IntRect visibleRect = frame->view()->visibleContentRect();
-        Vector<IntRect> frameRects = document->markers()->renderedRectsForMarkers(DocumentMarker::TextMatch);
-        IntPoint frameOffset(-frame->view()->scrollOffset().width(), -frame->view()->scrollOffset().height());
-        frameOffset = frame->view()->convertToContainingWindow(frameOffset);
-
-        for (Vector<IntRect>::iterator it = frameRects.begin(), end = frameRects.end(); it != end; ++it) {
-            it->intersect(visibleRect);
-            it->move(frameOffset.x(), frameOffset.y());
-            rects.append(*it);
-        }
-    }
-
-    return rects;
-}
-
-IntRect FindPageOverlay::bounds() const
-{
-    FrameView* frameView = webPage()->corePage()->mainFrame()->view();
-
-    int width = frameView->width();
-    if (frameView->verticalScrollbar())
-        width -= frameView->verticalScrollbar()->width();
-    int height = frameView->height();
-    if (frameView->horizontalScrollbar())
-        height -= frameView->horizontalScrollbar()->height();
-    
-    return IntRect(0, 0, width, height);
-}
-
-static Color overlayBackgroundColor()
-{
-    return Color(overlayBackgroundRed, overlayBackgroundGreen, overlayBackgroundBlue, overlayBackgroundAlpha);
-}
-
-void FindPageOverlay::drawRect(PageOverlay*, GraphicsContext& graphicsContext, const IntRect& dirtyRect)
+void FindPageOverlay::drawRect(PageOverlay* pageOverlay, GraphicsContext& graphicsContext, const IntRect& dirtyRect)
 {
-    Vector<IntRect> rects = rectsForTextMatches();
-    ASSERT(!rects.isEmpty());
-
-    IntRect paintRect = intersection(dirtyRect, bounds());
-    if (paintRect.isEmpty())
-        return;
-
-    graphicsContext.beginTransparencyLayer(1);
-    graphicsContext.setCompositeOperation(CompositeCopy);
-
-    // Draw the background.
-    graphicsContext.fillRect(paintRect, overlayBackgroundColor(), ColorSpaceSRGB);
-
-    graphicsContext.save();
-    graphicsContext.setShadow(FloatSize(shadowOffsetX, shadowOffsetY), shadowBlurRadius, Color::black, ColorSpaceSRGB);
-
-    graphicsContext.setFillColor(Color::white, ColorSpaceSRGB);
-
-    // Draw white frames around the holes.
-    for (size_t i = 0; i < rects.size(); ++i) {
-        IntRect whiteFrameRect = rects[i];
-        whiteFrameRect.inflate(1);
-
-        graphicsContext.fillRect(whiteFrameRect);
-    }
-
-    graphicsContext.restore();
-
-    graphicsContext.save();
-    graphicsContext.setFillColor(Color::transparent, ColorSpaceSRGB);
-
-    // Clear out the holes.
-    for (size_t i = 0; i < rects.size(); ++i)
-        graphicsContext.fillRect(rects[i]);
-
-    graphicsContext.restore();
-    graphicsContext.endTransparencyLayer();
+    m_findController->drawRect(pageOverlay, graphicsContext, dirtyRect);
 }
 
-bool FindPageOverlay::mouseEvent(PageOverlay*, const WebMouseEvent& event)
+bool FindPageOverlay::mouseEvent(PageOverlay* pageOverlay, const WebMouseEvent& event)
 {
-    // If we get a mouse down event inside the page overlay we should hide the find UI.
-    if (event.type() == WebEvent::MouseDown && bounds().contains(event.position())) {
-        // Dismiss the overlay.
-        m_findController->hideFindUI();
-        return false;
-    }
-
-    return false;
+    return m_findController->mouseEvent(pageOverlay, event);
 }
 
 } // namespace WebKit
diff --git a/WebKit2/WebProcess/WebPage/FindPageOverlay.h b/WebKit2/WebProcess/WebPage/FindPageOverlay.h
index 36cee32..7c64ccb 100644
--- a/WebKit2/WebProcess/WebPage/FindPageOverlay.h
+++ b/WebKit2/WebProcess/WebPage/FindPageOverlay.h
@@ -42,9 +42,6 @@ public:
 private:
     explicit FindPageOverlay(FindController*);
 
-    Vector<WebCore::IntRect> rectsForTextMatches();
-    WebCore::IntRect bounds() const;
-
     // PageOverlay::Client.
     virtual void drawRect(PageOverlay*, WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRect);
     virtual bool mouseEvent(PageOverlay*, const WebMouseEvent&);
diff --git a/WebKit2/WebProcess/WebPage/PageOverlay.cpp b/WebKit2/WebProcess/WebPage/PageOverlay.cpp
index d47b841..4aad8b2 100644
--- a/WebKit2/WebProcess/WebPage/PageOverlay.cpp
+++ b/WebKit2/WebProcess/WebPage/PageOverlay.cpp
@@ -26,6 +26,9 @@
 #include "PageOverlay.h"
 
 #include "WebPage.h"
+#include <WebCore/Frame.h>
+#include <WebCore/FrameView.h>
+#include <WebCore/Page.h>
 
 using namespace WebCore;
 
@@ -46,6 +49,20 @@ PageOverlay::~PageOverlay()
 {
 }
 
+IntRect PageOverlay::bounds() const
+{
+    FrameView* frameView = webPage()->corePage()->mainFrame()->view();
+
+    int width = frameView->width();
+    if (frameView->verticalScrollbar())
+        width -= frameView->verticalScrollbar()->width();
+    int height = frameView->height();
+    if (frameView->horizontalScrollbar())
+        height -= frameView->horizontalScrollbar()->height();
+    
+    return IntRect(0, 0, width, height);
+}
+
 void PageOverlay::setPage(WebPage* webPage)
 {
     ASSERT(!m_webPage);
@@ -61,11 +78,20 @@ void PageOverlay::setNeedsDisplay()
 
 void PageOverlay::drawRect(GraphicsContext& graphicsContext, const IntRect& dirtyRect)
 {
-    m_client->drawRect(this, graphicsContext, dirtyRect);
+    // If the dirty rect is outside the bounds, ignore it.
+    IntRect paintRect = intersection(dirtyRect, bounds());
+    if (paintRect.isEmpty())
+        return;
+    
+    m_client->drawRect(this, graphicsContext, paintRect);
 }
     
 bool PageOverlay::mouseEvent(const WebMouseEvent& mouseEvent)
 {
+    // Ignore events outside the bounds.
+    if (!bounds().contains(mouseEvent.position()))
+        return false;
+
     return m_client->mouseEvent(this, mouseEvent);
 }
 
diff --git a/WebKit2/WebProcess/WebPage/PageOverlay.h b/WebKit2/WebProcess/WebPage/PageOverlay.h
index 05c5f4f..f68d508 100644
--- a/WebKit2/WebProcess/WebPage/PageOverlay.h
+++ b/WebKit2/WebProcess/WebPage/PageOverlay.h
@@ -52,7 +52,7 @@ public:
 
     static PassRefPtr<PageOverlay> create(Client*);
     virtual ~PageOverlay();
-    
+
     void setPage(WebPage*);
     void setNeedsDisplay();
 
@@ -65,6 +65,8 @@ protected:
     WebPage* webPage() const { return m_webPage; }
 
 private:
+    WebCore::IntRect bounds() const;
+
     Client* m_client;
 
     WebPage* m_webPage;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list