Fix the MiniBrowser build with newer clang
[WebKit-https.git] / Tools / MiniBrowser / mac / SettingsController.m
index cedbfa762ff18436db47a7052e1473025796083f..009c1f746ade1d9e7531158b0e1ada83800d8da1 100644 (file)
@@ -33,8 +33,12 @@ static NSString * const DefaultURLPreferenceKey = @"DefaultURL";
 
 static NSString * const UseWebKit2ByDefaultPreferenceKey = @"UseWebKit2ByDefault";
 static NSString * const LayerBordersVisiblePreferenceKey = @"LayerBordersVisible";
 
 static NSString * const UseWebKit2ByDefaultPreferenceKey = @"UseWebKit2ByDefault";
 static NSString * const LayerBordersVisiblePreferenceKey = @"LayerBordersVisible";
+static NSString * const SimpleLineLayoutDebugBordersEnabledPreferenceKey = @"SimpleLineLayoutDebugBordersEnabled";
 static NSString * const TiledScrollingIndicatorVisiblePreferenceKey = @"TiledScrollingIndicatorVisible";
 
 static NSString * const TiledScrollingIndicatorVisiblePreferenceKey = @"TiledScrollingIndicatorVisible";
 
+static NSString * const NonFastScrollableRegionOverlayVisiblePreferenceKey = @"NonFastScrollableRegionOverlayVisible";
+static NSString * const WheelEventHandlerRegionOverlayVisiblePreferenceKey = @"WheelEventHandlerRegionOverlayVisible";
+
 static NSString * const UseTransparentWindowsPreferenceKey = @"UseTransparentWindows";
 static NSString * const UsePaginatedModePreferenceKey = @"UsePaginatedMode";
 static NSString * const EnableSubPixelCSSOMMetricsPreferenceKey = @"EnableSubPixelCSSOMMetrics";
 static NSString * const UseTransparentWindowsPreferenceKey = @"UseTransparentWindows";
 static NSString * const UsePaginatedModePreferenceKey = @"UsePaginatedMode";
 static NSString * const EnableSubPixelCSSOMMetricsPreferenceKey = @"EnableSubPixelCSSOMMetrics";
@@ -42,9 +46,12 @@ static NSString * const EnableSubPixelCSSOMMetricsPreferenceKey = @"EnableSubPix
 // This default name intentionally overlaps with the key that WebKit2 checks when creating a view.
 static NSString * const UseRemoteLayerTreeDrawingAreaPreferenceKey = @"WebKit2UseRemoteLayerTreeDrawingArea";
 
 // This default name intentionally overlaps with the key that WebKit2 checks when creating a view.
 static NSString * const UseRemoteLayerTreeDrawingAreaPreferenceKey = @"WebKit2UseRemoteLayerTreeDrawingArea";
 
-@implementation SettingsController {
-    NSMenu *_menu;
-}
+typedef NS_ENUM(NSInteger, DebugOverylayMenuItemTag) {
+    NonFastScrollableRegionOverlayTag = 100,
+    WheelEventHandlerRegionOverlayTag
+};
+
+@implementation SettingsController
 
 @synthesize menu=_menu;
 
 
 @synthesize menu=_menu;
 
@@ -94,11 +101,31 @@ static NSString * const UseRemoteLayerTreeDrawingAreaPreferenceKey = @"WebKit2Us
     [self _addItemWithTitle:@"Use Transparent Windows" action:@selector(toggleUseTransparentWindows:) indented:NO];
     [self _addItemWithTitle:@"Use Paginated Mode" action:@selector(toggleUsePaginatedMode:) indented:NO];
     [self _addItemWithTitle:@"Show Layer Borders" action:@selector(toggleShowLayerBorders:) indented:NO];
     [self _addItemWithTitle:@"Use Transparent Windows" action:@selector(toggleUseTransparentWindows:) indented:NO];
     [self _addItemWithTitle:@"Use Paginated Mode" action:@selector(toggleUsePaginatedMode:) indented:NO];
     [self _addItemWithTitle:@"Show Layer Borders" action:@selector(toggleShowLayerBorders:) indented:NO];
+    [self _addItemWithTitle:@"Show Simple Line Layout Borders" action:@selector(toggleSimpleLineLayoutDebugBordersEnabled:) indented:NO];
 
     [self _addHeaderWithTitle:@"WebKit2-only Settings"];
 
     [self _addHeaderWithTitle:@"WebKit2-only Settings"];
+
     [self _addItemWithTitle:@"Show Tiled Scrolling Indicator" action:@selector(toggleShowTiledScrollingIndicator:) indented:YES];
     [self _addItemWithTitle:@"Use UI-Side Compositing" action:@selector(toggleUseUISideCompositing:) indented:YES];
 
     [self _addItemWithTitle:@"Show Tiled Scrolling Indicator" action:@selector(toggleShowTiledScrollingIndicator:) indented:YES];
     [self _addItemWithTitle:@"Use UI-Side Compositing" action:@selector(toggleUseUISideCompositing:) indented:YES];
 
+    NSMenuItem *debugOverlaysSubmenuItem = [[NSMenuItem alloc] initWithTitle:@"Debug Overlays" action:nil keyEquivalent:@""];
+    NSMenu *debugOverlaysMenu = [[NSMenu alloc] initWithTitle:@"Debug Overlays"];
+    [debugOverlaysSubmenuItem setSubmenu:debugOverlaysMenu];
+
+    NSMenuItem *nonFastScrollableRegionItem = [[NSMenuItem alloc] initWithTitle:@"Non-fast Scrollable Region" action:@selector(toggleDebugOverlay:) keyEquivalent:@""];
+    [nonFastScrollableRegionItem setTag:NonFastScrollableRegionOverlayTag];
+    [nonFastScrollableRegionItem setTarget:self];
+    [debugOverlaysMenu addItem:[nonFastScrollableRegionItem autorelease]];
+
+    NSMenuItem *wheelEventHandlerRegionItem = [[NSMenuItem alloc] initWithTitle:@"Wheel Event Handler Region" action:@selector(toggleDebugOverlay:) keyEquivalent:@""];
+    [wheelEventHandlerRegionItem setTag:WheelEventHandlerRegionOverlayTag];
+    [wheelEventHandlerRegionItem setTarget:self];
+    [debugOverlaysMenu addItem:[wheelEventHandlerRegionItem autorelease]];
+    [debugOverlaysMenu release];
+    
+    [_menu addItem:debugOverlaysSubmenuItem];
+    [debugOverlaysSubmenuItem release];
+
     [self _addHeaderWithTitle:@"WebKit1-only Settings"];
     [self _addItemWithTitle:@"Enable Subpixel CSSOM Metrics" action:@selector(toggleEnableSubPixelCSSOMMetrics:) indented:YES];
 }
     [self _addHeaderWithTitle:@"WebKit1-only Settings"];
     [self _addItemWithTitle:@"Enable Subpixel CSSOM Metrics" action:@selector(toggleEnableSubPixelCSSOMMetrics:) indented:YES];
 }
@@ -115,12 +142,16 @@ static NSString * const UseRemoteLayerTreeDrawingAreaPreferenceKey = @"WebKit2Us
         [menuItem setState:[self usePaginatedMode] ? NSOnState : NSOffState];
     else if (action == @selector(toggleShowLayerBorders:))
         [menuItem setState:[self layerBordersVisible] ? NSOnState : NSOffState];
         [menuItem setState:[self usePaginatedMode] ? NSOnState : NSOffState];
     else if (action == @selector(toggleShowLayerBorders:))
         [menuItem setState:[self layerBordersVisible] ? NSOnState : NSOffState];
+    else if (action == @selector(toggleSimpleLineLayoutDebugBordersEnabled:))
+        [menuItem setState:[self simpleLineLayoutDebugBordersEnabled] ? NSOnState : NSOffState];
     else if (action == @selector(toggleShowTiledScrollingIndicator:))
         [menuItem setState:[self tiledScrollingIndicatorVisible] ? NSOnState : NSOffState];
     else if (action == @selector(toggleUseUISideCompositing:))
         [menuItem setState:[self useUISideCompositing] ? NSOnState : NSOffState];
     else if (action == @selector(toggleEnableSubPixelCSSOMMetrics:))
         [menuItem setState:[self subPixelCSSOMMetricsEnabled] ? NSOnState : NSOffState];
     else if (action == @selector(toggleShowTiledScrollingIndicator:))
         [menuItem setState:[self tiledScrollingIndicatorVisible] ? NSOnState : NSOffState];
     else if (action == @selector(toggleUseUISideCompositing:))
         [menuItem setState:[self useUISideCompositing] ? NSOnState : NSOffState];
     else if (action == @selector(toggleEnableSubPixelCSSOMMetrics:))
         [menuItem setState:[self subPixelCSSOMMetricsEnabled] ? NSOnState : NSOffState];
+    else if (action == @selector(toggleDebugOverlay:))
+        [menuItem setState:[self debugOverlayVisible:menuItem] ? NSOnState : NSOffState];
 
     return YES;
 }
 
     return YES;
 }
@@ -130,7 +161,7 @@ static NSString * const UseRemoteLayerTreeDrawingAreaPreferenceKey = @"WebKit2Us
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
     [defaults setBool:![defaults boolForKey:defaultName] forKey:defaultName];
 
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
     [defaults setBool:![defaults boolForKey:defaultName] forKey:defaultName];
 
-    [(BrowserAppDelegate *)[NSApp delegate] didChangeSettings];
+    [(BrowserAppDelegate *)[[NSApplication sharedApplication] delegate] didChangeSettings];
 }
 
 - (void)toggleUseWebKit2ByDefault:(id)sender
 }
 
 - (void)toggleUseWebKit2ByDefault:(id)sender
@@ -183,6 +214,16 @@ static NSString * const UseRemoteLayerTreeDrawingAreaPreferenceKey = @"WebKit2Us
     return [[NSUserDefaults standardUserDefaults] boolForKey:LayerBordersVisiblePreferenceKey];
 }
 
     return [[NSUserDefaults standardUserDefaults] boolForKey:LayerBordersVisiblePreferenceKey];
 }
 
+- (void)toggleSimpleLineLayoutDebugBordersEnabled:(id)sender
+{
+    [self _toggleBooleanDefault:SimpleLineLayoutDebugBordersEnabledPreferenceKey];
+}
+
+- (BOOL)simpleLineLayoutDebugBordersEnabled
+{
+    return [[NSUserDefaults standardUserDefaults] boolForKey:SimpleLineLayoutDebugBordersEnabledPreferenceKey];
+}
+
 - (void)toggleShowTiledScrollingIndicator:(id)sender
 {
     [self _toggleBooleanDefault:TiledScrollingIndicatorVisiblePreferenceKey];
 - (void)toggleShowTiledScrollingIndicator:(id)sender
 {
     [self _toggleBooleanDefault:TiledScrollingIndicatorVisiblePreferenceKey];
@@ -203,6 +244,44 @@ static NSString * const UseRemoteLayerTreeDrawingAreaPreferenceKey = @"WebKit2Us
     return [[NSUserDefaults standardUserDefaults] boolForKey:EnableSubPixelCSSOMMetricsPreferenceKey];
 }
 
     return [[NSUserDefaults standardUserDefaults] boolForKey:EnableSubPixelCSSOMMetricsPreferenceKey];
 }
 
+- (BOOL)nonFastScrollableRegionOverlayVisible
+{
+    return [[NSUserDefaults standardUserDefaults] boolForKey:NonFastScrollableRegionOverlayVisiblePreferenceKey];
+}
+
+- (BOOL)wheelEventHandlerRegionOverlayVisible
+{
+    return [[NSUserDefaults standardUserDefaults] boolForKey:WheelEventHandlerRegionOverlayVisiblePreferenceKey];
+}
+
+- (NSString *)preferenceKeyForRegionOverlayTag:(NSUInteger)tag
+{
+    switch (tag) {
+    case NonFastScrollableRegionOverlayTag:
+        return NonFastScrollableRegionOverlayVisiblePreferenceKey;
+
+    case WheelEventHandlerRegionOverlayTag:
+        return WheelEventHandlerRegionOverlayVisiblePreferenceKey;
+    }
+    return nil;
+}
+
+- (void)toggleDebugOverlay:(id)sender
+{
+    NSString *preferenceKey = [self preferenceKeyForRegionOverlayTag:[sender tag]];
+    if (preferenceKey)
+        [self _toggleBooleanDefault:preferenceKey];
+}
+
+- (BOOL)debugOverlayVisible:(NSMenuItem *)menuItem
+{
+    NSString *preferenceKey = [self preferenceKeyForRegionOverlayTag:[menuItem tag]];
+    if (preferenceKey)
+        return [[NSUserDefaults standardUserDefaults] boolForKey:preferenceKey];
+
+    return NO;
+}
+
 - (NSString *)defaultURL
 {
     NSString *customDefaultURL = [[NSUserDefaults standardUserDefaults] stringForKey:DefaultURLPreferenceKey];
 - (NSString *)defaultURL
 {
     NSString *customDefaultURL = [[NSUserDefaults standardUserDefaults] stringForKey:DefaultURLPreferenceKey];