[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.22-985-g3c00f00
mthole at apple.com
mthole at apple.com
Wed Mar 17 18:04:00 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 4e465fa107df15c9c4d12d13e572ed6f1393bbd0
Author: mthole at apple.com <mthole at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sat Feb 27 00:44:52 2010 +0000
https://bugs.webkit.org/show_bug.cgi?id=35449
Add ability to hide WebFrame scrollbars and to allow scrollbars to overlap with content.
Patch by Jing Jin <jjin at apple.com> on 2010-02-26
Reviewed by Timothy Hatcher.
* WebView/WebDynamicScrollBarsView.h:
* WebView/WebDynamicScrollBarsView.mm:
(-[WebDynamicScrollBarsView setAllowScrollersToOverlapContent:]): Allows scrollbars to
overlap with the document and re-layouts the document.
(-[WebDynamicScrollBarsView setAlwaysHideHorizontalScroller:]): Hides the horizontal scrollbar.
(-[WebDynamicScrollBarsView setAlwaysHideVerticalScroller:]): Hides the vertical scrollbar.
(-[WebDynamicScrollBarsView contentViewFrame]): Calculates the appropriate frame based
on allowScrollersToOverlapContent.
(-[WebDynamicScrollBarsView tile]): If allowScrollersToOverlapContent is YES, set the
contentView's frame so it overlaps with the scrollbar.
(-[WebDynamicScrollBarsView updateScrollers]): Take into account hideHorizontalScroller
and hideVerticalScroller.
(-[WebDynamicScrollBarsView reflectScrolledClipView:]): set drawsBackground to NO when
scrollbars are overlapping with content, so we don't get trails during scrollbar draw updates.
* WebView/WebDynamicScrollBarsViewInternal.h:
* WebView/WebFrame.h:
* WebView/WebFrame.mm:
(-[WebFrame setAllowScrollersToOverlapContent:]): Hook for [WebDynamicScrollBarsView setAllowScrollersToOverlapContent:]
(-[WebFrame setAlwaysHideHorizontalScroller:]): Hook for [WebDynamicScrollBarsView setAlwaysHideHorizontalScroller:]
(-[WebFrame setAlwaysHideVerticalScroller:]): Hook for [WebDynamicScrollBarsView setAlwaysHideVerticalScroller:]
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55324 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index 5a07ce0..7744caf 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,31 @@
+2010-02-26 Jing Jin <jjin at apple.com>
+
+ Reviewed by Timothy Hatcher.
+
+ https://bugs.webkit.org/show_bug.cgi?id=35449
+ Add ability to hide WebFrame scrollbars and to allow scrollbars to overlap with content.
+
+ * WebView/WebDynamicScrollBarsView.h:
+ * WebView/WebDynamicScrollBarsView.mm:
+ (-[WebDynamicScrollBarsView setAllowScrollersToOverlapContent:]): Allows scrollbars to
+ overlap with the document and re-layouts the document.
+ (-[WebDynamicScrollBarsView setAlwaysHideHorizontalScroller:]): Hides the horizontal scrollbar.
+ (-[WebDynamicScrollBarsView setAlwaysHideVerticalScroller:]): Hides the vertical scrollbar.
+ (-[WebDynamicScrollBarsView contentViewFrame]): Calculates the appropriate frame based
+ on allowScrollersToOverlapContent.
+ (-[WebDynamicScrollBarsView tile]): If allowScrollersToOverlapContent is YES, set the
+ contentView's frame so it overlaps with the scrollbar.
+ (-[WebDynamicScrollBarsView updateScrollers]): Take into account hideHorizontalScroller
+ and hideVerticalScroller.
+ (-[WebDynamicScrollBarsView reflectScrolledClipView:]): set drawsBackground to NO when
+ scrollbars are overlapping with content, so we don't get trails during scrollbar draw updates.
+ * WebView/WebDynamicScrollBarsViewInternal.h:
+ * WebView/WebFrame.h:
+ * WebView/WebFrame.mm:
+ (-[WebFrame setAllowScrollersToOverlapContent:]): Hook for [WebDynamicScrollBarsView setAllowScrollersToOverlapContent:]
+ (-[WebFrame setAlwaysHideHorizontalScroller:]): Hook for [WebDynamicScrollBarsView setAlwaysHideHorizontalScroller:]
+ (-[WebFrame setAlwaysHideVerticalScroller:]): Hook for [WebDynamicScrollBarsView setAlwaysHideVerticalScroller:]
+
2010-02-26 Gavin Barraclough <barraclough at apple.com>
Reviewed by Alexey Proskuryakov.
diff --git a/WebKit/mac/WebView/WebDynamicScrollBarsView.h b/WebKit/mac/WebView/WebDynamicScrollBarsView.h
index 15ed7e4..b57c939 100644
--- a/WebKit/mac/WebView/WebDynamicScrollBarsView.h
+++ b/WebKit/mac/WebView/WebDynamicScrollBarsView.h
@@ -29,8 +29,6 @@
// This is a Private header (containing SPI), despite the fact that its name
// does not contain the word Private.
-// This was once used by Safari, but has not been for a long time.
-
// FIXME: <rdar://problem/5898985> Mail currently expects this header to define WebCoreScrollbarAlwaysOn.
extern const int WebCoreScrollbarAlwaysOn;
@@ -45,9 +43,17 @@ extern const int WebCoreScrollbarAlwaysOn;
BOOL verticallyPinnedByPreviousWheelEvent;
BOOL horizontallyPinnedByPreviousWheelEvent;
unsigned inUpdateScrollersLayoutPass;
+
+ BOOL allowScrollersToOverlapContent;
+ BOOL hideHorizontalScroller;
+ BOOL hideVerticalScroller;
}
// 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;
+
+- (void)setAllowScrollersToOverlapContent:(BOOL)flag;
+- (void)setAlwaysHideHorizontalScroller:(BOOL)flag;
+- (void)setAlwaysHideVerticalScroller:(BOOL)flag;
@end
diff --git a/WebKit/mac/WebView/WebDynamicScrollBarsView.mm b/WebKit/mac/WebView/WebDynamicScrollBarsView.mm
index b4424e1..82f9d2f 100644
--- a/WebKit/mac/WebView/WebDynamicScrollBarsView.mm
+++ b/WebKit/mac/WebView/WebDynamicScrollBarsView.mm
@@ -54,10 +54,61 @@ const int WebCoreScrollbarAlwaysOn = ScrollbarAlwaysOn;
[self updateScrollers];
}
+- (void)setAllowScrollersToOverlapContent:(BOOL)flag
+{
+ if (allowScrollersToOverlapContent == flag)
+ return;
+
+ allowScrollersToOverlapContent = flag;
+
+ [[self contentView] setFrame:[self contentViewFrame]];
+ [[self documentView] setNeedsLayout:YES];
+ [[self documentView] layout];
+}
+
+- (void)setAlwaysHideHorizontalScroller:(BOOL)shouldBeVisible
+{
+ if (hideHorizontalScroller == shouldBeVisible)
+ return;
+
+ hideHorizontalScroller = shouldBeVisible;
+ [self updateScrollers];
+}
+
+- (void)setAlwaysHideVerticalScroller:(BOOL)shouldBeVisible
+{
+ if (hideVerticalScroller == shouldBeVisible)
+ return;
+
+ hideVerticalScroller = shouldBeVisible;
+ [self updateScrollers];
+}
+
@end
@implementation WebDynamicScrollBarsView (WebInternal)
+- (NSRect)contentViewFrame
+{
+ NSRect frame = [[self contentView] frame];
+
+ if ([self hasHorizontalScroller])
+ frame.size.height = (allowScrollersToOverlapContent ? NSMaxY([[self horizontalScroller] frame]) : NSMinY([[self horizontalScroller] frame]));
+ if ([self hasVerticalScroller])
+ frame.size.width = (allowScrollersToOverlapContent ? NSMaxX([[self verticalScroller] frame]) : NSMinX([[self verticalScroller] frame]));
+ return frame;
+}
+
+- (void)tile
+{
+ [super tile];
+
+ // [super tile] sets the contentView size so that it does not overlap with the scrollers,
+ // we want to re-set the contentView to overlap scrollers before displaying.
+ if (allowScrollersToOverlapContent)
+ [[self contentView] setFrame:[self contentViewFrame]];
+}
+
- (void)setSuppressLayout:(BOOL)flag;
{
suppressLayout = flag;
@@ -112,12 +163,15 @@ static const unsigned cMaxUpdateScrollbarsPass = 2;
if (!documentView) {
newHasHorizontalScroller = NO;
newHasVerticalScroller = NO;
- }
+ }
if (hScroll != ScrollbarAuto)
newHasHorizontalScroller = (hScroll == ScrollbarAlwaysOn);
if (vScroll != ScrollbarAuto)
newHasVerticalScroller = (vScroll == ScrollbarAlwaysOn);
+
+ newHasHorizontalScroller &= !hideHorizontalScroller;
+ newHasVerticalScroller &= !hideVerticalScroller;
if (!documentView || suppressLayout || suppressScrollers || (hScroll != ScrollbarAuto && vScroll != ScrollbarAuto)) {
inUpdateScrollers = YES;
@@ -158,6 +212,9 @@ static const unsigned cMaxUpdateScrollbarsPass = 2;
if (!newHasVerticalScroller && hasVerticalScroller && hScroll != ScrollbarAlwaysOn)
newHasHorizontalScroller = NO;
+ newHasHorizontalScroller &= !hideHorizontalScroller;
+ newHasVerticalScroller &= !hideVerticalScroller;
+
if (hasHorizontalScroller != newHasHorizontalScroller) {
inUpdateScrollers = YES;
[self setHasHorizontalScroller:newHasHorizontalScroller];
@@ -192,6 +249,10 @@ static const unsigned cMaxUpdateScrollbarsPass = 2;
- (void)reflectScrolledClipView:(NSClipView *)clipView
{
if (clipView == [self contentView]) {
+ // Prevent appearance of trails because of overlapping views
+ if (allowScrollersToOverlapContent)
+ [self setDrawsBackground:NO];
+
// FIXME: This hack here prevents infinite recursion that takes place when we
// gyrate between having a vertical scroller and not having one. A reproducible
// case is clicking on the "the Policy Routing text" link at
diff --git a/WebKit/mac/WebView/WebDynamicScrollBarsViewInternal.h b/WebKit/mac/WebView/WebDynamicScrollBarsViewInternal.h
index 312cf9d..40be88d 100644
--- a/WebKit/mac/WebView/WebDynamicScrollBarsViewInternal.h
+++ b/WebKit/mac/WebView/WebDynamicScrollBarsViewInternal.h
@@ -53,4 +53,6 @@
- (void)updateScrollers;
- (void)setSuppressLayout:(BOOL)flag;
+// Calculate the appropriate frame for the contentView based on allowsScrollersToOverlapContent.
+- (NSRect)contentViewFrame;
@end
diff --git a/WebKit/mac/WebView/WebFrame.h b/WebKit/mac/WebView/WebFrame.h
index a6cdebb..12e446d 100644
--- a/WebKit/mac/WebView/WebFrame.h
+++ b/WebKit/mac/WebView/WebFrame.h
@@ -214,4 +214,29 @@
*/
- (JSGlobalContextRef)globalContext;
+/*!
+ @method setAllowScrollersToOverlapContent:
+ @discussion This method sets whether the scrollbars, if any, should be shown inside
+ the document's border (thus overlapping some content) or outside the webView's border
+ (default behavior). Changing this flag changes the size of the contentView and maintains
+ the size of the frameView.
+ @param flag YES to allow scrollers to overlap content, NO otherwise.
+*/
+- (void)setAllowScrollersToOverlapContent:(BOOL)flag;
+
+/*!
+ @method setAlwaysHideHorizontalScroller:
+ @discussion This method sets if the horizontal scrollbar is always hidden, regardless of
+ other scrollbar visibility settings. This does not affect the scrollability of the document.
+ @param flag YES to always hide the horizontal scroller, NO otherwise.
+*/
+- (void)setAlwaysHideHorizontalScroller:(BOOL)flag;
+
+/*!
+ @method setAlwaysHideVerticalScroller:
+ @discussion This method sets if the vertical scrollbar is always hidden, regardless of
+ other scrollbar visibility settings. This does not affect the scrollability of the document.
+ @param flag YES to always hide the vertical scroller, NO otherwise.
+*/
+- (void)setAlwaysHideVerticalScroller:(BOOL)flag;
@end
diff --git a/WebKit/mac/WebView/WebFrame.mm b/WebKit/mac/WebView/WebFrame.mm
index 267d319..d67a267 100644
--- a/WebKit/mac/WebView/WebFrame.mm
+++ b/WebKit/mac/WebView/WebFrame.mm
@@ -39,6 +39,7 @@
#import "WebChromeClient.h"
#import "WebDataSourceInternal.h"
#import "WebDocumentLoaderMac.h"
+#import "WebDynamicScrollBarsView.h"
#import "WebFrameLoaderClient.h"
#import "WebFrameViewInternal.h"
#import "WebHTMLView.h"
@@ -1523,4 +1524,21 @@ static NSURL *createUniqueWebDataURL()
return toGlobalRef(coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec());
}
+- (void)setAllowScrollersToOverlapContent:(BOOL)flag
+{
+ ASSERT([[[self frameView] _scrollView] isKindOfClass:[WebDynamicScrollBarsView class]]);
+ [(WebDynamicScrollBarsView *)[[self frameView] _scrollView] setAllowScrollersToOverlapContent:flag];
+}
+
+- (void)setAlwaysHideHorizontalScroller:(BOOL)flag
+{
+ ASSERT([[[self frameView] _scrollView] isKindOfClass:[WebDynamicScrollBarsView class]]);
+ [(WebDynamicScrollBarsView *)[[self frameView] _scrollView] setAlwaysHideHorizontalScroller:flag];
+}
+- (void)setAlwaysHideVerticalScroller:(BOOL)flag
+{
+ ASSERT([[[self frameView] _scrollView] isKindOfClass:[WebDynamicScrollBarsView class]]);
+ [(WebDynamicScrollBarsView *)[[self frameView] _scrollView] setAlwaysHideVerticalScroller:flag];
+}
+
@end
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list