-- (BOOL) webView:(WebView *)sender shouldScrollToPoint:(struct CGPoint)point forFrame:(WebFrame *)frame {
- return [document_ webView:sender shouldScrollToPoint:point forFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didReceiveViewportArguments:(id)arguments forFrame:(WebFrame *)frame {
- return [document_ webView:sender didReceiveViewportArguments:arguments forFrame:frame];
-}
-
-- (void) webView:(WebView *)sender needsScrollNotifications:(id)notifications forFrame:(WebFrame *)frame {
- return [document_ webView:sender needsScrollNotifications:notifications forFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame {
- [self _pushPage];
- return [document_ webView:sender didCommitLoadForFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didReceiveDocTypeForFrame:(WebFrame *)frame {
- return [document_ webView:sender didReceiveDocTypeForFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
- [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
- [self _finishLoading];
-
- if ([frame parentFrame] == nil) {
- if (DOMDocument *document = [frame DOMDocument])
- if (DOMNodeList<NSFastEnumeration> *bodies = [document getElementsByTagName:@"body"])
- for (DOMHTMLBodyElement *body in bodies) {
- DOMCSSStyleDeclaration *style([document getComputedStyle:body pseudoElement:nil]);
-
- bool colored(false);
-
- if (DOMCSSPrimitiveValue *color = static_cast<DOMCSSPrimitiveValue *>([style getPropertyCSSValue:@"background-color"])) {
- if ([color primitiveType] == DOM_CSS_RGBCOLOR) {
- DOMRGBColor *rgb([color getRGBColorValue]);
-
- float red([[rgb red] getFloatValue:DOM_CSS_NUMBER]);
- float green([[rgb green] getFloatValue:DOM_CSS_NUMBER]);
- float blue([[rgb blue] getFloatValue:DOM_CSS_NUMBER]);
- float alpha([[rgb alpha] getFloatValue:DOM_CSS_NUMBER]);
-
- UIColor *uic(nil);
-
- if (red == 0xc7 && green == 0xce && blue == 0xd5)
- uic = [UIColor pinStripeColor];
- else if (alpha != 0)
- uic = [UIColor
- colorWithRed:(red / 255)
- green:(green / 255)
- blue:(blue / 255)
- alpha:alpha
- ];
-
- if (uic != nil) {
- colored = true;
- [scroller_ setBackgroundColor:uic];
- }
- }
- }
-
- if (!colored)
- [scroller_ setBackgroundColor:[UIColor pinStripeColor]];
- break;
- }
- }
-
- return [document_ webView:sender didFinishLoadForFrame:frame];
-}
-
-- (void) _didFailWithError:(NSError *)error forFrame:(WebFrame *)frame {
- _trace();
- /*if ([frame parentFrame] == nil)
- [self autorelease];*/
-
- [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
- [self _finishLoading];
-
- if (reloading_)
- return;
-
- if ([frame parentFrame] == nil) {
- [self loadURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?%@",
- [[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"error" ofType:@"html"]] absoluteString],
- [[error localizedDescription] stringByAddingPercentEscapes]
- ]]];
-
- error_ = true;
- }
-}
-
-- (void) webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
- [self _didFailWithError:error forFrame:frame];
- if ([document_ respondsToSelector:@selector(webView:didFailLoadWithError:forFrame:)])
- [document_ webView:sender didFailLoadWithError:error forFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
- [self _didFailWithError:error forFrame:frame];
-}
-
-- (void) webView:(WebView *)sender addMessageToConsole:(NSDictionary *)dictionary {
-#if LogBrowser || ForSaurik
- lprintf("Console:%s\n", [[dictionary description] UTF8String]);
-#endif
-}
-
-- (void) webView:(WebView *)sender didReceiveMessage:(NSDictionary *)dictionary {
-#if LogBrowser || ForSaurik
- lprintf("Console:%s\n", [[dictionary description] UTF8String]);
-#endif
- if ([document_ respondsToSelector:@selector(webView:didReceiveMessage:)])
- [document_ webView:sender didReceiveMessage:dictionary];
-}
-
-- (void) webView:(id)sender willCloseFrame:(id)frame {
- if ([document_ respondsToSelector:@selector(webView:willCloseFrame:)])
- [document_ webView:sender willCloseFrame:frame];
-}
-
-- (void) webView:(id)sender didFinishDocumentLoadForFrame:(id)frame {
- if ([document_ respondsToSelector:@selector(webView:didFinishDocumentLoadForFrame:)])
- [document_ webView:sender didFinishDocumentLoadForFrame:frame];
-}
-
-- (void) webView:(id)sender didFirstLayoutInFrame:(id)frame {
- if ([document_ respondsToSelector:@selector(webView:didFirstLayoutInFrame:)])
- [document_ webView:sender didFirstLayoutInFrame:frame];
-}
-
-- (void) webViewFormEditedStatusHasChanged:(id)changed {
- if ([document_ respondsToSelector:@selector(webViewFormEditedStatusHasChanged:)])
- [document_ webViewFormEditedStatusHasChanged:changed];
-}
-
-- (void) webView:(id)sender formStateDidFocusNode:(id)formState {
- if ([document_ respondsToSelector:@selector(webView:formStateDidFocusNode:)])
- [document_ webView:sender formStateDidFocusNode:formState];
-}
-
-- (void) webView:(id)sender formStateDidBlurNode:(id)formState {
- if ([document_ respondsToSelector:@selector(webView:formStateDidBlurNode:)])
- [document_ webView:sender formStateDidBlurNode:formState];
-}
-
-/* XXX: fix this stupid include file
-- (void) webView:(WebView *)sender frame:(WebFrame *)frame exceededDatabaseQuotaForSecurityOrigin:(WebSecurityOrigin *)origin database:(NSString *)database {
- [origin setQuota:0x500000];
-}*/
-
-- (void) webViewDidLayout:(id)sender {
- [document_ webViewDidLayout:sender];
-}
-
-- (void) webView:(id)sender didFirstVisuallyNonEmptyLayoutInFrame:(id)frame {
- [document_ webView:sender didFirstVisuallyNonEmptyLayoutInFrame:frame];
-}
-
-- (void) webView:(id)sender saveStateToHistoryItem:(id)item forFrame:(id)frame {
- [document_ webView:sender saveStateToHistoryItem:item forFrame:frame];
-}
-
-- (void) webView:(id)sender restoreStateFromHistoryItem:(id)item forFrame:(id)frame force:(BOOL)force {
- [document_ webView:sender restoreStateFromHistoryItem:item forFrame:frame force:force];
-}
-
-- (void) webView:(id)sender attachRootLayer:(id)layer {
- [document_ webView:sender attachRootLayer:layer];
-}
-
-- (id) webView:(id)sender plugInViewWithArguments:(id)arguments fromPlugInPackage:(id)package {
- return [document_ webView:sender plugInViewWithArguments:arguments fromPlugInPackage:package];
-}
-
-- (void) webView:(id)sender willShowFullScreenForPlugInView:(id)view {
- [document_ webView:sender willShowFullScreenForPlugInView:view];
-}
-
-- (void) webView:(id)sender didHideFullScreenForPlugInView:(id)view {
- [document_ webView:sender didHideFullScreenForPlugInView:view];
-}
-
-- (void) webView:(id)sender willAddPlugInView:(id)view {
- [document_ webView:sender willAddPlugInView:view];
-}
-
-- (void) webView:(id)sender didObserveDeferredContentChange:(int)change forFrame:(id)frame {
- [document_ webView:sender didObserveDeferredContentChange:change forFrame:frame];
-}
-
-- (void) webViewDidPreventDefaultForEvent:(id)sender {
- [document_ webViewDidPreventDefaultForEvent:sender];
-}
-
-- (void) _setTileDrawingEnabled:(BOOL)enabled {
- //[document_ setTileDrawingEnabled:enabled];
-}
-
-- (void) setViewportWidth:(float)width {
- width_ = width != 0 ? width : [[self class] defaultWidth];
- [document_ setViewportSize:CGSizeMake(width_, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x10];
-}
-
-- (void) willStartGesturesInView:(UIView *)view forEvent:(GSEventRef)event {
- [self _setTileDrawingEnabled:NO];
-}
-
-- (void) didFinishGesturesInView:(UIView *)view forEvent:(GSEventRef)event {
- [self _setTileDrawingEnabled:YES];
- [document_ redrawScaledDocument];
-}
-
-- (void) scrollerWillStartDragging:(UIScroller *)scroller {
- [self _setTileDrawingEnabled:NO];
-}
-
-- (void) scrollerDidEndDragging:(UIScroller *)scroller willSmoothScroll:(BOOL)smooth {
- [self _setTileDrawingEnabled:YES];
-}
-
-- (void) scrollerDidEndDragging:(UIScroller *)scroller {
- [self _setTileDrawingEnabled:YES];
-}
-