Changeset 111689 in webkit


Ignore:
Timestamp:
Mar 22, 2012 7:14:13 AM (12 years ago)
Author:
leviw@chromium.org
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.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r111688 r111689  
     12012-03-22  Levi Weintraub  <leviw@chromium.org>
     2
     3        Update LayoutUnit usage in FrameSelection
     4        https://bugs.webkit.org/show_bug.cgi?id=81754
     5
     6        Reviewed by Eric Seidel.
     7
     8        FrameSelection stores its caret and repaint bounds in absolute coordinates. Absolute coordinates
     9        we treat as pixel values, so this patch changes these values to integers. Sub-pixel precision
     10        will still be used when these coordinates are passed down and used locally.
     11
     12        No new tests. No change in behavior.
     13
     14        * editing/FrameSelection.cpp:
     15        (WebCore::absoluteCaretY): Uses absolute coordinates, which are ints.
     16        (WebCore::FrameSelection::modify): Uses absolute coordinates to handle vertical selection
     17        modification. Sub-pixel precision will be used when these values are converted to local ones.
     18        (WebCore::CaretBase::absoluteBoundsForLocalRect): Absolute coordinates -> ints.
     19        (WebCore::FrameSelection::absoluteCaretBounds): Ditto.
     20        (WebCore::CaretBase::caretRepaintRect): The caret repaint rect is stored in absolute coordinates.
     21        Reverting the values to ints.
     22        (WebCore::FrameSelection::recomputeCaretRect): Ditto.
     23        * editing/FrameSelection.h:
     24        (FrameSelection):
     25        * editing/mac/FrameSelectionMac.mm:
     26        (WebCore::FrameSelection::notifyAccessibilityForSelectionChange): Switching to store absolute
     27        coordinates as integers.
     28
    1292012-03-22  Alexei Filippov  <alexeif@chromium.org>
    230
  • trunk/Source/WebCore/editing/FrameSelection.cpp

    r111079 r111689  
    988988
    989989// FIXME: Maybe baseline would be better?
    990 static bool absoluteCaretY(const VisiblePosition &c, LayoutUnit &y)
    991 {
    992     LayoutRect rect = c.absoluteCaretBounds();
     990static bool absoluteCaretY(const VisiblePosition &c, int &y)
     991{
     992    IntRect rect = c.absoluteCaretBounds();
    993993    if (rect.isEmpty())
    994994        return false;
     
    10291029    }
    10301030
    1031     LayoutUnit startY;
     1031    int startY;
    10321032    if (!absoluteCaretY(pos, startY))
    10331033        return false;
    10341034    if (direction == DirectionUp)
    10351035        startY = -startY;
    1036     LayoutUnit lastY = startY;
     1036    int lastY = startY;
    10371037
    10381038    VisiblePosition result;
     
    10461046        if (next.isNull() || next == p)
    10471047            break;
    1048         LayoutUnit nextY;
     1048        int nextY;
    10491049        if (!absoluteCaretY(next, nextY))
    10501050            break;
    10511051        if (direction == DirectionUp)
    10521052            nextY = -nextY;
    1053         if (nextY - startY > static_cast<LayoutUnit>(verticalDistance))
     1053        if (nextY - startY > static_cast<int>(verticalDistance))
    10541054            break;
    10551055        if (nextY >= lastY) {
     
    12481248}
    12491249
    1250 LayoutRect CaretBase::absoluteBoundsForLocalRect(Node* node, const LayoutRect& rect) const
     1250IntRect CaretBase::absoluteBoundsForLocalRect(Node* node, const LayoutRect& rect) const
    12511251{
    12521252    RenderObject* caretPainter = caretRenderer(node);
    12531253    if (!caretPainter)
    1254         return LayoutRect();
     1254        return IntRect();
    12551255   
    12561256    LayoutRect localRect(rect);
     
    12601260}
    12611261
    1262 LayoutRect FrameSelection::absoluteCaretBounds()
     1262IntRect FrameSelection::absoluteCaretBounds()
    12631263{
    12641264    recomputeCaretRect();
     
    12761276}
    12771277
    1278 LayoutRect CaretBase::caretRepaintRect(Node* node) const
     1278IntRect CaretBase::caretRepaintRect(Node* node) const
    12791279{
    12801280    return absoluteBoundsForLocalRect(node, repaintRectForCaret(localCaretRectWithoutUpdate()));
     
    12981298        return false;
    12991299
    1300     LayoutRect oldAbsCaretBounds = m_absCaretBounds;
     1300    IntRect oldAbsCaretBounds = m_absCaretBounds;
    13011301    // FIXME: Rename m_caretRect to m_localCaretRect.
    13021302    m_absCaretBounds = absoluteBoundsForLocalRect(m_selection.start().deprecatedNode(), localCaretRectWithoutUpdate());
     
    13071307
    13081308#if ENABLE(TEXT_CARET)
    1309     LayoutRect oldAbsoluteCaretRepaintBounds = m_absoluteCaretRepaintBounds;
     1309    IntRect oldAbsoluteCaretRepaintBounds = m_absoluteCaretRepaintBounds;
    13101310#endif
    13111311
  • trunk/Source/WebCore/editing/FrameSelection.h

    r106681 r111689  
    6060    void clearCaretRect();
    6161    bool updateCaretRect(Document*, const VisiblePosition& caretPosition);
    62     LayoutRect absoluteBoundsForLocalRect(Node*, const LayoutRect&) const;
    63     LayoutRect caretRepaintRect(Node*) const;
     62    IntRect absoluteBoundsForLocalRect(Node*, const LayoutRect&) const;
     63    IntRect caretRepaintRect(Node*) const;
    6464    bool shouldRepaintCaret(const RenderView*, bool isContentEditable) const;
    6565    void paintCaret(Node*, GraphicsContext*, const LayoutPoint&, const LayoutRect& clipRect) const;
     
    181181
    182182    // Bounds of (possibly transformed) caret in absolute coords
    183     LayoutRect absoluteCaretBounds();
     183    IntRect absoluteCaretBounds();
    184184    void setCaretRectNeedsUpdate() { CaretBase::setCaretRectNeedsUpdate(); }
    185185
     
    296296
    297297    Timer<FrameSelection> m_caretBlinkTimer;
    298     LayoutRect m_absCaretBounds; // absolute bounding rect for the caret
    299     LayoutRect m_absoluteCaretRepaintBounds;
     298    // The painted bounds of the caret in absolute coordinates
     299    IntRect m_absCaretBounds;
     300    // Similar to above, but inflated to ensure proper repaint (see https://bugs.webkit.org/show_bug.cgi?id=19086)
     301    IntRect m_absoluteCaretRepaintBounds;
    300302    bool m_absCaretBoundsDirty : 1;
    301303    bool m_caretPaint : 1;
  • trunk/Source/WebCore/editing/mac/FrameSelectionMac.mm

    r95130 r111689  
    6464        return;
    6565
    66     LayoutRect selectionRect = absoluteCaretBounds();
    67     LayoutRect viewRect = renderView->viewRect();
     66    IntRect selectionRect = absoluteCaretBounds();
     67    IntRect viewRect = pixelSnappedIntRect(renderView->viewRect());
    6868
    6969    selectionRect = frameView->contentsToScreen(selectionRect);
Note: See TracChangeset for help on using the changeset viewer.