Title: [111689] trunk/Source/WebCore
Revision
111689
Author
le...@chromium.org
Date
2012-03-22 07:14:13 -0700 (Thu, 22 Mar 2012)

Log Message

Update LayoutUnit usage in FrameSelection
https://bugs.webkit.org/show_bug.cgi?id=81754

Reviewed by Eric Seidel.

FrameSelection stores its caret and repaint bounds in absolute coordinates. Absolute coordinates
we treat as pixel values, so this patch changes these values to integers. Sub-pixel precision
will still be used when these coordinates are passed down and used locally.

No new tests. No change in behavior.

* editing/FrameSelection.cpp:
(WebCore::absoluteCaretY): Uses absolute coordinates, which are ints.
(WebCore::FrameSelection::modify): Uses absolute coordinates to handle vertical selection
modification. Sub-pixel precision will be used when these values are converted to local ones.
(WebCore::CaretBase::absoluteBoundsForLocalRect): Absolute coordinates -> ints.
(WebCore::FrameSelection::absoluteCaretBounds): Ditto.
(WebCore::CaretBase::caretRepaintRect): The caret repaint rect is stored in absolute coordinates.
Reverting the values to ints.
(WebCore::FrameSelection::recomputeCaretRect): Ditto.
* editing/FrameSelection.h:
(FrameSelection):
* editing/mac/FrameSelectionMac.mm:
(WebCore::FrameSelection::notifyAccessibilityForSelectionChange): Switching to store absolute
coordinates as integers.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (111688 => 111689)


--- trunk/Source/WebCore/ChangeLog	2012-03-22 14:12:31 UTC (rev 111688)
+++ trunk/Source/WebCore/ChangeLog	2012-03-22 14:14:13 UTC (rev 111689)
@@ -1,3 +1,31 @@
+2012-03-22  Levi Weintraub  <le...@chromium.org>
+
+        Update LayoutUnit usage in FrameSelection
+        https://bugs.webkit.org/show_bug.cgi?id=81754
+
+        Reviewed by Eric Seidel.
+
+        FrameSelection stores its caret and repaint bounds in absolute coordinates. Absolute coordinates
+        we treat as pixel values, so this patch changes these values to integers. Sub-pixel precision
+        will still be used when these coordinates are passed down and used locally.
+
+        No new tests. No change in behavior.
+
+        * editing/FrameSelection.cpp:
+        (WebCore::absoluteCaretY): Uses absolute coordinates, which are ints.
+        (WebCore::FrameSelection::modify): Uses absolute coordinates to handle vertical selection
+        modification. Sub-pixel precision will be used when these values are converted to local ones.
+        (WebCore::CaretBase::absoluteBoundsForLocalRect): Absolute coordinates -> ints.
+        (WebCore::FrameSelection::absoluteCaretBounds): Ditto.
+        (WebCore::CaretBase::caretRepaintRect): The caret repaint rect is stored in absolute coordinates.
+        Reverting the values to ints.
+        (WebCore::FrameSelection::recomputeCaretRect): Ditto.
+        * editing/FrameSelection.h:
+        (FrameSelection):
+        * editing/mac/FrameSelectionMac.mm:
+        (WebCore::FrameSelection::notifyAccessibilityForSelectionChange): Switching to store absolute
+        coordinates as integers.
+
 2012-03-22  Alexei Filippov  <alex...@chromium.org>
 
         Web Inspector: Speed up the build retainers phase.

Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (111688 => 111689)


--- trunk/Source/WebCore/editing/FrameSelection.cpp	2012-03-22 14:12:31 UTC (rev 111688)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp	2012-03-22 14:14:13 UTC (rev 111689)
@@ -987,9 +987,9 @@
 }
 
 // FIXME: Maybe baseline would be better?
-static bool absoluteCaretY(const VisiblePosition &c, LayoutUnit &y)
+static bool absoluteCaretY(const VisiblePosition &c, int &y)
 {
-    LayoutRect rect = c.absoluteCaretBounds();
+    IntRect rect = c.absoluteCaretBounds();
     if (rect.isEmpty())
         return false;
     y = rect.y() + rect.height() / 2;
@@ -1028,12 +1028,12 @@
         break;
     }
 
-    LayoutUnit startY;
+    int startY;
     if (!absoluteCaretY(pos, startY))
         return false;
     if (direction == DirectionUp)
         startY = -startY;
-    LayoutUnit lastY = startY;
+    int lastY = startY;
 
     VisiblePosition result;
     VisiblePosition next;
@@ -1045,12 +1045,12 @@
 
         if (next.isNull() || next == p)
             break;
-        LayoutUnit nextY;
+        int nextY;
         if (!absoluteCaretY(next, nextY))
             break;
         if (direction == DirectionUp)
             nextY = -nextY;
-        if (nextY - startY > static_cast<LayoutUnit>(verticalDistance))
+        if (nextY - startY > static_cast<int>(verticalDistance))
             break;
         if (nextY >= lastY) {
             lastY = nextY;
@@ -1247,11 +1247,11 @@
     return localCaretRectWithoutUpdate();
 }
 
-LayoutRect CaretBase::absoluteBoundsForLocalRect(Node* node, const LayoutRect& rect) const
+IntRect CaretBase::absoluteBoundsForLocalRect(Node* node, const LayoutRect& rect) const
 {
     RenderObject* caretPainter = caretRenderer(node);
     if (!caretPainter)
-        return LayoutRect();
+        return IntRect();
     
     LayoutRect localRect(rect);
     if (caretPainter->isBox())
@@ -1259,7 +1259,7 @@
     return caretPainter->localToAbsoluteQuad(FloatRect(localRect)).enclosingBoundingBox();
 }
 
-LayoutRect FrameSelection::absoluteCaretBounds()
+IntRect FrameSelection::absoluteCaretBounds()
 {
     recomputeCaretRect();
     return m_absCaretBounds;
@@ -1275,7 +1275,7 @@
     return caret;
 }
 
-LayoutRect CaretBase::caretRepaintRect(Node* node) const
+IntRect CaretBase::caretRepaintRect(Node* node) const
 {
     return absoluteBoundsForLocalRect(node, repaintRectForCaret(localCaretRectWithoutUpdate()));
 }
@@ -1297,7 +1297,7 @@
     if (oldRect == newRect && !m_absCaretBoundsDirty)
         return false;
 
-    LayoutRect oldAbsCaretBounds = m_absCaretBounds;
+    IntRect oldAbsCaretBounds = m_absCaretBounds;
     // FIXME: Rename m_caretRect to m_localCaretRect.
     m_absCaretBounds = absoluteBoundsForLocalRect(m_selection.start().deprecatedNode(), localCaretRectWithoutUpdate());
     m_absCaretBoundsDirty = false;
@@ -1306,7 +1306,7 @@
         return false;
 
 #if ENABLE(TEXT_CARET)
-    LayoutRect oldAbsoluteCaretRepaintBounds = m_absoluteCaretRepaintBounds;
+    IntRect oldAbsoluteCaretRepaintBounds = m_absoluteCaretRepaintBounds;
 #endif
 
     // We believe that we need to inflate the local rect before transforming it to obtain the repaint bounds.

Modified: trunk/Source/WebCore/editing/FrameSelection.h (111688 => 111689)


--- trunk/Source/WebCore/editing/FrameSelection.h	2012-03-22 14:12:31 UTC (rev 111688)
+++ trunk/Source/WebCore/editing/FrameSelection.h	2012-03-22 14:14:13 UTC (rev 111689)
@@ -59,8 +59,8 @@
     void invalidateCaretRect(Node*, bool caretRectChanged = false);
     void clearCaretRect();
     bool updateCaretRect(Document*, const VisiblePosition& caretPosition);
-    LayoutRect absoluteBoundsForLocalRect(Node*, const LayoutRect&) const;
-    LayoutRect caretRepaintRect(Node*) const;
+    IntRect absoluteBoundsForLocalRect(Node*, const LayoutRect&) const;
+    IntRect caretRepaintRect(Node*) const;
     bool shouldRepaintCaret(const RenderView*, bool isContentEditable) const;
     void paintCaret(Node*, GraphicsContext*, const LayoutPoint&, const LayoutRect& clipRect) const;
     RenderObject* caretRenderer(Node*) const;
@@ -180,7 +180,7 @@
     LayoutRect localCaretRect();
 
     // Bounds of (possibly transformed) caret in absolute coords
-    LayoutRect absoluteCaretBounds();
+    IntRect absoluteCaretBounds();
     void setCaretRectNeedsUpdate() { CaretBase::setCaretRectNeedsUpdate(); }
 
     void willBeModified(EAlteration, SelectionDirection);
@@ -295,8 +295,10 @@
     RefPtr<EditingStyle> m_typingStyle;
 
     Timer<FrameSelection> m_caretBlinkTimer;
-    LayoutRect m_absCaretBounds; // absolute bounding rect for the caret
-    LayoutRect m_absoluteCaretRepaintBounds;
+    // The painted bounds of the caret in absolute coordinates
+    IntRect m_absCaretBounds;
+    // Similar to above, but inflated to ensure proper repaint (see https://bugs.webkit.org/show_bug.cgi?id=19086)
+    IntRect m_absoluteCaretRepaintBounds;
     bool m_absCaretBoundsDirty : 1;
     bool m_caretPaint : 1;
     bool m_isCaretBlinkingSuspended : 1;

Modified: trunk/Source/WebCore/editing/mac/FrameSelectionMac.mm (111688 => 111689)


--- trunk/Source/WebCore/editing/mac/FrameSelectionMac.mm	2012-03-22 14:12:31 UTC (rev 111688)
+++ trunk/Source/WebCore/editing/mac/FrameSelectionMac.mm	2012-03-22 14:14:13 UTC (rev 111689)
@@ -63,8 +63,8 @@
     if (!frameView)
         return;
 
-    LayoutRect selectionRect = absoluteCaretBounds();
-    LayoutRect viewRect = renderView->viewRect();
+    IntRect selectionRect = absoluteCaretBounds();
+    IntRect viewRect = pixelSnappedIntRect(renderView->viewRect());
 
     selectionRect = frameView->contentsToScreen(selectionRect);
     viewRect = frameView->contentsToScreen(viewRect);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to