[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
voas
voas at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:30:27 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 3bc8791bfebb28cfe11261a7884636dcfc29f161
Author: voas <voas at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Mar 19 23:11:52 2003 +0000
2003-03-19 Ed Voas voas at apple.com
Reviewed by Richard.
Got it working in non-compositing mode as well, so in theory it
can work inside a PowerPlant application as well. It's a bit of what
I'd consider a hack, but it's pretty straightforward.
* Carbon.subproj/CarbonWindowAdapter.m:
(-[CarbonWindowAdapter setViewsNeedDisplay:]):
* Carbon.subproj/HIViewAdapter.h:
* Carbon.subproj/HIViewAdapter.m:
(+[HIViewAdapter bindHIViewToNSView:nsView:]):
(-[HIViewAdapter setNeedsDisplay:]):
(-[HIViewAdapter setNeedsDisplayInRect:]):
(SetViewNeedsDisplay):
* Carbon.subproj/HIWebView.m:
(if):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3866 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/Carbon.subproj/CarbonWindowAdapter.m b/WebKit/Carbon.subproj/CarbonWindowAdapter.m
index 27d0218..f7e8123 100644
--- a/WebKit/Carbon.subproj/CarbonWindowAdapter.m
+++ b/WebKit/Carbon.subproj/CarbonWindowAdapter.m
@@ -281,14 +281,17 @@ extern const OSType NSCarbonWindowPropertyTag;
- (void)setViewsNeedDisplay:(BOOL)wellDoThey {
// Make sure we can flush anything that needs it.
- // Apparently we don't need to sync the context anymore now that we are
- // using the HIView context. I might need to turn this back on when I get
- // around to making this work in non-composited mode. We'll see. But this
- // function needs to exist no matter what to make sure the normal appkit
- // thing does not happen.
-
-/// CGContextRef cgContext = (CGContextRef)[[self _threadContext] graphicsPort];
-/// CGContextSynchronize( cgContext );
+ // We need to sync the context here. I was hoping I didn't need to do this,
+ // but apparently when scrolling, the AppKit view system draws directly.
+ // When this occurs, I cannot intercept it to make it draw in my HIView
+ // context. What ends up happening is that it draws, but nothing ever
+ // flushes it.
+
+ if ( [self windowNumber] != -1 )
+ {
+ CGContextRef cgContext = (CGContextRef)[[self _threadContext] graphicsPort];
+ CGContextSynchronize( cgContext );
+ }
}
// Given a reference to a Carbon window that is to be encapsulated, and an indicator of whether or not this object should take responsibility for disposing of the Carbon window, initialize.
diff --git a/WebKit/Carbon.subproj/HIViewAdapter.h b/WebKit/Carbon.subproj/HIViewAdapter.h
index abf1cfe..57d5a26 100644
--- a/WebKit/Carbon.subproj/HIViewAdapter.h
+++ b/WebKit/Carbon.subproj/HIViewAdapter.h
@@ -16,6 +16,9 @@
+ (void)bindHIViewToNSView:(HIViewRef)hiView nsView:(NSView*)nsView;
+ (void)unbindNSView:(NSView*)nsView;
+ (HIViewRef)getHIViewForNSView:(NSView*)inView;
+//- (void)mouseIsDown;
+//- (void)mouseIsUp;
+
//- (id)initWithFrame:(NSRect)frame view:(HIViewRef) inView;
//- (HIViewRef)hiView;
diff --git a/WebKit/Carbon.subproj/HIViewAdapter.m b/WebKit/Carbon.subproj/HIViewAdapter.m
index e81ee36..1fe07a5 100644
--- a/WebKit/Carbon.subproj/HIViewAdapter.m
+++ b/WebKit/Carbon.subproj/HIViewAdapter.m
@@ -8,23 +8,15 @@
#import "HIViewAdapter.h"
-extern OSStatus _HIViewSetNeedsDisplayInRect( HIViewRef inView, const HIRect* inBounds, Boolean inNeedsDisplay );
+//extern OSStatus _HIViewSetNeedsDisplayInRect( HIViewRef inView, const HIRect* inBounds, Boolean inNeedsDisplay );
+static void SetViewNeedsDisplay( HIViewRef inView, RgnHandle inRegion, Boolean inNeedsDisplay );
-#define SHEET_INTERCEPTOR 0
+#define WATCH_INVALIDATION 0
@interface NSView(ShhhhDontTell)
- (NSRect)_dirtyRect;
@end
-#if SHEET_INTERCEPTOR
- at interface CarbonSheetInterceptor : NSWindow
-{
-}
-
-- (void)_orderFrontRelativeToWindow:(NSWindow *)docWindow;
- at end
-#endif
-
@implementation HIViewAdapter
static CFMutableDictionaryRef sViewMap;
@@ -34,9 +26,6 @@ static CFMutableDictionaryRef sViewMap;
if ( sViewMap == NULL )
{
[HIViewAdapter poseAsClass: [NSView class]];
-#if SHEET_INTERCEPTOR
- [CarbonSheetInterceptor poseAsClass: [NSWindow class]];
-#endif
sViewMap = CFDictionaryCreateMutable( NULL, 0, NULL, NULL );
}
@@ -121,13 +110,9 @@ static CFMutableDictionaryRef sViewMap;
qdRect.right = CGRectGetMaxX( rect );
RectRgn( rgn, &qdRect );
- HIViewSetNeedsDisplayInRegion( hiView, rgn, false );
+ SetViewNeedsDisplay( hiView, rgn, false );
DisposeRgn( rgn );
}
- else
- {
- HIViewSetNeedsDisplay( hiView, false );
- }
}
//_HIViewSetNeedsDisplayInRect( hiView, &rect, false );
}
@@ -186,13 +171,9 @@ static CFMutableDictionaryRef sViewMap;
qdRect.right = CGRectGetMaxX( rect );
RectRgn( rgn, &qdRect );
- HIViewSetNeedsDisplayInRegion( hiView, rgn, true );
+ SetViewNeedsDisplay( hiView, rgn, true );
DisposeRgn( rgn );
}
- else
- {
- HIViewSetNeedsDisplay( hiView, true );
- }
}
//_HIViewSetNeedsDisplayInRect( hiView, &rect, true );
}
@@ -222,23 +203,63 @@ static CFMutableDictionaryRef sViewMap;
@end
-#if SHEET_INTERCEPTOR
- at implementation CarbonSheetInterceptor
-
-- (void)_orderFrontRelativeToWindow:(NSWindow *)docWindow
+static void
+SetViewNeedsDisplay( HIViewRef inHIView, RgnHandle inRegion, Boolean inNeedsDisplay )
{
- printf( "Here I am!\n" );
- [docWindow _attachSheetWindow:self];
- SetWindowClass( [self windowRef], kSheetWindowClass );
- ShowSheetWindow( [self windowRef], [docWindow windowRef] );
-}
+ WindowAttributes attrs;
+
+ GetWindowAttributes( GetControlOwner( inHIView ), &attrs );
-- (void)_orderOutRelativeToWindow:(NSWindow *)docWindow
-{
- printf( "Here I go!\n" );
- HideSheetWindow( [self windowRef] );
- [docWindow _detachSheetWindow];
-}
+ if ( attrs & kWindowCompositingAttribute )
+ {
+#if WATCH_INVALIDATION
+ Rect bounds;
+ GetRegionBounds( inRegion, &bounds );
+ printf( "%s: rect on input %d %d %d %d\n", inNeedsDisplay ? "INVALIDATE" : "VALIDATE",
+ bounds.top, bounds.left, bounds.bottom, bounds.right );
+#endif
+ HIViewSetNeedsDisplayInRegion( inHIView, inRegion, inNeedsDisplay );
+ }
+ else
+ {
+ Rect bounds, cntlBounds;
+ GrafPtr port, savePort;
+ Rect portBounds;
+
+#if WATCH_INVALIDATION
+ printf( "%s: rect on input %d %d %d %d\n", inNeedsDisplay ? "INVALIDATE" : "VALIDATE",
+ bounds.top, bounds.left, bounds.bottom, bounds.right );
+#endif
+ GetControlBounds( inHIView, &cntlBounds );
- at end
+#if WATCH_INVALIDATION
+ printf( "%s: control bounds are %d %d %d %d\n", inNeedsDisplay ? "INVALIDATE" : "VALIDATE",
+ cntlBounds.top, cntlBounds.left, cntlBounds.bottom, cntlBounds.right );
#endif
+
+ port = GetWindowPort( GetControlOwner( inHIView ) );
+
+ GetPort( &savePort );
+ SetPort( port );
+ GetPortBounds( port, &portBounds );
+ SetOrigin( 0, 0 );
+
+ OffsetRgn( inRegion, cntlBounds.left, cntlBounds.top );
+
+ GetRegionBounds( inRegion, &bounds );
+
+#if WATCH_INVALIDATION
+ printf( "%s: rect in port coords %d %d %d %d\n", inNeedsDisplay ? "INVALIDATE" : "VALIDATE",
+ bounds.top, bounds.left, bounds.bottom, bounds.right );
+#endif
+
+ if ( inNeedsDisplay )
+ InvalWindowRgn( GetControlOwner( inHIView ), inRegion );
+ else
+ ValidWindowRgn( GetControlOwner( inHIView ), inRegion );
+
+ SetOrigin( portBounds.left, portBounds.top );
+ SetPort( savePort );
+ }
+}
+
diff --git a/WebKit/Carbon.subproj/HIWebView.m b/WebKit/Carbon.subproj/HIWebView.m
index e28c6e2..4f78b65 100644
--- a/WebKit/Carbon.subproj/HIWebView.m
+++ b/WebKit/Carbon.subproj/HIWebView.m
@@ -23,9 +23,11 @@ struct HIWebFrameView
{
HIViewRef fViewRef;
- WebFrameView* fWebFrameView;
+ WebFrameView* fWebFrameView;
NSView* fFirstResponder;
CarbonWindowAdapter * fKitWindow;
+ bool fIsComposited;
+ CFRunLoopObserverRef fUpdateObserver;
};
typedef struct HIWebFrameView HIWebFrameView;
@@ -184,6 +186,18 @@ static void SyncFrame( HIWebFrameView* inView );
static OSStatus WindowCloseHandler( EventHandlerCallRef inCallRef, EventRef inEvent, void* inUserData );
+static void StartUpdateObserver( HIWebFrameView* view );
+static void StopUpdateObserver( HIWebFrameView* view );
+static void UpdateObserver( CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *info );
+
+static inline void HIRectToQDRect( const HIRect* inRect, Rect* outRect )
+{
+ outRect->top = CGRectGetMinY( *inRect );
+ outRect->left = CGRectGetMinX( *inRect );
+ outRect->bottom = CGRectGetMaxY( *inRect );
+ outRect->right = CGRectGetMaxX( *inRect );
+}
+
//----------------------------------------------------------------------------------
// HIWebFrameViewCreate
//----------------------------------------------------------------------------------
@@ -208,7 +222,7 @@ NSView*
HIWebFrameViewGetNSView( HIViewRef inView )
{
HIWebFrameView* view = (HIWebFrameView*)HIObjectDynamicCast( (HIObjectRef)inView, kHIWebFrameViewClassID );
- NSView* result = NULL;
+ NSView* result = NULL;
if ( view )
result = view->fWebFrameView;
@@ -264,6 +278,8 @@ HIWebFrameViewConstructor( HIViewRef inView )
view->fFirstResponder = NULL;
view->fKitWindow = NULL;
+ view->fIsComposited = false;
+ view->fUpdateObserver = NULL;
}
return view;
@@ -316,13 +332,27 @@ GetBehaviors()
static void
Draw( HIWebFrameView* inView, RgnHandle limitRgn, CGContextRef inContext )
{
- HIRect bounds;
+ HIRect bounds;
CGContextRef temp;
Rect drawRect;
HIRect hiRect;
-
+ bool createdContext = false;
+ GrafPtr port;
+
+ if ( !inView->fIsComposited )
+ {
+ Rect portRect;
+
+ GetPort( &port );
+ GetPortBounds( port, &portRect );
+ CreateCGContextForPort( port, &inContext );
+ SyncCGContextOriginWithPort( inContext, port );
+ CGContextTranslateCTM( inContext, 0, (portRect.bottom - portRect.top) );
+ CGContextScaleCTM( inContext, 1, -1 );
+ createdContext = true;
+ }
+
HIViewGetBounds( inView->fViewRef, &bounds );
-// CGContextStrokeRect( inContext, bounds );
temp = (CGContextRef)[[inView->fKitWindow _threadContext] graphicsPort];
CGContextRetain( temp );
@@ -331,16 +361,31 @@ Draw( HIWebFrameView* inView, RgnHandle limitRgn, CGContextRef inContext )
GetRegionBounds( limitRgn, &drawRect );
+ if ( !inView->fIsComposited )
+ OffsetRect( &drawRect, -bounds.origin.x, -bounds.origin.y );
+
hiRect.origin.x = drawRect.left;
hiRect.origin.y = bounds.size.height - drawRect.bottom; // flip y
hiRect.size.width = drawRect.right - drawRect.left;
hiRect.size.height = drawRect.bottom - drawRect.top;
- [inView->fWebFrameView displayIfNeededInRect: *(NSRect*)&hiRect];
+// printf( "Drawing: drawRect is (%g %g) (%g %g)\n", hiRect.origin.x, hiRect.origin.y,
+// hiRect.size.width, hiRect.size.height );
+
+ if ( inView->fIsComposited )
+ [inView->fWebFrameView displayIfNeededInRect: *(NSRect*)&hiRect];
+ else
+ [inView->fWebFrameView displayRect:*(NSRect*)&hiRect];
[[inView->fKitWindow _threadContext] setCGContext: temp];
CGContextRelease( temp );
+
+ if ( createdContext )
+ {
+ CGContextSynchronize( inContext );
+ CGContextRelease( inContext );
+ }
}
//----------------------------------------------------------------------------------
@@ -454,9 +499,15 @@ Click( HIWebFrameView* inView, EventRef inEvent )
// targ = [[inView->fKitWindow _borderView] hitTest:[kitEvent locationInWindow]];
+ if ( !inView->fIsComposited )
+ StartUpdateObserver( inView );
+
// [targ mouseDown:kitEvent];
[inView->fKitWindow sendEvent:kitEvent];
+ if ( !inView->fIsComposited )
+ StopUpdateObserver( inView );
+
[kitEvent release];
CantAllocNewEvent:
@@ -639,6 +690,8 @@ OwningWindowChanged(
{
if ( newWindow )
{
+ WindowAttributes attrs;
+
OSStatus err = GetWindowProperty(newWindow, NSAppKitPropertyCreator, NSCarbonWindowPropertyTag, sizeof(NSWindow *), NULL, &view->fKitWindow);
if ( err != noErr )
{
@@ -651,7 +704,11 @@ OwningWindowChanged(
}
[[view->fKitWindow contentView] addSubview:view->fWebFrameView];
- SyncFrame( view );
+
+ GetWindowAttributes( newWindow, &attrs );
+ view->fIsComposited = ( ( attrs & kWindowCompositingAttribute ) != 0 );
+
+ SyncFrame( view );
}
}
@@ -688,18 +745,54 @@ SyncFrame( HIWebFrameView* inView )
if ( parent )
{
- HIRect frame;
- HIRect parentBounds;
- NSPoint origin;
-
- HIViewGetFrame( inView->fViewRef, &frame );
- HIViewGetBounds( parent, &parentBounds );
-
- origin.x = frame.origin.x;
- origin.y = parentBounds.size.height - CGRectGetMaxY( frame );
-
- [inView->fWebFrameView setFrameOrigin: origin];
- [inView->fWebFrameView setFrameSize: *(NSSize*)&frame.size];
+ if ( inView->fIsComposited )
+ {
+ HIRect frame;
+ HIRect parentBounds;
+ NSPoint origin;
+
+ HIViewGetFrame( inView->fViewRef, &frame );
+ HIViewGetBounds( parent, &parentBounds );
+
+ origin.x = frame.origin.x;
+ origin.y = parentBounds.size.height - CGRectGetMaxY( frame );
+ printf( "syncing to (%g %g) (%g %g)\n", origin.x, origin.y,
+ frame.size.width, frame.size.height );
+ [inView->fWebFrameView setFrameOrigin: origin];
+ [inView->fWebFrameView setFrameSize: *(NSSize*)&frame.size];
+ }
+ else
+ {
+ GrafPtr port = GetWindowPort( GetControlOwner( inView->fViewRef ) );
+ PixMapHandle portPix = GetPortPixMap( port );
+ Rect bounds;
+ HIRect rootFrame;
+ HIRect frame;
+
+ GetControlBounds( inView->fViewRef, &bounds );
+ OffsetRect( &bounds, -(**portPix).bounds.left, -(**portPix).bounds.top );
+
+// printf( "control lives at %d %d %d %d in window-coords\n", bounds.top, bounds.left,
+// bounds.bottom, bounds.right );
+
+ HIViewGetFrame( HIViewGetRoot( GetControlOwner( inView->fViewRef ) ), &rootFrame );
+
+ frame.origin.x = bounds.left;
+ frame.origin.y = rootFrame.size.height - bounds.bottom;
+ frame.size.width = bounds.right - bounds.left;
+ frame.size.height = bounds.bottom - bounds.top;
+
+// printf( " before frame convert (%g %g) (%g %g)\n", frame.origin.x, frame.origin.y,
+// frame.size.width, frame.size.height );
+
+ [inView->fWebFrameView convertRect:*(NSRect*)&frame fromView:nil];
+
+// printf( " moving web view to (%g %g) (%g %g)\n", frame.origin.x, frame.origin.y,
+// frame.size.width, frame.size.height );
+
+ [inView->fWebFrameView setFrameOrigin: *(NSPoint*)&frame.origin];
+ [inView->fWebFrameView setFrameSize: *(NSSize*)&frame.size];
+ }
}
}
@@ -1398,3 +1491,127 @@ HIWebFrameViewEventHandler(
MissingParameter:
return result;
}
+
+static void
+StartUpdateObserver( HIWebFrameView* view )
+{
+ CFRunLoopObserverContext context;
+ CFRunLoopObserverRef observer;
+ CFRunLoopRef mainRunLoop;
+
+ check( view->fIsComposited == false );
+ check( view->fUpdateObserver == NULL );
+
+ context.version = 0;
+ context.info = view;
+ context.retain = NULL;
+ context.release = NULL;
+ context.copyDescription = NULL;
+
+ mainRunLoop = (CFRunLoopRef)GetCFRunLoopFromEventLoop( GetMainEventLoop() );
+ observer = CFRunLoopObserverCreate( NULL, kCFRunLoopEntry | kCFRunLoopBeforeWaiting, true, 0, UpdateObserver, &context );
+ CFRunLoopAddObserver( mainRunLoop, observer, kCFRunLoopCommonModes );
+
+ view->fUpdateObserver = observer;
+
+// printf( "Update observer started\n" );
+}
+
+static void
+StopUpdateObserver( HIWebFrameView* view )
+{
+ check( view->fIsComposited == false );
+ check( view->fUpdateObserver != NULL );
+
+ CFRunLoopObserverInvalidate( view->fUpdateObserver );
+ CFRelease( view->fUpdateObserver );
+ view->fUpdateObserver = NULL;
+
+// printf( "Update observer removed\n" );
+}
+
+static void
+UpdateObserver( CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *info )
+{
+ HIWebFrameView* view = (HIWebFrameView*)info;
+ RgnHandle region = NewRgn();
+
+// printf( "Update observer called\n" );
+
+ if ( region )
+ {
+ GetWindowRegion( GetControlOwner( view->fViewRef ), kWindowUpdateRgn, region );
+
+ if ( !EmptyRgn( region ) )
+ {
+ RgnHandle ourRgn = NewRgn();
+ Rect rect;
+
+ GetWindowBounds( GetControlOwner( view->fViewRef ), kWindowStructureRgn, &rect );
+
+// printf( "Update region is non-empty\n" );
+
+ if ( ourRgn )
+ {
+ Rect rect;
+ GrafPtr savePort, port;
+ Point offset = { 0, 0 };
+
+ port = GetWindowPort( GetControlOwner( view->fViewRef ) );
+
+ GetPort( &savePort );
+ SetPort( port );
+
+ GlobalToLocal( &offset );
+ OffsetRgn( region, offset.h, offset.v );
+
+ GetControlBounds( view->fViewRef, &rect );
+ RectRgn( ourRgn, &rect );
+
+// printf( "our control is at %d %d %d %d\n",
+// rect.top, rect.left, rect.bottom, rect.right );
+
+ GetRegionBounds( region, &rect );
+// printf( "region is at %d %d %d %d\n",
+// rect.top, rect.left, rect.bottom, rect.right );
+
+ SectRgn( ourRgn, region, ourRgn );
+
+ GetRegionBounds( ourRgn, &rect );
+// printf( "intersection is %d %d %d %d\n",
+// rect.top, rect.left, rect.bottom, rect.right );
+ if ( !EmptyRgn( ourRgn ) )
+ {
+ RgnHandle saveVis = NewRgn();
+
+// printf( "looks like we should draw\n" );
+
+ if ( saveVis )
+ {
+// RGBColor kRedColor = { 0xffff, 0, 0 };
+
+ GetPortVisibleRegion( GetWindowPort( GetControlOwner( view->fViewRef ) ), saveVis );
+ SetPortVisibleRegion( GetWindowPort( GetControlOwner( view->fViewRef ) ), ourRgn );
+
+// RGBForeColor( &kRedColor );
+// PaintRgn( ourRgn );
+// QDFlushPortBuffer( port, NULL );
+// Delay( 15, NULL );
+
+ Draw1Control( view->fViewRef );
+ ValidWindowRgn( GetControlOwner( view->fViewRef ), ourRgn );
+
+ SetPortVisibleRegion( GetWindowPort( GetControlOwner( view->fViewRef ) ), saveVis );
+ DisposeRgn( saveVis );
+ }
+ }
+
+ SetPort( savePort );
+
+ DisposeRgn( ourRgn );
+ }
+ }
+
+ DisposeRgn( region );
+ }
+}
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 630922f..da4593b 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,22 @@
+2003-03-19 Ed Voas voas at apple.com
+
+ Reviewed by Richard.
+
+ Got it working in non-compositing mode as well, so in theory it
+ can work inside a PowerPlant application as well. It's a bit of what
+ I'd consider a hack, but it's pretty straightforward.
+
+ * Carbon.subproj/CarbonWindowAdapter.m:
+ (-[CarbonWindowAdapter setViewsNeedDisplay:]):
+ * Carbon.subproj/HIViewAdapter.h:
+ * Carbon.subproj/HIViewAdapter.m:
+ (+[HIViewAdapter bindHIViewToNSView:nsView:]):
+ (-[HIViewAdapter setNeedsDisplay:]):
+ (-[HIViewAdapter setNeedsDisplayInRect:]):
+ (SetViewNeedsDisplay):
+ * Carbon.subproj/HIWebView.m:
+ (if):
+
2003-03-18 Maciej Stachowiak <mjs at apple.com>
Reviewed by Trey.
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list