summaryrefslogtreecommitdiff
path: root/UICaboodle
diff options
context:
space:
mode:
Diffstat (limited to 'UICaboodle')
-rw-r--r--UICaboodle/BrowserView.m44
-rw-r--r--UICaboodle/RVBook.h2
-rw-r--r--UICaboodle/RVBook.mm25
3 files changed, 61 insertions, 10 deletions
diff --git a/UICaboodle/BrowserView.m b/UICaboodle/BrowserView.m
index 2742e60..68427d2 100644
--- a/UICaboodle/BrowserView.m
+++ b/UICaboodle/BrowserView.m
@@ -306,13 +306,20 @@
}
- (void) _fixScroller {
+ CGRect bounds([webview_ documentBounds]);
+#if ForSaurik
+ NSLog(@"_fs:(%f,%f+%f,%f)", bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height);
+#endif
+
float extra;
if (!editing_)
extra = 0;
else {
UIFormAssistant *assistant([UIFormAssistant sharedFormAssistant]);
CGRect peripheral([assistant peripheralFrame]);
+#if ForSaurik
NSLog(@"per:%f", peripheral.size.height);
+#endif
extra = peripheral.size.height;
}
@@ -320,13 +327,21 @@
subrect.size.height -= extra;
[scroller_ setScrollerIndicatorSubrect:subrect];
+ NSSize visible(NSMakeSize(subrect.size.width, subrect.size.height));
+ [webview_ setValue:[NSValue valueWithSize:visible] forGestureAttribute:UIGestureAttributeVisibleSize];
+
CGSize size(size_);
size.height += extra;
[scroller_ setContentSize:size];
+
+ [scroller_ releaseRubberBandIfNecessary];
}
- (void) view:(UIView *)sender didSetFrame:(CGRect)frame {
size_ = frame.size;
+#if ForSaurik
+ NSLog(@"dsf:(%f,%f+%f,%f)", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
+#endif
[self _fixScroller];
}
@@ -348,6 +363,14 @@
[book_ pushPage:self];
}
+- (void) swapPage:(RVPage *)page {
+ [page setDelegate:delegate_];
+ if (pushed_)
+ [book_ swapPage:page];
+ else
+ [book_ pushPage:page];
+}
+
- (BOOL) getSpecial:(NSURL *)url {
#if ForSaurik
NSLog(@"getSpecial:%@", url);
@@ -368,7 +391,7 @@
return false;
if (page != nil)
- [self pushPage:page];
+ [self swapPage:page];
return true;
}
@@ -522,13 +545,15 @@
[listener use];
}
-- (void) webView:(WebView *)webView decidePolicyForMIMEType:(NSString *)type request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener {
+- (void) webView:(WebView *)sender decidePolicyForMIMEType:(NSString *)type request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener {
if ([WebView canShowMIMEType:type])
[listener use];
else {
// XXX: handle more mime types!
[listener ignore];
- if (frame == [webView mainFrame])
+
+ WebView *webview([webview_ webView]);
+ if (frame == [webview mainFrame])
[UIApp openURL:[request URL]];
}
}
@@ -552,6 +577,10 @@
}
[listener use];
+
+ WebView *webview([webview_ webView]);
+ if (frame == [webview mainFrame])
+ [self _pushPage];
return;
}
#if ForSaurik
@@ -725,7 +754,7 @@
#endif
NSNumber *value([features objectForKey:@"width"]);
- float width(value == nil ? [BrowserView defaultWidth] : [value floatValue]);
+ float width(value == nil ? 0 : [value floatValue]);
RVBook *book(!popup_ ? book_ : [[[RVPopUpBook alloc] initWithFrame:[delegate_ popUpBounds]] autorelease]);
@@ -769,6 +798,8 @@
if ([frame parentFrame] != nil)
return;
+ [webview_ resignFirstResponder];
+
reloading_ = false;
loading_ = true;
[self reloadButtons];
@@ -796,6 +827,7 @@
[book_ reloadTitleForPage:self];
[scroller_ scrollPointVisibleAtTopLeft:CGPointZero];
+ [scroller_ setZoomScale:1 duration:0];
CGRect webrect = [scroller_ bounds];
webrect.size.height = 0;
@@ -912,7 +944,7 @@
}
- (void) setViewportWidth:(float)width {
- width_ = width;
+ width_ = width ? width != 0 : [[self class] defaultWidth];
[webview_ setViewportSize:CGSizeMake(width_, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x10];
}
@@ -1048,7 +1080,7 @@
}
- (id) initWithBook:(RVBook *)book {
- return [self initWithBook:book forWidth:[[self class] defaultWidth]];
+ return [self initWithBook:book forWidth:0];
}
- (void) didFinishGesturesInView:(UIView *)view forEvent:(id)event {
diff --git a/UICaboodle/RVBook.h b/UICaboodle/RVBook.h
index a7781e7..730f7bb 100644
--- a/UICaboodle/RVBook.h
+++ b/UICaboodle/RVBook.h
@@ -42,6 +42,8 @@
- (void) setPage:(RVPage *)page;
+- (void) swapPage:(RVPage *)page;
+- (void) pushPage:(RVPage *)page animated:(BOOL)animated;
- (void) pushPage:(RVPage *)page;
- (void) popPages:(unsigned)pages;
diff --git a/UICaboodle/RVBook.mm b/UICaboodle/RVBook.mm
index b639958..d7a3949 100644
--- a/UICaboodle/RVBook.mm
+++ b/UICaboodle/RVBook.mm
@@ -135,10 +135,22 @@
[navbar_ enableAnimation];
}
-- (void) pushPage:(RVPage *)page {
- if ([pages_ count] != 0)
- [[pages_ lastObject] setPageActive:NO];
+- (void) swapPage:(RVPage *)page {
+ if ([pages_ count] == 0)
+ return [self pushPage:page];
+
+ [[pages_ lastObject] setPageActive:NO];
+
+ [navbar_ disableAnimation];
+ resetting_ = true;
+ [navbar_ popNavigationItem];
+ resetting_ = false;
+ [self pushPage:page animated:NO];
+ [navbar_ enableAnimation];
+}
+
+- (void) pushPage:(RVPage *)page animated:(BOOL)animated {
NSString *title = [self getTitleForPage:page];
NSString *backButtonTitle = [page backButtonTitle];
@@ -149,7 +161,6 @@
[navitem setBackButtonTitle:backButtonTitle];
[navbar_ pushNavigationItem:navitem];
- BOOL animated = [pages_ count] == 0 ? NO : YES;
[page setFrame:[transition_ bounds]];
[transition_ transition:(animated ? 1 : 0) toView:page];
[page setPageActive:YES];
@@ -160,6 +171,12 @@
[navbar_ setAccessoryView:[page accessoryView] animate:animated removeOnPop:NO];
}
+- (void) pushPage:(RVPage *)page {
+ if ([pages_ count] != 0)
+ [[pages_ lastObject] setPageActive:NO];
+ [self pushPage:page animated:([pages_ count] == 0 ? NO : YES)];
+}
+
- (void) pushBook:(RVBook *)book {
[delegate_ popUpBook:book];
}