зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1447889 part 8. Remove nsIDOMRange::SelectNode/SelectNodeContents. r=mystor
MozReview-Commit-ID: 2hbF6pT31Xd
This commit is contained in:
Родитель
6a7475413e
Коммит
3906df8d57
|
@ -335,15 +335,16 @@ nsCopySupport::GetTransferableForNode(nsINode* aNode,
|
|||
// XXX We should try to get rid of the Selection object here.
|
||||
// XXX bug 1245883
|
||||
nsCOMPtr<nsISelection> selection = new Selection();
|
||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aNode);
|
||||
NS_ENSURE_TRUE(node, NS_ERROR_FAILURE);
|
||||
RefPtr<nsRange> range = new nsRange(aNode);
|
||||
nsresult rv = range->SelectNode(node);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
ErrorResult result;
|
||||
range->SelectNode(*aNode, result);
|
||||
if (NS_WARN_IF(result.Failed())) {
|
||||
return result.StealNSResult();
|
||||
}
|
||||
selection->AsSelection()->AddRangeInternal(*range, aDoc, result);
|
||||
rv = result.StealNSResult();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(result.Failed())) {
|
||||
return result.StealNSResult();
|
||||
}
|
||||
// It's not the primary selection - so don't skip invisible content.
|
||||
uint32_t flags = 0;
|
||||
return SelectionCopyHelper(selection, aDoc, false, 0, flags,
|
||||
|
|
|
@ -1657,17 +1657,6 @@ nsRange::CollapseJS(bool aToStart)
|
|||
Collapse(aToStart);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRange::SelectNode(nsIDOMNode* aN)
|
||||
{
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aN);
|
||||
NS_ENSURE_TRUE(node, NS_ERROR_DOM_INVALID_NODE_TYPE_ERR);
|
||||
|
||||
ErrorResult rv;
|
||||
SelectNode(*node, rv);
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
void
|
||||
nsRange::SelectNodeJS(nsINode& aNode, ErrorResult& aErr)
|
||||
{
|
||||
|
@ -1709,17 +1698,6 @@ nsRange::SelectNode(nsINode& aNode, ErrorResult& aRv)
|
|||
RawRangeBoundary(container, index + 1), newRoot);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRange::SelectNodeContents(nsIDOMNode* aN)
|
||||
{
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aN);
|
||||
NS_ENSURE_TRUE(node, NS_ERROR_DOM_INVALID_NODE_TYPE_ERR);
|
||||
|
||||
ErrorResult rv;
|
||||
SelectNodeContents(*node, rv);
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
void
|
||||
nsRange::SelectNodeContentsJS(nsINode& aNode, ErrorResult& aErr)
|
||||
{
|
||||
|
|
|
@ -2197,8 +2197,7 @@ nsHTMLDocument::DeferredContentEditableCountChange(nsIContent *aElement)
|
|||
if (oldState == mEditingState && mEditingState == eContentEditable) {
|
||||
// We just changed the contentEditable state of a node, we need to reset
|
||||
// the spellchecking state of that node.
|
||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aElement);
|
||||
if (node) {
|
||||
if (aElement) {
|
||||
nsPIDOMWindowOuter *window = GetWindow();
|
||||
if (!window)
|
||||
return;
|
||||
|
@ -2210,8 +2209,9 @@ nsHTMLDocument::DeferredContentEditableCountChange(nsIContent *aElement)
|
|||
RefPtr<HTMLEditor> htmlEditor = docshell->GetHTMLEditor();
|
||||
if (htmlEditor) {
|
||||
RefPtr<nsRange> range = new nsRange(aElement);
|
||||
rv = range->SelectNode(node);
|
||||
if (NS_FAILED(rv)) {
|
||||
IgnoredErrorResult res;
|
||||
range->SelectNode(*aElement, res);
|
||||
if (res.Failed()) {
|
||||
// The node might be detached from the document at this point,
|
||||
// which would cause this call to fail. In this case, we can
|
||||
// safely ignore the contenteditable count change.
|
||||
|
|
|
@ -21,8 +21,6 @@ interface nsIDOMRange : nsISupports
|
|||
void setStartAfter(in nsIDOMNode refNode);
|
||||
void setEndBefore(in nsIDOMNode refNode);
|
||||
void setEndAfter(in nsIDOMNode refNode);
|
||||
void selectNode(in nsIDOMNode refNode);
|
||||
void selectNodeContents(in nsIDOMNode refNode);
|
||||
|
||||
// CompareHow
|
||||
const unsigned short START_TO_START = 0;
|
||||
|
|
|
@ -67,10 +67,7 @@ nsFilteredContentIterator::Init(nsINode* aRoot)
|
|||
mCurrentIterator = mPreIterator;
|
||||
|
||||
mRange = new nsRange(aRoot);
|
||||
nsCOMPtr<nsIDOMNode> domNode(do_QueryInterface(aRoot));
|
||||
if (domNode) {
|
||||
mRange->SelectNode(domNode);
|
||||
}
|
||||
mRange->SelectNode(*aRoot, IgnoreErrors());
|
||||
|
||||
nsresult rv = mPreIterator->Init(mRange);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
|
@ -3180,13 +3180,11 @@ PresShell::GoToAnchor(const nsAString& aAnchorName, bool aScroll,
|
|||
// Even if select anchor pref is false, we must still move the
|
||||
// caret there. That way tabbing will start from the new
|
||||
// location
|
||||
RefPtr<nsIDOMRange> jumpToRange = new nsRange(mDocument);
|
||||
RefPtr<nsRange> jumpToRange = new nsRange(mDocument);
|
||||
while (content && content->GetFirstChild()) {
|
||||
content = content->GetFirstChild();
|
||||
}
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(content));
|
||||
NS_ASSERTION(node, "No nsIDOMNode for descendant of anchor");
|
||||
jumpToRange->SelectNodeContents(node);
|
||||
jumpToRange->SelectNodeContents(*content, IgnoreErrors());
|
||||
// Select the anchor
|
||||
RefPtr<Selection> sel = mSelection->GetSelection(SelectionType::eNormal);
|
||||
if (sel) {
|
||||
|
@ -5156,8 +5154,11 @@ PresShell::RenderNode(nsIDOMNode* aNode,
|
|||
return nullptr;
|
||||
|
||||
RefPtr<nsRange> range = new nsRange(node);
|
||||
if (NS_FAILED(range->SelectNode(aNode)))
|
||||
IgnoredErrorResult rv;
|
||||
range->SelectNode(*node, rv);
|
||||
if (rv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
UniquePtr<RangePaintInfo> info = CreateRangePaintInfo(range, area, false);
|
||||
if (info && !rangeItems.AppendElement(Move(info))) {
|
||||
|
|
|
@ -392,6 +392,11 @@ nsFindContentIterator::SetupInnerIterator(nsIContent* aContent)
|
|||
nsCOMPtr<nsIDOMElement> rootElement;
|
||||
textEditor->GetRootElement(getter_AddRefs(rootElement));
|
||||
|
||||
nsCOMPtr<nsINode> rootNode = do_QueryInterface(rootElement);
|
||||
if (!rootNode) {
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<nsRange> innerRange = CreateRange(aContent);
|
||||
RefPtr<nsRange> outerRange = CreateRange(aContent);
|
||||
if (!innerRange || !outerRange) {
|
||||
|
@ -402,7 +407,7 @@ nsFindContentIterator::SetupInnerIterator(nsIContent* aContent)
|
|||
mInnerIterator = do_CreateInstance(kCPreContentIteratorCID);
|
||||
|
||||
if (mInnerIterator) {
|
||||
innerRange->SelectNodeContents(rootElement);
|
||||
innerRange->SelectNodeContents(*rootNode, IgnoreErrors());
|
||||
|
||||
// fix up the inner bounds, we may have to only lookup a portion
|
||||
// of the text control if the current node is a boundary point
|
||||
|
|
Загрузка…
Ссылка в новой задаче