Bug 389283 - Choose cursor value based on selectability. r?dbaron
MozReview-Commit-ID: 2c4RcXgwz1U
--- 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*