[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
cblu
cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:18:14 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 9f2cc6a93e119e11c6ec380a257105642715e612
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Jun 13 03:33:30 2002 +0000
Couldn't run ChangeLog because it hung with the massize diffs, so here's
a hand-made one.
Changes to support inline views.
Modified Files:
WebBrowser/BrowserDocument.m
WebBrowser/LocationChangeHandler.m
WebBrowser/Debug/DebugUtilities.m WebCore/WebCore.exp
WebCore/kwq/KWQKHTMLPart.mm
WebCore/kwq/KWQKHTMLPartBrowserExtension.mm
WebCore/kwq/KWQKloader.mm WebCore/kwq/KWQScrollView.mm
WebCore/kwq/KWQView.h WebCore/kwq/KWQView.mm
WebCore/kwq/KWQWidget.mm WebCore/kwq/external.h
WebKit/ChangeLog WebKit/Plugins.subproj/IFNullPluginView.mm
WebKit/Plugins.subproj/IFPluginDatabase.h
WebKit/Plugins.subproj/IFPluginDatabase.m
WebKit/Plugins.subproj/IFPluginView.mm
WebKit/WebCoreSupport.subproj/IFImageRenderer.h
WebKit/WebCoreSupport.subproj/IFWebCoreViewFactory.m
WebKit/WebKit.pbproj/project.pbxproj
WebKit/WebView.subproj/IFDOMNode.mm
WebKit/WebView.subproj/IFDynamicScrollBarsView.m
WebKit/WebView.subproj/IFMainURLHandleClient.h
WebKit/WebView.subproj/IFMainURLHandleClient.mm
WebKit/WebView.subproj/IFRenderNode.mm
WebKit/WebView.subproj/IFWebController.h
WebKit/WebView.subproj/IFWebController.mm
WebKit/WebView.subproj/IFWebControllerPrivate.h
WebKit/WebView.subproj/IFWebControllerPrivate.mm
WebKit/WebView.subproj/IFWebDataSource.h
WebKit/WebView.subproj/IFWebDataSource.mm
WebKit/WebView.subproj/IFWebDataSourcePrivate.h
WebKit/WebView.subproj/IFWebDataSourcePrivate.mm
WebKit/WebView.subproj/IFWebFrame.mm
WebKit/WebView.subproj/IFWebFramePrivate.h
WebKit/WebView.subproj/IFWebFramePrivate.mm
WebKit/WebView.subproj/IFWebView.h
WebKit/WebView.subproj/IFWebView.mm
WebKit/WebView.subproj/IFWebViewPrivate.h
WebKit/WebView.subproj/IFWebViewPrivate.mm
Added Files:
WebKit/Misc.subproj/IFNSViewExtras.h
WebKit/Misc.subproj/IFNSViewExtras.m
WebKit/WebView.subproj/IFDocument.h
WebKit/WebView.subproj/IFHTMLRepresentation.h
WebKit/WebView.subproj/IFHTMLRepresentation.mm
WebKit/WebView.subproj/IFHTMLView.h
WebKit/WebView.subproj/IFHTMLView.mm
WebKit/WebView.subproj/IFHTMLViewPrivate.h
WebKit/WebView.subproj/IFHTMLViewPrivate.mm
WebKit/WebView.subproj/IFImageRepresentation.h
WebKit/WebView.subproj/IFImageRepresentation.m
WebKit/WebView.subproj/IFImageView.h
WebKit/WebView.subproj/IFImageView.m
WebKit/WebView.subproj/IFTextRepresentation.h
WebKit/WebView.subproj/IFTextRepresentation.m
WebKit/WebView.subproj/IFTextView.h
WebKit/WebView.subproj/IFTextView.m
Removed Files:
WebKit/MIME.subproj/IFContentHandler.h
WebKit/MIME.subproj/IFContentHandler.m
WebKit/MIME.subproj/IFMIMEHandler.h
WebKit/MIME.subproj/IFMIMEHandler.m
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1340 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/WebCore.exp b/WebCore/WebCore.exp
index 2950829..778bb3d 100644
--- a/WebCore/WebCore.exp
+++ b/WebCore/WebCore.exp
@@ -34,3 +34,5 @@ __ZNK3DOM9DOMString6stringEv
__ZNK7QString6latin1Ev
__ZNK7QWidget7getViewEv
__ZNK9KHTMLPart10xmlDocImplEv
+__ZN9KHTMLView14setMarginWidthEi
+__ZN9KHTMLView15setMarginHeightEi
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index adec8dc..9678606 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -461,14 +461,18 @@ bool KWQKHTMLPartImpl::requestFrame( khtml::RenderPart *frame, const QString &ur
dataSource = getDataSource();
+ KWQDEBUGLEVEL (KWQ_LOG_FRAMES, "name %s\n", [nsframeName cString]);
aFrame =[dataSource frameNamed: nsframeName];
if (aFrame){
- if ([[aFrame view] _provisionalWidget])
- frame->setWidget ([[aFrame view] _provisionalWidget]);
+ KWQDEBUGLEVEL (KWQ_LOG_FRAMES, "found %s\n", [nsframeName cString]);
+ QWidget *khtmlview = [[[aFrame view] documentView] _provisionalWidget];
+ if (khtmlview)
+ frame->setWidget (khtmlview);
else
- frame->setWidget ([[aFrame view] _widget]);
+ frame->setWidget ([[[aFrame view] documentView] _widget]);
}
else {
+ KWQDEBUGLEVEL (KWQ_LOG_FRAMES, "creating %s\n", [nsframeName cString]);
IFWebDataSource *oldDataSource, *newDataSource;
NSURL *childURL;
IFWebFrame *newFrame;
@@ -494,10 +498,10 @@ bool KWQKHTMLPartImpl::requestFrame( khtml::RenderPart *frame, const QString &ur
[newDataSource _setParent: oldDataSource];
[newFrame setProvisionalDataSource: newDataSource];
- KHTMLView *view = (KHTMLView *)[[newFrame view] _provisionalWidget];
- view->setMarginWidth (o->getMarginWidth());
- view->setMarginHeight (o->getMarginWidth());
+ [[newFrame view] _setMarginWidth: o->getMarginWidth()];
+ [[newFrame view] _setMarginHeight: o->getMarginHeight()];
+
[newFrame startLoading];
}
@@ -659,7 +663,7 @@ QPtrList<KParts::ReadOnlyPart> KWQKHTMLPartImpl::frames() const
for (i = 0; i < [children count]; i++){
aFrame = [children objectAtIndex: i];
- res.append( [[aFrame dataSource] _part] );
+ res.append( [[[aFrame dataSource] representation] part] );
}
return res;
}
@@ -707,5 +711,5 @@ KHTMLPart *KWQKHTMLPartImpl::parentPart()
IFWebDataSource *parent, *dataSource = getDataSource();
parent = [dataSource parent];
- return [parent _part];
+ return [[parent representation] part];
}
diff --git a/WebCore/kwq/KWQKHTMLPartBrowserExtension.mm b/WebCore/kwq/KWQKHTMLPartBrowserExtension.mm
index dd861b1..59a4dc6 100644
--- a/WebCore/kwq/KWQKHTMLPartBrowserExtension.mm
+++ b/WebCore/kwq/KWQKHTMLPartBrowserExtension.mm
@@ -60,6 +60,6 @@ void KHTMLPartBrowserExtension::createNewWindow(const KURL &url,
{
IFWebController *newController = [[m_part->impl->getDataSource() controller] openNewWindowWithURL:url.getNSURL()];
if (part != NULL) {
- *part = [[[newController mainFrame] provisionalDataSource] _part];
+ *part = [[[[newController mainFrame] provisionalDataSource] representation] part];
}
}
diff --git a/WebCore/kwq/KWQKHTMLPartImpl.mm b/WebCore/kwq/KWQKHTMLPartImpl.mm
index adec8dc..9678606 100644
--- a/WebCore/kwq/KWQKHTMLPartImpl.mm
+++ b/WebCore/kwq/KWQKHTMLPartImpl.mm
@@ -461,14 +461,18 @@ bool KWQKHTMLPartImpl::requestFrame( khtml::RenderPart *frame, const QString &ur
dataSource = getDataSource();
+ KWQDEBUGLEVEL (KWQ_LOG_FRAMES, "name %s\n", [nsframeName cString]);
aFrame =[dataSource frameNamed: nsframeName];
if (aFrame){
- if ([[aFrame view] _provisionalWidget])
- frame->setWidget ([[aFrame view] _provisionalWidget]);
+ KWQDEBUGLEVEL (KWQ_LOG_FRAMES, "found %s\n", [nsframeName cString]);
+ QWidget *khtmlview = [[[aFrame view] documentView] _provisionalWidget];
+ if (khtmlview)
+ frame->setWidget (khtmlview);
else
- frame->setWidget ([[aFrame view] _widget]);
+ frame->setWidget ([[[aFrame view] documentView] _widget]);
}
else {
+ KWQDEBUGLEVEL (KWQ_LOG_FRAMES, "creating %s\n", [nsframeName cString]);
IFWebDataSource *oldDataSource, *newDataSource;
NSURL *childURL;
IFWebFrame *newFrame;
@@ -494,10 +498,10 @@ bool KWQKHTMLPartImpl::requestFrame( khtml::RenderPart *frame, const QString &ur
[newDataSource _setParent: oldDataSource];
[newFrame setProvisionalDataSource: newDataSource];
- KHTMLView *view = (KHTMLView *)[[newFrame view] _provisionalWidget];
- view->setMarginWidth (o->getMarginWidth());
- view->setMarginHeight (o->getMarginWidth());
+ [[newFrame view] _setMarginWidth: o->getMarginWidth()];
+ [[newFrame view] _setMarginHeight: o->getMarginHeight()];
+
[newFrame startLoading];
}
@@ -659,7 +663,7 @@ QPtrList<KParts::ReadOnlyPart> KWQKHTMLPartImpl::frames() const
for (i = 0; i < [children count]; i++){
aFrame = [children objectAtIndex: i];
- res.append( [[aFrame dataSource] _part] );
+ res.append( [[[aFrame dataSource] representation] part] );
}
return res;
}
@@ -707,5 +711,5 @@ KHTMLPart *KWQKHTMLPartImpl::parentPart()
IFWebDataSource *parent, *dataSource = getDataSource();
parent = [dataSource parent];
- return [parent _part];
+ return [[parent representation] part];
}
diff --git a/WebCore/kwq/KWQKloader.mm b/WebCore/kwq/KWQKloader.mm
index 92a0c55..bdfe7a4 100644
--- a/WebCore/kwq/KWQKloader.mm
+++ b/WebCore/kwq/KWQKloader.mm
@@ -203,7 +203,7 @@ void WCSetIFLoadProgressMakeFunc(WCIFLoadProgressMakeFunc func)
NSURL *oldURL = job->url();
KWQDEBUGLEVEL (KWQ_LOG_LOADING, "url = %s\n", DEBUG_OBJECT(url));
- [m_dataSource _part]->impl->setBaseURL([[url absoluteString] cString]);
+ [[m_dataSource representation] part]->impl->setBaseURL([[url absoluteString] cString]);
[m_dataSource _setFinalURL: url];
diff --git a/WebCore/kwq/KWQLoader.mm b/WebCore/kwq/KWQLoader.mm
index 92a0c55..bdfe7a4 100644
--- a/WebCore/kwq/KWQLoader.mm
+++ b/WebCore/kwq/KWQLoader.mm
@@ -203,7 +203,7 @@ void WCSetIFLoadProgressMakeFunc(WCIFLoadProgressMakeFunc func)
NSURL *oldURL = job->url();
KWQDEBUGLEVEL (KWQ_LOG_LOADING, "url = %s\n", DEBUG_OBJECT(url));
- [m_dataSource _part]->impl->setBaseURL([[url absoluteString] cString]);
+ [[m_dataSource representation] part]->impl->setBaseURL([[url absoluteString] cString]);
[m_dataSource _setFinalURL: url];
diff --git a/WebCore/kwq/KWQLoaderImpl.mm b/WebCore/kwq/KWQLoaderImpl.mm
index 92a0c55..bdfe7a4 100644
--- a/WebCore/kwq/KWQLoaderImpl.mm
+++ b/WebCore/kwq/KWQLoaderImpl.mm
@@ -203,7 +203,7 @@ void WCSetIFLoadProgressMakeFunc(WCIFLoadProgressMakeFunc func)
NSURL *oldURL = job->url();
KWQDEBUGLEVEL (KWQ_LOG_LOADING, "url = %s\n", DEBUG_OBJECT(url));
- [m_dataSource _part]->impl->setBaseURL([[url absoluteString] cString]);
+ [[m_dataSource representation] part]->impl->setBaseURL([[url absoluteString] cString]);
[m_dataSource _setFinalURL: url];
diff --git a/WebCore/kwq/KWQScrollView.mm b/WebCore/kwq/KWQScrollView.mm
index 2a30fa7..26aaf3b 100644
--- a/WebCore/kwq/KWQScrollView.mm
+++ b/WebCore/kwq/KWQScrollView.mm
@@ -50,49 +50,84 @@ QWidget* QScrollView::viewport() const
int QScrollView::visibleWidth() const
{
- NSScrollView *scrollView = [[getView() superview] superview];
+#if 0
+ id view = getView();
+ NSScrollView *scrollView = [[view superview] superview];
int visibleWidth;
if (scrollView != nil && [scrollView isKindOfClass: [NSScrollView class]])
visibleWidth = (int)[scrollView documentVisibleRect].size.width;
else
- visibleWidth = (int)[getView() bounds].size.width;
+ visibleWidth = (int)[view bounds].size.width;
return visibleWidth;
+#else
+ NSScrollView *view = (NSScrollView *)getView();
+ int visibleWidth;
+ if (view != nil && [view isKindOfClass: [NSScrollView class]]){
+ visibleWidth = (int)[view documentVisibleRect].size.width;
+ }
+ else
+ visibleWidth = (int)[view bounds].size.width;
+ if (visibleWidth <= 0)
+ visibleWidth = 200;
+ return visibleWidth;
+#endif
}
int QScrollView::visibleHeight() const
{
- NSScrollView *scrollView = [[getView() superview] superview];
+#if 0
+ id view = getView();
+ NSScrollView *scrollView = [[view superview] superview];
int visibleHeight;
- if (scrollView != nil && [scrollView isKindOfClass: [NSScrollView class]])
+ if (scrollView != nil && [scrollView isKindOfClass: [NSScrollView class]]){
visibleHeight = (int)[scrollView documentVisibleRect].size.height;
+ }
+ else
+ visibleHeight = (int)[view bounds].size.height;
+ return visibleHeight;
+#else
+ NSScrollView *view = (NSScrollView *)getView();
+ int visibleHeight;
+
+ if (view != nil && [view isKindOfClass: [NSScrollView class]]){
+ visibleHeight = (int)[view documentVisibleRect].size.height;
+ }
else
- visibleHeight = (int)[getView() bounds].size.height;
+ visibleHeight = (int)[view bounds].size.height;
+
+ if (visibleHeight <= 0)
+ visibleHeight = 200;
return visibleHeight;
+#endif
}
int QScrollView::contentsWidth() const
{
- return (int)[getView() bounds].size.width;
+ NSScrollView *view = (NSScrollView *)getView();
+ return (int)[[view documentView] bounds].size.width;
}
int QScrollView::contentsHeight() const
{
- return (int)[getView() bounds].size.height;
+ NSScrollView *view = (NSScrollView *)getView();
+ return (int)[[view documentView] bounds].size.height;
}
int QScrollView::contentsX() const
{
- return 0;
+ NSScrollView *view = (NSScrollView *)getView();
+ return (int)[[view documentView] bounds].origin.x;
}
int QScrollView::contentsY() const
{
- return 0;
+ NSScrollView *view = (NSScrollView *)getView();
+ return (int)[[view documentView] bounds].origin.y;
}
int QScrollView::childX(QWidget *)
@@ -149,6 +184,10 @@ void QScrollView::addChild(QWidget* child, int x, int y)
}
subView = child->getView();
+ if ([subView isKindOfClass: [NSScrollView class]]) {
+ subView = [subView superview];
+ }
+
if ([subView superview] == thisView) {
return;
}
@@ -167,7 +206,6 @@ void QScrollView::removeChild(QWidget* child)
void QScrollView::resizeContents(int w, int h)
{
KWQDEBUGLEVEL (KWQ_LOG_FRAMES, "%p %s at w %d h %d\n", getView(), [[[getView() class] className] cString], w, h);
- //if ([nsview isKindOfClass: NSClassFromString(@"IFDynamicScrollBarsView")])
if ([getView() isKindOfClass: [NSScrollView class]]){
NSScrollView *scrollView = (NSScrollView *)getView();
IFWebView *wview = [scrollView documentView];
diff --git a/WebCore/kwq/KWQView.h b/WebCore/kwq/KWQView.h
index 0112cde..4dcc3e7 100644
--- a/WebCore/kwq/KWQView.h
+++ b/WebCore/kwq/KWQView.h
@@ -60,24 +60,6 @@ class KHTMLPart;
@end
- at interface KWQHTMLView : NSView
-{
- QWidget *widget;
- KHTMLPart *part; // FIXME. This is a temporary reference.
- bool isFlipped;
- bool needsLayout;
- NSCursor *cursor;
-}
-- initWithFrame: (NSRect)r widget: (QWidget *)w;
-- (void)setIsFlipped: (bool)flag;
-- (void)setNeedsLayout: (bool)flag;
-- (void)resetView;
-- (void)setCursor:(NSCursor *)cursor;
-
- at end
-
-
-
diff --git a/WebCore/kwq/KWQView.mm b/WebCore/kwq/KWQView.mm
index 45fab79..b98b024 100644
--- a/WebCore/kwq/KWQView.mm
+++ b/WebCore/kwq/KWQView.mm
@@ -121,216 +121,3 @@
}
@end
-
-
- at implementation KWQHTMLView
-
-- initWithFrame: (NSRect) r widget: (QWidget *)w
-{
- NSNotificationCenter *notificationCenter;
- SEL notificationReceivedSEL;
-
- [super initWithFrame: r];
- widget = w;
- isFlipped = YES;
- needsLayout = YES;
- notificationCenter = [NSNotificationCenter defaultCenter];
-
- notificationReceivedSEL = @selector(notificationReceived:);
- [notificationCenter addObserver:self
- selector:notificationReceivedSEL name:nil object:nil];
-
- return self;
-}
-
-#ifdef DELAY_LAYOUT
-- delayLayout: sender
-{
- [NSObject cancelPreviousPerformRequestsWithTarget: self selector: @selector(delayLayout:) object: self];
- KWQDEBUG("KWQHTMLView: delayLayout called\n");
- [self setNeedsLayout: YES];
- [self setNeedsDisplay: YES];
-}
-
--(void)notificationReceived:(NSNotification *)notification
-{
- if ([[notification name] rangeOfString: @"uri-fin-"].location == 0){
- KWQDEBUG("KWQHTMLView: Received notification, %s\n", DEBUG_OBJECT([notification name]));
- [self performSelector:@selector(delayLayout:) withObject:self afterDelay:(NSTimeInterval)0.5];
- }
-}
-#else
--(void)notificationReceived:(NSNotification *)notification
-{
- if ([[notification name] rangeOfString: @"uri-fin-"].location == 0){
- [self setNeedsLayout: YES];
- [self setNeedsDisplay: YES];
- }
-}
-#endif
-
-- (void)layout
-{
- if (needsLayout){
-#ifndef NDEBUG
- double start = CFAbsoluteTimeGetCurrent();
-#endif
- ((KHTMLView *)widget)->layout();
- KWQDEBUGLEVEL (KWQ_LOG_TIMING, "layout time %e\n", CFAbsoluteTimeGetCurrent() - start);
- needsLayout = NO;
- }
-}
-
-
-- (void)setNeedsLayout: (bool)flag
-{
- needsLayout = flag;
-}
-
-// This should eventually be removed.
-- (void)drawRect:(NSRect)rect {
- if (widget != 0l){
- //widget->paint((void *)0);
-
- [self layout];
-
- QPainter p(widget);
-
- [self lockFocus];
-
-#ifndef NDEBUG
- double start = CFAbsoluteTimeGetCurrent();
-#endif
- ((KHTMLView *)widget)->drawContents( &p, (int)rect.origin.x,
- (int)rect.origin.y,
- (int)rect.size.width,
- (int)rect.size.height );
- KWQDEBUGLEVEL (KWQ_LOG_TIMING, "draw time %e\n", CFAbsoluteTimeGetCurrent() - start);
- [self unlockFocus];
- }
-}
-
-- (void)setIsFlipped: (bool)flag
-{
- isFlipped = flag;
-}
-
-
-- (BOOL)isFlipped
-{
- return isFlipped;
-}
-
-
-- (void)resetView
-{
- NSArray *views = [self subviews];
- int count;
-
- count = [views count];
- while (count--){
- KWQDEBUG("Removing %p %s\n", [views objectAtIndex: 0], DEBUG_OBJECT([[[views objectAtIndex: 0] class] className]));
- [[views objectAtIndex: 0] removeFromSuperviewWithoutNeedingDisplay];
- }
- [self setFrameSize: NSMakeSize (0,0)];
-}
-
-- (void)setFrame:(NSRect)frameRect
-{
- [super setFrame:frameRect];
- [self setNeedsLayout: YES];
-}
-
-
-// FIXME. This should be replaced. Ultimately we will use something like:
-// [[webView dataSource] setURL: url];
-- (void)setURL: (NSString *)urlString
-{
- KURL url = [urlString cString];
-
- [self resetView];
- part->openURL (url);
-}
-
-- (void)mouseUp: (NSEvent *)event
-{
- int button, state;
-
- button = state = 0;
-
- if ([event type] == NSLeftMouseDown){
- button = Qt::LeftButton;
- state = Qt::LeftButton;
- }
- else if ([event type] == NSRightMouseDown){
- button = Qt::RightButton;
- state = Qt::RightButton;
- }
- else if ([event type] == NSOtherMouseDown){
- button = Qt::MidButton;
- state = Qt::MidButton;
- }
- NSPoint p = [event locationInWindow];
-
- QMouseEvent *kEvent = new QMouseEvent(QEvent::MouseButtonPress, QPoint((int)p.x, (int)p.y), button, state);
- ((KHTMLView *)widget)->viewportMouseReleaseEvent(kEvent);
-}
-
-- (void)mouseDown: (NSEvent *)event
-{
- int button, state;
-
- button = state = 0;
-
- if ([event type] == NSLeftMouseDown){
- button = Qt::LeftButton;
- state = Qt::LeftButton;
- }
- else if ([event type] == NSRightMouseDown){
- button = Qt::RightButton;
- state = Qt::RightButton;
- }
- else if ([event type] == NSOtherMouseDown){
- button = Qt::MidButton;
- state = Qt::MidButton;
- }
- NSPoint p = [event locationInWindow];
-
- QMouseEvent *kEvent = new QMouseEvent(QEvent::MouseButtonPress, QPoint((int)p.x, (int)p.y), button, state);
- ((KHTMLView *)widget)->viewportMousePressEvent(kEvent);
-}
-
-- (void)mouseDragged: (NSEvent *)event
-{
- NSPoint p = [event locationInWindow];
- KWQDEBUG ("mouseDragged %f, %f\n", p.x, p.y);
-}
-
-- (void)setCursor:(NSCursor *)cur
-{
- [cursor release];
- cursor = [cur retain];
-
-
- // We have to make both of these calls, because:
- // - Just setting a cursor rect will have no effect, if the mouse cursor is already
- // inside the area of the rect.
- // - Just calling invalidateCursorRectsForView will not call resetCursorRects if
- // there is no cursor rect set currently and the view has no subviews.
- // Therefore we have to call resetCursorRects to ensure that a cursor rect is set
- // at all, if we are going to want one, and then invalidateCursorRectsForView: to
- // call resetCursorRects from the proper context that will
- // actually result in updating the cursor.
- [self resetCursorRects];
- [[self window] invalidateCursorRectsForView:self];
-}
-
-- (void)resetCursorRects
-{
- if (cursor != nil && cursor != [NSCursor arrowCursor]) {
- [self addCursorRect:[self visibleRect] cursor:cursor];
- }
-}
-
- at end
-
diff --git a/WebCore/kwq/KWQWidget.mm b/WebCore/kwq/KWQWidget.mm
index ea15b68..717dbd0 100644
--- a/WebCore/kwq/KWQWidget.mm
+++ b/WebCore/kwq/KWQWidget.mm
@@ -86,7 +86,6 @@ QSize QWidget::sizeHint() const
void QWidget::resize(int w, int h)
{
- KWQDEBUG ("%p %s to w %d h %d\n", getView(), [[[getView() class] className] cString], w, h);
internalSetGeometry(pos().x(), pos().y(), w, h);
}
@@ -282,10 +281,12 @@ void QWidget::setCursor(const QCursor &cur)
{
data->cursor = cur;
+#if 0
id view = data->view;
if ([view respondsToSelector:@selector(setCursor:)]) {
[view setCursor:data->cursor.handle()];
}
+#endif
}
QCursor QWidget::cursor()
@@ -324,7 +325,12 @@ void QWidget::hide()
void QWidget::internalSetGeometry(int x, int y, int w, int h)
{
- [data->view setFrame:NSMakeRect(x, y, w, h)];
+ id view = getView();
+ // If we're an scroll view, that means we're a khtmlview, so get
+ // the IFWebView and resize that.
+ if ([view isKindOfClass: [NSScrollView class]])
+ view = [view superview];
+ [view setFrame:NSMakeRect(x, y, w, h)];
}
void QWidget::showEvent(QShowEvent *)
diff --git a/WebCore/kwq/external.h b/WebCore/kwq/external.h
index 91e8aee..f6d6037 100644
--- a/WebCore/kwq/external.h
+++ b/WebCore/kwq/external.h
@@ -74,18 +74,26 @@ namespace khtml {
- (void)_addURLHandle: (IFURLHandle *)handle;
- (void)_removeURLHandle: (IFURLHandle *)handle;
- controller;
-- (KHTMLPart *)_part;
- (void)_setTitle: (NSString *)title;
- (void)_setFinalURL: (NSURL *)url;
- (id <IFLocationChangeHandler>)_locationChangeHandler;
- (BOOL)_isStopping;
- (NSArray *)children;
+- representation;
+ at end
+
+ at interface IFHTMLRepresentation : NSObject
+- (KHTMLPart *)part;
@end
@interface IFWebView: NSObject
- (QWidget *)_widget;
- (QWidget *)_provisionalWidget;
- (void)setFrameSize: (NSSize)r;
+- (void)_setMarginWidth: (int)w;
+- (int)_marginWidth;
+- (void)_setMarginHeight: (int)h;
+- (int)_marginHeight;
@end
@interface IFWebFrame: NSObject
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 45011c1..0b0d3e9 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,68 @@
+2002-06-12 Chris Blumenberg <cblu at apple.com>
+
+ Couldn't run ChangeLog because it hung with the massize diffs, so here's
+ a hand-made one.
+
+ Changes to support inline views.
+
+ Modified Files:
+
+ WebKit/ChangeLog WebKit/Plugins.subproj/IFNullPluginView.mm
+ WebKit/Plugins.subproj/IFPluginDatabase.h
+ WebKit/Plugins.subproj/IFPluginDatabase.m
+ WebKit/Plugins.subproj/IFPluginView.mm
+ WebKit/WebCoreSupport.subproj/IFImageRenderer.h
+ WebKit/WebCoreSupport.subproj/IFWebCoreViewFactory.m
+ WebKit/WebKit.pbproj/project.pbxproj
+ WebKit/WebView.subproj/IFDOMNode.mm
+ WebKit/WebView.subproj/IFDynamicScrollBarsView.m
+ WebKit/WebView.subproj/IFMainURLHandleClient.h
+ WebKit/WebView.subproj/IFMainURLHandleClient.mm
+ WebKit/WebView.subproj/IFRenderNode.mm
+ WebKit/WebView.subproj/IFWebController.h
+ WebKit/WebView.subproj/IFWebController.mm
+ WebKit/WebView.subproj/IFWebControllerPrivate.h
+ WebKit/WebView.subproj/IFWebControllerPrivate.mm
+ WebKit/WebView.subproj/IFWebDataSource.h
+ WebKit/WebView.subproj/IFWebDataSource.mm
+ WebKit/WebView.subproj/IFWebDataSourcePrivate.h
+ WebKit/WebView.subproj/IFWebDataSourcePrivate.mm
+ WebKit/WebView.subproj/IFWebFrame.mm
+ WebKit/WebView.subproj/IFWebFramePrivate.h
+ WebKit/WebView.subproj/IFWebFramePrivate.mm
+ WebKit/WebView.subproj/IFWebView.h
+ WebKit/WebView.subproj/IFWebView.mm
+ WebKit/WebView.subproj/IFWebViewPrivate.h
+ WebKit/WebView.subproj/IFWebViewPrivate.mm
+
+ Added Files:
+
+ WebKit/Misc.subproj/IFNSViewExtras.h
+ WebKit/Misc.subproj/IFNSViewExtras.m
+ WebKit/WebView.subproj/IFDocument.h
+ WebKit/WebView.subproj/IFHTMLRepresentation.h
+ WebKit/WebView.subproj/IFHTMLRepresentation.mm
+ WebKit/WebView.subproj/IFHTMLView.h
+ WebKit/WebView.subproj/IFHTMLView.mm
+ WebKit/WebView.subproj/IFHTMLViewPrivate.h
+ WebKit/WebView.subproj/IFHTMLViewPrivate.mm
+ WebKit/WebView.subproj/IFImageRepresentation.h
+ WebKit/WebView.subproj/IFImageRepresentation.m
+ WebKit/WebView.subproj/IFImageView.h
+ WebKit/WebView.subproj/IFImageView.m
+ WebKit/WebView.subproj/IFTextRepresentation.h
+ WebKit/WebView.subproj/IFTextRepresentation.m
+ WebKit/WebView.subproj/IFTextView.h
+ WebKit/WebView.subproj/IFTextView.m
+
+ Removed Files:
+
+ WebKit/MIME.subproj/IFContentHandler.h
+ WebKit/MIME.subproj/IFContentHandler.m
+ WebKit/MIME.subproj/IFMIMEHandler.h
+ WebKit/MIME.subproj/IFMIMEHandler.m
+
+
2002-06-12 Kenneth Kocienda <kocienda at apple.com>
* Misc.subproj/WebKitDebug.h: Made assertion failure console message bolder and easier to see.
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index 45011c1..0b0d3e9 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,3 +1,68 @@
+2002-06-12 Chris Blumenberg <cblu at apple.com>
+
+ Couldn't run ChangeLog because it hung with the massize diffs, so here's
+ a hand-made one.
+
+ Changes to support inline views.
+
+ Modified Files:
+
+ WebKit/ChangeLog WebKit/Plugins.subproj/IFNullPluginView.mm
+ WebKit/Plugins.subproj/IFPluginDatabase.h
+ WebKit/Plugins.subproj/IFPluginDatabase.m
+ WebKit/Plugins.subproj/IFPluginView.mm
+ WebKit/WebCoreSupport.subproj/IFImageRenderer.h
+ WebKit/WebCoreSupport.subproj/IFWebCoreViewFactory.m
+ WebKit/WebKit.pbproj/project.pbxproj
+ WebKit/WebView.subproj/IFDOMNode.mm
+ WebKit/WebView.subproj/IFDynamicScrollBarsView.m
+ WebKit/WebView.subproj/IFMainURLHandleClient.h
+ WebKit/WebView.subproj/IFMainURLHandleClient.mm
+ WebKit/WebView.subproj/IFRenderNode.mm
+ WebKit/WebView.subproj/IFWebController.h
+ WebKit/WebView.subproj/IFWebController.mm
+ WebKit/WebView.subproj/IFWebControllerPrivate.h
+ WebKit/WebView.subproj/IFWebControllerPrivate.mm
+ WebKit/WebView.subproj/IFWebDataSource.h
+ WebKit/WebView.subproj/IFWebDataSource.mm
+ WebKit/WebView.subproj/IFWebDataSourcePrivate.h
+ WebKit/WebView.subproj/IFWebDataSourcePrivate.mm
+ WebKit/WebView.subproj/IFWebFrame.mm
+ WebKit/WebView.subproj/IFWebFramePrivate.h
+ WebKit/WebView.subproj/IFWebFramePrivate.mm
+ WebKit/WebView.subproj/IFWebView.h
+ WebKit/WebView.subproj/IFWebView.mm
+ WebKit/WebView.subproj/IFWebViewPrivate.h
+ WebKit/WebView.subproj/IFWebViewPrivate.mm
+
+ Added Files:
+
+ WebKit/Misc.subproj/IFNSViewExtras.h
+ WebKit/Misc.subproj/IFNSViewExtras.m
+ WebKit/WebView.subproj/IFDocument.h
+ WebKit/WebView.subproj/IFHTMLRepresentation.h
+ WebKit/WebView.subproj/IFHTMLRepresentation.mm
+ WebKit/WebView.subproj/IFHTMLView.h
+ WebKit/WebView.subproj/IFHTMLView.mm
+ WebKit/WebView.subproj/IFHTMLViewPrivate.h
+ WebKit/WebView.subproj/IFHTMLViewPrivate.mm
+ WebKit/WebView.subproj/IFImageRepresentation.h
+ WebKit/WebView.subproj/IFImageRepresentation.m
+ WebKit/WebView.subproj/IFImageView.h
+ WebKit/WebView.subproj/IFImageView.m
+ WebKit/WebView.subproj/IFTextRepresentation.h
+ WebKit/WebView.subproj/IFTextRepresentation.m
+ WebKit/WebView.subproj/IFTextView.h
+ WebKit/WebView.subproj/IFTextView.m
+
+ Removed Files:
+
+ WebKit/MIME.subproj/IFContentHandler.h
+ WebKit/MIME.subproj/IFContentHandler.m
+ WebKit/MIME.subproj/IFMIMEHandler.h
+ WebKit/MIME.subproj/IFMIMEHandler.m
+
+
2002-06-12 Kenneth Kocienda <kocienda at apple.com>
* Misc.subproj/WebKitDebug.h: Made assertion failure console message bolder and easier to see.
diff --git a/WebKit/MIME.subproj/IFContentHandler.h b/WebKit/MIME.subproj/IFContentHandler.h
deleted file mode 100644
index 78b434d..0000000
--- a/WebKit/MIME.subproj/IFContentHandler.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- IFContentHandler.h
- Copyright 2002, Apple, Inc. All rights reserved.
-*/
-
-#import <WebKit/IFMIMEHandler.h>
-
- at interface IFContentHandler : NSObject {
- IFMIMEHandlerType handlerType;
- NSString *MIMEType, *URLString;
-}
-
-- initWithURL:(NSURL *)URL MIMEType:(NSString *)theMIMEType MIMEHandlerType:(IFMIMEHandlerType)theMIMEHandlerType;
-- (NSString *) HTMLDocument;
-- (NSString *) textHTMLDocumentBottom;
-
- at end
diff --git a/WebKit/MIME.subproj/IFContentHandler.m b/WebKit/MIME.subproj/IFContentHandler.m
deleted file mode 100644
index e5439c9..0000000
--- a/WebKit/MIME.subproj/IFContentHandler.m
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- IFContentHandler.m
- Copyright 2002, Apple, Inc. All rights reserved.
-*/
-
-#import <WebKit/IFContentHandler.h>
-
-static NSString *imageDocumentTemplate = nil;
-static NSString *pluginDocumentTemplate = nil;
-static NSString *textDocumentTemplate = nil;
-
- at implementation IFContentHandler
-
-- initWithURL:(NSURL *)URL MIMEType:(NSString *)theMIMEType MIMEHandlerType:(IFMIMEHandlerType)theMIMEHandlerType;
-{
- [super init];
-
- handlerType = theMIMEHandlerType;
- MIMEType = [theMIMEType retain];
- URLString = [[URL absoluteString] retain];
-
- return self;
-}
-
-- (NSString *)useTemplate:(NSString *)templateName withGlobal:(NSString **)global
-{
- NSBundle *bundle;
- NSString *path;
- NSData *data;
-
- if (!*global) {
- bundle = [NSBundle bundleForClass:[IFContentHandler class]];
- path = [bundle pathForResource:templateName ofType:@"html"];
- if (path) {
- data = [[NSData alloc] initWithContentsOfFile:path];
- if (data) {
- *global = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
- [data release];
- }
- }
- }
- return [NSString stringWithFormat:*global, URLString, MIMEType];
-}
-
-- (NSString *) HTMLDocument
-{
- switch (handlerType) {
- case IFMIMEHANDLERTYPE_IMAGE:
- return [self useTemplate:@"image_document_template" withGlobal:&imageDocumentTemplate];
- case IFMIMEHANDLERTYPE_PLUGIN:
- return [self useTemplate:@"plugin_document_template" withGlobal:&pluginDocumentTemplate];
- case IFMIMEHANDLERTYPE_TEXT:
- return [self useTemplate:@"text_document_template" withGlobal:&textDocumentTemplate];
- default:
- return nil;
- }
-}
-
-- (NSString *) textHTMLDocumentBottom;
-{
- return @"</pre></body></html>";
-}
-
--(void)dealloc
-{
- [MIMEType release];
- [URLString release];
- [super dealloc];
-}
-
- at end
diff --git a/WebKit/MIME.subproj/IFMIMEHandler.h b/WebKit/MIME.subproj/IFMIMEHandler.h
deleted file mode 100644
index b7a2f95..0000000
--- a/WebKit/MIME.subproj/IFMIMEHandler.h
+++ /dev/null
@@ -1,28 +0,0 @@
-//
-// IFMIMEHandler.h
-// WebKit
-//
-// Created by Chris Blumenberg on Fri Mar 22 2002.
-// Copyright (c) 2002 Apple Computer Inc.. All rights reserved.
-//
-
-#import <Foundation/Foundation.h>
-
-// FIXME: This code should be replaced by the MIME type DB 2927855
-
-typedef enum {
- IFMIMEHANDLERTYPE_NIL = 0,
- IFMIMEHANDLERTYPE_HTML = 1, //WebKit handled html
- IFMIMEHANDLERTYPE_IMAGE = 2, //WebKit handled image
- IFMIMEHANDLERTYPE_TEXT = 3, //WebKit handled text
- IFMIMEHANDLERTYPE_PLUGIN = 4, //Plug-in handled file
- IFMIMEHANDLERTYPE_APPLICATION = 5, //Application handled file
-} IFMIMEHandlerType;
-
-
- at interface IFMIMEHandler: NSObject
-
-+ (IFMIMEHandlerType) MIMEHandlerTypeForMIMEType:(NSString *)MIMEType;
-+ (BOOL) canShowMIMEType:(NSString *)MIMEType;
-
- at end
diff --git a/WebKit/MIME.subproj/IFMIMEHandler.m b/WebKit/MIME.subproj/IFMIMEHandler.m
deleted file mode 100644
index 4faeba9..0000000
--- a/WebKit/MIME.subproj/IFMIMEHandler.m
+++ /dev/null
@@ -1,64 +0,0 @@
-//
-// IFMIMEHandler.m
-// WebKit
-//
-// Created by Chris Blumenberg on Fri Mar 22 2002.
-// Copyright (c) 2002 Apple Computer Inc.. All rights reserved.
-//
-
-#import <WebKit/IFMIMEHandler.h>
-#import <WebKit/WebKitDebug.h>
-#import <IFPluginDatabase.h>
-
-
-// FIXME: This code should be replaced by the MIME type DB 2927855
-
- at implementation IFMIMEHandler
-
-+ (IFMIMEHandlerType) MIMEHandlerTypeForMIMEType:(NSString *)MIMEType
-{
- NSArray *pluginTypes;
-
- if(!MIMEType){
- return IFMIMEHANDLERTYPE_NIL;
- }else if([MIMEType isEqualToString:@"text/html"]){
- return IFMIMEHANDLERTYPE_HTML;
- }else if([MIMEType hasPrefix:@"text/"] && ![MIMEType isEqualToString:@"text/rtf"]){
- return IFMIMEHANDLERTYPE_TEXT;
- }else if([MIMEType isEqualToString:@"image/jpg"] || [MIMEType isEqualToString:@"image/jpeg"] ||
- [MIMEType isEqualToString:@"image/gif"] || [MIMEType isEqualToString:@"image/png"]){
- return IFMIMEHANDLERTYPE_IMAGE;
- }else{
- pluginTypes = [[IFPluginDatabase installedPlugins] allHandledMIMETypes];
- if([pluginTypes containsObject:MIMEType]){
- return IFMIMEHANDLERTYPE_PLUGIN;
- }else{
- return IFMIMEHANDLERTYPE_APPLICATION;
- }
- }
-}
-
-+ (BOOL) canShowMIMEType:(NSString *)MIMEType
-{
- NSArray *pluginTypes;
-
- if(!MIMEType)
- return YES;
-
- if(([MIMEType hasPrefix:@"text/"] && ![MIMEType isEqualToString:@"text/rtf"]) ||
- [MIMEType isEqualToString:@"image/jpg"] ||
- [MIMEType isEqualToString:@"image/jpeg"] ||
- [MIMEType isEqualToString:@"image/gif"] ||
- [MIMEType isEqualToString:@"image/png"]){
- return YES;
- }else{
- pluginTypes = [[IFPluginDatabase installedPlugins] allHandledMIMETypes];
- if([pluginTypes containsObject:MIMEType]){
- return YES;
- }else{
- return NO;
- }
- }
-}
-
- at end
diff --git a/WebKit/Misc.subproj/IFNSViewExtras.h b/WebKit/Misc.subproj/IFNSViewExtras.h
new file mode 100644
index 0000000..0883ce4
--- /dev/null
+++ b/WebKit/Misc.subproj/IFNSViewExtras.h
@@ -0,0 +1,16 @@
+//
+// NSViewExtras.h
+// WebKit
+//
+// Created by Chris Blumenberg on Tue Jun 11 2002.
+// Copyright (c) 2002 __MyCompanyName__. All rights reserved.
+//
+
+#import <AppKit/AppKit.h>
+
+
+ at interface NSView (IFExtensions)
+
+- (NSView *) _IF_superviewWithName:(NSString *)viewName;
+
+ at end
diff --git a/WebKit/Misc.subproj/IFNSViewExtras.m b/WebKit/Misc.subproj/IFNSViewExtras.m
new file mode 100644
index 0000000..953becd
--- /dev/null
+++ b/WebKit/Misc.subproj/IFNSViewExtras.m
@@ -0,0 +1,28 @@
+//
+// NSViewExtras.m
+// WebKit
+//
+// Created by Chris Blumenberg on Tue Jun 11 2002.
+// Copyright (c) 2002 __MyCompanyName__. All rights reserved.
+//
+
+#import "IFNSViewExtras.h"
+
+
+ at implementation NSView (IFExtensions)
+
+- (NSView *) _IF_superviewWithName:(NSString *)viewName
+{
+ NSView *view;
+
+ view = self;
+ while(view){
+ view = [view superview];
+ if([[view className] isEqualToString:viewName]){
+ return view;
+ }
+ }
+ return nil;
+}
+
+ at end
diff --git a/WebKit/Misc.subproj/WebNSViewExtras.h b/WebKit/Misc.subproj/WebNSViewExtras.h
new file mode 100644
index 0000000..0883ce4
--- /dev/null
+++ b/WebKit/Misc.subproj/WebNSViewExtras.h
@@ -0,0 +1,16 @@
+//
+// NSViewExtras.h
+// WebKit
+//
+// Created by Chris Blumenberg on Tue Jun 11 2002.
+// Copyright (c) 2002 __MyCompanyName__. All rights reserved.
+//
+
+#import <AppKit/AppKit.h>
+
+
+ at interface NSView (IFExtensions)
+
+- (NSView *) _IF_superviewWithName:(NSString *)viewName;
+
+ at end
diff --git a/WebKit/Misc.subproj/WebNSViewExtras.m b/WebKit/Misc.subproj/WebNSViewExtras.m
new file mode 100644
index 0000000..953becd
--- /dev/null
+++ b/WebKit/Misc.subproj/WebNSViewExtras.m
@@ -0,0 +1,28 @@
+//
+// NSViewExtras.m
+// WebKit
+//
+// Created by Chris Blumenberg on Tue Jun 11 2002.
+// Copyright (c) 2002 __MyCompanyName__. All rights reserved.
+//
+
+#import "IFNSViewExtras.h"
+
+
+ at implementation NSView (IFExtensions)
+
+- (NSView *) _IF_superviewWithName:(NSString *)viewName
+{
+ NSView *view;
+
+ view = self;
+ while(view){
+ view = [view superview];
+ if([[view className] isEqualToString:viewName]){
+ return view;
+ }
+ }
+ return nil;
+}
+
+ at end
diff --git a/WebKit/Plugins.subproj/IFNullPluginView.mm b/WebKit/Plugins.subproj/IFNullPluginView.mm
index e4d81db..248e0fc 100644
--- a/WebKit/Plugins.subproj/IFNullPluginView.mm
+++ b/WebKit/Plugins.subproj/IFNullPluginView.mm
@@ -3,10 +3,12 @@
Copyright 2002, Apple, Inc. All rights reserved.
*/
-#import "IFNullPluginView.h"
-#import "WCPluginWidget.h"
-#import "IFWebView.h"
-#import "IFWebController.h"
+#import <WebKit/IFNullPluginView.h>
+#import <WebKit/IFWebView.h>
+#import <WebKit/IFWebController.h>
+#import <WebKit/IFNSViewExtras.h>
+
+#import <WCPluginWidget.h>
static BOOL imageLoaded = NO;
static NSImage *image = nil;
@@ -62,7 +64,7 @@ static NSImage *image = nil;
[super drawRect:rect];
if(!errorSent){
errorSent = YES;
- webView = [self findSuperview:@"IFWebView"];
+ webView = [self _IF_superviewWithName:@"IFWebView"];
webController = [webView controller];
[webController pluginNotFoundForMIMEType:mimeType pluginPageURL:pluginPage];
}
diff --git a/WebKit/Plugins.subproj/IFPluginDatabase.h b/WebKit/Plugins.subproj/IFPluginDatabase.h
index 3549837..dc3984d 100644
--- a/WebKit/Plugins.subproj/IFPluginDatabase.h
+++ b/WebKit/Plugins.subproj/IFPluginDatabase.h
@@ -33,11 +33,8 @@
+ (IFPluginDatabase *)installedPlugins;
- (IFPlugin *)pluginForMimeType:(NSString *)mimeType;
- (IFPlugin *)pluginForExtension:(NSString *)extension;
-- (IFPlugin *)pluginForFilename:(NSString *)filename;
-- (NSArray *) allHandledMIMETypes;
+- (IFPlugin *)pluginWithFilename:(NSString *)filename;
+- (NSArray *) MIMETypes;
- (NSArray *) plugins;
- at end
-
-NSArray *pluginLocations(void);
-NSArray *findPlugins(void);
\ No newline at end of file
+ at end
\ No newline at end of file
diff --git a/WebKit/Plugins.subproj/IFPluginDatabase.m b/WebKit/Plugins.subproj/IFPluginDatabase.m
index 33d8821..7cc421a 100644
--- a/WebKit/Plugins.subproj/IFPluginDatabase.m
+++ b/WebKit/Plugins.subproj/IFPluginDatabase.m
@@ -26,6 +26,10 @@
#import "IFPluginDatabase.h"
#import "WebKitDebug.h"
+
+NSArray *_pluginLocations(void);
+NSArray *_findPlugins(void);
+
@implementation IFPluginDatabase
static IFPluginDatabase *__IFPluginDatabase = nil;
@@ -34,7 +38,7 @@ static IFPluginDatabase *__IFPluginDatabase = nil;
{
if(!__IFPluginDatabase){
__IFPluginDatabase = [IFPluginDatabase alloc];
- __IFPluginDatabase->plugins = findPlugins();
+ __IFPluginDatabase->plugins = _findPlugins();
}
return __IFPluginDatabase;
}
@@ -78,7 +82,7 @@ static IFPluginDatabase *__IFPluginDatabase = nil;
return nil;
}
-- (IFPlugin *)pluginForFilename:(NSString *)filename
+- (IFPlugin *)pluginWithFilename:(NSString *)filename
{
uint i;
IFPlugin *plugin;
@@ -97,7 +101,7 @@ static IFPluginDatabase *__IFPluginDatabase = nil;
return plugins;
}
-- (NSArray *) allHandledMIMETypes
+- (NSArray *) MIMETypes
{
NSMutableArray *allHandledMIMETypes;
IFPlugin *plugin;
@@ -117,7 +121,7 @@ static IFPluginDatabase *__IFPluginDatabase = nil;
@end
-NSArray *pluginLocations(void)
+NSArray *_pluginLocations(void)
{
NSMutableArray *locations;
NSBundle *applicationBundle;
@@ -138,7 +142,7 @@ NSArray *pluginLocations(void)
return locations;
}
-NSArray *findPlugins(void)
+NSArray *_findPlugins(void)
{
NSFileManager *fileManager;
NSArray *pluginDirectories, *files;
@@ -147,7 +151,7 @@ NSArray *findPlugins(void)
IFPlugin *plugin;
uint i, n;
- pluginDirectories = pluginLocations();
+ pluginDirectories = _pluginLocations();
fileManager = [NSFileManager defaultManager];
pluginPaths = [NSMutableArray arrayWithCapacity:10];
filenames = [NSMutableArray arrayWithCapacity:10];
diff --git a/WebKit/Plugins.subproj/IFPluginView.mm b/WebKit/Plugins.subproj/IFPluginView.mm
index ae7fa71..08f383e 100644
--- a/WebKit/Plugins.subproj/IFPluginView.mm
+++ b/WebKit/Plugins.subproj/IFPluginView.mm
@@ -5,31 +5,26 @@
#define USE_CARBON 1
-// FIXME: clean up these includes
-
-#import "IFPluginView.h"
-
+#import <WebKit/IFPluginView.h>
#import <WebKit/IFWebController.h>
#import <WebKit/IFWebFrame.h>
#import <WebKit/IFWebFramePrivate.h>
+#import <WebKit/IFWebDataSource.h>
+#import <WebKit/IFWebView.h>
+#import <WebKit/IFPluginDatabase.h>
+#import <WebKit/IFPluginStream.h>
+#import <WebKit/IFPluginNullEventSender.h>
+#import <WebKit/IFNullPluginView.h>
+#import <WebKit/IFPlugin.h>
+#import <WebKit/IFNSViewExtras.h>
+#import <WebKit/WebKitDebug.h>
-#import <AppKit/NSWindow_Private.h>
-#import <Carbon/Carbon.h>
-
-#import <IFPluginDatabase.h>
-#import <IFPluginStream.h>
-#import <IFWebDataSource.h>
#import <WebFoundation/IFError.h>
-#import <WebKitDebug.h>
-
-#import <IFPlugin.h>
-#import <qwidget.h>
-#import <IFWebView.h>
-#import <IFPluginNullEventSender.h>
-#import "IFNullPluginView.h"
-
#import <WebFoundation/IFNSStringExtensions.h>
+#import <AppKit/NSWindow_Private.h>
+#import <Carbon/Carbon.h>
+
@implementation IFPluginView
#pragma mark EVENTS
@@ -397,21 +392,6 @@ static char *newCString(NSString *string)
WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_SetWindow: %d, port=0x%08lx\n", npErr, (int)nPort.port);
}
-
-- (NSView *) findSuperview:(NSString *)viewName
-{
- NSView *view;
-
- view = self;
- while(view){
- view = [view superview];
- if([[view className] isEqualToString:viewName]){
- return view;
- }
- }
- return nil;
-}
-
-(void)start
{
NPSavedData saved;
@@ -435,12 +415,18 @@ static char *newCString(NSString *string)
theWindow = [self window];
notificationCenter = [NSNotificationCenter defaultCenter];
- [notificationCenter addObserver:self selector:@selector(viewHasMoved:) name:@"NSViewBoundsDidChangeNotification" object:[self findSuperview:@"NSClipView"]];
- [notificationCenter addObserver:self selector:@selector(viewHasMoved:) name:@"NSWindowDidResizeNotification" object:theWindow];
- [notificationCenter addObserver:self selector:@selector(windowWillClose:) name:@"NSWindowWillCloseNotification" object:theWindow];
- [notificationCenter addObserver:self selector:@selector(windowBecameKey:) name:@"NSWindowDidBecomeKeyNotification" object:theWindow];
- [notificationCenter addObserver:self selector:@selector(windowResignedKey:) name:@"NSWindowDidResignKeyNotification" object:theWindow];
- [notificationCenter addObserver:self selector:@selector(defaultsHaveChanged:) name:@"NSUserDefaultsDidChangeNotification" object:nil];
+ [notificationCenter addObserver:self selector:@selector(viewHasMoved:)
+ name:@"NSViewBoundsDidChangeNotification" object:[self _IF_superviewWithName:@"NSClipView"]];
+ [notificationCenter addObserver:self selector:@selector(viewHasMoved:)
+ name:@"NSWindowDidResizeNotification" object:theWindow];
+ [notificationCenter addObserver:self selector:@selector(windowWillClose:)
+ name:@"NSWindowWillCloseNotification" object:theWindow];
+ [notificationCenter addObserver:self selector:@selector(windowBecameKey:)
+ name:@"NSWindowDidBecomeKeyNotification" object:theWindow];
+ [notificationCenter addObserver:self selector:@selector(windowResignedKey:)
+ name:@"NSWindowDidResignKeyNotification" object:theWindow];
+ [notificationCenter addObserver:self selector:@selector(defaultsHaveChanged:)
+ name:@"NSUserDefaultsDidChangeNotification" object:nil];
if ([theWindow isKeyWindow])
[self sendActivateEvent:YES];
@@ -457,7 +443,7 @@ static char *newCString(NSString *string)
[eventSender sendNullEvents];
trackingTag = [self addTrackingRect:[self bounds] owner:self userData:nil assumeInside:NO];
- id webView = [self findSuperview:@"IFWebView"];
+ id webView = [self _IF_superviewWithName:@"IFWebView"];
webController = [[webView controller] retain];
webFrame = [[webController frameForView:webView] retain];
webDataSource = [[webFrame dataSource] retain];
diff --git a/WebKit/Plugins.subproj/WebNullPluginView.m b/WebKit/Plugins.subproj/WebNullPluginView.m
index e4d81db..248e0fc 100644
--- a/WebKit/Plugins.subproj/WebNullPluginView.m
+++ b/WebKit/Plugins.subproj/WebNullPluginView.m
@@ -3,10 +3,12 @@
Copyright 2002, Apple, Inc. All rights reserved.
*/
-#import "IFNullPluginView.h"
-#import "WCPluginWidget.h"
-#import "IFWebView.h"
-#import "IFWebController.h"
+#import <WebKit/IFNullPluginView.h>
+#import <WebKit/IFWebView.h>
+#import <WebKit/IFWebController.h>
+#import <WebKit/IFNSViewExtras.h>
+
+#import <WCPluginWidget.h>
static BOOL imageLoaded = NO;
static NSImage *image = nil;
@@ -62,7 +64,7 @@ static NSImage *image = nil;
[super drawRect:rect];
if(!errorSent){
errorSent = YES;
- webView = [self findSuperview:@"IFWebView"];
+ webView = [self _IF_superviewWithName:@"IFWebView"];
webController = [webView controller];
[webController pluginNotFoundForMIMEType:mimeType pluginPageURL:pluginPage];
}
diff --git a/WebKit/Plugins.subproj/WebPluginDatabase.h b/WebKit/Plugins.subproj/WebPluginDatabase.h
index 3549837..dc3984d 100644
--- a/WebKit/Plugins.subproj/WebPluginDatabase.h
+++ b/WebKit/Plugins.subproj/WebPluginDatabase.h
@@ -33,11 +33,8 @@
+ (IFPluginDatabase *)installedPlugins;
- (IFPlugin *)pluginForMimeType:(NSString *)mimeType;
- (IFPlugin *)pluginForExtension:(NSString *)extension;
-- (IFPlugin *)pluginForFilename:(NSString *)filename;
-- (NSArray *) allHandledMIMETypes;
+- (IFPlugin *)pluginWithFilename:(NSString *)filename;
+- (NSArray *) MIMETypes;
- (NSArray *) plugins;
- at end
-
-NSArray *pluginLocations(void);
-NSArray *findPlugins(void);
\ No newline at end of file
+ at end
\ No newline at end of file
diff --git a/WebKit/Plugins.subproj/WebPluginDatabase.m b/WebKit/Plugins.subproj/WebPluginDatabase.m
index 33d8821..7cc421a 100644
--- a/WebKit/Plugins.subproj/WebPluginDatabase.m
+++ b/WebKit/Plugins.subproj/WebPluginDatabase.m
@@ -26,6 +26,10 @@
#import "IFPluginDatabase.h"
#import "WebKitDebug.h"
+
+NSArray *_pluginLocations(void);
+NSArray *_findPlugins(void);
+
@implementation IFPluginDatabase
static IFPluginDatabase *__IFPluginDatabase = nil;
@@ -34,7 +38,7 @@ static IFPluginDatabase *__IFPluginDatabase = nil;
{
if(!__IFPluginDatabase){
__IFPluginDatabase = [IFPluginDatabase alloc];
- __IFPluginDatabase->plugins = findPlugins();
+ __IFPluginDatabase->plugins = _findPlugins();
}
return __IFPluginDatabase;
}
@@ -78,7 +82,7 @@ static IFPluginDatabase *__IFPluginDatabase = nil;
return nil;
}
-- (IFPlugin *)pluginForFilename:(NSString *)filename
+- (IFPlugin *)pluginWithFilename:(NSString *)filename
{
uint i;
IFPlugin *plugin;
@@ -97,7 +101,7 @@ static IFPluginDatabase *__IFPluginDatabase = nil;
return plugins;
}
-- (NSArray *) allHandledMIMETypes
+- (NSArray *) MIMETypes
{
NSMutableArray *allHandledMIMETypes;
IFPlugin *plugin;
@@ -117,7 +121,7 @@ static IFPluginDatabase *__IFPluginDatabase = nil;
@end
-NSArray *pluginLocations(void)
+NSArray *_pluginLocations(void)
{
NSMutableArray *locations;
NSBundle *applicationBundle;
@@ -138,7 +142,7 @@ NSArray *pluginLocations(void)
return locations;
}
-NSArray *findPlugins(void)
+NSArray *_findPlugins(void)
{
NSFileManager *fileManager;
NSArray *pluginDirectories, *files;
@@ -147,7 +151,7 @@ NSArray *findPlugins(void)
IFPlugin *plugin;
uint i, n;
- pluginDirectories = pluginLocations();
+ pluginDirectories = _pluginLocations();
fileManager = [NSFileManager defaultManager];
pluginPaths = [NSMutableArray arrayWithCapacity:10];
filenames = [NSMutableArray arrayWithCapacity:10];
diff --git a/WebKit/Plugins.subproj/WebPluginView.m b/WebKit/Plugins.subproj/WebPluginView.m
index ae7fa71..08f383e 100644
--- a/WebKit/Plugins.subproj/WebPluginView.m
+++ b/WebKit/Plugins.subproj/WebPluginView.m
@@ -5,31 +5,26 @@
#define USE_CARBON 1
-// FIXME: clean up these includes
-
-#import "IFPluginView.h"
-
+#import <WebKit/IFPluginView.h>
#import <WebKit/IFWebController.h>
#import <WebKit/IFWebFrame.h>
#import <WebKit/IFWebFramePrivate.h>
+#import <WebKit/IFWebDataSource.h>
+#import <WebKit/IFWebView.h>
+#import <WebKit/IFPluginDatabase.h>
+#import <WebKit/IFPluginStream.h>
+#import <WebKit/IFPluginNullEventSender.h>
+#import <WebKit/IFNullPluginView.h>
+#import <WebKit/IFPlugin.h>
+#import <WebKit/IFNSViewExtras.h>
+#import <WebKit/WebKitDebug.h>
-#import <AppKit/NSWindow_Private.h>
-#import <Carbon/Carbon.h>
-
-#import <IFPluginDatabase.h>
-#import <IFPluginStream.h>
-#import <IFWebDataSource.h>
#import <WebFoundation/IFError.h>
-#import <WebKitDebug.h>
-
-#import <IFPlugin.h>
-#import <qwidget.h>
-#import <IFWebView.h>
-#import <IFPluginNullEventSender.h>
-#import "IFNullPluginView.h"
-
#import <WebFoundation/IFNSStringExtensions.h>
+#import <AppKit/NSWindow_Private.h>
+#import <Carbon/Carbon.h>
+
@implementation IFPluginView
#pragma mark EVENTS
@@ -397,21 +392,6 @@ static char *newCString(NSString *string)
WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_SetWindow: %d, port=0x%08lx\n", npErr, (int)nPort.port);
}
-
-- (NSView *) findSuperview:(NSString *)viewName
-{
- NSView *view;
-
- view = self;
- while(view){
- view = [view superview];
- if([[view className] isEqualToString:viewName]){
- return view;
- }
- }
- return nil;
-}
-
-(void)start
{
NPSavedData saved;
@@ -435,12 +415,18 @@ static char *newCString(NSString *string)
theWindow = [self window];
notificationCenter = [NSNotificationCenter defaultCenter];
- [notificationCenter addObserver:self selector:@selector(viewHasMoved:) name:@"NSViewBoundsDidChangeNotification" object:[self findSuperview:@"NSClipView"]];
- [notificationCenter addObserver:self selector:@selector(viewHasMoved:) name:@"NSWindowDidResizeNotification" object:theWindow];
- [notificationCenter addObserver:self selector:@selector(windowWillClose:) name:@"NSWindowWillCloseNotification" object:theWindow];
- [notificationCenter addObserver:self selector:@selector(windowBecameKey:) name:@"NSWindowDidBecomeKeyNotification" object:theWindow];
- [notificationCenter addObserver:self selector:@selector(windowResignedKey:) name:@"NSWindowDidResignKeyNotification" object:theWindow];
- [notificationCenter addObserver:self selector:@selector(defaultsHaveChanged:) name:@"NSUserDefaultsDidChangeNotification" object:nil];
+ [notificationCenter addObserver:self selector:@selector(viewHasMoved:)
+ name:@"NSViewBoundsDidChangeNotification" object:[self _IF_superviewWithName:@"NSClipView"]];
+ [notificationCenter addObserver:self selector:@selector(viewHasMoved:)
+ name:@"NSWindowDidResizeNotification" object:theWindow];
+ [notificationCenter addObserver:self selector:@selector(windowWillClose:)
+ name:@"NSWindowWillCloseNotification" object:theWindow];
+ [notificationCenter addObserver:self selector:@selector(windowBecameKey:)
+ name:@"NSWindowDidBecomeKeyNotification" object:theWindow];
+ [notificationCenter addObserver:self selector:@selector(windowResignedKey:)
+ name:@"NSWindowDidResignKeyNotification" object:theWindow];
+ [notificationCenter addObserver:self selector:@selector(defaultsHaveChanged:)
+ name:@"NSUserDefaultsDidChangeNotification" object:nil];
if ([theWindow isKeyWindow])
[self sendActivateEvent:YES];
@@ -457,7 +443,7 @@ static char *newCString(NSString *string)
[eventSender sendNullEvents];
trackingTag = [self addTrackingRect:[self bounds] owner:self userData:nil assumeInside:NO];
- id webView = [self findSuperview:@"IFWebView"];
+ id webView = [self _IF_superviewWithName:@"IFWebView"];
webController = [[webView controller] retain];
webFrame = [[webController frameForView:webView] retain];
webDataSource = [[webFrame dataSource] retain];
diff --git a/WebKit/WebCoreSupport.subproj/IFImageRenderer.h b/WebKit/WebCoreSupport.subproj/IFImageRenderer.h
index c5c26b0..8f7d73c 100644
--- a/WebKit/WebCoreSupport.subproj/IFImageRenderer.h
+++ b/WebKit/WebCoreSupport.subproj/IFImageRenderer.h
@@ -15,4 +15,7 @@
unsigned lastLength;
BOOL lastReturn;
}
+- (BOOL)incrementalLoadWithBytes: (const void *)bytes length:(unsigned)length complete:(BOOL)isComplete;
+- (void)beginAnimationInView: (NSView *)view inRect: (NSRect)ir fromRect: (NSRect)fr;
+- (void)stopAnimation;
@end
diff --git a/WebKit/WebCoreSupport.subproj/IFWebCoreViewFactory.m b/WebKit/WebCoreSupport.subproj/IFWebCoreViewFactory.m
index c8a3fe9..c5ff6c8 100644
--- a/WebKit/WebCoreSupport.subproj/IFWebCoreViewFactory.m
+++ b/WebKit/WebCoreSupport.subproj/IFWebCoreViewFactory.m
@@ -70,7 +70,7 @@
IFPlugin *plugin;
NSMutableDictionary *argsCopy;
- plugin = [[IFPluginDatabase installedPlugins] pluginForFilename:@"Java.plugin"];
+ plugin = [[IFPluginDatabase installedPlugins] pluginWithFilename:@"Java.plugin"];
if (plugin == nil) {
return nil;
}
diff --git a/WebKit/WebCoreSupport.subproj/WebImageRenderer.h b/WebKit/WebCoreSupport.subproj/WebImageRenderer.h
index c5c26b0..8f7d73c 100644
--- a/WebKit/WebCoreSupport.subproj/WebImageRenderer.h
+++ b/WebKit/WebCoreSupport.subproj/WebImageRenderer.h
@@ -15,4 +15,7 @@
unsigned lastLength;
BOOL lastReturn;
}
+- (BOOL)incrementalLoadWithBytes: (const void *)bytes length:(unsigned)length complete:(BOOL)isComplete;
+- (void)beginAnimationInView: (NSView *)view inRect: (NSRect)ir fromRect: (NSRect)fr;
+- (void)stopAnimation;
@end
diff --git a/WebKit/WebCoreSupport.subproj/WebViewFactory.m b/WebKit/WebCoreSupport.subproj/WebViewFactory.m
index c8a3fe9..c5ff6c8 100644
--- a/WebKit/WebCoreSupport.subproj/WebViewFactory.m
+++ b/WebKit/WebCoreSupport.subproj/WebViewFactory.m
@@ -70,7 +70,7 @@
IFPlugin *plugin;
NSMutableDictionary *argsCopy;
- plugin = [[IFPluginDatabase installedPlugins] pluginForFilename:@"Java.plugin"];
+ plugin = [[IFPluginDatabase installedPlugins] pluginWithFilename:@"Java.plugin"];
if (plugin == nil) {
return nil;
}
diff --git a/WebKit/WebKit.pbproj/project.pbxproj b/WebKit/WebKit.pbproj/project.pbxproj
index 1359b13..9b7c287 100644
--- a/WebKit/WebKit.pbproj/project.pbxproj
+++ b/WebKit/WebKit.pbproj/project.pbxproj
@@ -93,7 +93,6 @@
9C7CABBB0190A37C0ECA16EA,
25A8176801B5474B0ECA149E,
F5065217027F555001C1A526,
- F5F084B8024BBFFE01CA1520,
F5B36B400281DE87018635CB,
F5EBC45202134BB601CA1520,
254DC334016E1D3F0ECA149E,
@@ -213,14 +212,12 @@
9CF0E24B021361B10ECA16EA,
F5B92B840223191D01C1A525,
F5D538EA02441F2601A80181,
- F5F084BB024BDC8E01CA1520,
F58BAB3B025036CA01C1A526,
9CAE9D080252A4130ECA16EA,
F59EAE400253C7EE018635CA,
F5883BE2025E5E9D01000102,
F5A672BB0263866E01000102,
F5A672BD0263866E01000102,
- F5A357540265E57A01000102,
F544394F02674FD501FF6181,
F567433F026B5B7B01A80181,
F5065221027F557E01C1A526,
@@ -246,6 +243,15 @@
F59668CA02AD2923018635CA,
F5F81C3702B67C0F018635CA,
F5F81C3B02B67C26018635CA,
+ 35081D9C02B6D4D80ACA2ACA,
+ 35081D9E02B6D4D80ACA2ACA,
+ 35081DA002B6D4D80ACA2ACA,
+ 35081DA202B6D4D80ACA2ACA,
+ 35081DA402B6D4D80ACA2ACA,
+ 35081DAA02B6D4E40ACA2ACA,
+ 35081DAC02B6D4E40ACA2ACA,
+ 35081DAF02B6D4F50ACA2ACA,
+ F508946B02B71D59018A9CD4,
);
isa = PBXHeadersBuildPhase;
};
@@ -287,13 +293,11 @@
F5B92B850223191D01C1A525,
F5D538ED02441FDD01A80181,
F5AEBB3E024A527601C1A526,
- F5F084BC024BDC8E01CA1520,
F58BAB390250363E01C1A526,
F59EAE420253C8DE018635CA,
F5883BE3025E5E9D01000102,
F5A672BC0263866E01000102,
F5A672BE0263866E01000102,
- F5A357530265E57A01000102,
F544395002674FD501FF6181,
F5065223027F557E01C1A526,
F5065225027F557E01C1A526,
@@ -314,6 +318,14 @@
F59668CB02AD2923018635CA,
F5F81C3802B67C0F018635CA,
F5F81C3C02B67C26018635CA,
+ 35081D9D02B6D4D80ACA2ACA,
+ 35081D9F02B6D4D80ACA2ACA,
+ 35081DA102B6D4D80ACA2ACA,
+ 35081DA302B6D4D80ACA2ACA,
+ 35081DA502B6D4D80ACA2ACA,
+ 35081DAB02B6D4E40ACA2ACA,
+ 35081DAD02B6D4E40ACA2ACA,
+ F508946C02B71D59018A9CD4,
);
isa = PBXSourcesBuildPhase;
};
@@ -390,8 +402,12 @@
//254
254DC334016E1D3F0ECA149E = {
children = (
+ F544394D02674FD501FF6181,
+ F544394E02674FD501FF6181,
3944607A020F50ED0ECA1767,
3944607B020F50ED0ECA1767,
+ F508946902B71D59018A9CD4,
+ F508946A02B71D59018A9CD4,
2568C72C0174912D0ECA149E,
25C29825016E29620ECA149E,
F5C283730284676D018635CA,
@@ -512,6 +528,189 @@
//352
//353
//354
+ 35081D9202B6D4D80ACA2ACA = {
+ isa = PBXFileReference;
+ name = IFHTMLRepresentation.h;
+ path = WebView.subproj/IFHTMLRepresentation.h;
+ refType = 4;
+ };
+ 35081D9302B6D4D80ACA2ACA = {
+ isa = PBXFileReference;
+ name = IFHTMLRepresentation.mm;
+ path = WebView.subproj/IFHTMLRepresentation.mm;
+ refType = 4;
+ };
+ 35081D9402B6D4D80ACA2ACA = {
+ isa = PBXFileReference;
+ name = IFHTMLView.h;
+ path = WebView.subproj/IFHTMLView.h;
+ refType = 4;
+ };
+ 35081D9502B6D4D80ACA2ACA = {
+ isa = PBXFileReference;
+ name = IFHTMLView.mm;
+ path = WebView.subproj/IFHTMLView.mm;
+ refType = 4;
+ };
+ 35081D9602B6D4D80ACA2ACA = {
+ isa = PBXFileReference;
+ name = IFHTMLViewPrivate.h;
+ path = WebView.subproj/IFHTMLViewPrivate.h;
+ refType = 4;
+ };
+ 35081D9702B6D4D80ACA2ACA = {
+ isa = PBXFileReference;
+ name = IFHTMLViewPrivate.mm;
+ path = WebView.subproj/IFHTMLViewPrivate.mm;
+ refType = 4;
+ };
+ 35081D9802B6D4D80ACA2ACA = {
+ isa = PBXFileReference;
+ name = IFImageRepresentation.h;
+ path = WebView.subproj/IFImageRepresentation.h;
+ refType = 4;
+ };
+ 35081D9902B6D4D80ACA2ACA = {
+ isa = PBXFileReference;
+ name = IFImageRepresentation.m;
+ path = WebView.subproj/IFImageRepresentation.m;
+ refType = 4;
+ };
+ 35081D9A02B6D4D80ACA2ACA = {
+ isa = PBXFileReference;
+ name = IFImageView.h;
+ path = WebView.subproj/IFImageView.h;
+ refType = 4;
+ };
+ 35081D9B02B6D4D80ACA2ACA = {
+ isa = PBXFileReference;
+ name = IFImageView.m;
+ path = WebView.subproj/IFImageView.m;
+ refType = 4;
+ };
+ 35081D9C02B6D4D80ACA2ACA = {
+ fileRef = 35081D9202B6D4D80ACA2ACA;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ 35081D9D02B6D4D80ACA2ACA = {
+ fileRef = 35081D9302B6D4D80ACA2ACA;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ 35081D9E02B6D4D80ACA2ACA = {
+ fileRef = 35081D9402B6D4D80ACA2ACA;
+ isa = PBXBuildFile;
+ settings = {
+ ATTRIBUTES = (
+ Private,
+ );
+ };
+ };
+ 35081D9F02B6D4D80ACA2ACA = {
+ fileRef = 35081D9502B6D4D80ACA2ACA;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ 35081DA002B6D4D80ACA2ACA = {
+ fileRef = 35081D9602B6D4D80ACA2ACA;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ 35081DA102B6D4D80ACA2ACA = {
+ fileRef = 35081D9702B6D4D80ACA2ACA;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ 35081DA202B6D4D80ACA2ACA = {
+ fileRef = 35081D9802B6D4D80ACA2ACA;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ 35081DA302B6D4D80ACA2ACA = {
+ fileRef = 35081D9902B6D4D80ACA2ACA;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ 35081DA402B6D4D80ACA2ACA = {
+ fileRef = 35081D9A02B6D4D80ACA2ACA;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ 35081DA502B6D4D80ACA2ACA = {
+ fileRef = 35081D9B02B6D4D80ACA2ACA;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ 35081DA602B6D4E40ACA2ACA = {
+ isa = PBXFileReference;
+ name = IFTextRepresentation.h;
+ path = WebView.subproj/IFTextRepresentation.h;
+ refType = 4;
+ };
+ 35081DA702B6D4E40ACA2ACA = {
+ isa = PBXFileReference;
+ name = IFTextRepresentation.m;
+ path = WebView.subproj/IFTextRepresentation.m;
+ refType = 4;
+ };
+ 35081DA802B6D4E40ACA2ACA = {
+ isa = PBXFileReference;
+ name = IFTextView.h;
+ path = WebView.subproj/IFTextView.h;
+ refType = 4;
+ };
+ 35081DA902B6D4E40ACA2ACA = {
+ isa = PBXFileReference;
+ name = IFTextView.m;
+ path = WebView.subproj/IFTextView.m;
+ refType = 4;
+ };
+ 35081DAA02B6D4E40ACA2ACA = {
+ fileRef = 35081DA602B6D4E40ACA2ACA;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ 35081DAB02B6D4E40ACA2ACA = {
+ fileRef = 35081DA702B6D4E40ACA2ACA;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ 35081DAC02B6D4E40ACA2ACA = {
+ fileRef = 35081DA802B6D4E40ACA2ACA;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ 35081DAD02B6D4E40ACA2ACA = {
+ fileRef = 35081DA902B6D4E40ACA2ACA;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ 35081DAE02B6D4F50ACA2ACA = {
+ isa = PBXFileReference;
+ name = IFDocument.h;
+ path = WebView.subproj/IFDocument.h;
+ refType = 4;
+ };
+ 35081DAF02B6D4F50ACA2ACA = {
+ fileRef = 35081DAE02B6D4F50ACA2ACA;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
354B0A1A0198BD810ACA1520 = {
isa = PBXFileReference;
name = French;
@@ -966,13 +1165,36 @@
//9C4
9C7CABBB0190A37C0ECA16EA = {
children = (
+ 35081DAE02B6D4F50ACA2ACA,
+ F5F81C3502B67C0F018635CA,
+ F5F81C3602B67C0F018635CA,
3944606B020F50ED0ECA1767,
3944606C020F50ED0ECA1767,
3944606D020F50ED0ECA1767,
+ 35081D9202B6D4D80ACA2ACA,
+ 35081D9302B6D4D80ACA2ACA,
+ 35081D9402B6D4D80ACA2ACA,
+ 35081D9502B6D4D80ACA2ACA,
+ 35081D9602B6D4D80ACA2ACA,
+ 35081D9702B6D4D80ACA2ACA,
+ 35081D9802B6D4D80ACA2ACA,
+ 35081D9902B6D4D80ACA2ACA,
+ 35081D9A02B6D4D80ACA2ACA,
+ 35081D9B02B6D4D80ACA2ACA,
F58BAB3A025036CA01C1A526,
F58BAB380250363E01C1A526,
+ F567433E026B5B7B01A80181,
+ F5D538E802441F2601A80181,
+ F5D538EC02441FDD01A80181,
3944606E020F50ED0ECA1767,
F5AEBB3D024A527601C1A526,
+ 9CAE9D070252A4130ECA16EA,
+ F5F81C3902B67C26018635CA,
+ F5F81C3A02B67C26018635CA,
+ 35081DA602B6D4E40ACA2ACA,
+ 35081DA702B6D4E40ACA2ACA,
+ 35081DA802B6D4E40ACA2ACA,
+ 35081DA902B6D4E40ACA2ACA,
3944606F020F50ED0ECA1767,
39446064020F50ED0ECA1767,
39446065020F50ED0ECA1767,
@@ -989,14 +1211,6 @@
F5143A370221DCCE01A80181,
9CF0E249021361B00ECA16EA,
9CF0E24A021361B00ECA16EA,
- F5D538E802441F2601A80181,
- F5D538EC02441FDD01A80181,
- 9CAE9D070252A4130ECA16EA,
- F567433E026B5B7B01A80181,
- F5F81C3502B67C0F018635CA,
- F5F81C3602B67C0F018635CA,
- F5F81C3902B67C26018635CA,
- F5F81C3A02B67C26018635CA,
);
isa = PBXGroup;
name = WebView;
@@ -1233,6 +1447,30 @@
settings = {
};
};
+ F508946902B71D59018A9CD4 = {
+ isa = PBXFileReference;
+ name = IFNSViewExtras.h;
+ path = Misc.subproj/IFNSViewExtras.h;
+ refType = 4;
+ };
+ F508946A02B71D59018A9CD4 = {
+ isa = PBXFileReference;
+ name = IFNSViewExtras.m;
+ path = Misc.subproj/IFNSViewExtras.m;
+ refType = 4;
+ };
+ F508946B02B71D59018A9CD4 = {
+ fileRef = F508946902B71D59018A9CD4;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ F508946C02B71D59018A9CD4 = {
+ fileRef = F508946A02B71D59018A9CD4;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
F50AD3870282028B01C1A526 = {
isa = PBXFileReference;
name = IFBookmarkGroup_Private.h;
@@ -1467,30 +1705,6 @@
settings = {
};
};
- F5A357510265E57A01000102 = {
- isa = PBXFileReference;
- name = IFContentHandler.m;
- path = MIME.subproj/IFContentHandler.m;
- refType = 4;
- };
- F5A357520265E57A01000102 = {
- isa = PBXFileReference;
- name = IFContentHandler.h;
- path = MIME.subproj/IFContentHandler.h;
- refType = 4;
- };
- F5A357530265E57A01000102 = {
- fileRef = F5A357510265E57A01000102;
- isa = PBXBuildFile;
- settings = {
- };
- };
- F5A357540265E57A01000102 = {
- fileRef = F5A357520265E57A01000102;
- isa = PBXBuildFile;
- settings = {
- };
- };
F5A672B70263866E01000102 = {
isa = PBXFileReference;
name = IFPluginNullEventSender.h;
@@ -1810,47 +2024,6 @@
settings = {
};
};
- F5F084B8024BBFFE01CA1520 = {
- children = (
- F5F084B9024BDC8E01CA1520,
- F5F084BA024BDC8E01CA1520,
- F5A357510265E57A01000102,
- F5A357520265E57A01000102,
- F544394D02674FD501FF6181,
- F544394E02674FD501FF6181,
- );
- isa = PBXGroup;
- name = MIME;
- path = "";
- refType = 2;
- };
- F5F084B9024BDC8E01CA1520 = {
- isa = PBXFileReference;
- name = IFMIMEHandler.h;
- path = MIME.subproj/IFMIMEHandler.h;
- refType = 4;
- };
- F5F084BA024BDC8E01CA1520 = {
- isa = PBXFileReference;
- name = IFMIMEHandler.m;
- path = MIME.subproj/IFMIMEHandler.m;
- refType = 4;
- };
- F5F084BB024BDC8E01CA1520 = {
- fileRef = F5F084B9024BDC8E01CA1520;
- isa = PBXBuildFile;
- settings = {
- ATTRIBUTES = (
- Public,
- );
- };
- };
- F5F084BC024BDC8E01CA1520 = {
- fileRef = F5F084BA024BDC8E01CA1520;
- isa = PBXBuildFile;
- settings = {
- };
- };
F5F7171E0288493C018635CA = {
isa = PBXFileReference;
name = IFPlugin.h;
diff --git a/WebKit/WebView.subproj/IFDOMNode.mm b/WebKit/WebView.subproj/IFDOMNode.mm
index 5ca1c90..23ca798 100644
--- a/WebKit/WebView.subproj/IFDOMNode.mm
+++ b/WebKit/WebView.subproj/IFDOMNode.mm
@@ -8,7 +8,8 @@
#import "IFDOMNode.h"
-#import <WebKit/IFWebViewPrivate.h>
+#import <WebKit/IFWebView.h>
+#import <WebKit/IFHTMLViewPrivate.h>
#import <khtmlview.h>
#import <khtml_part.h>
#import <xml/dom_docimpl.h>
@@ -37,7 +38,7 @@
- initWithWebView:(IFWebView *)view
{
- return [self initWithDOMNode:[view _widget]->part()->xmlDocImpl()];
+ return [self initWithDOMNode:[[view documentView] _widget]->part()->xmlDocImpl()];
}
- (void)dealloc
diff --git a/WebKit/WebView.subproj/IFDocument.h b/WebKit/WebView.subproj/IFDocument.h
new file mode 100644
index 0000000..bca5c9e
--- /dev/null
+++ b/WebKit/WebView.subproj/IFDocument.h
@@ -0,0 +1,32 @@
+/*
+ IFDocument.h
+ Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#include <Cocoa/Cocoa.h>
+
+ at class IFWebDataSource;
+ at class IFError;
+
+ at protocol IFDocumentLoading
+- (void)provisionalDataSourceChanged:(IFWebDataSource *)dataSource;
+- (void)provisionalDataSourceCommitted:(IFWebDataSource *)dataSource;
+- (void)dataSourceUpdated:(IFWebDataSource *)dataSource;
+- (void)layout;
+ at end
+
+ at protocol IFDocumentDragSettings
+- (void)setCanDragFrom: (BOOL)flag;
+- (BOOL)canDragFrom;
+- (void)setCanDragTo: (BOOL)flag;
+- (BOOL)canDragTo;
+ at end
+
+ at protocol IFDocumentSearching
+- (void)searchFor: (NSString *)string direction: (BOOL)forward caseSensitive: (BOOL)caseFlag;
+ at end
+
+ at protocol IFDocumentRepresentation
+- (void)receivedData:(NSData *)data withDataSource:(IFWebDataSource *)dataSource isComplete:(BOOL)isComplete;
+- (void)receivedError:(IFError *)error withDataSource:(IFWebDataSource *)dataSource;
+ at end
\ No newline at end of file
diff --git a/WebKit/WebView.subproj/IFDynamicScrollBarsView.m b/WebKit/WebView.subproj/IFDynamicScrollBarsView.m
index 26c8b57..d5276c7 100644
--- a/WebKit/WebView.subproj/IFDynamicScrollBarsView.m
+++ b/WebKit/WebView.subproj/IFDynamicScrollBarsView.m
@@ -7,9 +7,6 @@
//
#import <WebKit/IFDynamicScrollBarsView.h>
-
-#import <WebKit/IFWebView.h>
-
#import <WebKit/WebKitDebug.h>
@implementation IFDynamicScrollBarsView
diff --git a/WebKit/WebView.subproj/IFHTMLRepresentation.h b/WebKit/WebView.subproj/IFHTMLRepresentation.h
new file mode 100644
index 0000000..8a1981f
--- /dev/null
+++ b/WebKit/WebView.subproj/IFHTMLRepresentation.h
@@ -0,0 +1,26 @@
+/*
+ IFHTMLRepresentation.h
+ Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#import <Foundation/Foundation.h>
+
+
+ at class IFError;
+ at class IFWebDataSource;
+
+class KHTMLPart;
+
+ at protocol IFDocumentRepresentation;
+
+ at interface IFHTMLRepresentation : NSObject <IFDocumentRepresentation>
+{
+ KHTMLPart *part;
+ BOOL isFirstChunk;
+}
+
+- (KHTMLPart *)part;
+- (void)receivedData:(NSData *)data withDataSource:(IFWebDataSource *)dataSource isComplete:(BOOL)isComplete;
+- (void)receivedError:(IFError *)error withDataSource:(IFWebDataSource *)dataSource;
+
+ at end
diff --git a/WebKit/WebView.subproj/IFHTMLRepresentation.mm b/WebKit/WebView.subproj/IFHTMLRepresentation.mm
new file mode 100644
index 0000000..2ce5385
--- /dev/null
+++ b/WebKit/WebView.subproj/IFHTMLRepresentation.mm
@@ -0,0 +1,49 @@
+/*
+ IFHTMLRepresentation.mm
+ Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#import <WebKit/IFHTMLRepresentation.h>
+#import <WebKit/IFWebDataSource.h>
+#import <KWQKHTMLPartImpl.h>
+
+ at implementation IFHTMLRepresentation
+
+- init
+{
+ part = new KHTMLPart();
+ isFirstChunk = YES;
+
+ return self;
+}
+
+- (void)dealloc
+{
+ part->deref();
+}
+
+- (KHTMLPart *)part
+{
+ return part;
+}
+
+- (void)receivedData:(NSData *)data withDataSource:(IFWebDataSource *)dataSource isComplete:(BOOL)isComplete
+{
+ if(isFirstChunk){
+ // FIXME [rjw]: Do any work need in the kde engine. This should be removed.
+ // We should move any code needed out of KWQ.
+ part->openURL([[[dataSource inputURL] absoluteString] cString]);
+ part->impl->setDataSource(dataSource);
+ }
+
+ part->impl->slotData([dataSource encoding], (const char *)[data bytes], [data length], isComplete);
+
+ isFirstChunk = NO;
+}
+
+- (void)receivedError:(IFError *)error withDataSource:(IFWebDataSource *)dataSource
+{
+
+}
+
+ at end
diff --git a/WebKit/WebView.subproj/WebFrameView.h b/WebKit/WebView.subproj/IFHTMLView.h
similarity index 79%
copy from WebKit/WebView.subproj/WebFrameView.h
copy to WebKit/WebView.subproj/IFHTMLView.h
index 933968c..ddf0dc5 100644
--- a/WebKit/WebView.subproj/WebFrameView.h
+++ b/WebKit/WebView.subproj/IFHTMLView.h
@@ -1,8 +1,8 @@
/*
- IFWebView.h
- Copyright 2001, Apple, Inc. All rights reserved.
+ IFHTMLView.h
+ Copyright 2002, Apple, Inc. All rights reserved.
- Public header file.
+ Private header file.
*/
#import <Cocoa/Cocoa.h>
@@ -13,24 +13,24 @@
@class IFWebDataSource;
@class IFWebController;
+ at class IFHTMLViewPrivate;
+ at protocol IFDocumentLoading;
+ at protocol IFDocumentDragSettings;
+ at protocol IFDocumentSearching;
- at class IFWebViewPrivate;
-
- at interface IFWebView : NSView
+ at interface IFHTMLView : NSView <IFDocumentLoading, IFDocumentDragSettings, IFDocumentSearching>
{
@private
- IFWebViewPrivate *_private;
+ IFHTMLViewPrivate *_private;
}
- initWithFrame: (NSRect)frame;
-// Note that the controller is not retained.
-- (IFWebController *)controller;
-
// These methods is typically called by the view's controller when
// the data source is changed.
-- (void)dataSourceChanged: (IFWebDataSource *)dataSource;
-- (void)provisionalDataSourceChanged: (IFWebDataSource *)dataSource;
+- (void)provisionalDataSourceChanged:(IFWebDataSource *)dataSource;
+- (void)provisionalDataSourceCommitted:(IFWebDataSource *)dataSource;
+- (void)dataSourceUpdated:(IFWebDataSource *)dataSource;
- (void)setNeedsLayout: (bool)flag;
diff --git a/WebKit/WebView.subproj/IFWebView.mm b/WebKit/WebView.subproj/IFHTMLView.mm
similarity index 93%
copy from WebKit/WebView.subproj/IFWebView.mm
copy to WebKit/WebView.subproj/IFHTMLView.mm
index a2b43d7..52b8b29 100644
--- a/WebKit/WebView.subproj/IFWebView.mm
+++ b/WebKit/WebView.subproj/IFHTMLView.mm
@@ -1,6 +1,9 @@
-/* IFWebView.mm
- Copyright 2001, Apple, Inc. All rights reserved.
+/* IFHTMLView.mm
+ Copyright 2002, Apple, Inc. All rights reserved.
*/
+
+#import <WebKit/IFHTMLView.h>
+#import <WebKit/IFHTMLViewPrivate.h>
#import <WebKit/IFWebView.h>
#import <WebKit/IFWebViewPrivate.h>
#import <WebKit/IFWebFrame.h>
@@ -13,6 +16,8 @@
#import <WebKit/IFTextRendererFactory.h>
#import <WebKit/IFImageRendererFactory.h>
#import <WebKit/WebKitDebug.h>
+#import <WebKit/IFHTMLRepresentation.h>
+#import <WebKit/IFNSViewExtras.h>
#import <WebFoundation/IFNSStringExtensions.h>
@@ -28,7 +33,7 @@
#import <KWQKHTMLPartImpl.h>
- at implementation IFWebView
+ at implementation IFHTMLView
- initWithFrame: (NSRect) frame
{
@@ -38,7 +43,7 @@
[IFTextRendererFactory createSharedFactory];
[IFImageRendererFactory createSharedFactory];
- _private = [[IFWebViewPrivate alloc] init];
+ _private = [[IFHTMLViewPrivate alloc] init];
_private->isFlipped = YES;
_private->needsLayout = YES;
@@ -50,7 +55,7 @@
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(windowResized:) name: NSWindowDidResizeNotification object: nil];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(mouseMovedNotification:) name: NSMouseMovedNotification object: nil];
-
+
return self;
}
@@ -70,13 +75,6 @@
}
-// Note that the controller is not retained.
-- (IFWebController *)controller
-{
- return _private->controller;
-}
-
-
- (void)removeFromSuperview
{
[self _stopPlugins];
@@ -90,37 +88,49 @@
[super removeFromSuperviewWithoutNeedingDisplay];
}
-
// This method is typically called by the view's controller when
// the data source is changed.
- (void)provisionalDataSourceChanged: (IFWebDataSource *)dataSource
{
NSRect r = [self frame];
- IFWebView *provisionalView;
+ IFHTMLView *provisionalView;
// Nasty! Setup the cross references between the KHTMLView and
// the KHTMLPart.
- KHTMLPart *part = [dataSource _part];
+ KHTMLPart *part = [[dataSource representation] part];
_private->provisionalWidget = new KHTMLView (part, 0);
part->impl->setView (_private->provisionalWidget);
// Create a temporary provisional view. It will be replaced with
// the actual view once the datasource has been committed.
- provisionalView = [[IFWebView alloc] initWithFrame: NSMakeRect (0,0,0,0)];
+ provisionalView = [[IFHTMLView alloc] initWithFrame: NSMakeRect (0,0,0,0)];
+
+ // PROBLEM!! This provisionalView may become the actual view in the case
+ // of a sub frame. We need to create an IFWebView/IFDSV here.
_private->provisionalWidget->setView (provisionalView);
+
[provisionalView release];
+ int mw = [[[dataSource webFrame] view] _marginWidth];
+ if (mw >= 0)
+ _private->provisionalWidget->setMarginWidth (mw);
+ int mh = [[[dataSource webFrame] view] _marginHeight];
+ if (mh >= 0)
+ _private->provisionalWidget->setMarginHeight (mh);
+
_private->provisionalWidget->resize ((int)r.size.width, (int)r.size.height);
+
}
-- (void)dataSourceChanged: (IFWebDataSource *)dataSource
+- (void)provisionalDataSourceCommitted: (IFWebDataSource *)dataSource
{
- IFWebViewPrivate *data = _private;
-
+ IFHTMLViewPrivate *data = _private;
+ IFWebView *webView = (IFWebView *)[self _IF_superviewWithName:@"IFWebView"];
+
// Setup the real view.
- if ([self _frameScrollView])
- data->provisionalWidget->setView ([self _frameScrollView]);
+ if ([webView _frameScrollView])
+ data->provisionalWidget->setView ([webView _frameScrollView]);
else
data->provisionalWidget->setView (self);
@@ -134,6 +144,11 @@
data->provisionalWidget = 0;
}
+- (void)dataSourceUpdated: (IFWebDataSource *)dataSource
+{
+
+}
+
- (void)reapplyStyles
{
KHTMLView *widget = _private->widget;
@@ -274,7 +289,8 @@
return NO;
dataSource = [[[IFWebDataSource alloc] initWithURL:URL] autorelease];
- frame = [[self controller] frameForView:self];
+ frame = nil;
+ //frame = [[self controller] frameForView:self];
[frame setProvisionalDataSource:dataSource];
[frame startLoading];
diff --git a/WebKit/WebView.subproj/WebFrameViewInternal.h b/WebKit/WebView.subproj/IFHTMLViewPrivate.h
similarity index 82%
copy from WebKit/WebView.subproj/WebFrameViewInternal.h
copy to WebKit/WebView.subproj/IFHTMLViewPrivate.h
index 33764e4..16770e7 100644
--- a/WebKit/WebView.subproj/WebFrameViewInternal.h
+++ b/WebKit/WebView.subproj/IFHTMLViewPrivate.h
@@ -1,18 +1,18 @@
-/* IFWebViewPrivate.h
- Copyright 2001, Apple, Inc. All rights reserved.
+/* IFHTMLViewPrivate.h
+ Copyright 2002, Apple, Inc. All rights reserved.
Private header file. This file may reference classes (both ObjectiveC and C++)
in WebCore. Instances of this class are referenced by _private in
NSWebPageView.
*/
-#import <WebKit/IFWebView.h>
+#import <WebKit/IFHTMLView.h>
class QWidget;
class KHTMLPart;
class KHTMLView;
- at interface IFWebViewPrivate : NSObject
+ at interface IFHTMLViewPrivate : NSObject
{
IFWebController *controller;
KHTMLView *widget;
@@ -29,7 +29,7 @@ class KHTMLView;
@end
- at interface IFWebView (IFPrivate)
+ at interface IFHTMLView (IFPrivate)
- (void)_setController: (IFWebController *)controller;
- (void)_resetWidget;
- (KHTMLView *)_widget;
diff --git a/WebKit/WebView.subproj/WebFrameViewPrivate.m b/WebKit/WebView.subproj/IFHTMLViewPrivate.mm
similarity index 70%
copy from WebKit/WebView.subproj/WebFrameViewPrivate.m
copy to WebKit/WebView.subproj/IFHTMLViewPrivate.mm
index eee7488..fdf0fb6 100644
--- a/WebKit/WebView.subproj/WebFrameViewPrivate.m
+++ b/WebKit/WebView.subproj/IFHTMLViewPrivate.mm
@@ -1,5 +1,5 @@
-/* IFWebViewPrivate.mm
- Copyright 2001, Apple, Inc. All rights reserved.
+/* IFHTMLViewPrivate.mm
+ Copyright 2002, Apple, Inc. All rights reserved.
Private header file. This file may reference classes (both ObjectiveC and C++)
in WebCore. Instances of this class are referenced by _private in
@@ -7,7 +7,7 @@
*/
#import <WebKit/WebKitDebug.h>
-#import <WebKit/IFWebViewPrivate.h>
+#import <WebKit/IFHTMLViewPrivate.h>
#import <WebKit/IFPluginView.h>
// Includes from KDE
@@ -16,7 +16,7 @@
#import <html/html_documentimpl.h>
#import "IFWebController.h"
- at implementation IFWebViewPrivate
+ at implementation IFHTMLViewPrivate
- (void)dealloc
{
@@ -33,7 +33,7 @@
@end
- at implementation IFWebView (IFPrivate)
+ at implementation IFHTMLView (IFPrivate)
- (void)_resetWidget
{
@@ -74,6 +74,45 @@
return _private->widget;
}
+- (DOM::DocumentImpl *)_document
+{
+ KHTMLPart *part = _private->widget->part();
+ if (part) {
+ return part->xmlDocImpl();
+ }
+ return 0;
+}
+
++ (NSString *)_nodeName: (DOM::NodeImpl *)node
+{
+ // FIXME: good for debugging only since it's Latin 1 only
+ return [NSString stringWithCString:node->nodeName().string().latin1()];
+}
+
++ (NSString *)_nodeValue: (DOM::NodeImpl *)node
+{
+ // FIXME: good for debugging only since it's Latin 1 only
+ return [NSString stringWithCString:node->nodeValue().string().latin1()];
+}
+
++ (NSString *)_nodeHTML: (DOM::NodeImpl *)node
+{
+ NSString *string = QSTRING_TO_NSSTRING(node->recursive_toHTML(1));
+ return string;
+}
+
+- (khtml::RenderObject *)_renderRoot
+{
+ KHTMLPart *part = _private->widget->part();
+ DOM::DocumentImpl *doc;
+ if (part) {
+ doc = part->xmlDocImpl();
+ if (doc)
+ return doc->renderer();
+ }
+ return 0;
+}
+
- (KHTMLView *)_provisionalWidget
{
return _private->provisionalWidget;
diff --git a/WebKit/WebView.subproj/IFImageRepresentation.h b/WebKit/WebView.subproj/IFImageRepresentation.h
new file mode 100644
index 0000000..c24babe
--- /dev/null
+++ b/WebKit/WebView.subproj/IFImageRepresentation.h
@@ -0,0 +1,22 @@
+/*
+ IFImageRepresentation.h
+ Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#import <Foundation/Foundation.h>
+
+ at class IFError;
+ at class IFWebDataSource;
+ at class IFImageRenderer;
+ at protocol IFDocumentRepresentation;
+
+ at interface IFImageRepresentation : NSObject <IFDocumentRepresentation>
+{
+ IFImageRenderer *image;
+}
+
+- (IFImageRenderer *)image;
+- (void)receivedData:(NSData *)data withDataSource:(IFWebDataSource *)dataSource isComplete:(BOOL)isComplete;
+- (void)receivedError:(IFError *)error withDataSource:(IFWebDataSource *)dataSource;
+
+ at end
diff --git a/WebKit/WebView.subproj/IFImageRepresentation.m b/WebKit/WebView.subproj/IFImageRepresentation.m
new file mode 100644
index 0000000..a1a3507
--- /dev/null
+++ b/WebKit/WebView.subproj/IFImageRepresentation.m
@@ -0,0 +1,42 @@
+/*
+ IFImageRepresentation.m
+ Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#import "IFImageRepresentation.h"
+#import <WebKit/IFWebDataSource.h>
+#import <WebKit/IFImageRenderer.h>
+#import <WebKit/IFImageRendererFactory.h>
+
+ at implementation IFImageRepresentation
+
+- init
+{
+ self = [super init];
+ if (self) {
+ //image = [[IFImageRenderer alloc] init];
+ }
+ return self;
+}
+
+- (IFImageRenderer *)image
+{
+ return image;
+}
+
+- (void)receivedData:(NSData *)data withDataSource:(IFWebDataSource *)dataSource isComplete:(BOOL)isComplete
+{
+ if(isComplete){
+ NSData *resourceData = [dataSource data];
+ image = [[IFImageRendererFactory alloc] imageRendererWithBytes:[resourceData bytes]
+ length:[resourceData length]];
+ }
+ //[image incrementalLoadWithBytes:[data bytes] length:[data length] complete:isComplete];
+}
+
+- (void)receivedError:(IFError *)error withDataSource:(IFWebDataSource *)dataSource
+{
+
+}
+
+ at end
diff --git a/WebKit/WebView.subproj/IFImageView.h b/WebKit/WebView.subproj/IFImageView.h
new file mode 100644
index 0000000..cc0e398
--- /dev/null
+++ b/WebKit/WebView.subproj/IFImageView.h
@@ -0,0 +1,33 @@
+/*
+ IFImageView.h
+ Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#import <AppKit/AppKit.h>
+
+ at class IFWebDataSource;
+ at class IFImageRepresentation;
+ at protocol IFDocumentLoading;
+ at protocol IFDocumentDragSettings;
+
+ at interface IFImageView : NSView <IFDocumentLoading, IFDocumentDragSettings>
+{
+ IFImageRepresentation *representation;
+ BOOL canDragFrom;
+ BOOL canDragTo;
+ BOOL didSetFrame;
+}
+
+
+- (void)provisionalDataSourceChanged:(IFWebDataSource *)dataSource;
+- (void)provisionalDataSourceCommitted:(IFWebDataSource *)dataSource;
+- (void)dataSourceUpdated:(IFWebDataSource *)dataSource;
+- (void)layout;
+
+- (void)setCanDragFrom: (BOOL)flag;
+- (BOOL)canDragFrom;
+- (void)setCanDragTo: (BOOL)flag;
+- (BOOL)canDragTo;
+
+
+ at end
diff --git a/WebKit/WebView.subproj/IFImageView.m b/WebKit/WebView.subproj/IFImageView.m
new file mode 100644
index 0000000..dc9a78a
--- /dev/null
+++ b/WebKit/WebView.subproj/IFImageView.m
@@ -0,0 +1,91 @@
+/*
+ IFImageView.m
+ Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#import "IFImageView.h"
+#import <WebKit/IFWebDataSource.h>
+#import <WebKit/IFImageRenderer.h>
+#import <WebKit/IFImageRepresentation.h>
+
+ at implementation IFImageView
+
+- (id)initWithFrame:(NSRect)frame {
+
+ self = [super initWithFrame:frame];
+ if (self) {
+ canDragFrom = YES;
+ canDragTo = YES;
+ didSetFrame = NO;
+ }
+ return self;
+}
+
+- (void)dealloc
+{
+ [[representation image] stopAnimation];
+ [representation release];
+}
+
+
+- (void)drawRect:(NSRect)rect {
+ IFImageRenderer *image;
+ NSSize imageSize;
+
+ image = [representation image];
+ if([representation image]){
+
+ imageSize = [image size];
+ [image beginAnimationInView:self inRect:rect fromRect:NSMakeRect(0, 0, imageSize.width, imageSize.height)];
+ }
+}
+
+- (void)provisionalDataSourceChanged:(IFWebDataSource *)dataSource
+{
+
+}
+
+- (void)provisionalDataSourceCommitted:(IFWebDataSource *)dataSource
+{
+ representation = [[dataSource representation] retain];
+}
+
+- (void)dataSourceUpdated:(IFWebDataSource *)dataSource
+{
+
+}
+
+- (void)layout
+{
+ if([representation image] && !didSetFrame){
+ IFImageRenderer *image = [representation image];
+ NSSize imageSize = [image size];
+ NSRect frame = [self frame];
+
+ [self setFrame:NSMakeRect(frame.origin.x, frame.origin.x, imageSize.width, imageSize.height)];
+ didSetFrame = YES;
+ }
+}
+
+- (void)setCanDragFrom: (BOOL)flag
+{
+ canDragFrom = flag;
+}
+
+- (BOOL)canDragFrom
+{
+ return canDragFrom;
+}
+
+- (void)setCanDragTo: (BOOL)flag
+{
+ canDragTo = flag;
+}
+
+- (BOOL)canDragTo
+{
+ return canDragTo;
+}
+
+
+ at end
diff --git a/WebKit/WebView.subproj/IFMainURLHandleClient.h b/WebKit/WebView.subproj/IFMainURLHandleClient.h
index f1ccc14..835a670 100644
--- a/WebKit/WebView.subproj/IFMainURLHandleClient.h
+++ b/WebKit/WebView.subproj/IFMainURLHandleClient.h
@@ -6,7 +6,7 @@
Copyright 2001, Apple, Inc. All rights reserved.
*/
-#import <WebKit/IFMIMEHandler.h>
+
#import <WebKit/IFLocationChangeHandler.h>
#import <WebFoundation/IFURLHandle.h>
@@ -18,20 +18,14 @@ class KHTMLPart;
@interface IFMainURLHandleClient : NSObject <IFURLHandleClient>
{
+ NSURL *url;
id dataSource;
KHTMLPart *part;
- BOOL sentFakeDocForNonHTMLContentType, processedBufferedData, downloadStarted, loadFinished, examinedInitialData;
- IFMIMEHandlerType handlerType;
- IFDownloadHandler *downloadHandler;
- IFContentPolicy contentPolicy;
- NSData *resourceData;
- NSString *encoding, *MIMEType;
- NSURL *url;
+ BOOL processedBufferedData;
+ BOOL examinedInitialData;
+ BOOL isFirstChunk;
}
-- initWithDataSource: (IFWebDataSource *)ds part: (KHTMLPart *)p;
-- (void)setContentPolicy:(IFContentPolicy)theContentPolicy;
+- initWithDataSource: (IFWebDataSource *)ds;
-- (void) processData:(NSData *)data isComplete:(BOOL)complete allDataReceived:(BOOL)allDataReceived;
-- (void) finishProcessingData:(NSData *)data;
@end
diff --git a/WebKit/WebView.subproj/IFMainURLHandleClient.mm b/WebKit/WebView.subproj/IFMainURLHandleClient.mm
index 4b77070..d5ba7b6 100644
--- a/WebKit/WebView.subproj/IFMainURLHandleClient.mm
+++ b/WebKit/WebView.subproj/IFMainURLHandleClient.mm
@@ -4,41 +4,35 @@
Copyright 2001, Apple, Inc. All rights reserved.
*/
-#import <WebKit/IFMainURLHandleClient.h>
-
-#import <pthread.h>
-
+#import <WebKit/IFDocument.h>
+#import <WebKit/IFHTMLRepresentation.h>
#import <WebKit/IFLoadProgress.h>
+#import <WebKit/IFLocationChangeHandler.h>
+#import <WebKit/IFMainURLHandleClient.h>
+#import <WebKit/IFWebController.h>
#import <WebKit/IFWebControllerPrivate.h>
-#import <WebKit/WebKitDebug.h>
-#import <WebKit/IFContentHandler.h>
-#import <WebKit/IFDownloadHandler.h>
#import <WebKit/IFWebDataSource.h>
#import <WebKit/IFWebDataSourcePrivate.h>
-#import <WebKit/IFWebController.h>
-#import <WebKit/IFLocationChangeHandler.h>
#import <WebKit/IFWebFrame.h>
#import <WebKit/IFWebFramePrivate.h>
+#import <WebKit/IFWebView.h>
+#import <WebKit/WebKitDebug.h>
+
+#import <KWQKHTMLPartImpl.h>
#import <WebFoundation/IFError.h>
-#import <khtmlview.h>
-#import <KWQKHTMLPartImpl.h>
+
@implementation IFMainURLHandleClient
-- initWithDataSource: (IFWebDataSource *)ds part:(KHTMLPart *)p
+- initWithDataSource: (IFWebDataSource *)ds
{
if ((self = [super init])) {
dataSource = [ds retain];
- part = p;
- part->ref();
- sentFakeDocForNonHTMLContentType = NO;
- downloadStarted = NO;
- loadFinished = NO;
examinedInitialData = NO;
processedBufferedData = NO;
- contentPolicy = IFContentPolicyNone;
+ isFirstChunk = YES;
return self;
}
@@ -49,27 +43,10 @@
{
WEBKIT_ASSERT(url == nil);
- part->deref();
[dataSource release];
- [resourceData release];
- [encoding release];
- [MIMEType release];
[super dealloc];
}
-// This method should never get called more than once.
-// Also, this method should never be passed a IFContentPolicyNone.
-- (void)setContentPolicy:(IFContentPolicy)theContentPolicy
-{
- WEBKIT_ASSERT(contentPolicy == IFContentPolicyNone);
- WEBKIT_ASSERT(theContentPolicy != IFContentPolicyNone);
-
- contentPolicy = theContentPolicy;
-
- if(loadFinished)
- [self processData:resourceData isComplete:YES allDataReceived:loadFinished];
-}
-
- (void)IFURLHandleResourceDidBeginLoading:(IFURLHandle *)sender
{
WEBKITDEBUGLEVEL (WEBKIT_LOG_LOADING, "url = %s\n", DEBUG_OBJECT([sender url]));
@@ -87,8 +64,6 @@
WEBKIT_ASSERT([url isEqual:[sender redirectedURL] ? [sender redirectedURL] : [sender url]]);
- [downloadHandler release];
-
IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
loadProgress->totalToLoad = -1;
loadProgress->bytesSoFar = -1;
@@ -107,14 +82,7 @@
WEBKIT_ASSERT([url isEqual:[sender redirectedURL] ? [sender redirectedURL] : [sender url]]);
- loadFinished = YES;
-
- if(contentPolicy != IFContentPolicyNone){
- [self finishProcessingData:data];
- }else{
- // If the content policy hasn't been set, save the data until it has.
- resourceData = [data retain];
- }
+ [dataSource _setResourceData:data];
// update progress
IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
@@ -133,6 +101,11 @@
{
int contentLength = [sender contentLength];
int contentLengthReceived = [sender contentLengthReceived];
+ BOOL isComplete = (contentLength == contentLengthReceived);
+ NSString *contentType = [sender contentType];
+ IFWebFrame *frame = [dataSource webFrame];
+ IFWebView *view = [frame view];
+ IFContentPolicy contentPolicy;
WEBKITDEBUGLEVEL(WEBKIT_LOG_LOADING, "url = %s, data = %p, length %d\n", DEBUG_OBJECT([sender url]), data, [data length]);
@@ -140,17 +113,14 @@
// Check the mime type and ask the client for the content policy.
if(!examinedInitialData){
- MIMEType = [[sender contentType] retain];
- WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "main content type: %s", DEBUG_OBJECT(MIMEType));
- [[dataSource _locationChangeHandler] requestContentPolicyForMIMEType:MIMEType];
-
- // FIXME: Remove/replace IFMIMEHandler stuff
- handlerType = [IFMIMEHandler MIMEHandlerTypeForMIMEType:MIMEType];
-
- encoding = [[sender characterSet] retain];
+ WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "main content type: %s", DEBUG_OBJECT(contentType));
+ [dataSource _setContentType:contentType];
+ [dataSource _setEncoding:[sender characterSet]];
+ [[dataSource _locationChangeHandler] requestContentPolicyForMIMEType:contentType];
examinedInitialData = YES;
}
+ contentPolicy = [dataSource contentPolicy];
if(contentPolicy == IFContentPolicyIgnore){
[sender cancelLoadInBackground];
return;
@@ -158,12 +128,19 @@
if(contentPolicy != IFContentPolicyNone){
if(!processedBufferedData){
- // process all data that has been received now that we have a content policy
- [self processData:[sender resourceData] isComplete:NO allDataReceived:(contentLength == contentLengthReceived)];
- processedBufferedData = YES;
+ // Process all data that has been received now that we have a content policy
+ // and don't call resourceData if this is the first chunk since resourceData is a copy
+ if(isFirstChunk){
+ [[dataSource representation] receivedData:data withDataSource:dataSource isComplete:isComplete];
+ }else{
+ [[dataSource representation] receivedData:[sender resourceData]
+ withDataSource:dataSource isComplete:isComplete];
+ }
+ processedBufferedData = YES;
}else{
- [self processData:data isComplete:NO allDataReceived:(contentLength == contentLengthReceived)];
+ [[dataSource representation] receivedData:data withDataSource:dataSource isComplete:isComplete];
}
+ [[view documentView] dataSourceUpdated:dataSource];
}
WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "%d of %d", contentLengthReceived, contentLength);
@@ -182,6 +159,8 @@
[(IFWebController *)[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress
forResource: [[sender url] absoluteString] fromDataSource: dataSource];
[loadProgress release];
+
+ isFirstChunk = NO;
}
@@ -190,8 +169,6 @@
WEBKITDEBUGLEVEL (WEBKIT_LOG_LOADING, "url = %s, result = %s\n", DEBUG_OBJECT([sender url]), DEBUG_OBJECT([result errorDescription]));
WEBKIT_ASSERT([url isEqual:[sender redirectedURL] ? [sender redirectedURL] : [sender url]]);
-
- [downloadHandler release];
IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
loadProgress->totalToLoad = [sender contentLength];
@@ -216,93 +193,11 @@
url = newURL;
[(IFWebController *)[dataSource controller] _didStartLoading:url];
- part->impl->setBaseURL([[url absoluteString] cString]);
+ if([dataSource _isDocumentHTML])
+ [[dataSource representation] part]->impl->setBaseURL([[url absoluteString] cString]);
[dataSource _setFinalURL:url];
[[dataSource _locationChangeHandler] serverRedirectTo:url forDataSource:dataSource];
}
-
-- (void) processData:(NSData *)data isComplete:(BOOL)complete allDataReceived:(BOOL)allDataReceived
-{
- NSString *fakeHTMLDocument;
- const char *fakeHTMLDocumentBytes;
- IFContentHandler *contentHandler;
- IFWebFrame *frame;
-
- WEBKIT_ASSERT(url != nil);
-
- if(contentPolicy == IFContentPolicyShow){
-
- if(handlerType == IFMIMEHANDLERTYPE_NIL || handlerType == IFMIMEHANDLERTYPE_HTML) {
- // If data is html, send it to the part.
- part->impl->slotData(encoding, (const char *)[data bytes], [data length], allDataReceived);
- }
-
- else if(handlerType == IFMIMEHANDLERTYPE_IMAGE ||
- handlerType == IFMIMEHANDLERTYPE_PLUGIN ||
- handlerType == IFMIMEHANDLERTYPE_TEXT) {
-
- // For a non-html document, create html doc that embeds it.
- if (!sentFakeDocForNonHTMLContentType) {
- contentHandler = [[IFContentHandler alloc] initWithURL:url MIMEType:MIMEType MIMEHandlerType:handlerType];
- fakeHTMLDocument = [contentHandler HTMLDocument];
- fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
- part->impl->slotData(encoding, fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes), allDataReceived);
- [contentHandler release];
- sentFakeDocForNonHTMLContentType = YES;
- }
-
- // For text documents, the incoming data is part of the main page.
- if(handlerType == IFMIMEHANDLERTYPE_TEXT){
- part->impl->slotData(encoding, (const char *)[data bytes], [data length], allDataReceived);
- }
- }
- }
-
- else if(contentPolicy == IFContentPolicySave || contentPolicy == IFContentPolicyOpenExternally){
- if(!downloadStarted){
-
- // If this is a download, detach the provisionalDataSource from the frame
- // and have downloadHandler retain it.
- downloadHandler = [[IFDownloadHandler alloc] initWithDataSource:dataSource];
- frame = [dataSource webFrame];
- [frame->_private setProvisionalDataSource:nil];
-
- // go right to locationChangeDone as the data source never gets committed.
- [[dataSource _locationChangeHandler] locationChangeDone:nil];
- downloadStarted = YES;
- }
- }
-
- if(complete)
- [self finishProcessingData:data];
-}
-
-- (void) finishProcessingData:(NSData *)data;
-{
- NSString *fakeHTMLDocument;
- const char *fakeHTMLDocumentBytes;
- IFContentHandler *contentHandler;
-
- WEBKIT_ASSERT(url != nil);
-
- if(contentPolicy == IFContentPolicyShow){
- if(handlerType == IFMIMEHANDLERTYPE_TEXT) {
- contentHandler = [[IFContentHandler alloc] initWithURL:url MIMEType:MIMEType MIMEHandlerType:IFMIMEHANDLERTYPE_TEXT];
- fakeHTMLDocument = [contentHandler textHTMLDocumentBottom];
- fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
- part->impl->slotData(encoding, fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes), YES);
- [contentHandler release];
- }
- }
-
- else if(contentPolicy == IFContentPolicySave || contentPolicy == IFContentPolicyOpenExternally){
- // FIXME [cblu]: We shouldn't wait for the download to end to write to the disk.
- // Will fix once we there is an IFURLHandle flag to not cache in memory (2903660).
- [downloadHandler downloadCompletedWithData:data];
- [downloadHandler release];
- }
-}
-
@end
diff --git a/WebKit/WebView.subproj/IFRenderNode.mm b/WebKit/WebView.subproj/IFRenderNode.mm
index f5010b0..b239f10 100644
--- a/WebKit/WebView.subproj/IFRenderNode.mm
+++ b/WebKit/WebView.subproj/IFRenderNode.mm
@@ -8,7 +8,8 @@
#import "IFRenderNode.h"
-#import <IFWebViewPrivate.h>
+#import <WebKit/IFWebView.h>
+#import <WebKit/IFHTMLViewPrivate.h>
#import <khtmlview.h>
#import <khtml_part.h>
#import <xml/dom_docimpl.h>
@@ -54,7 +55,7 @@
- initWithWebView:(IFWebView *)view
{
- return [self initWithRenderObject:[view _widget]->part()->xmlDocImpl()->renderer()];
+ return [self initWithRenderObject:[[view documentView] _widget]->part()->xmlDocImpl()->renderer()];
}
- (void)dealloc
diff --git a/WebKit/WebView.subproj/IFTextRepresentation.h b/WebKit/WebView.subproj/IFTextRepresentation.h
new file mode 100644
index 0000000..68fcdc5
--- /dev/null
+++ b/WebKit/WebView.subproj/IFTextRepresentation.h
@@ -0,0 +1,20 @@
+/*
+ IFTextRepresentation.h
+ Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#import <Foundation/Foundation.h>
+
+ at class IFError;
+ at class IFWebDataSource;
+ at protocol IFDocumentRepresentation;
+
+ at interface IFTextRepresentation : NSObject <IFDocumentRepresentation>
+{
+
+}
+
+- (void)receivedData:(NSData *)data withDataSource:(IFWebDataSource *)dataSource isComplete:(BOOL)isComplete;
+- (void)receivedError:(IFError *)error withDataSource:(IFWebDataSource *)dataSource;
+
+ at end
diff --git a/WebKit/WebView.subproj/IFTextRepresentation.m b/WebKit/WebView.subproj/IFTextRepresentation.m
new file mode 100644
index 0000000..ec31613
--- /dev/null
+++ b/WebKit/WebView.subproj/IFTextRepresentation.m
@@ -0,0 +1,21 @@
+/*
+ IFTextRepresentation.h
+ Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#import "IFTextRepresentation.h"
+
+
+ at implementation IFTextRepresentation
+
+- (void)receivedData:(NSData *)data withDataSource:(IFWebDataSource *)dataSource isComplete:(BOOL)isComplete
+{
+
+}
+
+- (void)receivedError:(IFError *)error withDataSource:(IFWebDataSource *)dataSource
+{
+
+}
+
+ at end
diff --git a/WebKit/WebView.subproj/IFTextView.h b/WebKit/WebView.subproj/IFTextView.h
new file mode 100644
index 0000000..418c8b0
--- /dev/null
+++ b/WebKit/WebView.subproj/IFTextView.h
@@ -0,0 +1,31 @@
+/*
+ IFTextView.h
+ Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#import <Cocoa/Cocoa.h>
+
+ at class IFWebDataSource;
+ at protocol IFDocumentLoading;
+ at protocol IFDocumentDragSettings;
+ at protocol IFDocumentSearching;
+
+ at interface IFTextView : NSTextView <IFDocumentLoading, IFDocumentDragSettings, IFDocumentSearching>
+{
+ BOOL canDragFrom;
+ BOOL canDragTo;
+}
+
+- (void)provisionalDataSourceChanged:(IFWebDataSource *)dataSource;
+- (void)provisionalDataSourceCommitted:(IFWebDataSource *)dataSource;
+- (void)dataSourceUpdated:(IFWebDataSource *)dataSource;
+- (void)layout;
+
+- (void)setCanDragFrom: (BOOL)flag;
+- (BOOL)canDragFrom;
+- (void)setCanDragTo: (BOOL)flag;
+- (BOOL)canDragTo;
+
+- (void)searchFor: (NSString *)string direction: (BOOL)forward caseSensitive: (BOOL)caseFlag;
+
+ at end
diff --git a/WebKit/WebView.subproj/IFTextView.m b/WebKit/WebView.subproj/IFTextView.m
new file mode 100644
index 0000000..56d790b
--- /dev/null
+++ b/WebKit/WebView.subproj/IFTextView.m
@@ -0,0 +1,71 @@
+/*
+ IFTextView.m
+ Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#import "IFTextView.h"
+#import <WebKit/IFWebDataSource.h>
+
+ at implementation IFTextView
+
+
+- (id)initWithFrame:(NSRect)frame {
+
+ self = [super initWithFrame:frame];
+ if (self) {
+ canDragFrom = YES;
+ canDragTo = YES;
+ [[self textContainer] setWidthTracksTextView:YES];
+ [self setAutoresizingMask:NSViewWidthSizable];
+ [self setRichText:YES];
+ }
+ return self;
+}
+
+- (void)provisionalDataSourceChanged:(IFWebDataSource *)dataSource
+{
+
+}
+
+- (void)provisionalDataSourceCommitted:(IFWebDataSource *)dataSource
+{
+
+}
+
+- (void)dataSourceUpdated:(IFWebDataSource *)dataSource
+{
+ NSString *theString = [[NSString alloc] initWithData:[dataSource data] encoding:NSASCIIStringEncoding];
+ [self setString:theString];
+ [theString release];
+}
+
+- (void)layout
+{
+}
+
+- (void)setCanDragFrom: (BOOL)flag
+{
+ canDragFrom = flag;
+}
+
+- (BOOL)canDragFrom
+{
+ return canDragFrom;
+}
+
+- (void)setCanDragTo: (BOOL)flag
+{
+ canDragTo = flag;
+}
+
+- (BOOL)canDragTo
+{
+ return canDragTo;
+}
+
+- (void)searchFor: (NSString *)string direction: (BOOL)forward caseSensitive: (BOOL)caseFlag
+{
+
+}
+
+ at end
diff --git a/WebKit/WebView.subproj/IFWebController.h b/WebKit/WebView.subproj/IFWebController.h
index e48022f..f8312d5 100644
--- a/WebKit/WebView.subproj/IFWebController.h
+++ b/WebKit/WebView.subproj/IFWebController.h
@@ -37,6 +37,8 @@
@class IFWebController;
@class IFWebControllerPrivate;
+ at protocol IFDocumentLoading;
+
/*
=============================================================================
@@ -106,14 +108,6 @@ typedef enum {
IFWebControllerPrivate *_private;
}
-/*
-// Called when the content policy is set to IFContentPolicyShow
-+ (id <IFDocumentView>) createViewForMIMEType:(NSString *)MIMEType
-
-// registerClass extends the views that WebKit supports
-+ (void) registerClass:(Class)class forMIMEType:(NSString *)MIMEType
-*/
-
// Calls designated initializer with nil arguments.
- init;
@@ -176,5 +170,6 @@ typedef enum {
- (void)stopAnimatedImageLooping;
- (void)startAnimatedImageLooping;
++ (BOOL)canShowMIMEType:(NSString *)MIMEType;
@end
diff --git a/WebKit/WebView.subproj/IFWebController.mm b/WebKit/WebView.subproj/IFWebController.mm
index 8f01fb4..4155631 100644
--- a/WebKit/WebView.subproj/IFWebController.mm
+++ b/WebKit/WebView.subproj/IFWebController.mm
@@ -3,14 +3,16 @@
Copyright 2001, 2002 Apple, Inc. All rights reserved.
*/
+#import <WebKit/IFDocument.h>
+#import <WebKit/IFDynamicScrollBarsView.h>
+#import <WebKit/IFException.h>
+#import <WebKit/IFPluginDatabase.h>
#import <WebKit/IFWebController.h>
#import <WebKit/IFWebControllerPrivate.h>
#import <WebKit/IFWebViewPrivate.h>
#import <WebKit/IFWebDataSourcePrivate.h>
#import <WebKit/IFWebFrame.h>
#import <WebKit/IFWebFramePrivate.h>
-#import <WebKit/IFDynamicScrollBarsView.h>
-#import <WebKit/IFException.h>
#import <WebKit/IFWebController.h>
#import <WebKit/WebKitDebug.h>
@@ -18,18 +20,6 @@
@implementation IFWebController
-/*
-+ (id <IFDocumentView>) createViewForMIMEType:(NSString *)MIMEType
-{
- return nil;
-}
-
-+ (void) registerClass:(Class)class forMIMEType:(NSString *)MIMEType
-{
-
-}
-*/
-
- init
{
return [self initWithView: nil provisionalDataSource: nil];
@@ -66,7 +56,6 @@
{
IFWebView *childView;
IFWebFrame *newFrame;
- NSScrollView *scrollView;
childView = [[[IFWebView alloc] initWithFrame: NSMakeRect (0,0,0,0)] autorelease];
@@ -77,12 +66,7 @@
[childView _setController: self];
[childDataSource _setController: self];
- if (inScrollView == YES){
- scrollView = [[[IFDynamicScrollBarsView alloc] initWithFrame: NSMakeRect(0,0,0,0)] autorelease];
- [scrollView setHasVerticalScroller: NO];
- [scrollView setHasHorizontalScroller: NO];
- [childView _setFrameScrollView: scrollView];
- }
+ [childView setAllowsScrolling: inScrollView];
return newFrame;
}
@@ -262,6 +246,7 @@
- (void)haveContentPolicy: (IFContentPolicy)policy andPath: (NSString *)path forLocationChangeHandler: (id <IFLocationChangeHandler>)handler
{
IFWebDataSource *mainDataSource, *mainProvisionalDataSource, *dataSource;
+ NSString *MIMEType;
if(policy == IFContentPolicyNone)
[NSException raise:NSInvalidArgumentException format:@"Can't set policy of IFContentPolicyNone. Use IFContentPolicyIgnore instead"];
@@ -279,6 +264,24 @@
}else{
[dataSource _setContentPolicy:policy];
[dataSource _setDownloadPath:path];
+
+ if(policy == IFContentPolicyShow){
+ MIMEType = [dataSource contentType];
+ if([[self class] canShowMIMEType:MIMEType]){
+ id documentView;
+ IFWebView *webView;
+ id <IFDocumentRepresentation> dataRepresentation;
+
+ dataRepresentation = [IFWebDataSource createRepresentationForMIMEType:MIMEType];
+ [dataSource _setRepresentation:dataRepresentation];
+ webView = [[dataSource webFrame] view];
+ documentView = [IFWebView createViewForMIMEType:MIMEType];
+ [webView _setDocumentView: documentView];
+ [documentView provisionalDataSourceChanged: dataSource];
+ }else{
+ // return error with unableToImplementContentPolicy
+ }
+ }
}
}
}
@@ -299,4 +302,17 @@
{
}
++ (BOOL)canShowMIMEType:(NSString *)MIMEType
+{
+ if([IFWebView _canShowMIMEType:MIMEType] && [IFWebDataSource _canShowMIMEType:MIMEType]){
+ return YES;
+ }else{
+ // Have the plug-ins register views
+ [IFPluginDatabase installedPlugins];
+ if([IFWebView _canShowMIMEType:MIMEType] && [IFWebDataSource _canShowMIMEType:MIMEType])
+ return YES;
+ }
+ return NO;
+}
+
@end
diff --git a/WebKit/WebView.subproj/IFWebControllerPrivate.h b/WebKit/WebView.subproj/IFWebControllerPrivate.h
index a169cee..bf07746 100644
--- a/WebKit/WebView.subproj/IFWebControllerPrivate.h
+++ b/WebKit/WebView.subproj/IFWebControllerPrivate.h
@@ -4,6 +4,7 @@
*/
#import <WebKit/IFWebController.h>
+//#import <WebKit/IFDocument.h>
@class IFError;
@class IFLoadProgress;
diff --git a/WebKit/WebView.subproj/IFWebControllerPrivate.mm b/WebKit/WebView.subproj/IFWebControllerPrivate.mm
index cb21f7b..9e630cf 100644
--- a/WebKit/WebView.subproj/IFWebControllerPrivate.mm
+++ b/WebKit/WebView.subproj/IFWebControllerPrivate.mm
@@ -18,7 +18,6 @@
#import <WebKit/WebKitDebug.h>
-
@implementation IFWebControllerPrivate
- init
@@ -51,8 +50,8 @@
[self _clearControllerReferences: mainFrame];
[mainFrame reset];
-
[mainFrame autorelease];
+
[super dealloc];
}
diff --git a/WebKit/WebView.subproj/IFWebDataSource.h b/WebKit/WebView.subproj/IFWebDataSource.h
index 9d1eca6..4c647ff 100644
--- a/WebKit/WebView.subproj/IFWebDataSource.h
+++ b/WebKit/WebView.subproj/IFWebDataSource.h
@@ -25,6 +25,7 @@
#endif
@class IFWebDataSourcePrivate;
+ at protocol IFDocumentRepresentation;
@interface IFWebDataSource : NSObject
{
@@ -43,6 +44,10 @@
- initWithLoader: (IFLoader *)loader;
#endif
+- (NSData *)data;
+
+- (id)representation;
+
// Returns YES if this is the main document. The main document is the 'top'
// document, typically either a frameset or a normal HTML document.
- (BOOL)isMainDocument;
@@ -112,6 +117,8 @@
// Returns YES if there are any pending loads.
- (BOOL)isLoading;
+
+/*
#ifdef TENTATIVE_API
// Get DOM access to the document.
- (IFDOMDocument *)document;
@@ -119,10 +126,12 @@
// Get the source of the document by reconstructing it from the DOM.
- (NSString *)documentTextFromDOM;
+*/
// Get the actual source of the document.
- (NSString *)documentText;
+
// URL reference point, these should probably not be public for 1.0.
- (NSURL *)base;
- (NSString *)baseTarget;
@@ -148,6 +157,8 @@
- (IFContentPolicy)contentPolicy;
+- (NSString *)contentType;
+
- (NSString *)downloadPath;
/*
@@ -158,5 +169,8 @@
*/
- (IFError *)mainDocumentError;
++ (void) registerRepresentationClass:(Class)repClass forMIMEType:(NSString *)MIMEType;
+
++ (id <IFDocumentRepresentation>) createRepresentationForMIMEType:(NSString *)MIMEType;
@end
diff --git a/WebKit/WebView.subproj/IFWebDataSource.mm b/WebKit/WebView.subproj/IFWebDataSource.mm
index ee83e49..e045c0d 100644
--- a/WebKit/WebView.subproj/IFWebDataSource.mm
+++ b/WebKit/WebView.subproj/IFWebDataSource.mm
@@ -10,11 +10,17 @@
#import <WebKit/IFWebController.h>
#import <WebKit/IFWebFramePrivate.h>
#import <WebFoundation/WebFoundation.h>
+#import <WebKit/IFHTMLView.h>
+#import <WebKit/IFImageView.h>
+#import <WebKit/IFTextView.h>
+#import <WebKit/IFHTMLRepresentation.h>
+#import <WebKit/IFImageRepresentation.h>
+#import <WebKit/IFTextRepresentation.h>
#import <xml/dom_docimpl.h>
-#import <KWQKHTMLPartImpl.h>
#import <WCWebDataSource.h>
+#import <KWQKHTMLPartImpl.h>
@implementation IFWebDataSource
@@ -58,11 +64,19 @@ static id IFWebDataSourceMake(void *url, void *attributes, unsigned flags)
[super dealloc];
}
-#ifdef TENTATIVE_API
-- initWithData: (NSData *)data
-- initWithString: (NSString *)string;
-- initWithLoader: (IFLoader *)loader;
-#endif
+- (NSData *)data
+{
+ if(_private->mainHandle){
+ return [_private->mainHandle resourceData];
+ }else{
+ return _private->resourceData;
+ }
+}
+
+- (id) representation
+{
+ return _private->representation;
+}
- (IFWebFrame *)webFrame
{
@@ -235,32 +249,35 @@ static id IFWebDataSourceMake(void *url, void *attributes, unsigned flags)
- (IFDOMDocument *)document;
#endif
+
// Get the actual source of the docment.
- (NSString *)documentText
{
- KHTMLPart *part = [self _part];
-
- return QSTRING_TO_NSSTRING(part->impl->documentSource());
+ return [[[NSString alloc] initWithData:[self data] encoding:NSASCIIStringEncoding] autorelease];
}
-
+// FIXME: Move to representation
- (NSString *)documentTextFromDOM
{
- DOM::DocumentImpl *doc;
- NSString *string = nil;
- KHTMLPart *part = [self _part];
-
- if (part != 0){
- doc = [self _part]->xmlDocImpl();
- if (doc != 0){
- QString str = doc->recursive_toHTML(1);
- string = QSTRING_TO_NSSTRING(str);
+ if([self _isDocumentHTML]){
+ DOM::DocumentImpl *doc;
+ NSString *string = nil;
+ KHTMLPart *part = [[self representation] part];
+
+ if (part != 0){
+ doc = part->xmlDocImpl();
+ if (doc != 0){
+ QString str = doc->recursive_toHTML(1);
+ string = QSTRING_TO_NSSTRING(str);
+ }
}
+ if (string == nil) {
+ string = @"";
+ }
+ return string;
+ }else{
+ return nil;
}
- if (string == nil) {
- string = @"";
- }
- return string;
}
@@ -281,8 +298,7 @@ static id IFWebDataSourceMake(void *url, void *attributes, unsigned flags)
- (NSString *)encoding
{
- [NSException raise:IFMethodNotYetImplemented format:@"IFWebDataSource::encoding is not implemented"];
- return nil;
+ return _private->encoding;
}
// Style sheet
@@ -323,6 +339,11 @@ static id IFWebDataSourceMake(void *url, void *attributes, unsigned flags)
return _private->contentPolicy;
}
+- (NSString *)contentType
+{
+ return _private->contentType;
+}
+
- (NSString *)downloadPath
{
return _private->downloadPath;
@@ -338,5 +359,36 @@ static id IFWebDataSourceMake(void *url, void *attributes, unsigned flags)
return _private->mainDocumentError;
}
++ (void)registerRepresentationClass:(Class)repClass forMIMEType:(NSString *)MIMEType
+{
+ NSMutableDictionary *repTypes = [[self class] _repTypes];
+
+ // FIXME: OK to allow developers to override built-in reps?
+ [repTypes setObject:repClass forKey:MIMEType];
+}
+
++ (id <IFDocumentRepresentation>) createRepresentationForMIMEType:(NSString *)MIMEType
+{
+ NSMutableDictionary *repTypes = [[self class] _repTypes];
+ Class repClass;
+ NSArray *keys;
+ unsigned i;
+
+ repClass = [repTypes objectForKey:MIMEType];
+ if(repClass){
+ return [[[repClass alloc] init] autorelease];
+ }else{
+ keys = [repTypes allKeys];
+ for(i=0; i<[keys count]; i++){
+ if([[keys objectAtIndex:i] hasSuffix:@"/"] && [MIMEType hasPrefix:[keys objectAtIndex:i]]){
+ repClass = [repTypes objectForKey:[keys objectAtIndex:i]];
+ return [[[repClass alloc] init] autorelease];
+ }
+ }
+ }
+ return nil;
+}
+
+
@end
diff --git a/WebKit/WebView.subproj/IFWebDataSourcePrivate.h b/WebKit/WebView.subproj/IFWebDataSourcePrivate.h
index 96690b2..397bb6b 100644
--- a/WebKit/WebView.subproj/IFWebDataSourcePrivate.h
+++ b/WebKit/WebView.subproj/IFWebDataSourcePrivate.h
@@ -9,14 +9,18 @@
#import <WebKit/IFWebDataSource.h>
#import <WebKit/IFLocationChangeHandler.h>
-class KHTMLPart;
@class IFURLHandle;
@class IFMainURLHandleClient;
@protocol IFLocationChangeHandler;
+ at protocol IFDocumentRepresentation;
@interface IFWebDataSourcePrivate : NSObject
{
+ NSData *resourceData;
+
+ id representation;
+
IFWebDataSource *parent;
NSMutableArray *children;
@@ -28,8 +32,6 @@ class KHTMLPart;
// The original URL we may have been redirected to.
NSURL *finalURL;
- KHTMLPart *part;
-
// Child frames of this frame.
NSMutableDictionary *frames;
@@ -51,7 +53,7 @@ class KHTMLPart;
BOOL stopping;
- NSString *pageTitle, *downloadPath;
+ NSString *pageTitle, *downloadPath, *encoding, *contentType;
// Errors associated with resources.
NSMutableDictionary *errors;
@@ -73,8 +75,9 @@ class KHTMLPart;
@end
@interface IFWebDataSource (IFPrivate)
+- (void)_setResourceData:(NSData *)data;
+- (void)_setRepresentation:(id <IFDocumentRepresentation>)representation;
- (void)_setController: (IFWebController *)controller;
-- (KHTMLPart *)_part;
- (void)_setParent: (IFWebDataSource *)p;
- (void)_startLoading: (BOOL)forceRefresh;
@@ -87,15 +90,18 @@ class KHTMLPart;
- (double)_loadingStartedTime;
- (void)_setTitle: (NSString *)title;
- (void)_setFinalURL: (NSURL *)url;
-
- (id <IFLocationChangeHandler>)_locationChangeHandler;
- (void)_setLocationChangeHandler: (id <IFLocationChangeHandler>)l;
-- (void) _setDownloadPath:(NSString *)path;
-- (void) _setContentPolicy:(IFContentPolicy)policy;
+- (void)_setDownloadPath:(NSString *)path;
+- (void)_setContentPolicy:(IFContentPolicy)policy;
+- (void)_setContentType:(NSString *)type;
+- (void)_setEncoding:(NSString *)encoding;
- (IFWebDataSource *) _recursiveDataSourceForLocationChangeHandler:(id <IFLocationChangeHandler>)handler;
- (void)_clearErrors;
- (void)_setMainDocumentError: (IFError *)error;
- (void)_addError: (IFError *)error forResource: (NSString *)resourceDescription;
-
+- (BOOL)_isDocumentHTML;
++ (NSMutableDictionary *)_repTypes;
++ (BOOL)_canShowMIMEType:(NSString *)MIMEType;
@end
diff --git a/WebKit/WebView.subproj/IFWebDataSourcePrivate.mm b/WebKit/WebView.subproj/IFWebDataSourcePrivate.mm
index 9dfd5b0..c38b994 100644
--- a/WebKit/WebView.subproj/IFWebDataSourcePrivate.mm
+++ b/WebKit/WebView.subproj/IFWebDataSourcePrivate.mm
@@ -15,9 +15,16 @@
#import <WebFoundation/IFError.h>
#import <WebFoundation/IFNSStringExtensions.h>
#import <WebKit/IFLocationChangeHandler.h>
+#import <WebKit/IFHTMLRepresentation.h>
+#import <WebKit/IFImageRepresentation.h>
+#import <WebKit/IFTextRepresentation.h>
#import <KWQKHTMLPartImpl.h>
#import "IFWebController.h"
+#import <kurl.h>
+
+static NSMutableDictionary *_repTypes=nil;
+
@implementation IFWebDataSourcePrivate
- init
@@ -27,8 +34,6 @@
frames = nil;
controller = nil;
inputURL = nil;
-
- part = new KHTMLPart();
primaryLoadComplete = NO;
@@ -61,8 +66,7 @@
[errors release];
[mainDocumentError release];
-
- part->deref();
+
[super dealloc];
}
@@ -71,6 +75,18 @@
@implementation IFWebDataSource (IFPrivate)
+- (void)_setResourceData:(NSData *)data
+{
+ [_private->resourceData release];
+ _private->resourceData = [data retain];
+}
+
+- (void)_setRepresentation:(id) representation
+{
+ [_private->representation release];
+ _private->representation = [representation retain];
+}
+
- (void)_setLoading:(BOOL)loading
{
WEBKIT_ASSERT_VALID_ARG("loading", loading == NO || loading == YES);
@@ -95,19 +111,11 @@
- (void)_setController: (IFWebController *)controller
{
- WEBKIT_ASSERT(_private->part != nil);
-
if (_private->loading) {
[controller retain];
[_private->controller release];
}
_private->controller = controller;
- _private->part->impl->setDataSource(self);
-}
-
-- (KHTMLPart *)_part
-{
- return _private->part;
}
- (void)_setParent: (IFWebDataSource *)p
@@ -151,7 +159,7 @@
}
theURL = [NSURL URLWithString:urlString];
- _private->mainURLHandleClient = [[IFMainURLHandleClient alloc] initWithDataSource: self part: _private->part];
+ _private->mainURLHandleClient = [[IFMainURLHandleClient alloc] initWithDataSource: self];
[_private->mainHandle addClient: _private->mainURLHandleClient];
// Mark the start loading time.
@@ -159,10 +167,6 @@
// Fire this guy up.
[_private->mainHandle loadInBackground];
-
- // FIXME [rjw]: Do any work need in the kde engine. This should be removed.
- // We should move any code needed out of KWQ.
- _private->part->openURL(url);
[self _setLoading:YES];
@@ -205,7 +209,8 @@
[[_private->urlHandles objectAtIndex: i] cancelLoadInBackground];
}
- _private->part->closeURL();
+ if ([self _isDocumentHTML])
+ [[self representation] part]->closeURL();
}
- (void)_recursiveStopLoading
@@ -285,13 +290,21 @@
_private->downloadPath = [path retain];
}
-
-// This method should only be called by haveContentPolicy in IFWebController
-// and should only be called once.
- (void) _setContentPolicy:(IFContentPolicy)policy
{
_private->contentPolicy = policy;
- [_private->mainURLHandleClient setContentPolicy:policy];
+}
+
+- (void)_setContentType:(NSString *)type
+{
+ [_private->contentType release];
+ _private->contentType = [type retain];
+}
+
+- (void)_setEncoding:(NSString *)encoding
+{
+ [_private->encoding release];
+ _private->encoding = [encoding retain];
}
- (IFWebDataSource *) _recursiveDataSourceForLocationChangeHandler:(id <IFLocationChangeHandler>)handler;
@@ -343,6 +356,43 @@
[_private->errors setObject: error forKey: resourceDescription];
}
+- (BOOL)_isDocumentHTML
+{
+ return [[[self representation] className] isEqualToString:@"IFHTMLRepresentation"];
+}
+
++ (NSMutableDictionary *)_repTypes
+{
+ if(!_repTypes){
+ _repTypes = [[NSMutableDictionary dictionary] retain];
+ [_repTypes setObject:[IFHTMLRepresentation class] forKey:@"text/html"];
+ [_repTypes setObject:[IFImageRepresentation class] forKey:@"image/jpeg"];
+ [_repTypes setObject:[IFImageRepresentation class] forKey:@"image/gif"];
+ [_repTypes setObject:[IFImageRepresentation class] forKey:@"image/png"];
+ [_repTypes setObject:[IFTextRepresentation class] forKey:@"text/"];
+ }
+ return _repTypes;
+}
++ (BOOL)_canShowMIMEType:(NSString *)MIMEType
+{
+ NSMutableDictionary *repTypes = [[self class] _repTypes];
+ NSArray *keys;
+ unsigned i;
+
+ if([repTypes objectForKey:MIMEType]){
+ return YES;
+ }else{
+ keys = [repTypes allKeys];
+ for(i=0; i<[keys count]; i++){
+ if([[keys objectAtIndex:i] hasSuffix:@"/"] && [MIMEType hasPrefix:[keys objectAtIndex:i]]){
+ if([repTypes objectForKey:[keys objectAtIndex:i]]){
+ return YES;
+ }
+ }
+ }
+ }
+ return NO;
+}
@end
diff --git a/WebKit/WebView.subproj/IFWebFrame.mm b/WebKit/WebView.subproj/IFWebFrame.mm
index e953671..9986904 100644
--- a/WebKit/WebView.subproj/IFWebFrame.mm
+++ b/WebKit/WebView.subproj/IFWebFrame.mm
@@ -12,7 +12,9 @@
#import <WebKit/IFWebControllerPrivate.h>
#import <WebKit/IFWebController.h>
#import <WebKit/IFLocationChangeHandler.h>
-#import <WebKit/IFDownloadHandler.h>
+#import <WebKit/IFHTMLView.h>
+#import <WebKit/IFHTMLViewPrivate.h>
+
#import <WebFoundation/WebFoundation.h>
#import <WebKit/WebKitDebug.h>
@@ -152,15 +154,8 @@
[_private setProvisionalDataSource: newDataSource];
- [[self view] provisionalDataSourceChanged: newDataSource];
-
- #ifdef OLD_WAY
- // This introduces a nasty dependency on the view.
- khtml::RenderPart *renderPartFrame = [self _renderFramePart];
- id view = [self view];
- if (renderPartFrame && [view isKindOfClass: NSClassFromString(@"IFWebView")])
- renderPartFrame->setWidget ([view _provisionalWidget]);
- #endif
+ //[[self view] provisionalDataSourceChanged: newDataSource];
+ //[[[self view] documentView] provisionalDataSourceChanged: newDataSource];
[self _setState: IFWEBFRAMESTATE_PROVISIONAL];
}
@@ -204,7 +199,8 @@
- (void)reset
{
[_private setDataSource: nil];
- [[_private view] _resetWidget];
+ if([[[self view] documentView] isKindOfClass: NSClassFromString(@"IFHTMLView")])
+ [[[self view] documentView] _resetWidget];
[_private setView: nil];
}
diff --git a/WebKit/WebView.subproj/IFWebFramePrivate.h b/WebKit/WebView.subproj/IFWebFramePrivate.h
index 5177e16..f8fb956 100644
--- a/WebKit/WebView.subproj/IFWebFramePrivate.h
+++ b/WebKit/WebView.subproj/IFWebFramePrivate.h
@@ -9,6 +9,7 @@
#import <WebKit/IFWebFrame.h>
@class IFWebView;
+ at protocol IFDocumentLoading;
namespace khtml {
class RenderPart;
diff --git a/WebKit/WebView.subproj/IFWebFramePrivate.mm b/WebKit/WebView.subproj/IFWebFramePrivate.mm
index 4364168..a4b628c 100644
--- a/WebKit/WebView.subproj/IFWebFramePrivate.mm
+++ b/WebKit/WebView.subproj/IFWebFramePrivate.mm
@@ -10,7 +10,9 @@
#import <WebKit/IFPreferencesPrivate.h>
#import <WebKit/IFWebController.h>
#import <WebKit/IFLocationChangeHandler.h>
-
+#import <WebKit/IFHTMLRepresentation.h>
+#import <WebKit/IFHTMLView.h>
+#import <WebKit/IFHTMLViewPrivate.h>
#import <WebKit/WebKitDebug.h>
#import <WebFoundation/IFError.h>
@@ -137,8 +139,10 @@ static const char * const stateNames[6] = {
if (_private->state == IFWEBFRAMESTATE_LAYOUT_ACCEPTABLE) {
if ([self controller])
WEBKITDEBUGLEVEL (WEBKIT_LOG_TIMING, "%s: performing timed layout, %f seconds since start of document load\n", [[self name] cString], CFAbsoluteTimeGetCurrent() - [[[[self controller] mainFrame] dataSource] _loadingStartedTime]);
- [[self view] setNeedsLayout: YES];
- [[self view] setNeedsDisplay: YES];
+
+ if([[[self view] documentView] isKindOfClass: NSClassFromString(@"IFHTMLView")])
+ [[[self view] documentView] setNeedsLayout: YES];
+ [[[self view] documentView] setNeedsDisplay: YES];
}
else {
if ([self controller])
@@ -199,36 +203,38 @@ static const char * const stateNames[6] = {
- (void)_transitionProvisionalToCommitted
{
WEBKIT_ASSERT ([self controller] != nil);
-
+ id documentView = [[self view] documentView];
+ BOOL isDocumentHTML = [[self view] isDocumentHTML];
+
switch ([self _state]) {
case IFWEBFRAMESTATE_PROVISIONAL:
{
- id view = [self view];
-
- WEBKIT_ASSERT (view != nil);
+ WEBKIT_ASSERT (documentView != nil);
- // Make sure any plugsin are shut down cleanly.
- [view _stopPlugins];
+ if(isDocumentHTML){
- // Remove any widgets.
- [view _removeSubviews];
+ // Make sure any plugsin are shut down cleanly.
+ [documentView _stopPlugins];
+
+ // Remove any widgets.
+ [documentView _removeSubviews];
+ }
// Set the committed data source on the frame.
[self _setDataSource: _private->provisionalDataSource];
+ // provisionalDataSourceCommitted: will reset the view and begin trying to
+ // display the new new datasource.
+ [documentView provisionalDataSourceCommitted: _private->provisionalDataSource];
+
// If we're a frame (not the main frame) hookup the kde internals. This introduces a nasty dependency
// in kde on the view.
khtml::RenderPart *renderPartFrame = [self _renderFramePart];
- if (renderPartFrame && [view isKindOfClass: NSClassFromString(@"IFWebView")]) {
+ if (renderPartFrame && isDocumentHTML) {
// Setting the widget will delete the previous KHTMLView associated with the frame.
- renderPartFrame->setWidget ([view _provisionalWidget]);
+ renderPartFrame->setWidget ([documentView _widget]);
}
-
- // dataSourceChanged: will reset the view and begin trying to
- // display the new new datasource.
- [view dataSourceChanged: _private->provisionalDataSource];
-
-
+
// Now that the provisional data source is committed, release it.
[_private setProvisionalDataSource: nil];
@@ -328,14 +334,19 @@ static const char * const stateNames[6] = {
[self _setState: IFWEBFRAMESTATE_COMPLETE];
- [ds _part]->end();
+ if([ds _isDocumentHTML])
+ [[ds representation] part]->end();
- // May need to relayout each time a frame is completely
- // loaded.
- [mainView setNeedsLayout: YES];
+ if ([mainView isDocumentHTML]){
+ // May need to relayout each time a frame is completely
+ // loaded.
+ [[mainView documentView] setNeedsLayout: YES];
+ }
- // Layout this view (eventually).
- [thisView setNeedsLayout: YES];
+ if ([thisView isDocumentHTML]){
+ // Layout this view (eventually).
+ [[thisView documentView] setNeedsLayout: YES];
+ }
// Draw this view (eventually), and it's scroll view
// (eventually).
@@ -345,15 +356,19 @@ static const char * const stateNames[6] = {
// Force a relayout and draw NOW if we are complete are the top level.
if ([[self controller] mainFrame] == self) {
- [mainView layout];
- [mainView display];
+ [[mainView documentView] layout];
+ [[mainView documentView] display];
}
// Jump to anchor point, if necessary.
- [ds _part]->impl->gotoBaseAnchor();
+ if ([ds _isDocumentHTML])
+ [[ds representation] part]->impl->gotoBaseAnchor();
[[ds _locationChangeHandler] locationChangeDone: [ds mainDocumentError]];
-
+
+ //if ([ds _isDocumentHTML])
+ // [[ds representation] part]->closeURL();
+
return;
}
// A resource was loaded, but the entire frame isn't complete. Schedule a
diff --git a/WebKit/WebView.subproj/IFWebView.h b/WebKit/WebView.subproj/IFWebView.h
index 933968c..85ef6e5 100644
--- a/WebKit/WebView.subproj/IFWebView.h
+++ b/WebKit/WebView.subproj/IFWebView.h
@@ -13,8 +13,8 @@
@class IFWebDataSource;
@class IFWebController;
-
@class IFWebViewPrivate;
+ at protocol IFDocumentLoading;
@interface IFWebView : NSView
{
@@ -22,72 +22,23 @@
IFWebViewPrivate *_private;
}
-- initWithFrame: (NSRect)frame;
+- initWithFrame: (NSRect) frame;
// Note that the controller is not retained.
- (IFWebController *)controller;
-// These methods is typically called by the view's controller when
-// the data source is changed.
-- (void)dataSourceChanged: (IFWebDataSource *)dataSource;
-- (void)provisionalDataSourceChanged: (IFWebDataSource *)dataSource;
-
-- (void)setNeedsLayout: (bool)flag;
-
-// This method should not be public until we have a more completely
-// understood way to subclass IFWebView.
-- (void)layout;
-
-// Set needsToApplyStyles if you change anything that might impact styles, like
-// font preferences.
-- (void)setNeedsToApplyStyles: (bool)flag;
-
-// Reapplies style information to the document. This should not be called directly,
-// instead call setNeedsToApplyStyles:.
-- (void)reapplyStyles;
-
-// Stop animating animated GIFs, etc.
-- (void)stopAnimations;
+- (id)documentView;
-// Drag and drop links and images. Others?
-- (void)setCanDragFrom: (BOOL)flag;
-- (BOOL)canDragFrom;
-- (void)setCanDragTo: (BOOL)flag;
-- (BOOL)canDragTo;
+- (BOOL) isDocumentHTML;
-// Returns an array of built-in context menu items for this node.
-// Generally called by IFContextMenuHandlers from contextMenuItemsForNode:
-#ifdef TENTATIVE_API
-- (NSArray *)defaultContextMenuItemsForNode: (IFDOMNode *);
-#endif
-- (void)setContextMenusEnabled: (BOOL)flag;
-- (BOOL)contextMenusEnabled;
+- (void)setAllowsScrolling: (BOOL)flag;
+- (BOOL)allowsScrolling;
-// Remove the selection.
-- (void)deselectText;
+// Extends the views that WebKit supports
+// The view must conform to the IFDocumentLoading protocol
++ (void)registerViewClass:(Class)viewClass forMIMEType:(NSString *)MIMEType;
-// Search from the end of the currently selected location, or from the beginning of the document if nothing
-// is selected.
-- (void)searchFor: (NSString *)string direction: (BOOL)forward caseSensitive: (BOOL)caseFlag;
-
-// Get an attributed string that represents the current selection.
-- (NSAttributedString *)selectedText;
+// Called when the contentPolicy is set to IFContentPolicyShow
++ (id <IFDocumentLoading>) createViewForMIMEType:(NSString *)MIMEType;
@end
-
-/*
- Areas still to consider:
-
- ALT image text and link URLs
- Should this be built-in? or able to be overriden?
-
- node events
-
- client access to form elements for auto-completion, passwords
-
- selection
- Selection on data source is reflected in view.
- Does the view also need a cover selection API?
-
- subclassing of IFWebView
-*/
diff --git a/WebKit/WebView.subproj/IFWebView.mm b/WebKit/WebView.subproj/IFWebView.mm
index a2b43d7..88ff4a8 100644
--- a/WebKit/WebView.subproj/IFWebView.mm
+++ b/WebKit/WebView.subproj/IFWebView.mm
@@ -1,55 +1,26 @@
/* IFWebView.mm
Copyright 2001, Apple, Inc. All rights reserved.
*/
+#import <WebKit/IFDynamicScrollBarsView.h>
+#import <WebKit/IFHTMLView.h>
+#import <WebKit/IFImageView.h>
+#import <WebKit/IFTextView.h>
#import <WebKit/IFWebView.h>
#import <WebKit/IFWebViewPrivate.h>
-#import <WebKit/IFWebFrame.h>
-#import <WebKit/IFWebDataSource.h>
-#import <WebKit/IFWebDataSourcePrivate.h>
-#import <WebKit/IFWebController.h>
-#import <WebKit/IFDynamicScrollBarsView.h>
-#import <WebKit/IFException.h>
-#import <WebKit/IFWebCoreViewFactory.h>
-#import <WebKit/IFTextRendererFactory.h>
-#import <WebKit/IFImageRendererFactory.h>
-#import <WebKit/WebKitDebug.h>
-
-#import <WebFoundation/IFNSStringExtensions.h>
-
-// Needed for the mouse move notification.
-#import <AppKit/NSResponder_Private.h>
-
-// KDE related includes
-#import <khtmlview.h>
-#import <qwidget.h>
-#import <qpainter.h>
-#import <qevent.h>
-#import <html/html_documentimpl.h>
-
-#import <KWQKHTMLPartImpl.h>
@implementation IFWebView
- initWithFrame: (NSRect) frame
{
[super initWithFrame: frame];
-
- [IFWebCoreViewFactory createSharedFactory];
- [IFTextRendererFactory createSharedFactory];
- [IFImageRendererFactory createSharedFactory];
_private = [[IFWebViewPrivate alloc] init];
- _private->isFlipped = YES;
- _private->needsLayout = YES;
-
- _private->canDragTo = YES;
- _private->canDragFrom = YES;
- _private->draggingTypes = [[NSArray arrayWithObjects:@"NSFilenamesPboardType", @"NSURLPboardType", @"NSStringPboardType", nil] retain];
- [self registerForDraggedTypes:_private->draggingTypes];
-
- [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(windowResized:) name: NSWindowDidResizeNotification object: nil];
- [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(mouseMovedNotification:) name: NSMouseMovedNotification object: nil];
+ IFDynamicScrollBarsView *scrollView = [[IFDynamicScrollBarsView alloc] initWithFrame: NSMakeRect(0,0,0,0)];
+ [scrollView setHasVerticalScroller: NO];
+ [scrollView setHasHorizontalScroller: NO];
+ [self _setFrameScrollView: scrollView];
+ [scrollView release];
return self;
}
@@ -57,560 +28,67 @@
- (void)dealloc
{
- [self _stopPlugins];
- [[NSNotificationCenter defaultCenter] removeObserver: self];
[_private release];
[super dealloc];
}
-
-- (BOOL)acceptsFirstResponder
-{
- return YES;
-}
-
-
-// Note that the controller is not retained.
-- (IFWebController *)controller
-{
- return _private->controller;
-}
-
-
-- (void)removeFromSuperview
-{
- [self _stopPlugins];
- [super removeFromSuperview];
-}
-
-
-- (void)removeFromSuperviewWithoutNeedingDisplay
-{
- [self _stopPlugins];
- [super removeFromSuperviewWithoutNeedingDisplay];
-}
-
-
-// This method is typically called by the view's controller when
-// the data source is changed.
-- (void)provisionalDataSourceChanged: (IFWebDataSource *)dataSource
-{
- NSRect r = [self frame];
- IFWebView *provisionalView;
-
- // Nasty! Setup the cross references between the KHTMLView and
- // the KHTMLPart.
- KHTMLPart *part = [dataSource _part];
-
- _private->provisionalWidget = new KHTMLView (part, 0);
- part->impl->setView (_private->provisionalWidget);
-
- // Create a temporary provisional view. It will be replaced with
- // the actual view once the datasource has been committed.
- provisionalView = [[IFWebView alloc] initWithFrame: NSMakeRect (0,0,0,0)];
- _private->provisionalWidget->setView (provisionalView);
- [provisionalView release];
-
- _private->provisionalWidget->resize ((int)r.size.width, (int)r.size.height);
-}
-
-- (void)dataSourceChanged: (IFWebDataSource *)dataSource
-{
- IFWebViewPrivate *data = _private;
-
- // Setup the real view.
- if ([self _frameScrollView])
- data->provisionalWidget->setView ([self _frameScrollView]);
- else
- data->provisionalWidget->setView (self);
-
- // Only delete the widget if we're the top level widget. In other
- // cases the widget is associated with a RenderFrame which will
- // delete it's widget.
- if ([dataSource isMainDocument] && data->widget)
- delete data->widget;
-
- data->widget = data->provisionalWidget;
- data->provisionalWidget = 0;
-}
-
-- (void)reapplyStyles
-{
- KHTMLView *widget = _private->widget;
-
- if (widget->part()->xmlDocImpl() &&
- widget->part()->xmlDocImpl()->renderer()){
- if (_private->needsToApplyStyles){
-#ifdef _KWQ_TIMING
- double start = CFAbsoluteTimeGetCurrent();
-#endif
- widget->part()->xmlDocImpl()->updateStyleSelector();
- _private->needsToApplyStyles = NO;
-#ifdef _KWQ_TIMING
- double thisTime = CFAbsoluteTimeGetCurrent() - start;
- WEBKITDEBUGLEVEL (WEBKIT_LOG_TIMING, "%s apply style seconds = %f\n", widget->part()->baseURL().url().latin1(), thisTime);
-#endif
- }
- }
-
-}
-
-
-// This method should not be public until we have more completely
-// understood how IFWebView will be subclassed.
-- (void)layout
+- (void)setAllowsScrolling: (BOOL)flag
{
- KHTMLView *widget = _private->widget;
-
-
- // Ensure that we will receive mouse move events. Is this the best place to put this?
- [[self window] setAcceptsMouseMovedEvents: YES];
- [[self window] _setShouldPostEventNotifications: YES];
-
- if (widget->part()->xmlDocImpl() &&
- widget->part()->xmlDocImpl()->renderer()){
- if (_private->needsLayout){
-#ifdef _KWQ_TIMING
- double start = CFAbsoluteTimeGetCurrent();
-#endif
-
- WEBKITDEBUGLEVEL (WEBKIT_LOG_VIEW, "doing layout\n");
- //double start = CFAbsoluteTimeGetCurrent();
- widget->layout();
- //WebKitDebugAtLevel (WEBKIT_LOG_TIMING, "layout time %e\n", CFAbsoluteTimeGetCurrent() - start);
- _private->needsLayout = NO;
-#ifdef _KWQ_TIMING
- double thisTime = CFAbsoluteTimeGetCurrent() - start;
- WEBKITDEBUGLEVEL (WEBKIT_LOG_TIMING, "%s layout seconds = %f\n", widget->part()->baseURL().url().latin1(), thisTime);
-#endif
- }
- }
-
+ _private->allowsScrolling = flag;
}
-
-// Stop animating animated GIFs, etc.
-- (void)stopAnimations
+- (BOOL)allowsScrolling
{
- [NSException raise:IFMethodNotYetImplemented format:@"IFWebView::stopAnimations is not implemented"];
+ return _private->allowsScrolling;
}
-// Drag and drop links and images. Others?
-- (void)setCanDragFrom: (BOOL)flag
+- (id)documentView
{
- _private->canDragFrom = flag;
+ return _private->documentView;
}
-- (BOOL)canDragFrom
+// Note that the controller is not retained.
+- (IFWebController *)controller
{
- return _private->canDragFrom;
+ return _private->controller;
}
-- (void)setCanDragTo: (BOOL)flag
-{
- _private->canDragTo = flag;
-}
-- (BOOL)canDragTo
+- (BOOL) isDocumentHTML
{
- return _private->canDragTo;
+ return [[[self documentView] className] isEqualToString:@"IFHTMLView"];
}
-- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
++ (void) registerViewClass:(Class)viewClass forMIMEType:(NSString *)MIMEType
{
- NSString *dragType, *file, *URLString;
- NSArray *files;
-
- if(![self canDragTo])
- return NSDragOperationNone;
-
- dragType = [[sender draggingPasteboard] availableTypeFromArray:_private->draggingTypes];
- if([dragType isEqualToString:@"NSFilenamesPboardType"]){
- files = [[sender draggingPasteboard] propertyListForType:@"NSFilenamesPboardType"];
-
- // FIXME: We only look at the first dragged file (2931225)
- file = [files objectAtIndex:0];
+ NSMutableDictionary *viewTypes = [[self class] _viewTypes];
- // FIXME: Need the file type database to know what files we handle (2927855)
- if([[file pathExtension] isEqualToString:@"html"] || [[file pathExtension] isEqualToString:@"htm"])
- return NSDragOperationCopy;
- }else if([dragType isEqualToString:@"NSURLPboardType"]){
- return NSDragOperationCopy;
- }else if([dragType isEqualToString:@"NSStringPboardType"]){
- URLString = [[sender draggingPasteboard] stringForType:@"NSStringPboardType"];
- if([URLString _IF_looksLikeAbsoluteURL])
- return NSDragOperationCopy;
- }
- return NSDragOperationNone;
-}
-
-- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
-{
- return YES;
+ // FIXME: OK to allow developers to override built-in views?
+ [viewTypes setObject:viewClass forKey:MIMEType];
}
-- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
++ (id <IFDocumentLoading>) createViewForMIMEType:(NSString *)MIMEType
{
- IFWebDataSource *dataSource;
- IFWebFrame *frame;
- NSArray *files;
- NSString *file, *dragType;
- NSURL *URL=nil;
+ NSMutableDictionary *viewTypes = [[self class] _viewTypes];
+ Class viewClass;
+ NSArray *keys;
+ unsigned i;
- dragType = [[sender draggingPasteboard] availableTypeFromArray:_private->draggingTypes];
- if([dragType isEqualToString:@"NSFilenamesPboardType"]){
- files = [[sender draggingPasteboard] propertyListForType:@"NSFilenamesPboardType"];
- file = [files objectAtIndex:0];
- URL = [NSURL fileURLWithPath:file];
- }else if([dragType isEqualToString:@"NSURLPboardType"]){
- // FIXME: Is this the right way to get the URL? How to test?
- URL = [NSURL URLWithString:[[sender draggingPasteboard] stringForType:@"NSURLPboardType"]];
- }else if([dragType isEqualToString:@"NSStringPboardType"]){
- URL = [NSURL URLWithString:[[sender draggingPasteboard] stringForType:@"NSStringPboardType"]];
+ viewClass = [viewTypes objectForKey:MIMEType];
+ if(viewClass){
+ return [[[viewClass alloc] initWithFrame:NSMakeRect(0,0,0,0)] autorelease];
+ }else{
+ keys = [viewTypes allKeys];
+ for(i=0; i<[keys count]; i++){
+ if([[keys objectAtIndex:i] hasSuffix:@"/"] && [MIMEType hasPrefix:[keys objectAtIndex:i]]){
+ viewClass = [viewTypes objectForKey:[keys objectAtIndex:i]];
+ return [[[viewClass alloc] initWithFrame:NSMakeRect(0,0,0,0)] autorelease];
+ }
+ }
}
-
- if(!URL)
- return NO;
-
- dataSource = [[[IFWebDataSource alloc] initWithURL:URL] autorelease];
- frame = [[self controller] frameForView:self];
- [frame setProvisionalDataSource:dataSource];
- [frame startLoading];
-
- return YES;
-}
-
-// Returns an array of built-in context menu items for this node.
-// Generally called by IFContextMenuHandlers from contextMenuItemsForNode:
-#ifdef TENTATIVE_API
-- (NSArray *)defaultContextMenuItemsForNode: (IFDOMNode *)
-{
- [NSException raise:IFMethodNotYetImplemented format:@"IFWebView::defaultContextMenuItemsForNode: is not implemented"];
return nil;
}
-#endif
-
-- (void)setContextMenusEnabled: (BOOL)flag
-{
- [NSException raise:IFMethodNotYetImplemented format:@"IFWebView::setContextMenusEnabled: is not implemented"];
-}
-
-
-- (BOOL)contextMenusEnabled;
-{
- return NO;
-}
-
-
-// Remove the selection.
-- (void)deselectText
-{
- [NSException raise:IFMethodNotYetImplemented format:@"IFWebView::deselectText: is not implemented"];
-}
-
-// Search from the end of the currently selected location, or from the beginning of the document if nothing
-// is selected.
-- (void)searchFor: (NSString *)string direction: (BOOL)forward caseSensitive: (BOOL)caseFlag
-{
- [NSException raise:IFMethodNotYetImplemented format:@"IFWebView::searchFor:direction:caseSensitive: is not implemented"];
-}
-
-
-// Get an attributed string that represents the current selection.
-- (NSAttributedString *)selectedText
-{
- [NSException raise:IFMethodNotYetImplemented format:@"IFWebView::selectedText is not implemented"];
- return nil;
-}
-
-
-- (BOOL)isOpaque
-{
- return YES;
-}
-
-
-#ifdef DELAY_LAYOUT
-- delayLayout: sender
-{
- [NSObject cancelPreviousPerformRequestsWithTarget: self selector: @selector(delayLayout:) object: self];
- WEBKITDEBUG("KWQHTMLView: delayLayout called\n");
- [self setNeedsLayout: YES];
- [self setNeedsDisplay: YES];
-}
-
--(void)notificationReceived:(NSNotification *)notification
-{
- if ([[notification name] rangeOfString: @"uri-fin-"].location == 0){
- WEBKITDEBUG1("KWQHTMLView: Received notification, %s\n", DEBUG_OBJECT([notification name]));
- [self performSelector:@selector(delayLayout:) withObject:self afterDelay:(NSTimeInterval)0.5];
- }
-}
-#else
--(void)notificationReceived:(NSNotification *)notification
-{
- if ([[notification name] rangeOfString: @"uri-fin-"].location == 0){
- [self setNeedsLayout: YES];
- [self setNeedsDisplay: YES];
- }
-}
-#endif
-
-- (void)setNeedsDisplay:(BOOL)flag
-{
- WEBKITDEBUGLEVEL (WEBKIT_LOG_VIEW, "flag = %d\n", (int)flag);
- [super setNeedsDisplay: flag];
-}
-
-
-- (void)setNeedsLayout: (bool)flag
-{
- WEBKITDEBUGLEVEL (WEBKIT_LOG_VIEW, "flag = %d\n", (int)flag);
- _private->needsLayout = flag;
-}
-
-
-- (void)setNeedsToApplyStyles: (bool)flag
-{
- WEBKITDEBUGLEVEL (WEBKIT_LOG_VIEW, "flag = %d\n", (int)flag);
- _private->needsToApplyStyles = flag;
-}
-
-
-// This should eventually be removed.
-- (void)drawRect:(NSRect)rect {
- KHTMLView *widget = _private->widget;
- //IFWebViewPrivate *data = _private;
-
- //if (data->provisionalWidget != 0){
- // WEBKITDEBUGLEVEL (WEBKIT_LOG_VIEW, "not drawing, frame in provisional state.\n");
- // return;
- //}
-
- // Draw plain white bg in empty case, to avoid redraw weirdness when
- // no page is yet loaded (2890818). We may need to modify this to always
- // draw the background color, in which case we'll have to make sure the
- // no-widget case is still handled correctly.
- if (widget == 0l) {
- [[NSColor whiteColor] set];
- NSRectFill(rect);
- return;
- }
-
- WEBKITDEBUGLEVEL (WEBKIT_LOG_VIEW, "drawing\n");
-
- [self reapplyStyles];
-
- [self layout];
-
-#ifdef _KWQ_TIMING
- double start = CFAbsoluteTimeGetCurrent();
-#endif
- QPainter p(widget);
-
- [self lockFocus];
-
- //double start = CFAbsoluteTimeGetCurrent();
- widget->drawContents( &p, (int)rect.origin.x,
- (int)rect.origin.y,
- (int)rect.size.width,
- (int)rect.size.height );
- //WebKitDebugAtLevel (WEBKIT_LOG_TIMING, "draw time %e\n", CFAbsoluteTimeGetCurrent() - start);
-
-#ifdef DEBUG_LAYOUT
- NSRect vframe = [self frame];
- [[NSColor blackColor] set];
- NSBezierPath *path;
- path = [NSBezierPath bezierPath];
- [path setLineWidth:(float)0.1];
- [path moveToPoint:NSMakePoint(0, 0)];
- [path lineToPoint:NSMakePoint(vframe.size.width, vframe.size.height)];
- [path closePath];
- [path stroke];
- path = [NSBezierPath bezierPath];
- [path setLineWidth:(float)0.1];
- [path moveToPoint:NSMakePoint(0, vframe.size.height)];
- [path lineToPoint:NSMakePoint(vframe.size.width, 0)];
- [path closePath];
- [path stroke];
-#endif
-
- [self unlockFocus];
-
-#ifdef _KWQ_TIMING
- double thisTime = CFAbsoluteTimeGetCurrent() - start;
- WEBKITDEBUGLEVEL (WEBKIT_LOG_TIMING, "%s draw seconds = %f\n", widget->part()->baseURL().url().latin1(), thisTime);
-#endif
-}
-
-- (void)setIsFlipped: (bool)flag
-{
- _private->isFlipped = flag;
-}
-
-
-- (BOOL)isFlipped
-{
- return _private->isFlipped;
-}
-
-
-- (void)windowResized: (NSNotification *)notification
-{
- if ([notification object] == [self window])
- [self setNeedsLayout: YES];
-}
-
-- (void)_addModifiers:(unsigned)modifiers toState:(int *)state
-{
- if (modifiers & NSControlKeyMask)
- *state |= Qt::ControlButton;
- if (modifiers & NSShiftKeyMask)
- *state |= Qt::ShiftButton;
- if (modifiers & NSAlternateKeyMask)
- *state |= Qt::AltButton;
- // Mapping command to meta is slightly questionable
- if (modifiers & NSCommandKeyMask)
- *state |= Qt::MetaButton;
-}
-
-- (void)mouseUp: (NSEvent *)event
-{
- int button, state;
-
- if ([event type] == NSLeftMouseUp){
- button = Qt::LeftButton;
- state = Qt::LeftButton;
- }
- else if ([event type] == NSRightMouseUp){
- button = Qt::RightButton;
- state = Qt::RightButton;
- }
- else if ([event type] == NSOtherMouseUp){
- button = Qt::MidButton;
- state = Qt::MidButton;
- }
- else {
- [NSException raise:IFRuntimeError format:@"IFWebView::mouseUp: unknown button type"];
- button = 0; state = 0; // Shutup the compiler.
- }
- NSPoint p = [event locationInWindow];
-
- [self _addModifiers:[event modifierFlags] toState:&state];
-
- QMouseEvent kEvent(QEvent::MouseButtonPress, QPoint((int)p.x, (int)p.y), button, state);
- KHTMLView *widget = _private->widget;
- if (widget != 0l) {
- widget->viewportMouseReleaseEvent(&kEvent);
- }
-}
-
-- (void)mouseDown: (NSEvent *)event
-{
- int button, state;
-
- if ([event type] == NSLeftMouseDown){
- button = Qt::LeftButton;
- state = Qt::LeftButton;
- }
- else if ([event type] == NSRightMouseDown){
- button = Qt::RightButton;
- state = Qt::RightButton;
- }
- else if ([event type] == NSOtherMouseDown){
- button = Qt::MidButton;
- state = Qt::MidButton;
- }
- else {
- [NSException raise:IFRuntimeError format:@"IFWebView::mouseDown: unknown button type"];
- button = 0; state = 0; // Shutup the compiler.
- }
- NSPoint p = [event locationInWindow];
-
- [self _addModifiers:[event modifierFlags] toState:&state];
-
- QMouseEvent kEvent(QEvent::MouseButtonPress, QPoint((int)p.x, (int)p.y), button, state);
- KHTMLView *widget = _private->widget;
- if (widget != 0l) {
- widget->viewportMousePressEvent(&kEvent);
- }
-}
-
-- (void)mouseMovedNotification: (NSNotification *)notification
-{
- NSEvent *event = [(NSDictionary *)[notification userInfo] objectForKey: @"NSEvent"];
- NSPoint p = [event locationInWindow];
-
- // Only act on the mouse move event if it's inside this view (and
- // not inside a subview)
- if ([[[self window] contentView] hitTest:p] == self) {
- QMouseEvent kEvent(QEvent::MouseButtonPress, QPoint((int)p.x, (int)p.y), 0, 0);
- KHTMLView *widget = _private->widget;
- if (widget != 0l) {
- widget->viewportMouseMoveEvent(&kEvent);
- }
- }
-}
-
-- (void)mouseDragged: (NSEvent *)event
-{
- NSPoint p = [event locationInWindow];
- //WebKitDebugAtLevel (WEBKIT_LOG_EVENTS, "mouseDragged %f, %f\n", p.x, p.y);
-}
-
-- (void)keyDown: (NSEvent *)event
-{
- WEBKITDEBUGLEVEL(WEBKIT_LOG_EVENTS, "keyDown: %s\n", DEBUG_OBJECT(event));
- int state = 0;
-
- [self _addModifiers:[event modifierFlags] toState:&state];
- QKeyEvent kEvent(QEvent::KeyPress, 0, 0, state, NSSTRING_TO_QSTRING([event characters]), [event isARepeat], 1);
-
- KHTMLView *widget = _private->widget;
- if (widget != 0l)
- widget->keyPressEvent(&kEvent);
-}
-
-
-- (void)keyUp: (NSEvent *)event
-{
- WEBKITDEBUGLEVEL(WEBKIT_LOG_EVENTS, "keyUp: %s\n", DEBUG_OBJECT(event));
- int state = 0;
-
- [self _addModifiers:[event modifierFlags] toState:&state];
- QKeyEvent kEvent(QEvent::KeyPress, 0, 0, state, NSSTRING_TO_QSTRING([event characters]), [event isARepeat], 1);
-
- KHTMLView *widget = _private->widget;
- if (widget != 0l)
- widget->keyReleaseEvent(&kEvent);
-}
-
-- (void)setCursor:(NSCursor *)cursor
-{
- [_private->cursor release];
- _private->cursor = [cursor retain];
-
- // We have to make both of these calls, because:
- // - Just setting a cursor rect will have no effect, if the mouse cursor is already
- // inside the area of the rect.
- // - Just calling invalidateCursorRectsForView will not call resetCursorRects if
- // there is no cursor rect set currently and the view has no subviews.
- // Therefore we have to call resetCursorRects to ensure that a cursor rect is set
- // at all, if we are going to want one, and then invalidateCursorRectsForView: to
- // call resetCursorRects from the proper context that will
- // actually result in updating the cursor.
- [self resetCursorRects];
- [[self window] invalidateCursorRectsForView:self];
-}
-
-- (void)resetCursorRects
-{
- if (_private->cursor != nil && _private->cursor != [NSCursor arrowCursor]) {
- [self addCursorRect:[self visibleRect] cursor:_private->cursor];
- }
-}
-
@end
diff --git a/WebKit/WebView.subproj/IFWebViewPrivate.h b/WebKit/WebView.subproj/IFWebViewPrivate.h
index 33764e4..db43810 100644
--- a/WebKit/WebView.subproj/IFWebViewPrivate.h
+++ b/WebKit/WebView.subproj/IFWebViewPrivate.h
@@ -9,34 +9,33 @@
#import <WebKit/IFWebView.h>
class QWidget;
-class KHTMLPart;
-class KHTMLView;
+
@interface IFWebViewPrivate : NSObject
{
IFWebController *controller;
- KHTMLView *widget;
- KHTMLView *provisionalWidget;
+ id documentView;
NSScrollView *frameScrollView;
- bool isFlipped;
- bool needsLayout;
- bool needsToApplyStyles;
- bool canDragTo;
- bool canDragFrom;
- NSArray *draggingTypes;
- NSCursor *cursor;
+
+ // These margin values are used to temporarily hold
+ // the margins of a frame until we have the appropriate
+ // document view type.
+ int marginWidth;
+ int marginHeight;
+
+ BOOL allowsScrolling;
}
@end
@interface IFWebView (IFPrivate)
+- (void)_setDocumentView:(id <IFDocumentLoading>)view;
- (void)_setController: (IFWebController *)controller;
-- (void)_resetWidget;
-- (KHTMLView *)_widget;
-- (KHTMLView *)_provisionalWidget;
-- (void)_stopPlugins;
-- (void)_removeSubviews;
- (void)_setFrameScrollView: (NSScrollView *)sv;
- (NSScrollView *)_frameScrollView;
- (void)_setupScrollers;
+- (int)_marginWidth;
+- (int)_marginHeight;
++ (NSMutableDictionary *)_viewTypes;
++ (BOOL)_canShowMIMEType:(NSString *)MIMEType;
@end
diff --git a/WebKit/WebView.subproj/IFWebViewPrivate.mm b/WebKit/WebView.subproj/IFWebViewPrivate.mm
index eee7488..1d75df0 100644
--- a/WebKit/WebView.subproj/IFWebViewPrivate.mm
+++ b/WebKit/WebView.subproj/IFWebViewPrivate.mm
@@ -6,28 +6,31 @@
NSWebPageView.
*/
#import <WebKit/WebKitDebug.h>
-
+#import <WebKit/IFDynamicScrollBarsView.h>
#import <WebKit/IFWebViewPrivate.h>
-#import <WebKit/IFPluginView.h>
+#import <WebKit/IFWebController.h>
+#import <WebKit/IFHTMLView.h>
+#import <WebKit/IFImageView.h>
+#import <WebKit/IFTextView.h>
-// Includes from KDE
-#import <khtmlview.h>
-#import <khtml_part.h>
-#import <html/html_documentimpl.h>
-#import "IFWebController.h"
+static NSMutableDictionary *_viewTypes=nil;
@implementation IFWebViewPrivate
+- init
+{
+ [super init];
+
+ marginWidth = -1;
+ marginHeight = -1;
+
+ return self;
+}
+
- (void)dealloc
{
- [controller release];
[frameScrollView release];
- [draggingTypes release];
- [cursor release];
-
- //if (widget)
- // delete widget;
-
+ [documentView release];
[super dealloc];
}
@@ -35,48 +38,43 @@
@implementation IFWebView (IFPrivate)
-- (void)_resetWidget
+- (void)_setMarginWidth: (int)w
{
- delete _private->widget;
- _private->widget = 0;
+ _private->marginWidth = w;
}
-- (void)_stopPlugins
+- (int)_marginWidth
{
- NSArray *subviews = [[self subviews] copy];
- int count = [subviews count];
- while (count--) {
- id view = [subviews objectAtIndex:count];
- if ([view isKindOfClass:[IFPluginView class]]) {
- IFPluginView *pluginView = (IFPluginView *)view;
- [pluginView stop];
- }
- }
- [subviews release];
+ return _private->marginWidth;
}
-- (void)_removeSubviews
+- (void)_setMarginHeight: (int)h
{
- // Remove all the views. They will be be re-added if this is a re-layout.
- NSArray *subviews = [[self subviews] copy];
- [subviews makeObjectsPerformSelector:@selector(removeFromSuperviewWithoutNeedingDisplay)];
- [subviews release];
+ _private->marginHeight = h;
}
-- (void)_setController: (IFWebController *)controller
+- (int)_marginHeight
{
- // Not retained; the controller owns the view.
- _private->controller = controller;
+ return _private->marginHeight;
}
-- (KHTMLView *)_widget
+- (void)_setDocumentView:(id)view
{
- return _private->widget;
+ [[self _frameScrollView] setDocumentView: view];
+
+ // Set the size of the new document scroll view to the size
+ // of the IFWebView.
+ [[self _frameScrollView] setFrame:[self frame]];
+
+ [view retain];
+ [_private->documentView release];
+ _private->documentView = view;
}
-- (KHTMLView *)_provisionalWidget
+- (void)_setController: (IFWebController *)controller
{
- return _private->provisionalWidget;
+ // Not retained; the controller owns the view.
+ _private->controller = controller;
}
- (void)_setFrameScrollView: (NSScrollView *)sv
@@ -84,11 +82,8 @@
[sv retain];
[_private->frameScrollView release];
_private->frameScrollView = sv;
- //[sv setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
- //[sv setHasVerticalScroller: YES];
- //[sv setHasHorizontalScroller: YES];
- [self setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
- [sv setDocumentView: self];
+ [sv setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
+ [self addSubview: sv];
}
- (NSScrollView *)_frameScrollView
@@ -110,4 +105,38 @@
}
}
++ (NSMutableDictionary *)_viewTypes
+{
+ if(!_viewTypes){
+ _viewTypes = [[NSMutableDictionary dictionary] retain];
+ [_viewTypes setObject:[IFHTMLView class] forKey:@"text/html"];
+ [_viewTypes setObject:[IFTextView class] forKey:@"text/"];
+ [_viewTypes setObject:[IFImageView class] forKey:@"image/jpeg"];
+ [_viewTypes setObject:[IFImageView class] forKey:@"image/gif"];
+ [_viewTypes setObject:[IFImageView class] forKey:@"image/png"];
+ }
+ return _viewTypes;
+}
+
++ (BOOL)_canShowMIMEType:(NSString *)MIMEType
+{
+ NSMutableDictionary *viewTypes = [[self class] _viewTypes];
+ NSArray *keys;
+ unsigned i;
+
+ if([viewTypes objectForKey:MIMEType]){
+ return YES;
+ }else{
+ keys = [viewTypes allKeys];
+ for(i=0; i<[keys count]; i++){
+ if([[keys objectAtIndex:i] hasSuffix:@"/"] && [MIMEType hasPrefix:[keys objectAtIndex:i]]){
+ if([viewTypes objectForKey:[keys objectAtIndex:i]]){
+ return YES;
+ }
+ }
+ }
+ }
+ return NO;
+}
+
@end
diff --git a/WebKit/WebView.subproj/WebController.h b/WebKit/WebView.subproj/WebController.h
index e48022f..f8312d5 100644
--- a/WebKit/WebView.subproj/WebController.h
+++ b/WebKit/WebView.subproj/WebController.h
@@ -37,6 +37,8 @@
@class IFWebController;
@class IFWebControllerPrivate;
+ at protocol IFDocumentLoading;
+
/*
=============================================================================
@@ -106,14 +108,6 @@ typedef enum {
IFWebControllerPrivate *_private;
}
-/*
-// Called when the content policy is set to IFContentPolicyShow
-+ (id <IFDocumentView>) createViewForMIMEType:(NSString *)MIMEType
-
-// registerClass extends the views that WebKit supports
-+ (void) registerClass:(Class)class forMIMEType:(NSString *)MIMEType
-*/
-
// Calls designated initializer with nil arguments.
- init;
@@ -176,5 +170,6 @@ typedef enum {
- (void)stopAnimatedImageLooping;
- (void)startAnimatedImageLooping;
++ (BOOL)canShowMIMEType:(NSString *)MIMEType;
@end
diff --git a/WebKit/WebView.subproj/WebController.m b/WebKit/WebView.subproj/WebController.m
index 8f01fb4..4155631 100644
--- a/WebKit/WebView.subproj/WebController.m
+++ b/WebKit/WebView.subproj/WebController.m
@@ -3,14 +3,16 @@
Copyright 2001, 2002 Apple, Inc. All rights reserved.
*/
+#import <WebKit/IFDocument.h>
+#import <WebKit/IFDynamicScrollBarsView.h>
+#import <WebKit/IFException.h>
+#import <WebKit/IFPluginDatabase.h>
#import <WebKit/IFWebController.h>
#import <WebKit/IFWebControllerPrivate.h>
#import <WebKit/IFWebViewPrivate.h>
#import <WebKit/IFWebDataSourcePrivate.h>
#import <WebKit/IFWebFrame.h>
#import <WebKit/IFWebFramePrivate.h>
-#import <WebKit/IFDynamicScrollBarsView.h>
-#import <WebKit/IFException.h>
#import <WebKit/IFWebController.h>
#import <WebKit/WebKitDebug.h>
@@ -18,18 +20,6 @@
@implementation IFWebController
-/*
-+ (id <IFDocumentView>) createViewForMIMEType:(NSString *)MIMEType
-{
- return nil;
-}
-
-+ (void) registerClass:(Class)class forMIMEType:(NSString *)MIMEType
-{
-
-}
-*/
-
- init
{
return [self initWithView: nil provisionalDataSource: nil];
@@ -66,7 +56,6 @@
{
IFWebView *childView;
IFWebFrame *newFrame;
- NSScrollView *scrollView;
childView = [[[IFWebView alloc] initWithFrame: NSMakeRect (0,0,0,0)] autorelease];
@@ -77,12 +66,7 @@
[childView _setController: self];
[childDataSource _setController: self];
- if (inScrollView == YES){
- scrollView = [[[IFDynamicScrollBarsView alloc] initWithFrame: NSMakeRect(0,0,0,0)] autorelease];
- [scrollView setHasVerticalScroller: NO];
- [scrollView setHasHorizontalScroller: NO];
- [childView _setFrameScrollView: scrollView];
- }
+ [childView setAllowsScrolling: inScrollView];
return newFrame;
}
@@ -262,6 +246,7 @@
- (void)haveContentPolicy: (IFContentPolicy)policy andPath: (NSString *)path forLocationChangeHandler: (id <IFLocationChangeHandler>)handler
{
IFWebDataSource *mainDataSource, *mainProvisionalDataSource, *dataSource;
+ NSString *MIMEType;
if(policy == IFContentPolicyNone)
[NSException raise:NSInvalidArgumentException format:@"Can't set policy of IFContentPolicyNone. Use IFContentPolicyIgnore instead"];
@@ -279,6 +264,24 @@
}else{
[dataSource _setContentPolicy:policy];
[dataSource _setDownloadPath:path];
+
+ if(policy == IFContentPolicyShow){
+ MIMEType = [dataSource contentType];
+ if([[self class] canShowMIMEType:MIMEType]){
+ id documentView;
+ IFWebView *webView;
+ id <IFDocumentRepresentation> dataRepresentation;
+
+ dataRepresentation = [IFWebDataSource createRepresentationForMIMEType:MIMEType];
+ [dataSource _setRepresentation:dataRepresentation];
+ webView = [[dataSource webFrame] view];
+ documentView = [IFWebView createViewForMIMEType:MIMEType];
+ [webView _setDocumentView: documentView];
+ [documentView provisionalDataSourceChanged: dataSource];
+ }else{
+ // return error with unableToImplementContentPolicy
+ }
+ }
}
}
}
@@ -299,4 +302,17 @@
{
}
++ (BOOL)canShowMIMEType:(NSString *)MIMEType
+{
+ if([IFWebView _canShowMIMEType:MIMEType] && [IFWebDataSource _canShowMIMEType:MIMEType]){
+ return YES;
+ }else{
+ // Have the plug-ins register views
+ [IFPluginDatabase installedPlugins];
+ if([IFWebView _canShowMIMEType:MIMEType] && [IFWebDataSource _canShowMIMEType:MIMEType])
+ return YES;
+ }
+ return NO;
+}
+
@end
diff --git a/WebKit/WebView.subproj/WebControllerPrivate.h b/WebKit/WebView.subproj/WebControllerPrivate.h
index a169cee..bf07746 100644
--- a/WebKit/WebView.subproj/WebControllerPrivate.h
+++ b/WebKit/WebView.subproj/WebControllerPrivate.h
@@ -4,6 +4,7 @@
*/
#import <WebKit/IFWebController.h>
+//#import <WebKit/IFDocument.h>
@class IFError;
@class IFLoadProgress;
diff --git a/WebKit/WebView.subproj/WebControllerPrivate.m b/WebKit/WebView.subproj/WebControllerPrivate.m
index cb21f7b..9e630cf 100644
--- a/WebKit/WebView.subproj/WebControllerPrivate.m
+++ b/WebKit/WebView.subproj/WebControllerPrivate.m
@@ -18,7 +18,6 @@
#import <WebKit/WebKitDebug.h>
-
@implementation IFWebControllerPrivate
- init
@@ -51,8 +50,8 @@
[self _clearControllerReferences: mainFrame];
[mainFrame reset];
-
[mainFrame autorelease];
+
[super dealloc];
}
diff --git a/WebKit/WebView.subproj/WebDOMNode.m b/WebKit/WebView.subproj/WebDOMNode.m
index 5ca1c90..23ca798 100644
--- a/WebKit/WebView.subproj/WebDOMNode.m
+++ b/WebKit/WebView.subproj/WebDOMNode.m
@@ -8,7 +8,8 @@
#import "IFDOMNode.h"
-#import <WebKit/IFWebViewPrivate.h>
+#import <WebKit/IFWebView.h>
+#import <WebKit/IFHTMLViewPrivate.h>
#import <khtmlview.h>
#import <khtml_part.h>
#import <xml/dom_docimpl.h>
@@ -37,7 +38,7 @@
- initWithWebView:(IFWebView *)view
{
- return [self initWithDOMNode:[view _widget]->part()->xmlDocImpl()];
+ return [self initWithDOMNode:[[view documentView] _widget]->part()->xmlDocImpl()];
}
- (void)dealloc
diff --git a/WebKit/WebView.subproj/WebDataSource.h b/WebKit/WebView.subproj/WebDataSource.h
index 9d1eca6..4c647ff 100644
--- a/WebKit/WebView.subproj/WebDataSource.h
+++ b/WebKit/WebView.subproj/WebDataSource.h
@@ -25,6 +25,7 @@
#endif
@class IFWebDataSourcePrivate;
+ at protocol IFDocumentRepresentation;
@interface IFWebDataSource : NSObject
{
@@ -43,6 +44,10 @@
- initWithLoader: (IFLoader *)loader;
#endif
+- (NSData *)data;
+
+- (id)representation;
+
// Returns YES if this is the main document. The main document is the 'top'
// document, typically either a frameset or a normal HTML document.
- (BOOL)isMainDocument;
@@ -112,6 +117,8 @@
// Returns YES if there are any pending loads.
- (BOOL)isLoading;
+
+/*
#ifdef TENTATIVE_API
// Get DOM access to the document.
- (IFDOMDocument *)document;
@@ -119,10 +126,12 @@
// Get the source of the document by reconstructing it from the DOM.
- (NSString *)documentTextFromDOM;
+*/
// Get the actual source of the document.
- (NSString *)documentText;
+
// URL reference point, these should probably not be public for 1.0.
- (NSURL *)base;
- (NSString *)baseTarget;
@@ -148,6 +157,8 @@
- (IFContentPolicy)contentPolicy;
+- (NSString *)contentType;
+
- (NSString *)downloadPath;
/*
@@ -158,5 +169,8 @@
*/
- (IFError *)mainDocumentError;
++ (void) registerRepresentationClass:(Class)repClass forMIMEType:(NSString *)MIMEType;
+
++ (id <IFDocumentRepresentation>) createRepresentationForMIMEType:(NSString *)MIMEType;
@end
diff --git a/WebKit/WebView.subproj/WebDataSource.m b/WebKit/WebView.subproj/WebDataSource.m
index ee83e49..e045c0d 100644
--- a/WebKit/WebView.subproj/WebDataSource.m
+++ b/WebKit/WebView.subproj/WebDataSource.m
@@ -10,11 +10,17 @@
#import <WebKit/IFWebController.h>
#import <WebKit/IFWebFramePrivate.h>
#import <WebFoundation/WebFoundation.h>
+#import <WebKit/IFHTMLView.h>
+#import <WebKit/IFImageView.h>
+#import <WebKit/IFTextView.h>
+#import <WebKit/IFHTMLRepresentation.h>
+#import <WebKit/IFImageRepresentation.h>
+#import <WebKit/IFTextRepresentation.h>
#import <xml/dom_docimpl.h>
-#import <KWQKHTMLPartImpl.h>
#import <WCWebDataSource.h>
+#import <KWQKHTMLPartImpl.h>
@implementation IFWebDataSource
@@ -58,11 +64,19 @@ static id IFWebDataSourceMake(void *url, void *attributes, unsigned flags)
[super dealloc];
}
-#ifdef TENTATIVE_API
-- initWithData: (NSData *)data
-- initWithString: (NSString *)string;
-- initWithLoader: (IFLoader *)loader;
-#endif
+- (NSData *)data
+{
+ if(_private->mainHandle){
+ return [_private->mainHandle resourceData];
+ }else{
+ return _private->resourceData;
+ }
+}
+
+- (id) representation
+{
+ return _private->representation;
+}
- (IFWebFrame *)webFrame
{
@@ -235,32 +249,35 @@ static id IFWebDataSourceMake(void *url, void *attributes, unsigned flags)
- (IFDOMDocument *)document;
#endif
+
// Get the actual source of the docment.
- (NSString *)documentText
{
- KHTMLPart *part = [self _part];
-
- return QSTRING_TO_NSSTRING(part->impl->documentSource());
+ return [[[NSString alloc] initWithData:[self data] encoding:NSASCIIStringEncoding] autorelease];
}
-
+// FIXME: Move to representation
- (NSString *)documentTextFromDOM
{
- DOM::DocumentImpl *doc;
- NSString *string = nil;
- KHTMLPart *part = [self _part];
-
- if (part != 0){
- doc = [self _part]->xmlDocImpl();
- if (doc != 0){
- QString str = doc->recursive_toHTML(1);
- string = QSTRING_TO_NSSTRING(str);
+ if([self _isDocumentHTML]){
+ DOM::DocumentImpl *doc;
+ NSString *string = nil;
+ KHTMLPart *part = [[self representation] part];
+
+ if (part != 0){
+ doc = part->xmlDocImpl();
+ if (doc != 0){
+ QString str = doc->recursive_toHTML(1);
+ string = QSTRING_TO_NSSTRING(str);
+ }
}
+ if (string == nil) {
+ string = @"";
+ }
+ return string;
+ }else{
+ return nil;
}
- if (string == nil) {
- string = @"";
- }
- return string;
}
@@ -281,8 +298,7 @@ static id IFWebDataSourceMake(void *url, void *attributes, unsigned flags)
- (NSString *)encoding
{
- [NSException raise:IFMethodNotYetImplemented format:@"IFWebDataSource::encoding is not implemented"];
- return nil;
+ return _private->encoding;
}
// Style sheet
@@ -323,6 +339,11 @@ static id IFWebDataSourceMake(void *url, void *attributes, unsigned flags)
return _private->contentPolicy;
}
+- (NSString *)contentType
+{
+ return _private->contentType;
+}
+
- (NSString *)downloadPath
{
return _private->downloadPath;
@@ -338,5 +359,36 @@ static id IFWebDataSourceMake(void *url, void *attributes, unsigned flags)
return _private->mainDocumentError;
}
++ (void)registerRepresentationClass:(Class)repClass forMIMEType:(NSString *)MIMEType
+{
+ NSMutableDictionary *repTypes = [[self class] _repTypes];
+
+ // FIXME: OK to allow developers to override built-in reps?
+ [repTypes setObject:repClass forKey:MIMEType];
+}
+
++ (id <IFDocumentRepresentation>) createRepresentationForMIMEType:(NSString *)MIMEType
+{
+ NSMutableDictionary *repTypes = [[self class] _repTypes];
+ Class repClass;
+ NSArray *keys;
+ unsigned i;
+
+ repClass = [repTypes objectForKey:MIMEType];
+ if(repClass){
+ return [[[repClass alloc] init] autorelease];
+ }else{
+ keys = [repTypes allKeys];
+ for(i=0; i<[keys count]; i++){
+ if([[keys objectAtIndex:i] hasSuffix:@"/"] && [MIMEType hasPrefix:[keys objectAtIndex:i]]){
+ repClass = [repTypes objectForKey:[keys objectAtIndex:i]];
+ return [[[repClass alloc] init] autorelease];
+ }
+ }
+ }
+ return nil;
+}
+
+
@end
diff --git a/WebKit/WebView.subproj/WebDataSourcePrivate.h b/WebKit/WebView.subproj/WebDataSourcePrivate.h
index 96690b2..397bb6b 100644
--- a/WebKit/WebView.subproj/WebDataSourcePrivate.h
+++ b/WebKit/WebView.subproj/WebDataSourcePrivate.h
@@ -9,14 +9,18 @@
#import <WebKit/IFWebDataSource.h>
#import <WebKit/IFLocationChangeHandler.h>
-class KHTMLPart;
@class IFURLHandle;
@class IFMainURLHandleClient;
@protocol IFLocationChangeHandler;
+ at protocol IFDocumentRepresentation;
@interface IFWebDataSourcePrivate : NSObject
{
+ NSData *resourceData;
+
+ id representation;
+
IFWebDataSource *parent;
NSMutableArray *children;
@@ -28,8 +32,6 @@ class KHTMLPart;
// The original URL we may have been redirected to.
NSURL *finalURL;
- KHTMLPart *part;
-
// Child frames of this frame.
NSMutableDictionary *frames;
@@ -51,7 +53,7 @@ class KHTMLPart;
BOOL stopping;
- NSString *pageTitle, *downloadPath;
+ NSString *pageTitle, *downloadPath, *encoding, *contentType;
// Errors associated with resources.
NSMutableDictionary *errors;
@@ -73,8 +75,9 @@ class KHTMLPart;
@end
@interface IFWebDataSource (IFPrivate)
+- (void)_setResourceData:(NSData *)data;
+- (void)_setRepresentation:(id <IFDocumentRepresentation>)representation;
- (void)_setController: (IFWebController *)controller;
-- (KHTMLPart *)_part;
- (void)_setParent: (IFWebDataSource *)p;
- (void)_startLoading: (BOOL)forceRefresh;
@@ -87,15 +90,18 @@ class KHTMLPart;
- (double)_loadingStartedTime;
- (void)_setTitle: (NSString *)title;
- (void)_setFinalURL: (NSURL *)url;
-
- (id <IFLocationChangeHandler>)_locationChangeHandler;
- (void)_setLocationChangeHandler: (id <IFLocationChangeHandler>)l;
-- (void) _setDownloadPath:(NSString *)path;
-- (void) _setContentPolicy:(IFContentPolicy)policy;
+- (void)_setDownloadPath:(NSString *)path;
+- (void)_setContentPolicy:(IFContentPolicy)policy;
+- (void)_setContentType:(NSString *)type;
+- (void)_setEncoding:(NSString *)encoding;
- (IFWebDataSource *) _recursiveDataSourceForLocationChangeHandler:(id <IFLocationChangeHandler>)handler;
- (void)_clearErrors;
- (void)_setMainDocumentError: (IFError *)error;
- (void)_addError: (IFError *)error forResource: (NSString *)resourceDescription;
-
+- (BOOL)_isDocumentHTML;
++ (NSMutableDictionary *)_repTypes;
++ (BOOL)_canShowMIMEType:(NSString *)MIMEType;
@end
diff --git a/WebKit/WebView.subproj/WebDataSourcePrivate.m b/WebKit/WebView.subproj/WebDataSourcePrivate.m
index 9dfd5b0..c38b994 100644
--- a/WebKit/WebView.subproj/WebDataSourcePrivate.m
+++ b/WebKit/WebView.subproj/WebDataSourcePrivate.m
@@ -15,9 +15,16 @@
#import <WebFoundation/IFError.h>
#import <WebFoundation/IFNSStringExtensions.h>
#import <WebKit/IFLocationChangeHandler.h>
+#import <WebKit/IFHTMLRepresentation.h>
+#import <WebKit/IFImageRepresentation.h>
+#import <WebKit/IFTextRepresentation.h>
#import <KWQKHTMLPartImpl.h>
#import "IFWebController.h"
+#import <kurl.h>
+
+static NSMutableDictionary *_repTypes=nil;
+
@implementation IFWebDataSourcePrivate
- init
@@ -27,8 +34,6 @@
frames = nil;
controller = nil;
inputURL = nil;
-
- part = new KHTMLPart();
primaryLoadComplete = NO;
@@ -61,8 +66,7 @@
[errors release];
[mainDocumentError release];
-
- part->deref();
+
[super dealloc];
}
@@ -71,6 +75,18 @@
@implementation IFWebDataSource (IFPrivate)
+- (void)_setResourceData:(NSData *)data
+{
+ [_private->resourceData release];
+ _private->resourceData = [data retain];
+}
+
+- (void)_setRepresentation:(id) representation
+{
+ [_private->representation release];
+ _private->representation = [representation retain];
+}
+
- (void)_setLoading:(BOOL)loading
{
WEBKIT_ASSERT_VALID_ARG("loading", loading == NO || loading == YES);
@@ -95,19 +111,11 @@
- (void)_setController: (IFWebController *)controller
{
- WEBKIT_ASSERT(_private->part != nil);
-
if (_private->loading) {
[controller retain];
[_private->controller release];
}
_private->controller = controller;
- _private->part->impl->setDataSource(self);
-}
-
-- (KHTMLPart *)_part
-{
- return _private->part;
}
- (void)_setParent: (IFWebDataSource *)p
@@ -151,7 +159,7 @@
}
theURL = [NSURL URLWithString:urlString];
- _private->mainURLHandleClient = [[IFMainURLHandleClient alloc] initWithDataSource: self part: _private->part];
+ _private->mainURLHandleClient = [[IFMainURLHandleClient alloc] initWithDataSource: self];
[_private->mainHandle addClient: _private->mainURLHandleClient];
// Mark the start loading time.
@@ -159,10 +167,6 @@
// Fire this guy up.
[_private->mainHandle loadInBackground];
-
- // FIXME [rjw]: Do any work need in the kde engine. This should be removed.
- // We should move any code needed out of KWQ.
- _private->part->openURL(url);
[self _setLoading:YES];
@@ -205,7 +209,8 @@
[[_private->urlHandles objectAtIndex: i] cancelLoadInBackground];
}
- _private->part->closeURL();
+ if ([self _isDocumentHTML])
+ [[self representation] part]->closeURL();
}
- (void)_recursiveStopLoading
@@ -285,13 +290,21 @@
_private->downloadPath = [path retain];
}
-
-// This method should only be called by haveContentPolicy in IFWebController
-// and should only be called once.
- (void) _setContentPolicy:(IFContentPolicy)policy
{
_private->contentPolicy = policy;
- [_private->mainURLHandleClient setContentPolicy:policy];
+}
+
+- (void)_setContentType:(NSString *)type
+{
+ [_private->contentType release];
+ _private->contentType = [type retain];
+}
+
+- (void)_setEncoding:(NSString *)encoding
+{
+ [_private->encoding release];
+ _private->encoding = [encoding retain];
}
- (IFWebDataSource *) _recursiveDataSourceForLocationChangeHandler:(id <IFLocationChangeHandler>)handler;
@@ -343,6 +356,43 @@
[_private->errors setObject: error forKey: resourceDescription];
}
+- (BOOL)_isDocumentHTML
+{
+ return [[[self representation] className] isEqualToString:@"IFHTMLRepresentation"];
+}
+
++ (NSMutableDictionary *)_repTypes
+{
+ if(!_repTypes){
+ _repTypes = [[NSMutableDictionary dictionary] retain];
+ [_repTypes setObject:[IFHTMLRepresentation class] forKey:@"text/html"];
+ [_repTypes setObject:[IFImageRepresentation class] forKey:@"image/jpeg"];
+ [_repTypes setObject:[IFImageRepresentation class] forKey:@"image/gif"];
+ [_repTypes setObject:[IFImageRepresentation class] forKey:@"image/png"];
+ [_repTypes setObject:[IFTextRepresentation class] forKey:@"text/"];
+ }
+ return _repTypes;
+}
++ (BOOL)_canShowMIMEType:(NSString *)MIMEType
+{
+ NSMutableDictionary *repTypes = [[self class] _repTypes];
+ NSArray *keys;
+ unsigned i;
+
+ if([repTypes objectForKey:MIMEType]){
+ return YES;
+ }else{
+ keys = [repTypes allKeys];
+ for(i=0; i<[keys count]; i++){
+ if([[keys objectAtIndex:i] hasSuffix:@"/"] && [MIMEType hasPrefix:[keys objectAtIndex:i]]){
+ if([repTypes objectForKey:[keys objectAtIndex:i]]){
+ return YES;
+ }
+ }
+ }
+ }
+ return NO;
+}
@end
diff --git a/WebKit/WebView.subproj/WebDebugDOMNode.m b/WebKit/WebView.subproj/WebDebugDOMNode.m
index 5ca1c90..23ca798 100644
--- a/WebKit/WebView.subproj/WebDebugDOMNode.m
+++ b/WebKit/WebView.subproj/WebDebugDOMNode.m
@@ -8,7 +8,8 @@
#import "IFDOMNode.h"
-#import <WebKit/IFWebViewPrivate.h>
+#import <WebKit/IFWebView.h>
+#import <WebKit/IFHTMLViewPrivate.h>
#import <khtmlview.h>
#import <khtml_part.h>
#import <xml/dom_docimpl.h>
@@ -37,7 +38,7 @@
- initWithWebView:(IFWebView *)view
{
- return [self initWithDOMNode:[view _widget]->part()->xmlDocImpl()];
+ return [self initWithDOMNode:[[view documentView] _widget]->part()->xmlDocImpl()];
}
- (void)dealloc
diff --git a/WebKit/WebView.subproj/WebDocument.h b/WebKit/WebView.subproj/WebDocument.h
new file mode 100644
index 0000000..bca5c9e
--- /dev/null
+++ b/WebKit/WebView.subproj/WebDocument.h
@@ -0,0 +1,32 @@
+/*
+ IFDocument.h
+ Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#include <Cocoa/Cocoa.h>
+
+ at class IFWebDataSource;
+ at class IFError;
+
+ at protocol IFDocumentLoading
+- (void)provisionalDataSourceChanged:(IFWebDataSource *)dataSource;
+- (void)provisionalDataSourceCommitted:(IFWebDataSource *)dataSource;
+- (void)dataSourceUpdated:(IFWebDataSource *)dataSource;
+- (void)layout;
+ at end
+
+ at protocol IFDocumentDragSettings
+- (void)setCanDragFrom: (BOOL)flag;
+- (BOOL)canDragFrom;
+- (void)setCanDragTo: (BOOL)flag;
+- (BOOL)canDragTo;
+ at end
+
+ at protocol IFDocumentSearching
+- (void)searchFor: (NSString *)string direction: (BOOL)forward caseSensitive: (BOOL)caseFlag;
+ at end
+
+ at protocol IFDocumentRepresentation
+- (void)receivedData:(NSData *)data withDataSource:(IFWebDataSource *)dataSource isComplete:(BOOL)isComplete;
+- (void)receivedError:(IFError *)error withDataSource:(IFWebDataSource *)dataSource;
+ at end
\ No newline at end of file
diff --git a/WebKit/WebView.subproj/WebDynamicScrollBarsView.m b/WebKit/WebView.subproj/WebDynamicScrollBarsView.m
index 26c8b57..d5276c7 100644
--- a/WebKit/WebView.subproj/WebDynamicScrollBarsView.m
+++ b/WebKit/WebView.subproj/WebDynamicScrollBarsView.m
@@ -7,9 +7,6 @@
//
#import <WebKit/IFDynamicScrollBarsView.h>
-
-#import <WebKit/IFWebView.h>
-
#import <WebKit/WebKitDebug.h>
@implementation IFDynamicScrollBarsView
diff --git a/WebKit/WebView.subproj/WebFrame.m b/WebKit/WebView.subproj/WebFrame.m
index e953671..9986904 100644
--- a/WebKit/WebView.subproj/WebFrame.m
+++ b/WebKit/WebView.subproj/WebFrame.m
@@ -12,7 +12,9 @@
#import <WebKit/IFWebControllerPrivate.h>
#import <WebKit/IFWebController.h>
#import <WebKit/IFLocationChangeHandler.h>
-#import <WebKit/IFDownloadHandler.h>
+#import <WebKit/IFHTMLView.h>
+#import <WebKit/IFHTMLViewPrivate.h>
+
#import <WebFoundation/WebFoundation.h>
#import <WebKit/WebKitDebug.h>
@@ -152,15 +154,8 @@
[_private setProvisionalDataSource: newDataSource];
- [[self view] provisionalDataSourceChanged: newDataSource];
-
- #ifdef OLD_WAY
- // This introduces a nasty dependency on the view.
- khtml::RenderPart *renderPartFrame = [self _renderFramePart];
- id view = [self view];
- if (renderPartFrame && [view isKindOfClass: NSClassFromString(@"IFWebView")])
- renderPartFrame->setWidget ([view _provisionalWidget]);
- #endif
+ //[[self view] provisionalDataSourceChanged: newDataSource];
+ //[[[self view] documentView] provisionalDataSourceChanged: newDataSource];
[self _setState: IFWEBFRAMESTATE_PROVISIONAL];
}
@@ -204,7 +199,8 @@
- (void)reset
{
[_private setDataSource: nil];
- [[_private view] _resetWidget];
+ if([[[self view] documentView] isKindOfClass: NSClassFromString(@"IFHTMLView")])
+ [[[self view] documentView] _resetWidget];
[_private setView: nil];
}
diff --git a/WebKit/WebView.subproj/WebFramePrivate.h b/WebKit/WebView.subproj/WebFramePrivate.h
index 5177e16..f8fb956 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.h
+++ b/WebKit/WebView.subproj/WebFramePrivate.h
@@ -9,6 +9,7 @@
#import <WebKit/IFWebFrame.h>
@class IFWebView;
+ at protocol IFDocumentLoading;
namespace khtml {
class RenderPart;
diff --git a/WebKit/WebView.subproj/WebFramePrivate.m b/WebKit/WebView.subproj/WebFramePrivate.m
index 4364168..a4b628c 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.m
+++ b/WebKit/WebView.subproj/WebFramePrivate.m
@@ -10,7 +10,9 @@
#import <WebKit/IFPreferencesPrivate.h>
#import <WebKit/IFWebController.h>
#import <WebKit/IFLocationChangeHandler.h>
-
+#import <WebKit/IFHTMLRepresentation.h>
+#import <WebKit/IFHTMLView.h>
+#import <WebKit/IFHTMLViewPrivate.h>
#import <WebKit/WebKitDebug.h>
#import <WebFoundation/IFError.h>
@@ -137,8 +139,10 @@ static const char * const stateNames[6] = {
if (_private->state == IFWEBFRAMESTATE_LAYOUT_ACCEPTABLE) {
if ([self controller])
WEBKITDEBUGLEVEL (WEBKIT_LOG_TIMING, "%s: performing timed layout, %f seconds since start of document load\n", [[self name] cString], CFAbsoluteTimeGetCurrent() - [[[[self controller] mainFrame] dataSource] _loadingStartedTime]);
- [[self view] setNeedsLayout: YES];
- [[self view] setNeedsDisplay: YES];
+
+ if([[[self view] documentView] isKindOfClass: NSClassFromString(@"IFHTMLView")])
+ [[[self view] documentView] setNeedsLayout: YES];
+ [[[self view] documentView] setNeedsDisplay: YES];
}
else {
if ([self controller])
@@ -199,36 +203,38 @@ static const char * const stateNames[6] = {
- (void)_transitionProvisionalToCommitted
{
WEBKIT_ASSERT ([self controller] != nil);
-
+ id documentView = [[self view] documentView];
+ BOOL isDocumentHTML = [[self view] isDocumentHTML];
+
switch ([self _state]) {
case IFWEBFRAMESTATE_PROVISIONAL:
{
- id view = [self view];
-
- WEBKIT_ASSERT (view != nil);
+ WEBKIT_ASSERT (documentView != nil);
- // Make sure any plugsin are shut down cleanly.
- [view _stopPlugins];
+ if(isDocumentHTML){
- // Remove any widgets.
- [view _removeSubviews];
+ // Make sure any plugsin are shut down cleanly.
+ [documentView _stopPlugins];
+
+ // Remove any widgets.
+ [documentView _removeSubviews];
+ }
// Set the committed data source on the frame.
[self _setDataSource: _private->provisionalDataSource];
+ // provisionalDataSourceCommitted: will reset the view and begin trying to
+ // display the new new datasource.
+ [documentView provisionalDataSourceCommitted: _private->provisionalDataSource];
+
// If we're a frame (not the main frame) hookup the kde internals. This introduces a nasty dependency
// in kde on the view.
khtml::RenderPart *renderPartFrame = [self _renderFramePart];
- if (renderPartFrame && [view isKindOfClass: NSClassFromString(@"IFWebView")]) {
+ if (renderPartFrame && isDocumentHTML) {
// Setting the widget will delete the previous KHTMLView associated with the frame.
- renderPartFrame->setWidget ([view _provisionalWidget]);
+ renderPartFrame->setWidget ([documentView _widget]);
}
-
- // dataSourceChanged: will reset the view and begin trying to
- // display the new new datasource.
- [view dataSourceChanged: _private->provisionalDataSource];
-
-
+
// Now that the provisional data source is committed, release it.
[_private setProvisionalDataSource: nil];
@@ -328,14 +334,19 @@ static const char * const stateNames[6] = {
[self _setState: IFWEBFRAMESTATE_COMPLETE];
- [ds _part]->end();
+ if([ds _isDocumentHTML])
+ [[ds representation] part]->end();
- // May need to relayout each time a frame is completely
- // loaded.
- [mainView setNeedsLayout: YES];
+ if ([mainView isDocumentHTML]){
+ // May need to relayout each time a frame is completely
+ // loaded.
+ [[mainView documentView] setNeedsLayout: YES];
+ }
- // Layout this view (eventually).
- [thisView setNeedsLayout: YES];
+ if ([thisView isDocumentHTML]){
+ // Layout this view (eventually).
+ [[thisView documentView] setNeedsLayout: YES];
+ }
// Draw this view (eventually), and it's scroll view
// (eventually).
@@ -345,15 +356,19 @@ static const char * const stateNames[6] = {
// Force a relayout and draw NOW if we are complete are the top level.
if ([[self controller] mainFrame] == self) {
- [mainView layout];
- [mainView display];
+ [[mainView documentView] layout];
+ [[mainView documentView] display];
}
// Jump to anchor point, if necessary.
- [ds _part]->impl->gotoBaseAnchor();
+ if ([ds _isDocumentHTML])
+ [[ds representation] part]->impl->gotoBaseAnchor();
[[ds _locationChangeHandler] locationChangeDone: [ds mainDocumentError]];
-
+
+ //if ([ds _isDocumentHTML])
+ // [[ds representation] part]->closeURL();
+
return;
}
// A resource was loaded, but the entire frame isn't complete. Schedule a
diff --git a/WebKit/WebView.subproj/WebFrameView.h b/WebKit/WebView.subproj/WebFrameView.h
index 933968c..85ef6e5 100644
--- a/WebKit/WebView.subproj/WebFrameView.h
+++ b/WebKit/WebView.subproj/WebFrameView.h
@@ -13,8 +13,8 @@
@class IFWebDataSource;
@class IFWebController;
-
@class IFWebViewPrivate;
+ at protocol IFDocumentLoading;
@interface IFWebView : NSView
{
@@ -22,72 +22,23 @@
IFWebViewPrivate *_private;
}
-- initWithFrame: (NSRect)frame;
+- initWithFrame: (NSRect) frame;
// Note that the controller is not retained.
- (IFWebController *)controller;
-// These methods is typically called by the view's controller when
-// the data source is changed.
-- (void)dataSourceChanged: (IFWebDataSource *)dataSource;
-- (void)provisionalDataSourceChanged: (IFWebDataSource *)dataSource;
-
-- (void)setNeedsLayout: (bool)flag;
-
-// This method should not be public until we have a more completely
-// understood way to subclass IFWebView.
-- (void)layout;
-
-// Set needsToApplyStyles if you change anything that might impact styles, like
-// font preferences.
-- (void)setNeedsToApplyStyles: (bool)flag;
-
-// Reapplies style information to the document. This should not be called directly,
-// instead call setNeedsToApplyStyles:.
-- (void)reapplyStyles;
-
-// Stop animating animated GIFs, etc.
-- (void)stopAnimations;
+- (id)documentView;
-// Drag and drop links and images. Others?
-- (void)setCanDragFrom: (BOOL)flag;
-- (BOOL)canDragFrom;
-- (void)setCanDragTo: (BOOL)flag;
-- (BOOL)canDragTo;
+- (BOOL) isDocumentHTML;
-// Returns an array of built-in context menu items for this node.
-// Generally called by IFContextMenuHandlers from contextMenuItemsForNode:
-#ifdef TENTATIVE_API
-- (NSArray *)defaultContextMenuItemsForNode: (IFDOMNode *);
-#endif
-- (void)setContextMenusEnabled: (BOOL)flag;
-- (BOOL)contextMenusEnabled;
+- (void)setAllowsScrolling: (BOOL)flag;
+- (BOOL)allowsScrolling;
-// Remove the selection.
-- (void)deselectText;
+// Extends the views that WebKit supports
+// The view must conform to the IFDocumentLoading protocol
++ (void)registerViewClass:(Class)viewClass forMIMEType:(NSString *)MIMEType;
-// Search from the end of the currently selected location, or from the beginning of the document if nothing
-// is selected.
-- (void)searchFor: (NSString *)string direction: (BOOL)forward caseSensitive: (BOOL)caseFlag;
-
-// Get an attributed string that represents the current selection.
-- (NSAttributedString *)selectedText;
+// Called when the contentPolicy is set to IFContentPolicyShow
++ (id <IFDocumentLoading>) createViewForMIMEType:(NSString *)MIMEType;
@end
-
-/*
- Areas still to consider:
-
- ALT image text and link URLs
- Should this be built-in? or able to be overriden?
-
- node events
-
- client access to form elements for auto-completion, passwords
-
- selection
- Selection on data source is reflected in view.
- Does the view also need a cover selection API?
-
- subclassing of IFWebView
-*/
diff --git a/WebKit/WebView.subproj/WebFrameView.m b/WebKit/WebView.subproj/WebFrameView.m
index a2b43d7..88ff4a8 100644
--- a/WebKit/WebView.subproj/WebFrameView.m
+++ b/WebKit/WebView.subproj/WebFrameView.m
@@ -1,55 +1,26 @@
/* IFWebView.mm
Copyright 2001, Apple, Inc. All rights reserved.
*/
+#import <WebKit/IFDynamicScrollBarsView.h>
+#import <WebKit/IFHTMLView.h>
+#import <WebKit/IFImageView.h>
+#import <WebKit/IFTextView.h>
#import <WebKit/IFWebView.h>
#import <WebKit/IFWebViewPrivate.h>
-#import <WebKit/IFWebFrame.h>
-#import <WebKit/IFWebDataSource.h>
-#import <WebKit/IFWebDataSourcePrivate.h>
-#import <WebKit/IFWebController.h>
-#import <WebKit/IFDynamicScrollBarsView.h>
-#import <WebKit/IFException.h>
-#import <WebKit/IFWebCoreViewFactory.h>
-#import <WebKit/IFTextRendererFactory.h>
-#import <WebKit/IFImageRendererFactory.h>
-#import <WebKit/WebKitDebug.h>
-
-#import <WebFoundation/IFNSStringExtensions.h>
-
-// Needed for the mouse move notification.
-#import <AppKit/NSResponder_Private.h>
-
-// KDE related includes
-#import <khtmlview.h>
-#import <qwidget.h>
-#import <qpainter.h>
-#import <qevent.h>
-#import <html/html_documentimpl.h>
-
-#import <KWQKHTMLPartImpl.h>
@implementation IFWebView
- initWithFrame: (NSRect) frame
{
[super initWithFrame: frame];
-
- [IFWebCoreViewFactory createSharedFactory];
- [IFTextRendererFactory createSharedFactory];
- [IFImageRendererFactory createSharedFactory];
_private = [[IFWebViewPrivate alloc] init];
- _private->isFlipped = YES;
- _private->needsLayout = YES;
-
- _private->canDragTo = YES;
- _private->canDragFrom = YES;
- _private->draggingTypes = [[NSArray arrayWithObjects:@"NSFilenamesPboardType", @"NSURLPboardType", @"NSStringPboardType", nil] retain];
- [self registerForDraggedTypes:_private->draggingTypes];
-
- [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(windowResized:) name: NSWindowDidResizeNotification object: nil];
- [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(mouseMovedNotification:) name: NSMouseMovedNotification object: nil];
+ IFDynamicScrollBarsView *scrollView = [[IFDynamicScrollBarsView alloc] initWithFrame: NSMakeRect(0,0,0,0)];
+ [scrollView setHasVerticalScroller: NO];
+ [scrollView setHasHorizontalScroller: NO];
+ [self _setFrameScrollView: scrollView];
+ [scrollView release];
return self;
}
@@ -57,560 +28,67 @@
- (void)dealloc
{
- [self _stopPlugins];
- [[NSNotificationCenter defaultCenter] removeObserver: self];
[_private release];
[super dealloc];
}
-
-- (BOOL)acceptsFirstResponder
-{
- return YES;
-}
-
-
-// Note that the controller is not retained.
-- (IFWebController *)controller
-{
- return _private->controller;
-}
-
-
-- (void)removeFromSuperview
-{
- [self _stopPlugins];
- [super removeFromSuperview];
-}
-
-
-- (void)removeFromSuperviewWithoutNeedingDisplay
-{
- [self _stopPlugins];
- [super removeFromSuperviewWithoutNeedingDisplay];
-}
-
-
-// This method is typically called by the view's controller when
-// the data source is changed.
-- (void)provisionalDataSourceChanged: (IFWebDataSource *)dataSource
-{
- NSRect r = [self frame];
- IFWebView *provisionalView;
-
- // Nasty! Setup the cross references between the KHTMLView and
- // the KHTMLPart.
- KHTMLPart *part = [dataSource _part];
-
- _private->provisionalWidget = new KHTMLView (part, 0);
- part->impl->setView (_private->provisionalWidget);
-
- // Create a temporary provisional view. It will be replaced with
- // the actual view once the datasource has been committed.
- provisionalView = [[IFWebView alloc] initWithFrame: NSMakeRect (0,0,0,0)];
- _private->provisionalWidget->setView (provisionalView);
- [provisionalView release];
-
- _private->provisionalWidget->resize ((int)r.size.width, (int)r.size.height);
-}
-
-- (void)dataSourceChanged: (IFWebDataSource *)dataSource
-{
- IFWebViewPrivate *data = _private;
-
- // Setup the real view.
- if ([self _frameScrollView])
- data->provisionalWidget->setView ([self _frameScrollView]);
- else
- data->provisionalWidget->setView (self);
-
- // Only delete the widget if we're the top level widget. In other
- // cases the widget is associated with a RenderFrame which will
- // delete it's widget.
- if ([dataSource isMainDocument] && data->widget)
- delete data->widget;
-
- data->widget = data->provisionalWidget;
- data->provisionalWidget = 0;
-}
-
-- (void)reapplyStyles
-{
- KHTMLView *widget = _private->widget;
-
- if (widget->part()->xmlDocImpl() &&
- widget->part()->xmlDocImpl()->renderer()){
- if (_private->needsToApplyStyles){
-#ifdef _KWQ_TIMING
- double start = CFAbsoluteTimeGetCurrent();
-#endif
- widget->part()->xmlDocImpl()->updateStyleSelector();
- _private->needsToApplyStyles = NO;
-#ifdef _KWQ_TIMING
- double thisTime = CFAbsoluteTimeGetCurrent() - start;
- WEBKITDEBUGLEVEL (WEBKIT_LOG_TIMING, "%s apply style seconds = %f\n", widget->part()->baseURL().url().latin1(), thisTime);
-#endif
- }
- }
-
-}
-
-
-// This method should not be public until we have more completely
-// understood how IFWebView will be subclassed.
-- (void)layout
+- (void)setAllowsScrolling: (BOOL)flag
{
- KHTMLView *widget = _private->widget;
-
-
- // Ensure that we will receive mouse move events. Is this the best place to put this?
- [[self window] setAcceptsMouseMovedEvents: YES];
- [[self window] _setShouldPostEventNotifications: YES];
-
- if (widget->part()->xmlDocImpl() &&
- widget->part()->xmlDocImpl()->renderer()){
- if (_private->needsLayout){
-#ifdef _KWQ_TIMING
- double start = CFAbsoluteTimeGetCurrent();
-#endif
-
- WEBKITDEBUGLEVEL (WEBKIT_LOG_VIEW, "doing layout\n");
- //double start = CFAbsoluteTimeGetCurrent();
- widget->layout();
- //WebKitDebugAtLevel (WEBKIT_LOG_TIMING, "layout time %e\n", CFAbsoluteTimeGetCurrent() - start);
- _private->needsLayout = NO;
-#ifdef _KWQ_TIMING
- double thisTime = CFAbsoluteTimeGetCurrent() - start;
- WEBKITDEBUGLEVEL (WEBKIT_LOG_TIMING, "%s layout seconds = %f\n", widget->part()->baseURL().url().latin1(), thisTime);
-#endif
- }
- }
-
+ _private->allowsScrolling = flag;
}
-
-// Stop animating animated GIFs, etc.
-- (void)stopAnimations
+- (BOOL)allowsScrolling
{
- [NSException raise:IFMethodNotYetImplemented format:@"IFWebView::stopAnimations is not implemented"];
+ return _private->allowsScrolling;
}
-// Drag and drop links and images. Others?
-- (void)setCanDragFrom: (BOOL)flag
+- (id)documentView
{
- _private->canDragFrom = flag;
+ return _private->documentView;
}
-- (BOOL)canDragFrom
+// Note that the controller is not retained.
+- (IFWebController *)controller
{
- return _private->canDragFrom;
+ return _private->controller;
}
-- (void)setCanDragTo: (BOOL)flag
-{
- _private->canDragTo = flag;
-}
-- (BOOL)canDragTo
+- (BOOL) isDocumentHTML
{
- return _private->canDragTo;
+ return [[[self documentView] className] isEqualToString:@"IFHTMLView"];
}
-- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
++ (void) registerViewClass:(Class)viewClass forMIMEType:(NSString *)MIMEType
{
- NSString *dragType, *file, *URLString;
- NSArray *files;
-
- if(![self canDragTo])
- return NSDragOperationNone;
-
- dragType = [[sender draggingPasteboard] availableTypeFromArray:_private->draggingTypes];
- if([dragType isEqualToString:@"NSFilenamesPboardType"]){
- files = [[sender draggingPasteboard] propertyListForType:@"NSFilenamesPboardType"];
-
- // FIXME: We only look at the first dragged file (2931225)
- file = [files objectAtIndex:0];
+ NSMutableDictionary *viewTypes = [[self class] _viewTypes];
- // FIXME: Need the file type database to know what files we handle (2927855)
- if([[file pathExtension] isEqualToString:@"html"] || [[file pathExtension] isEqualToString:@"htm"])
- return NSDragOperationCopy;
- }else if([dragType isEqualToString:@"NSURLPboardType"]){
- return NSDragOperationCopy;
- }else if([dragType isEqualToString:@"NSStringPboardType"]){
- URLString = [[sender draggingPasteboard] stringForType:@"NSStringPboardType"];
- if([URLString _IF_looksLikeAbsoluteURL])
- return NSDragOperationCopy;
- }
- return NSDragOperationNone;
-}
-
-- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
-{
- return YES;
+ // FIXME: OK to allow developers to override built-in views?
+ [viewTypes setObject:viewClass forKey:MIMEType];
}
-- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
++ (id <IFDocumentLoading>) createViewForMIMEType:(NSString *)MIMEType
{
- IFWebDataSource *dataSource;
- IFWebFrame *frame;
- NSArray *files;
- NSString *file, *dragType;
- NSURL *URL=nil;
+ NSMutableDictionary *viewTypes = [[self class] _viewTypes];
+ Class viewClass;
+ NSArray *keys;
+ unsigned i;
- dragType = [[sender draggingPasteboard] availableTypeFromArray:_private->draggingTypes];
- if([dragType isEqualToString:@"NSFilenamesPboardType"]){
- files = [[sender draggingPasteboard] propertyListForType:@"NSFilenamesPboardType"];
- file = [files objectAtIndex:0];
- URL = [NSURL fileURLWithPath:file];
- }else if([dragType isEqualToString:@"NSURLPboardType"]){
- // FIXME: Is this the right way to get the URL? How to test?
- URL = [NSURL URLWithString:[[sender draggingPasteboard] stringForType:@"NSURLPboardType"]];
- }else if([dragType isEqualToString:@"NSStringPboardType"]){
- URL = [NSURL URLWithString:[[sender draggingPasteboard] stringForType:@"NSStringPboardType"]];
+ viewClass = [viewTypes objectForKey:MIMEType];
+ if(viewClass){
+ return [[[viewClass alloc] initWithFrame:NSMakeRect(0,0,0,0)] autorelease];
+ }else{
+ keys = [viewTypes allKeys];
+ for(i=0; i<[keys count]; i++){
+ if([[keys objectAtIndex:i] hasSuffix:@"/"] && [MIMEType hasPrefix:[keys objectAtIndex:i]]){
+ viewClass = [viewTypes objectForKey:[keys objectAtIndex:i]];
+ return [[[viewClass alloc] initWithFrame:NSMakeRect(0,0,0,0)] autorelease];
+ }
+ }
}
-
- if(!URL)
- return NO;
-
- dataSource = [[[IFWebDataSource alloc] initWithURL:URL] autorelease];
- frame = [[self controller] frameForView:self];
- [frame setProvisionalDataSource:dataSource];
- [frame startLoading];
-
- return YES;
-}
-
-// Returns an array of built-in context menu items for this node.
-// Generally called by IFContextMenuHandlers from contextMenuItemsForNode:
-#ifdef TENTATIVE_API
-- (NSArray *)defaultContextMenuItemsForNode: (IFDOMNode *)
-{
- [NSException raise:IFMethodNotYetImplemented format:@"IFWebView::defaultContextMenuItemsForNode: is not implemented"];
return nil;
}
-#endif
-
-- (void)setContextMenusEnabled: (BOOL)flag
-{
- [NSException raise:IFMethodNotYetImplemented format:@"IFWebView::setContextMenusEnabled: is not implemented"];
-}
-
-
-- (BOOL)contextMenusEnabled;
-{
- return NO;
-}
-
-
-// Remove the selection.
-- (void)deselectText
-{
- [NSException raise:IFMethodNotYetImplemented format:@"IFWebView::deselectText: is not implemented"];
-}
-
-// Search from the end of the currently selected location, or from the beginning of the document if nothing
-// is selected.
-- (void)searchFor: (NSString *)string direction: (BOOL)forward caseSensitive: (BOOL)caseFlag
-{
- [NSException raise:IFMethodNotYetImplemented format:@"IFWebView::searchFor:direction:caseSensitive: is not implemented"];
-}
-
-
-// Get an attributed string that represents the current selection.
-- (NSAttributedString *)selectedText
-{
- [NSException raise:IFMethodNotYetImplemented format:@"IFWebView::selectedText is not implemented"];
- return nil;
-}
-
-
-- (BOOL)isOpaque
-{
- return YES;
-}
-
-
-#ifdef DELAY_LAYOUT
-- delayLayout: sender
-{
- [NSObject cancelPreviousPerformRequestsWithTarget: self selector: @selector(delayLayout:) object: self];
- WEBKITDEBUG("KWQHTMLView: delayLayout called\n");
- [self setNeedsLayout: YES];
- [self setNeedsDisplay: YES];
-}
-
--(void)notificationReceived:(NSNotification *)notification
-{
- if ([[notification name] rangeOfString: @"uri-fin-"].location == 0){
- WEBKITDEBUG1("KWQHTMLView: Received notification, %s\n", DEBUG_OBJECT([notification name]));
- [self performSelector:@selector(delayLayout:) withObject:self afterDelay:(NSTimeInterval)0.5];
- }
-}
-#else
--(void)notificationReceived:(NSNotification *)notification
-{
- if ([[notification name] rangeOfString: @"uri-fin-"].location == 0){
- [self setNeedsLayout: YES];
- [self setNeedsDisplay: YES];
- }
-}
-#endif
-
-- (void)setNeedsDisplay:(BOOL)flag
-{
- WEBKITDEBUGLEVEL (WEBKIT_LOG_VIEW, "flag = %d\n", (int)flag);
- [super setNeedsDisplay: flag];
-}
-
-
-- (void)setNeedsLayout: (bool)flag
-{
- WEBKITDEBUGLEVEL (WEBKIT_LOG_VIEW, "flag = %d\n", (int)flag);
- _private->needsLayout = flag;
-}
-
-
-- (void)setNeedsToApplyStyles: (bool)flag
-{
- WEBKITDEBUGLEVEL (WEBKIT_LOG_VIEW, "flag = %d\n", (int)flag);
- _private->needsToApplyStyles = flag;
-}
-
-
-// This should eventually be removed.
-- (void)drawRect:(NSRect)rect {
- KHTMLView *widget = _private->widget;
- //IFWebViewPrivate *data = _private;
-
- //if (data->provisionalWidget != 0){
- // WEBKITDEBUGLEVEL (WEBKIT_LOG_VIEW, "not drawing, frame in provisional state.\n");
- // return;
- //}
-
- // Draw plain white bg in empty case, to avoid redraw weirdness when
- // no page is yet loaded (2890818). We may need to modify this to always
- // draw the background color, in which case we'll have to make sure the
- // no-widget case is still handled correctly.
- if (widget == 0l) {
- [[NSColor whiteColor] set];
- NSRectFill(rect);
- return;
- }
-
- WEBKITDEBUGLEVEL (WEBKIT_LOG_VIEW, "drawing\n");
-
- [self reapplyStyles];
-
- [self layout];
-
-#ifdef _KWQ_TIMING
- double start = CFAbsoluteTimeGetCurrent();
-#endif
- QPainter p(widget);
-
- [self lockFocus];
-
- //double start = CFAbsoluteTimeGetCurrent();
- widget->drawContents( &p, (int)rect.origin.x,
- (int)rect.origin.y,
- (int)rect.size.width,
- (int)rect.size.height );
- //WebKitDebugAtLevel (WEBKIT_LOG_TIMING, "draw time %e\n", CFAbsoluteTimeGetCurrent() - start);
-
-#ifdef DEBUG_LAYOUT
- NSRect vframe = [self frame];
- [[NSColor blackColor] set];
- NSBezierPath *path;
- path = [NSBezierPath bezierPath];
- [path setLineWidth:(float)0.1];
- [path moveToPoint:NSMakePoint(0, 0)];
- [path lineToPoint:NSMakePoint(vframe.size.width, vframe.size.height)];
- [path closePath];
- [path stroke];
- path = [NSBezierPath bezierPath];
- [path setLineWidth:(float)0.1];
- [path moveToPoint:NSMakePoint(0, vframe.size.height)];
- [path lineToPoint:NSMakePoint(vframe.size.width, 0)];
- [path closePath];
- [path stroke];
-#endif
-
- [self unlockFocus];
-
-#ifdef _KWQ_TIMING
- double thisTime = CFAbsoluteTimeGetCurrent() - start;
- WEBKITDEBUGLEVEL (WEBKIT_LOG_TIMING, "%s draw seconds = %f\n", widget->part()->baseURL().url().latin1(), thisTime);
-#endif
-}
-
-- (void)setIsFlipped: (bool)flag
-{
- _private->isFlipped = flag;
-}
-
-
-- (BOOL)isFlipped
-{
- return _private->isFlipped;
-}
-
-
-- (void)windowResized: (NSNotification *)notification
-{
- if ([notification object] == [self window])
- [self setNeedsLayout: YES];
-}
-
-- (void)_addModifiers:(unsigned)modifiers toState:(int *)state
-{
- if (modifiers & NSControlKeyMask)
- *state |= Qt::ControlButton;
- if (modifiers & NSShiftKeyMask)
- *state |= Qt::ShiftButton;
- if (modifiers & NSAlternateKeyMask)
- *state |= Qt::AltButton;
- // Mapping command to meta is slightly questionable
- if (modifiers & NSCommandKeyMask)
- *state |= Qt::MetaButton;
-}
-
-- (void)mouseUp: (NSEvent *)event
-{
- int button, state;
-
- if ([event type] == NSLeftMouseUp){
- button = Qt::LeftButton;
- state = Qt::LeftButton;
- }
- else if ([event type] == NSRightMouseUp){
- button = Qt::RightButton;
- state = Qt::RightButton;
- }
- else if ([event type] == NSOtherMouseUp){
- button = Qt::MidButton;
- state = Qt::MidButton;
- }
- else {
- [NSException raise:IFRuntimeError format:@"IFWebView::mouseUp: unknown button type"];
- button = 0; state = 0; // Shutup the compiler.
- }
- NSPoint p = [event locationInWindow];
-
- [self _addModifiers:[event modifierFlags] toState:&state];
-
- QMouseEvent kEvent(QEvent::MouseButtonPress, QPoint((int)p.x, (int)p.y), button, state);
- KHTMLView *widget = _private->widget;
- if (widget != 0l) {
- widget->viewportMouseReleaseEvent(&kEvent);
- }
-}
-
-- (void)mouseDown: (NSEvent *)event
-{
- int button, state;
-
- if ([event type] == NSLeftMouseDown){
- button = Qt::LeftButton;
- state = Qt::LeftButton;
- }
- else if ([event type] == NSRightMouseDown){
- button = Qt::RightButton;
- state = Qt::RightButton;
- }
- else if ([event type] == NSOtherMouseDown){
- button = Qt::MidButton;
- state = Qt::MidButton;
- }
- else {
- [NSException raise:IFRuntimeError format:@"IFWebView::mouseDown: unknown button type"];
- button = 0; state = 0; // Shutup the compiler.
- }
- NSPoint p = [event locationInWindow];
-
- [self _addModifiers:[event modifierFlags] toState:&state];
-
- QMouseEvent kEvent(QEvent::MouseButtonPress, QPoint((int)p.x, (int)p.y), button, state);
- KHTMLView *widget = _private->widget;
- if (widget != 0l) {
- widget->viewportMousePressEvent(&kEvent);
- }
-}
-
-- (void)mouseMovedNotification: (NSNotification *)notification
-{
- NSEvent *event = [(NSDictionary *)[notification userInfo] objectForKey: @"NSEvent"];
- NSPoint p = [event locationInWindow];
-
- // Only act on the mouse move event if it's inside this view (and
- // not inside a subview)
- if ([[[self window] contentView] hitTest:p] == self) {
- QMouseEvent kEvent(QEvent::MouseButtonPress, QPoint((int)p.x, (int)p.y), 0, 0);
- KHTMLView *widget = _private->widget;
- if (widget != 0l) {
- widget->viewportMouseMoveEvent(&kEvent);
- }
- }
-}
-
-- (void)mouseDragged: (NSEvent *)event
-{
- NSPoint p = [event locationInWindow];
- //WebKitDebugAtLevel (WEBKIT_LOG_EVENTS, "mouseDragged %f, %f\n", p.x, p.y);
-}
-
-- (void)keyDown: (NSEvent *)event
-{
- WEBKITDEBUGLEVEL(WEBKIT_LOG_EVENTS, "keyDown: %s\n", DEBUG_OBJECT(event));
- int state = 0;
-
- [self _addModifiers:[event modifierFlags] toState:&state];
- QKeyEvent kEvent(QEvent::KeyPress, 0, 0, state, NSSTRING_TO_QSTRING([event characters]), [event isARepeat], 1);
-
- KHTMLView *widget = _private->widget;
- if (widget != 0l)
- widget->keyPressEvent(&kEvent);
-}
-
-
-- (void)keyUp: (NSEvent *)event
-{
- WEBKITDEBUGLEVEL(WEBKIT_LOG_EVENTS, "keyUp: %s\n", DEBUG_OBJECT(event));
- int state = 0;
-
- [self _addModifiers:[event modifierFlags] toState:&state];
- QKeyEvent kEvent(QEvent::KeyPress, 0, 0, state, NSSTRING_TO_QSTRING([event characters]), [event isARepeat], 1);
-
- KHTMLView *widget = _private->widget;
- if (widget != 0l)
- widget->keyReleaseEvent(&kEvent);
-}
-
-- (void)setCursor:(NSCursor *)cursor
-{
- [_private->cursor release];
- _private->cursor = [cursor retain];
-
- // We have to make both of these calls, because:
- // - Just setting a cursor rect will have no effect, if the mouse cursor is already
- // inside the area of the rect.
- // - Just calling invalidateCursorRectsForView will not call resetCursorRects if
- // there is no cursor rect set currently and the view has no subviews.
- // Therefore we have to call resetCursorRects to ensure that a cursor rect is set
- // at all, if we are going to want one, and then invalidateCursorRectsForView: to
- // call resetCursorRects from the proper context that will
- // actually result in updating the cursor.
- [self resetCursorRects];
- [[self window] invalidateCursorRectsForView:self];
-}
-
-- (void)resetCursorRects
-{
- if (_private->cursor != nil && _private->cursor != [NSCursor arrowCursor]) {
- [self addCursorRect:[self visibleRect] cursor:_private->cursor];
- }
-}
-
@end
diff --git a/WebKit/WebView.subproj/WebFrameViewInternal.h b/WebKit/WebView.subproj/WebFrameViewInternal.h
index 33764e4..db43810 100644
--- a/WebKit/WebView.subproj/WebFrameViewInternal.h
+++ b/WebKit/WebView.subproj/WebFrameViewInternal.h
@@ -9,34 +9,33 @@
#import <WebKit/IFWebView.h>
class QWidget;
-class KHTMLPart;
-class KHTMLView;
+
@interface IFWebViewPrivate : NSObject
{
IFWebController *controller;
- KHTMLView *widget;
- KHTMLView *provisionalWidget;
+ id documentView;
NSScrollView *frameScrollView;
- bool isFlipped;
- bool needsLayout;
- bool needsToApplyStyles;
- bool canDragTo;
- bool canDragFrom;
- NSArray *draggingTypes;
- NSCursor *cursor;
+
+ // These margin values are used to temporarily hold
+ // the margins of a frame until we have the appropriate
+ // document view type.
+ int marginWidth;
+ int marginHeight;
+
+ BOOL allowsScrolling;
}
@end
@interface IFWebView (IFPrivate)
+- (void)_setDocumentView:(id <IFDocumentLoading>)view;
- (void)_setController: (IFWebController *)controller;
-- (void)_resetWidget;
-- (KHTMLView *)_widget;
-- (KHTMLView *)_provisionalWidget;
-- (void)_stopPlugins;
-- (void)_removeSubviews;
- (void)_setFrameScrollView: (NSScrollView *)sv;
- (NSScrollView *)_frameScrollView;
- (void)_setupScrollers;
+- (int)_marginWidth;
+- (int)_marginHeight;
++ (NSMutableDictionary *)_viewTypes;
++ (BOOL)_canShowMIMEType:(NSString *)MIMEType;
@end
diff --git a/WebKit/WebView.subproj/WebFrameViewPrivate.h b/WebKit/WebView.subproj/WebFrameViewPrivate.h
index 33764e4..db43810 100644
--- a/WebKit/WebView.subproj/WebFrameViewPrivate.h
+++ b/WebKit/WebView.subproj/WebFrameViewPrivate.h
@@ -9,34 +9,33 @@
#import <WebKit/IFWebView.h>
class QWidget;
-class KHTMLPart;
-class KHTMLView;
+
@interface IFWebViewPrivate : NSObject
{
IFWebController *controller;
- KHTMLView *widget;
- KHTMLView *provisionalWidget;
+ id documentView;
NSScrollView *frameScrollView;
- bool isFlipped;
- bool needsLayout;
- bool needsToApplyStyles;
- bool canDragTo;
- bool canDragFrom;
- NSArray *draggingTypes;
- NSCursor *cursor;
+
+ // These margin values are used to temporarily hold
+ // the margins of a frame until we have the appropriate
+ // document view type.
+ int marginWidth;
+ int marginHeight;
+
+ BOOL allowsScrolling;
}
@end
@interface IFWebView (IFPrivate)
+- (void)_setDocumentView:(id <IFDocumentLoading>)view;
- (void)_setController: (IFWebController *)controller;
-- (void)_resetWidget;
-- (KHTMLView *)_widget;
-- (KHTMLView *)_provisionalWidget;
-- (void)_stopPlugins;
-- (void)_removeSubviews;
- (void)_setFrameScrollView: (NSScrollView *)sv;
- (NSScrollView *)_frameScrollView;
- (void)_setupScrollers;
+- (int)_marginWidth;
+- (int)_marginHeight;
++ (NSMutableDictionary *)_viewTypes;
++ (BOOL)_canShowMIMEType:(NSString *)MIMEType;
@end
diff --git a/WebKit/WebView.subproj/WebFrameViewPrivate.m b/WebKit/WebView.subproj/WebFrameViewPrivate.m
index eee7488..1d75df0 100644
--- a/WebKit/WebView.subproj/WebFrameViewPrivate.m
+++ b/WebKit/WebView.subproj/WebFrameViewPrivate.m
@@ -6,28 +6,31 @@
NSWebPageView.
*/
#import <WebKit/WebKitDebug.h>
-
+#import <WebKit/IFDynamicScrollBarsView.h>
#import <WebKit/IFWebViewPrivate.h>
-#import <WebKit/IFPluginView.h>
+#import <WebKit/IFWebController.h>
+#import <WebKit/IFHTMLView.h>
+#import <WebKit/IFImageView.h>
+#import <WebKit/IFTextView.h>
-// Includes from KDE
-#import <khtmlview.h>
-#import <khtml_part.h>
-#import <html/html_documentimpl.h>
-#import "IFWebController.h"
+static NSMutableDictionary *_viewTypes=nil;
@implementation IFWebViewPrivate
+- init
+{
+ [super init];
+
+ marginWidth = -1;
+ marginHeight = -1;
+
+ return self;
+}
+
- (void)dealloc
{
- [controller release];
[frameScrollView release];
- [draggingTypes release];
- [cursor release];
-
- //if (widget)
- // delete widget;
-
+ [documentView release];
[super dealloc];
}
@@ -35,48 +38,43 @@
@implementation IFWebView (IFPrivate)
-- (void)_resetWidget
+- (void)_setMarginWidth: (int)w
{
- delete _private->widget;
- _private->widget = 0;
+ _private->marginWidth = w;
}
-- (void)_stopPlugins
+- (int)_marginWidth
{
- NSArray *subviews = [[self subviews] copy];
- int count = [subviews count];
- while (count--) {
- id view = [subviews objectAtIndex:count];
- if ([view isKindOfClass:[IFPluginView class]]) {
- IFPluginView *pluginView = (IFPluginView *)view;
- [pluginView stop];
- }
- }
- [subviews release];
+ return _private->marginWidth;
}
-- (void)_removeSubviews
+- (void)_setMarginHeight: (int)h
{
- // Remove all the views. They will be be re-added if this is a re-layout.
- NSArray *subviews = [[self subviews] copy];
- [subviews makeObjectsPerformSelector:@selector(removeFromSuperviewWithoutNeedingDisplay)];
- [subviews release];
+ _private->marginHeight = h;
}
-- (void)_setController: (IFWebController *)controller
+- (int)_marginHeight
{
- // Not retained; the controller owns the view.
- _private->controller = controller;
+ return _private->marginHeight;
}
-- (KHTMLView *)_widget
+- (void)_setDocumentView:(id)view
{
- return _private->widget;
+ [[self _frameScrollView] setDocumentView: view];
+
+ // Set the size of the new document scroll view to the size
+ // of the IFWebView.
+ [[self _frameScrollView] setFrame:[self frame]];
+
+ [view retain];
+ [_private->documentView release];
+ _private->documentView = view;
}
-- (KHTMLView *)_provisionalWidget
+- (void)_setController: (IFWebController *)controller
{
- return _private->provisionalWidget;
+ // Not retained; the controller owns the view.
+ _private->controller = controller;
}
- (void)_setFrameScrollView: (NSScrollView *)sv
@@ -84,11 +82,8 @@
[sv retain];
[_private->frameScrollView release];
_private->frameScrollView = sv;
- //[sv setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
- //[sv setHasVerticalScroller: YES];
- //[sv setHasHorizontalScroller: YES];
- [self setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
- [sv setDocumentView: self];
+ [sv setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
+ [self addSubview: sv];
}
- (NSScrollView *)_frameScrollView
@@ -110,4 +105,38 @@
}
}
++ (NSMutableDictionary *)_viewTypes
+{
+ if(!_viewTypes){
+ _viewTypes = [[NSMutableDictionary dictionary] retain];
+ [_viewTypes setObject:[IFHTMLView class] forKey:@"text/html"];
+ [_viewTypes setObject:[IFTextView class] forKey:@"text/"];
+ [_viewTypes setObject:[IFImageView class] forKey:@"image/jpeg"];
+ [_viewTypes setObject:[IFImageView class] forKey:@"image/gif"];
+ [_viewTypes setObject:[IFImageView class] forKey:@"image/png"];
+ }
+ return _viewTypes;
+}
+
++ (BOOL)_canShowMIMEType:(NSString *)MIMEType
+{
+ NSMutableDictionary *viewTypes = [[self class] _viewTypes];
+ NSArray *keys;
+ unsigned i;
+
+ if([viewTypes objectForKey:MIMEType]){
+ return YES;
+ }else{
+ keys = [viewTypes allKeys];
+ for(i=0; i<[keys count]; i++){
+ if([[keys objectAtIndex:i] hasSuffix:@"/"] && [MIMEType hasPrefix:[keys objectAtIndex:i]]){
+ if([viewTypes objectForKey:[keys objectAtIndex:i]]){
+ return YES;
+ }
+ }
+ }
+ }
+ return NO;
+}
+
@end
diff --git a/WebKit/WebView.subproj/WebHTMLRepresentation.h b/WebKit/WebView.subproj/WebHTMLRepresentation.h
new file mode 100644
index 0000000..8a1981f
--- /dev/null
+++ b/WebKit/WebView.subproj/WebHTMLRepresentation.h
@@ -0,0 +1,26 @@
+/*
+ IFHTMLRepresentation.h
+ Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#import <Foundation/Foundation.h>
+
+
+ at class IFError;
+ at class IFWebDataSource;
+
+class KHTMLPart;
+
+ at protocol IFDocumentRepresentation;
+
+ at interface IFHTMLRepresentation : NSObject <IFDocumentRepresentation>
+{
+ KHTMLPart *part;
+ BOOL isFirstChunk;
+}
+
+- (KHTMLPart *)part;
+- (void)receivedData:(NSData *)data withDataSource:(IFWebDataSource *)dataSource isComplete:(BOOL)isComplete;
+- (void)receivedError:(IFError *)error withDataSource:(IFWebDataSource *)dataSource;
+
+ at end
diff --git a/WebKit/WebView.subproj/WebHTMLRepresentation.m b/WebKit/WebView.subproj/WebHTMLRepresentation.m
new file mode 100644
index 0000000..2ce5385
--- /dev/null
+++ b/WebKit/WebView.subproj/WebHTMLRepresentation.m
@@ -0,0 +1,49 @@
+/*
+ IFHTMLRepresentation.mm
+ Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#import <WebKit/IFHTMLRepresentation.h>
+#import <WebKit/IFWebDataSource.h>
+#import <KWQKHTMLPartImpl.h>
+
+ at implementation IFHTMLRepresentation
+
+- init
+{
+ part = new KHTMLPart();
+ isFirstChunk = YES;
+
+ return self;
+}
+
+- (void)dealloc
+{
+ part->deref();
+}
+
+- (KHTMLPart *)part
+{
+ return part;
+}
+
+- (void)receivedData:(NSData *)data withDataSource:(IFWebDataSource *)dataSource isComplete:(BOOL)isComplete
+{
+ if(isFirstChunk){
+ // FIXME [rjw]: Do any work need in the kde engine. This should be removed.
+ // We should move any code needed out of KWQ.
+ part->openURL([[[dataSource inputURL] absoluteString] cString]);
+ part->impl->setDataSource(dataSource);
+ }
+
+ part->impl->slotData([dataSource encoding], (const char *)[data bytes], [data length], isComplete);
+
+ isFirstChunk = NO;
+}
+
+- (void)receivedError:(IFError *)error withDataSource:(IFWebDataSource *)dataSource
+{
+
+}
+
+ at end
diff --git a/WebKit/WebView.subproj/WebFrameView.h b/WebKit/WebView.subproj/WebHTMLView.h
similarity index 79%
copy from WebKit/WebView.subproj/WebFrameView.h
copy to WebKit/WebView.subproj/WebHTMLView.h
index 933968c..ddf0dc5 100644
--- a/WebKit/WebView.subproj/WebFrameView.h
+++ b/WebKit/WebView.subproj/WebHTMLView.h
@@ -1,8 +1,8 @@
/*
- IFWebView.h
- Copyright 2001, Apple, Inc. All rights reserved.
+ IFHTMLView.h
+ Copyright 2002, Apple, Inc. All rights reserved.
- Public header file.
+ Private header file.
*/
#import <Cocoa/Cocoa.h>
@@ -13,24 +13,24 @@
@class IFWebDataSource;
@class IFWebController;
+ at class IFHTMLViewPrivate;
+ at protocol IFDocumentLoading;
+ at protocol IFDocumentDragSettings;
+ at protocol IFDocumentSearching;
- at class IFWebViewPrivate;
-
- at interface IFWebView : NSView
+ at interface IFHTMLView : NSView <IFDocumentLoading, IFDocumentDragSettings, IFDocumentSearching>
{
@private
- IFWebViewPrivate *_private;
+ IFHTMLViewPrivate *_private;
}
- initWithFrame: (NSRect)frame;
-// Note that the controller is not retained.
-- (IFWebController *)controller;
-
// These methods is typically called by the view's controller when
// the data source is changed.
-- (void)dataSourceChanged: (IFWebDataSource *)dataSource;
-- (void)provisionalDataSourceChanged: (IFWebDataSource *)dataSource;
+- (void)provisionalDataSourceChanged:(IFWebDataSource *)dataSource;
+- (void)provisionalDataSourceCommitted:(IFWebDataSource *)dataSource;
+- (void)dataSourceUpdated:(IFWebDataSource *)dataSource;
- (void)setNeedsLayout: (bool)flag;
diff --git a/WebKit/WebView.subproj/IFWebView.mm b/WebKit/WebView.subproj/WebHTMLView.m
similarity index 93%
copy from WebKit/WebView.subproj/IFWebView.mm
copy to WebKit/WebView.subproj/WebHTMLView.m
index a2b43d7..52b8b29 100644
--- a/WebKit/WebView.subproj/IFWebView.mm
+++ b/WebKit/WebView.subproj/WebHTMLView.m
@@ -1,6 +1,9 @@
-/* IFWebView.mm
- Copyright 2001, Apple, Inc. All rights reserved.
+/* IFHTMLView.mm
+ Copyright 2002, Apple, Inc. All rights reserved.
*/
+
+#import <WebKit/IFHTMLView.h>
+#import <WebKit/IFHTMLViewPrivate.h>
#import <WebKit/IFWebView.h>
#import <WebKit/IFWebViewPrivate.h>
#import <WebKit/IFWebFrame.h>
@@ -13,6 +16,8 @@
#import <WebKit/IFTextRendererFactory.h>
#import <WebKit/IFImageRendererFactory.h>
#import <WebKit/WebKitDebug.h>
+#import <WebKit/IFHTMLRepresentation.h>
+#import <WebKit/IFNSViewExtras.h>
#import <WebFoundation/IFNSStringExtensions.h>
@@ -28,7 +33,7 @@
#import <KWQKHTMLPartImpl.h>
- at implementation IFWebView
+ at implementation IFHTMLView
- initWithFrame: (NSRect) frame
{
@@ -38,7 +43,7 @@
[IFTextRendererFactory createSharedFactory];
[IFImageRendererFactory createSharedFactory];
- _private = [[IFWebViewPrivate alloc] init];
+ _private = [[IFHTMLViewPrivate alloc] init];
_private->isFlipped = YES;
_private->needsLayout = YES;
@@ -50,7 +55,7 @@
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(windowResized:) name: NSWindowDidResizeNotification object: nil];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(mouseMovedNotification:) name: NSMouseMovedNotification object: nil];
-
+
return self;
}
@@ -70,13 +75,6 @@
}
-// Note that the controller is not retained.
-- (IFWebController *)controller
-{
- return _private->controller;
-}
-
-
- (void)removeFromSuperview
{
[self _stopPlugins];
@@ -90,37 +88,49 @@
[super removeFromSuperviewWithoutNeedingDisplay];
}
-
// This method is typically called by the view's controller when
// the data source is changed.
- (void)provisionalDataSourceChanged: (IFWebDataSource *)dataSource
{
NSRect r = [self frame];
- IFWebView *provisionalView;
+ IFHTMLView *provisionalView;
// Nasty! Setup the cross references between the KHTMLView and
// the KHTMLPart.
- KHTMLPart *part = [dataSource _part];
+ KHTMLPart *part = [[dataSource representation] part];
_private->provisionalWidget = new KHTMLView (part, 0);
part->impl->setView (_private->provisionalWidget);
// Create a temporary provisional view. It will be replaced with
// the actual view once the datasource has been committed.
- provisionalView = [[IFWebView alloc] initWithFrame: NSMakeRect (0,0,0,0)];
+ provisionalView = [[IFHTMLView alloc] initWithFrame: NSMakeRect (0,0,0,0)];
+
+ // PROBLEM!! This provisionalView may become the actual view in the case
+ // of a sub frame. We need to create an IFWebView/IFDSV here.
_private->provisionalWidget->setView (provisionalView);
+
[provisionalView release];
+ int mw = [[[dataSource webFrame] view] _marginWidth];
+ if (mw >= 0)
+ _private->provisionalWidget->setMarginWidth (mw);
+ int mh = [[[dataSource webFrame] view] _marginHeight];
+ if (mh >= 0)
+ _private->provisionalWidget->setMarginHeight (mh);
+
_private->provisionalWidget->resize ((int)r.size.width, (int)r.size.height);
+
}
-- (void)dataSourceChanged: (IFWebDataSource *)dataSource
+- (void)provisionalDataSourceCommitted: (IFWebDataSource *)dataSource
{
- IFWebViewPrivate *data = _private;
-
+ IFHTMLViewPrivate *data = _private;
+ IFWebView *webView = (IFWebView *)[self _IF_superviewWithName:@"IFWebView"];
+
// Setup the real view.
- if ([self _frameScrollView])
- data->provisionalWidget->setView ([self _frameScrollView]);
+ if ([webView _frameScrollView])
+ data->provisionalWidget->setView ([webView _frameScrollView]);
else
data->provisionalWidget->setView (self);
@@ -134,6 +144,11 @@
data->provisionalWidget = 0;
}
+- (void)dataSourceUpdated: (IFWebDataSource *)dataSource
+{
+
+}
+
- (void)reapplyStyles
{
KHTMLView *widget = _private->widget;
@@ -274,7 +289,8 @@
return NO;
dataSource = [[[IFWebDataSource alloc] initWithURL:URL] autorelease];
- frame = [[self controller] frameForView:self];
+ frame = nil;
+ //frame = [[self controller] frameForView:self];
[frame setProvisionalDataSource:dataSource];
[frame startLoading];
diff --git a/WebKit/WebView.subproj/WebFrameViewInternal.h b/WebKit/WebView.subproj/WebHTMLViewPrivate.h
similarity index 82%
copy from WebKit/WebView.subproj/WebFrameViewInternal.h
copy to WebKit/WebView.subproj/WebHTMLViewPrivate.h
index 33764e4..16770e7 100644
--- a/WebKit/WebView.subproj/WebFrameViewInternal.h
+++ b/WebKit/WebView.subproj/WebHTMLViewPrivate.h
@@ -1,18 +1,18 @@
-/* IFWebViewPrivate.h
- Copyright 2001, Apple, Inc. All rights reserved.
+/* IFHTMLViewPrivate.h
+ Copyright 2002, Apple, Inc. All rights reserved.
Private header file. This file may reference classes (both ObjectiveC and C++)
in WebCore. Instances of this class are referenced by _private in
NSWebPageView.
*/
-#import <WebKit/IFWebView.h>
+#import <WebKit/IFHTMLView.h>
class QWidget;
class KHTMLPart;
class KHTMLView;
- at interface IFWebViewPrivate : NSObject
+ at interface IFHTMLViewPrivate : NSObject
{
IFWebController *controller;
KHTMLView *widget;
@@ -29,7 +29,7 @@ class KHTMLView;
@end
- at interface IFWebView (IFPrivate)
+ at interface IFHTMLView (IFPrivate)
- (void)_setController: (IFWebController *)controller;
- (void)_resetWidget;
- (KHTMLView *)_widget;
diff --git a/WebKit/WebView.subproj/WebFrameViewPrivate.m b/WebKit/WebView.subproj/WebHTMLViewPrivate.m
similarity index 70%
copy from WebKit/WebView.subproj/WebFrameViewPrivate.m
copy to WebKit/WebView.subproj/WebHTMLViewPrivate.m
index eee7488..fdf0fb6 100644
--- a/WebKit/WebView.subproj/WebFrameViewPrivate.m
+++ b/WebKit/WebView.subproj/WebHTMLViewPrivate.m
@@ -1,5 +1,5 @@
-/* IFWebViewPrivate.mm
- Copyright 2001, Apple, Inc. All rights reserved.
+/* IFHTMLViewPrivate.mm
+ Copyright 2002, Apple, Inc. All rights reserved.
Private header file. This file may reference classes (both ObjectiveC and C++)
in WebCore. Instances of this class are referenced by _private in
@@ -7,7 +7,7 @@
*/
#import <WebKit/WebKitDebug.h>
-#import <WebKit/IFWebViewPrivate.h>
+#import <WebKit/IFHTMLViewPrivate.h>
#import <WebKit/IFPluginView.h>
// Includes from KDE
@@ -16,7 +16,7 @@
#import <html/html_documentimpl.h>
#import "IFWebController.h"
- at implementation IFWebViewPrivate
+ at implementation IFHTMLViewPrivate
- (void)dealloc
{
@@ -33,7 +33,7 @@
@end
- at implementation IFWebView (IFPrivate)
+ at implementation IFHTMLView (IFPrivate)
- (void)_resetWidget
{
@@ -74,6 +74,45 @@
return _private->widget;
}
+- (DOM::DocumentImpl *)_document
+{
+ KHTMLPart *part = _private->widget->part();
+ if (part) {
+ return part->xmlDocImpl();
+ }
+ return 0;
+}
+
++ (NSString *)_nodeName: (DOM::NodeImpl *)node
+{
+ // FIXME: good for debugging only since it's Latin 1 only
+ return [NSString stringWithCString:node->nodeName().string().latin1()];
+}
+
++ (NSString *)_nodeValue: (DOM::NodeImpl *)node
+{
+ // FIXME: good for debugging only since it's Latin 1 only
+ return [NSString stringWithCString:node->nodeValue().string().latin1()];
+}
+
++ (NSString *)_nodeHTML: (DOM::NodeImpl *)node
+{
+ NSString *string = QSTRING_TO_NSSTRING(node->recursive_toHTML(1));
+ return string;
+}
+
+- (khtml::RenderObject *)_renderRoot
+{
+ KHTMLPart *part = _private->widget->part();
+ DOM::DocumentImpl *doc;
+ if (part) {
+ doc = part->xmlDocImpl();
+ if (doc)
+ return doc->renderer();
+ }
+ return 0;
+}
+
- (KHTMLView *)_provisionalWidget
{
return _private->provisionalWidget;
diff --git a/WebKit/WebView.subproj/WebImageRepresentation.h b/WebKit/WebView.subproj/WebImageRepresentation.h
new file mode 100644
index 0000000..c24babe
--- /dev/null
+++ b/WebKit/WebView.subproj/WebImageRepresentation.h
@@ -0,0 +1,22 @@
+/*
+ IFImageRepresentation.h
+ Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#import <Foundation/Foundation.h>
+
+ at class IFError;
+ at class IFWebDataSource;
+ at class IFImageRenderer;
+ at protocol IFDocumentRepresentation;
+
+ at interface IFImageRepresentation : NSObject <IFDocumentRepresentation>
+{
+ IFImageRenderer *image;
+}
+
+- (IFImageRenderer *)image;
+- (void)receivedData:(NSData *)data withDataSource:(IFWebDataSource *)dataSource isComplete:(BOOL)isComplete;
+- (void)receivedError:(IFError *)error withDataSource:(IFWebDataSource *)dataSource;
+
+ at end
diff --git a/WebKit/WebView.subproj/WebImageRepresentation.m b/WebKit/WebView.subproj/WebImageRepresentation.m
new file mode 100644
index 0000000..a1a3507
--- /dev/null
+++ b/WebKit/WebView.subproj/WebImageRepresentation.m
@@ -0,0 +1,42 @@
+/*
+ IFImageRepresentation.m
+ Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#import "IFImageRepresentation.h"
+#import <WebKit/IFWebDataSource.h>
+#import <WebKit/IFImageRenderer.h>
+#import <WebKit/IFImageRendererFactory.h>
+
+ at implementation IFImageRepresentation
+
+- init
+{
+ self = [super init];
+ if (self) {
+ //image = [[IFImageRenderer alloc] init];
+ }
+ return self;
+}
+
+- (IFImageRenderer *)image
+{
+ return image;
+}
+
+- (void)receivedData:(NSData *)data withDataSource:(IFWebDataSource *)dataSource isComplete:(BOOL)isComplete
+{
+ if(isComplete){
+ NSData *resourceData = [dataSource data];
+ image = [[IFImageRendererFactory alloc] imageRendererWithBytes:[resourceData bytes]
+ length:[resourceData length]];
+ }
+ //[image incrementalLoadWithBytes:[data bytes] length:[data length] complete:isComplete];
+}
+
+- (void)receivedError:(IFError *)error withDataSource:(IFWebDataSource *)dataSource
+{
+
+}
+
+ at end
diff --git a/WebKit/WebView.subproj/WebImageView.h b/WebKit/WebView.subproj/WebImageView.h
new file mode 100644
index 0000000..cc0e398
--- /dev/null
+++ b/WebKit/WebView.subproj/WebImageView.h
@@ -0,0 +1,33 @@
+/*
+ IFImageView.h
+ Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#import <AppKit/AppKit.h>
+
+ at class IFWebDataSource;
+ at class IFImageRepresentation;
+ at protocol IFDocumentLoading;
+ at protocol IFDocumentDragSettings;
+
+ at interface IFImageView : NSView <IFDocumentLoading, IFDocumentDragSettings>
+{
+ IFImageRepresentation *representation;
+ BOOL canDragFrom;
+ BOOL canDragTo;
+ BOOL didSetFrame;
+}
+
+
+- (void)provisionalDataSourceChanged:(IFWebDataSource *)dataSource;
+- (void)provisionalDataSourceCommitted:(IFWebDataSource *)dataSource;
+- (void)dataSourceUpdated:(IFWebDataSource *)dataSource;
+- (void)layout;
+
+- (void)setCanDragFrom: (BOOL)flag;
+- (BOOL)canDragFrom;
+- (void)setCanDragTo: (BOOL)flag;
+- (BOOL)canDragTo;
+
+
+ at end
diff --git a/WebKit/WebView.subproj/WebImageView.m b/WebKit/WebView.subproj/WebImageView.m
new file mode 100644
index 0000000..dc9a78a
--- /dev/null
+++ b/WebKit/WebView.subproj/WebImageView.m
@@ -0,0 +1,91 @@
+/*
+ IFImageView.m
+ Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#import "IFImageView.h"
+#import <WebKit/IFWebDataSource.h>
+#import <WebKit/IFImageRenderer.h>
+#import <WebKit/IFImageRepresentation.h>
+
+ at implementation IFImageView
+
+- (id)initWithFrame:(NSRect)frame {
+
+ self = [super initWithFrame:frame];
+ if (self) {
+ canDragFrom = YES;
+ canDragTo = YES;
+ didSetFrame = NO;
+ }
+ return self;
+}
+
+- (void)dealloc
+{
+ [[representation image] stopAnimation];
+ [representation release];
+}
+
+
+- (void)drawRect:(NSRect)rect {
+ IFImageRenderer *image;
+ NSSize imageSize;
+
+ image = [representation image];
+ if([representation image]){
+
+ imageSize = [image size];
+ [image beginAnimationInView:self inRect:rect fromRect:NSMakeRect(0, 0, imageSize.width, imageSize.height)];
+ }
+}
+
+- (void)provisionalDataSourceChanged:(IFWebDataSource *)dataSource
+{
+
+}
+
+- (void)provisionalDataSourceCommitted:(IFWebDataSource *)dataSource
+{
+ representation = [[dataSource representation] retain];
+}
+
+- (void)dataSourceUpdated:(IFWebDataSource *)dataSource
+{
+
+}
+
+- (void)layout
+{
+ if([representation image] && !didSetFrame){
+ IFImageRenderer *image = [representation image];
+ NSSize imageSize = [image size];
+ NSRect frame = [self frame];
+
+ [self setFrame:NSMakeRect(frame.origin.x, frame.origin.x, imageSize.width, imageSize.height)];
+ didSetFrame = YES;
+ }
+}
+
+- (void)setCanDragFrom: (BOOL)flag
+{
+ canDragFrom = flag;
+}
+
+- (BOOL)canDragFrom
+{
+ return canDragFrom;
+}
+
+- (void)setCanDragTo: (BOOL)flag
+{
+ canDragTo = flag;
+}
+
+- (BOOL)canDragTo
+{
+ return canDragTo;
+}
+
+
+ at end
diff --git a/WebKit/WebView.subproj/WebMainResourceClient.h b/WebKit/WebView.subproj/WebMainResourceClient.h
index f1ccc14..835a670 100644
--- a/WebKit/WebView.subproj/WebMainResourceClient.h
+++ b/WebKit/WebView.subproj/WebMainResourceClient.h
@@ -6,7 +6,7 @@
Copyright 2001, Apple, Inc. All rights reserved.
*/
-#import <WebKit/IFMIMEHandler.h>
+
#import <WebKit/IFLocationChangeHandler.h>
#import <WebFoundation/IFURLHandle.h>
@@ -18,20 +18,14 @@ class KHTMLPart;
@interface IFMainURLHandleClient : NSObject <IFURLHandleClient>
{
+ NSURL *url;
id dataSource;
KHTMLPart *part;
- BOOL sentFakeDocForNonHTMLContentType, processedBufferedData, downloadStarted, loadFinished, examinedInitialData;
- IFMIMEHandlerType handlerType;
- IFDownloadHandler *downloadHandler;
- IFContentPolicy contentPolicy;
- NSData *resourceData;
- NSString *encoding, *MIMEType;
- NSURL *url;
+ BOOL processedBufferedData;
+ BOOL examinedInitialData;
+ BOOL isFirstChunk;
}
-- initWithDataSource: (IFWebDataSource *)ds part: (KHTMLPart *)p;
-- (void)setContentPolicy:(IFContentPolicy)theContentPolicy;
+- initWithDataSource: (IFWebDataSource *)ds;
-- (void) processData:(NSData *)data isComplete:(BOOL)complete allDataReceived:(BOOL)allDataReceived;
-- (void) finishProcessingData:(NSData *)data;
@end
diff --git a/WebKit/WebView.subproj/WebMainResourceClient.m b/WebKit/WebView.subproj/WebMainResourceClient.m
index 4b77070..d5ba7b6 100644
--- a/WebKit/WebView.subproj/WebMainResourceClient.m
+++ b/WebKit/WebView.subproj/WebMainResourceClient.m
@@ -4,41 +4,35 @@
Copyright 2001, Apple, Inc. All rights reserved.
*/
-#import <WebKit/IFMainURLHandleClient.h>
-
-#import <pthread.h>
-
+#import <WebKit/IFDocument.h>
+#import <WebKit/IFHTMLRepresentation.h>
#import <WebKit/IFLoadProgress.h>
+#import <WebKit/IFLocationChangeHandler.h>
+#import <WebKit/IFMainURLHandleClient.h>
+#import <WebKit/IFWebController.h>
#import <WebKit/IFWebControllerPrivate.h>
-#import <WebKit/WebKitDebug.h>
-#import <WebKit/IFContentHandler.h>
-#import <WebKit/IFDownloadHandler.h>
#import <WebKit/IFWebDataSource.h>
#import <WebKit/IFWebDataSourcePrivate.h>
-#import <WebKit/IFWebController.h>
-#import <WebKit/IFLocationChangeHandler.h>
#import <WebKit/IFWebFrame.h>
#import <WebKit/IFWebFramePrivate.h>
+#import <WebKit/IFWebView.h>
+#import <WebKit/WebKitDebug.h>
+
+#import <KWQKHTMLPartImpl.h>
#import <WebFoundation/IFError.h>
-#import <khtmlview.h>
-#import <KWQKHTMLPartImpl.h>
+
@implementation IFMainURLHandleClient
-- initWithDataSource: (IFWebDataSource *)ds part:(KHTMLPart *)p
+- initWithDataSource: (IFWebDataSource *)ds
{
if ((self = [super init])) {
dataSource = [ds retain];
- part = p;
- part->ref();
- sentFakeDocForNonHTMLContentType = NO;
- downloadStarted = NO;
- loadFinished = NO;
examinedInitialData = NO;
processedBufferedData = NO;
- contentPolicy = IFContentPolicyNone;
+ isFirstChunk = YES;
return self;
}
@@ -49,27 +43,10 @@
{
WEBKIT_ASSERT(url == nil);
- part->deref();
[dataSource release];
- [resourceData release];
- [encoding release];
- [MIMEType release];
[super dealloc];
}
-// This method should never get called more than once.
-// Also, this method should never be passed a IFContentPolicyNone.
-- (void)setContentPolicy:(IFContentPolicy)theContentPolicy
-{
- WEBKIT_ASSERT(contentPolicy == IFContentPolicyNone);
- WEBKIT_ASSERT(theContentPolicy != IFContentPolicyNone);
-
- contentPolicy = theContentPolicy;
-
- if(loadFinished)
- [self processData:resourceData isComplete:YES allDataReceived:loadFinished];
-}
-
- (void)IFURLHandleResourceDidBeginLoading:(IFURLHandle *)sender
{
WEBKITDEBUGLEVEL (WEBKIT_LOG_LOADING, "url = %s\n", DEBUG_OBJECT([sender url]));
@@ -87,8 +64,6 @@
WEBKIT_ASSERT([url isEqual:[sender redirectedURL] ? [sender redirectedURL] : [sender url]]);
- [downloadHandler release];
-
IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
loadProgress->totalToLoad = -1;
loadProgress->bytesSoFar = -1;
@@ -107,14 +82,7 @@
WEBKIT_ASSERT([url isEqual:[sender redirectedURL] ? [sender redirectedURL] : [sender url]]);
- loadFinished = YES;
-
- if(contentPolicy != IFContentPolicyNone){
- [self finishProcessingData:data];
- }else{
- // If the content policy hasn't been set, save the data until it has.
- resourceData = [data retain];
- }
+ [dataSource _setResourceData:data];
// update progress
IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
@@ -133,6 +101,11 @@
{
int contentLength = [sender contentLength];
int contentLengthReceived = [sender contentLengthReceived];
+ BOOL isComplete = (contentLength == contentLengthReceived);
+ NSString *contentType = [sender contentType];
+ IFWebFrame *frame = [dataSource webFrame];
+ IFWebView *view = [frame view];
+ IFContentPolicy contentPolicy;
WEBKITDEBUGLEVEL(WEBKIT_LOG_LOADING, "url = %s, data = %p, length %d\n", DEBUG_OBJECT([sender url]), data, [data length]);
@@ -140,17 +113,14 @@
// Check the mime type and ask the client for the content policy.
if(!examinedInitialData){
- MIMEType = [[sender contentType] retain];
- WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "main content type: %s", DEBUG_OBJECT(MIMEType));
- [[dataSource _locationChangeHandler] requestContentPolicyForMIMEType:MIMEType];
-
- // FIXME: Remove/replace IFMIMEHandler stuff
- handlerType = [IFMIMEHandler MIMEHandlerTypeForMIMEType:MIMEType];
-
- encoding = [[sender characterSet] retain];
+ WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "main content type: %s", DEBUG_OBJECT(contentType));
+ [dataSource _setContentType:contentType];
+ [dataSource _setEncoding:[sender characterSet]];
+ [[dataSource _locationChangeHandler] requestContentPolicyForMIMEType:contentType];
examinedInitialData = YES;
}
+ contentPolicy = [dataSource contentPolicy];
if(contentPolicy == IFContentPolicyIgnore){
[sender cancelLoadInBackground];
return;
@@ -158,12 +128,19 @@
if(contentPolicy != IFContentPolicyNone){
if(!processedBufferedData){
- // process all data that has been received now that we have a content policy
- [self processData:[sender resourceData] isComplete:NO allDataReceived:(contentLength == contentLengthReceived)];
- processedBufferedData = YES;
+ // Process all data that has been received now that we have a content policy
+ // and don't call resourceData if this is the first chunk since resourceData is a copy
+ if(isFirstChunk){
+ [[dataSource representation] receivedData:data withDataSource:dataSource isComplete:isComplete];
+ }else{
+ [[dataSource representation] receivedData:[sender resourceData]
+ withDataSource:dataSource isComplete:isComplete];
+ }
+ processedBufferedData = YES;
}else{
- [self processData:data isComplete:NO allDataReceived:(contentLength == contentLengthReceived)];
+ [[dataSource representation] receivedData:data withDataSource:dataSource isComplete:isComplete];
}
+ [[view documentView] dataSourceUpdated:dataSource];
}
WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "%d of %d", contentLengthReceived, contentLength);
@@ -182,6 +159,8 @@
[(IFWebController *)[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress
forResource: [[sender url] absoluteString] fromDataSource: dataSource];
[loadProgress release];
+
+ isFirstChunk = NO;
}
@@ -190,8 +169,6 @@
WEBKITDEBUGLEVEL (WEBKIT_LOG_LOADING, "url = %s, result = %s\n", DEBUG_OBJECT([sender url]), DEBUG_OBJECT([result errorDescription]));
WEBKIT_ASSERT([url isEqual:[sender redirectedURL] ? [sender redirectedURL] : [sender url]]);
-
- [downloadHandler release];
IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
loadProgress->totalToLoad = [sender contentLength];
@@ -216,93 +193,11 @@
url = newURL;
[(IFWebController *)[dataSource controller] _didStartLoading:url];
- part->impl->setBaseURL([[url absoluteString] cString]);
+ if([dataSource _isDocumentHTML])
+ [[dataSource representation] part]->impl->setBaseURL([[url absoluteString] cString]);
[dataSource _setFinalURL:url];
[[dataSource _locationChangeHandler] serverRedirectTo:url forDataSource:dataSource];
}
-
-- (void) processData:(NSData *)data isComplete:(BOOL)complete allDataReceived:(BOOL)allDataReceived
-{
- NSString *fakeHTMLDocument;
- const char *fakeHTMLDocumentBytes;
- IFContentHandler *contentHandler;
- IFWebFrame *frame;
-
- WEBKIT_ASSERT(url != nil);
-
- if(contentPolicy == IFContentPolicyShow){
-
- if(handlerType == IFMIMEHANDLERTYPE_NIL || handlerType == IFMIMEHANDLERTYPE_HTML) {
- // If data is html, send it to the part.
- part->impl->slotData(encoding, (const char *)[data bytes], [data length], allDataReceived);
- }
-
- else if(handlerType == IFMIMEHANDLERTYPE_IMAGE ||
- handlerType == IFMIMEHANDLERTYPE_PLUGIN ||
- handlerType == IFMIMEHANDLERTYPE_TEXT) {
-
- // For a non-html document, create html doc that embeds it.
- if (!sentFakeDocForNonHTMLContentType) {
- contentHandler = [[IFContentHandler alloc] initWithURL:url MIMEType:MIMEType MIMEHandlerType:handlerType];
- fakeHTMLDocument = [contentHandler HTMLDocument];
- fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
- part->impl->slotData(encoding, fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes), allDataReceived);
- [contentHandler release];
- sentFakeDocForNonHTMLContentType = YES;
- }
-
- // For text documents, the incoming data is part of the main page.
- if(handlerType == IFMIMEHANDLERTYPE_TEXT){
- part->impl->slotData(encoding, (const char *)[data bytes], [data length], allDataReceived);
- }
- }
- }
-
- else if(contentPolicy == IFContentPolicySave || contentPolicy == IFContentPolicyOpenExternally){
- if(!downloadStarted){
-
- // If this is a download, detach the provisionalDataSource from the frame
- // and have downloadHandler retain it.
- downloadHandler = [[IFDownloadHandler alloc] initWithDataSource:dataSource];
- frame = [dataSource webFrame];
- [frame->_private setProvisionalDataSource:nil];
-
- // go right to locationChangeDone as the data source never gets committed.
- [[dataSource _locationChangeHandler] locationChangeDone:nil];
- downloadStarted = YES;
- }
- }
-
- if(complete)
- [self finishProcessingData:data];
-}
-
-- (void) finishProcessingData:(NSData *)data;
-{
- NSString *fakeHTMLDocument;
- const char *fakeHTMLDocumentBytes;
- IFContentHandler *contentHandler;
-
- WEBKIT_ASSERT(url != nil);
-
- if(contentPolicy == IFContentPolicyShow){
- if(handlerType == IFMIMEHANDLERTYPE_TEXT) {
- contentHandler = [[IFContentHandler alloc] initWithURL:url MIMEType:MIMEType MIMEHandlerType:IFMIMEHANDLERTYPE_TEXT];
- fakeHTMLDocument = [contentHandler textHTMLDocumentBottom];
- fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
- part->impl->slotData(encoding, fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes), YES);
- [contentHandler release];
- }
- }
-
- else if(contentPolicy == IFContentPolicySave || contentPolicy == IFContentPolicyOpenExternally){
- // FIXME [cblu]: We shouldn't wait for the download to end to write to the disk.
- // Will fix once we there is an IFURLHandle flag to not cache in memory (2903660).
- [downloadHandler downloadCompletedWithData:data];
- [downloadHandler release];
- }
-}
-
@end
diff --git a/WebKit/WebView.subproj/WebMainResourceLoader.h b/WebKit/WebView.subproj/WebMainResourceLoader.h
index f1ccc14..835a670 100644
--- a/WebKit/WebView.subproj/WebMainResourceLoader.h
+++ b/WebKit/WebView.subproj/WebMainResourceLoader.h
@@ -6,7 +6,7 @@
Copyright 2001, Apple, Inc. All rights reserved.
*/
-#import <WebKit/IFMIMEHandler.h>
+
#import <WebKit/IFLocationChangeHandler.h>
#import <WebFoundation/IFURLHandle.h>
@@ -18,20 +18,14 @@ class KHTMLPart;
@interface IFMainURLHandleClient : NSObject <IFURLHandleClient>
{
+ NSURL *url;
id dataSource;
KHTMLPart *part;
- BOOL sentFakeDocForNonHTMLContentType, processedBufferedData, downloadStarted, loadFinished, examinedInitialData;
- IFMIMEHandlerType handlerType;
- IFDownloadHandler *downloadHandler;
- IFContentPolicy contentPolicy;
- NSData *resourceData;
- NSString *encoding, *MIMEType;
- NSURL *url;
+ BOOL processedBufferedData;
+ BOOL examinedInitialData;
+ BOOL isFirstChunk;
}
-- initWithDataSource: (IFWebDataSource *)ds part: (KHTMLPart *)p;
-- (void)setContentPolicy:(IFContentPolicy)theContentPolicy;
+- initWithDataSource: (IFWebDataSource *)ds;
-- (void) processData:(NSData *)data isComplete:(BOOL)complete allDataReceived:(BOOL)allDataReceived;
-- (void) finishProcessingData:(NSData *)data;
@end
diff --git a/WebKit/WebView.subproj/WebMainResourceLoader.m b/WebKit/WebView.subproj/WebMainResourceLoader.m
index 4b77070..d5ba7b6 100644
--- a/WebKit/WebView.subproj/WebMainResourceLoader.m
+++ b/WebKit/WebView.subproj/WebMainResourceLoader.m
@@ -4,41 +4,35 @@
Copyright 2001, Apple, Inc. All rights reserved.
*/
-#import <WebKit/IFMainURLHandleClient.h>
-
-#import <pthread.h>
-
+#import <WebKit/IFDocument.h>
+#import <WebKit/IFHTMLRepresentation.h>
#import <WebKit/IFLoadProgress.h>
+#import <WebKit/IFLocationChangeHandler.h>
+#import <WebKit/IFMainURLHandleClient.h>
+#import <WebKit/IFWebController.h>
#import <WebKit/IFWebControllerPrivate.h>
-#import <WebKit/WebKitDebug.h>
-#import <WebKit/IFContentHandler.h>
-#import <WebKit/IFDownloadHandler.h>
#import <WebKit/IFWebDataSource.h>
#import <WebKit/IFWebDataSourcePrivate.h>
-#import <WebKit/IFWebController.h>
-#import <WebKit/IFLocationChangeHandler.h>
#import <WebKit/IFWebFrame.h>
#import <WebKit/IFWebFramePrivate.h>
+#import <WebKit/IFWebView.h>
+#import <WebKit/WebKitDebug.h>
+
+#import <KWQKHTMLPartImpl.h>
#import <WebFoundation/IFError.h>
-#import <khtmlview.h>
-#import <KWQKHTMLPartImpl.h>
+
@implementation IFMainURLHandleClient
-- initWithDataSource: (IFWebDataSource *)ds part:(KHTMLPart *)p
+- initWithDataSource: (IFWebDataSource *)ds
{
if ((self = [super init])) {
dataSource = [ds retain];
- part = p;
- part->ref();
- sentFakeDocForNonHTMLContentType = NO;
- downloadStarted = NO;
- loadFinished = NO;
examinedInitialData = NO;
processedBufferedData = NO;
- contentPolicy = IFContentPolicyNone;
+ isFirstChunk = YES;
return self;
}
@@ -49,27 +43,10 @@
{
WEBKIT_ASSERT(url == nil);
- part->deref();
[dataSource release];
- [resourceData release];
- [encoding release];
- [MIMEType release];
[super dealloc];
}
-// This method should never get called more than once.
-// Also, this method should never be passed a IFContentPolicyNone.
-- (void)setContentPolicy:(IFContentPolicy)theContentPolicy
-{
- WEBKIT_ASSERT(contentPolicy == IFContentPolicyNone);
- WEBKIT_ASSERT(theContentPolicy != IFContentPolicyNone);
-
- contentPolicy = theContentPolicy;
-
- if(loadFinished)
- [self processData:resourceData isComplete:YES allDataReceived:loadFinished];
-}
-
- (void)IFURLHandleResourceDidBeginLoading:(IFURLHandle *)sender
{
WEBKITDEBUGLEVEL (WEBKIT_LOG_LOADING, "url = %s\n", DEBUG_OBJECT([sender url]));
@@ -87,8 +64,6 @@
WEBKIT_ASSERT([url isEqual:[sender redirectedURL] ? [sender redirectedURL] : [sender url]]);
- [downloadHandler release];
-
IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
loadProgress->totalToLoad = -1;
loadProgress->bytesSoFar = -1;
@@ -107,14 +82,7 @@
WEBKIT_ASSERT([url isEqual:[sender redirectedURL] ? [sender redirectedURL] : [sender url]]);
- loadFinished = YES;
-
- if(contentPolicy != IFContentPolicyNone){
- [self finishProcessingData:data];
- }else{
- // If the content policy hasn't been set, save the data until it has.
- resourceData = [data retain];
- }
+ [dataSource _setResourceData:data];
// update progress
IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
@@ -133,6 +101,11 @@
{
int contentLength = [sender contentLength];
int contentLengthReceived = [sender contentLengthReceived];
+ BOOL isComplete = (contentLength == contentLengthReceived);
+ NSString *contentType = [sender contentType];
+ IFWebFrame *frame = [dataSource webFrame];
+ IFWebView *view = [frame view];
+ IFContentPolicy contentPolicy;
WEBKITDEBUGLEVEL(WEBKIT_LOG_LOADING, "url = %s, data = %p, length %d\n", DEBUG_OBJECT([sender url]), data, [data length]);
@@ -140,17 +113,14 @@
// Check the mime type and ask the client for the content policy.
if(!examinedInitialData){
- MIMEType = [[sender contentType] retain];
- WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "main content type: %s", DEBUG_OBJECT(MIMEType));
- [[dataSource _locationChangeHandler] requestContentPolicyForMIMEType:MIMEType];
-
- // FIXME: Remove/replace IFMIMEHandler stuff
- handlerType = [IFMIMEHandler MIMEHandlerTypeForMIMEType:MIMEType];
-
- encoding = [[sender characterSet] retain];
+ WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "main content type: %s", DEBUG_OBJECT(contentType));
+ [dataSource _setContentType:contentType];
+ [dataSource _setEncoding:[sender characterSet]];
+ [[dataSource _locationChangeHandler] requestContentPolicyForMIMEType:contentType];
examinedInitialData = YES;
}
+ contentPolicy = [dataSource contentPolicy];
if(contentPolicy == IFContentPolicyIgnore){
[sender cancelLoadInBackground];
return;
@@ -158,12 +128,19 @@
if(contentPolicy != IFContentPolicyNone){
if(!processedBufferedData){
- // process all data that has been received now that we have a content policy
- [self processData:[sender resourceData] isComplete:NO allDataReceived:(contentLength == contentLengthReceived)];
- processedBufferedData = YES;
+ // Process all data that has been received now that we have a content policy
+ // and don't call resourceData if this is the first chunk since resourceData is a copy
+ if(isFirstChunk){
+ [[dataSource representation] receivedData:data withDataSource:dataSource isComplete:isComplete];
+ }else{
+ [[dataSource representation] receivedData:[sender resourceData]
+ withDataSource:dataSource isComplete:isComplete];
+ }
+ processedBufferedData = YES;
}else{
- [self processData:data isComplete:NO allDataReceived:(contentLength == contentLengthReceived)];
+ [[dataSource representation] receivedData:data withDataSource:dataSource isComplete:isComplete];
}
+ [[view documentView] dataSourceUpdated:dataSource];
}
WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "%d of %d", contentLengthReceived, contentLength);
@@ -182,6 +159,8 @@
[(IFWebController *)[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress
forResource: [[sender url] absoluteString] fromDataSource: dataSource];
[loadProgress release];
+
+ isFirstChunk = NO;
}
@@ -190,8 +169,6 @@
WEBKITDEBUGLEVEL (WEBKIT_LOG_LOADING, "url = %s, result = %s\n", DEBUG_OBJECT([sender url]), DEBUG_OBJECT([result errorDescription]));
WEBKIT_ASSERT([url isEqual:[sender redirectedURL] ? [sender redirectedURL] : [sender url]]);
-
- [downloadHandler release];
IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
loadProgress->totalToLoad = [sender contentLength];
@@ -216,93 +193,11 @@
url = newURL;
[(IFWebController *)[dataSource controller] _didStartLoading:url];
- part->impl->setBaseURL([[url absoluteString] cString]);
+ if([dataSource _isDocumentHTML])
+ [[dataSource representation] part]->impl->setBaseURL([[url absoluteString] cString]);
[dataSource _setFinalURL:url];
[[dataSource _locationChangeHandler] serverRedirectTo:url forDataSource:dataSource];
}
-
-- (void) processData:(NSData *)data isComplete:(BOOL)complete allDataReceived:(BOOL)allDataReceived
-{
- NSString *fakeHTMLDocument;
- const char *fakeHTMLDocumentBytes;
- IFContentHandler *contentHandler;
- IFWebFrame *frame;
-
- WEBKIT_ASSERT(url != nil);
-
- if(contentPolicy == IFContentPolicyShow){
-
- if(handlerType == IFMIMEHANDLERTYPE_NIL || handlerType == IFMIMEHANDLERTYPE_HTML) {
- // If data is html, send it to the part.
- part->impl->slotData(encoding, (const char *)[data bytes], [data length], allDataReceived);
- }
-
- else if(handlerType == IFMIMEHANDLERTYPE_IMAGE ||
- handlerType == IFMIMEHANDLERTYPE_PLUGIN ||
- handlerType == IFMIMEHANDLERTYPE_TEXT) {
-
- // For a non-html document, create html doc that embeds it.
- if (!sentFakeDocForNonHTMLContentType) {
- contentHandler = [[IFContentHandler alloc] initWithURL:url MIMEType:MIMEType MIMEHandlerType:handlerType];
- fakeHTMLDocument = [contentHandler HTMLDocument];
- fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
- part->impl->slotData(encoding, fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes), allDataReceived);
- [contentHandler release];
- sentFakeDocForNonHTMLContentType = YES;
- }
-
- // For text documents, the incoming data is part of the main page.
- if(handlerType == IFMIMEHANDLERTYPE_TEXT){
- part->impl->slotData(encoding, (const char *)[data bytes], [data length], allDataReceived);
- }
- }
- }
-
- else if(contentPolicy == IFContentPolicySave || contentPolicy == IFContentPolicyOpenExternally){
- if(!downloadStarted){
-
- // If this is a download, detach the provisionalDataSource from the frame
- // and have downloadHandler retain it.
- downloadHandler = [[IFDownloadHandler alloc] initWithDataSource:dataSource];
- frame = [dataSource webFrame];
- [frame->_private setProvisionalDataSource:nil];
-
- // go right to locationChangeDone as the data source never gets committed.
- [[dataSource _locationChangeHandler] locationChangeDone:nil];
- downloadStarted = YES;
- }
- }
-
- if(complete)
- [self finishProcessingData:data];
-}
-
-- (void) finishProcessingData:(NSData *)data;
-{
- NSString *fakeHTMLDocument;
- const char *fakeHTMLDocumentBytes;
- IFContentHandler *contentHandler;
-
- WEBKIT_ASSERT(url != nil);
-
- if(contentPolicy == IFContentPolicyShow){
- if(handlerType == IFMIMEHANDLERTYPE_TEXT) {
- contentHandler = [[IFContentHandler alloc] initWithURL:url MIMEType:MIMEType MIMEHandlerType:IFMIMEHANDLERTYPE_TEXT];
- fakeHTMLDocument = [contentHandler textHTMLDocumentBottom];
- fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
- part->impl->slotData(encoding, fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes), YES);
- [contentHandler release];
- }
- }
-
- else if(contentPolicy == IFContentPolicySave || contentPolicy == IFContentPolicyOpenExternally){
- // FIXME [cblu]: We shouldn't wait for the download to end to write to the disk.
- // Will fix once we there is an IFURLHandle flag to not cache in memory (2903660).
- [downloadHandler downloadCompletedWithData:data];
- [downloadHandler release];
- }
-}
-
@end
diff --git a/WebKit/WebView.subproj/WebRenderNode.m b/WebKit/WebView.subproj/WebRenderNode.m
index f5010b0..b239f10 100644
--- a/WebKit/WebView.subproj/WebRenderNode.m
+++ b/WebKit/WebView.subproj/WebRenderNode.m
@@ -8,7 +8,8 @@
#import "IFRenderNode.h"
-#import <IFWebViewPrivate.h>
+#import <WebKit/IFWebView.h>
+#import <WebKit/IFHTMLViewPrivate.h>
#import <khtmlview.h>
#import <khtml_part.h>
#import <xml/dom_docimpl.h>
@@ -54,7 +55,7 @@
- initWithWebView:(IFWebView *)view
{
- return [self initWithRenderObject:[view _widget]->part()->xmlDocImpl()->renderer()];
+ return [self initWithRenderObject:[[view documentView] _widget]->part()->xmlDocImpl()->renderer()];
}
- (void)dealloc
diff --git a/WebKit/WebView.subproj/WebTextRepresentation.h b/WebKit/WebView.subproj/WebTextRepresentation.h
new file mode 100644
index 0000000..68fcdc5
--- /dev/null
+++ b/WebKit/WebView.subproj/WebTextRepresentation.h
@@ -0,0 +1,20 @@
+/*
+ IFTextRepresentation.h
+ Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#import <Foundation/Foundation.h>
+
+ at class IFError;
+ at class IFWebDataSource;
+ at protocol IFDocumentRepresentation;
+
+ at interface IFTextRepresentation : NSObject <IFDocumentRepresentation>
+{
+
+}
+
+- (void)receivedData:(NSData *)data withDataSource:(IFWebDataSource *)dataSource isComplete:(BOOL)isComplete;
+- (void)receivedError:(IFError *)error withDataSource:(IFWebDataSource *)dataSource;
+
+ at end
diff --git a/WebKit/WebView.subproj/WebTextRepresentation.m b/WebKit/WebView.subproj/WebTextRepresentation.m
new file mode 100644
index 0000000..ec31613
--- /dev/null
+++ b/WebKit/WebView.subproj/WebTextRepresentation.m
@@ -0,0 +1,21 @@
+/*
+ IFTextRepresentation.h
+ Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#import "IFTextRepresentation.h"
+
+
+ at implementation IFTextRepresentation
+
+- (void)receivedData:(NSData *)data withDataSource:(IFWebDataSource *)dataSource isComplete:(BOOL)isComplete
+{
+
+}
+
+- (void)receivedError:(IFError *)error withDataSource:(IFWebDataSource *)dataSource
+{
+
+}
+
+ at end
diff --git a/WebKit/WebView.subproj/WebTextView.h b/WebKit/WebView.subproj/WebTextView.h
new file mode 100644
index 0000000..418c8b0
--- /dev/null
+++ b/WebKit/WebView.subproj/WebTextView.h
@@ -0,0 +1,31 @@
+/*
+ IFTextView.h
+ Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#import <Cocoa/Cocoa.h>
+
+ at class IFWebDataSource;
+ at protocol IFDocumentLoading;
+ at protocol IFDocumentDragSettings;
+ at protocol IFDocumentSearching;
+
+ at interface IFTextView : NSTextView <IFDocumentLoading, IFDocumentDragSettings, IFDocumentSearching>
+{
+ BOOL canDragFrom;
+ BOOL canDragTo;
+}
+
+- (void)provisionalDataSourceChanged:(IFWebDataSource *)dataSource;
+- (void)provisionalDataSourceCommitted:(IFWebDataSource *)dataSource;
+- (void)dataSourceUpdated:(IFWebDataSource *)dataSource;
+- (void)layout;
+
+- (void)setCanDragFrom: (BOOL)flag;
+- (BOOL)canDragFrom;
+- (void)setCanDragTo: (BOOL)flag;
+- (BOOL)canDragTo;
+
+- (void)searchFor: (NSString *)string direction: (BOOL)forward caseSensitive: (BOOL)caseFlag;
+
+ at end
diff --git a/WebKit/WebView.subproj/WebTextView.m b/WebKit/WebView.subproj/WebTextView.m
new file mode 100644
index 0000000..56d790b
--- /dev/null
+++ b/WebKit/WebView.subproj/WebTextView.m
@@ -0,0 +1,71 @@
+/*
+ IFTextView.m
+ Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#import "IFTextView.h"
+#import <WebKit/IFWebDataSource.h>
+
+ at implementation IFTextView
+
+
+- (id)initWithFrame:(NSRect)frame {
+
+ self = [super initWithFrame:frame];
+ if (self) {
+ canDragFrom = YES;
+ canDragTo = YES;
+ [[self textContainer] setWidthTracksTextView:YES];
+ [self setAutoresizingMask:NSViewWidthSizable];
+ [self setRichText:YES];
+ }
+ return self;
+}
+
+- (void)provisionalDataSourceChanged:(IFWebDataSource *)dataSource
+{
+
+}
+
+- (void)provisionalDataSourceCommitted:(IFWebDataSource *)dataSource
+{
+
+}
+
+- (void)dataSourceUpdated:(IFWebDataSource *)dataSource
+{
+ NSString *theString = [[NSString alloc] initWithData:[dataSource data] encoding:NSASCIIStringEncoding];
+ [self setString:theString];
+ [theString release];
+}
+
+- (void)layout
+{
+}
+
+- (void)setCanDragFrom: (BOOL)flag
+{
+ canDragFrom = flag;
+}
+
+- (BOOL)canDragFrom
+{
+ return canDragFrom;
+}
+
+- (void)setCanDragTo: (BOOL)flag
+{
+ canDragTo = flag;
+}
+
+- (BOOL)canDragTo
+{
+ return canDragTo;
+}
+
+- (void)searchFor: (NSString *)string direction: (BOOL)forward caseSensitive: (BOOL)caseFlag
+{
+
+}
+
+ at end
diff --git a/WebKit/WebView.subproj/WebView.h b/WebKit/WebView.subproj/WebView.h
index e48022f..f8312d5 100644
--- a/WebKit/WebView.subproj/WebView.h
+++ b/WebKit/WebView.subproj/WebView.h
@@ -37,6 +37,8 @@
@class IFWebController;
@class IFWebControllerPrivate;
+ at protocol IFDocumentLoading;
+
/*
=============================================================================
@@ -106,14 +108,6 @@ typedef enum {
IFWebControllerPrivate *_private;
}
-/*
-// Called when the content policy is set to IFContentPolicyShow
-+ (id <IFDocumentView>) createViewForMIMEType:(NSString *)MIMEType
-
-// registerClass extends the views that WebKit supports
-+ (void) registerClass:(Class)class forMIMEType:(NSString *)MIMEType
-*/
-
// Calls designated initializer with nil arguments.
- init;
@@ -176,5 +170,6 @@ typedef enum {
- (void)stopAnimatedImageLooping;
- (void)startAnimatedImageLooping;
++ (BOOL)canShowMIMEType:(NSString *)MIMEType;
@end
diff --git a/WebKit/WebView.subproj/WebView.m b/WebKit/WebView.subproj/WebView.m
index 8f01fb4..4155631 100644
--- a/WebKit/WebView.subproj/WebView.m
+++ b/WebKit/WebView.subproj/WebView.m
@@ -3,14 +3,16 @@
Copyright 2001, 2002 Apple, Inc. All rights reserved.
*/
+#import <WebKit/IFDocument.h>
+#import <WebKit/IFDynamicScrollBarsView.h>
+#import <WebKit/IFException.h>
+#import <WebKit/IFPluginDatabase.h>
#import <WebKit/IFWebController.h>
#import <WebKit/IFWebControllerPrivate.h>
#import <WebKit/IFWebViewPrivate.h>
#import <WebKit/IFWebDataSourcePrivate.h>
#import <WebKit/IFWebFrame.h>
#import <WebKit/IFWebFramePrivate.h>
-#import <WebKit/IFDynamicScrollBarsView.h>
-#import <WebKit/IFException.h>
#import <WebKit/IFWebController.h>
#import <WebKit/WebKitDebug.h>
@@ -18,18 +20,6 @@
@implementation IFWebController
-/*
-+ (id <IFDocumentView>) createViewForMIMEType:(NSString *)MIMEType
-{
- return nil;
-}
-
-+ (void) registerClass:(Class)class forMIMEType:(NSString *)MIMEType
-{
-
-}
-*/
-
- init
{
return [self initWithView: nil provisionalDataSource: nil];
@@ -66,7 +56,6 @@
{
IFWebView *childView;
IFWebFrame *newFrame;
- NSScrollView *scrollView;
childView = [[[IFWebView alloc] initWithFrame: NSMakeRect (0,0,0,0)] autorelease];
@@ -77,12 +66,7 @@
[childView _setController: self];
[childDataSource _setController: self];
- if (inScrollView == YES){
- scrollView = [[[IFDynamicScrollBarsView alloc] initWithFrame: NSMakeRect(0,0,0,0)] autorelease];
- [scrollView setHasVerticalScroller: NO];
- [scrollView setHasHorizontalScroller: NO];
- [childView _setFrameScrollView: scrollView];
- }
+ [childView setAllowsScrolling: inScrollView];
return newFrame;
}
@@ -262,6 +246,7 @@
- (void)haveContentPolicy: (IFContentPolicy)policy andPath: (NSString *)path forLocationChangeHandler: (id <IFLocationChangeHandler>)handler
{
IFWebDataSource *mainDataSource, *mainProvisionalDataSource, *dataSource;
+ NSString *MIMEType;
if(policy == IFContentPolicyNone)
[NSException raise:NSInvalidArgumentException format:@"Can't set policy of IFContentPolicyNone. Use IFContentPolicyIgnore instead"];
@@ -279,6 +264,24 @@
}else{
[dataSource _setContentPolicy:policy];
[dataSource _setDownloadPath:path];
+
+ if(policy == IFContentPolicyShow){
+ MIMEType = [dataSource contentType];
+ if([[self class] canShowMIMEType:MIMEType]){
+ id documentView;
+ IFWebView *webView;
+ id <IFDocumentRepresentation> dataRepresentation;
+
+ dataRepresentation = [IFWebDataSource createRepresentationForMIMEType:MIMEType];
+ [dataSource _setRepresentation:dataRepresentation];
+ webView = [[dataSource webFrame] view];
+ documentView = [IFWebView createViewForMIMEType:MIMEType];
+ [webView _setDocumentView: documentView];
+ [documentView provisionalDataSourceChanged: dataSource];
+ }else{
+ // return error with unableToImplementContentPolicy
+ }
+ }
}
}
}
@@ -299,4 +302,17 @@
{
}
++ (BOOL)canShowMIMEType:(NSString *)MIMEType
+{
+ if([IFWebView _canShowMIMEType:MIMEType] && [IFWebDataSource _canShowMIMEType:MIMEType]){
+ return YES;
+ }else{
+ // Have the plug-ins register views
+ [IFPluginDatabase installedPlugins];
+ if([IFWebView _canShowMIMEType:MIMEType] && [IFWebDataSource _canShowMIMEType:MIMEType])
+ return YES;
+ }
+ return NO;
+}
+
@end
diff --git a/WebKit/WebView.subproj/WebViewPrivate.h b/WebKit/WebView.subproj/WebViewPrivate.h
index a169cee..bf07746 100644
--- a/WebKit/WebView.subproj/WebViewPrivate.h
+++ b/WebKit/WebView.subproj/WebViewPrivate.h
@@ -4,6 +4,7 @@
*/
#import <WebKit/IFWebController.h>
+//#import <WebKit/IFDocument.h>
@class IFError;
@class IFLoadProgress;
diff --git a/WebKit/WebView.subproj/WebViewPrivate.m b/WebKit/WebView.subproj/WebViewPrivate.m
index cb21f7b..9e630cf 100644
--- a/WebKit/WebView.subproj/WebViewPrivate.m
+++ b/WebKit/WebView.subproj/WebViewPrivate.m
@@ -18,7 +18,6 @@
#import <WebKit/WebKitDebug.h>
-
@implementation IFWebControllerPrivate
- init
@@ -51,8 +50,8 @@
[self _clearControllerReferences: mainFrame];
[mainFrame reset];
-
[mainFrame autorelease];
+
[super dealloc];
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list