Update LayoutUnit usage in Editor and Frame
authorleviw@chromium.org <leviw@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Apr 2012 18:34:43 +0000 (18:34 +0000)
committerleviw@chromium.org <leviw@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Apr 2012 18:34:43 +0000 (18:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=83278

Reviewed by Eric Seidel.

Frame and Editor both take input from the embedder, which passes along coordinates in screen
coordinates, which aren't fractional. Updating a few remaining functions to show this, and correcting
some inconsistencies in LayoutUnit usage.

No new tests. No change in behavior.

* editing/Editor.cpp:
(WebCore::Editor::rangeForPoint): windowToContents returns an IntPoint.
(WebCore::Editor::countMatchesForText): Using enclosingIntRect since we're (fake) repainting the entire
view rect.
* editing/Editor.h:
(Editor): Correcting mismatched function signature.
* page/Frame.cpp:
(WebCore::Frame::visiblePositionForPoint): Frame takes points in screen coordinates, usually from the
embedder. Changing these functions to be in IntPoints.
(WebCore::Frame::documentAtPoint): Ditto.
(WebCore::Frame::rangeForPoint): Ditto.
* page/Frame.h:
(Frame):
* platform/graphics/IntRect.h:
(enclosingIntRect): Adding an inline no-op copy of the FractionalLayoutRect method enclosingIntRect.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@113466 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/Editor.h
Source/WebCore/page/Frame.cpp
Source/WebCore/page/Frame.h
Source/WebCore/platform/graphics/IntRect.h

index 0297674..c790d14 100644 (file)
@@ -1,3 +1,32 @@
+2012-04-06  Levi Weintraub  <leviw@chromium.org>
+
+        Update LayoutUnit usage in Editor and Frame
+        https://bugs.webkit.org/show_bug.cgi?id=83278
+
+        Reviewed by Eric Seidel.
+
+        Frame and Editor both take input from the embedder, which passes along coordinates in screen
+        coordinates, which aren't fractional. Updating a few remaining functions to show this, and correcting
+        some inconsistencies in LayoutUnit usage.
+
+        No new tests. No change in behavior.
+
+        * editing/Editor.cpp:
+        (WebCore::Editor::rangeForPoint): windowToContents returns an IntPoint.
+        (WebCore::Editor::countMatchesForText): Using enclosingIntRect since we're (fake) repainting the entire
+        view rect.
+        * editing/Editor.h:
+        (Editor): Correcting mismatched function signature.
+        * page/Frame.cpp:
+        (WebCore::Frame::visiblePositionForPoint): Frame takes points in screen coordinates, usually from the
+        embedder. Changing these functions to be in IntPoints.
+        (WebCore::Frame::documentAtPoint): Ditto.
+        (WebCore::Frame::rangeForPoint): Ditto.
+        * page/Frame.h:
+        (Frame):
+        * platform/graphics/IntRect.h:
+        (enclosingIntRect): Adding an inline no-op copy of the FractionalLayoutRect method enclosingIntRect.
+
 2012-04-06  Tommy Widenflycht  <tommyw@google.com>
 
         MediaStream API: Deleting the chromium bridge class MediaStreamCenterInternal
index 009c340..004b258 100644 (file)
@@ -2248,7 +2248,7 @@ PassRefPtr<Range> Editor::rangeForPoint(const IntPoint& windowPoint)
     FrameView* frameView = frame->view();
     if (!frameView)
         return 0;
-    LayoutPoint framePoint = frameView->windowToContents(windowPoint);
+    IntPoint framePoint = frameView->windowToContents(windowPoint);
     VisibleSelection selection(frame->visiblePositionForPoint(framePoint));
     return avoidIntersectionWithNode(selection.toNormalizedRange().get(), m_deleteButtonController->containerElement());
 }
@@ -2868,7 +2868,7 @@ unsigned Editor::countMatchesForText(const String& target, Range* range, FindOpt
 
                 PaintBehavior oldBehavior = m_frame->view()->paintBehavior();
                 m_frame->view()->setPaintBehavior(oldBehavior | PaintBehaviorFlattenCompositingLayers);
-                m_frame->view()->paintContents(&context, visibleRect);
+                m_frame->view()->paintContents(&context, enclosingIntRect(visibleRect));
                 m_frame->view()->setPaintBehavior(oldBehavior);
             }
         }
index d7005cd..45bac9f 100644 (file)
@@ -300,7 +300,7 @@ public:
 
     void setStartNewKillRingSequence(bool);
 
-    PassRefPtr<Range> rangeForPoint(const LayoutPoint& windowPoint);
+    PassRefPtr<Range> rangeForPoint(const IntPoint& windowPoint);
 
     void clear();
 
index d5c176d..49eface 100644 (file)
@@ -725,7 +725,7 @@ String Frame::displayStringModifiedByEncoding(const String& str) const
     return document() ? document()->displayStringModifiedByEncoding(str) : str;
 }
 
-VisiblePosition Frame::visiblePositionForPoint(const LayoutPoint& framePoint)
+VisiblePosition Frame::visiblePositionForPoint(const IntPoint& framePoint)
 {
     HitTestResult result = eventHandler()->hitTestResultAtPoint(framePoint, true);
     Node* node = result.innerNonSharedNode();
@@ -745,7 +745,7 @@ Document* Frame::documentAtPoint(const IntPoint& point)
     if (!view())
         return 0;
 
-    LayoutPoint pt = view()->windowToContents(point);
+    IntPoint pt = view()->windowToContents(point);
     HitTestResult result = HitTestResult(pt);
 
     if (contentRenderer())
@@ -753,7 +753,7 @@ Document* Frame::documentAtPoint(const IntPoint& point)
     return result.innerNode() ? result.innerNode()->document() : 0;
 }
 
-PassRefPtr<Range> Frame::rangeForPoint(const LayoutPoint& framePoint)
+PassRefPtr<Range> Frame::rangeForPoint(const IntPoint& framePoint)
 {
     VisiblePosition position = visiblePositionForPoint(framePoint);
     if (position.isNull())
index 8c56e8f..4cd4f96 100644 (file)
@@ -179,9 +179,9 @@ namespace WebCore {
         DragImageRef nodeImage(Node*);
         DragImageRef dragImageForSelection();
 
-        VisiblePosition visiblePositionForPoint(const LayoutPoint& framePoint);
+        VisiblePosition visiblePositionForPoint(const IntPoint& framePoint);
         Document* documentAtPoint(const IntPoint& windowPoint);
-        PassRefPtr<Range> rangeForPoint(const LayoutPoint& framePoint);
+        PassRefPtr<Range> rangeForPoint(const IntPoint& framePoint);
 
         String searchForLabelsAboveCell(RegularExpression*, HTMLTableCellElement*, size_t* resultDistanceFromStartOfCell);
         String searchForLabelsBeforeElement(const Vector<String>& labels, Element*, size_t* resultDistance, bool* resultIsInCellAbove);
index c381d63..9a9a7f7 100644 (file)
@@ -272,6 +272,13 @@ inline bool operator!=(const IntRect& a, const IntRect& b)
     return a.location() != b.location() || a.size() != b.size();
 }
 
+// FIXME: This method is here only to ease the transition to sub-pixel layout. It should
+// be removed when we close http://webkit.org/b/60318
+inline IntRect enclosingIntRect(const IntRect& rect)
+{
+    return rect;
+}
+
 #if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM)
 IntRect enclosingIntRect(const CGRect&);
 #endif