| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/renderer_host/gtk_key_bindings_handler.h" | 5 #include "content/browser/renderer_host/gtk_key_bindings_handler.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 125 |
| 126 GtkKeyBindingsHandler* GtkKeyBindingsHandler::GetHandlerOwner( | 126 GtkKeyBindingsHandler* GtkKeyBindingsHandler::GetHandlerOwner( |
| 127 GtkTextView* text_view) { | 127 GtkTextView* text_view) { |
| 128 Handler* handler = G_TYPE_CHECK_INSTANCE_CAST( | 128 Handler* handler = G_TYPE_CHECK_INSTANCE_CAST( |
| 129 text_view, HandlerGetType(), Handler); | 129 text_view, HandlerGetType(), Handler); |
| 130 DCHECK(handler); | 130 DCHECK(handler); |
| 131 return handler->owner; | 131 return handler->owner; |
| 132 } | 132 } |
| 133 | 133 |
| 134 void GtkKeyBindingsHandler::BackSpace(GtkTextView* text_view) { | 134 void GtkKeyBindingsHandler::BackSpace(GtkTextView* text_view) { |
| 135 GetHandlerOwner(text_view)->EditCommandMatched("DeleteBackward", ""); | 135 GetHandlerOwner(text_view) |
| 136 ->EditCommandMatched("DeleteBackward", std::string()); |
| 136 } | 137 } |
| 137 | 138 |
| 138 void GtkKeyBindingsHandler::CopyClipboard(GtkTextView* text_view) { | 139 void GtkKeyBindingsHandler::CopyClipboard(GtkTextView* text_view) { |
| 139 GetHandlerOwner(text_view)->EditCommandMatched("Copy", ""); | 140 GetHandlerOwner(text_view)->EditCommandMatched("Copy", std::string()); |
| 140 } | 141 } |
| 141 | 142 |
| 142 void GtkKeyBindingsHandler::CutClipboard(GtkTextView* text_view) { | 143 void GtkKeyBindingsHandler::CutClipboard(GtkTextView* text_view) { |
| 143 GetHandlerOwner(text_view)->EditCommandMatched("Cut", ""); | 144 GetHandlerOwner(text_view)->EditCommandMatched("Cut", std::string()); |
| 144 } | 145 } |
| 145 | 146 |
| 146 void GtkKeyBindingsHandler::DeleteFromCursor( | 147 void GtkKeyBindingsHandler::DeleteFromCursor( |
| 147 GtkTextView* text_view, GtkDeleteType type, gint count) { | 148 GtkTextView* text_view, GtkDeleteType type, gint count) { |
| 148 if (!count) | 149 if (!count) |
| 149 return; | 150 return; |
| 150 | 151 |
| 151 const char *commands[3] = { NULL, NULL, NULL }; | 152 const char *commands[3] = { NULL, NULL, NULL }; |
| 152 switch (type) { | 153 switch (type) { |
| 153 case GTK_DELETE_CHARS: | 154 case GTK_DELETE_CHARS: |
| (...skipping 30 matching lines...) Expand all Loading... |
| 184 default: | 185 default: |
| 185 // GTK_DELETE_WHITESPACE has no corresponding editor command. | 186 // GTK_DELETE_WHITESPACE has no corresponding editor command. |
| 186 return; | 187 return; |
| 187 } | 188 } |
| 188 | 189 |
| 189 GtkKeyBindingsHandler* owner = GetHandlerOwner(text_view); | 190 GtkKeyBindingsHandler* owner = GetHandlerOwner(text_view); |
| 190 if (count < 0) | 191 if (count < 0) |
| 191 count = -count; | 192 count = -count; |
| 192 for (; count > 0; --count) { | 193 for (; count > 0; --count) { |
| 193 for (const char* const* p = commands; *p; ++p) | 194 for (const char* const* p = commands; *p; ++p) |
| 194 owner->EditCommandMatched(*p, ""); | 195 owner->EditCommandMatched(*p, std::string()); |
| 195 } | 196 } |
| 196 } | 197 } |
| 197 | 198 |
| 198 void GtkKeyBindingsHandler::InsertAtCursor(GtkTextView* text_view, | 199 void GtkKeyBindingsHandler::InsertAtCursor(GtkTextView* text_view, |
| 199 const gchar* str) { | 200 const gchar* str) { |
| 200 if (str && *str) | 201 if (str && *str) |
| 201 GetHandlerOwner(text_view)->EditCommandMatched("InsertText", str); | 202 GetHandlerOwner(text_view)->EditCommandMatched("InsertText", str); |
| 202 } | 203 } |
| 203 | 204 |
| 204 void GtkKeyBindingsHandler::MoveCursor( | 205 void GtkKeyBindingsHandler::MoveCursor( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 // no corresponding editor commands. | 241 // no corresponding editor commands. |
| 241 return; | 242 return; |
| 242 } | 243 } |
| 243 | 244 |
| 244 GtkKeyBindingsHandler* owner = GetHandlerOwner(text_view); | 245 GtkKeyBindingsHandler* owner = GetHandlerOwner(text_view); |
| 245 if (extend_selection) | 246 if (extend_selection) |
| 246 command.append("AndModifySelection"); | 247 command.append("AndModifySelection"); |
| 247 if (count < 0) | 248 if (count < 0) |
| 248 count = -count; | 249 count = -count; |
| 249 for (; count > 0; --count) | 250 for (; count > 0; --count) |
| 250 owner->EditCommandMatched(command, ""); | 251 owner->EditCommandMatched(command, std::string()); |
| 251 } | 252 } |
| 252 | 253 |
| 253 void GtkKeyBindingsHandler::MoveViewport( | 254 void GtkKeyBindingsHandler::MoveViewport( |
| 254 GtkTextView* text_view, GtkScrollStep step, gint count) { | 255 GtkTextView* text_view, GtkScrollStep step, gint count) { |
| 255 // Not supported by webkit. | 256 // Not supported by webkit. |
| 256 } | 257 } |
| 257 | 258 |
| 258 void GtkKeyBindingsHandler::PasteClipboard(GtkTextView* text_view) { | 259 void GtkKeyBindingsHandler::PasteClipboard(GtkTextView* text_view) { |
| 259 GetHandlerOwner(text_view)->EditCommandMatched("Paste", ""); | 260 GetHandlerOwner(text_view)->EditCommandMatched("Paste", std::string()); |
| 260 } | 261 } |
| 261 | 262 |
| 262 void GtkKeyBindingsHandler::SelectAll(GtkTextView* text_view, gboolean select) { | 263 void GtkKeyBindingsHandler::SelectAll(GtkTextView* text_view, gboolean select) { |
| 263 if (select) | 264 if (select) |
| 264 GetHandlerOwner(text_view)->EditCommandMatched("SelectAll", ""); | 265 GetHandlerOwner(text_view)->EditCommandMatched("SelectAll", std::string()); |
| 265 else | 266 else |
| 266 GetHandlerOwner(text_view)->EditCommandMatched("Unselect", ""); | 267 GetHandlerOwner(text_view)->EditCommandMatched("Unselect", std::string()); |
| 267 } | 268 } |
| 268 | 269 |
| 269 void GtkKeyBindingsHandler::SetAnchor(GtkTextView* text_view) { | 270 void GtkKeyBindingsHandler::SetAnchor(GtkTextView* text_view) { |
| 270 GetHandlerOwner(text_view)->EditCommandMatched("SetMark", ""); | 271 GetHandlerOwner(text_view)->EditCommandMatched("SetMark", std::string()); |
| 271 } | 272 } |
| 272 | 273 |
| 273 void GtkKeyBindingsHandler::ToggleCursorVisible(GtkTextView* text_view) { | 274 void GtkKeyBindingsHandler::ToggleCursorVisible(GtkTextView* text_view) { |
| 274 // Not supported by webkit. | 275 // Not supported by webkit. |
| 275 } | 276 } |
| 276 | 277 |
| 277 void GtkKeyBindingsHandler::ToggleOverwrite(GtkTextView* text_view) { | 278 void GtkKeyBindingsHandler::ToggleOverwrite(GtkTextView* text_view) { |
| 278 // Not supported by webkit. | 279 // Not supported by webkit. |
| 279 } | 280 } |
| 280 | 281 |
| 281 gboolean GtkKeyBindingsHandler::ShowHelp(GtkWidget* widget, | 282 gboolean GtkKeyBindingsHandler::ShowHelp(GtkWidget* widget, |
| 282 GtkWidgetHelpType arg1) { | 283 GtkWidgetHelpType arg1) { |
| 283 // Just for disabling the default handler. | 284 // Just for disabling the default handler. |
| 284 return FALSE; | 285 return FALSE; |
| 285 } | 286 } |
| 286 | 287 |
| 287 void GtkKeyBindingsHandler::MoveFocus(GtkWidget* widget, | 288 void GtkKeyBindingsHandler::MoveFocus(GtkWidget* widget, |
| 288 GtkDirectionType arg1) { | 289 GtkDirectionType arg1) { |
| 289 // Just for disabling the default handler. | 290 // Just for disabling the default handler. |
| 290 } | 291 } |
| 291 | 292 |
| 292 } // namespace content | 293 } // namespace content |
| OLD | NEW |