Title: [207512] trunk
Revision
207512
Author
simon.fra...@apple.com
Date
2016-10-18 18:03:23 -0700 (Tue, 18 Oct 2016)

Log Message

Add a MiniBrowser menu item to apply page scale in WK1 and WK2
https://bugs.webkit.org/show_bug.cgi?id=163627

Reviewed by Dean Jackson.

Source/WebKit/mac:

Add an explanatory comment about viewScaleFactor not really being viewScaleFactor.

* WebView/WebViewPrivate.h:

Source/WebKit2:

New SPI to set and retrieve page scale.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _setPageScale:withOrigin:]):
(-[WKWebView _pageScale]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:

Tools:

Rename setScale: to setViewScale: and add setPageScale:, hooking it up for WK1 (via exisiting SPI)
and WK2 (via new SPI).

* MiniBrowser/mac/BrowserWindowController.h:
* MiniBrowser/mac/BrowserWindowController.m:
(-[BrowserWindowController pageScaleForMenuItemTag:]):
(-[BrowserWindowController setPageScale:]):
(-[BrowserWindowController setViewScale:]):
(-[BrowserWindowController setScale:]): Deleted.
* MiniBrowser/mac/MainMenu.xib:
* MiniBrowser/mac/WK1BrowserWindowController.m:
(-[WK1BrowserWindowController setPageScale:]):
(-[WK1BrowserWindowController setViewScale:]):
(areEssentiallyEqual):
(-[WK1BrowserWindowController validateMenuItem:]):
(-[WK1BrowserWindowController setScale:]): Deleted.
* MiniBrowser/mac/WK2BrowserWindowController.m:
(-[WK2BrowserWindowController setPageScale:]):
(-[WK2BrowserWindowController viewScaleForMenuItemTag:]):
(-[WK2BrowserWindowController setViewScale:]):
(areEssentiallyEqual):
(-[WK2BrowserWindowController validateMenuItem:]):
(viewScaleForMenuItemTag): Deleted.
(-[WK2BrowserWindowController setScale:]): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebKit/mac/ChangeLog (207511 => 207512)


--- trunk/Source/WebKit/mac/ChangeLog	2016-10-19 00:51:13 UTC (rev 207511)
+++ trunk/Source/WebKit/mac/ChangeLog	2016-10-19 01:03:23 UTC (rev 207512)
@@ -1,3 +1,14 @@
+2016-10-18  Simon Fraser  <simon.fra...@apple.com>
+
+        Add a MiniBrowser menu item to apply page scale in WK1 and WK2
+        https://bugs.webkit.org/show_bug.cgi?id=163627
+
+        Reviewed by Dean Jackson.
+
+        Add an explanatory comment about viewScaleFactor not really being viewScaleFactor.
+
+        * WebView/WebViewPrivate.h:
+
 2016-10-18  Dean Jackson  <d...@apple.com>
 
         Remove CSS_SHAPES feature definition. This should always be on.

Modified: trunk/Source/WebKit/mac/WebView/WebViewPrivate.h (207511 => 207512)


--- trunk/Source/WebKit/mac/WebView/WebViewPrivate.h	2016-10-19 00:51:13 UTC (rev 207511)
+++ trunk/Source/WebKit/mac/WebView/WebViewPrivate.h	2016-10-19 01:03:23 UTC (rev 207512)
@@ -813,7 +813,7 @@
 + (void)_registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing:(NSString *)scheme;
 
 - (void)_scaleWebView:(float)scale atOrigin:(NSPoint)origin;
-- (float)_viewScaleFactor;
+- (float)_viewScaleFactor; // This is actually pageScaleFactor.
 
 - (void)_setUseFixedLayout:(BOOL)fixed;
 - (void)_setFixedLayoutSize:(NSSize)size;

Modified: trunk/Source/WebKit2/ChangeLog (207511 => 207512)


--- trunk/Source/WebKit2/ChangeLog	2016-10-19 00:51:13 UTC (rev 207511)
+++ trunk/Source/WebKit2/ChangeLog	2016-10-19 01:03:23 UTC (rev 207512)
@@ -1,3 +1,17 @@
+2016-10-18  Simon Fraser  <simon.fra...@apple.com>
+
+        Add a MiniBrowser menu item to apply page scale in WK1 and WK2
+        https://bugs.webkit.org/show_bug.cgi?id=163627
+
+        Reviewed by Dean Jackson.
+
+        New SPI to set and retrieve page scale.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _setPageScale:withOrigin:]):
+        (-[WKWebView _pageScale]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+
 2016-10-18  Dean Jackson  <d...@apple.com>
 
         Remove CSS_SHAPES feature definition. This should always be on.

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (207511 => 207512)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2016-10-19 00:51:13 UTC (rev 207511)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2016-10-19 01:03:23 UTC (rev 207512)
@@ -4620,6 +4620,16 @@
 }
 #endif // PLATFORM(MAC)
 
+- (void)_setPageScale:(CGFloat)scale withOrigin:(CGPoint)origin
+{
+    _page->scalePage(scale, WebCore::roundedIntPoint(origin));
+}
+
+- (CGFloat)_pageScale
+{
+    return _page->pageScaleFactor();
+}
+
 // Execute the supplied block after the next transaction from the WebProcess.
 - (void)_doAfterNextPresentationUpdate:(void (^)(void))updateBlock
 {

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (207511 => 207512)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2016-10-19 00:51:13 UTC (rev 207511)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2016-10-19 01:03:23 UTC (rev 207512)
@@ -288,6 +288,9 @@
 - (void)_handleActiveNowPlayingSessionInfoResponse:(BOOL)hasActiveSession title:(NSString *)title duration:(double)duration elapsedTime:(double)elapsedTime WK_API_AVAILABLE(macosx(WK_MAC_TBA));
 #endif
 
+- (void)_setPageScale:(CGFloat)scale withOrigin:(CGPoint)origin WK_API_AVAILABLE(ios(WK_IOS_TBA));
+- (CGFloat)_pageScale WK_API_AVAILABLE(ios(WK_IOS_TBA));
+
 - (void)_doAfterNextPresentationUpdate:(void (^)(void))updateBlock WK_API_AVAILABLE(macosx(10.12), ios(10.0));
 
 - (void)_disableBackForwardSnapshotVolatilityForTesting WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));

Modified: trunk/Tools/ChangeLog (207511 => 207512)


--- trunk/Tools/ChangeLog	2016-10-19 00:51:13 UTC (rev 207511)
+++ trunk/Tools/ChangeLog	2016-10-19 01:03:23 UTC (rev 207512)
@@ -1,3 +1,35 @@
+2016-10-18  Simon Fraser  <simon.fra...@apple.com>
+
+        Add a MiniBrowser menu item to apply page scale in WK1 and WK2
+        https://bugs.webkit.org/show_bug.cgi?id=163627
+
+        Reviewed by Dean Jackson.
+
+        Rename setScale: to setViewScale: and add setPageScale:, hooking it up for WK1 (via exisiting SPI)
+        and WK2 (via new SPI).
+
+        * MiniBrowser/mac/BrowserWindowController.h:
+        * MiniBrowser/mac/BrowserWindowController.m:
+        (-[BrowserWindowController pageScaleForMenuItemTag:]):
+        (-[BrowserWindowController setPageScale:]):
+        (-[BrowserWindowController setViewScale:]):
+        (-[BrowserWindowController setScale:]): Deleted.
+        * MiniBrowser/mac/MainMenu.xib:
+        * MiniBrowser/mac/WK1BrowserWindowController.m:
+        (-[WK1BrowserWindowController setPageScale:]):
+        (-[WK1BrowserWindowController setViewScale:]):
+        (areEssentiallyEqual):
+        (-[WK1BrowserWindowController validateMenuItem:]):
+        (-[WK1BrowserWindowController setScale:]): Deleted.
+        * MiniBrowser/mac/WK2BrowserWindowController.m:
+        (-[WK2BrowserWindowController setPageScale:]):
+        (-[WK2BrowserWindowController viewScaleForMenuItemTag:]):
+        (-[WK2BrowserWindowController setViewScale:]):
+        (areEssentiallyEqual):
+        (-[WK2BrowserWindowController validateMenuItem:]):
+        (viewScaleForMenuItemTag): Deleted.
+        (-[WK2BrowserWindowController setScale:]): Deleted.
+
 2016-10-18  Anders Carlsson  <ander...@apple.com>
 
         Add an beforeunload alert to the WebKitLegacy MiniBrowser

Modified: trunk/Tools/MiniBrowser/mac/BrowserWindowController.h (207511 => 207512)


--- trunk/Tools/MiniBrowser/mac/BrowserWindowController.h	2016-10-19 00:51:13 UTC (rev 207511)
+++ trunk/Tools/MiniBrowser/mac/BrowserWindowController.h	2016-10-19 01:03:23 UTC (rev 207512)
@@ -67,7 +67,8 @@
 
 - (IBAction)toggleZoomMode:(id)sender;
 
-- (IBAction)setScale:(id)sender;
+- (IBAction)setPageScale:(id)sender;
+- (IBAction)setViewScale:(id)sender;
 
 - (IBAction)toggleShrinkToFit:(id)sender;
 
@@ -79,5 +80,7 @@
 - (NSURL *)currentURL;
 - (NSView *)mainContentView;
 
+- (CGFloat)pageScaleForMenuItemTag:(NSInteger)tag;
+
 @end
 

Modified: trunk/Tools/MiniBrowser/mac/BrowserWindowController.m (207511 => 207512)


--- trunk/Tools/MiniBrowser/mac/BrowserWindowController.m	2016-10-19 00:51:13 UTC (rev 207511)
+++ trunk/Tools/MiniBrowser/mac/BrowserWindowController.m	2016-10-19 01:03:23 UTC (rev 207512)
@@ -157,11 +157,30 @@
     [self doesNotRecognizeSelector:_cmd];
 }
 
-- (IBAction)setScale:(id)sender
+- (CGFloat)pageScaleForMenuItemTag:(NSInteger)tag
 {
+    if (tag == 1)
+        return 1;
+    if (tag == 2)
+        return 1.25;
+    if (tag == 3)
+        return 1.5;
+    if (tag == 4)
+        return 2.0;
+
+    return 1;
+}
+
+- (IBAction)setPageScale:(id)sender
+{
     [self doesNotRecognizeSelector:_cmd];
 }
 
+- (IBAction)setViewScale:(id)sender
+{
+    [self doesNotRecognizeSelector:_cmd];
+}
+
 - (IBAction)toggleShrinkToFit:(id)sender
 {
     [self doesNotRecognizeSelector:_cmd];

Modified: trunk/Tools/MiniBrowser/mac/MainMenu.xib (207511 => 207512)


--- trunk/Tools/MiniBrowser/mac/MainMenu.xib	2016-10-19 00:51:13 UTC (rev 207511)
+++ trunk/Tools/MiniBrowser/mac/MainMenu.xib	2016-10-19 01:03:23 UTC (rev 207512)
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="8096.6" systemVersion="15A178f" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11521.1" systemVersion="16B2648a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="8096.6"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11521.1"/>
     </dependencies>
     <objects>
         <customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
@@ -12,10 +12,10 @@
         </customObject>
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
         <customObject id="-3" userLabel="Application" customClass="NSObject"/>
-        <menu title="AMainMenu" systemMenu="main" userInterfaceLayoutDirection="leftToRight" id="29">
+        <menu title="AMainMenu" systemMenu="main" id="29">
             <items>
                 <menuItem title="MiniBrowser" id="56">
-                    <menu key="submenu" title="MiniBrowser" systemMenu="apple" userInterfaceLayoutDirection="leftToRight" id="57">
+                    <menu key="submenu" title="MiniBrowser" systemMenu="apple" id="57">
                         <items>
                             <menuItem title="About MiniBrowser" id="58">
                                 <modifierMask key="keyEquivalentModifierMask"/>
@@ -31,7 +31,7 @@
                                 <modifierMask key="keyEquivalentModifierMask" command="YES"/>
                             </menuItem>
                             <menuItem title="Services" id="131">
-                                <menu key="submenu" title="Services" systemMenu="services" userInterfaceLayoutDirection="leftToRight" id="130"/>
+                                <menu key="submenu" title="Services" systemMenu="services" id="130"/>
                             </menuItem>
                             <menuItem isSeparatorItem="YES" id="144">
                                 <modifierMask key="keyEquivalentModifierMask" command="YES"/>
@@ -64,7 +64,7 @@
                     </menu>
                 </menuItem>
                 <menuItem title="File" id="83">
-                    <menu key="submenu" title="File" userInterfaceLayoutDirection="leftToRight" id="81">
+                    <menu key="submenu" title="File" id="81">
                         <items>
                             <menuItem title="Open Location " tag="1" keyEquivalent="l" id="82">
                                 <connections>
@@ -94,7 +94,7 @@
                                 </connections>
                             </menuItem>
                             <menuItem title="Open Recent" id="124">
-                                <menu key="submenu" title="Open Recent" systemMenu="recentDocuments" userInterfaceLayoutDirection="leftToRight" id="125">
+                                <menu key="submenu" title="Open Recent" systemMenu="recentDocuments" id="125">
                                     <items>
                                         <menuItem title="Clear Menu" id="126">
                                             <connections>
@@ -147,7 +147,7 @@
                     </menu>
                 </menuItem>
                 <menuItem title="Edit" id="217">
-                    <menu key="submenu" title="Edit" userInterfaceLayoutDirection="leftToRight" id="205">
+                    <menu key="submenu" title="Edit" id="205">
                         <items>
                             <menuItem title="Undo" keyEquivalent="z" id="207">
                                 <connections>
@@ -198,7 +198,7 @@
                                 <modifierMask key="keyEquivalentModifierMask" command="YES"/>
                             </menuItem>
                             <menuItem title="Find" id="218">
-                                <menu key="submenu" title="Find" userInterfaceLayoutDirection="leftToRight" id="220">
+                                <menu key="submenu" title="Find" id="220">
                                     <items>
                                         <menuItem title="Find…" tag="1" keyEquivalent="f" id="209">
                                             <connections>
@@ -230,7 +230,7 @@
                                 </menu>
                             </menuItem>
                             <menuItem title="Spelling and Grammar" id="216">
-                                <menu key="submenu" title="Spelling and Grammar" userInterfaceLayoutDirection="leftToRight" id="200">
+                                <menu key="submenu" title="Spelling and Grammar" id="200">
                                     <items>
                                         <menuItem title="Show Spelling and Grammar" keyEquivalent=":" id="204">
                                             <connections>
@@ -263,7 +263,7 @@
                                 </menu>
                             </menuItem>
                             <menuItem title="Substitutions" id="348">
-                                <menu key="submenu" title="Substitutions" userInterfaceLayoutDirection="leftToRight" id="349">
+                                <menu key="submenu" title="Substitutions" id="349">
                                     <items>
                                         <menuItem title="Show Substitutions" id="457">
                                             <modifierMask key="keyEquivalentModifierMask"/>
@@ -305,7 +305,7 @@
                             </menuItem>
                             <menuItem title="Transformations" id="450">
                                 <modifierMask key="keyEquivalentModifierMask"/>
-                                <menu key="submenu" title="Transformations" userInterfaceLayoutDirection="leftToRight" id="451">
+                                <menu key="submenu" title="Transformations" id="451">
                                     <items>
                                         <menuItem title="Make Upper Case" id="452">
                                             <modifierMask key="keyEquivalentModifierMask"/>
@@ -329,7 +329,7 @@
                                 </menu>
                             </menuItem>
                             <menuItem title="Speech" id="211">
-                                <menu key="submenu" title="Speech" userInterfaceLayoutDirection="leftToRight" id="212">
+                                <menu key="submenu" title="Speech" id="212">
                                     <items>
                                         <menuItem title="Start Speaking" id="196">
                                             <connections>
@@ -348,7 +348,7 @@
                     </menu>
                 </menuItem>
                 <menuItem title="View" id="295">
-                    <menu key="submenu" title="View" userInterfaceLayoutDirection="leftToRight" id="296">
+                    <menu key="submenu" title="View" id="296">
                         <items>
                             <menuItem title="Show Toolbar" keyEquivalent="t" id="297">
                                 <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
@@ -383,28 +383,59 @@
                                     <action selector="toggleZoomMode:" target="-1" id="564"/>
                                 </connections>
                             </menuItem>
+                            <menuItem title="Page Scale" id="Hzb-c3-Qfv">
+                                <modifierMask key="keyEquivalentModifierMask"/>
+                                <menu key="submenu" title="Page Scale" id="jdo-5V-3CM">
+                                    <items>
+                                        <menuItem title="100%" state="on" tag="1" keyEquivalent="1" id="wHb-mR-Fv0">
+                                            <connections>
+                                                <action selector="setPageScale:" target="-1" id="uMw-eY-289"/>
+                                            </connections>
+                                        </menuItem>
+                                        <menuItem title="125%" tag="2" keyEquivalent="2" id="u4i-F7-rPb">
+                                            <connections>
+                                                <action selector="setPageScale:" target="-1" id="IbE-Ep-hfc"/>
+                                            </connections>
+                                        </menuItem>
+                                        <menuItem title="150%" tag="3" keyEquivalent="3" id="fwT-Iy-oK9">
+                                            <connections>
+                                                <action selector="setPageScale:" target="-1" id="9c0-eN-0f5"/>
+                                            </connections>
+                                        </menuItem>
+                                        <menuItem title="200%" tag="4" keyEquivalent="4" id="R5e-ct-O2u">
+                                            <connections>
+                                                <action selector="setPageScale:" target="-1" id="mkk-gh-dlN"/>
+                                            </connections>
+                                        </menuItem>
+                                    </items>
+                                </menu>
+                            </menuItem>
                             <menuItem title="View Scale" id="8UY-Pj-H13">
                                 <modifierMask key="keyEquivalentModifierMask"/>
-                                <menu key="submenu" title="View Scale" userInterfaceLayoutDirection="leftToRight" id="Ml8-mk-ffu">
+                                <menu key="submenu" title="View Scale" id="Ml8-mk-ffu">
                                     <items>
-                                        <menuItem title="100%" state="on" tag="1" keyEquivalent="1" id="EAm-Xn-VrC">
+                                        <menuItem title="100%" state="on" tag="1" id="EAm-Xn-VrC">
+                                            <modifierMask key="keyEquivalentModifierMask"/>
                                             <connections>
-                                                <action selector="setScale:" target="-1" id="aaW-VE-lxu"/>
+                                                <action selector="setViewScale:" target="-1" id="dkW-CI-RG4"/>
                                             </connections>
                                         </menuItem>
-                                        <menuItem title="75%" tag="2" keyEquivalent="2" id="jcA-I1-Cbq">
+                                        <menuItem title="75%" tag="2" id="jcA-I1-Cbq">
+                                            <modifierMask key="keyEquivalentModifierMask"/>
                                             <connections>
-                                                <action selector="setScale:" target="-1" id="voc-3W-ppg"/>
+                                                <action selector="setViewScale:" target="-1" id="BAF-Ym-IqV"/>
                                             </connections>
                                         </menuItem>
-                                        <menuItem title="50%" tag="3" keyEquivalent="3" id="BRM-D5-YNO">
+                                        <menuItem title="50%" tag="3" id="BRM-D5-YNO">
+                                            <modifierMask key="keyEquivalentModifierMask"/>
                                             <connections>
-                                                <action selector="setScale:" target="-1" id="sfY-6N-EeS"/>
+                                                <action selector="setViewScale:" target="-1" id="nXy-2b-9Zz"/>
                                             </connections>
                                         </menuItem>
-                                        <menuItem title="25%" tag="4" keyEquivalent="4" id="gzk-YK-x0W">
+                                        <menuItem title="25%" tag="4" id="gzk-YK-x0W">
+                                            <modifierMask key="keyEquivalentModifierMask"/>
                                             <connections>
-                                                <action selector="setScale:" target="-1" id="WPq-Rm-CVA"/>
+                                                <action selector="setViewScale:" target="-1" id="KXK-f6-24N"/>
                                             </connections>
                                         </menuItem>
                                     </items>
@@ -420,7 +451,7 @@
                     </menu>
                 </menuItem>
                 <menuItem title="Window" id="19">
-                    <menu key="submenu" title="Window" systemMenu="window" userInterfaceLayoutDirection="leftToRight" id="24">
+                    <menu key="submenu" title="Window" systemMenu="window" id="24">
                         <items>
                             <menuItem title="Minimize" keyEquivalent="m" id="23">
                                 <connections>
@@ -445,7 +476,7 @@
                 </menuItem>
                 <menuItem title="Help" id="490">
                     <modifierMask key="keyEquivalentModifierMask"/>
-                    <menu key="submenu" title="Help" systemMenu="help" userInterfaceLayoutDirection="leftToRight" id="491">
+                    <menu key="submenu" title="Help" systemMenu="help" id="491">
                         <items>
                             <menuItem title="MiniBrowser Help" keyEquivalent="?" id="492">
                                 <connections>
@@ -457,7 +488,7 @@
                 </menuItem>
                 <menuItem title="Debug" id="534">
                     <modifierMask key="keyEquivalentModifierMask"/>
-                    <menu key="submenu" title="Debug" userInterfaceLayoutDirection="leftToRight" id="535">
+                    <menu key="submenu" title="Debug" id="535">
                         <items>
                             <menuItem title="Force Repaint" keyEquivalent="r" id="545">
                                 <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>

Modified: trunk/Tools/MiniBrowser/mac/WK1BrowserWindowController.m (207511 => 207512)


--- trunk/Tools/MiniBrowser/mac/WK1BrowserWindowController.m	2016-10-19 00:51:13 UTC (rev 207511)
+++ trunk/Tools/MiniBrowser/mac/WK1BrowserWindowController.m	2016-10-19 01:03:23 UTC (rev 207512)
@@ -103,11 +103,16 @@
     }
 }
 
-- (IBAction)setScale:(id)sender
+- (IBAction)setPageScale:(id)sender
 {
-    
+    CGFloat scale = [self pageScaleForMenuItemTag:[sender tag]];
+    [_webView _scaleWebView:scale atOrigin:NSZeroPoint];
 }
 
+- (IBAction)setViewScale:(id)sender
+{
+}
+
 - (IBAction)reload:(id)sender
 {
     [_webView reload:sender];
@@ -128,6 +133,12 @@
     [_webView goForward:sender];
 }
 
+static BOOL areEssentiallyEqual(double a, double b)
+{
+    double tolerance = 0.001;
+    return (fabs(a - b) <= tolerance);
+}
+
 - (BOOL)validateMenuItem:(NSMenuItem *)menuItem
 {
     SEL action = "" action];
@@ -146,6 +157,9 @@
     else if (action == @selector(toggleZoomMode:))
         [menuItem setState:_zoomTextOnly ? NSOnState : NSOffState];
 
+    if (action == @selector(setPageScale:))
+        [menuItem setState:areEssentiallyEqual([_webView _viewScaleFactor], [self pageScaleForMenuItemTag:[menuItem tag]])];
+
     return YES;
 }
 

Modified: trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m (207511 => 207512)


--- trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m	2016-10-19 00:51:13 UTC (rev 207511)
+++ trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m	2016-10-19 01:03:23 UTC (rev 207512)
@@ -133,8 +133,14 @@
     }
 }
 
-static CGFloat viewScaleForMenuItemTag(NSInteger tag)
+- (IBAction)setPageScale:(id)sender
 {
+    CGFloat scale = [self pageScaleForMenuItemTag:[sender tag]];
+    [_webView _setPageScale:scale withOrigin:CGPointZero];
+}
+
+- (CGFloat)viewScaleForMenuItemTag:(NSInteger)tag
+{
     if (tag == 1)
         return 1;
     if (tag == 2)
@@ -147,9 +153,9 @@
     return 1;
 }
 
-- (IBAction)setScale:(id)sender
+- (IBAction)setViewScale:(id)sender
 {
-    CGFloat scale = viewScaleForMenuItemTag([sender tag]);
+    CGFloat scale = [self viewScaleForMenuItemTag:[sender tag]];
     CGFloat oldScale = [_webView _viewScale];
 
     if (scale == oldScale)
@@ -164,6 +170,12 @@
     [_webView _setViewScale:scale];
 }
 
+static BOOL areEssentiallyEqual(double a, double b)
+{
+    double tolerance = 0.001;
+    return (fabs(a - b) <= tolerance);
+}
+
 - (BOOL)validateMenuItem:(NSMenuItem *)menuItem
 {
     SEL action = "" action];
@@ -188,9 +200,12 @@
     else if (action == @selector(toggleZoomMode:))
         [menuItem setState:_zoomTextOnly ? NSOnState : NSOffState];
 
-    if (action == @selector(setScale:))
-        [menuItem setState:[_webView _viewScale] == viewScaleForMenuItemTag([menuItem tag])];
+    if (action == @selector(setPageScale:))
+        [menuItem setState:areEssentiallyEqual([_webView _pageScale], [self pageScaleForMenuItemTag:[menuItem tag]])];
 
+    if (action == @selector(setViewScale:))
+        [menuItem setState:areEssentiallyEqual([_webView _viewScale], [self viewScaleForMenuItemTag:[menuItem tag]])];
+
     return YES;
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to