From 6245fa17d5bb5054129dd513497d1d026ed8dee6 Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Mon, 3 Oct 2016 21:39:55 +0200 Subject: [PATCH] =?UTF-8?q?Introduce=20=E2=80=98reusable=E2=80=99=20proper?= =?UTF-8?q?ty=20to=20OakHTMLOutputView?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This defaults to YES but can be set to NO if an output view should not be re-used (even though no command is currently running). --- .../DocumentWindow/src/DocumentWindowController.mm | 2 +- Frameworks/HTMLOutput/src/HTMLOutput.h | 1 + Frameworks/HTMLOutput/src/OakHTMLOutputView.h | 1 + Frameworks/HTMLOutput/src/OakHTMLOutputView.mm | 9 +++++++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Frameworks/DocumentWindow/src/DocumentWindowController.mm b/Frameworks/DocumentWindow/src/DocumentWindowController.mm index fbd8b670..be63cb59 100644 --- a/Frameworks/DocumentWindow/src/DocumentWindowController.mm +++ b/Frameworks/DocumentWindow/src/DocumentWindowController.mm @@ -1210,7 +1210,7 @@ static NSArray* const kObservedKeyPaths = @[ @"arrayController.arrangedObjects.p [htmlOutputViews addObject:[(HTMLOutputWindowController*)window.delegate htmlOutputView]]; } - NSArray* allHTMLViews = [htmlOutputViews filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"needsNewWebView == NO AND commandIdentifier == %@", identifier]]; + NSArray* allHTMLViews = [htmlOutputViews filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"needsNewWebView == NO AND isReusable == YES AND commandIdentifier == %@", identifier]]; NSArray* nonBusyViews = [allHTMLViews filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"isRunningCommand == NO"]]; if(OakHTMLOutputView* view = [nonBusyViews firstObject]) diff --git a/Frameworks/HTMLOutput/src/HTMLOutput.h b/Frameworks/HTMLOutput/src/HTMLOutput.h index 246634f6..976c8deb 100644 --- a/Frameworks/HTMLOutput/src/HTMLOutput.h +++ b/Frameworks/HTMLOutput/src/HTMLOutput.h @@ -8,6 +8,7 @@ @property (nonatomic) NSUUID* commandIdentifier; // UUID from initial load request @property (nonatomic, getter = isRunningCommand, readonly) BOOL runningCommand; @property (nonatomic, getter = isVisible, readonly) BOOL visible; +@property (nonatomic, getter = isReusable) BOOL reusable; // Read-only access to the webview is given to allow reading page title, etc. @property (nonatomic, readonly) WebView* webView; diff --git a/Frameworks/HTMLOutput/src/OakHTMLOutputView.h b/Frameworks/HTMLOutput/src/OakHTMLOutputView.h index 1575f2b8..564a0c94 100644 --- a/Frameworks/HTMLOutput/src/OakHTMLOutputView.h +++ b/Frameworks/HTMLOutput/src/OakHTMLOutputView.h @@ -9,4 +9,5 @@ PUBLIC @interface OakHTMLOutputView : HOBrowserView @property (nonatomic, readonly) NSString* mainFrameTitle; @property (nonatomic) NSUUID* commandIdentifier; // UUID from initial load request @property (nonatomic, getter = isRunningCommand, readonly) BOOL runningCommand; +@property (nonatomic, getter = isReusable) BOOL reusable; @end diff --git a/Frameworks/HTMLOutput/src/OakHTMLOutputView.mm b/Frameworks/HTMLOutput/src/OakHTMLOutputView.mm index 55d285e3..406c6311 100644 --- a/Frameworks/HTMLOutput/src/OakHTMLOutputView.mm +++ b/Frameworks/HTMLOutput/src/OakHTMLOutputView.mm @@ -24,6 +24,15 @@ return [NSSet setWithObjects:@"webView.mainFrameTitle", nil]; } +- (instancetype)initWithFrame:(NSRect)aRect +{ + if(self = [super initWithFrame:aRect]) + { + _reusable = YES; + } + return self; +} + - (void)loadRequest:(NSURLRequest*)aRequest environment:(std::map const&)anEnvironment autoScrolls:(BOOL)flag { if(flag)