Bug 1320815 - DeCOMtaminate nsIFrame::IsSelectable by returning boolean instead of nsresult. r=xidorn

MozReview-Commit-ID: EBxBcEgIvp7

--HG--
extra : rebase_source : 49e5a370df86baec014e99be56b05d451d5ee78c
This commit is contained in:
L. David Baron 2016-11-28 15:31:29 -08:00
parent 813fb8c039
commit 03d6962a30
6 changed files with 24 additions and 49 deletions

View File

@ -450,9 +450,7 @@ nsDocumentEncoder::SerializeToStringRecursive(nsINode* aNode,
if (aNode->IsNodeOfType(nsINode::eCONTENT)) {
nsIFrame* frame = static_cast<nsIContent*>(aNode)->GetPrimaryFrame();
if (frame) {
bool isSelectable;
frame->IsSelectable(&isSelectable, nullptr);
if (!isSelectable){
if (!frame->IsSelectable(nullptr)) {
aDontSerializeRoot = true;
}
}

View File

@ -3260,7 +3260,7 @@ nsRange::ExcludeNonSelectableNodes(nsTArray<RefPtr<nsRange>>* aOutRanges)
frame = p->GetPrimaryFrame();
}
if (frame) {
frame->IsSelectable(&selectable, nullptr);
selectable = frame->IsSelectable(nullptr);
}
}
}

View File

@ -614,8 +614,7 @@ AccessibleCaretManager::SelectWordOrShortcut(const nsPoint& aPoint)
return NS_OK;
}
bool selectable = false;
ptFrame->IsSelectable(&selectable, nullptr);
bool selectable = ptFrame->IsSelectable(nullptr);
#ifdef DEBUG_FRAME_DUMP
AC_LOG("%s: %s %s selectable.", __FUNCTION__, ptFrame->ListTag().get(),
@ -1211,9 +1210,7 @@ AccessibleCaretManager::DragCaretInternal(const nsPoint& aPoint)
return NS_ERROR_FAILURE;
}
bool selectable;
newFrame->IsSelectable(&selectable, nullptr);
if (!selectable) {
if (!newFrame->IsSelectable(nullptr)) {
return NS_ERROR_FAILURE;
}

View File

@ -1726,9 +1726,7 @@ nsFrame::DisplaySelection(nsPresContext* aPresContext, bool isOkToTurnOn)
result = selCon->GetDisplaySelection(&selType);
if (NS_SUCCEEDED(result) && (selType != nsISelectionController::SELECTION_OFF)) {
// Check whether style allows selection.
bool selectable;
IsSelectable(&selectable, nullptr);
if (!selectable) {
if (!IsSelectable(nullptr)) {
selType = nsISelectionController::SELECTION_OFF;
isOkToTurnOn = false;
}
@ -3163,11 +3161,10 @@ nsFrame::GetDataForTableSelection(const nsFrameSelection* aFrameSelection,
return NS_OK;
}
nsresult
nsIFrame::IsSelectable(bool* aSelectable, StyleUserSelect* aSelectStyle) const
bool
nsIFrame::IsSelectable(StyleUserSelect* aSelectStyle) const
{
if (!aSelectable) //it's ok if aSelectStyle is null
return NS_ERROR_NULL_POINTER;
// it's ok if aSelectStyle is null
// Like 'visibility', we must check all the parents: if a parent
// is not selectable, none of its children is selectable.
@ -3239,13 +3236,9 @@ nsIFrame::IsSelectable(bool* aSelectable, StyleUserSelect* aSelectStyle) const
*aSelectStyle = selectStyle;
}
if (mState & NS_FRAME_GENERATED_CONTENT) {
*aSelectable = false;
} else {
*aSelectable = allowSelection && (selectStyle != StyleUserSelect::None);
}
return NS_OK;
return !(mState & NS_FRAME_GENERATED_CONTENT) &&
allowSelection &&
selectStyle != StyleUserSelect::None;
}
/**
@ -3272,7 +3265,6 @@ nsFrame::HandlePress(nsPresContext* aPresContext,
if (!aPresContext->EventStateManager()->EventStatusOK(aEvent))
return NS_OK;
nsresult rv;
nsIPresShell *shell = aPresContext->GetPresShell();
if (!shell)
return NS_ERROR_FAILURE;
@ -3302,14 +3294,11 @@ nsFrame::HandlePress(nsPresContext* aPresContext,
// check whether style allows selection
// if not, don't tell selection the mouse event even occurred.
bool selectable;
StyleUserSelect selectStyle;
rv = IsSelectable(&selectable, &selectStyle);
if (NS_FAILED(rv)) return rv;
// check for select: none
if (!selectable)
if (!IsSelectable(&selectStyle)) {
return NS_OK;
}
// When implementing StyleUserSelect::Element, StyleUserSelect::Elements and
// StyleUserSelect::Toggle, need to change this logic
@ -3390,6 +3379,7 @@ nsFrame::HandlePress(nsPresContext* aPresContext,
nsCOMPtr<nsIContent>parentContent;
int32_t contentOffset;
int32_t target;
nsresult rv;
rv = GetDataForTableSelection(frameselection, shell, mouseEvent,
getter_AddRefs(parentContent), &contentOffset,
&target);
@ -7442,10 +7432,7 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext,
aPos->mAttach = offsets.associate;
if (offsets.content)
{
bool selectable;
resultFrame->IsSelectable(&selectable, nullptr);
if (selectable)
{
if (resultFrame->IsSelectable(nullptr)) {
found = true;
break;
}
@ -7487,10 +7474,7 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext,
aPos->mAttach = offsets.associate;
if (offsets.content)
{
bool selectable;
resultFrame->IsSelectable(&selectable, nullptr);
if (selectable)
{
if (resultFrame->IsSelectable(nullptr)) {
found = true;
if (resultFrame == farStoppingFrame)
aPos->mAttach = CARET_ASSOCIATE_BEFORE;
@ -8301,7 +8285,7 @@ nsIFrame::GetFrameFromDirection(nsDirection aDirection, bool aVisual,
}
}
traversedFrame->IsSelectable(&selectable, nullptr);
selectable = traversedFrame->IsSelectable(nullptr);
if (!selectable) {
*aOutMovedOverNonSelectableText = true;
}

View File

@ -2782,13 +2782,13 @@ public:
* called to discover where this frame, or a parent frame has user-select style
* applied, which affects that way that it is selected.
*
* @param aIsSelectable out param. Set to true if the frame can be selected
* (i.e. is not affected by user-select: none)
* @param aSelectStyle out param. Returns the type of selection style found
* (using values defined in nsStyleConsts.h).
*
* @return Whether the frame can be selected (i.e. is not affected by
* user-select: none)
*/
nsresult IsSelectable(bool* aIsSelectable,
mozilla::StyleUserSelect* aSelectStyle) const;
bool IsSelectable(mozilla::StyleUserSelect* aSelectStyle) const;
/**
* Called to retrieve the SelectionController associated with the frame.

View File

@ -4525,9 +4525,7 @@ nsTextFrame::GetCursor(const nsPoint& aPoint,
{
FillCursorInformationFromStyle(StyleUserInterface(), aCursor);
if (NS_STYLE_CURSOR_AUTO == aCursor.mCursor) {
bool selectable;
IsSelectable(&selectable, nullptr);
if (!selectable) {
if (!IsSelectable(nullptr)) {
aCursor.mCursor = NS_STYLE_CURSOR_DEFAULT;
} else {
aCursor.mCursor = GetWritingMode().IsVertical()
@ -7853,9 +7851,8 @@ nsTextFrame::PeekOffsetCharacter(bool aForward, int32_t* aOffset,
int32_t contentLength = GetContentLength();
NS_ASSERTION(aOffset && *aOffset <= contentLength, "aOffset out of range");
bool selectable;
StyleUserSelect selectStyle;
IsSelectable(&selectable, &selectStyle);
IsSelectable(&selectStyle);
if (selectStyle == StyleUserSelect::All)
return CONTINUE_UNSELECTABLE;
@ -8042,9 +8039,8 @@ nsTextFrame::PeekOffsetWord(bool aForward, bool aWordSelectEatSpace, bool aIsKey
int32_t contentLength = GetContentLength();
NS_ASSERTION (aOffset && *aOffset <= contentLength, "aOffset out of range");
bool selectable;
StyleUserSelect selectStyle;
IsSelectable(&selectable, &selectStyle);
IsSelectable(&selectStyle);
if (selectStyle == StyleUserSelect::All)
return CONTINUE_UNSELECTABLE;