WebCore:
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Dec 2007 19:24:19 +0000 (19:24 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Dec 2007 19:24:19 +0000 (19:24 +0000)
        Reviewed by Darin Adler.

        - WebCore part of fixing <rdar://problem/5499918> REGRESSION: insertion point in input field with custom border cuts holes in focus ring interior edges

        Test: fast/repaint/focus-ring.html

        * editing/SelectionController.cpp:
        (WebCore::SelectionController::caretRepaintRect): Changed to return just
        the caret rect without any padding.
        (WebCore::SelectionController::recomputeCaretRect): Changed to repaint
        just the caret rect without any padding.
        * platform/graphics/GraphicsContext.h: Removed setFocusRingClip() and
        clearFocusRingClip().
        * platform/graphics/cairo/GraphicsContextCairo.cpp: Ditto.
        * platform/graphics/cg/GraphicsContextCG.cpp: Ditto.
        * platform/graphics/cg/GraphicsContextPlatformPrivate.h: Removed
        m_focusRingClip member.
        * platform/graphics/mac/GraphicsContextMac.mm:
        (WebCore::GraphicsContext::drawFocusRing): Changed to call
        wkDrawFocusRing() once without setting up additional clip. On Leopard,
        wkDrawFocusRing() respects the context clip now. On Tiger, a
        transparency layer is used to apply clipping to the focus ring.
        * platform/graphics/qt/GraphicsContextQt.cpp: Removed focus ring clip
        methods and member.
        * platform/graphics/wx/GraphicsContextWx.cpp: Ditto.
        * platform/mac/WebCoreSystemInterface.h: Removed the clipRect argument
        to wkDrawFocusRing().
        * platform/mac/WebCoreSystemInterface.mm: Ditto.
        * rendering/RenderLayer.cpp:
        (WebCore::setClip): Removed call to set the focus ring clip.
        (WebCore::restoreClip): Removed call to reset the focus ring clip.

WebKitLibraries:

        Reviewed by Darin Adler.

        - updated system interface for fixing <rdar://problem/5499918> REGRESSION: insertion point in input field with custom border cuts holes in focus ring interior edges

        * WebKitSystemInterface.h:
        * libWebKitSystemInterfaceLeopard.a:
        * libWebKitSystemInterfaceTiger.a:

LayoutTests:

        Reviewed by Darin Adler.

        - repaint test for <rdar://problem/5499918> REGRESSION: insertion point in input field with custom border cuts holes in focus ring interior edges

        * fast/repaint/focus-ring.html: Added.
        * platform/mac/fast/repaint/focus-ring-expected.checksum: Added.
        * platform/mac/fast/repaint/focus-ring-expected.png: Added.
        * platform/mac/fast/repaint/focus-ring-expected.txt: Added.

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

21 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/repaint/focus-ring.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/repaint/focus-ring-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/repaint/focus-ring-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/repaint/focus-ring-expected.txt [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/SelectionController.cpp
WebCore/platform/graphics/GraphicsContext.h
WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
WebCore/platform/graphics/cg/GraphicsContextCG.cpp
WebCore/platform/graphics/cg/GraphicsContextPlatformPrivate.h
WebCore/platform/graphics/mac/GraphicsContextMac.mm
WebCore/platform/graphics/qt/GraphicsContextQt.cpp
WebCore/platform/graphics/wx/GraphicsContextWx.cpp
WebCore/platform/mac/WebCoreSystemInterface.h
WebCore/platform/mac/WebCoreSystemInterface.mm
WebCore/rendering/RenderLayer.cpp
WebKitLibraries/ChangeLog
WebKitLibraries/WebKitSystemInterface.h
WebKitLibraries/libWebKitSystemInterfaceLeopard.a
WebKitLibraries/libWebKitSystemInterfaceTiger.a

index 77f3076..631eaaa 100644 (file)
@@ -2,6 +2,17 @@
 
         Reviewed by Darin Adler.
 
+        - repaint test for <rdar://problem/5499918> REGRESSION: insertion point in input field with custom border cuts holes in focus ring interior edges
+
+        * fast/repaint/focus-ring.html: Added.
+        * platform/mac/fast/repaint/focus-ring-expected.checksum: Added.
+        * platform/mac/fast/repaint/focus-ring-expected.png: Added.
+        * platform/mac/fast/repaint/focus-ring-expected.txt: Added.
+
+2007-12-07  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Darin Adler.
+
         - test for http://bugs.webkit.org/show_bug.cgi?id=16334
           <rdar://problem/5634923> REGRESSION (r28299): Homepage of any DotMac Web Gallery won't load completely
 
diff --git a/LayoutTests/fast/repaint/focus-ring.html b/LayoutTests/fast/repaint/focus-ring.html
new file mode 100644 (file)
index 0000000..e0b26be
--- /dev/null
@@ -0,0 +1,15 @@
+<script>
+    if (window.layoutTestController)
+        layoutTestController.testRepaint();
+</script>
+<style>
+    div {
+        width: 100px;
+        height: 100px;
+        outline: auto;
+        outline-width: 10px;
+        background-color: lightyellow;
+    }
+</style>
+<div style="margin: 20px; "></div>
+<div style="position: absolute; top: 148px; left: 28px; clip: rect(-10px 50px 50px -10px)"></div>
diff --git a/LayoutTests/platform/mac/fast/repaint/focus-ring-expected.checksum b/LayoutTests/platform/mac/fast/repaint/focus-ring-expected.checksum
new file mode 100644 (file)
index 0000000..c54b0a1
--- /dev/null
@@ -0,0 +1 @@
+e7972d277234de94b7a67fefb444146c
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/repaint/focus-ring-expected.png b/LayoutTests/platform/mac/fast/repaint/focus-ring-expected.png
new file mode 100644 (file)
index 0000000..7dae2c2
Binary files /dev/null and b/LayoutTests/platform/mac/fast/repaint/focus-ring-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/repaint/focus-ring-expected.txt b/LayoutTests/platform/mac/fast/repaint/focus-ring-expected.txt
new file mode 100644 (file)
index 0000000..899f316
--- /dev/null
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,20) size 784x560
+      RenderBlock {DIV} at (20,0) size 100x100 [bgcolor=#FFFFE0]
+layer at (28,148) size 100x100 backgroundClip at (28,148) size 50x50 clip at (18,138) size 60x60 outlineClip at (18,138) size 60x60
+  RenderBlock (positioned) {DIV} at (28,148) size 100x100 [bgcolor=#FFFFE0]
index 24cd1ce..25db321 100644 (file)
@@ -1,3 +1,37 @@
+2007-12-07  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Darin Adler.
+
+        - WebCore part of fixing <rdar://problem/5499918> REGRESSION: insertion point in input field with custom border cuts holes in focus ring interior edges
+
+        Test: fast/repaint/focus-ring.html
+
+        * editing/SelectionController.cpp:
+        (WebCore::SelectionController::caretRepaintRect): Changed to return just
+        the caret rect without any padding.
+        (WebCore::SelectionController::recomputeCaretRect): Changed to repaint
+        just the caret rect without any padding.
+        * platform/graphics/GraphicsContext.h: Removed setFocusRingClip() and
+        clearFocusRingClip().
+        * platform/graphics/cairo/GraphicsContextCairo.cpp: Ditto.
+        * platform/graphics/cg/GraphicsContextCG.cpp: Ditto.
+        * platform/graphics/cg/GraphicsContextPlatformPrivate.h: Removed
+        m_focusRingClip member.
+        * platform/graphics/mac/GraphicsContextMac.mm:
+        (WebCore::GraphicsContext::drawFocusRing): Changed to call
+        wkDrawFocusRing() once without setting up additional clip. On Leopard,
+        wkDrawFocusRing() respects the context clip now. On Tiger, a
+        transparency layer is used to apply clipping to the focus ring.
+        * platform/graphics/qt/GraphicsContextQt.cpp: Removed focus ring clip
+        methods and member.
+        * platform/graphics/wx/GraphicsContextWx.cpp: Ditto.
+        * platform/mac/WebCoreSystemInterface.h: Removed the clipRect argument
+        to wkDrawFocusRing().
+        * platform/mac/WebCoreSystemInterface.mm: Ditto.
+        * rendering/RenderLayer.cpp:
+        (WebCore::setClip): Removed call to set the focus ring clip.
+        (WebCore::restoreClip): Removed call to reset the focus ring clip.
+
 2007-12-07  Darin Adler  <darin@apple.com>
 
         Reviewed by Antti Koivisto and Kevin Decker.
index 09f3436..5619f6f 100644 (file)
@@ -704,17 +704,9 @@ IntRect SelectionController::caretRect() const
     return caret;
 }
 
-static IntRect repaintRectForCaret(IntRect caret)
-{
-    if (caret.isEmpty())
-        return IntRect();
-    caret.inflate(1);
-    return caret;
-}
-
 IntRect SelectionController::caretRepaintRect() const
 {
-    return repaintRectForCaret(caretRect());
+    return caretRect();
 }
 
 bool SelectionController::recomputeCaretRect()
@@ -735,8 +727,8 @@ bool SelectionController::recomputeCaretRect()
     if (oldRect == newRect)
         return false;
 
-    v->updateContents(repaintRectForCaret(oldRect), false);
-    v->updateContents(repaintRectForCaret(newRect), false);
+    v->updateContents(oldRect, false);
+    v->updateContents(newRect, false);
     return true;
 }
 
index 71eeffd..e5228a4 100644 (file)
@@ -164,10 +164,6 @@ namespace WebCore {
         void clipOutEllipseInRect(const IntRect&);
         void clipOutRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight);
 
-        // Functions to work around bugs in focus ring clipping on Mac.
-        void setFocusRingClip(const IntRect&);
-        void clearFocusRingClip();
-
         int textDrawingMode();
         void setTextDrawingMode(int);
 
index be37d50..85d0c00 100644 (file)
@@ -441,18 +441,6 @@ void GraphicsContext::drawFocusRing(const Color& color)
     cairo_restore(cr);
 }
 
-void GraphicsContext::setFocusRingClip(const IntRect&)
-{
-    // hopefully a no-op. Comment in CG version says that it exists
-    // to work around bugs in Mac focus ring clipping
-}
-
-void GraphicsContext::clearFocusRingClip()
-{
-    // hopefully a no-op. Comment in CG version says that it exists
-    // to work around bugs in Mac focus ring clipping
-}
-
 void GraphicsContext::drawLineForText(const IntPoint& origin, int width, bool printing)
 {
     if (paintingDisabled())
index 2c94e2f..a04b584 100644 (file)
@@ -72,18 +72,6 @@ GraphicsContext::~GraphicsContext()
     delete m_data;
 }
 
-void GraphicsContext::setFocusRingClip(const IntRect& r)
-{
-    // This method only exists to work around bugs in Mac focus ring clipping.
-    m_data->m_focusRingClip = r;
-}
-
-void GraphicsContext::clearFocusRingClip()
-{
-    // This method only exists to work around bugs in Mac focus ring clipping.
-    m_data->m_focusRingClip = IntRect();
-}
-
 CGContextRef GraphicsContext::platformContext() const
 {
     ASSERT(!paintingDisabled());
index 106cb06..937481b 100644 (file)
@@ -79,7 +79,6 @@ public:
 #endif
 
     CGContextRef m_cgContext;
-    IntRect m_focusRingClip; // Work around CG bug in focus ring clipping.
     bool m_userToDeviceTransformKnownToBeIdentity;
 };
 
index da83416..3b1d3fe 100644 (file)
@@ -55,35 +55,15 @@ void GraphicsContext::drawFocusRing(const Color& color)
         CGPathAddRect(focusRingPath, 0, CGRectInset(rects[i], -offset, -offset));
 
     CGContextRef context = platformContext();
-
-    // FIXME: This works only inside a NSView's drawRect method. The view must be
-    // focused and this context must be the current NSGraphicsContext.
-    ASSERT(context == [[NSGraphicsContext currentContext] graphicsPort]);
-    NSView* view = [NSView focusView];
-    ASSERT(view);
-
-    const NSRect* drawRects;
-#ifdef __LP64__
-    long count;
-#else
-    int count;
+#ifdef BUILDING_ON_TIGER
+    CGContextBeginTransparencyLayer(context, NULL);
+#endif
+    CGContextBeginPath(context);
+    CGContextAddPath(context, focusRingPath);
+    wkDrawFocusRing(context, colorRef, radius);
+#ifdef BUILDING_ON_TIGER
+    CGContextEndTransparencyLayer(context);
 #endif
-    [view getRectsBeingDrawn:&drawRects count:&count];
-
-    // We have to pass in our own clip rectangles here because a bug in CG
-    // seems to inflate the clip (thus allowing the focus ring to paint
-    // slightly outside the clip).
-    NSRect transformedClipRect = [view convertRect:m_data->m_focusRingClip toView:nil];
-    for (int i = 0; i < count; ++i) {
-        NSRect transformedRect = [view convertRect:drawRects[i] toView:nil];
-        NSRect rectToUse = NSIntersectionRect(transformedRect, transformedClipRect);
-        if (!NSIsEmptyRect(rectToUse)) {
-            CGContextBeginPath(context);
-            CGContextAddPath(context, focusRingPath);
-            wkDrawFocusRing(context, *(CGRect *)&rectToUse, colorRef, radius);
-        }
-    }
-
     CGColorRelease(colorRef);
 
     CGPathRelease(focusRingPath);
index ec0486d..4da69b0 100644 (file)
@@ -216,7 +216,6 @@ public:
     QStack<TransparencyLayer> layers;
     QPainter* redirect;
 
-    IntRect focusRingClip;
     TextShadow shadow;
 
     // Only used by SVG for now.
@@ -566,22 +565,6 @@ void GraphicsContext::drawFocusRing(const Color& color)
     }
 }
 
-void GraphicsContext::setFocusRingClip(const IntRect& rect)
-{
-    if (paintingDisabled())
-        return;
-
-    m_data->focusRingClip = rect;
-}
-
-void GraphicsContext::clearFocusRingClip()
-{
-    if (paintingDisabled())
-        return;
-
-    m_data->focusRingClip = IntRect();
-}
-
 void GraphicsContext::drawLineForText(const IntPoint& origin, int width, bool printing)
 {
     if (paintingDisabled())
index 02fbcf9..99521ac 100644 (file)
@@ -93,7 +93,6 @@ public:
 #else
     wxWindowDC* context;
 #endif
-    IntRect focusRect;
     int mswDCStateID;
     wxRegion gtkCurrentClipRgn;
     wxRegion gtkPaintClipRgn;
@@ -101,7 +100,6 @@ public:
 
 GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate() :
     context(0),
-    focusRect(IntRect()),
     mswDCStateID(0),
     gtkCurrentClipRgn(wxRegion()),
     gtkPaintClipRgn(wxRegion())
@@ -329,16 +327,6 @@ void GraphicsContext::clipOutEllipseInRect(const IntRect&)
     notImplemented();
 }
 
-void GraphicsContext::setFocusRingClip(const IntRect& r)
-{
-    m_data->focusRect = r;
-}
-
-void GraphicsContext::clearFocusRingClip()
-{
-    m_data->focusRect = IntRect(); 
-}
-
 void GraphicsContext::drawLineForText(const IntPoint& origin, int width, bool printing)
 {
     if (paintingDisabled())
index 66b4a14..7539f12 100644 (file)
@@ -90,7 +90,7 @@ extern void (*wkDrawBezeledTextFieldCell)(NSRect, BOOL enabled);
 extern void (*wkDrawTextFieldCellFocusRing)(NSTextFieldCell*, NSRect);
 extern void (*wkDrawCapsLockIndicator)(CGContextRef, CGRect);
 extern void (*wkDrawBezeledTextArea)(NSRect, BOOL enabled);
-extern void (*wkDrawFocusRing)(CGContextRef, CGRect clipRect, CGColorRef, int radius);
+extern void (*wkDrawFocusRing)(CGContextRef, CGColorRef, int radius);
 extern BOOL (*wkFontSmoothingModeIsLCD)(int mode);
 extern OSStatus (*wkGetATSStyleGroup)(ATSUStyle, void** styleGroup);
 extern CGFontRef (*wkGetCGFontFromNSFont)(NSFont*);
index 28dc491..436049e 100644 (file)
@@ -35,7 +35,7 @@ void (*wkDrawBezeledTextFieldCell)(NSRect, BOOL enabled);
 void (*wkDrawTextFieldCellFocusRing)(NSTextFieldCell*, NSRect);
 void (*wkDrawCapsLockIndicator)(CGContextRef, CGRect);
 void (*wkDrawBezeledTextArea)(NSRect, BOOL enabled);
-void (*wkDrawFocusRing)(CGContextRef, CGRect clipRect, CGColorRef, int radius);
+void (*wkDrawFocusRing)(CGContextRef, CGColorRef, int radius);
 BOOL (*wkFontSmoothingModeIsLCD)(int mode);
 OSStatus (*wkGetATSStyleGroup)(ATSUStyle, void** styleGroup);
 CGFontRef (*wkGetCGFontFromNSFont)(NSFont*);
index 852dee9..a2449f9 100644 (file)
@@ -1439,8 +1439,6 @@ RenderLayer::paint(GraphicsContext* p, const IntRect& damageRect, PaintRestricti
 
 static void setClip(GraphicsContext* p, const IntRect& paintDirtyRect, const IntRect& clipRect)
 {
-    // Work around bugs in focus ring clipping on Mac.
-    p->setFocusRingClip(clipRect);
     if (paintDirtyRect == clipRect)
         return;
     p->save();
@@ -1449,8 +1447,6 @@ static void setClip(GraphicsContext* p, const IntRect& paintDirtyRect, const Int
 
 static void restoreClip(GraphicsContext* p, const IntRect& paintDirtyRect, const IntRect& clipRect)
 {
-    // Work around bugs in focus ring clipping on Mac.
-    p->clearFocusRingClip();
     if (paintDirtyRect == clipRect)
         return;
     p->restore();
index ff755e3..31ba3d6 100644 (file)
@@ -1,3 +1,13 @@
+2007-12-07  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Darin Adler.
+
+        - updated system interface for fixing <rdar://problem/5499918> REGRESSION: insertion point in input field with custom border cuts holes in focus ring interior edges
+
+        * WebKitSystemInterface.h:
+        * libWebKitSystemInterfaceLeopard.a:
+        * libWebKitSystemInterfaceTiger.a:
+
 2007-11-27  John Sullivan  <sullivan@apple.com>
 
         Fixed 5614525, caused by a recent bug in WKGetExtensionsForMIMEType
index 4ba5316..07572b7 100644 (file)
@@ -95,8 +95,7 @@ CFReadStreamRef WKCreateCustomCFReadStream(void *(*formCreate)(CFReadStreamRef,
 
 void WKDrawCapsLockIndicator(CGContextRef, CGRect);
 
-void WKDrawFocusRing(CGContextRef context, CGRect clipRect, CGColorRef color, int radius);
-    // Ignore the context's clipping.
+void WKDrawFocusRing(CGContextRef context, CGColorRef color, int radius);
     // The CG context's current path is the focus ring's path.
     // A color of 0 means "use system focus ring color".
     // A radius of 0 means "use default focus ring radius".
index 70fb5b6..e7c1c2a 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceLeopard.a and b/WebKitLibraries/libWebKitSystemInterfaceLeopard.a differ
index d7f6e5c..ace0ab1 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceTiger.a and b/WebKitLibraries/libWebKitSystemInterfaceTiger.a differ