Changeset 69625 in webkit


Ignore:
Timestamp:
Oct 12, 2010 6:05:41 PM (14 years ago)
Author:
andersca@apple.com
Message:

Paint the find overlay background
https://bugs.webkit.org/show_bug.cgi?id=47565

Reviewed by Dan Bernstein.

WebCore:

Export symbols required by WebKit2.

  • WebCore.exp.in:

WebKit2:

  • WebProcess/WebPage/FindController.cpp:

(WebKit::FindController::findString):
Don't show the overlay if we have too many matches.

  • WebProcess/WebPage/FindPageOverlay.cpp:

(WebKit::FindPageOverlay::rectsForTextMatches):
Get the rects for all text matches.

(WebKit::FindPageOverlay::drawRect):
Assert that we're only being called if there are any text matches.
Paint the background.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r69624 r69625  
     12010-10-12  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        Paint the find overlay background
     6        https://bugs.webkit.org/show_bug.cgi?id=47565
     7
     8        Export symbols required by WebKit2.
     9
     10        * WebCore.exp.in:
     11
    1122010-10-12  James Robinson  <jamesr@chromium.org>
    213
  • trunk/WebCore/WebCore.exp.in

    r69598 r69625  
    347347__ZN7WebCore15FocusController9setActiveEb
    348348__ZN7WebCore15GraphicsContext12setFillColorERKNS_5ColorENS_10ColorSpaceE
     349__ZN7WebCore15GraphicsContext20endTransparencyLayerEv
     350__ZN7WebCore15GraphicsContext21setCompositeOperationENS_17CompositeOperatorE
     351__ZN7WebCore15GraphicsContext22beginTransparencyLayerEf
    349352__ZN7WebCore15GraphicsContext4clipERKNS_9FloatRectE
    350353__ZN7WebCore15GraphicsContext4saveEv
     354__ZN7WebCore15GraphicsContext8fillRectERKNS_9FloatRectERKNS_5ColorENS_10ColorSpaceE
    351355__ZN7WebCore15GraphicsContext7restoreEv
    352356__ZN7WebCore15GraphicsContext9translateEff
     
    10591063__ZNK7WebCore6Widget25convertFromContainingViewERKNS_8IntPointE
    10601064__ZNK7WebCore6Widget25convertToContainingWindowERKNS_7IntRectE
     1065__ZNK7WebCore6Widget25convertToContainingWindowERKNS_8IntPointE
    10611066__ZNK7WebCore6Widget9frameRectEv
    10621067__ZNK7WebCore7Element12getAttributeERKNS_13QualifiedNameE
  • trunk/WebKit2/ChangeLog

    r69621 r69625  
     12010-10-12  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        Paint the find overlay background
     6        https://bugs.webkit.org/show_bug.cgi?id=47565
     7
     8        * WebProcess/WebPage/FindController.cpp:
     9        (WebKit::FindController::findString):
     10        Don't show the overlay if we have too many matches.
     11
     12        * WebProcess/WebPage/FindPageOverlay.cpp:
     13        (WebKit::FindPageOverlay::rectsForTextMatches):
     14        Get the rects for all text matches.
     15
     16        (WebKit::FindPageOverlay::drawRect):
     17        Assert that we're only being called if there are any text matches.
     18        Paint the background.
     19
    1202010-10-12  Sam Weinig  <sam@webkit.org>
    221
  • trunk/WebKit2/WebProcess/WebPage/FindController.cpp

    r69616 r69625  
    5353void FindController::findString(const String& string, FindDirection findDirection, FindOptions findOptions, unsigned maxNumMatches)
    5454{
    55     bool found = m_webPage->corePage()->findString(string, (findOptions & FindOptionsCaseInsensitive) ? TextCaseInsensitive : TextCaseSensitive,
     55    TextCaseSensitivity caseSensitivity = findOptions & FindOptionsCaseInsensitive ? TextCaseInsensitive : TextCaseSensitive;
     56    bool found = m_webPage->corePage()->findString(string, caseSensitivity,
    5657                                                   findDirection == FindDirectionForward ? WebCore::FindDirectionForward : WebCore::FindDirectionBackward,
    5758                                                   findOptions & FindOptionsWrapAround);
     
    6970            selectedFrame->selection()->clear();
    7071    } else {
    71         // FIXME: We need to show the find indicator here.
     72        shouldShowOverlay = findOptions & FindOptionsShowOverlay;
    7273
    73         shouldShowOverlay = findOptions & FindOptionsShowOverlay;
     74        if (shouldShowOverlay) {
     75            unsigned numMatches = m_webPage->corePage()->markAllMatchesForText(string, caseSensitivity, false, maxNumMatches);
     76
     77            // Check if we have more matches than allowed.
     78            if (numMatches > maxNumMatches)
     79                shouldShowOverlay = false;
     80        }
    7481    }
    7582
  • trunk/WebKit2/WebProcess/WebPage/FindPageOverlay.cpp

    r69616 r69625  
    2727
    2828#include "FindController.h"
     29#include "WebPage.h"
     30#include <WebCore/Frame.h>
     31#include <WebCore/FrameView.h>
    2932#include <WebCore/GraphicsContext.h>
     33#include <WebCore/Page.h>
    3034
    3135using namespace WebCore;
     
    4852}
    4953
     54Vector<IntRect> FindPageOverlay::rectsForTextMatches()
     55{
     56    Vector<IntRect> rects;
     57
     58    for (Frame* frame = webPage()->corePage()->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
     59        Document* document = frame->document();
     60        if (!document)
     61            continue;
     62
     63        IntRect visibleRect = frame->view()->visibleContentRect();
     64        Vector<IntRect> frameRects = document->markers()->renderedRectsForMarkers(DocumentMarker::TextMatch);
     65        IntPoint frameOffset(-frame->view()->scrollOffset().width(), -frame->view()->scrollOffset().height());
     66        frameOffset = frame->view()->convertToContainingWindow(frameOffset);
     67
     68        for (Vector<IntRect>::iterator it = frameRects.begin(), end = frameRects.end(); it != end; ++it) {
     69            it->intersect(visibleRect);
     70            it->move(frameOffset.x(), frameOffset.y());
     71            rects.append(*it);
     72        }
     73    }
     74
     75    return rects;
     76}
     77
     78static const int overlayBackgroundRed = 25;
     79static const int overlayBackgroundGreen = 25;
     80static const int overlayBackgroundBlue = 25;
     81static const int overlayBackgroundAlpha = 63;
     82   
     83static Color overlayBackgroundColor()
     84{
     85    return Color(overlayBackgroundRed, overlayBackgroundGreen, overlayBackgroundBlue, overlayBackgroundAlpha);
     86}
     87   
    5088void FindPageOverlay::drawRect(GraphicsContext& graphicsContext, const IntRect& dirtyRect)
    5189{
    52     // FIXME: Draw something.
     90    Vector<IntRect> rects = rectsForTextMatches();
     91    ASSERT(!rects.isEmpty());
     92
     93    FrameView* frameView = webPage()->corePage()->mainFrame()->view();
     94
     95    int width = frameView->width();
     96    if (frameView->verticalScrollbar())
     97        width -= frameView->verticalScrollbar()->width();
     98    int height = frameView->height();
     99    if (frameView->horizontalScrollbar())
     100        height -= frameView->horizontalScrollbar()->height();
     101   
     102    IntRect paintRect = intersection(dirtyRect, IntRect(0, 0, width, height));
     103    if (paintRect.isEmpty())
     104        return;
     105
     106    graphicsContext.beginTransparencyLayer(1);
     107    graphicsContext.setCompositeOperation(CompositeCopy);
     108
     109    // Draw the background.
     110    graphicsContext.fillRect(paintRect, overlayBackgroundColor(), sRGBColorSpace);
     111
     112    // FIXME: Draw the holes.
     113
     114    graphicsContext.endTransparencyLayer();
    53115}
    54116
    55 
    56117} // namespace WebKit
  • trunk/WebKit2/WebProcess/WebPage/FindPageOverlay.h

    r69616 r69625  
    2929#include "PageOverlay.h"
    3030#include <wtf/PassOwnPtr.h>
     31#include <wtf/Vector.h>
    3132
    3233namespace WebKit {
     
    4243    explicit FindPageOverlay(FindController*);
    4344
     45    Vector<WebCore::IntRect> rectsForTextMatches();
     46
    4447    // PageOverlay.
    4548    virtual void drawRect(WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRect);
  • trunk/WebKit2/WebProcess/WebPage/PageOverlay.h

    r69616 r69625  
    5151    PageOverlay();
    5252
     53    WebPage* webPage() const { return m_webPage; }
     54
    5355private:
    5456    WebPage* m_webPage;
Note: See TracChangeset for help on using the changeset viewer.