mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1090008 - Part 4 - Rename SelectionChange to SelectionStateChanged, r=smaug
This commit is contained in:
parent
b09f5634dd
commit
17d9113f50
@ -329,7 +329,7 @@ var shell = {
|
||||
window.addEventListener('sizemodechange', this);
|
||||
window.addEventListener('unload', this);
|
||||
this.contentBrowser.addEventListener('mozbrowserloadstart', this, true);
|
||||
this.contentBrowser.addEventListener('mozbrowserselectionchange', this, true);
|
||||
this.contentBrowser.addEventListener('mozbrowserselectionstatechanged', this, true);
|
||||
this.contentBrowser.addEventListener('mozbrowserscrollviewchange', this, true);
|
||||
this.contentBrowser.addEventListener('mozbrowsertouchcarettap', this, true);
|
||||
|
||||
@ -357,7 +357,7 @@ var shell = {
|
||||
window.removeEventListener('mozfullscreenchange', this);
|
||||
window.removeEventListener('sizemodechange', this);
|
||||
this.contentBrowser.removeEventListener('mozbrowserloadstart', this, true);
|
||||
this.contentBrowser.removeEventListener('mozbrowserselectionchange', this, true);
|
||||
this.contentBrowser.removeEventListener('mozbrowserselectionstatechanged', this, true);
|
||||
this.contentBrowser.removeEventListener('mozbrowserscrollviewchange', this, true);
|
||||
this.contentBrowser.removeEventListener('mozbrowsertouchcarettap', this, true);
|
||||
ppmm.removeMessageListener("content-handler", this);
|
||||
@ -505,8 +505,8 @@ var shell = {
|
||||
detail: evt.detail,
|
||||
});
|
||||
break;
|
||||
case 'mozbrowserselectionchange':
|
||||
// The mozbrowserselectionchange event, may have crossed the chrome-content boundary.
|
||||
case 'mozbrowserselectionstatechanged':
|
||||
// The mozbrowserselectionstatechanged event, may have crossed the chrome-content boundary.
|
||||
// This event always dispatch to shell.js. But the offset we got from this event is
|
||||
// based on tab's coordinate. So get the actual offsets between shell and evt.target.
|
||||
let elt = evt.target;
|
||||
@ -524,7 +524,7 @@ var shell = {
|
||||
|
||||
DoCommandHelper.setEvent(evt);
|
||||
shell.sendChromeEvent({
|
||||
type: 'selectionchange',
|
||||
type: 'selectionstatechanged',
|
||||
detail: data,
|
||||
});
|
||||
break;
|
||||
|
@ -94,7 +94,7 @@ function BrowserElementChild() {
|
||||
|
||||
this._isContentWindowCreated = false;
|
||||
this._pendingSetInputMethodActive = [];
|
||||
this._forceDispatchSelectionChange = false;
|
||||
this._forceDispatchSelectionStateChanged = false;
|
||||
|
||||
this._init();
|
||||
};
|
||||
@ -162,8 +162,8 @@ BrowserElementChild.prototype = {
|
||||
/* useCapture = */ true,
|
||||
/* wantsUntrusted = */ false);
|
||||
|
||||
addEventListener('mozselectionchange',
|
||||
this._selectionChangeHandler.bind(this),
|
||||
addEventListener('mozselectionstatechanged',
|
||||
this._selectionStateChangedHandler.bind(this),
|
||||
/* useCapture = */ false,
|
||||
/* wantsUntrusted = */ false);
|
||||
|
||||
@ -592,7 +592,7 @@ BrowserElementChild.prototype = {
|
||||
sendAsyncMsg('scrollviewchange', detail);
|
||||
},
|
||||
|
||||
_selectionChangeHandler: function(e) {
|
||||
_selectionStateChangedHandler: function(e) {
|
||||
e.stopPropagation();
|
||||
let boundingClientRect = e.boundingClientRect;
|
||||
if (!boundingClientRect) {
|
||||
@ -600,22 +600,22 @@ BrowserElementChild.prototype = {
|
||||
}
|
||||
|
||||
let isCollapsed = (e.selectedText.length == 0);
|
||||
let isMouseUp = (e.reasons.indexOf('mouseup') == 0);
|
||||
let isMouseUp = (e.states.indexOf('mouseup') == 0);
|
||||
let canPaste = this._isCommandEnabled("paste");
|
||||
|
||||
if (!this._forceDispatchSelectionChange) {
|
||||
// SelectionChange events with the following reasons are not
|
||||
if (!this._forceDispatchSelectionStateChanged) {
|
||||
// SelectionStateChanged events with the following states are not
|
||||
// necessary to trigger the text dialog, bypass these events
|
||||
// by default.
|
||||
//
|
||||
if(e.reasons.length == 0 ||
|
||||
e.reasons.indexOf('drag') == 0 ||
|
||||
e.reasons.indexOf('keypress') == 0 ||
|
||||
e.reasons.indexOf('mousedown') == 0) {
|
||||
if(e.states.length == 0 ||
|
||||
e.states.indexOf('drag') == 0 ||
|
||||
e.states.indexOf('keypress') == 0 ||
|
||||
e.states.indexOf('mousedown') == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The collapsed SelectionChange event is unnecessary to dispatch,
|
||||
// The collapsed SelectionStateChanged event is unnecessary to dispatch,
|
||||
// bypass this event by default. But there is one exception to support
|
||||
// the shortcut mode which can paste previous copied content easily
|
||||
if (isCollapsed) {
|
||||
@ -631,13 +631,13 @@ BrowserElementChild.prototype = {
|
||||
// mousedown/mouseup, no matter touch or long tap on the screen. When there is
|
||||
// is a non-collapsed selection change event which comes with mouseup reason,
|
||||
// it implies some texts are selected. In order to hide the text dialog during next
|
||||
// touch, here sets the forceDispatchSelectionChange flag as true to dispatch the
|
||||
// touch, here sets the forceDispatchSelectionStateChanged flag as true to dispatch the
|
||||
// next SelecitonChange event(with the mousedown) so that the parent side can
|
||||
// hide the text dialog.
|
||||
if (isMouseUp && !isCollapsed) {
|
||||
this._forceDispatchSelectionChange = true;
|
||||
this._forceDispatchSelectionStateChanged = true;
|
||||
} else {
|
||||
this._forceDispatchSelectionChange = false;
|
||||
this._forceDispatchSelectionStateChanged = false;
|
||||
}
|
||||
|
||||
let zoomFactor = content.screen.width / content.innerWidth;
|
||||
@ -658,7 +658,7 @@ BrowserElementChild.prototype = {
|
||||
canPaste: this._isCommandEnabled("paste"),
|
||||
},
|
||||
zoomFactor: zoomFactor,
|
||||
reasons: e.reasons,
|
||||
states: e.states,
|
||||
isCollapsed: (e.selectedText.length == 0),
|
||||
};
|
||||
|
||||
@ -673,7 +673,7 @@ BrowserElementChild.prototype = {
|
||||
currentWindow = currentWindow.parent;
|
||||
}
|
||||
|
||||
sendAsyncMsg('selectionchange', detail);
|
||||
sendAsyncMsg('selectionstatechanged', detail);
|
||||
},
|
||||
|
||||
_themeColorChangedHandler: function(eventType, target) {
|
||||
|
@ -197,7 +197,7 @@ BrowserElementParent.prototype = {
|
||||
"got-visible": this._gotDOMRequestResult,
|
||||
"visibilitychange": this._childVisibilityChange,
|
||||
"got-set-input-method-active": this._gotDOMRequestResult,
|
||||
"selectionchange": this._handleSelectionChange,
|
||||
"selectionstatechanged": this._handleSelectionStateChanged,
|
||||
"scrollviewchange": this._handleScrollViewChange,
|
||||
"touchcarettap": this._handleTouchCaretTap
|
||||
};
|
||||
@ -435,8 +435,8 @@ BrowserElementParent.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
_handleSelectionChange: function(data) {
|
||||
let evt = this._createEvent('selectionchange', data.json,
|
||||
_handleSelectionStateChanged: function(data) {
|
||||
let evt = this._createEvent('selectionstatechanged', data.json,
|
||||
/* cancelable = */ false);
|
||||
this._frameElement.dispatchEvent(evt);
|
||||
},
|
||||
|
@ -4,7 +4,7 @@
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
enum SelectionChangeReason {
|
||||
enum SelectionState {
|
||||
"drag",
|
||||
"mousedown",
|
||||
"mouseup",
|
||||
@ -14,16 +14,16 @@ enum SelectionChangeReason {
|
||||
"collapsetoend"
|
||||
};
|
||||
|
||||
dictionary SelectionChangeEventInit : EventInit {
|
||||
dictionary SelectionStateChangedEventInit : EventInit {
|
||||
DOMString selectedText = "";
|
||||
DOMRectReadOnly? boundingClientRect = null;
|
||||
sequence<SelectionChangeReason> reasons = [];
|
||||
sequence<SelectionState> states = [];
|
||||
};
|
||||
|
||||
[Constructor(DOMString type, optional SelectionChangeEventInit eventInit),
|
||||
[Constructor(DOMString type, optional SelectionStateChangedEventInit eventInit),
|
||||
ChromeOnly]
|
||||
interface SelectionChangeEvent : Event {
|
||||
interface SelectionStateChangedEvent : Event {
|
||||
readonly attribute DOMString selectedText;
|
||||
readonly attribute DOMRectReadOnly? boundingClientRect;
|
||||
[Cached, Pure] readonly attribute sequence<SelectionChangeReason> reasons;
|
||||
[Cached, Pure] readonly attribute sequence<SelectionState> states;
|
||||
};
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "mozilla/dom/DOMRect.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/ScrollViewChangeEvent.h"
|
||||
#include "mozilla/dom/SelectionChangeEvent.h"
|
||||
#include "mozilla/dom/SelectionStateChangedEvent.h"
|
||||
#include "mozilla/dom/Selection.h"
|
||||
#include "mozilla/dom/TreeWalker.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
@ -936,32 +936,32 @@ SelectionCarets::GetFrameSelection()
|
||||
}
|
||||
}
|
||||
|
||||
static dom::Sequence<SelectionChangeReason>
|
||||
GetSelectionChangeReasons(int16_t aReason)
|
||||
static dom::Sequence<SelectionState>
|
||||
GetSelectionStates(int16_t aReason)
|
||||
{
|
||||
dom::Sequence<SelectionChangeReason> reasons;
|
||||
dom::Sequence<SelectionState> states;
|
||||
if (aReason & nsISelectionListener::DRAG_REASON) {
|
||||
reasons.AppendElement(SelectionChangeReason::Drag);
|
||||
states.AppendElement(SelectionState::Drag);
|
||||
}
|
||||
if (aReason & nsISelectionListener::MOUSEDOWN_REASON) {
|
||||
reasons.AppendElement(SelectionChangeReason::Mousedown);
|
||||
states.AppendElement(SelectionState::Mousedown);
|
||||
}
|
||||
if (aReason & nsISelectionListener::MOUSEUP_REASON) {
|
||||
reasons.AppendElement(SelectionChangeReason::Mouseup);
|
||||
states.AppendElement(SelectionState::Mouseup);
|
||||
}
|
||||
if (aReason & nsISelectionListener::KEYPRESS_REASON) {
|
||||
reasons.AppendElement(SelectionChangeReason::Keypress);
|
||||
states.AppendElement(SelectionState::Keypress);
|
||||
}
|
||||
if (aReason & nsISelectionListener::SELECTALL_REASON) {
|
||||
reasons.AppendElement(SelectionChangeReason::Selectall);
|
||||
states.AppendElement(SelectionState::Selectall);
|
||||
}
|
||||
if (aReason & nsISelectionListener::COLLAPSETOSTART_REASON) {
|
||||
reasons.AppendElement(SelectionChangeReason::Collapsetostart);
|
||||
states.AppendElement(SelectionState::Collapsetostart);
|
||||
}
|
||||
if (aReason & nsISelectionListener::COLLAPSETOEND_REASON) {
|
||||
reasons.AppendElement(SelectionChangeReason::Collapsetoend);
|
||||
states.AppendElement(SelectionState::Collapsetoend);
|
||||
}
|
||||
return reasons;
|
||||
return states;
|
||||
}
|
||||
|
||||
static nsRect
|
||||
@ -997,15 +997,15 @@ GetSelectionBoundingRect(Selection* aSel, nsIPresShell* aShell)
|
||||
}
|
||||
|
||||
static void
|
||||
DispatchSelectionChangeEvent(nsIPresShell* aPresShell,
|
||||
DispatchSelectionStateChangedEvent(nsIPresShell* aPresShell,
|
||||
nsISelection* aSel,
|
||||
const dom::Sequence<SelectionChangeReason>& aReasons)
|
||||
const dom::Sequence<SelectionState>& aStates)
|
||||
{
|
||||
nsIDocument* doc = aPresShell->GetDocument();
|
||||
|
||||
MOZ_ASSERT(doc);
|
||||
|
||||
SelectionChangeEventInit init;
|
||||
SelectionStateChangedEventInit init;
|
||||
init.mBubbles = true;
|
||||
|
||||
if (aSel) {
|
||||
@ -1018,10 +1018,10 @@ DispatchSelectionChangeEvent(nsIPresShell* aPresShell,
|
||||
|
||||
selection->Stringify(init.mSelectedText);
|
||||
}
|
||||
init.mReasons = aReasons;
|
||||
init.mStates = aStates;
|
||||
|
||||
nsRefPtr<SelectionChangeEvent> event =
|
||||
SelectionChangeEvent::Constructor(doc, NS_LITERAL_STRING("mozselectionchange"), init);
|
||||
nsRefPtr<SelectionStateChangedEvent> event =
|
||||
SelectionStateChangedEvent::Constructor(doc, NS_LITERAL_STRING("mozselectionstatechanged"), init);
|
||||
|
||||
event->SetTrusted(true);
|
||||
event->GetInternalNSEvent()->mFlags.mOnlyChromeDispatch = true;
|
||||
@ -1043,7 +1043,7 @@ SelectionCarets::NotifySelectionChanged(nsIDOMDocument* aDoc,
|
||||
UpdateSelectionCarets();
|
||||
}
|
||||
|
||||
DispatchSelectionChangeEvent(mPresShell, aSel, GetSelectionChangeReasons(aReason));
|
||||
DispatchSelectionStateChangedEvent(mPresShell, aSel, GetSelectionStates(aReason));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user