[WebEditingTester] Factor out list of editing operations
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Feb 2015 19:13:33 +0000 (19:13 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Feb 2015 19:13:33 +0000 (19:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=141826

Reviewed by Sam Weinig.

* WebEditingTester/AppDelegate.m:
(-[WebEditingAppDelegate showOperations:]):
* WebEditingTester/EditingOperations.h: Added.
* WebEditingTester/EditingOperations.m: Added.
(editingOperations):
* WebEditingTester/WebEditingTester.xcodeproj/project.pbxproj:
Move EditingOperations array to its own file, and make it an NSArray
instead of a C array. Adjust accordingly in showOperations:.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@180425 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/WebEditingTester/AppDelegate.m
Tools/WebEditingTester/EditingOperations.h [new file with mode: 0644]
Tools/WebEditingTester/EditingOperations.m [new file with mode: 0644]
Tools/WebEditingTester/WebEditingTester.xcodeproj/project.pbxproj

index 3e4c13f..a1edfe9 100644 (file)
@@ -1,3 +1,19 @@
+2015-02-20  Timothy Horton  <timothy_horton@apple.com>
+
+        [WebEditingTester] Factor out list of editing operations
+        https://bugs.webkit.org/show_bug.cgi?id=141826
+
+        Reviewed by Sam Weinig.
+
+        * WebEditingTester/AppDelegate.m:
+        (-[WebEditingAppDelegate showOperations:]):
+        * WebEditingTester/EditingOperations.h: Added.
+        * WebEditingTester/EditingOperations.m: Added.
+        (editingOperations):
+        * WebEditingTester/WebEditingTester.xcodeproj/project.pbxproj:
+        Move EditingOperations array to its own file, and make it an NSArray
+        instead of a C array. Adjust accordingly in showOperations:.
+
 2015-02-20  Michael Saboff  <msaboff@apple.com>
 
         DFG JIT needs to check for stack overflow at the start of Program and Eval execution
index f2e1e01..0ff38a4 100644 (file)
@@ -25,6 +25,7 @@
 
 #import "AppDelegate.h"
 
+#import "EditingOperations.h"
 #import "WK1WebDocumentController.h"
 #import "WK2WebDocumentController.h"
 #import <WebKit/WKPreferencesPrivate.h>
@@ -92,130 +93,19 @@ static WKWebViewConfiguration *defaultConfiguration()
 - (IBAction)showOperations:(id)sender
 {
     static BOOL initialized = NO;
-    static NSString *operationNames[] = {
-        @"alignCenter:",
-        @"alignJustified:",
-        @"alignLeft:",
-        @"alignRight:",
-        @"capitalizeWord:",
-        @"centerSelectionInVisibleArea:",
-        @"changeCaseOfLetter:",
-        @"checkSpelling:",
-        @"complete:",
-        @"copy:",
-        @"copyFont:",
-        @"cut:",
-        @"delete:",
-        @"deleteBackward:",
-        @"deleteBackwardByDecomposingPreviousCharacter:",
-        @"deleteForward:",
-        @"deleteToBeginningOfLine:",
-        @"deleteToBeginningOfParagraph:",
-        @"deleteToEndOfLine:",
-        @"deleteToEndOfParagraph:",
-        @"deleteToMark:",
-        @"deleteWordBackward:",
-        @"deleteWordForward:",
-        @"ignoreSpelling:",
-        @"indent:",
-        @"insertBacktab:",
-        @"insertLineBreak:",
-        @"insertNewline:",
-        @"insertNewlineIgnoringFieldEditor:",
-        @"insertParagraphSeparator:",
-        @"insertTab:",
-        @"insertTabIgnoringFieldEditor:",
-        @"insertTable:",
-        @"lowercaseWord:",
-        @"moveBackward:",
-        @"moveBackwardAndModifySelection:",
-        @"moveDown:",
-        @"moveDownAndModifySelection:",
-        @"moveForward:",
-        @"moveForwardAndModifySelection:",
-        @"moveLeft:",
-        @"moveLeftAndModifySelection:",
-        @"moveParagraphBackwardAndModifySelection:",
-        @"moveParagraphForwardAndModifySelection:",
-        @"moveRight:",
-        @"moveRightAndModifySelection:",
-        @"moveToBeginningOfDocument:",
-        @"moveToBeginningOfDocumentAndModifySelection:",
-        @"moveToBeginningOfSentence:",
-        @"moveToBeginningOfSentenceAndModifySelection:",
-        @"moveToBeginningOfLine:",
-        @"moveToBeginningOfLineAndModifySelection:",
-        @"moveToBeginningOfParagraph:",
-        @"moveToBeginningOfParagraphAndModifySelection:",
-        @"moveToEndOfDocument:",
-        @"moveToEndOfDocumentAndModifySelection:",
-        @"moveToEndOfSentence:",
-        @"moveToEndOfSentenceAndModifySelection:",
-        @"moveToEndOfLine:",
-        @"moveToEndOfLineAndModifySelection:",
-        @"moveToEndOfParagraph:",
-        @"moveToEndOfParagraphAndModifySelection:",
-        @"moveUp:",
-        @"moveUpAndModifySelection:",
-        @"moveWordBackward:",
-        @"moveWordBackwardAndModifySelection:",
-        @"moveWordForward:",
-        @"moveWordForwardAndModifySelection:",
-        @"moveWordLeft:",
-        @"moveWordLeftAndModifySelection:",
-        @"moveWordRight:",
-        @"moveWordRightAndModifySelection:",
-        @"outline:",
-        @"pageDown:",
-        @"pageDownAndModifySelection:",
-        @"pageUp:",
-        @"pageUpAndModifySelection:",
-        @"paste:",
-        @"pasteAsPlainText:",
-        @"pasteAsRichText:",
-        @"pasteFont:",
-        @"scrollLineDown:",
-        @"scrollLineUp:",
-        @"scrollPageDown:",
-        @"scrollPageUp:",
-        @"selectAll:",
-        @"selectSentence:",
-        @"selectLine:",
-        @"selectParagraph:",
-        @"selectToMark:",
-        @"selectWord:",
-        @"setMark:",
-        @"showGuessPanel:",
-        @"startSpeaking:",
-        @"stopSpeaking:",
-        @"subscript:",
-        @"superscript:",
-        @"swapWithMark:",
-        @"takeFindStringFromSelection:",
-        @"toggleContinuousSpellChecking:",
-        @"toggleSmartInsertDelete:",
-        @"transpose:",
-        @"transposeWords:",
-        @"underline:",
-        @"unscript:",
-        @"uppercaseWord:",
-        @"yank:",
-        @"yankAndSelect:",
-        NULL
-    };
 
     if (!initialized) {
         NSFont *font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSMiniControlSize]];
         NSDictionary *attributes = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
+        NSArray *operations = editingOperations();
         
         float maxWidth = 0;
-        int i;
-        for (i = 0; operationNames[i]; ++i)
-            maxWidth = MAX(maxWidth, [operationNames[i] sizeWithAttributes:attributes].width);
+        for (NSString *operationName in operations)
+            maxWidth = MAX(maxWidth, [operationName sizeWithAttributes:attributes].width);
 
         maxWidth += 24;
         
-        int columnHeight = (i + 2) / 3;
+        unsigned long columnHeight = (operations.count + 2) / 3;
         
         NSView *superview = [_operationsPanel contentView];
         
@@ -224,7 +114,7 @@ static WKWebViewConfiguration *defaultConfiguration()
         float firstY = NSMaxY([superview frame]) - 1;
         float y = firstY;
         float x = 0;
-        for (i = 0; operationNames[i]; ++i) {
+        for (NSString *operationName in operations) {
             y -= 16;
             if (y < 0) {
                 y = firstY - 16;
@@ -234,8 +124,8 @@ static WKWebViewConfiguration *defaultConfiguration()
             [button setBezelStyle:NSRoundedBezelStyle];
             [button.cell setControlSize:NSMiniControlSize];
             [button setFont:font];
-            [button setTitle:operationNames[i]];
-            [button setAction:NSSelectorFromString(operationNames[i])];
+            [button setTitle:operationName];
+            [button setAction:NSSelectorFromString(operationName)];
             [superview addSubview:button];
         }
         
diff --git a/Tools/WebEditingTester/EditingOperations.h b/Tools/WebEditingTester/EditingOperations.h
new file mode 100644 (file)
index 0000000..a06551e
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+@class NSArray;
+
+NSArray *editingOperations();
diff --git a/Tools/WebEditingTester/EditingOperations.m b/Tools/WebEditingTester/EditingOperations.m
new file mode 100644 (file)
index 0000000..f654c35
--- /dev/null
@@ -0,0 +1,142 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "EditingOperations.h"
+
+#import <Foundation/Foundation.h>
+
+NSArray *editingOperations()
+{
+    return @[
+        @"alignCenter:",
+        @"alignJustified:",
+        @"alignLeft:",
+        @"alignRight:",
+        @"capitalizeWord:",
+        @"centerSelectionInVisibleArea:",
+        @"changeCaseOfLetter:",
+        @"checkSpelling:",
+        @"complete:",
+        @"copy:",
+        @"copyFont:",
+        @"cut:",
+        @"delete:",
+        @"deleteBackward:",
+        @"deleteBackwardByDecomposingPreviousCharacter:",
+        @"deleteForward:",
+        @"deleteToBeginningOfLine:",
+        @"deleteToBeginningOfParagraph:",
+        @"deleteToEndOfLine:",
+        @"deleteToEndOfParagraph:",
+        @"deleteToMark:",
+        @"deleteWordBackward:",
+        @"deleteWordForward:",
+        @"ignoreSpelling:",
+        @"indent:",
+        @"insertBacktab:",
+        @"insertLineBreak:",
+        @"insertNewline:",
+        @"insertNewlineIgnoringFieldEditor:",
+        @"insertParagraphSeparator:",
+        @"insertTab:",
+        @"insertTabIgnoringFieldEditor:",
+        @"insertTable:",
+        @"lowercaseWord:",
+        @"moveBackward:",
+        @"moveBackwardAndModifySelection:",
+        @"moveDown:",
+        @"moveDownAndModifySelection:",
+        @"moveForward:",
+        @"moveForwardAndModifySelection:",
+        @"moveLeft:",
+        @"moveLeftAndModifySelection:",
+        @"moveParagraphBackwardAndModifySelection:",
+        @"moveParagraphForwardAndModifySelection:",
+        @"moveRight:",
+        @"moveRightAndModifySelection:",
+        @"moveToBeginningOfDocument:",
+        @"moveToBeginningOfDocumentAndModifySelection:",
+        @"moveToBeginningOfSentence:",
+        @"moveToBeginningOfSentenceAndModifySelection:",
+        @"moveToBeginningOfLine:",
+        @"moveToBeginningOfLineAndModifySelection:",
+        @"moveToBeginningOfParagraph:",
+        @"moveToBeginningOfParagraphAndModifySelection:",
+        @"moveToEndOfDocument:",
+        @"moveToEndOfDocumentAndModifySelection:",
+        @"moveToEndOfSentence:",
+        @"moveToEndOfSentenceAndModifySelection:",
+        @"moveToEndOfLine:",
+        @"moveToEndOfLineAndModifySelection:",
+        @"moveToEndOfParagraph:",
+        @"moveToEndOfParagraphAndModifySelection:",
+        @"moveUp:",
+        @"moveUpAndModifySelection:",
+        @"moveWordBackward:",
+        @"moveWordBackwardAndModifySelection:",
+        @"moveWordForward:",
+        @"moveWordForwardAndModifySelection:",
+        @"moveWordLeft:",
+        @"moveWordLeftAndModifySelection:",
+        @"moveWordRight:",
+        @"moveWordRightAndModifySelection:",
+        @"outline:",
+        @"pageDown:",
+        @"pageDownAndModifySelection:",
+        @"pageUp:",
+        @"pageUpAndModifySelection:",
+        @"paste:",
+        @"pasteAsPlainText:",
+        @"pasteAsRichText:",
+        @"pasteFont:",
+        @"scrollLineDown:",
+        @"scrollLineUp:",
+        @"scrollPageDown:",
+        @"scrollPageUp:",
+        @"selectAll:",
+        @"selectSentence:",
+        @"selectLine:",
+        @"selectParagraph:",
+        @"selectToMark:",
+        @"selectWord:",
+        @"setMark:",
+        @"showGuessPanel:",
+        @"startSpeaking:",
+        @"stopSpeaking:",
+        @"subscript:",
+        @"superscript:",
+        @"swapWithMark:",
+        @"takeFindStringFromSelection:",
+        @"toggleContinuousSpellChecking:",
+        @"toggleSmartInsertDelete:",
+        @"transpose:",
+        @"transposeWords:",
+        @"underline:",
+        @"unscript:",
+        @"uppercaseWord:",
+        @"yank:",
+        @"yankAndSelect:"
+    ];
+}
index 2a6d2d5..2513723 100644 (file)
@@ -7,6 +7,7 @@
        objects = {
 
 /* Begin PBXBuildFile section */
+               2D4FFA111A97079D0006360B /* EditingOperations.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D4FFA101A97079D0006360B /* EditingOperations.m */; };
                C53E7D0D1A9546E600818F19 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = C53E7D0B1A9546E600818F19 /* MainMenu.xib */; };
                C53E7D0E1A9546E600818F19 /* WebDocument.xib in Resources */ = {isa = PBXBuildFile; fileRef = C53E7D0C1A9546E600818F19 /* WebDocument.xib */; };
                C558CDB31A92D6900059A907 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = C558CDB21A92D6900059A907 /* AppDelegate.m */; };
@@ -19,6 +20,8 @@
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
+               2D4FFA0F1A97079D0006360B /* EditingOperations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditingOperations.h; sourceTree = "<group>"; };
+               2D4FFA101A97079D0006360B /* EditingOperations.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EditingOperations.m; sourceTree = "<group>"; };
                C53E7D0B1A9546E600818F19 /* MainMenu.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainMenu.xib; sourceTree = "<group>"; };
                C53E7D0C1A9546E600818F19 /* WebDocument.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = WebDocument.xib; sourceTree = "<group>"; };
                C558CDAC1A92D6900059A907 /* WebEditingTester.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WebEditingTester.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -79,6 +82,8 @@
                                C59F9B9E1A93CB630041A959 /* WK2WebDocumentController.m */,
                                C558CDB61A92D6900059A907 /* WebDocumentController.h */,
                                C558CDB71A92D6900059A907 /* WebDocumentController.m */,
+                               2D4FFA0F1A97079D0006360B /* EditingOperations.h */,
+                               2D4FFA101A97079D0006360B /* EditingOperations.m */,
                        );
                        name = WebEditingTester;
                        sourceTree = "<group>";
                        files = (
                                C558CDB81A92D6900059A907 /* WebDocumentController.m in Sources */,
                                C59F9BA01A93CB630041A959 /* WK2WebDocumentController.m in Sources */,
+                               2D4FFA111A97079D0006360B /* EditingOperations.m in Sources */,
                                C558CDB51A92D6900059A907 /* main.m in Sources */,
                                C558CDB31A92D6900059A907 /* AppDelegate.m in Sources */,
                                C59F9B9F1A93CB630041A959 /* WK1WebDocumentController.m in Sources */,