Changeset 103677 in webkit


Ignore:
Timestamp:
Dec 25, 2011 9:20:02 PM (12 years ago)
Author:
mitz@apple.com
Message:

../WebCore: WebCore changes for: Find indicators overlap when a match spans multiple text boxes
https://bugs.webkit.org/show_bug.cgi?id=75220

Reviewed by Darin Adler.

  • WebCore.exp.in: Exported new unionRect(const Vector<FloatRect>&) and existing

FloatRect::intersects().

  • platform/graphics/FloatRect.cpp:

(WebCore::unionRect): Added.

  • platform/graphics/FloatRect.h:

../WebKit2: Find indicators overlap when a match spans multiple text boxes
https://bugs.webkit.org/show_bug.cgi?id=75220

Reviewed by Darin Adler.

  • UIProcess/FindIndicator.cpp:

(WebKit::findIndicatorsForTextRectsOverlap): Added this helper function that checks for
pairwise intersections between all indicator rects.
(WebKit::FindIndicator::FindIndicator): Changed to use a single rect (the union of all text
rects) if any two indicator rects would otherwise overlap. This is similar to what Safari
does, and it eliminates overlapping rects for adjacent text boxes. In rare cases (such as when
a match spans two lines and adjacent text boxes on one of those lines) it results in a find
indicator that is too large and obscures some non-match text.

  • UIProcess/FindIndicator.h:
Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r103676 r103677  
     12011-12-25  Dan Bernstein  <mitz@apple.com>
     2
     3        WebCore changes for: Find indicators overlap when a match spans multiple text boxes
     4        https://bugs.webkit.org/show_bug.cgi?id=75220
     5
     6        Reviewed by Darin Adler.
     7
     8        * WebCore.exp.in: Exported new unionRect(const Vector<FloatRect>&) and existing
     9        FloatRect::intersects().
     10        * platform/graphics/FloatRect.cpp:
     11        (WebCore::unionRect): Added.
     12        * platform/graphics/FloatRect.h:
     13
    1142011-12-25  Darin Adler  <darin@apple.com>
    215
  • trunk/Source/WebCore/WebCore.exp.in

    r103643 r103677  
    11161116__ZN7WebCore9plainTextEPKNS_5RangeENS_20TextIteratorBehaviorE
    11171117__ZN7WebCore9toElementEN3JSC7JSValueE
     1118__ZN7WebCore9unionRectERKN3WTF6VectorINS_9FloatRectELm0EEE
    11181119__ZNK3JSC8Bindings10RootObject12globalObjectEv
    11191120__ZNK3WTF6String14createCFStringEv
     
    14241425__ZNK7WebCore9DOMWindow27pendingUnloadEventListenersEv
    14251426__ZNK7WebCore9FloatQuad11boundingBoxEv
     1427__ZNK7WebCore9FloatRect10intersectsERKS0_
    14261428__ZNK7WebCore9FloatRectcv7_NSRectEv
    14271429__ZNK7WebCore9FrameTree12traverseNextEPKNS_5FrameE
  • trunk/Source/WebCore/platform/graphics/FloatRect.cpp

    r101517 r103677  
    138138}
    139139
     140FloatRect unionRect(const Vector<FloatRect>& rects)
     141{
     142    FloatRect result;
     143
     144    size_t count = rects.size();
     145    for (size_t i = 0; i < count; ++i)
     146        result.unite(rects[i]);
     147
     148    return result;
     149}
     150
    140151void FloatRect::fitToPoints(const FloatPoint& p0, const FloatPoint& p1)
    141152{
  • trunk/Source/WebCore/platform/graphics/FloatRect.h

    r101517 r103677  
    2929
    3030#include "FloatPoint.h"
     31#include <wtf/Vector.h>
    3132
    3233#if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM)
     
    240241}
    241242
     243FloatRect unionRect(const Vector<FloatRect>&);
     244
    242245inline FloatRect& operator+=(FloatRect& a, const FloatRect& b)
    243246{
  • trunk/Source/WebKit2/ChangeLog

    r103643 r103677  
     12011-12-25  Dan Bernstein  <mitz@apple.com>
     2
     3        Find indicators overlap when a match spans multiple text boxes
     4        https://bugs.webkit.org/show_bug.cgi?id=75220
     5
     6        Reviewed by Darin Adler.
     7
     8        * UIProcess/FindIndicator.cpp:
     9        (WebKit::findIndicatorsForTextRectsOverlap): Added this helper function that checks for
     10        pairwise intersections between all indicator rects.
     11        (WebKit::FindIndicator::FindIndicator): Changed to use a single rect (the union of all text
     12        rects) if any two indicator rects would otherwise overlap. This is similar to what Safari
     13        does, and it eliminates overlapping rects for adjacent text boxes. In rare cases (such as when
     14        a match spans two lines and adjacent text boxes on one of those lines) it results in a find
     15        indicator that is too large and obscures some non-match text.
     16        * UIProcess/FindIndicator.h:
     17
    1182011-12-21  Sam Weinig  <sam@webkit.org>
    219
  • trunk/Source/WebKit2/UIProcess/FindIndicator.cpp

    r95901 r103677  
    8888}
    8989
     90static bool findIndicatorsForTextRectsOverlap(const Vector<FloatRect>& textRects)
     91{
     92    size_t count = textRects.size();
     93    if (count <= 1)
     94        return false;
     95
     96    Vector<FloatRect> indicatorRects;
     97    indicatorRects.reserveInitialCapacity(count);
     98
     99    for (size_t i = 0; i < count; ++i) {
     100        FloatRect indicatorRect = textRects[i];
     101        indicatorRect.move(-leftBorderThickness, -topBorderThickness);
     102        indicatorRect.expand(leftBorderThickness + rightBorderThickness, topBorderThickness + bottomBorderThickness);
     103
     104        for (size_t j = indicatorRects.size(); j; ) {
     105            --j;
     106            if (indicatorRect.intersects(indicatorRects[j]))
     107                return true;
     108        }
     109
     110        indicatorRects.uncheckedAppend(indicatorRect);
     111    }
     112
     113    return false;
     114}
     115
    90116FindIndicator::FindIndicator(const WebCore::FloatRect& selectionRectInWindowCoordinates, const Vector<WebCore::FloatRect>& textRectsInSelectionRectCoordinates, float contentImageScaleFactor, PassRefPtr<ShareableBitmap> contentImage)
    91117    : m_selectionRectInWindowCoordinates(selectionRectInWindowCoordinates)
     
    94120    , m_contentImage(contentImage)
    95121{
     122    if (findIndicatorsForTextRectsOverlap(m_textRectsInSelectionRectCoordinates)) {
     123        m_textRectsInSelectionRectCoordinates[0] = unionRect(m_textRectsInSelectionRectCoordinates);
     124        m_textRectsInSelectionRectCoordinates.shrink(1);
     125    }
    96126}
    97127
  • trunk/Source/WebKit2/UIProcess/FindIndicator.h

    r95901 r103677  
    4747    WebCore::FloatRect frameRect() const;
    4848
    49     const Vector<WebCore::FloatRect>& textRects() const { return m_textRectsInSelectionRectCoordinates; }
    50 
    5149    ShareableBitmap* contentImage() const { return m_contentImage.get(); }
    5250
Note: See TracChangeset for help on using the changeset viewer.