Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: Source/web/EditorClientImpl.cpp

Issue 14107015: Rename OS(DARWIN) to OS(MACOSX). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/web/ContextMenuClientImpl.cpp ('k') | Source/web/WebFrameImpl.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007 Apple, Inc. All rights reserved. 2 * Copyright (C) 2006, 2007 Apple, Inc. All rights reserved.
3 * Copyright (C) 2012 Google, Inc. All rights reserved. 3 * Copyright (C) 2012 Google, Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 } 334 }
335 335
336 // 336 //
337 // The below code was adapted from the WebKit file webview.cpp 337 // The below code was adapted from the WebKit file webview.cpp
338 // 338 //
339 339
340 static const unsigned CtrlKey = 1 << 0; 340 static const unsigned CtrlKey = 1 << 0;
341 static const unsigned AltKey = 1 << 1; 341 static const unsigned AltKey = 1 << 1;
342 static const unsigned ShiftKey = 1 << 2; 342 static const unsigned ShiftKey = 1 << 2;
343 static const unsigned MetaKey = 1 << 3; 343 static const unsigned MetaKey = 1 << 3;
344 #if OS(DARWIN) 344 #if OS(MACOSX)
345 // Aliases for the generic key defintions to make kbd shortcuts definitions more 345 // Aliases for the generic key defintions to make kbd shortcuts definitions more
346 // readable on OS X. 346 // readable on OS X.
347 static const unsigned OptionKey = AltKey; 347 static const unsigned OptionKey = AltKey;
348 348
349 // Do not use this constant for anything but cursor movement commands. Keys 349 // Do not use this constant for anything but cursor movement commands. Keys
350 // with cmd set have their |isSystemKey| bit set, so chances are the shortcut 350 // with cmd set have their |isSystemKey| bit set, so chances are the shortcut
351 // will not be executed. Another, less important, reason is that shortcuts 351 // will not be executed. Another, less important, reason is that shortcuts
352 // defined in the renderer do not blink the menu item that they triggered. See 352 // defined in the renderer do not blink the menu item that they triggered. See
353 // http://crbug.com/25856 and the bugs linked from there for details. 353 // http://crbug.com/25856 and the bugs linked from there for details.
354 static const unsigned CommandKey = MetaKey; 354 static const unsigned CommandKey = MetaKey;
355 #endif 355 #endif
356 356
357 // Keys with special meaning. These will be delegated to the editor using 357 // Keys with special meaning. These will be delegated to the editor using
358 // the execCommand() method 358 // the execCommand() method
359 struct KeyDownEntry { 359 struct KeyDownEntry {
360 unsigned virtualKey; 360 unsigned virtualKey;
361 unsigned modifiers; 361 unsigned modifiers;
362 const char* name; 362 const char* name;
363 }; 363 };
364 364
365 struct KeyPressEntry { 365 struct KeyPressEntry {
366 unsigned charCode; 366 unsigned charCode;
367 unsigned modifiers; 367 unsigned modifiers;
368 const char* name; 368 const char* name;
369 }; 369 };
370 370
371 static const KeyDownEntry keyDownEntries[] = { 371 static const KeyDownEntry keyDownEntries[] = {
372 { VKEY_LEFT, 0, "MoveLeft" }, 372 { VKEY_LEFT, 0, "MoveLeft" },
373 { VKEY_LEFT, ShiftKey, "MoveLeftAndModifySelection" }, 373 { VKEY_LEFT, ShiftKey, "MoveLeftAndModifySelection" },
374 #if OS(DARWIN) 374 #if OS(MACOSX)
375 { VKEY_LEFT, OptionKey, "MoveWordLeft" }, 375 { VKEY_LEFT, OptionKey, "MoveWordLeft" },
376 { VKEY_LEFT, OptionKey | ShiftKey, 376 { VKEY_LEFT, OptionKey | ShiftKey,
377 "MoveWordLeftAndModifySelection" }, 377 "MoveWordLeftAndModifySelection" },
378 #else 378 #else
379 { VKEY_LEFT, CtrlKey, "MoveWordLeft" }, 379 { VKEY_LEFT, CtrlKey, "MoveWordLeft" },
380 { VKEY_LEFT, CtrlKey | ShiftKey, 380 { VKEY_LEFT, CtrlKey | ShiftKey,
381 "MoveWordLeftAndModifySelection" }, 381 "MoveWordLeftAndModifySelection" },
382 #endif 382 #endif
383 { VKEY_RIGHT, 0, "MoveRight" }, 383 { VKEY_RIGHT, 0, "MoveRight" },
384 { VKEY_RIGHT, ShiftKey, "MoveRightAndModifySelection" }, 384 { VKEY_RIGHT, ShiftKey, "MoveRightAndModifySelection" },
385 #if OS(DARWIN) 385 #if OS(MACOSX)
386 { VKEY_RIGHT, OptionKey, "MoveWordRight" }, 386 { VKEY_RIGHT, OptionKey, "MoveWordRight" },
387 { VKEY_RIGHT, OptionKey | ShiftKey, 387 { VKEY_RIGHT, OptionKey | ShiftKey,
388 "MoveWordRightAndModifySelection" }, 388 "MoveWordRightAndModifySelection" },
389 #else 389 #else
390 { VKEY_RIGHT, CtrlKey, "MoveWordRight" }, 390 { VKEY_RIGHT, CtrlKey, "MoveWordRight" },
391 { VKEY_RIGHT, CtrlKey | ShiftKey, 391 { VKEY_RIGHT, CtrlKey | ShiftKey,
392 "MoveWordRightAndModifySelection" }, 392 "MoveWordRightAndModifySelection" },
393 #endif 393 #endif
394 { VKEY_UP, 0, "MoveUp" }, 394 { VKEY_UP, 0, "MoveUp" },
395 { VKEY_UP, ShiftKey, "MoveUpAndModifySelection" }, 395 { VKEY_UP, ShiftKey, "MoveUpAndModifySelection" },
396 { VKEY_PRIOR, ShiftKey, "MovePageUpAndModifySelection" }, 396 { VKEY_PRIOR, ShiftKey, "MovePageUpAndModifySelection" },
397 { VKEY_DOWN, 0, "MoveDown" }, 397 { VKEY_DOWN, 0, "MoveDown" },
398 { VKEY_DOWN, ShiftKey, "MoveDownAndModifySelection" }, 398 { VKEY_DOWN, ShiftKey, "MoveDownAndModifySelection" },
399 { VKEY_NEXT, ShiftKey, "MovePageDownAndModifySelection" }, 399 { VKEY_NEXT, ShiftKey, "MovePageDownAndModifySelection" },
400 #if !OS(DARWIN) 400 #if !OS(MACOSX)
401 { VKEY_UP, CtrlKey, "MoveParagraphBackward" }, 401 { VKEY_UP, CtrlKey, "MoveParagraphBackward" },
402 { VKEY_UP, CtrlKey | ShiftKey, "MoveParagraphBackwardAndModifySelection" }, 402 { VKEY_UP, CtrlKey | ShiftKey, "MoveParagraphBackwardAndModifySelection" },
403 { VKEY_DOWN, CtrlKey, "MoveParagraphForward" }, 403 { VKEY_DOWN, CtrlKey, "MoveParagraphForward" },
404 { VKEY_DOWN, CtrlKey | ShiftKey, "MoveParagraphForwardAndModifySelection" }, 404 { VKEY_DOWN, CtrlKey | ShiftKey, "MoveParagraphForwardAndModifySelection" },
405 { VKEY_PRIOR, 0, "MovePageUp" }, 405 { VKEY_PRIOR, 0, "MovePageUp" },
406 { VKEY_NEXT, 0, "MovePageDown" }, 406 { VKEY_NEXT, 0, "MovePageDown" },
407 #endif 407 #endif
408 { VKEY_HOME, 0, "MoveToBeginningOfLine" }, 408 { VKEY_HOME, 0, "MoveToBeginningOfLine" },
409 { VKEY_HOME, ShiftKey, 409 { VKEY_HOME, ShiftKey,
410 "MoveToBeginningOfLineAndModifySelection" }, 410 "MoveToBeginningOfLineAndModifySelection" },
411 #if OS(DARWIN) 411 #if OS(MACOSX)
412 { VKEY_LEFT, CommandKey, "MoveToBeginningOfLine" }, 412 { VKEY_LEFT, CommandKey, "MoveToBeginningOfLine" },
413 { VKEY_LEFT, CommandKey | ShiftKey, 413 { VKEY_LEFT, CommandKey | ShiftKey,
414 "MoveToBeginningOfLineAndModifySelection" }, 414 "MoveToBeginningOfLineAndModifySelection" },
415 { VKEY_PRIOR, OptionKey, "MovePageUp" }, 415 { VKEY_PRIOR, OptionKey, "MovePageUp" },
416 { VKEY_NEXT, OptionKey, "MovePageDown" }, 416 { VKEY_NEXT, OptionKey, "MovePageDown" },
417 #endif 417 #endif
418 #if OS(DARWIN) 418 #if OS(MACOSX)
419 { VKEY_UP, CommandKey, "MoveToBeginningOfDocument" }, 419 { VKEY_UP, CommandKey, "MoveToBeginningOfDocument" },
420 { VKEY_UP, CommandKey | ShiftKey, 420 { VKEY_UP, CommandKey | ShiftKey,
421 "MoveToBeginningOfDocumentAndModifySelection" }, 421 "MoveToBeginningOfDocumentAndModifySelection" },
422 #else 422 #else
423 { VKEY_HOME, CtrlKey, "MoveToBeginningOfDocument" }, 423 { VKEY_HOME, CtrlKey, "MoveToBeginningOfDocument" },
424 { VKEY_HOME, CtrlKey | ShiftKey, 424 { VKEY_HOME, CtrlKey | ShiftKey,
425 "MoveToBeginningOfDocumentAndModifySelection" }, 425 "MoveToBeginningOfDocumentAndModifySelection" },
426 #endif 426 #endif
427 { VKEY_END, 0, "MoveToEndOfLine" }, 427 { VKEY_END, 0, "MoveToEndOfLine" },
428 { VKEY_END, ShiftKey, "MoveToEndOfLineAndModifySelection" }, 428 { VKEY_END, ShiftKey, "MoveToEndOfLineAndModifySelection" },
429 #if OS(DARWIN) 429 #if OS(MACOSX)
430 { VKEY_DOWN, CommandKey, "MoveToEndOfDocument" }, 430 { VKEY_DOWN, CommandKey, "MoveToEndOfDocument" },
431 { VKEY_DOWN, CommandKey | ShiftKey, 431 { VKEY_DOWN, CommandKey | ShiftKey,
432 "MoveToEndOfDocumentAndModifySelection" }, 432 "MoveToEndOfDocumentAndModifySelection" },
433 #else 433 #else
434 { VKEY_END, CtrlKey, "MoveToEndOfDocument" }, 434 { VKEY_END, CtrlKey, "MoveToEndOfDocument" },
435 { VKEY_END, CtrlKey | ShiftKey, 435 { VKEY_END, CtrlKey | ShiftKey,
436 "MoveToEndOfDocumentAndModifySelection" }, 436 "MoveToEndOfDocumentAndModifySelection" },
437 #endif 437 #endif
438 #if OS(DARWIN) 438 #if OS(MACOSX)
439 { VKEY_RIGHT, CommandKey, "MoveToEndOfLine" }, 439 { VKEY_RIGHT, CommandKey, "MoveToEndOfLine" },
440 { VKEY_RIGHT, CommandKey | ShiftKey, 440 { VKEY_RIGHT, CommandKey | ShiftKey,
441 "MoveToEndOfLineAndModifySelection" }, 441 "MoveToEndOfLineAndModifySelection" },
442 #endif 442 #endif
443 { VKEY_BACK, 0, "DeleteBackward" }, 443 { VKEY_BACK, 0, "DeleteBackward" },
444 { VKEY_BACK, ShiftKey, "DeleteBackward" }, 444 { VKEY_BACK, ShiftKey, "DeleteBackward" },
445 { VKEY_DELETE, 0, "DeleteForward" }, 445 { VKEY_DELETE, 0, "DeleteForward" },
446 #if OS(DARWIN) 446 #if OS(MACOSX)
447 { VKEY_BACK, OptionKey, "DeleteWordBackward" }, 447 { VKEY_BACK, OptionKey, "DeleteWordBackward" },
448 { VKEY_DELETE, OptionKey, "DeleteWordForward" }, 448 { VKEY_DELETE, OptionKey, "DeleteWordForward" },
449 #else 449 #else
450 { VKEY_BACK, CtrlKey, "DeleteWordBackward" }, 450 { VKEY_BACK, CtrlKey, "DeleteWordBackward" },
451 { VKEY_DELETE, CtrlKey, "DeleteWordForward" }, 451 { VKEY_DELETE, CtrlKey, "DeleteWordForward" },
452 #endif 452 #endif
453 { 'B', CtrlKey, "ToggleBold" }, 453 { 'B', CtrlKey, "ToggleBold" },
454 { 'I', CtrlKey, "ToggleItalic" }, 454 { 'I', CtrlKey, "ToggleItalic" },
455 { 'U', CtrlKey, "ToggleUnderline" }, 455 { 'U', CtrlKey, "ToggleUnderline" },
456 { VKEY_ESCAPE, 0, "Cancel" }, 456 { VKEY_ESCAPE, 0, "Cancel" },
457 { VKEY_OEM_PERIOD, CtrlKey, "Cancel" }, 457 { VKEY_OEM_PERIOD, CtrlKey, "Cancel" },
458 { VKEY_TAB, 0, "InsertTab" }, 458 { VKEY_TAB, 0, "InsertTab" },
459 { VKEY_TAB, ShiftKey, "InsertBacktab" }, 459 { VKEY_TAB, ShiftKey, "InsertBacktab" },
460 { VKEY_RETURN, 0, "InsertNewline" }, 460 { VKEY_RETURN, 0, "InsertNewline" },
461 { VKEY_RETURN, CtrlKey, "InsertNewline" }, 461 { VKEY_RETURN, CtrlKey, "InsertNewline" },
462 { VKEY_RETURN, AltKey, "InsertNewline" }, 462 { VKEY_RETURN, AltKey, "InsertNewline" },
463 { VKEY_RETURN, AltKey | ShiftKey, "InsertNewline" }, 463 { VKEY_RETURN, AltKey | ShiftKey, "InsertNewline" },
464 { VKEY_RETURN, ShiftKey, "InsertLineBreak" }, 464 { VKEY_RETURN, ShiftKey, "InsertLineBreak" },
465 { VKEY_INSERT, CtrlKey, "Copy" }, 465 { VKEY_INSERT, CtrlKey, "Copy" },
466 { VKEY_INSERT, ShiftKey, "Paste" }, 466 { VKEY_INSERT, ShiftKey, "Paste" },
467 { VKEY_DELETE, ShiftKey, "Cut" }, 467 { VKEY_DELETE, ShiftKey, "Cut" },
468 #if !OS(DARWIN) 468 #if !OS(MACOSX)
469 // On OS X, we pipe these back to the browser, so that it can do menu item 469 // On OS X, we pipe these back to the browser, so that it can do menu item
470 // blinking. 470 // blinking.
471 { 'C', CtrlKey, "Copy" }, 471 { 'C', CtrlKey, "Copy" },
472 { 'V', CtrlKey, "Paste" }, 472 { 'V', CtrlKey, "Paste" },
473 { 'V', CtrlKey | ShiftKey, "PasteAndMatchStyle" }, 473 { 'V', CtrlKey | ShiftKey, "PasteAndMatchStyle" },
474 { 'X', CtrlKey, "Cut" }, 474 { 'X', CtrlKey, "Cut" },
475 { 'A', CtrlKey, "SelectAll" }, 475 { 'A', CtrlKey, "SelectAll" },
476 { 'Z', CtrlKey, "Undo" }, 476 { 'Z', CtrlKey, "Undo" },
477 { 'Z', CtrlKey | ShiftKey, "Redo" }, 477 { 'Z', CtrlKey | ShiftKey, "Redo" },
478 { 'Y', CtrlKey, "Redo" }, 478 { 'Y', CtrlKey, "Redo" },
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 // Don't insert null or control characters as they can result in 592 // Don't insert null or control characters as they can result in
593 // unexpected behaviour 593 // unexpected behaviour
594 if (ch < ' ') 594 if (ch < ' ')
595 return false; 595 return false;
596 #if !OS(WINDOWS) 596 #if !OS(WINDOWS)
597 // Don't insert ASCII character if ctrl w/o alt or meta is on. 597 // Don't insert ASCII character if ctrl w/o alt or meta is on.
598 // On Mac, we should ignore events when meta is on (Command-<x>). 598 // On Mac, we should ignore events when meta is on (Command-<x>).
599 if (ch < 0x80) { 599 if (ch < 0x80) {
600 if (evt->keyEvent()->ctrlKey() && !evt->keyEvent()->altKey()) 600 if (evt->keyEvent()->ctrlKey() && !evt->keyEvent()->altKey())
601 return false; 601 return false;
602 #if OS(DARWIN) 602 #if OS(MACOSX)
603 if (evt->keyEvent()->metaKey()) 603 if (evt->keyEvent()->metaKey())
604 return false; 604 return false;
605 #endif 605 #endif
606 } 606 }
607 #endif 607 #endif
608 } 608 }
609 609
610 if (!frame->editor().canEdit()) 610 if (!frame->editor().canEdit())
611 return false; 611 return false;
612 612
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 762
763 bool EditorClientImpl::spellingUIIsShowing() 763 bool EditorClientImpl::spellingUIIsShowing()
764 { 764 {
765 if (m_webView->spellCheckClient()) 765 if (m_webView->spellCheckClient())
766 return m_webView->spellCheckClient()->isShowingSpellingUI(); 766 return m_webView->spellCheckClient()->isShowingSpellingUI();
767 return false; 767 return false;
768 } 768 }
769 769
770 bool EditorClientImpl::supportsGlobalSelection() 770 bool EditorClientImpl::supportsGlobalSelection()
771 { 771 {
772 #if OS(UNIX) && !OS(DARWIN) 772 #if OS(UNIX) && !OS(MACOSX)
773 return true; 773 return true;
774 #else 774 #else
775 return false; 775 return false;
776 #endif 776 #endif
777 } 777 }
778 778
779 void EditorClientImpl::willSetInputMethodState() 779 void EditorClientImpl::willSetInputMethodState()
780 { 780 {
781 if (m_webView->client()) 781 if (m_webView->client())
782 m_webView->client()->resetInputMethod(); 782 m_webView->client()->resetInputMethod();
783 } 783 }
784 784
785 } // namesace WebKit 785 } // namesace WebKit
OLDNEW
« no previous file with comments | « Source/web/ContextMenuClientImpl.cpp ('k') | Source/web/WebFrameImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698