Changeset 111689 in webkit
- Timestamp:
- Mar 22, 2012 7:14:13 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r111688 r111689 1 2012-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 1 29 2012-03-22 Alexei Filippov <alexeif@chromium.org> 2 30 -
trunk/Source/WebCore/editing/FrameSelection.cpp
r111079 r111689 988 988 989 989 // FIXME: Maybe baseline would be better? 990 static bool absoluteCaretY(const VisiblePosition &c, LayoutUnit &y)991 { 992 LayoutRect rect = c.absoluteCaretBounds();990 static bool absoluteCaretY(const VisiblePosition &c, int &y) 991 { 992 IntRect rect = c.absoluteCaretBounds(); 993 993 if (rect.isEmpty()) 994 994 return false; … … 1029 1029 } 1030 1030 1031 LayoutUnit startY;1031 int startY; 1032 1032 if (!absoluteCaretY(pos, startY)) 1033 1033 return false; 1034 1034 if (direction == DirectionUp) 1035 1035 startY = -startY; 1036 LayoutUnit lastY = startY;1036 int lastY = startY; 1037 1037 1038 1038 VisiblePosition result; … … 1046 1046 if (next.isNull() || next == p) 1047 1047 break; 1048 LayoutUnit nextY;1048 int nextY; 1049 1049 if (!absoluteCaretY(next, nextY)) 1050 1050 break; 1051 1051 if (direction == DirectionUp) 1052 1052 nextY = -nextY; 1053 if (nextY - startY > static_cast< LayoutUnit>(verticalDistance))1053 if (nextY - startY > static_cast<int>(verticalDistance)) 1054 1054 break; 1055 1055 if (nextY >= lastY) { … … 1248 1248 } 1249 1249 1250 LayoutRect CaretBase::absoluteBoundsForLocalRect(Node* node, const LayoutRect& rect) const1250 IntRect CaretBase::absoluteBoundsForLocalRect(Node* node, const LayoutRect& rect) const 1251 1251 { 1252 1252 RenderObject* caretPainter = caretRenderer(node); 1253 1253 if (!caretPainter) 1254 return LayoutRect();1254 return IntRect(); 1255 1255 1256 1256 LayoutRect localRect(rect); … … 1260 1260 } 1261 1261 1262 LayoutRect FrameSelection::absoluteCaretBounds()1262 IntRect FrameSelection::absoluteCaretBounds() 1263 1263 { 1264 1264 recomputeCaretRect(); … … 1276 1276 } 1277 1277 1278 LayoutRect CaretBase::caretRepaintRect(Node* node) const1278 IntRect CaretBase::caretRepaintRect(Node* node) const 1279 1279 { 1280 1280 return absoluteBoundsForLocalRect(node, repaintRectForCaret(localCaretRectWithoutUpdate())); … … 1298 1298 return false; 1299 1299 1300 LayoutRect oldAbsCaretBounds = m_absCaretBounds;1300 IntRect oldAbsCaretBounds = m_absCaretBounds; 1301 1301 // FIXME: Rename m_caretRect to m_localCaretRect. 1302 1302 m_absCaretBounds = absoluteBoundsForLocalRect(m_selection.start().deprecatedNode(), localCaretRectWithoutUpdate()); … … 1307 1307 1308 1308 #if ENABLE(TEXT_CARET) 1309 LayoutRect oldAbsoluteCaretRepaintBounds = m_absoluteCaretRepaintBounds;1309 IntRect oldAbsoluteCaretRepaintBounds = m_absoluteCaretRepaintBounds; 1310 1310 #endif 1311 1311 -
trunk/Source/WebCore/editing/FrameSelection.h
r106681 r111689 60 60 void clearCaretRect(); 61 61 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; 64 64 bool shouldRepaintCaret(const RenderView*, bool isContentEditable) const; 65 65 void paintCaret(Node*, GraphicsContext*, const LayoutPoint&, const LayoutRect& clipRect) const; … … 181 181 182 182 // Bounds of (possibly transformed) caret in absolute coords 183 LayoutRect absoluteCaretBounds();183 IntRect absoluteCaretBounds(); 184 184 void setCaretRectNeedsUpdate() { CaretBase::setCaretRectNeedsUpdate(); } 185 185 … … 296 296 297 297 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; 300 302 bool m_absCaretBoundsDirty : 1; 301 303 bool m_caretPaint : 1; -
trunk/Source/WebCore/editing/mac/FrameSelectionMac.mm
r95130 r111689 64 64 return; 65 65 66 LayoutRect selectionRect = absoluteCaretBounds();67 LayoutRect viewRect = renderView->viewRect();66 IntRect selectionRect = absoluteCaretBounds(); 67 IntRect viewRect = pixelSnappedIntRect(renderView->viewRect()); 68 68 69 69 selectionRect = frameView->contentsToScreen(selectionRect);
Note: See TracChangeset
for help on using the changeset viewer.