Title: [117607] trunk/Source/WebCore
Revision
117607
Author
[email protected]
Date
2012-05-18 11:09:16 -0700 (Fri, 18 May 2012)

Log Message

<rdar://problem/11467250> No focus ring around popup buttons

Reviewed by Anders Carlsson.

The exact same issue was fixed for buttons drawn in ThemeMac.mm in <rdar://problem/10542095>.
This change extends the fix to also cover buttons drawn in RenderThemeMac.mm.

* WebCore.xcodeproj/project.pbxproj: Added WebCoreNSCellExtras.{h.m}.
* platform/mac/ThemeMac.mm: Removed the definitions of BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING
and -[NSCell _web_drawFocusRingWithFrame:inView:] from here. They are now in WebCoreNSCellExtras.
* platform/mac/WebCoreNSCellExtras.h: Added.
* platform/mac/WebCoreNSCellExtras.m: Added.
(-[NSCell _web_drawFocusRingWithFrame:inView:]): Moved from ThemeMac.mm here.
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::paintMenuList): Changed to use -_web_drawFocusRingWithFrame:inView:.
(WebCore::RenderThemeMac::setPopupButtonCellState): Removed call to updateFocusedState() when
the focus ring is drawn separately.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (117606 => 117607)


--- trunk/Source/WebCore/ChangeLog	2012-05-18 18:02:31 UTC (rev 117606)
+++ trunk/Source/WebCore/ChangeLog	2012-05-18 18:09:16 UTC (rev 117607)
@@ -1,3 +1,23 @@
+2012-05-18  Dan Bernstein  <[email protected]>
+
+        <rdar://problem/11467250> No focus ring around popup buttons
+
+        Reviewed by Anders Carlsson.
+
+        The exact same issue was fixed for buttons drawn in ThemeMac.mm in <rdar://problem/10542095>.
+        This change extends the fix to also cover buttons drawn in RenderThemeMac.mm.
+
+        * WebCore.xcodeproj/project.pbxproj: Added WebCoreNSCellExtras.{h.m}.
+        * platform/mac/ThemeMac.mm: Removed the definitions of BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING
+        and -[NSCell _web_drawFocusRingWithFrame:inView:] from here. They are now in WebCoreNSCellExtras.
+        * platform/mac/WebCoreNSCellExtras.h: Added.
+        * platform/mac/WebCoreNSCellExtras.m: Added.
+        (-[NSCell _web_drawFocusRingWithFrame:inView:]): Moved from ThemeMac.mm here.
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::paintMenuList): Changed to use -_web_drawFocusRingWithFrame:inView:.
+        (WebCore::RenderThemeMac::setPopupButtonCellState): Removed call to updateFocusedState() when
+        the focus ring is drawn separately.
+
 2012-05-18  Philippe Normand  <[email protected]>
 
         [GStreamer] Fix early return of the mimeTypeCache function after r117207.

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (117606 => 117607)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2012-05-18 18:02:31 UTC (rev 117606)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2012-05-18 18:09:16 UTC (rev 117607)
@@ -945,6 +945,8 @@
 		33D0212D131DB37B004091A8 /* CookieStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = E13F01EA1270E10D00DFBA71 /* CookieStorage.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		370D6EDA138454550044103E /* ContentTypeParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 370D6ED8138454550044103E /* ContentTypeParser.cpp */; };
 		370D6EDB138454550044103E /* ContentTypeParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 370D6ED9138454550044103E /* ContentTypeParser.h */; };
+		371941961566B37200A276D8 /* WebCoreNSCellExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = 371941941566B37200A276D8 /* WebCoreNSCellExtras.m */; };
+		371941971566B37200A276D8 /* WebCoreNSCellExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 371941951566B37200A276D8 /* WebCoreNSCellExtras.h */; };
 		371A67CB11C6C7DB00047B8B /* HyphenationCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 371A67CA11C6C7DB00047B8B /* HyphenationCF.cpp */; };
 		371E65CC13661EDC00BEEDB0 /* PageSerializer.h in Headers */ = {isa = PBXBuildFile; fileRef = 371E65CB13661EDC00BEEDB0 /* PageSerializer.h */; };
 		371E65CE13661EED00BEEDB0 /* PageSerializer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 371E65CD13661EED00BEEDB0 /* PageSerializer.cpp */; };
@@ -7896,6 +7898,8 @@
 		33C0CCD3112C5E6200CE057D /* SecureTextInput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SecureTextInput.h; sourceTree = "<group>"; };
 		370D6ED8138454550044103E /* ContentTypeParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentTypeParser.cpp; sourceTree = "<group>"; };
 		370D6ED9138454550044103E /* ContentTypeParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentTypeParser.h; sourceTree = "<group>"; };
+		371941941566B37200A276D8 /* WebCoreNSCellExtras.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebCoreNSCellExtras.m; sourceTree = "<group>"; };
+		371941951566B37200A276D8 /* WebCoreNSCellExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreNSCellExtras.h; sourceTree = "<group>"; };
 		371A67CA11C6C7DB00047B8B /* HyphenationCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HyphenationCF.cpp; sourceTree = "<group>"; };
 		371E65CB13661EDC00BEEDB0 /* PageSerializer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageSerializer.h; sourceTree = "<group>"; };
 		371E65CD13661EED00BEEDB0 /* PageSerializer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageSerializer.cpp; sourceTree = "<group>"; };
@@ -15358,6 +15362,8 @@
 				51DF6D7F0B92A18E00C2DC85 /* ThreadCheck.mm */,
 				CD127DEA14F3097900E84779 /* WebCoreFullScreenWindow.h */,
 				CD127DEB14F3097900E84779 /* WebCoreFullScreenWindow.mm */,
+				371941951566B37200A276D8 /* WebCoreNSCellExtras.h */,
+				371941941566B37200A276D8 /* WebCoreNSCellExtras.m */,
 				934D9BA60B8C1175007B42A9 /* WebCoreNSStringExtras.h */,
 				934D9BA40B8C116B007B42A9 /* WebCoreNSStringExtras.mm */,
 				C5B4C24B1509236C00A6EF37 /* WebCoreNSURLExtras.h */,
@@ -24906,6 +24912,7 @@
 				B658FFA61522EFAA00DD5595 /* RadioNodeList.h in Headers */,
 				29A309B11561CAC400BBD8E5 /* VisitedLinks.h in Headers */,
 				FDB052E01561A42C00B500D6 /* AudioSummingJunction.h in Headers */,
+				371941971566B37200A276D8 /* WebCoreNSCellExtras.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -27929,6 +27936,7 @@
 				29A309AC1561C99B00BBD8E5 /* RunLoopCF.cpp in Sources */,
 				29A309B01561CAC400BBD8E5 /* VisitedLinks.cpp in Sources */,
 				FDB052DF1561A42C00B500D6 /* AudioSummingJunction.cpp in Sources */,
+				371941961566B37200A276D8 /* WebCoreNSCellExtras.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: trunk/Source/WebCore/platform/mac/ThemeMac.mm (117606 => 117607)


--- trunk/Source/WebCore/platform/mac/ThemeMac.mm	2012-05-18 18:02:31 UTC (rev 117606)
+++ trunk/Source/WebCore/platform/mac/ThemeMac.mm	2012-05-18 18:09:16 UTC (rev 117607)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008, 2010, 2011 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008, 2010, 2011, 2012 Apple Inc. All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -30,6 +30,7 @@
 #import "GraphicsContext.h"
 #import "LocalCurrentGraphicsContext.h"
 #import "ScrollView.h"
+#import "WebCoreNSCellExtras.h"
 #import "WebCoreSystemInterface.h"
 #import <Carbon/Carbon.h>
 #include <wtf/StdLibExtras.h>
@@ -77,31 +78,6 @@
 
 @end
 
-#define BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING (defined(BUILDING_ON_SNOW_LEOPARD) || defined(BUILDING_ON_LION))
-
-#if !BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING
-
-@interface NSCell (WebFocusRingDrawing)
-- (void)_web_drawFocusRingWithFrame:(NSRect)cellFrame inView:(NSView *)controlView;
-@end
-
-@implementation NSCell (WebFocusRingDrawing)
-
-- (void)_web_drawFocusRingWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
-{
-    CGContextRef cgContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
-    CGContextSaveGState(cgContext);
-    NSSetFocusRingStyle(NSFocusRingOnly);
-    CGContextBeginTransparencyLayerWithRect(cgContext, NSRectToCGRect(cellFrame), 0);
-    [self drawFocusRingMaskWithFrame:cellFrame inView:controlView];
-    CGContextEndTransparencyLayer(cgContext);
-    CGContextRestoreGState(cgContext);
-}
-
-@end
-
-#endif
-
 // FIXME: Default buttons really should be more like push buttons and not like buttons.
 
 namespace WebCore {

Added: trunk/Source/WebCore/platform/mac/WebCoreNSCellExtras.h (0 => 117607)


--- trunk/Source/WebCore/platform/mac/WebCoreNSCellExtras.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/mac/WebCoreNSCellExtras.h	2012-05-18 18:09:16 UTC (rev 117607)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <AppKit/AppKit.h>
+
+#define BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING (defined(BUILDING_ON_SNOW_LEOPARD) || defined(BUILDING_ON_LION))
+
+#if !BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING
+
+@interface NSCell (WebCoreFocusRingDrawing)
+- (void)_web_drawFocusRingWithFrame:(NSRect)cellFrame inView:(NSView *)controlView;
+@end
+
+#endif

Added: trunk/Source/WebCore/platform/mac/WebCoreNSCellExtras.m (0 => 117607)


--- trunk/Source/WebCore/platform/mac/WebCoreNSCellExtras.m	                        (rev 0)
+++ trunk/Source/WebCore/platform/mac/WebCoreNSCellExtras.m	2012-05-18 18:09:16 UTC (rev 117607)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "WebCoreNSCellExtras.h"
+
+#if !BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING
+
+@implementation NSCell (WebCoreFocusRingDrawing)
+
+- (void)_web_drawFocusRingWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
+{
+    CGContextRef cgContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
+    CGContextSaveGState(cgContext);
+    NSSetFocusRingStyle(NSFocusRingOnly);
+    CGContextBeginTransparencyLayerWithRect(cgContext, NSRectToCGRect(cellFrame), 0);
+    [self drawFocusRingMaskWithFrame:cellFrame inView:controlView];
+    CGContextEndTransparencyLayer(cgContext);
+    CGContextRestoreGState(cgContext);
+}
+
+@end
+
+#endif // !BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (117606 => 117607)


--- trunk/Source/WebCore/rendering/RenderThemeMac.mm	2012-05-18 18:02:31 UTC (rev 117606)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm	2012-05-18 18:09:16 UTC (rev 117607)
@@ -47,6 +47,7 @@
 #import "StyleResolver.h"
 #import "TimeRanges.h"
 #import "ThemeMac.h"
+#import "WebCoreNSCellExtras.h"
 #import "WebCoreSystemInterface.h"
 #import "UserAgentStyleSheets.h"
 #import <Carbon/Carbon.h>
@@ -845,7 +846,12 @@
         paintInfo.context->translate(-inflatedRect.x(), -inflatedRect.y());
     }
 
-    [popupButton drawWithFrame:inflatedRect inView:documentViewFor(o)];
+    NSView *view = documentViewFor(o);
+    [popupButton drawWithFrame:inflatedRect inView:view];
+#if !BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING
+    if (isFocused(o) && o->style()->outlineStyleIsAuto())
+        [popupButton _web_drawFocusRingWithFrame:inflatedRect inView:view];
+#endif
     [popupButton setControlView:nil];
 
     return false;
@@ -1324,7 +1330,9 @@
     updateCheckedState(popupButton, o);
     updateEnabledState(popupButton, o);
     updatePressedState(popupButton, o);
+#if BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING
     updateFocusedState(popupButton, o);
+#endif
 }
 
 const IntSize* RenderThemeMac::menuListSizes() const
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to