Bug 389283 - Choose cursor value based on selectability. r?dbaron draft
authorXidorn Quan <me@upsuper.org>
Fri, 25 Nov 2016 01:00:34 +1100
changeset 443454 cbdc0c1850b77a94b5ce639ddb5792529d83e5f0
parent 443220 34fce7c12173bdd6dda54c2ebf6d344252f1ac48
child 538060 21096f865384ca607b63074e0fc48ac2e95a2226
push id37002
push usermozilla@upsuper.org
push dateThu, 24 Nov 2016 14:19:00 +0000
reviewersdbaron
bugs389283
milestone53.0a1
Bug 389283 - Choose cursor value based on selectability. r?dbaron MozReview-Commit-ID: 2c4RcXgwz1U
layout/generic/nsTextFrame.cpp
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -4517,39 +4517,23 @@ nsTextFrame::~nsTextFrame()
 }
 
 nsresult
 nsTextFrame::GetCursor(const nsPoint& aPoint,
                        nsIFrame::Cursor& aCursor)
 {
   FillCursorInformationFromStyle(StyleUserInterface(), aCursor);
   if (NS_STYLE_CURSOR_AUTO == aCursor.mCursor) {
-    aCursor.mCursor = GetWritingMode().IsVertical()
-                      ? NS_STYLE_CURSOR_VERTICAL_TEXT : NS_STYLE_CURSOR_TEXT;
-    // If this is editable, we should ignore tabindex value.
-    if (mContent->IsEditable()) {
-      return NS_OK;
-    }
-
-    // If tabindex >= 0, use default cursor to indicate it's not selectable
-    nsIFrame *ancestorFrame = this;
-    while ((ancestorFrame = ancestorFrame->GetParent()) != nullptr) {
-      nsIContent *ancestorContent = ancestorFrame->GetContent();
-      if (ancestorContent && ancestorContent->HasAttr(kNameSpaceID_None, nsGkAtoms::tabindex)) {
-        nsAutoString tabIndexStr;
-        ancestorContent->GetAttr(kNameSpaceID_None, nsGkAtoms::tabindex, tabIndexStr);
-        if (!tabIndexStr.IsEmpty()) {
-          nsresult rv;
-          int32_t tabIndexVal = tabIndexStr.ToInteger(&rv);
-          if (NS_SUCCEEDED(rv) && tabIndexVal >= 0) {
-            aCursor.mCursor = NS_STYLE_CURSOR_DEFAULT;
-            break;
-          }
-        }
-      }
+    bool selectable;
+    IsSelectable(&selectable, nullptr);
+    if (!selectable) {
+      aCursor.mCursor = NS_STYLE_CURSOR_DEFAULT;
+    } else {
+      aCursor.mCursor = GetWritingMode().IsVertical()
+        ? NS_STYLE_CURSOR_VERTICAL_TEXT : NS_STYLE_CURSOR_TEXT;
     }
     return NS_OK;
   } else {
     return nsFrame::GetCursor(aPoint, aCursor);
   }
 }
 
 nsIFrame*