Patch by Trey Matteson <trey@usa.net>
authorsullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Jul 2005 22:35:53 +0000 (22:35 +0000)
committersullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Jul 2005 22:35:53 +0000 (22:35 +0000)
        Reviewed by me.

        Fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4169
          scaling PDF view up leaves later HTML view scaled too

        An additional step of separating scaling of HTML and PDF.  If we do a zoom and there
        are no docViews that track the common scaling factor, then don't change it.  Thus in
        the common PDF case where it is the only doc view, scaling the PDF does not affect
        HTML pages loaded in the same window.

        * WebView.subproj/WebView.m:
        (-[WebView canMakeTextSmaller]):  Pass 0 for new scaling factor, since we just querying.
        (-[WebView canMakeTextLarger]):  Ditto.
        (-[WebView makeTextSmaller:]):  Pass new scaling factor.
        (-[WebView makeTextLarger:]):  Ditto.
        (-[WebView canMakeTextStandardSize]):  Pass 0 for new scaling factor.
        (-[WebView makeTextStandardSize:]):  Pass new scaling factor.
        (-[WebView _performTextSizingSelector:withObject:onTrackingDocs:selForNonTrackingDocs:newScaleFactor:]):
          The meat of the change is that this Swiss Army Knife also takes a new scaling
          factor, which it will set as the common scaling factor if it finds any doc views that
          are able to be scaled which track the common scaling factor.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@9928 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/ChangeLog
WebKit/WebView.subproj/WebView.m

index d33f9b0..d68e337 100644 (file)
@@ -3,6 +3,31 @@
        Patch by Trey Matteson <trey@usa.net>
         Reviewed by me.
 
+        Fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4169
+          scaling PDF view up leaves later HTML view scaled too
+
+        An additional step of separating scaling of HTML and PDF.  If we do a zoom and there
+        are no docViews that track the common scaling factor, then don't change it.  Thus in
+        the common PDF case where it is the only doc view, scaling the PDF does not affect
+        HTML pages loaded in the same window.
+
+        * WebView.subproj/WebView.m:
+        (-[WebView canMakeTextSmaller]):  Pass 0 for new scaling factor, since we just querying.
+        (-[WebView canMakeTextLarger]):  Ditto.
+        (-[WebView makeTextSmaller:]):  Pass new scaling factor.
+        (-[WebView makeTextLarger:]):  Ditto.
+        (-[WebView canMakeTextStandardSize]):  Pass 0 for new scaling factor.
+        (-[WebView makeTextStandardSize:]):  Pass new scaling factor.
+        (-[WebView _performTextSizingSelector:withObject:onTrackingDocs:selForNonTrackingDocs:newScaleFactor:]):
+          The meat of the change is that this Swiss Army Knife also takes a new scaling
+          factor, which it will set as the common scaling factor if it finds any doc views that
+          are able to be scaled which track the common scaling factor.
+
+2005-07-27  John Sullivan  <sullivan@apple.com>
+
+       Patch by Trey Matteson <trey@usa.net>
+        Reviewed by me.
+
         Fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4015
           PDF views should remember viewing mode, scroll position across back/forward
           Note this doesn't work within frames because of a PDFKit bug - see 4164
index 79b9fab..abb6321 100644 (file)
@@ -214,7 +214,7 @@ macro(yankAndSelect) \
 - (void)_preflightSpellChecker;
 - (BOOL)_continuousCheckingAllowed;
 - (NSResponder *)_responderForResponderOperations;
-- (BOOL)_performTextSizingSelector:(SEL)sel withObject:(id)arg onTrackingDocs:(BOOL)doTrackingViews selForNonTrackingDocs:(SEL)testSel;
+- (BOOL)_performTextSizingSelector:(SEL)sel withObject:(id)arg onTrackingDocs:(BOOL)doTrackingViews selForNonTrackingDocs:(SEL)testSel newScaleFactor:(float)newScaleFactor;
 @end
 
 NSString *WebElementDOMNodeKey =            @"WebElementDOMNode";
@@ -2366,31 +2366,27 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
 - (BOOL)canMakeTextSmaller
 {
     BOOL canShrinkMore = _private->textSizeMultiplier/TextSizeMultiplierRatio > MinimumTextSizeMultiplier;
-    return [self _performTextSizingSelector:(SEL)0 withObject:nil onTrackingDocs:canShrinkMore selForNonTrackingDocs:@selector(_canMakeTextSmaller)];
+    return [self _performTextSizingSelector:(SEL)0 withObject:nil onTrackingDocs:canShrinkMore selForNonTrackingDocs:@selector(_canMakeTextSmaller) newScaleFactor:0];
 }
 
 - (BOOL)canMakeTextLarger
 {
     BOOL canGrowMore = _private->textSizeMultiplier*TextSizeMultiplierRatio < MaximumTextSizeMultiplier;
-    return [self _performTextSizingSelector:(SEL)0 withObject:nil onTrackingDocs:canGrowMore selForNonTrackingDocs:@selector(_canMakeTextLarger)];
+    return [self _performTextSizingSelector:(SEL)0 withObject:nil onTrackingDocs:canGrowMore selForNonTrackingDocs:@selector(_canMakeTextLarger) newScaleFactor:0];
 }
 
 - (IBAction)makeTextSmaller:(id)sender
 {
-    BOOL canShrinkMore = _private->textSizeMultiplier/TextSizeMultiplierRatio > MinimumTextSizeMultiplier;
-    if (canShrinkMore) {
-        [self setTextSizeMultiplier:_private->textSizeMultiplier/TextSizeMultiplierRatio];
-    }
-    [self _performTextSizingSelector:@selector(_makeTextSmaller:) withObject:sender onTrackingDocs:canShrinkMore selForNonTrackingDocs:@selector(_canMakeTextSmaller)];
+    float newScale = _private->textSizeMultiplier/TextSizeMultiplierRatio;
+    BOOL canShrinkMore = newScale > MinimumTextSizeMultiplier;
+    [self _performTextSizingSelector:@selector(_makeTextSmaller:) withObject:sender onTrackingDocs:canShrinkMore selForNonTrackingDocs:@selector(_canMakeTextSmaller) newScaleFactor:newScale];
 }
 
 - (IBAction)makeTextLarger:(id)sender
 {
-    BOOL canGrowMore = _private->textSizeMultiplier*TextSizeMultiplierRatio < MaximumTextSizeMultiplier;
-    if (canGrowMore) {
-        [self setTextSizeMultiplier:_private->textSizeMultiplier*TextSizeMultiplierRatio];
-    }
-    [self _performTextSizingSelector:@selector(_makeTextLarger:) withObject:sender onTrackingDocs:canGrowMore selForNonTrackingDocs:@selector(_canMakeTextLarger)];
+    float newScale = _private->textSizeMultiplier*TextSizeMultiplierRatio;
+    BOOL canGrowMore = newScale < MaximumTextSizeMultiplier;
+    [self _performTextSizingSelector:@selector(_makeTextLarger:) withObject:sender onTrackingDocs:canGrowMore selForNonTrackingDocs:@selector(_canMakeTextLarger) newScaleFactor:newScale];
 }
 
 - (BOOL)_responderValidateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
@@ -2546,16 +2542,13 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
 - (BOOL)canMakeTextStandardSize
 {
     BOOL notAlreadyStandard = _private->textSizeMultiplier != 1.0;
-    return [self _performTextSizingSelector:(SEL)0 withObject:nil onTrackingDocs:notAlreadyStandard selForNonTrackingDocs:@selector(_canMakeTextStandardSize)];
+    return [self _performTextSizingSelector:(SEL)0 withObject:nil onTrackingDocs:notAlreadyStandard selForNonTrackingDocs:@selector(_canMakeTextStandardSize) newScaleFactor:0];
 }
 
 - (IBAction)makeTextStandardSize:(id)sender
 {
     BOOL notAlreadyStandard = _private->textSizeMultiplier != 1.0;
-    if (notAlreadyStandard) {
-        [self setTextSizeMultiplier:1.0];
-    }
-    [self _performTextSizingSelector:@selector(_makeTextStandardSize:) withObject:sender onTrackingDocs:notAlreadyStandard selForNonTrackingDocs:@selector(_canMakeTextStandardSize)];
+    [self _performTextSizingSelector:@selector(_makeTextStandardSize:) withObject:sender onTrackingDocs:notAlreadyStandard selForNonTrackingDocs:@selector(_canMakeTextStandardSize) newScaleFactor:1.0];
 }
 
 @end
@@ -3147,8 +3140,10 @@ FOR_EACH_RESPONDER_SELECTOR(FORWARD)
 // text sizing.  It returns whether it found any "suitable" doc views.  It sends sel to any suitable
 // doc views, or if sel==0 we do nothing to them.  For doc views that track our size factor, they are
 // suitable if doTrackingViews==YES (which in practice means that our size factor isn't at its max or
-// min).  For doc views that don't track it, we send them testSel to determine suitablility.
-- (BOOL)_performTextSizingSelector:(SEL)sel withObject:(id)arg onTrackingDocs:(BOOL)doTrackingViews selForNonTrackingDocs:(SEL)testSel
+// min).  For doc views that don't track it, we send them testSel to determine suitablility.  If we
+// do find any suitable tracking doc views and newScaleFactor!=0, we will set the common scale factor
+// to that new factor before we send sel to any of them. 
+- (BOOL)_performTextSizingSelector:(SEL)sel withObject:(id)arg onTrackingDocs:(BOOL)doTrackingViews selForNonTrackingDocs:(SEL)testSel newScaleFactor:(float)newScaleFactor
 {
     if ([[self mainFrame] dataSource] == nil) {
         return NO;
@@ -3164,6 +3159,9 @@ FOR_EACH_RESPONDER_SELECTOR(FORWARD)
             BOOL isSuitable;
             if ([sizingDocView _tracksCommonSizeFactor]) {
                 isSuitable = doTrackingViews;
+                if (isSuitable && newScaleFactor != 0) {
+                    [self setTextSizeMultiplier:newScaleFactor];
+                }
             } else {
                 // Incarnation to perform a selector returning a BOOL from objc/objc-runtime.h
                 isSuitable = (*(BOOL(*)(id, SEL, ...))objc_msgSend)(sizingDocView, testSel);