Title: [181007] trunk/Tools
Revision
181007
Author
[email protected]
Date
2015-03-04 11:27:39 -0800 (Wed, 04 Mar 2015)

Log Message

[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:]):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (181006 => 181007)


--- trunk/Tools/ChangeLog	2015-03-04 19:26:22 UTC (rev 181006)
+++ trunk/Tools/ChangeLog	2015-03-04 19:27:39 UTC (rev 181007)
@@ -1,3 +1,40 @@
+2015-03-04  Timothy Horton  <[email protected]>
+
+        [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  <[email protected]>
 
         [Content Extensions] Split parsing and compiling of content extensions into their own files

Modified: trunk/Tools/WebEditingTester/AppDelegate.h (181006 => 181007)


--- trunk/Tools/WebEditingTester/AppDelegate.h	2015-03-04 19:26:22 UTC (rev 181006)
+++ trunk/Tools/WebEditingTester/AppDelegate.h	2015-03-04 19:27:39 UTC (rev 181007)
@@ -36,5 +36,7 @@
 - (IBAction)showOperations:(id)sender;
 - (IBAction)toggleUseWebKit2ByDefault:(id)sender;
 
+- (IBAction)performTextFinderAction:(id)sender;
+
 @end
 

Modified: trunk/Tools/WebEditingTester/AppDelegate.m (181006 => 181007)


--- trunk/Tools/WebEditingTester/AppDelegate.m	2015-03-04 19:26:22 UTC (rev 181006)
+++ trunk/Tools/WebEditingTester/AppDelegate.m	2015-03-04 19:27:39 UTC (rev 181007)
@@ -210,4 +210,12 @@
     }
 }
 
+- (void)performTextFinderAction:(id)sender
+{
+    id keyWindowDelegate = [NSApplication sharedApplication].keyWindow.delegate;
+    if (![keyWindowDelegate isKindOfClass:[WebDocumentController class]])
+        return;
+    [(WebDocumentController *)keyWindowDelegate performTextFinderAction:sender];
+}
+
 @end

Modified: trunk/Tools/WebEditingTester/MainMenu.xib (181006 => 181007)


--- trunk/Tools/WebEditingTester/MainMenu.xib	2015-03-04 19:26:22 UTC (rev 181006)
+++ trunk/Tools/WebEditingTester/MainMenu.xib	2015-03-04 19:27:39 UTC (rev 181007)
@@ -1,7 +1,7 @@
 <?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">
@@ -183,28 +183,28 @@
                                     <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">
@@ -685,7 +685,7 @@
             <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"/>

Modified: trunk/Tools/WebEditingTester/WK2WebDocumentController.m (181006 => 181007)


--- trunk/Tools/WebEditingTester/WK2WebDocumentController.m	2015-03-04 19:26:22 UTC (rev 181006)
+++ trunk/Tools/WebEditingTester/WK2WebDocumentController.m	2015-03-04 19:27:39 UTC (rev 181007)
@@ -34,11 +34,15 @@
 #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()
 {
@@ -67,6 +71,10 @@
     
     [containerView addSubview:_webView];
     self.window.title = @"WebEditor [WK2]";
+
+    _textFinder = [[NSTextFinder alloc] init];
+    _textFinder.client = (id<NSTextFinderClient>)_webView;
+    _textFinder.findBarContainer = self;
 }
 
 - (void)loadHTMLString:(NSString *)content
@@ -74,4 +82,57 @@
     [_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

Modified: trunk/Tools/WebEditingTester/WebDocument.xib (181006 => 181007)


--- trunk/Tools/WebEditingTester/WebDocument.xib	2015-03-04 19:26:22 UTC (rev 181006)
+++ trunk/Tools/WebEditingTester/WebDocument.xib	2015-03-04 19:27:39 UTC (rev 181007)
@@ -1,7 +1,7 @@
 <?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">
@@ -13,10 +13,10 @@
         <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"/>
@@ -36,6 +36,7 @@
             <connections>
                 <outlet property="delegate" destination="-2" id="0bl-1N-x8E"/>
             </connections>
+            <point key="canvasLocation" x="409.5" y="297.5"/>
         </window>
     </objects>
 </document>

Modified: trunk/Tools/WebEditingTester/WebDocumentController.h (181006 => 181007)


--- trunk/Tools/WebEditingTester/WebDocumentController.h	2015-03-04 19:26:22 UTC (rev 181006)
+++ trunk/Tools/WebEditingTester/WebDocumentController.h	2015-03-04 19:27:39 UTC (rev 181007)
@@ -38,5 +38,7 @@
 
 - (void)loadHTMLString:(NSString *)content;
 
+- (void)performTextFinderAction:(id)sender;
+
 @end
 

Modified: trunk/Tools/WebEditingTester/WebDocumentController.m (181006 => 181007)


--- trunk/Tools/WebEditingTester/WebDocumentController.m	2015-03-04 19:26:22 UTC (rev 181006)
+++ trunk/Tools/WebEditingTester/WebDocumentController.m	2015-03-04 19:27:39 UTC (rev 181007)
@@ -51,4 +51,8 @@
 {
 }
 
+- (void)performTextFinderAction:(id)sender
+{
+}
+
 @end
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to