| 1 | /* | 
| 2 |  * Copyright (C) 2019 Apple Inc. All rights reserved. | 
| 3 |  * | 
| 4 |  * Redistribution and use in source and binary forms, with or without | 
| 5 |  * modification, are permitted provided that the following conditions | 
| 6 |  * are met: | 
| 7 |  * 1. Redistributions of source code must retain the above copyright | 
| 8 |  *    notice, this list of conditions and the following disclaimer. | 
| 9 |  * 2. Redistributions in binary form must reproduce the above copyright | 
| 10 |  *    notice, this list of conditions and the following disclaimer in the | 
| 11 |  *    documentation and/or other materials provided with the distribution. | 
| 12 |  * | 
| 13 |  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | 
| 14 |  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | 
| 15 |  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 
| 16 |  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | 
| 17 |  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 
| 18 |  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 
| 19 |  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 
| 20 |  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 
| 21 |  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 
| 22 |  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 
| 23 |  * THE POSSIBILITY OF SUCH DAMAGE. | 
| 24 |  */ | 
| 25 |  | 
| 26 | #include "config.h" | 
| 27 | #include "EditAction.h" | 
| 28 |  | 
| 29 | #include "LocalizedStrings.h" | 
| 30 | #include <wtf/text/WTFString.h> | 
| 31 |  | 
| 32 | namespace WebCore { | 
| 33 |  | 
| 34 | String undoRedoLabel(EditAction editAction) | 
| 35 | { | 
| 36 |     switch (editAction) { | 
| 37 |     case EditAction::Unspecified: | 
| 38 |     case EditAction::Insert: | 
| 39 |     case EditAction::InsertReplacement: | 
| 40 |     case EditAction::InsertFromDrop: | 
| 41 |         return { }; | 
| 42 |     case EditAction::SetColor: | 
| 43 |         return WEB_UI_STRING_KEY("Set Color" , "Set Color (Undo action name)" , "Undo action name" ); | 
| 44 |     case EditAction::SetBackgroundColor: | 
| 45 |         return WEB_UI_STRING_KEY("Set Background Color" , "Set Background Color (Undo action name)" , "Undo action name" ); | 
| 46 |     case EditAction::TurnOffKerning: | 
| 47 |         return WEB_UI_STRING_KEY("Turn Off Kerning" , "Turn Off Kerning (Undo action name)" , "Undo action name" ); | 
| 48 |     case EditAction::TightenKerning: | 
| 49 |         return WEB_UI_STRING_KEY("Tighten Kerning" , "Tighten Kerning (Undo action name)" , "Undo action name" ); | 
| 50 |     case EditAction::LoosenKerning: | 
| 51 |         return WEB_UI_STRING_KEY("Loosen Kerning" , "Loosen Kerning (Undo action name)" , "Undo action name" ); | 
| 52 |     case EditAction::UseStandardKerning: | 
| 53 |         return WEB_UI_STRING_KEY("Use Standard Kerning" , "Use Standard Kerning (Undo action name)" , "Undo action name" ); | 
| 54 |     case EditAction::TurnOffLigatures: | 
| 55 |         return WEB_UI_STRING_KEY("Turn Off Ligatures" , "Turn Off Ligatures (Undo action name)" , "Undo action name" ); | 
| 56 |     case EditAction::UseStandardLigatures: | 
| 57 |         return WEB_UI_STRING_KEY("Use Standard Ligatures" , "Use Standard Ligatures (Undo action name)" , "Undo action name" ); | 
| 58 |     case EditAction::UseAllLigatures: | 
| 59 |         return WEB_UI_STRING_KEY("Use All Ligatures" , "Use All Ligatures (Undo action name)" , "Undo action name" ); | 
| 60 |     case EditAction::RaiseBaseline: | 
| 61 |         return WEB_UI_STRING_KEY("Raise Baseline" , "Raise Baseline (Undo action name)" , "Undo action name" ); | 
| 62 |     case EditAction::LowerBaseline: | 
| 63 |         return WEB_UI_STRING_KEY("Lower Baseline" , "Lower Baseline (Undo action name)" , "Undo action name" ); | 
| 64 |     case EditAction::SetTraditionalCharacterShape: | 
| 65 |         return WEB_UI_STRING_KEY("Set Traditional Character Shape" , "Set Traditional Character Shape (Undo action name)" , "Undo action name" ); | 
| 66 |     case EditAction::SetFont: | 
| 67 |         return WEB_UI_STRING_KEY("Set Font" , "Set Font (Undo action name)" , "Undo action name" ); | 
| 68 |     case EditAction::ChangeAttributes: | 
| 69 |         return WEB_UI_STRING_KEY("Change Attributes" , "Change Attributes (Undo action name)" , "Undo action name" ); | 
| 70 |     case EditAction::AlignLeft: | 
| 71 |         return WEB_UI_STRING_KEY("Align Left" , "Align Left (Undo action name)" , "Undo action name" ); | 
| 72 |     case EditAction::AlignRight: | 
| 73 |         return WEB_UI_STRING_KEY("Align Right" , "Align Right (Undo action name)" , "Undo action name" ); | 
| 74 |     case EditAction::Center: | 
| 75 |         return WEB_UI_STRING_KEY("Center" , "Center (Undo action name)" , "Undo action name" ); | 
| 76 |     case EditAction::Justify: | 
| 77 |         return WEB_UI_STRING_KEY("Justify" , "Justify (Undo action name)" , "Undo action name" ); | 
| 78 |     case EditAction::SetInlineWritingDirection: | 
| 79 |     case EditAction::SetBlockWritingDirection: | 
| 80 |         return WEB_UI_STRING_KEY("Set Writing Direction" , "Set Writing Direction (Undo action name)" , "Undo action name" ); | 
| 81 |     case EditAction::Subscript: | 
| 82 |         return WEB_UI_STRING_KEY("Subscript" , "Subscript (Undo action name)" , "Undo action name" ); | 
| 83 |     case EditAction::Superscript: | 
| 84 |         return WEB_UI_STRING_KEY("Superscript" , "Superscript (Undo action name)" , "Undo action name" ); | 
| 85 |     case EditAction::Underline: | 
| 86 |         return WEB_UI_STRING_KEY("Underline" , "Underline (Undo action name)" , "Undo action name" ); | 
| 87 |     case EditAction::Outline: | 
| 88 |         return WEB_UI_STRING_KEY("Outline" , "Outline (Undo action name)" , "Undo action name" ); | 
| 89 |     case EditAction::Unscript: | 
| 90 |         return WEB_UI_STRING_KEY("Unscript" , "Unscript (Undo action name)" , "Undo action name" ); | 
| 91 |     case EditAction::DeleteByDrag: | 
| 92 |         return WEB_UI_STRING_KEY("Drag" , "Drag (Undo action name)" , "Undo action name" ); | 
| 93 |     case EditAction::Cut: | 
| 94 |         return WEB_UI_STRING_KEY("Cut" , "Cut (Undo action name)" , "Undo action name" ); | 
| 95 |     case EditAction::Bold: | 
| 96 |         return WEB_UI_STRING_KEY("Bold" , "Bold (Undo action name)" , "Undo action name" ); | 
| 97 |     case EditAction::Italics: | 
| 98 |         return WEB_UI_STRING_KEY("Italics" , "Italics (Undo action name)" , "Undo action name" ); | 
| 99 |     case EditAction::Delete: | 
| 100 |         return WEB_UI_STRING_KEY("Delete" , "Delete (Undo action name)" , "Undo action name" ); | 
| 101 |     case EditAction::Dictation: | 
| 102 |         return WEB_UI_STRING_KEY("Dictation" , "Dictation (Undo action name)" , "Undo action name" ); | 
| 103 |     case EditAction::Paste: | 
| 104 |         return WEB_UI_STRING_KEY("Paste" , "Paste (Undo action name)" , "Undo action name" ); | 
| 105 |     case EditAction::PasteFont: | 
| 106 |         return WEB_UI_STRING_KEY("Paste Font" , "Paste Font (Undo action name)" , "Undo action name" ); | 
| 107 |     case EditAction::PasteRuler: | 
| 108 |         return WEB_UI_STRING_KEY("Paste Ruler" , "Paste Ruler (Undo action name)" , "Undo action name" ); | 
| 109 |     case EditAction::TypingDeleteSelection: | 
| 110 |     case EditAction::TypingDeleteBackward: | 
| 111 |     case EditAction::TypingDeleteForward: | 
| 112 |     case EditAction::TypingDeleteWordBackward: | 
| 113 |     case EditAction::TypingDeleteWordForward: | 
| 114 |     case EditAction::TypingDeleteLineBackward: | 
| 115 |     case EditAction::TypingDeleteLineForward: | 
| 116 |     case EditAction::TypingDeletePendingComposition: | 
| 117 |     case EditAction::TypingDeleteFinalComposition: | 
| 118 |     case EditAction::TypingInsertText: | 
| 119 |     case EditAction::TypingInsertLineBreak: | 
| 120 |     case EditAction::TypingInsertParagraph: | 
| 121 |     case EditAction::TypingInsertPendingComposition: | 
| 122 |     case EditAction::TypingInsertFinalComposition: | 
| 123 |         return WEB_UI_STRING_KEY("Typing" , "Typing (Undo action name)" , "Undo action name" ); | 
| 124 |     case EditAction::CreateLink: | 
| 125 |         return WEB_UI_STRING_KEY("Create Link" , "Create Link (Undo action name)" , "Undo action name" ); | 
| 126 |     case EditAction::Unlink: | 
| 127 |         return WEB_UI_STRING_KEY("Unlink" , "Unlink (Undo action name)" , "Undo action name" ); | 
| 128 |     case EditAction::InsertUnorderedList: | 
| 129 |     case EditAction::InsertOrderedList: | 
| 130 |         return WEB_UI_STRING_KEY("Insert List" , "Insert List (Undo action name)" , "Undo action name" ); | 
| 131 |     case EditAction::FormatBlock: | 
| 132 |         return WEB_UI_STRING_KEY("Formatting" , "Format Block (Undo action name)" , "Undo action name" ); | 
| 133 |     case EditAction::Indent: | 
| 134 |         return WEB_UI_STRING_KEY("Indent" , "Indent (Undo action name)" , "Undo action name" ); | 
| 135 |     case EditAction::Outdent: | 
| 136 |         return WEB_UI_STRING_KEY("Outdent" , "Outdent (Undo action name)" , "Undo action name" ); | 
| 137 |     // FIXME: We should give internal clients a way to override these undo names. For instance, Mail refers to ordered and unordered lists as "numbered" and "bulleted" lists, respectively, | 
| 138 |     // despite the fact that ordered and unordered lists are not necessarily displayed using bullets and numerals. | 
| 139 |     case EditAction::ConvertToOrderedList: | 
| 140 |         return WEB_UI_STRING_KEY("Convert to Ordered List" , "Convert to Ordered List (Undo action name)" , "Undo action name" ); | 
| 141 |     case EditAction::ConvertToUnorderedList: | 
| 142 |         return WEB_UI_STRING_KEY("Convert to Unordered List" , "Convert to Unordered List (Undo action name)" , "Undo action name" ); | 
| 143 |     case EditAction::InsertEditableImage: | 
| 144 |         return WEB_UI_STRING_KEY("Insert Drawing" , "Insert Drawing (Undo action name)" , "Undo action name" ); | 
| 145 |     } | 
| 146 |     return { }; | 
| 147 | } | 
| 148 |  | 
| 149 | } // namespace WebCore | 
| 150 |  |