mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 06:45:42 +00:00
Bug 1092888 - Part 2: Check pointer of FrameSelection and Selection is valid. r=roc
This commit is contained in:
parent
f2a5cc0c0b
commit
bc58167c82
@ -451,6 +451,11 @@ SelectionCarets::UpdateSelectionCarets()
|
||||
|
||||
// Check start and end frame is rtl or ltr text
|
||||
nsRefPtr<nsFrameSelection> fs = GetFrameSelection();
|
||||
if (!fs) {
|
||||
SetVisibility(false);
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t startOffset;
|
||||
nsIFrame* startFrame = FindFirstNodeWithFrame(mPresShell->GetDocument(),
|
||||
firstRange, fs, false, startOffset);
|
||||
@ -587,7 +592,9 @@ SelectionCarets::SelectWord()
|
||||
|
||||
// Clear maintain selection otherwise we cannot select less than a word
|
||||
nsRefPtr<nsFrameSelection> fs = GetFrameSelection();
|
||||
fs->MaintainSelection();
|
||||
if (fs) {
|
||||
fs->MaintainSelection();
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
||||
@ -677,6 +684,9 @@ SelectionCarets::DragSelection(const nsPoint &movePoint)
|
||||
}
|
||||
|
||||
nsRefPtr<nsFrameSelection> fs = GetFrameSelection();
|
||||
if (!fs) {
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
|
||||
nsresult result;
|
||||
nsIFrame *newFrame = nullptr;
|
||||
@ -701,6 +711,10 @@ SelectionCarets::DragSelection(const nsPoint &movePoint)
|
||||
}
|
||||
|
||||
nsRefPtr<dom::Selection> selection = GetSelection();
|
||||
if (!selection) {
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
|
||||
int32_t rangeCount = selection->GetRangeCount();
|
||||
if (rangeCount <= 0) {
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
@ -751,12 +765,19 @@ SelectionCarets::GetCaretYCenterPosition()
|
||||
}
|
||||
|
||||
nsRefPtr<dom::Selection> selection = GetSelection();
|
||||
if (!selection) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t rangeCount = selection->GetRangeCount();
|
||||
if (rangeCount <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
nsRefPtr<nsFrameSelection> fs = GetFrameSelection();
|
||||
if (!fs) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mDragMode != NONE);
|
||||
nsCOMPtr<nsIContent> node;
|
||||
@ -789,14 +810,18 @@ void
|
||||
SelectionCarets::SetSelectionDragState(bool aState)
|
||||
{
|
||||
nsRefPtr<nsFrameSelection> fs = GetFrameSelection();
|
||||
fs->SetDragState(aState);
|
||||
if (fs) {
|
||||
fs->SetDragState(aState);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SelectionCarets::SetSelectionDirection(bool aForward)
|
||||
{
|
||||
nsRefPtr<dom::Selection> selection = GetSelection();
|
||||
selection->SetDirection(aForward ? eDirNext : eDirPrevious);
|
||||
if (selection) {
|
||||
selection->SetDirection(aForward ? eDirNext : eDirPrevious);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user