Bug 1447890 part 5. Remove nsISelection::RemoveAllRanges. r=mystor
MozReview-Commit-ID: EeMje9KW6An
This commit is contained in:
@@ -273,7 +273,7 @@ nsCoreUtils::ScrollSubstringTo(nsIFrame* aFrame, nsRange* aRange,
|
|||||||
selCon->GetDOMSelection(nsISelectionController::SELECTION_ACCESSIBILITY);
|
selCon->GetDOMSelection(nsISelectionController::SELECTION_ACCESSIBILITY);
|
||||||
|
|
||||||
nsCOMPtr<nsISelectionPrivate> privSel(do_QueryObject(selection));
|
nsCOMPtr<nsISelectionPrivate> privSel(do_QueryObject(selection));
|
||||||
selection->RemoveAllRanges();
|
selection->RemoveAllRanges(IgnoreErrors());
|
||||||
selection->AddRange(*aRange, IgnoreErrors());
|
selection->AddRange(*aRange, IgnoreErrors());
|
||||||
|
|
||||||
privSel->ScrollIntoViewInternal(
|
privSel->ScrollIntoViewInternal(
|
||||||
|
|||||||
@@ -778,7 +778,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Selection)
|
|||||||
// in JS!).
|
// in JS!).
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSelectionListeners)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSelectionListeners)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCachedRange)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCachedRange)
|
||||||
tmp->RemoveAllRanges();
|
tmp->RemoveAllRanges(IgnoreErrors());
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFrameSelection)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFrameSelection)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||||
@@ -2225,16 +2225,6 @@ Selection::DoAutoScroll(nsIFrame* aFrame, nsPoint aPoint)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** RemoveAllRanges zeroes the selection
|
|
||||||
*/
|
|
||||||
NS_IMETHODIMP
|
|
||||||
Selection::RemoveAllRanges()
|
|
||||||
{
|
|
||||||
ErrorResult result;
|
|
||||||
RemoveAllRanges(result);
|
|
||||||
return result.StealNSResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Selection::RemoveAllRanges(ErrorResult& aRv)
|
Selection::RemoveAllRanges(ErrorResult& aRv)
|
||||||
{
|
{
|
||||||
@@ -4025,7 +4015,6 @@ Selection::SetBaseAndExtent(nsINode& aAnchorNode, uint32_t aAnchorOffset,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use non-virtual method instead of nsISelection::RemoveAllRanges().
|
|
||||||
RemoveAllRanges(aRv);
|
RemoveAllRanges(aRv);
|
||||||
if (aRv.Failed()) {
|
if (aRv.Failed()) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -2439,7 +2439,7 @@ nsFocusManager::MoveCaretToFocus(nsIPresShell* aPresShell, nsIContent* aContent)
|
|||||||
if (domSelection) {
|
if (domSelection) {
|
||||||
// First clear the selection. This way, if there is no currently focused
|
// First clear the selection. This way, if there is no currently focused
|
||||||
// content, the selection will just be cleared.
|
// content, the selection will just be cleared.
|
||||||
domSelection->RemoveAllRanges();
|
domSelection->RemoveAllRanges(IgnoreErrors());
|
||||||
if (aContent) {
|
if (aContent) {
|
||||||
ErrorResult rv;
|
ErrorResult rv;
|
||||||
RefPtr<nsRange> newRange = doc->CreateRange(rv);
|
RefPtr<nsRange> newRange = doc->CreateRange(rv);
|
||||||
|
|||||||
@@ -102,11 +102,6 @@ interface nsISelection : nsISupports
|
|||||||
*/
|
*/
|
||||||
void selectAllChildren(in nsIDOMNode parentNode);
|
void selectAllChildren(in nsIDOMNode parentNode);
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes all ranges from the current selection.
|
|
||||||
*/
|
|
||||||
void removeAllRanges();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes this selection from document the nodes belong to.
|
* Deletes this selection from document the nodes belong to.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -103,6 +103,7 @@
|
|||||||
#include "nsIImageDocument.h"
|
#include "nsIImageDocument.h"
|
||||||
#include "mozilla/dom/HTMLBodyElement.h"
|
#include "mozilla/dom/HTMLBodyElement.h"
|
||||||
#include "mozilla/dom/HTMLDocumentBinding.h"
|
#include "mozilla/dom/HTMLDocumentBinding.h"
|
||||||
|
#include "mozilla/dom/Selection.h"
|
||||||
#include "nsCharsetSource.h"
|
#include "nsCharsetSource.h"
|
||||||
#include "nsIStringBundle.h"
|
#include "nsIStringBundle.h"
|
||||||
#include "nsDOMClassInfo.h"
|
#include "nsDOMClassInfo.h"
|
||||||
@@ -2548,12 +2549,11 @@ nsHTMLDocument::EditingStateChanged()
|
|||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsISelection> spellCheckSelection;
|
RefPtr<Selection> spellCheckSelection =
|
||||||
rv = selectionController->GetSelection(
|
selectionController->GetDOMSelection(
|
||||||
nsISelectionController::SELECTION_SPELLCHECK,
|
nsISelectionController::SELECTION_SPELLCHECK);
|
||||||
getter_AddRefs(spellCheckSelection));
|
if (spellCheckSelection) {
|
||||||
if (NS_SUCCEEDED(rv)) {
|
spellCheckSelection->RemoveAllRanges(IgnoreErrors());
|
||||||
spellCheckSelection->RemoveAllRanges();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
htmlEditor->SyncRealTimeSpell();
|
htmlEditor->SyncRealTimeSpell();
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ interface Selection {
|
|||||||
*/
|
*/
|
||||||
[Throws]
|
[Throws]
|
||||||
void removeRange(Range range);
|
void removeRange(Range range);
|
||||||
|
/**
|
||||||
|
* Removes all ranges from the current selection.
|
||||||
|
*/
|
||||||
[Throws]
|
[Throws]
|
||||||
void removeAllRanges();
|
void removeAllRanges();
|
||||||
[Throws, BinaryName="RemoveAllRanges"]
|
[Throws, BinaryName="RemoveAllRanges"]
|
||||||
|
|||||||
@@ -245,14 +245,11 @@ CompositionTransaction::SetIMESelection(EditorBase& aEditorBase,
|
|||||||
|
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
for (uint32_t i = 0; i < ArrayLength(kIMESelections); ++i) {
|
for (uint32_t i = 0; i < ArrayLength(kIMESelections); ++i) {
|
||||||
nsCOMPtr<nsISelection> selectionOfIME;
|
RefPtr<Selection> selectionOfIME = selCon->GetDOMSelection(kIMESelections[i]);
|
||||||
if (NS_FAILED(selCon->GetSelection(kIMESelections[i],
|
if (!selectionOfIME) {
|
||||||
getter_AddRefs(selectionOfIME)))) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
rv = selectionOfIME->RemoveAllRanges();
|
selectionOfIME->RemoveAllRanges(IgnoreErrors());
|
||||||
NS_ASSERTION(NS_SUCCEEDED(rv),
|
|
||||||
"Failed to remove all ranges of IME selection");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set caret position and selection of IME composition with TextRangeArray.
|
// Set caret position and selection of IME composition with TextRangeArray.
|
||||||
|
|||||||
@@ -3444,8 +3444,11 @@ EditorBase::JoinNodesImpl(nsINode* aNodeToKeep,
|
|||||||
|
|
||||||
// If we have not seen the selection yet, clear all of its ranges.
|
// If we have not seen the selection yet, clear all of its ranges.
|
||||||
if (range.mSelection != previousSelection) {
|
if (range.mSelection != previousSelection) {
|
||||||
nsresult rv = range.mSelection->RemoveAllRanges();
|
ErrorResult rv;
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
range.mSelection->RemoveAllRanges(rv);
|
||||||
|
if (NS_WARN_IF(rv.Failed())) {
|
||||||
|
return rv.StealNSResult();
|
||||||
|
}
|
||||||
previousSelection = range.mSelection;
|
previousSelection = range.mSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4897,7 +4900,9 @@ EditorBase::ClearSelection()
|
|||||||
{
|
{
|
||||||
RefPtr<Selection> selection = GetSelection();
|
RefPtr<Selection> selection = GetSelection();
|
||||||
NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
|
||||||
return selection->RemoveAllRanges();
|
ErrorResult rv;
|
||||||
|
selection->RemoveAllRanges(rv);
|
||||||
|
return rv.StealNSResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<Element>
|
already_AddRefed<Element>
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ SelectionState::RestoreSelection(Selection* aSel)
|
|||||||
NS_ENSURE_TRUE(aSel, NS_ERROR_NULL_POINTER);
|
NS_ENSURE_TRUE(aSel, NS_ERROR_NULL_POINTER);
|
||||||
|
|
||||||
// clear out selection
|
// clear out selection
|
||||||
aSel->RemoveAllRanges();
|
aSel->RemoveAllRanges(IgnoreErrors());
|
||||||
|
|
||||||
// set the selection ranges anew
|
// set the selection ranges anew
|
||||||
size_t arrayCount = mArray.Length();
|
size_t arrayCount = mArray.Length();
|
||||||
|
|||||||
@@ -614,7 +614,7 @@ nsresult mozInlineSpellChecker::Cleanup(bool aDestroyingFrames)
|
|||||||
rv = NS_ERROR_FAILURE;
|
rv = NS_ERROR_FAILURE;
|
||||||
} else {
|
} else {
|
||||||
if (!aDestroyingFrames) {
|
if (!aDestroyingFrames) {
|
||||||
spellCheckSelection->RemoveAllRanges();
|
spellCheckSelection->RemoveAllRanges(IgnoreErrors());
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = UnregisterEventListeners();
|
rv = UnregisterEventListeners();
|
||||||
@@ -964,7 +964,7 @@ mozInlineSpellChecker::ReplaceWord(nsIDOMNode *aNode, int32_t aOffset,
|
|||||||
|
|
||||||
RefPtr<Selection> selection = mTextEditor->GetSelection();
|
RefPtr<Selection> selection = mTextEditor->GetSelection();
|
||||||
NS_ENSURE_TRUE(selection, NS_ERROR_UNEXPECTED);
|
NS_ENSURE_TRUE(selection, NS_ERROR_UNEXPECTED);
|
||||||
selection->RemoveAllRanges();
|
selection->RemoveAllRanges(IgnoreErrors());
|
||||||
selection->AddRange(*editorRange, IgnoreErrors());
|
selection->AddRange(*editorRange, IgnoreErrors());
|
||||||
|
|
||||||
MOZ_ASSERT(mTextEditor);
|
MOZ_ASSERT(mTextEditor);
|
||||||
@@ -1307,7 +1307,7 @@ mozInlineSpellChecker::DoSpellCheckSelection(mozInlineSpellWordUtil& aWordUtil,
|
|||||||
// provides better performance. By ensuring that no ranges need to be
|
// provides better performance. By ensuring that no ranges need to be
|
||||||
// removed in DoSpellCheck, we can save checking range inclusion which is
|
// removed in DoSpellCheck, we can save checking range inclusion which is
|
||||||
// slow.
|
// slow.
|
||||||
aSpellCheckSelection->RemoveAllRanges();
|
aSpellCheckSelection->RemoveAllRanges(IgnoreErrors());
|
||||||
|
|
||||||
// We use this state object for all calls, and just update its range. Note
|
// We use this state object for all calls, and just update its range. Note
|
||||||
// that we don't need to call FinishInit since we will be filling in the
|
// that we don't need to call FinishInit since we will be filling in the
|
||||||
|
|||||||
@@ -3187,7 +3187,7 @@ PresShell::GoToAnchor(const nsAString& aAnchorName, bool aScroll,
|
|||||||
// Select the anchor
|
// Select the anchor
|
||||||
RefPtr<Selection> sel = mSelection->GetSelection(SelectionType::eNormal);
|
RefPtr<Selection> sel = mSelection->GetSelection(SelectionType::eNormal);
|
||||||
if (sel) {
|
if (sel) {
|
||||||
sel->RemoveAllRanges();
|
sel->RemoveAllRanges(IgnoreErrors());
|
||||||
sel->AddRange(*jumpToRange, IgnoreErrors());
|
sel->AddRange(*jumpToRange, IgnoreErrors());
|
||||||
if (!selectAnchor) {
|
if (!selectAnchor) {
|
||||||
// Use a caret (collapsed selection) at the start of the anchor
|
// Use a caret (collapsed selection) at the start of the anchor
|
||||||
|
|||||||
@@ -2732,11 +2732,13 @@ NS_IMETHODIMP nsDocumentViewer::SelectAll()
|
|||||||
}
|
}
|
||||||
if (!bodyNode) return NS_ERROR_FAILURE;
|
if (!bodyNode) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
nsresult rv = selection->RemoveAllRanges();
|
ErrorResult err;
|
||||||
if (NS_FAILED(rv)) return rv;
|
selection->RemoveAllRanges(err);
|
||||||
|
if (err.Failed()) {
|
||||||
|
return err.StealNSResult();
|
||||||
|
}
|
||||||
|
|
||||||
mozilla::dom::Selection::AutoUserInitiated userSelection(selection);
|
mozilla::dom::Selection::AutoUserInitiated userSelection(selection);
|
||||||
ErrorResult err;
|
|
||||||
selection->SelectAllChildren(*bodyNode, err);
|
selection->SelectAllChildren(*bodyNode, err);
|
||||||
return err.StealNSResult();
|
return err.StealNSResult();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -797,15 +797,15 @@ void nsTextControlFrame::SetFocus(bool aOn, bool aRepaint)
|
|||||||
// document since the focus is now on our independent selection.
|
// document since the focus is now on our independent selection.
|
||||||
|
|
||||||
nsCOMPtr<nsISelectionController> selcon = do_QueryInterface(presShell);
|
nsCOMPtr<nsISelectionController> selcon = do_QueryInterface(presShell);
|
||||||
nsCOMPtr<nsISelection> docSel;
|
RefPtr<Selection> docSel =
|
||||||
selcon->GetSelection(nsISelectionController::SELECTION_NORMAL,
|
selcon->GetDOMSelection(nsISelectionController::SELECTION_NORMAL);
|
||||||
getter_AddRefs(docSel));
|
if (!docSel) {
|
||||||
if (!docSel) return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
bool isCollapsed = false;
|
if (!docSel->IsCollapsed()) {
|
||||||
docSel->GetIsCollapsed(&isCollapsed);
|
docSel->RemoveAllRanges(IgnoreErrors());
|
||||||
if (!isCollapsed)
|
}
|
||||||
docSel->RemoveAllRanges();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsTextControlFrame::SetFormProperty(nsAtom* aName, const nsAString& aValue)
|
nsresult nsTextControlFrame::SetFormProperty(nsAtom* aName, const nsAString& aValue)
|
||||||
@@ -891,10 +891,12 @@ nsTextControlFrame::SetSelectionInternal(nsINode* aStartNode,
|
|||||||
direction = (aDirection == eBackward) ? eDirPrevious : eDirNext;
|
direction = (aDirection == eBackward) ? eDirPrevious : eDirNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = selection->RemoveAllRanges();
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
ErrorResult err;
|
ErrorResult err;
|
||||||
|
selection->RemoveAllRanges(err);
|
||||||
|
if (NS_WARN_IF(err.Failed())) {
|
||||||
|
return err.StealNSResult();
|
||||||
|
}
|
||||||
|
|
||||||
selection->AddRange(*range, err); // NOTE: can destroy the world
|
selection->AddRange(*range, err); // NOTE: can destroy the world
|
||||||
if (NS_WARN_IF(err.Failed())) {
|
if (NS_WARN_IF(err.Failed())) {
|
||||||
return err.StealNSResult();
|
return err.StealNSResult();
|
||||||
|
|||||||
@@ -2043,7 +2043,9 @@ nsFrameSelection::ClearNormalSelection()
|
|||||||
if (!mDomSelections[index])
|
if (!mDomSelections[index])
|
||||||
return NS_ERROR_NULL_POINTER;
|
return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
return mDomSelections[index]->RemoveAllRanges();
|
ErrorResult err;
|
||||||
|
mDomSelections[index]->RemoveAllRanges(err);
|
||||||
|
return err.StealNSResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
static nsIContent*
|
static nsIContent*
|
||||||
@@ -2160,7 +2162,7 @@ printf("HandleTableSelection: Dragged into a new cell\n");
|
|||||||
{
|
{
|
||||||
// Force new selection block
|
// Force new selection block
|
||||||
mStartSelectedCell = nullptr;
|
mStartSelectedCell = nullptr;
|
||||||
mDomSelections[index]->RemoveAllRanges();
|
mDomSelections[index]->RemoveAllRanges(IgnoreErrors());
|
||||||
|
|
||||||
if (startRowIndex == curRowIndex)
|
if (startRowIndex == curRowIndex)
|
||||||
mSelectingTableCellMode = nsISelectionPrivate::TABLESELECTION_ROW;
|
mSelectingTableCellMode = nsISelectionPrivate::TABLESELECTION_ROW;
|
||||||
@@ -2208,7 +2210,7 @@ printf("HandleTableSelection: Mouse down event\n");
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// No cells selected -- remove non-cell selection
|
// No cells selected -- remove non-cell selection
|
||||||
mDomSelections[index]->RemoveAllRanges();
|
mDomSelections[index]->RemoveAllRanges(IgnoreErrors());
|
||||||
}
|
}
|
||||||
mDragSelectingCells = true; // Signal to start drag-cell-selection
|
mDragSelectingCells = true; // Signal to start drag-cell-selection
|
||||||
mSelectingTableCellMode = aTarget;
|
mSelectingTableCellMode = aTarget;
|
||||||
@@ -2232,7 +2234,7 @@ printf("HandleTableSelection: Saving mUnselectCellOnMouseUp\n");
|
|||||||
if (previousCellNode &&
|
if (previousCellNode &&
|
||||||
!IsInSameTable(previousCellNode, childContent))
|
!IsInSameTable(previousCellNode, childContent))
|
||||||
{
|
{
|
||||||
mDomSelections[index]->RemoveAllRanges();
|
mDomSelections[index]->RemoveAllRanges(IgnoreErrors());
|
||||||
// Reset selection mode that is cleared in RemoveAllRanges
|
// Reset selection mode that is cleared in RemoveAllRanges
|
||||||
mSelectingTableCellMode = aTarget;
|
mSelectingTableCellMode = aTarget;
|
||||||
}
|
}
|
||||||
@@ -2252,7 +2254,7 @@ printf("HandleTableSelection: Saving mUnselectCellOnMouseUp\n");
|
|||||||
mEndSelectedCell = nullptr;
|
mEndSelectedCell = nullptr;
|
||||||
|
|
||||||
// Remove existing selection and select the table
|
// Remove existing selection and select the table
|
||||||
mDomSelections[index]->RemoveAllRanges();
|
mDomSelections[index]->RemoveAllRanges(IgnoreErrors());
|
||||||
return CreateAndAddRange(aParentContent, aContentOffset);
|
return CreateAndAddRange(aParentContent, aContentOffset);
|
||||||
}
|
}
|
||||||
else if (aTarget == nsISelectionPrivate::TABLESELECTION_ROW || aTarget == nsISelectionPrivate::TABLESELECTION_COLUMN)
|
else if (aTarget == nsISelectionPrivate::TABLESELECTION_ROW || aTarget == nsISelectionPrivate::TABLESELECTION_COLUMN)
|
||||||
@@ -2268,7 +2270,7 @@ printf("aTarget == %d\n", aTarget);
|
|||||||
|
|
||||||
// Force new selection block
|
// Force new selection block
|
||||||
mStartSelectedCell = nullptr;
|
mStartSelectedCell = nullptr;
|
||||||
mDomSelections[index]->RemoveAllRanges();
|
mDomSelections[index]->RemoveAllRanges(IgnoreErrors());
|
||||||
// Always do this AFTER RemoveAllRanges
|
// Always do this AFTER RemoveAllRanges
|
||||||
mSelectingTableCellMode = aTarget;
|
mSelectingTableCellMode = aTarget;
|
||||||
return SelectRowOrColumn(childContent, aTarget);
|
return SelectRowOrColumn(childContent, aTarget);
|
||||||
|
|||||||
@@ -2165,7 +2165,7 @@ nsPrintJob::UpdateSelectionAndShrinkPrintObject(nsPrintObject* aPO,
|
|||||||
// Reset all existing selection ranges that might have been added by calling
|
// Reset all existing selection ranges that might have been added by calling
|
||||||
// this function before.
|
// this function before.
|
||||||
if (selectionPS) {
|
if (selectionPS) {
|
||||||
selectionPS->RemoveAllRanges();
|
selectionPS->RemoveAllRanges(IgnoreErrors());
|
||||||
}
|
}
|
||||||
if (selection && selectionPS) {
|
if (selection && selectionPS) {
|
||||||
int32_t cnt = selection->RangeCount();
|
int32_t cnt = selection->RangeCount();
|
||||||
|
|||||||
@@ -393,7 +393,7 @@ nsWebBrowserFind::SetSelectionAndScroll(nsPIDOMWindowOuter* aWindow,
|
|||||||
RefPtr<Selection> selection =
|
RefPtr<Selection> selection =
|
||||||
selCon->GetDOMSelection(nsISelectionController::SELECTION_NORMAL);
|
selCon->GetDOMSelection(nsISelectionController::SELECTION_NORMAL);
|
||||||
if (selection) {
|
if (selection) {
|
||||||
selection->RemoveAllRanges();
|
selection->RemoveAllRanges(IgnoreErrors());
|
||||||
selection->AddRange(*aRange, IgnoreErrors());
|
selection->AddRange(*aRange, IgnoreErrors());
|
||||||
|
|
||||||
nsCOMPtr<nsIFocusManager> fm = do_GetService(FOCUSMANAGER_CONTRACTID);
|
nsCOMPtr<nsIFocusManager> fm = do_GetService(FOCUSMANAGER_CONTRACTID);
|
||||||
@@ -718,7 +718,7 @@ nsWebBrowserFind::SearchInFrame(nsPIDOMWindowOuter* aWindow, bool aWrapping,
|
|||||||
// selection) models are up to date.
|
// selection) models are up to date.
|
||||||
theDoc->FlushPendingNotifications(FlushType::Frames);
|
theDoc->FlushPendingNotifications(FlushType::Frames);
|
||||||
|
|
||||||
nsCOMPtr<nsISelection> sel = GetFrameSelection(aWindow);
|
RefPtr<Selection> sel = GetFrameSelection(aWindow);
|
||||||
NS_ENSURE_ARG_POINTER(sel);
|
NS_ENSURE_ARG_POINTER(sel);
|
||||||
|
|
||||||
RefPtr<nsRange> searchRange = new nsRange(theDoc);
|
RefPtr<nsRange> searchRange = new nsRange(theDoc);
|
||||||
@@ -747,7 +747,7 @@ nsWebBrowserFind::SearchInFrame(nsPIDOMWindowOuter* aWindow, bool aWrapping,
|
|||||||
|
|
||||||
if (NS_SUCCEEDED(rv) && foundRange) {
|
if (NS_SUCCEEDED(rv) && foundRange) {
|
||||||
*aDidFind = true;
|
*aDidFind = true;
|
||||||
sel->RemoveAllRanges();
|
sel->RemoveAllRanges(IgnoreErrors());
|
||||||
// Beware! This may flush notifications via synchronous
|
// Beware! This may flush notifications via synchronous
|
||||||
// ScrollSelectionIntoView.
|
// ScrollSelectionIntoView.
|
||||||
SetSelectionAndScroll(aWindow, static_cast<nsRange*>(foundRange.get()));
|
SetSelectionAndScroll(aWindow, static_cast<nsRange*>(foundRange.get()));
|
||||||
@@ -773,7 +773,7 @@ nsWebBrowserFind::OnEndSearchFrame(nsPIDOMWindowOuter* aWindow)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<nsISelection>
|
already_AddRefed<Selection>
|
||||||
nsWebBrowserFind::GetFrameSelection(nsPIDOMWindowOuter* aWindow)
|
nsWebBrowserFind::GetFrameSelection(nsPIDOMWindowOuter* aWindow)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDocument> doc = aWindow->GetDoc();
|
nsCOMPtr<nsIDocument> doc = aWindow->GetDoc();
|
||||||
@@ -818,9 +818,9 @@ nsresult
|
|||||||
nsWebBrowserFind::ClearFrameSelection(nsPIDOMWindowOuter* aWindow)
|
nsWebBrowserFind::ClearFrameSelection(nsPIDOMWindowOuter* aWindow)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(aWindow);
|
NS_ENSURE_ARG(aWindow);
|
||||||
nsCOMPtr<nsISelection> selection = GetFrameSelection(aWindow);
|
RefPtr<Selection> selection = GetFrameSelection(aWindow);
|
||||||
if (selection) {
|
if (selection) {
|
||||||
selection->RemoveAllRanges();
|
selection->RemoveAllRanges(IgnoreErrors());
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|||||||
@@ -27,6 +27,12 @@ class nsIDOMWindow;
|
|||||||
class nsIDocShell;
|
class nsIDocShell;
|
||||||
class nsRange;
|
class nsRange;
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
namespace dom {
|
||||||
|
class Selection;
|
||||||
|
} // namespace dom
|
||||||
|
} // namespace mozilla
|
||||||
|
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
// class nsWebBrowserFind
|
// class nsWebBrowserFind
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
@@ -58,7 +64,8 @@ protected:
|
|||||||
nsresult OnStartSearchFrame(nsPIDOMWindowOuter* aWindow);
|
nsresult OnStartSearchFrame(nsPIDOMWindowOuter* aWindow);
|
||||||
nsresult OnEndSearchFrame(nsPIDOMWindowOuter* aWindow);
|
nsresult OnEndSearchFrame(nsPIDOMWindowOuter* aWindow);
|
||||||
|
|
||||||
already_AddRefed<nsISelection> GetFrameSelection(nsPIDOMWindowOuter* aWindow);
|
already_AddRefed<mozilla::dom::Selection>
|
||||||
|
GetFrameSelection(nsPIDOMWindowOuter* aWindow);
|
||||||
nsresult ClearFrameSelection(nsPIDOMWindowOuter* aWindow);
|
nsresult ClearFrameSelection(nsPIDOMWindowOuter* aWindow);
|
||||||
|
|
||||||
nsresult OnFind(nsPIDOMWindowOuter* aFoundWindow);
|
nsresult OnFind(nsPIDOMWindowOuter* aFoundWindow);
|
||||||
|
|||||||
@@ -630,7 +630,7 @@ nsTypeAheadFind::FindItNow(nsIPresShell *aPresShell, bool aIsLinksOnly,
|
|||||||
|
|
||||||
// Select the found text
|
// Select the found text
|
||||||
if (selection) {
|
if (selection) {
|
||||||
selection->RemoveAllRanges();
|
selection->RemoveAllRanges(IgnoreErrors());
|
||||||
selection->AddRange(*returnRange, IgnoreErrors());
|
selection->AddRange(*returnRange, IgnoreErrors());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user