[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

sullivan sullivan at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:24:25 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit d8e3776dbce1f2f4266c695b08e824da8f993b2e
Author: sullivan <sullivan at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Jan 28 02:25:17 2004 +0000

    Tests:
    
            * Blot/Blot.xcode/project.pbxproj:
            added blot-api.txt
    
    WebKit:
    
            WebKit part of fixes for:
            <rdar://problem/3123975>: ER: please list the source URL in the header
            or footer when printing the contents of a page
            <rdar://problem/3184091>: Safari - Configurable printing header/footer
            <rdar://problem/3306826>: Please allow printing the date (as well as URL)
            in the header or footer
    
            Reviewed by Dave.
    
            * WebView.subproj/WebHTMLView.m:
            (-[WebHTMLView _headerHeight]):
            new method, gets result from WebView's UI delegate or returns 0
            (-[WebHTMLView _footerHeight]):
            new method, gets result from WebView's UI delegate or returns 0
            (-[WebHTMLView _drawHeaderInRect:]):
            new method, gives WebView's UI delegate a chance to draw header
            (-[WebHTMLView _drawFooterInRect:]):
            new method, gives WebView's UI delegate a chance to draw footer
            (-[WebHTMLView _adjustPrintingMarginsForHeaderAndFooter]):
            new method, adds header and footer heights into page margins so
            AppKit printing code will compute and use the right area
            (-[WebHTMLView _setPrinting:minimumPageWidth:maximumPageWidth:adjustViewSize:]):
            now calls _adjustPrintingMarginsForHeaderAndFooter if starting to print
            (-[WebHTMLView drawPageBorderWithSize:]):
            new method, computes rects for header and footer and calls new drawing methods
    
            * WebView.subproj/WebUIDelegatePrivate.h:
            add header and footer-related delegate methods
    
    WebBrowser:
    
            WebBrowser part of fixes for:
            <rdar://problem/3123975>: ER: please list the source URL in the header
            or footer when printing the contents of a page
            <rdar://problem/3184091>: Safari - Configurable printing header/footer
            <rdar://problem/3306826>: Please allow printing the date (as well as URL)
            in the header or footer
    
            Reviewed by Dave.
    
            * BrowserWebController.m:
            moved webViewPrint: from here to new file
    
            * BrowserWebViewPrinting.m: Added.
            (-[BrowserWebView webViewPrint:]):
            moved this here from BrowserWebController.m
            (headerFooterFont):
            new function, returns the font used in header and footer
            (printHeadersAndFooters):
            new function, returns the preference value
            (-[BrowserWebView webViewHeaderHeight:]):
            new method, bases the header height on the font height, with some pleasant whitespace
            (-[BrowserWebView webViewFooterHeight:]):
            new method, bases the footer's height on the font height, with some pleasant whitespace
            (-[BrowserWebView drawLeftString:rightString:inRect:atBaseline:withFont:]):
            new method, used to draw a long truncated string on the left and short
            nontruncated string on the right
            (-[BrowserWebView webView:drawHeaderInRect:forPage:of:]):
            new method, draws title on left and date/time on right
            (-[BrowserWebView webView:drawFooterInRect:forPage:of:]):
            new method, draws URL on left and page x of n on right
    
            * PreferenceKeys.h:
            new preference key PrintHeaderAndFooterPreferenceKey
    
            * Defaults.plist:
            default value of PrintHeaderAndFooterPreferenceKey is true
    
            * English.lproj/PrintingAccessoryView.nib:
            added checkbox for "Print Headers and Footers"
    
            * PrintingAccessoryViewController.h:
            * PrintingAccessoryViewController.m:
            (-[PrintingAccessoryViewController togglePrintHeadersAndFooters:]):
            new method, toggles the preference
            (-[PrintingAccessoryViewController accessoryView]):
            now updates the setting of the Print Headers and Footers checkbox
    
            * English.lproj/Localizable.strings:
            updated for these changes
    
            * WebBrowser.pbproj/project.pbxproj:
            updated to add new file
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@5997 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index e0647b2..d50f260 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,34 @@
+2004-01-27  John Sullivan  <sullivan at apple.com>
+
+        WebKit part of fixes for:
+        <rdar://problem/3123975>: ER: please list the source URL in the header 
+        or footer when printing the contents of a page
+        <rdar://problem/3184091>: Safari - Configurable printing header/footer
+        <rdar://problem/3306826>: Please allow printing the date (as well as URL) 
+        in the header or footer
+
+        Reviewed by Dave.
+
+        * WebView.subproj/WebHTMLView.m:
+        (-[WebHTMLView _headerHeight]):
+        new method, gets result from WebView's UI delegate or returns 0
+        (-[WebHTMLView _footerHeight]):
+        new method, gets result from WebView's UI delegate or returns 0
+        (-[WebHTMLView _drawHeaderInRect:]):
+        new method, gives WebView's UI delegate a chance to draw header
+        (-[WebHTMLView _drawFooterInRect:]):
+        new method, gives WebView's UI delegate a chance to draw footer
+        (-[WebHTMLView _adjustPrintingMarginsForHeaderAndFooter]):
+        new method, adds header and footer heights into page margins so
+        AppKit printing code will compute and use the right area
+        (-[WebHTMLView _setPrinting:minimumPageWidth:maximumPageWidth:adjustViewSize:]):
+        now calls _adjustPrintingMarginsForHeaderAndFooter if starting to print
+        (-[WebHTMLView drawPageBorderWithSize:]):
+        new method, computes rects for header and footer and calls new drawing methods
+        
+        * WebView.subproj/WebUIDelegatePrivate.h:
+        add header and footer-related delegate methods
+
 2004-01-27  Chris Blumenberg  <cblu at apple.com>
 
 	Fixed:
diff --git a/WebKit/WebView.subproj/WebHTMLView.m b/WebKit/WebView.subproj/WebHTMLView.m
index a14db7d..06e445b 100644
--- a/WebKit/WebView.subproj/WebHTMLView.m
+++ b/WebKit/WebView.subproj/WebHTMLView.m
@@ -22,6 +22,7 @@
 #import <WebKit/WebPluginController.h>
 #import <WebKit/WebTextRenderer.h>
 #import <WebKit/WebTextRendererFactory.h>
+#import <WebKit/WebUIDelegatePrivate.h>
 #import <WebKit/WebUnicode.h>
 #import <WebKit/WebViewPrivate.h>
 
@@ -82,6 +83,10 @@ static BOOL forceRealHitTest = NO;
 - (void)_setPrinting:(BOOL)printing minimumPageWidth:(float)minPageWidth maximumPageWidth:(float)maxPageWidth adjustViewSize:(BOOL)adjustViewSize;
 - (void)_updateTextSizeMultiplier;
 - (float)_calculatePrintHeight;
+- (float)_footerHeight;
+- (float)_headerHeight;
+- (float)_scaleFactorForPrintOperation:(NSPrintOperation *)printOperation;
+- (float)_userScaleFactorForPrintOperation:(NSPrintOperation *)printOperation;
 @end
 
 // Any non-zero value will do, but using somethign recognizable might help us debug some day.
@@ -1671,6 +1676,95 @@ static WebHTMLView *lastHitView = nil;
 {
 }
 
+//#define DEBUG_HEADER_AND_FOOTER
+
+- (float)_headerHeight
+{
+    // FIXME: headers and footers are only drawn for HTMLView, not for other views
+    // such as plain text or standalone images
+    if ([[[self _webView] UIDelegate] respondsToSelector:@selector(webViewHeaderHeight:)]) {
+        return [[[self _webView] UIDelegate] webViewHeaderHeight:[self _webView]];
+    }
+
+#ifdef DEBUG_HEADER_AND_FOOTER
+    return 25;
+#else
+    return 0;
+#endif
+}
+
+- (float)_footerHeight
+{
+    // FIXME: headers and footers are only drawn for HTMLView, not for other views
+    // such as plain text or standalone images
+    if ([[[self _webView] UIDelegate] respondsToSelector:@selector(webViewFooterHeight:)]) {
+        return [[[self _webView] UIDelegate] webViewFooterHeight:[self _webView]];
+    }
+    
+#ifdef DEBUG_HEADER_AND_FOOTER
+    return 50;
+#else
+    return 0;
+#endif
+}
+
+- (void)_drawHeaderInRect:(NSRect)rect
+{
+#ifdef DEBUG_HEADER_AND_FOOTER
+    NSGraphicsContext *currentContext = [NSGraphicsContext currentContext];
+    [currentContext saveGraphicsState];
+    [[NSColor yellowColor] set];
+    NSRectFill(rect);
+    [currentContext restoreGraphicsState];
+#endif
+    
+    // FIXME: headers and footers are only drawn for HTMLView, not for other views
+    // such as plain text or standalone images
+    if ([[[self _webView] UIDelegate] respondsToSelector:@selector(webView:drawHeaderInRect:forPage:of:)]) {
+        NSGraphicsContext *currentContext = [NSGraphicsContext currentContext];
+        [currentContext saveGraphicsState];
+        NSRectClip(rect);
+        [[[self _webView] UIDelegate] webView:[self _webView] 
+                             drawHeaderInRect:rect 
+                                      forPage:[[NSPrintOperation currentOperation] currentPage] 
+                                           of:[_private->pageRects count]];
+        [currentContext restoreGraphicsState];
+    }
+}
+
+- (void)_drawFooterInRect:(NSRect)rect
+{
+#ifdef DEBUG_HEADER_AND_FOOTER
+    NSGraphicsContext *currentContext = [NSGraphicsContext currentContext];
+    [currentContext saveGraphicsState];
+    [[NSColor cyanColor] set];
+    NSRectFill(rect);
+    [currentContext restoreGraphicsState];
+#endif
+    
+    // FIXME: headers and footers are only drawn for HTMLView, not for other views
+    // such as plain text or standalone images
+    if ([[[self _webView] UIDelegate] respondsToSelector:@selector(webView:drawFooterInRect:forPage:of:)]) {
+        NSGraphicsContext *currentContext = [NSGraphicsContext currentContext];
+        [currentContext saveGraphicsState];
+        NSRectClip(rect);
+        [[[self _webView] UIDelegate] webView:[self _webView] 
+                             drawFooterInRect:rect 
+                                      forPage:[[NSPrintOperation currentOperation] currentPage] 
+                                           of:[_private->pageRects count]];
+        [currentContext restoreGraphicsState];
+    }
+}
+
+- (void)_adjustPrintingMarginsForHeaderAndFooter
+{
+    NSPrintOperation *operation = [NSPrintOperation currentOperation];
+    NSPrintInfo *info = [[NSPrintOperation currentOperation] printInfo];
+    float userScale = [self _userScaleFactorForPrintOperation:operation];
+    [info setTopMargin:[info topMargin] + [self _headerHeight]*userScale];
+    [info setBottomMargin:[info bottomMargin] + [self _footerHeight]*userScale];
+}
+
 // Does setNeedsDisplay:NO as a side effect when printing is ending.
 // pageWidth != 0 implies we will relayout to a new width
 - (void)_setPrinting:(BOOL)printing minimumPageWidth:(float)minPageWidth maximumPageWidth:(float)maxPageWidth adjustViewSize:(BOOL)adjustViewSize
@@ -1694,7 +1788,9 @@ static WebHTMLView *lastHitView = nil;
         [self setNeedsToApplyStyles:YES];
         [self setNeedsLayout:YES];
         [self layoutToMinimumPageWidth:minPageWidth maximumPageWidth:maxPageWidth adjustingViewSize:adjustViewSize];
-        if (!printing) {
+        if (printing) {
+            [self _adjustPrintingMarginsForHeaderAndFooter];
+        } else {
             // Can't do this when starting printing or nested printing won't work, see 3491427.
             [self setNeedsDisplay:NO];
         }
@@ -1799,6 +1895,25 @@ static WebHTMLView *lastHitView = nil;
     return paperSize.height - [pi topMargin] - [pi bottomMargin];
 }
 
+- (void)drawPageBorderWithSize:(NSSize)borderSize
+{
+    ASSERT(NSEqualSizes(borderSize, [[[NSPrintOperation currentOperation] printInfo] paperSize]));
+    
+    // The header and footer rect height scales with the page, but the width is always
+    // all the way across the printed page (inset by printing margins).
+    float userScale = [self _userScaleFactorForPrintOperation:[NSPrintOperation currentOperation]];
+    NSPrintInfo *printInfo = [[NSPrintOperation currentOperation] printInfo];
+    float headerFooterLeft = [printInfo leftMargin]/userScale;
+    float headerFooterWidth = (borderSize.width - ([printInfo leftMargin] + [printInfo rightMargin]))/userScale;
+    NSRect footerRect = NSMakeRect(headerFooterLeft, [printInfo bottomMargin]/userScale - [self _footerHeight] , 
+                                   headerFooterWidth, [self _footerHeight]);
+    NSRect headerRect = NSMakeRect(headerFooterLeft, (borderSize.height - [printInfo topMargin])/userScale, 
+                                   headerFooterWidth, [self _headerHeight]);
+    
+    [self _drawHeaderInRect:headerRect];
+    [self _drawFooterInRect:footerRect];
+}
+
 - (void)endDocument
 {
     [super endDocument];
diff --git a/WebKit/WebView.subproj/WebUIDelegatePrivate.h b/WebKit/WebView.subproj/WebUIDelegatePrivate.h
index 01ef814..a70569d 100644
--- a/WebKit/WebView.subproj/WebUIDelegatePrivate.h
+++ b/WebKit/WebView.subproj/WebUIDelegatePrivate.h
@@ -9,4 +9,9 @@
 
 - (void)webViewPrint:(WebView *)sender;
 
+- (float)webViewHeaderHeight:(WebView *)sender;
+- (float)webViewFooterHeight:(WebView *)sender;
+- (void)webView:(WebView *)sender drawHeaderInRect:(NSRect)rect forPage:(unsigned)pageIndex of:(unsigned)pageCount;
+- (void)webView:(WebView *)sender drawFooterInRect:(NSRect)rect forPage:(unsigned)pageIndex of:(unsigned)pageCount;
+
 @end

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list