Changeset 106357 in webkit


Ignore:
Timestamp:
Jan 31, 2012 6:28:13 AM (12 years ago)
Author:
kenneth@webkit.org
Message:

Tap highlighting: Support better outlines for multiline inlines https://bugs.webkit.org/show_bug.cgi?id=77428

Reviewed by Simon Hausmann.

.:

Update the test to use a transform.

  • ManualTests/qt/tap-highlighting-inlines.html:

Source/WebCore:

Covered by manual tests.

Do not use the linesBoundingBox anymore but draw a custom path
with rounded corners. Inlines are drawn as max 3 rects, first
line rect, joined middle rect and the rect for the last line.

  • page/GestureTapHighlighter.cpp:
  • platform/graphics/Path.h: Make addBeziersForRoundedRect public.
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r106346 r106357  
     12012-01-31  Kenneth Rohde Christiansen  <kenneth@webkit.org>
     2
     3        Tap highlighting: Support better outlines for multiline inlines
     4        https://bugs.webkit.org/show_bug.cgi?id=77428
     5
     6        Reviewed by Simon Hausmann.
     7
     8        Update the test to use a transform.
     9
     10        * ManualTests/qt/tap-highlighting-inlines.html:
     11
    1122012-01-31  Nayan Kumar K  <nayankk@motorola.com>
    213
  • trunk/ManualTests/qt/tap-highlighting-inlines.html

    r106241 r106357  
    11<body>
    2     <p style="width: 10em; background-color: gray">
     2    <p style="position:absolute; left:100px; top:20px; width: 10em; -webkit-transform: rotate(30deg)">
    33    <a href="">some link</a><br><br>
    44    <a href="">some link breaking lines</a><br><br>
  • trunk/Source/WebCore/ChangeLog

    r106354 r106357  
     12012-01-31  Kenneth Rohde Christiansen  <kenneth@webkit.org>
     2
     3        Tap highlighting: Support better outlines for multiline inlines
     4        https://bugs.webkit.org/show_bug.cgi?id=77428
     5
     6        Reviewed by Simon Hausmann.
     7
     8        Covered by manual tests.
     9
     10        Do not use the linesBoundingBox anymore but draw a custom path
     11        with rounded corners. Inlines are drawn as max 3 rects, first
     12        line rect, joined middle rect and the rect for the last line.
     13
     14        * page/GestureTapHighlighter.cpp:
     15        * platform/graphics/Path.h: Make addBeziersForRoundedRect public.
     16
    1172012-01-31  Alexei Filippov  <alexeif@chromium.org>
    218
  • trunk/Source/WebCore/page/GestureTapHighlighter.cpp

    r105893 r106357  
    4747namespace {
    4848
    49 inline LayoutSize ownerFrameToMainFrameOffset(const RenderObject* o)
     49inline LayoutPoint ownerFrameToMainFrameOffset(const RenderObject* o)
    5050{
    5151    ASSERT(o->node());
    5252    Frame* containingFrame = o->frame();
    5353    if (!containingFrame)
    54         return LayoutSize();
     54        return LayoutPoint();
    5555
    5656    Frame* mainFrame = containingFrame->page()->mainFrame();
    5757
    5858    LayoutPoint mainFramePoint = mainFrame->view()->rootViewToContents(containingFrame->view()->contentsToRootView(LayoutPoint()));
    59     return toLayoutSize(mainFramePoint);
     59    return mainFramePoint;
    6060}
    6161
     
    8585{
    8686    ASSERT(o);
     87    const int rounding = 4;
    8788
    8889    LayoutRect contentBox;
     
    103104
    104105    FloatRect rect(borderBox);
    105     rect.inflate(5);
    106 
    107     rect.move(ownerFrameToMainFrameOffset(o));
     106    rect.inflate(rounding);
     107
     108    rect.move(toLayoutSize(ownerFrameToMainFrameOffset(o)));
    108109
    109110    Path path;
    110     path.addRoundedRect(rect, FloatSize(10, 10));
     111    FloatSize rounded(rounding * 1.8, rounding * 1.8);
     112    path.addRoundedRect(rect, rounded);
    111113
    112114    return path;
    113115}
    114116
     117void addRectWithRoundedCorners(Path& path, const LayoutRect& rect, bool topLeft, bool topRight, bool bottomLeft, bool bottomRight)
     118{
     119    const int rounding = 4;
     120
     121    FloatRect copy(rect);
     122    copy.inflateX(rounding);
     123    copy.inflateY(rounding / 2);
     124
     125    FloatSize rounded(rounding * 1.8, rounding * 1.8);
     126    FloatSize squared(0, 0);
     127
     128    path.addBeziersForRoundedRect(copy,
     129            topLeft ? rounded : squared, topRight ? rounded : squared,
     130            bottomLeft ? rounded : squared, bottomRight ? rounded : squared);
     131}
     132
     133inline bool contains(LayoutRect rect, int x)
     134{
     135    return !rect.isEmpty() && x >= rect.x() && x <= rect.maxX();
     136}
     137
    115138Path pathForRenderInline(RenderInline* o)
    116139{
    117     // FIXME: Adapt this to not just use the bounding box.
    118     LayoutRect borderBox = o->linesBoundingBox();
    119 
    120     FloatRect rect(borderBox);
    121     rect.inflate(5);
    122 
    123     rect.move(ownerFrameToMainFrameOffset(o));
    124 
     140    ASSERT(o);
    125141    Path path;
    126     path.addRoundedRect(rect, FloatSize(10, 10));
     142
     143    Vector<LayoutRect> rects;
     144    o->absoluteRects(rects, /* acc. offset */ ownerFrameToMainFrameOffset(o));
     145
     146    LayoutRect first = rects.size() ? rects.first() : LayoutRect();
     147    LayoutRect last = rects.size() > 1 ? rects.last() : LayoutRect();
     148    LayoutRect middle;
     149    for (int i = 1; i < rects.size() - 1; ++i)
     150        middle.uniteIfNonZero(rects.at(i));
     151
     152    if (!middle.isEmpty()) {
     153        int leftSide = middle.x();
     154        int rightSide = middle.maxX();
     155
     156        if (!first.isEmpty()) {
     157            leftSide = std::min(leftSide, first.x());
     158            rightSide = std::max(rightSide, first.maxX());
     159        }
     160        if (!last.isEmpty()) {
     161            leftSide = std::min(leftSide, last.x());
     162            rightSide = std::max(rightSide, last.maxX());
     163        }
     164
     165        middle.setX(leftSide);
     166        middle.setWidth(rightSide - leftSide);
     167    }
     168
     169    if (!first.isEmpty()) {
     170        bool roundBottomLeft = !contains(middle, first.x()) && !contains(last, first.x());
     171        bool roundBottomRight = !contains(middle, first.maxX()) && !contains(last, first.maxX());
     172        addRectWithRoundedCorners(path, first, /* roundTopLeft */ true, /* roundTopRight */ true, roundBottomLeft, roundBottomRight);
     173    }
     174
     175    if (!middle.isEmpty()) {
     176        bool roundTopLeft = !contains(first, middle.x());
     177        bool roundBottomRight = !contains(last, middle.maxX());
     178        addRectWithRoundedCorners(path, middle, roundTopLeft, /* roundTopRight */ false, /* roundBottomLeft */ false, roundBottomRight);
     179    }
     180
     181    if (!last.isEmpty()) {
     182        bool roundTopLeft = !contains(middle, last.x()) && !contains(first, last.x());
     183        bool roundTopRight = !contains(middle, last.maxX()) && !contains(first, last.maxX());
     184        addRectWithRoundedCorners(path, last, roundTopLeft, roundTopRight, /* roundBottomLeft */ true, /* roundBottomRight */ true);
     185    }
    127186
    128187    return path;
  • trunk/Source/WebCore/platform/graphics/Path.h

    r104585 r106357  
    147147        void transform(const AffineTransform&);
    148148
    149     private:
    150149        void addBeziersForRoundedRect(const FloatRect&, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius);
    151150
     151    private:
    152152        PlatformPathPtr m_path;
    153153    };
Note: See TracChangeset for help on using the changeset viewer.