forked from mirrors/gecko-dev
		
	 a25988774a
			
		
	
	
		a25988774a
		
	
	
	
	
		
			
			Currently, this feature is implemented only on Linux and macOS (see also bug 1077515 and bug 1301497), and the code is really similar each other. Additionally, it always tries to query selection to check whether the caret is in vertical content or not if arrow keys are pressed. For avoiding a lot of query, this patch makes `TextEventDispatcher` cache writing mode at every selection change notification. However, unfortunately, it's not available when non-editable content has focus, but it should be out of scope of this bug since it requires a lot of changes. Anyway, with this patch, we can write a mochitest only on Linux and macOS. The following patch adds a test for this as a fix of bug 1103374. Differential Revision: https://phabricator.services.mozilla.com/D102881
		
			
				
	
	
		
			63 lines
		
	
	
	
		
			1.9 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			63 lines
		
	
	
	
		
			1.9 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 | |
| /* This Source Code Form is subject to the terms of the Mozilla Public
 | |
|  * License, v. 2.0. If a copy of the MPL was not distributed with this
 | |
|  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 | |
| 
 | |
| #ifndef NativeKeyBindings_h
 | |
| #define NativeKeyBindings_h
 | |
| 
 | |
| #include "mozilla/Attributes.h"
 | |
| #include "mozilla/EventForwards.h"
 | |
| #include "nsIWidget.h"
 | |
| 
 | |
| #include <glib.h>  // for guint
 | |
| 
 | |
| using GtkWidget = struct _GtkWidget;
 | |
| 
 | |
| namespace mozilla {
 | |
| 
 | |
| class WritingMode;
 | |
| template <typename T>
 | |
| class Maybe;
 | |
| 
 | |
| namespace widget {
 | |
| 
 | |
| class NativeKeyBindings final {
 | |
|   typedef nsIWidget::NativeKeyBindingsType NativeKeyBindingsType;
 | |
| 
 | |
|  public:
 | |
|   static NativeKeyBindings* GetInstance(NativeKeyBindingsType aType);
 | |
|   static void Shutdown();
 | |
| 
 | |
|   /**
 | |
|    * GetEditCommandsForTests() returns commands performed in native widget
 | |
|    * in typical environment.  I.e., this does NOT refer customized shortcut
 | |
|    * key mappings of the environment.
 | |
|    */
 | |
|   static void GetEditCommandsForTests(NativeKeyBindingsType aType,
 | |
|                                       const WidgetKeyboardEvent& aEvent,
 | |
|                                       const Maybe<WritingMode>& aWritingMode,
 | |
|                                       nsTArray<CommandInt>& aCommands);
 | |
| 
 | |
|   void Init(NativeKeyBindingsType aType);
 | |
| 
 | |
|   void GetEditCommands(const WidgetKeyboardEvent& aEvent,
 | |
|                        const Maybe<WritingMode>& aWritingMode,
 | |
|                        nsTArray<CommandInt>& aCommands);
 | |
| 
 | |
|  private:
 | |
|   ~NativeKeyBindings();
 | |
| 
 | |
|   bool GetEditCommandsInternal(const WidgetKeyboardEvent& aEvent,
 | |
|                                nsTArray<CommandInt>& aCommands, guint aKeyval);
 | |
| 
 | |
|   GtkWidget* mNativeTarget;
 | |
| 
 | |
|   static NativeKeyBindings* sInstanceForSingleLineEditor;
 | |
|   static NativeKeyBindings* sInstanceForMultiLineEditor;
 | |
| };
 | |
| 
 | |
| }  // namespace widget
 | |
| }  // namespace mozilla
 | |
| 
 | |
| #endif  // NativeKeyBindings_h
 |