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):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@104331 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5b955fb4
2012-01-06 Simon Fraser <simon.fraser@apple.com>
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 <tsepez@chromium.org>
Pass Content-Security-Policy directives to worker threads.
......@@ -943,6 +943,7 @@ __ZN7WebCore8Settings19setShowDebugBordersEb
__ZN7WebCore8Settings20setCursiveFontFamilyERKN3WTF12AtomicStringE11UScriptCode
__ZN7WebCore8Settings20setFantasyFontFamilyERKN3WTF12AtomicStringE11UScriptCode
__ZN7WebCore8Settings20setXSSAuditorEnabledEb
__ZN7WebCore8Settings21mockScrollbarsEnabledEv
__ZN7WebCore8Settings21setShowRepaintCounterEb
__ZN7WebCore8Settings21setStandardFontFamilyERKN3WTF12AtomicStringE11UScriptCode
__ZN7WebCore8Settings21setWebSecurityEnabledEb
......
2012-01-06 Simon Fraser <simon.fraser@apple.com>
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 <mitz@apple.com>
<rdar://problem/10633760> Update copyright strings
......
......@@ -42,6 +42,9 @@ struct WebDynamicScrollBarsViewPrivate;
#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;
......
......@@ -43,6 +43,11 @@ const int WebCoreScrollbarAlwaysOn = ScrollbarAlwaysOn;
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 @@ struct WebDynamicScrollBarsViewPrivate {
@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]))
......
......@@ -1497,6 +1497,7 @@ static bool needsSelfRetainWhileLoadingQuirk()
settings->setMediaPlaybackAllowsInline([preferences mediaPlaybackAllowsInline]);
settings->setSuppressIncrementalRendering([preferences suppressIncrementalRendering]);
settings->setBackspaceKeyNavigationEnabled([preferences backspaceKeyNavigationEnabled]);
settings->setMockScrollbarsEnabled([preferences mockScrollbarsEnabled]);
#if ENABLE(VIDEO_TRACK)
settings->setShouldDisplaySubtitles([preferences shouldDisplaySubtitles]);
......
2012-01-06 Simon Fraser <simon.fraser@apple.com>
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 <jonlee@apple.com>
Update DRT on Mac to draw resize handles on text areas.
......@@ -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 @@ static void adjustFonts()
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 @@ static void prepareConsistentTestingEnvironment()
setDefaultsToConsistentValuesForTesting();
adjustFonts();
registerMockScrollbars();
if (dumpPixels)
setupMainDisplayColorProfile();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment