Title: [164173] trunk/Source/WebCore
Revision
164173
Author
[email protected]
Date
2014-02-15 09:51:57 -0800 (Sat, 15 Feb 2014)

Log Message

Form controls are always painted in the active state
https://bugs.webkit.org/show_bug.cgi?id=128872
<rdar://problem/9422677>

Reviewed by Dan Bernstein.

AppKit will always paint form controls in the active state if the view doesn't have a
window. Fix this by adding a fake window whose key appearance we'll update based on the
control state. Also, rename WebCoreFlippedView to WebCoreThemeView since it stopped being
just about the flippedness a long time ago.

* platform/mac/ThemeMac.h:
* platform/mac/ThemeMac.mm:
(-[WebCoreThemeWindow hasKeyAppearance]):
Return themeWindowHasKeyAppearance.

(-[WebCoreThemeView window]):
Create a WebCoreThemeWindow object lazily and return it.

(WebCore::paintCheckbox):
(WebCore::paintRadio):
(WebCore::paintButton):
Pass the control states to ThemeMac::ensuredView.

(WebCore::ThemeMac::ensuredView):
Set themeWindowHasKeyAppearance based on the control state.

* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::documentViewFor):
Pass the control states to ThemeMac::ensuredView.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (164172 => 164173)


--- trunk/Source/WebCore/ChangeLog	2014-02-15 17:06:17 UTC (rev 164172)
+++ trunk/Source/WebCore/ChangeLog	2014-02-15 17:51:57 UTC (rev 164173)
@@ -1,3 +1,36 @@
+2014-02-15  Anders Carlsson  <[email protected]>
+
+        Form controls are always painted in the active state
+        https://bugs.webkit.org/show_bug.cgi?id=128872
+        <rdar://problem/9422677>
+
+        Reviewed by Dan Bernstein.
+
+        AppKit will always paint form controls in the active state if the view doesn't have a
+        window. Fix this by adding a fake window whose key appearance we'll update based on the 
+        control state. Also, rename WebCoreFlippedView to WebCoreThemeView since it stopped being
+        just about the flippedness a long time ago.
+
+        * platform/mac/ThemeMac.h:
+        * platform/mac/ThemeMac.mm:
+        (-[WebCoreThemeWindow hasKeyAppearance]):
+        Return themeWindowHasKeyAppearance.
+
+        (-[WebCoreThemeView window]):
+        Create a WebCoreThemeWindow object lazily and return it.
+
+        (WebCore::paintCheckbox):
+        (WebCore::paintRadio):
+        (WebCore::paintButton):
+        Pass the control states to ThemeMac::ensuredView.
+
+        (WebCore::ThemeMac::ensuredView):
+        Set themeWindowHasKeyAppearance based on the control state.
+
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::documentViewFor):
+        Pass the control states to ThemeMac::ensuredView.
+
 2014-02-15  Renata Hodovan  <[email protected]>
 
         ASSERT_WITH_SECURITY_IMPLICATION in WebCore::toElement

Modified: trunk/Source/WebCore/platform/mac/ThemeMac.h (164172 => 164173)


--- trunk/Source/WebCore/platform/mac/ThemeMac.h	2014-02-15 17:06:17 UTC (rev 164172)
+++ trunk/Source/WebCore/platform/mac/ThemeMac.h	2014-02-15 17:51:57 UTC (rev 164173)
@@ -55,7 +55,7 @@
     virtual void inflateControlPaintRect(ControlPart, ControlStates, IntRect&, float zoomFactor) const;
 
     // FIXME: Once RenderThemeMac is converted over to use Theme then this can be internal to ThemeMac.
-    static NSView* ensuredView(ScrollView*);
+    static NSView* ensuredView(ScrollView*, ControlStates);
     static void setFocusRingClipRect(const FloatRect&);
 };
 

Modified: trunk/Source/WebCore/platform/mac/ThemeMac.mm (164172 => 164173)


--- trunk/Source/WebCore/platform/mac/ThemeMac.mm	2014-02-15 17:06:17 UTC (rev 164172)
+++ trunk/Source/WebCore/platform/mac/ThemeMac.mm	2014-02-15 17:51:57 UTC (rev 164173)
@@ -35,14 +35,35 @@
 #import <Carbon/Carbon.h>
 #include <wtf/StdLibExtras.h>
 
-NSRect focusRingClipRect;
+static NSRect focusRingClipRect;
+static BOOL themeWindowHasKeyAppearance;
 
-// This is a view whose sole purpose is to tell AppKit that it's flipped.
-@interface WebCoreFlippedView : NSControl
+@interface WebCoreThemeWindow : NSWindow {
+}
+
 @end
 
-@implementation WebCoreFlippedView
+@implementation WebCoreThemeWindow
 
+- (BOOL)hasKeyAppearance
+{
+    return themeWindowHasKeyAppearance;
+}
+
+@end
+
+@interface WebCoreThemeView : NSControl
+@end
+
+@implementation WebCoreThemeView
+
+- (NSWindow *)window
+{
+    static WebCoreThemeWindow *window = [[WebCoreThemeWindow alloc] init];
+
+    return window;
+}
+
 - (BOOL)isFlipped
 {
     return YES;
@@ -290,7 +311,7 @@
     }
 
     LocalCurrentGraphicsContext localContext(context);
-    NSView *view = ThemeMac::ensuredView(scrollView);
+    NSView *view = ThemeMac::ensuredView(scrollView, states);
     [checkboxCell drawWithFrame:NSRect(inflatedRect) inView:view];
     if (states & FocusState)
         [checkboxCell _web_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view];
@@ -369,7 +390,7 @@
 
     LocalCurrentGraphicsContext localContext(context);
     BEGIN_BLOCK_OBJC_EXCEPTIONS
-    NSView *view = ThemeMac::ensuredView(scrollView);
+    NSView *view = ThemeMac::ensuredView(scrollView, states);
     [radioCell drawWithFrame:NSRect(inflatedRect) inView:view];
     if (states & FocusState)
         [radioCell _web_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view];
@@ -473,7 +494,7 @@
     } 
 
     LocalCurrentGraphicsContext localContext(context);
-    NSView *view = ThemeMac::ensuredView(scrollView);
+    NSView *view = ThemeMac::ensuredView(scrollView, states);
     NSWindow *window = [view window];
     NSButtonCell *previousDefaultButtonCell = [window defaultButtonCell];
 
@@ -555,17 +576,19 @@
 }
 
 // This will ensure that we always return a valid NSView, even if ScrollView doesn't have an associated document NSView.
-// If the ScrollView doesn't have an NSView, we will return a fake NSView whose sole purpose is to tell AppKit that it's flipped.
-NSView *ThemeMac::ensuredView(ScrollView* scrollView)
+// If the ScrollView doesn't have an NSView, we will return a fake NSView set up in the way AppKit expects.
+NSView *ThemeMac::ensuredView(ScrollView* scrollView, ControlStates states)
 {
     if (NSView *documentView = scrollView->documentView())
         return documentView;
 
-    // Use a fake flipped view.
-    static NSView *flippedView = [[WebCoreFlippedView alloc] init];
-    [flippedView setFrameSize:NSSizeFromCGSize(scrollView->totalContentsSize())];
+    // Use a fake view.
+    static WebCoreThemeView *themeView = [[WebCoreThemeView alloc] init];
+    [themeView setFrameSize:NSSizeFromCGSize(scrollView->totalContentsSize())];
 
-    return flippedView;
+    themeWindowHasKeyAppearance = !(states & WindowInactiveState);
+
+    return themeView;
 }
 
 void ThemeMac::setFocusRingClipRect(const FloatRect& rect)

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (164172 => 164173)


--- trunk/Source/WebCore/rendering/RenderThemeMac.mm	2014-02-15 17:06:17 UTC (rev 164172)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm	2014-02-15 17:51:57 UTC (rev 164173)
@@ -179,7 +179,7 @@
 
 NSView* RenderThemeMac::documentViewFor(RenderObject* o) const
 {
-    return ThemeMac::ensuredView(&o->view().frameView());
+    return ThemeMac::ensuredView(&o->view().frameView(), controlStatesForRenderer(o));
 }
 
 #if ENABLE(VIDEO)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to