From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../actors/KeyPressEventModelCheckerChild.sys.mjs | 107 +++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 toolkit/actors/KeyPressEventModelCheckerChild.sys.mjs (limited to 'toolkit/actors/KeyPressEventModelCheckerChild.sys.mjs') diff --git a/toolkit/actors/KeyPressEventModelCheckerChild.sys.mjs b/toolkit/actors/KeyPressEventModelCheckerChild.sys.mjs new file mode 100644 index 0000000000..8b4fe82f17 --- /dev/null +++ b/toolkit/actors/KeyPressEventModelCheckerChild.sys.mjs @@ -0,0 +1,107 @@ +/* -*- mode: js; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set ts=2 sw=2 sts=2 et tw=80: */ +/* 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/. */ + +import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs"; + +export class KeyPressEventModelCheckerChild extends JSWindowActorChild { + // Currently, the event is dispatched only when the document becomes editable + // because of contenteditable. If you need to add new editor which is in + // designMode, you need to change MaybeDispatchCheckKeyPressEventModelEvent() + // of Document. + handleEvent(aEvent) { + if (!AppConstants.DEBUG) { + // Stop propagation in opt build to save the propagation cost. + // However, the event is necessary for running test_bug1514940.html. + // Therefore, we need to keep propagating it at least on debug build. + aEvent.stopImmediatePropagation(); + } + + // Currently, even if we set Document.KEYPRESS_EVENT_MODEL_CONFLATED + // here, conflated model isn't used forcibly. If you need it, you need + // to change WidgetKeyboardEvent, dom::KeyboardEvent and PresShell. + let model = Document.KEYPRESS_EVENT_MODEL_DEFAULT; + if ( + this._isOldOfficeOnlineServer(aEvent.target) || + this._isOldConfluence(aEvent.target.ownerGlobal) + ) { + model = Document.KEYPRESS_EVENT_MODEL_SPLIT; + } + aEvent.target.setKeyPressEventModel(model); + } + + _isOldOfficeOnlineServer(aDocument) { + let editingElement = aDocument.getElementById( + "WACViewPanel_EditingElement" + ); + // If it's not Office Online Server, don't include it into the telemetry + // because we just need to collect percentage of old version in all loaded + // Office Online Server instances. + if (!editingElement) { + return false; + } + let isOldVersion = !editingElement.classList.contains( + "WACViewPanel_DisableLegacyKeyCodeAndCharCode" + ); + Services.telemetry.keyedScalarAdd( + "dom.event.office_online_load_count", + isOldVersion ? "old" : "new", + 1 + ); + return isOldVersion; + } + + _isOldConfluence(aWindow) { + if (!aWindow) { + return false; + } + // aWindow should be an editor window in