https://bugs.webkit.org/show_bug.cgi?id=142247
Reviewed by Enrica Casucci.
While it's not hooked up yet in WKWebView, adding support for the
find bar to WebEditingTester will help us implement that functionality.
* WebEditingTester/AppDelegate.h:
* WebEditingTester/AppDelegate.m:
(-[WebEditingAppDelegate performTextFinderAction:]):
* WebEditingTester/MainMenu.xib:
Receive performTextFinderAction: and forward it to the frontmost WebDocumentController.
* WebEditingTester/WK2WebDocumentController.m:
(-[WK2WebDocumentController awakeFromNib]):
(-[WK2WebDocumentController performTextFinderAction:]):
(-[WK2WebDocumentController findBarView]):
(-[WK2WebDocumentController setFindBarView:]):
(-[WK2WebDocumentController isFindBarVisible]):
(-[WK2WebDocumentController setFindBarVisible:]):
(-[WK2WebDocumentController findBarViewDidChangeHeight]):
(-[WK2WebDocumentController layout]):
Implement performTextFinderAction: for WebKit2, and have a NSTextFinder
pointing at the WKWebView (currently nothing will work, but the bar will
show up). Install and uninstall the bar as needed.
* WebEditingTester/WebDocument.xib:
Don't use a full-size content view. There's no need, and it makes find
bar layout harder.
* WebEditingTester/WebDocumentController.h:
* WebEditingTester/WebDocumentController.m:
(-[WebDocumentController performTextFinderAction:]):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181007
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2015-03-04 Timothy Horton <timothy_horton@apple.com>
+
+ [WebEditingTester] Add support for the find and replace bar
+ https://bugs.webkit.org/show_bug.cgi?id=142247
+
+ Reviewed by Enrica Casucci.
+
+ While it's not hooked up yet in WKWebView, adding support for the
+ find bar to WebEditingTester will help us implement that functionality.
+
+ * WebEditingTester/AppDelegate.h:
+ * WebEditingTester/AppDelegate.m:
+ (-[WebEditingAppDelegate performTextFinderAction:]):
+ * WebEditingTester/MainMenu.xib:
+ Receive performTextFinderAction: and forward it to the frontmost WebDocumentController.
+
+ * WebEditingTester/WK2WebDocumentController.m:
+ (-[WK2WebDocumentController awakeFromNib]):
+ (-[WK2WebDocumentController performTextFinderAction:]):
+ (-[WK2WebDocumentController findBarView]):
+ (-[WK2WebDocumentController setFindBarView:]):
+ (-[WK2WebDocumentController isFindBarVisible]):
+ (-[WK2WebDocumentController setFindBarVisible:]):
+ (-[WK2WebDocumentController findBarViewDidChangeHeight]):
+ (-[WK2WebDocumentController layout]):
+ Implement performTextFinderAction: for WebKit2, and have a NSTextFinder
+ pointing at the WKWebView (currently nothing will work, but the bar will
+ show up). Install and uninstall the bar as needed.
+
+ * WebEditingTester/WebDocument.xib:
+ Don't use a full-size content view. There's no need, and it makes find
+ bar layout harder.
+
+ * WebEditingTester/WebDocumentController.h:
+ * WebEditingTester/WebDocumentController.m:
+ (-[WebDocumentController performTextFinderAction:]):
+
2015-03-03 Sam Weinig <sam@webkit.org>
[Content Extensions] Split parsing and compiling of content extensions into their own files
- (IBAction)showOperations:(id)sender;
- (IBAction)toggleUseWebKit2ByDefault:(id)sender;
+- (IBAction)performTextFinderAction:(id)sender;
+
@end
}
}
+- (void)performTextFinderAction:(id)sender
+{
+ id keyWindowDelegate = [NSApplication sharedApplication].keyWindow.delegate;
+ if (![keyWindowDelegate isKindOfClass:[WebDocumentController class]])
+ return;
+ [(WebDocumentController *)keyWindowDelegate performTextFinderAction:sender];
+}
+
@end
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="8034" systemVersion="14D87" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="8014.3" systemVersion="14D83" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
- <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="8034"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="8014.3"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
<items>
<menuItem title="Find…" tag="1" keyEquivalent="f" id="Xz5-n4-O0W">
<connections>
- <action selector="performFindPanelAction:" target="-1" id="cD7-Qs-BN4"/>
+ <action selector="performTextFinderAction:" target="Voe-Tx-rLC" id="KVS-KQ-3q9"/>
</connections>
</menuItem>
<menuItem title="Find and Replace…" tag="12" keyEquivalent="f" id="YEy-JH-Tfz">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
- <action selector="performFindPanelAction:" target="-1" id="WD3-Gg-5AJ"/>
+ <action selector="performTextFinderAction:" target="Voe-Tx-rLC" id="Tm2-fN-dsI"/>
</connections>
</menuItem>
<menuItem title="Find Next" tag="2" keyEquivalent="g" id="q09-fT-Sye">
<connections>
- <action selector="performFindPanelAction:" target="-1" id="NDo-RZ-v9R"/>
+ <action selector="performTextFinderAction:" target="Voe-Tx-rLC" id="iEF-Pu-h9y"/>
</connections>
</menuItem>
<menuItem title="Find Previous" tag="3" keyEquivalent="G" id="OwM-mh-QMV">
<connections>
- <action selector="performFindPanelAction:" target="-1" id="HOh-sY-3ay"/>
+ <action selector="performTextFinderAction:" target="Voe-Tx-rLC" id="kVG-Ls-YyZ"/>
</connections>
</menuItem>
<menuItem title="Use Selection for Find" tag="7" keyEquivalent="e" id="buJ-ug-pKt">
<connections>
- <action selector="performFindPanelAction:" target="-1" id="U76-nv-p5D"/>
+ <action selector="performTextFinderAction:" target="Voe-Tx-rLC" id="Kcf-K3-qYC"/>
</connections>
</menuItem>
<menuItem title="Jump to Selection" keyEquivalent="j" id="S0p-oC-mLd">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" utility="YES" nonactivatingPanel="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="272" y="172" width="565" height="366"/>
- <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
+ <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1177"/>
<view key="contentView" id="64n-CD-rIB">
<rect key="frame" x="0.0" y="0.0" width="565" height="366"/>
<autoresizingMask key="autoresizingMask"/>
#import <WebKit/WKWebViewPrivate.h>
#import <WebKit/_WKWebsiteDataStore.h>
-@interface WK2WebDocumentController () <WKUIDelegate>
+@interface WK2WebDocumentController () <WKUIDelegate, NSTextFinderBarContainer>
@property (nonatomic, strong) WKWebView *webView;
@end
-@implementation WK2WebDocumentController
+@implementation WK2WebDocumentController {
+ NSTextFinder *_textFinder;
+ NSView *_textFindBarView;
+ BOOL _findBarVisible;
+}
static WKWebViewConfiguration *defaultConfiguration()
{
[containerView addSubview:_webView];
self.window.title = @"WebEditor [WK2]";
+
+ _textFinder = [[NSTextFinder alloc] init];
+ _textFinder.client = (id<NSTextFinderClient>)_webView;
+ _textFinder.findBarContainer = self;
}
- (void)loadHTMLString:(NSString *)content
[_webView loadHTMLString:content baseURL:nil];
}
+- (void)performTextFinderAction:(id)sender
+{
+ [_textFinder performAction:[sender tag]];
+}
+
+- (NSView *)findBarView
+{
+ return _textFindBarView;
+}
+
+- (void)setFindBarView:(NSView *)findBarView
+{
+ if (_textFindBarView)
+ [_textFindBarView removeFromSuperview];
+ _textFindBarView = findBarView;
+ _findBarVisible = YES;
+ [containerView addSubview:_textFindBarView];
+ [self layout];
+}
+
+- (BOOL)isFindBarVisible
+{
+ return _findBarVisible;
+}
+
+- (void)setFindBarVisible:(BOOL)findBarVisible
+{
+ _findBarVisible = findBarVisible;
+ if (findBarVisible)
+ [containerView addSubview:_textFindBarView];
+ else
+ [_textFindBarView removeFromSuperview];
+
+ [self layout];
+}
+
+- (void)findBarViewDidChangeHeight
+{
+ [self layout];
+}
+
+- (void)layout
+{
+ CGRect containerBounds = [containerView bounds];
+
+ if (!_findBarVisible) {
+ _webView.frame = containerBounds;
+ } else {
+ _textFindBarView.frame = CGRectMake(containerBounds.origin.x, containerBounds.origin.y + containerBounds.size.height - _textFindBarView.frame.size.height, containerBounds.size.width, _textFindBarView.frame.size.height);
+ _webView.frame = CGRectMake(containerBounds.origin.x, containerBounds.origin.y, containerBounds.size.width, containerBounds.size.height - _textFindBarView.frame.size.height);
+ }
+}
+
@end
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7504.2" systemVersion="14D77" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="8014.3" systemVersion="14D83" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
- <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7504.2"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="8014.3"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="WebDocumentController">
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" frameAutosaveName="Main Window" animationBehavior="default" id="xOd-HO-29H" userLabel="Window">
- <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES" fullSizeContentView="YES"/>
+ <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="115" y="862" width="507" height="413"/>
- <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
+ <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1177"/>
<value key="minSize" type="size" width="94" height="86"/>
<view key="contentView" id="gIp-Ho-8D9">
<rect key="frame" x="0.0" y="0.0" width="507" height="413"/>
<connections>
<outlet property="delegate" destination="-2" id="0bl-1N-x8E"/>
</connections>
+ <point key="canvasLocation" x="409.5" y="297.5"/>
</window>
</objects>
</document>
- (void)loadHTMLString:(NSString *)content;
+- (void)performTextFinderAction:(id)sender;
+
@end
{
}
+- (void)performTextFinderAction:(id)sender
+{
+}
+
@end