Title: [104331] trunk
Revision
104331
Author
[email protected]
Date
2012-01-06 13:44:50 -0800 (Fri, 06 Jan 2012)

Log Message

Mitigate scrollbar differences when running pixel tests
https://bugs.webkit.org/show_bug.cgi?id=67217

Source/WebCore:

Reviewed by Dan Bernstein.

Export WebCore::Settings::mockScrollbarsEnabled() for DRT.

* WebCore.exp.in:

Source/WebKit/mac:

Reviewed by Dan Bernstein.

Make it possible to register a custom NSScroller class, which
the WebDynamicScrollBarsView will use when mock scrollbars are enabled.

Also ensure that the WebPreferences mock scrollbars preference is
migrated into Settings.

* WebView/WebDynamicScrollBarsView.h:
* WebView/WebDynamicScrollBarsView.mm:
(+[WebDynamicScrollBarsView _horizontalScrollerClass]):
(+[WebDynamicScrollBarsView _verticalScrollerClass]):
(+[WebDynamicScrollBarsView setCustomScrollerClass:]):
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):

Tools:

Reviewed by Dan Bernstein.

Add an NSScroller subclass that draws mock scrollbars identically
to the WebCore mock scrollbar theme, and register it with the
WebDynamicScrollbarsView.

* DumpRenderTree/mac/DumpRenderTree.mm:
(-[DRTMockScroller rectForPart:]):
(-[DRTMockScroller drawKnob]):
(-[DRTMockScroller drawRect:]):
(registerMockScrollbars):
(prepareConsistentTestingEnvironment):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (104330 => 104331)


--- trunk/Source/WebCore/ChangeLog	2012-01-06 21:19:54 UTC (rev 104330)
+++ trunk/Source/WebCore/ChangeLog	2012-01-06 21:44:50 UTC (rev 104331)
@@ -1,3 +1,14 @@
+2012-01-06  Simon Fraser  <[email protected]>
+
+        Mitigate scrollbar differences when running pixel tests
+        https://bugs.webkit.org/show_bug.cgi?id=67217
+
+        Reviewed by Dan Bernstein.
+
+        Export WebCore::Settings::mockScrollbarsEnabled() for DRT.
+
+        * WebCore.exp.in:
+
 2012-01-06  Tom Sepez  <[email protected]>
 
         Pass Content-Security-Policy directives to worker threads.

Modified: trunk/Source/WebCore/WebCore.exp.in (104330 => 104331)


--- trunk/Source/WebCore/WebCore.exp.in	2012-01-06 21:19:54 UTC (rev 104330)
+++ trunk/Source/WebCore/WebCore.exp.in	2012-01-06 21:44:50 UTC (rev 104331)
@@ -943,6 +943,7 @@
 __ZN7WebCore8Settings20setCursiveFontFamilyERKN3WTF12AtomicStringE11UScriptCode
 __ZN7WebCore8Settings20setFantasyFontFamilyERKN3WTF12AtomicStringE11UScriptCode
 __ZN7WebCore8Settings20setXSSAuditorEnabledEb
+__ZN7WebCore8Settings21mockScrollbarsEnabledEv
 __ZN7WebCore8Settings21setShowRepaintCounterEb
 __ZN7WebCore8Settings21setStandardFontFamilyERKN3WTF12AtomicStringE11UScriptCode
 __ZN7WebCore8Settings21setWebSecurityEnabledEb

Modified: trunk/Source/WebKit/mac/ChangeLog (104330 => 104331)


--- trunk/Source/WebKit/mac/ChangeLog	2012-01-06 21:19:54 UTC (rev 104330)
+++ trunk/Source/WebKit/mac/ChangeLog	2012-01-06 21:44:50 UTC (rev 104331)
@@ -1,3 +1,24 @@
+2012-01-06  Simon Fraser  <[email protected]>
+
+        Mitigate scrollbar differences when running pixel tests
+        https://bugs.webkit.org/show_bug.cgi?id=67217
+
+        Reviewed by Dan Bernstein.
+        
+        Make it possible to register a custom NSScroller class, which
+        the WebDynamicScrollBarsView will use when mock scrollbars are enabled.
+        
+        Also ensure that the WebPreferences mock scrollbars preference is
+        migrated into Settings.
+
+        * WebView/WebDynamicScrollBarsView.h:
+        * WebView/WebDynamicScrollBarsView.mm:
+        (+[WebDynamicScrollBarsView _horizontalScrollerClass]):
+        (+[WebDynamicScrollBarsView _verticalScrollerClass]):
+        (+[WebDynamicScrollBarsView setCustomScrollerClass:]):
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]):
+
 2012-01-05  Dan Bernstein  <[email protected]>
 
         <rdar://problem/10633760> Update copyright strings

Modified: trunk/Source/WebKit/mac/WebView/WebDynamicScrollBarsView.h (104330 => 104331)


--- trunk/Source/WebKit/mac/WebView/WebDynamicScrollBarsView.h	2012-01-06 21:19:54 UTC (rev 104330)
+++ trunk/Source/WebKit/mac/WebView/WebDynamicScrollBarsView.h	2012-01-06 21:44:50 UTC (rev 104331)
@@ -42,6 +42,9 @@
 #endif
 }
 
+// For use by DumpRenderTree only.
++ (void)setCustomScrollerClass:(Class)scrollerClass;
+
 // This was originally added for Safari's benefit, but Safari has not used it for a long time.
 // Perhaps it can be removed.
 - (void)setAllowsHorizontalScrolling:(BOOL)flag;

Modified: trunk/Source/WebKit/mac/WebView/WebDynamicScrollBarsView.mm (104330 => 104331)


--- trunk/Source/WebKit/mac/WebView/WebDynamicScrollBarsView.mm	2012-01-06 21:19:54 UTC (rev 104330)
+++ trunk/Source/WebKit/mac/WebView/WebDynamicScrollBarsView.mm	2012-01-06 21:44:50 UTC (rev 104331)
@@ -43,6 +43,11 @@
 COMPILE_ASSERT(sizeof(WebDynamicScrollBarsView) == 0x8c, WebDynamicScrollBarsView_is_expected_size);
 #endif
 
+@interface NSScrollView(WebNSScrollViewDetails)
++ (Class)_horizontalScrollerClass;
++ (Class)_verticalScrollerClass;
+@end
+
 struct WebDynamicScrollBarsViewPrivate {
     unsigned inUpdateScrollersLayoutPass;
 
@@ -77,6 +82,29 @@
 
 @implementation WebDynamicScrollBarsView
 
+static Class customScrollerClass;
+
++ (Class)_horizontalScrollerClass
+{
+    if (Settings::mockScrollbarsEnabled() && customScrollerClass)
+        return customScrollerClass;
+
+    return [super _horizontalScrollerClass];
+}
+
++ (Class)_verticalScrollerClass
+{
+    if (Settings::mockScrollbarsEnabled() && customScrollerClass)
+        return customScrollerClass;
+
+    return [super _horizontalScrollerClass];
+}
+
++ (void)setCustomScrollerClass:(Class)scrollerClass
+{
+    customScrollerClass = scrollerClass;
+}
+
 - (id)initWithFrame:(NSRect)frame
 {
     if (!(self = [super initWithFrame:frame]))

Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (104330 => 104331)


--- trunk/Source/WebKit/mac/WebView/WebView.mm	2012-01-06 21:19:54 UTC (rev 104330)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm	2012-01-06 21:44:50 UTC (rev 104331)
@@ -1497,6 +1497,7 @@
     settings->setMediaPlaybackAllowsInline([preferences mediaPlaybackAllowsInline]);
     settings->setSuppressIncrementalRendering([preferences suppressIncrementalRendering]);
     settings->setBackspaceKeyNavigationEnabled([preferences backspaceKeyNavigationEnabled]);
+    settings->setMockScrollbarsEnabled([preferences mockScrollbarsEnabled]);
 
 #if ENABLE(VIDEO_TRACK)
     settings->setShouldDisplaySubtitles([preferences shouldDisplaySubtitles]);

Modified: trunk/Tools/ChangeLog (104330 => 104331)


--- trunk/Tools/ChangeLog	2012-01-06 21:19:54 UTC (rev 104330)
+++ trunk/Tools/ChangeLog	2012-01-06 21:44:50 UTC (rev 104331)
@@ -1,3 +1,21 @@
+2012-01-06  Simon Fraser  <[email protected]>
+
+        Mitigate scrollbar differences when running pixel tests
+        https://bugs.webkit.org/show_bug.cgi?id=67217
+
+        Reviewed by Dan Bernstein.
+        
+        Add an NSScroller subclass that draws mock scrollbars identically
+        to the WebCore mock scrollbar theme, and register it with the
+        WebDynamicScrollbarsView.
+
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (-[DRTMockScroller rectForPart:]):
+        (-[DRTMockScroller drawKnob]):
+        (-[DRTMockScroller drawRect:]):
+        (registerMockScrollbars):
+        (prepareConsistentTestingEnvironment):
+
 2012-01-05  Jon Lee  <[email protected]>
 
         Update DRT on Mac to draw resize handles on text areas.

Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (104330 => 104331)


--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2012-01-06 21:19:54 UTC (rev 104330)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2012-01-06 21:44:50 UTC (rev 104331)
@@ -68,6 +68,7 @@
 #import <WebKit/WebDatabaseManagerPrivate.h>
 #import <WebKit/WebDocumentPrivate.h>
 #import <WebKit/WebDeviceOrientationProviderMock.h>
+#import <WebKit/WebDynamicScrollbarsView.h>
 #import <WebKit/WebEditingDelegate.h>
 #import <WebKit/WebFrameView.h>
 #import <WebKit/WebHistory.h>
@@ -439,6 +440,60 @@
     activateTestingFonts();
 }
 
+@interface DRTMockScroller : NSScroller
+@end
+
+@implementation DRTMockScroller
+
+- (NSRect)rectForPart:(NSScrollerPart)partCode
+{
+    switch (partCode) {
+    case NSScrollerKnob: {
+        NSRect frameRect = [self frame];
+        NSRect bounds = [self bounds];
+        BOOL isHorizontal = frameRect.size.width > frameRect.size.height;
+        CGFloat trackLength = isHorizontal ? bounds.size.width : bounds.size.height;
+        CGFloat minKnobSize = isHorizontal ? bounds.size.height : bounds.size.width;
+        CGFloat knobLength = max(minKnobSize, static_cast<CGFloat>(round(trackLength * [self knobProportion])));
+        CGFloat knobPosition = static_cast<CGFloat>((round([self doubleValue] * (trackLength - knobLength))));
+        
+        if (isHorizontal)
+            return NSMakeRect(bounds.origin.x + knobPosition, bounds.origin.y, knobLength, bounds.size.height);
+
+        return NSMakeRect(bounds.origin.x, bounds.origin.y +  + knobPosition, bounds.size.width, knobLength);
+    }
+    }
+    
+    return [super rectForPart:partCode];
+}
+
+- (void)drawKnob
+{
+    NSRect knobRect = [self rectForPart:NSScrollerKnob];
+    
+    static NSColor *knobColor = [[NSColor colorWithDeviceRed:0x80 / 255.0 green:0x80 / 255.0 blue:0x80 / 255.0 alpha:1] retain];
+    [knobColor set];
+
+    NSRectFill(knobRect);
+}
+
+- (void)drawRect:(NSRect)dirtyRect
+{
+    static NSColor *trackColor = [[NSColor colorWithDeviceRed:0xC0 / 255.0 green:0xC0 / 255.0 blue:0xC0 / 255.0 alpha:1] retain];
+    [trackColor set];
+
+    NSRectFill(dirtyRect);
+    
+    [self drawKnob];
+}
+
+@end
+
+static void registerMockScrollbars()
+{
+    [WebDynamicScrollBarsView setCustomScrollerClass:[DRTMockScroller class]];
+}
+
 WebView *createWebViewAndOffscreenWindow()
 {
     NSRect rect = NSMakeRect(0, 0, LayoutTestController::maxViewWidth, LayoutTestController::maxViewHeight);
@@ -753,6 +808,7 @@
 
     setDefaultsToConsistentValuesForTesting();
     adjustFonts();
+    registerMockScrollbars();
     
     if (dumpPixels)
         setupMainDisplayColorProfile();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to