Bug 1181418 - Send selectionEditable info to app_text_selection_dialog. r=tlin, r=kanru, sr=smaug
authorJeremy Chen <jeremychen@mozilla.com>
Fri, 31 Jul 2015 04:34:00 +0800
changeset 288175 2848ae508c5d566b41ca40ef159ea9566c917070
parent 288174 e22327ec52514f4c6db4810c1eea316adc1f5ded
child 288176 f5ed4dae7a9c702eef49c3de3f0fa9b8882e0a17
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstlin, kanru, smaug
bugs1181418
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1181418 - Send selectionEditable info to app_text_selection_dialog. r=tlin, r=kanru, sr=smaug
dom/browser-element/BrowserElementCopyPaste.js
dom/browser-element/BrowserElementParent.js
dom/webidl/CaretStateChangedEvent.webidl
layout/base/AccessibleCaretManager.cpp
--- a/dom/browser-element/BrowserElementCopyPaste.js
+++ b/dom/browser-element/BrowserElementCopyPaste.js
@@ -66,17 +66,18 @@ let CopyPasteAssistent = {
         canCut: this._isCommandEnabled("cut"),
         canCopy: this._isCommandEnabled("copy"),
         canPaste: this._isCommandEnabled("paste"),
       },
       zoomFactor: zoomFactor,
       reason: e.reason,
       collapsed: e.collapsed,
       caretVisible: e.caretVisible,
-      selectionVisible: e.selectionVisible
+      selectionVisible: e.selectionVisible,
+      selectionEditable: e.selectionEditable
     };
 
     // Get correct geometry information if we have nested iframe.
     let currentWindow = e.target.defaultView;
     while (currentWindow.realFrameElement) {
       let currentRect = currentWindow.realFrameElement.getBoundingClientRect();
       detail.rect.top += currentRect.top;
       detail.rect.bottom += currentRect.top;
--- a/dom/browser-element/BrowserElementParent.js
+++ b/dom/browser-element/BrowserElementParent.js
@@ -447,16 +447,17 @@ BrowserElementParent.prototype = {
   //              command is available, using following code, if (data.commands.canCut) {}.
   //  - zoomFactor: Current zoom factor in child frame.
   //  - reason: The reason causes the state changed. Include "visibilitychange",
   //            "updateposition", "longpressonemptycontent", "taponcaret", "presscaret",
   //            "releasecaret".
   //  - collapsed: Indicate current selection is collapsed or not.
   //  - caretVisible: Indicate the caret visiibility.
   //  - selectionVisible: Indicate current selection is visible or not.
+  //  - selectionEditable: Indicate current selection is editable or not.
   _handleCaretStateChanged: function(data) {
     let evt = this._createEvent('caretstatechanged', data.json,
                                 /* cancelable = */ false);
 
     let self = this;
     function sendDoCommandMsg(cmd) {
       let data = { command: cmd };
       self._sendAsyncMsg('copypaste-do-command', data);
--- a/dom/webidl/CaretStateChangedEvent.webidl
+++ b/dom/webidl/CaretStateChangedEvent.webidl
@@ -14,19 +14,21 @@ enum CaretChangedReason {
 };
 
 dictionary CaretStateChangedEventInit : EventInit {
   boolean collapsed = true;
   DOMRectReadOnly? boundingClientRect = null;
   CaretChangedReason reason = "visibilitychange";
   boolean caretVisible = false;
   boolean selectionVisible = false;
+  boolean selectionEditable = false;
 };
 
 [Constructor(DOMString type, optional CaretStateChangedEventInit eventInit),
  ChromeOnly]
 interface CaretStateChangedEvent : Event {
   readonly attribute boolean collapsed;
   readonly attribute DOMRectReadOnly? boundingClientRect;
   readonly attribute CaretChangedReason reason;
   readonly attribute boolean caretVisible;
   readonly attribute boolean selectionVisible;
+  readonly attribute boolean selectionEditable;
 };
--- a/layout/base/AccessibleCaretManager.cpp
+++ b/layout/base/AccessibleCaretManager.cpp
@@ -936,16 +936,21 @@ AccessibleCaretManager::DispatchCaretSta
     nsLayoutUtils::TransformRect(commonAncestorFrame, rootFrame, clampedRect);
     domRect->SetLayoutRect(clampedRect);
     init.mSelectionVisible = !clampedRect.IsEmpty();
   } else {
     domRect->SetLayoutRect(rect);
     init.mSelectionVisible = true;
   }
 
+  // Send isEditable info w/ event detail. This info can help determine
+  // whether to show cut command on selection dialog or not.
+  init.mSelectionEditable = commonAncestorFrame &&
+    commonAncestorFrame->GetContent()->GetEditingHost();
+
   init.mBoundingClientRect = domRect;
   init.mReason = aReason;
   init.mCollapsed = sel->IsCollapsed();
   init.mCaretVisible = mFirstCaret->IsLogicallyVisible() ||
                        mSecondCaret->IsLogicallyVisible();
 
   nsRefPtr<CaretStateChangedEvent> event =
     CaretStateChangedEvent::Constructor(doc, NS_LITERAL_STRING("mozcaretstatechanged"), init);