Title: [129643] trunk/Source/WebCore
Revision
129643
Author
[email protected]
Date
2012-09-26 07:35:37 -0700 (Wed, 26 Sep 2012)

Log Message

Gesture tap highlighting entire first line
https://bugs.webkit.org/show_bug.cgi?id=97668

Patch by Allan Sandfeld Jensen <[email protected]> on 2012-09-26
Reviewed by Kenneth Rohde Christiansen.

Keep better track if which part is the first, middle or last, and adjust the X-edges accordingly.

* page/GestureTapHighlighter.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (129642 => 129643)


--- trunk/Source/WebCore/ChangeLog	2012-09-26 14:35:15 UTC (rev 129642)
+++ trunk/Source/WebCore/ChangeLog	2012-09-26 14:35:37 UTC (rev 129643)
@@ -1,3 +1,14 @@
+2012-09-26  Allan Sandfeld Jensen  <[email protected]>
+
+        Gesture tap highlighting entire first line
+        https://bugs.webkit.org/show_bug.cgi?id=97668
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Keep better track if which part is the first, middle or last, and adjust the X-edges accordingly.
+
+        * page/GestureTapHighlighter.cpp:
+
 2012-09-26  Vsevolod Vlasov  <[email protected]>
 
         Web Inspector: DefaultTextEditor throws exception sometimes.

Modified: trunk/Source/WebCore/page/GestureTapHighlighter.cpp (129642 => 129643)


--- trunk/Source/WebCore/page/GestureTapHighlighter.cpp	2012-09-26 14:35:15 UTC (rev 129642)
+++ trunk/Source/WebCore/page/GestureTapHighlighter.cpp	2012-09-26 14:35:37 UTC (rev 129643)
@@ -93,20 +93,24 @@
         && a.y() <= b.maxY() && b.y() <= a.maxY();
 }
 
-inline void shiftXEdgesToContainIfStrikes(LayoutRect& rect, const LayoutRect& other)
+inline void shiftXEdgesToContainIfStrikes(LayoutRect& rect, LayoutRect& other, bool isFirst)
 {
     if (rect.isEmpty())
         return;
-    LayoutUnit leftSide = rect.x();
-    LayoutUnit rightSide = rect.maxX();
 
-    if (!other.isEmpty() && strikes(rect, other)) {
-        leftSide = std::min(leftSide, other.x());
-        rightSide = std::max(rightSide, other.maxX());
-    }
+    if (other.isEmpty() || !strikes(rect, other))
+        return;
 
-    rect.setX(leftSide);
-    rect.setWidth(rightSide - leftSide);
+    LayoutUnit leftSide = std::min(rect.x(), other.x());
+    LayoutUnit rightSide = std::max(rect.maxX(), other.maxX());
+
+    rect.shiftXEdgeTo(leftSide);
+    rect.shiftMaxXEdgeTo(rightSide);
+
+    if (isFirst)
+        other.shiftMaxXEdgeTo(rightSide);
+    else
+        other.shiftXEdgeTo(leftSide);
 }
 
 inline void addHighlightRect(Path& path, const LayoutRect& rect, const LayoutRect& prev, const LayoutRect& next)
@@ -158,33 +162,38 @@
     for (int i = 1; i < end; ++i)
         mid.uniteIfNonZero(rects.at(i));
 
-    Vector<LayoutRect> drawableRects;
+    LayoutRect first;
+    LayoutRect last;
 
-    if (!mid.isEmpty())
-        drawableRects.append(mid);
-
     // Add the first box, but merge it with the center boxes if it intersects.
     if (rects.size() && !rects.first().isEmpty()) {
-        // Adjust center boxes to boundary of first
-        if (drawableRects.size())
-            shiftXEdgesToContainIfStrikes(drawableRects.last(), rects.first());
-        if (drawableRects.size() && drawableRects.last().intersects(rects.first()))
-            drawableRects.last().unite(rects.first());
-        else
-            drawableRects.prepend(rects.first());
+        if (!mid.isEmpty() && mid.intersects(rects.first()))
+            mid.unite(rects.first());
+        else {
+            first = rects.first();
+            shiftXEdgesToContainIfStrikes(mid, first, /* isFirst */ true);
+        }
     }
 
     // Add the last box, but merge it with the center boxes if it intersects.
     if (rects.size() > 1 && !rects.last().isEmpty()) {
         // Adjust center boxes to boundary of last
-        if (drawableRects.size())
-            shiftXEdgesToContainIfStrikes(drawableRects.last(), rects.last());
-        if (drawableRects.size() && drawableRects.last().intersects(rects.last()))
-            drawableRects.last().unite(rects.last());
-        else
-            drawableRects.append(rects.last());
+        if (!mid.isEmpty() && mid.intersects(rects.last()))
+            mid.unite(rects.last());
+        else {
+            last = rects.last();
+            shiftXEdgesToContainIfStrikes(mid, last, /* isFirst */ false);
+        }
     }
 
+    Vector<LayoutRect> drawableRects;
+    if (!first.isEmpty())
+        drawableRects.append(first);
+    if (!mid.isEmpty())
+        drawableRects.append(mid);
+    if (!last.isEmpty())
+        drawableRects.append(last);
+
     // Clip the overflow rects if needed, before the ring path is formed to
     // ensure rounded highlight rects. This clipping has the problem with nested
     // divs with transforms, which could be resolved by proper Path::intersecting.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to