--- a/dom/base/Selection.cpp
+++ b/dom/base/Selection.cpp
@@ -2452,60 +2452,61 @@ Selection::RemoveRange(nsRange& aRange,
}
/*
* Collapse sets the whole selection to be one point.
*/
NS_IMETHODIMP
-Selection::Collapse(nsIDOMNode* aParentNode, int32_t aOffset)
+Selection::Collapse(nsIDOMNode* aContainer, int32_t aOffset)
{
- nsCOMPtr<nsINode> parentNode = do_QueryInterface(aParentNode);
+ nsCOMPtr<nsINode> parentNode = do_QueryInterface(aContainer);
return Collapse(parentNode, aOffset);
}
NS_IMETHODIMP
-Selection::CollapseNative(nsINode* aParentNode, int32_t aOffset)
+Selection::CollapseNative(nsINode* aContainer, int32_t aOffset)
{
- return Collapse(aParentNode, aOffset);
+ return Collapse(aContainer, aOffset);
}
void
-Selection::CollapseJS(nsINode* aNode, uint32_t aOffset, ErrorResult& aRv)
+Selection::CollapseJS(nsINode* aContainer, uint32_t aOffset, ErrorResult& aRv)
{
AutoRestore<bool> calledFromJSRestorer(mCalledByJS);
mCalledByJS = true;
- if (!aNode) {
+ if (!aContainer) {
RemoveAllRanges(aRv);
return;
}
- Collapse(*aNode, aOffset, aRv);
+ Collapse(*aContainer, aOffset, aRv);
}
nsresult
-Selection::Collapse(nsINode* aParentNode, int32_t aOffset)
+Selection::Collapse(nsINode* aContainer, int32_t aOffset)
{
- if (!aParentNode)
+ if (!aContainer) {
return NS_ERROR_INVALID_ARG;
+ }
ErrorResult result;
- Collapse(*aParentNode, static_cast<uint32_t>(aOffset), result);
+ Collapse(*aContainer, static_cast<uint32_t>(aOffset), result);
return result.StealNSResult();
}
void
-Selection::Collapse(nsINode& aParentNode, uint32_t aOffset, ErrorResult& aRv)
+Selection::Collapse(nsINode& aContainer, uint32_t aOffset, ErrorResult& aRv)
{
if (!mFrameSelection) {
aRv.Throw(NS_ERROR_NOT_INITIALIZED); // Can't do selection
return;
}
- nsCOMPtr<nsINode> parentNode = &aParentNode;
+ nsCOMPtr<nsINode> parentNode = &aContainer;
RefPtr<nsFrameSelection> frameSelection = mFrameSelection;
frameSelection->InvalidateDesiredPos();
if (!IsValidSelectionPoint(frameSelection, parentNode)) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
nsresult result;
@@ -2836,69 +2837,70 @@ 2 1 a = continue selection from 2 to 1
*/
/*
* Extend extends the selection away from the anchor.
* We don't need to know the direction, because we always change the focus.
*/
NS_IMETHODIMP
-Selection::Extend(nsIDOMNode* aParentNode, int32_t aOffset)
+Selection::Extend(nsIDOMNode* aContainer, int32_t aOffset)
{
- nsCOMPtr<nsINode> parentNode = do_QueryInterface(aParentNode);
+ nsCOMPtr<nsINode> parentNode = do_QueryInterface(aContainer);
return Extend(parentNode, aOffset);
}
NS_IMETHODIMP
-Selection::ExtendNative(nsINode* aParentNode, int32_t aOffset)
+Selection::ExtendNative(nsINode* aContainer, int32_t aOffset)
{
- return Extend(aParentNode, aOffset);
+ return Extend(aContainer, aOffset);
}
void
-Selection::ExtendJS(nsINode& aNode, uint32_t aOffset, ErrorResult& aRv)
+Selection::ExtendJS(nsINode& aContainer, uint32_t aOffset, ErrorResult& aRv)
{
AutoRestore<bool> calledFromJSRestorer(mCalledByJS);
mCalledByJS = true;
- Extend(aNode, aOffset, aRv);
+ Extend(aContainer, aOffset, aRv);
}
nsresult
-Selection::Extend(nsINode* aParentNode, int32_t aOffset)
+Selection::Extend(nsINode* aContainer, int32_t aOffset)
{
- if (!aParentNode)
+ if (!aContainer) {
return NS_ERROR_INVALID_ARG;
+ }
ErrorResult result;
- Extend(*aParentNode, static_cast<uint32_t>(aOffset), result);
+ Extend(*aContainer, static_cast<uint32_t>(aOffset), result);
return result.StealNSResult();
}
void
-Selection::Extend(nsINode& aParentNode, uint32_t aOffset, ErrorResult& aRv)
+Selection::Extend(nsINode& aContainer, uint32_t aOffset, ErrorResult& aRv)
{
// First, find the range containing the old focus point:
if (!mAnchorFocusRange) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
if (!mFrameSelection) {
aRv.Throw(NS_ERROR_NOT_INITIALIZED); // Can't do selection
return;
}
nsresult res;
- if (!IsValidSelectionPoint(mFrameSelection, &aParentNode)) {
+ if (!IsValidSelectionPoint(mFrameSelection, &aContainer)) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
RefPtr<nsPresContext> presContext = GetPresContext();
- if (!presContext || presContext->Document() != aParentNode.OwnerDoc()) {
+ if (!presContext || presContext->Document() != aContainer.OwnerDoc()) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
#ifdef DEBUG_SELECTION
nsDirection oldDirection = GetDirection();
#endif
nsINode* anchorNode = GetAnchorNode();
@@ -2925,35 +2927,35 @@ Selection::Extend(nsINode& aParentNode,
bool disconnected = false;
bool shouldClearRange = false;
int32_t result1 = nsContentUtils::ComparePoints(anchorNode, anchorOffset,
focusNode, focusOffset,
&disconnected);
//compare old cursor to new cursor
shouldClearRange |= disconnected;
int32_t result2 = nsContentUtils::ComparePoints(focusNode, focusOffset,
- &aParentNode, aOffset,
+ &aContainer, aOffset,
&disconnected);
//compare anchor to new cursor
shouldClearRange |= disconnected;
int32_t result3 = nsContentUtils::ComparePoints(anchorNode, anchorOffset,
- &aParentNode, aOffset,
+ &aContainer, aOffset,
&disconnected);
// If the points are disconnected, the range will be collapsed below,
// resulting in a range that selects nothing.
if (shouldClearRange) {
// Repaint the current range with the selection removed.
SelectFrames(presContext, range, false);
}
- RefPtr<nsRange> difRange = new nsRange(&aParentNode);
+ RefPtr<nsRange> difRange = new nsRange(&aContainer);
if ((result1 == 0 && result3 < 0) || (result1 <= 0 && result2 < 0)){//a1,2 a,1,2
//select from 1 to 2 unless they are collapsed
- range->SetEnd(aParentNode, aOffset, aRv);
+ range->SetEnd(aContainer, aOffset, aRv);
if (aRv.Failed()) {
return;
}
SetDirection(eDirNext);
res = difRange->SetStartAndEnd(focusNode, focusOffset,
range->GetEndContainer(),
range->EndOffset());
if (NS_FAILED(res)) {
@@ -2965,37 +2967,37 @@ Selection::Extend(nsINode& aParentNode,
if (NS_FAILED(res)) {
aRv.Throw(res);
return;
}
}
else if (result1 == 0 && result3 > 0){//2, a1
//select from 2 to 1a
SetDirection(eDirPrevious);
- range->SetStart(aParentNode, aOffset, aRv);
+ range->SetStart(aContainer, aOffset, aRv);
if (aRv.Failed()) {
return;
}
SelectFrames(presContext, range, true);
res = SetAnchorFocusToRange(range);
if (NS_FAILED(res)) {
aRv.Throw(res);
return;
}
}
else if (result3 <= 0 && result2 >= 0) {//a,2,1 or a2,1 or a,21 or a21
//deselect from 2 to 1
- res = difRange->SetStartAndEnd(&aParentNode, aOffset,
+ res = difRange->SetStartAndEnd(&aContainer, aOffset,
focusNode, focusOffset);
if (NS_FAILED(res)) {
aRv.Throw(res);
return;
}
- range->SetEnd(aParentNode, aOffset, aRv);
+ range->SetEnd(aContainer, aOffset, aRv);
if (aRv.Failed()) {
return;
}
res = SetAnchorFocusToRange(range);
if (NS_FAILED(res)) {
aRv.Throw(res);
return;
}
@@ -3008,17 +3010,17 @@ Selection::Extend(nsINode& aParentNode,
if (GetDirection() == eDirPrevious){
res = range->SetStart(endNode, endOffset);
if (NS_FAILED(res)) {
aRv.Throw(res);
return;
}
}
SetDirection(eDirNext);
- range->SetEnd(aParentNode, aOffset, aRv);
+ range->SetEnd(aContainer, aOffset, aRv);
if (aRv.Failed()) {
return;
}
if (focusNode != anchorNode || focusOffset != anchorOffset) {//if collapsed diff dont do anything
res = difRange->SetStart(focusNode, focusOffset);
nsresult tmp = difRange->SetEnd(anchorNode, anchorOffset);
if (NS_FAILED(tmp)) {
res = tmp;
@@ -3044,23 +3046,23 @@ Selection::Extend(nsINode& aParentNode,
}
}
//select from a to 2
SelectFrames(presContext, range , true);
}
else if (result2 <= 0 && result3 >= 0) {//1,2,a or 12,a or 1,2a or 12a
//deselect from 1 to 2
res = difRange->SetStartAndEnd(focusNode, focusOffset,
- &aParentNode, aOffset);
+ &aContainer, aOffset);
if (NS_FAILED(res)) {
aRv.Throw(res);
return;
}
SetDirection(eDirPrevious);
- range->SetStart(aParentNode, aOffset, aRv);
+ range->SetStart(aContainer, aOffset, aRv);
if (aRv.Failed()) {
return;
}
res = SetAnchorFocusToRange(range);
if (NS_FAILED(res)) {
aRv.Throw(res);
return;
@@ -3069,17 +3071,17 @@ Selection::Extend(nsINode& aParentNode,
difRange->SetStart(range->GetStartContainer(), range->StartOffset());
SelectFrames(presContext, difRange, true); // must reselect last node
}
else if (result3 >= 0 && result1 <= 0) {//2,a,1 or 2a,1 or 2,a1 or 2a1
if (GetDirection() == eDirNext){
range->SetEnd(startNode, startOffset);
}
SetDirection(eDirPrevious);
- range->SetStart(aParentNode, aOffset, aRv);
+ range->SetStart(aContainer, aOffset, aRv);
if (aRv.Failed()) {
return;
}
//deselect from a to 1
if (focusNode != anchorNode || focusOffset!= anchorOffset) {//if collapsed diff dont do anything
res = difRange->SetStartAndEnd(anchorNode, anchorOffset,
focusNode, focusOffset);
nsresult tmp = SetAnchorFocusToRange(range);
@@ -3100,17 +3102,17 @@ Selection::Extend(nsINode& aParentNode,
return;
}
}
//select from 2 to a
SelectFrames(presContext, range , true);
}
else if (result2 >= 0 && result1 >= 0) {//2,1,a or 21,a or 2,1a or 21a
//select from 2 to 1
- range->SetStart(aParentNode, aOffset, aRv);
+ range->SetStart(aContainer, aOffset, aRv);
if (aRv.Failed()) {
return;
}
SetDirection(eDirPrevious);
res = difRange->SetStartAndEnd(
range->GetStartContainer(), range->StartOffset(),
focusNode, focusOffset);
if (NS_FAILED(res)) {
@@ -3135,35 +3137,35 @@ Selection::Extend(nsINode& aParentNode,
}
DEBUG_OUT_RANGE(range);
#ifdef DEBUG_SELECTION
if (GetDirection() != oldDirection) {
printf(" direction changed to %s\n",
GetDirection() == eDirNext? "eDirNext":"eDirPrevious");
}
- nsCOMPtr<nsIContent> content = do_QueryInterface(&aParentNode);
+ nsCOMPtr<nsIContent> content = do_QueryInterface(&aContainer);
printf ("Sel. Extend to %p %s %d\n", content.get(),
nsAtomCString(content->NodeInfo()->NameAtom()).get(), aOffset);
#endif
// Be aware, this instance may be destroyed after this call.
// XXX Why doesn't this call Selection::NotifySelectionListener() directly?
RefPtr<nsFrameSelection> frameSelection = mFrameSelection;
res = frameSelection->NotifySelectionListeners(GetType());
if (NS_FAILED(res)) {
aRv.Throw(res);
}
}
NS_IMETHODIMP
-Selection::SelectAllChildren(nsIDOMNode* aParentNode)
+Selection::SelectAllChildren(nsIDOMNode* aNode)
{
ErrorResult result;
- nsCOMPtr<nsINode> node = do_QueryInterface(aParentNode);
+ nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
NS_ENSURE_TRUE(node, NS_ERROR_INVALID_ARG);
SelectAllChildren(*node, result);
return result.StealNSResult();
}
void
Selection::SelectAllChildrenJS(nsINode& aNode, ErrorResult& aRv)
{
--- a/dom/base/Selection.h
+++ b/dom/base/Selection.h
@@ -124,33 +124,36 @@ public:
* then aRange is first scanned for -moz-user-select:none nodes and split up
* into multiple ranges to exclude those before adding the resulting ranges
* to this Selection.
*/
nsresult AddItem(nsRange* aRange, int32_t* aOutIndex, bool aNoStartSelect = false);
nsresult RemoveItem(nsRange* aRange);
nsresult RemoveCollapsedRanges();
nsresult Clear(nsPresContext* aPresContext);
- nsresult Collapse(nsINode* aParentNode, int32_t aOffset);
- nsresult Extend(nsINode* aParentNode, int32_t aOffset);
+ nsresult Collapse(nsINode* aContainer, int32_t aOffset);
+ nsresult Extend(nsINode* aContainer, int32_t aOffset);
nsRange* GetRangeAt(int32_t aIndex) const;
// Get the anchor-to-focus range if we don't care which end is
// anchor and which end is focus.
const nsRange* GetAnchorFocusRange() const {
return mAnchorFocusRange;
}
nsDirection GetDirection(){return mDirection;}
void SetDirection(nsDirection aDir){mDirection = aDir;}
nsresult SetAnchorFocusToRange(nsRange *aRange);
void ReplaceAnchorFocusRange(nsRange *aRange);
void AdjustAnchorFocusForMultiRange(nsDirection aDirection);
- // NS_IMETHOD GetPrimaryFrameForRangeEndpoint(nsIDOMNode *aNode, int32_t aOffset, bool aIsEndNode, nsIFrame **aResultFrame);
+ // NS_IMETHOD GetPrimaryFrameForRangeEndpoint(nsIDOMNode* aContainer,
+ // int32_t aOffset,
+ // bool aIsEndNode,
+ // nsIFrame** aResultFrame);
NS_IMETHOD GetPrimaryFrameForAnchorNode(nsIFrame **aResultFrame);
NS_IMETHOD GetPrimaryFrameForFocusNode(nsIFrame **aResultFrame, int32_t *aOffset, bool aVisual);
UniquePtr<SelectionDetails> LookUpSelection(
nsIContent* aContent,
int32_t aContentOffset,
int32_t aContentLength,
UniquePtr<SelectionDetails> aDetailsHead,
@@ -174,22 +177,22 @@ public:
nsINode* GetFocusNode();
uint32_t FocusOffset();
bool IsCollapsed() const;
// *JS() methods are mapped to Selection.*().
// They may move focus only when the range represents normal selection.
// These methods shouldn't be used by non-JS callers.
- void CollapseJS(nsINode* aNode, uint32_t aOffset,
+ void CollapseJS(nsINode* aContainer, uint32_t aOffset,
mozilla::ErrorResult& aRv);
void CollapseToStartJS(mozilla::ErrorResult& aRv);
void CollapseToEndJS(mozilla::ErrorResult& aRv);
- void ExtendJS(nsINode& aNode, uint32_t aOffset,
+ void ExtendJS(nsINode& aContainer, uint32_t aOffset,
mozilla::ErrorResult& aRv);
void SelectAllChildrenJS(nsINode& aNode, mozilla::ErrorResult& aRv);
void DeleteFromDocument(mozilla::ErrorResult& aRv);
uint32_t RangeCount() const
{
@@ -254,20 +257,20 @@ public:
void SetColors(const nsAString& aForeColor, const nsAString& aBackColor,
const nsAString& aAltForeColor, const nsAString& aAltBackColor,
mozilla::ErrorResult& aRv);
void ResetColors(mozilla::ErrorResult& aRv);
// Non-JS callers should use the following methods.
- void Collapse(nsINode& aNode, uint32_t aOffset, mozilla::ErrorResult& aRv);
+ void Collapse(nsINode& aContainer, uint32_t aOffset, ErrorResult& aRv);
void CollapseToStart(mozilla::ErrorResult& aRv);
void CollapseToEnd(mozilla::ErrorResult& aRv);
- void Extend(nsINode& aNode, uint32_t aOffset, mozilla::ErrorResult& aRv);
+ void Extend(nsINode& aContainer, uint32_t aOffset, ErrorResult& aRv);
void AddRange(nsRange& aRange, mozilla::ErrorResult& aRv);
void SelectAllChildren(nsINode& aNode, mozilla::ErrorResult& aRv);
void SetBaseAndExtent(nsINode& aAnchorNode, uint32_t aAnchorOffset,
nsINode& aFocusNode, uint32_t aFocusOffset,
mozilla::ErrorResult& aRv);
void AddSelectionChangeBlocker();
void RemoveSelectionChangeBlocker();
--- a/dom/base/nsRange.cpp
+++ b/dom/base/nsRange.cpp
@@ -748,87 +748,87 @@ nsRange::ParentChainChanged(nsIContent *
// of mRoot is the last thing in DoSetRange.
DoSetRange(mStartContainer, mStartOffset, mEndContainer, mEndOffset, newRoot);
}
/******************************************************
* Utilities for comparing points: API from nsIDOMRange
******************************************************/
NS_IMETHODIMP
-nsRange::IsPointInRange(nsIDOMNode* aParent, int32_t aOffset, bool* aResult)
+nsRange::IsPointInRange(nsIDOMNode* aContainer, int32_t aOffset, bool* aResult)
{
- nsCOMPtr<nsINode> parent = do_QueryInterface(aParent);
+ nsCOMPtr<nsINode> parent = do_QueryInterface(aContainer);
if (!parent) {
return NS_ERROR_DOM_NOT_OBJECT_ERR;
}
ErrorResult rv;
*aResult = IsPointInRange(*parent, aOffset, rv);
return rv.StealNSResult();
}
bool
-nsRange::IsPointInRange(nsINode& aParent, uint32_t aOffset, ErrorResult& aRv)
+nsRange::IsPointInRange(nsINode& aContainer, uint32_t aOffset, ErrorResult& aRv)
{
- uint16_t compareResult = ComparePoint(aParent, aOffset, aRv);
+ uint16_t compareResult = ComparePoint(aContainer, aOffset, aRv);
// If the node isn't in the range's document, it clearly isn't in the range.
if (aRv.ErrorCodeIs(NS_ERROR_DOM_WRONG_DOCUMENT_ERR)) {
aRv.SuppressException();
return false;
}
return compareResult == 0;
}
// returns -1 if point is before range, 0 if point is in range,
// 1 if point is after range.
NS_IMETHODIMP
-nsRange::ComparePoint(nsIDOMNode* aParent, int32_t aOffset, int16_t* aResult)
+nsRange::ComparePoint(nsIDOMNode* aContainer, int32_t aOffset, int16_t* aResult)
{
- nsCOMPtr<nsINode> parent = do_QueryInterface(aParent);
+ nsCOMPtr<nsINode> parent = do_QueryInterface(aContainer);
NS_ENSURE_TRUE(parent, NS_ERROR_DOM_HIERARCHY_REQUEST_ERR);
ErrorResult rv;
*aResult = ComparePoint(*parent, aOffset, rv);
return rv.StealNSResult();
}
int16_t
-nsRange::ComparePoint(nsINode& aParent, uint32_t aOffset, ErrorResult& aRv)
+nsRange::ComparePoint(nsINode& aContainer, uint32_t aOffset, ErrorResult& aRv)
{
// our range is in a good state?
if (!mIsPositioned) {
aRv.Throw(NS_ERROR_NOT_INITIALIZED);
return 0;
}
- if (!nsContentUtils::ContentIsDescendantOf(&aParent, mRoot)) {
+ if (!nsContentUtils::ContentIsDescendantOf(&aContainer, mRoot)) {
aRv.Throw(NS_ERROR_DOM_WRONG_DOCUMENT_ERR);
return 0;
}
- if (aParent.NodeType() == nsIDOMNode::DOCUMENT_TYPE_NODE) {
+ if (aContainer.NodeType() == nsIDOMNode::DOCUMENT_TYPE_NODE) {
aRv.Throw(NS_ERROR_DOM_INVALID_NODE_TYPE_ERR);
return 0;
}
- if (aOffset > aParent.Length()) {
+ if (aOffset > aContainer.Length()) {
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
return 0;
}
int32_t cmp;
- if ((cmp = nsContentUtils::ComparePoints(&aParent, aOffset,
+ if ((cmp = nsContentUtils::ComparePoints(&aContainer, aOffset,
mStartContainer,
mStartOffset)) <= 0) {
return cmp;
}
if (nsContentUtils::ComparePoints(mEndContainer, mEndOffset,
- &aParent, aOffset) == -1) {
+ &aContainer, aOffset) == -1) {
return 1;
}
return 0;
}
NS_IMETHODIMP
nsRange::IntersectsNode(nsIDOMNode* aNode, bool* aResult)
@@ -1210,51 +1210,51 @@ nsRange::SetStart(nsINode& aNode, uint32
return;
}
AutoInvalidateSelection atEndOfBlock(this);
aRv = SetStart(&aNode, aOffset);
}
NS_IMETHODIMP
-nsRange::SetStart(nsIDOMNode* aParent, int32_t aOffset)
+nsRange::SetStart(nsIDOMNode* aContainer, int32_t aOffset)
{
- nsCOMPtr<nsINode> parent = do_QueryInterface(aParent);
+ nsCOMPtr<nsINode> parent = do_QueryInterface(aContainer);
if (!parent) {
return NS_ERROR_DOM_NOT_OBJECT_ERR;
}
ErrorResult rv;
SetStart(*parent, aOffset, rv);
return rv.StealNSResult();
}
/* virtual */ nsresult
-nsRange::SetStart(nsINode* aParent, int32_t aOffset)
+nsRange::SetStart(nsINode* aContainer, int32_t aOffset)
{
- nsINode* newRoot = IsValidBoundary(aParent);
+ nsINode* newRoot = IsValidBoundary(aContainer);
if (!newRoot) {
return NS_ERROR_DOM_INVALID_NODE_TYPE_ERR;
}
- if (!IsValidOffset(aParent, aOffset)) {
+ if (!IsValidOffset(aContainer, aOffset)) {
return NS_ERROR_DOM_INDEX_SIZE_ERR;
}
// Collapse if not positioned yet, if positioned in another doc or
// if the new start is after end.
if (!mIsPositioned || newRoot != mRoot ||
- nsContentUtils::ComparePoints(aParent, aOffset,
+ nsContentUtils::ComparePoints(aContainer, aOffset,
mEndContainer, mEndOffset) == 1) {
- DoSetRange(aParent, aOffset, aParent, aOffset, newRoot);
+ DoSetRange(aContainer, aOffset, aContainer, aOffset, newRoot);
return NS_OK;
}
- DoSetRange(aParent, aOffset, mEndContainer, mEndOffset, mRoot);
+ DoSetRange(aContainer, aOffset, mEndContainer, mEndOffset, mRoot);
return NS_OK;
}
void
nsRange::SetStartBeforeJS(nsINode& aNode, ErrorResult& aErr)
{
AutoCalledByJSRestore calledByJSRestorer(*this);
@@ -1342,51 +1342,51 @@ nsRange::SetEnd(nsINode& aNode, uint32_t
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return;
}
AutoInvalidateSelection atEndOfBlock(this);
aRv = SetEnd(&aNode, aOffset);
}
NS_IMETHODIMP
-nsRange::SetEnd(nsIDOMNode* aParent, int32_t aOffset)
+nsRange::SetEnd(nsIDOMNode* aContainer, int32_t aOffset)
{
- nsCOMPtr<nsINode> parent = do_QueryInterface(aParent);
+ nsCOMPtr<nsINode> parent = do_QueryInterface(aContainer);
if (!parent) {
return NS_ERROR_DOM_NOT_OBJECT_ERR;
}
ErrorResult rv;
SetEnd(*parent, aOffset, rv);
return rv.StealNSResult();
}
/* virtual */ nsresult
-nsRange::SetEnd(nsINode* aParent, int32_t aOffset)
+nsRange::SetEnd(nsINode* aContainer, int32_t aOffset)
{
- nsINode* newRoot = IsValidBoundary(aParent);
+ nsINode* newRoot = IsValidBoundary(aContainer);
if (!newRoot) {
return NS_ERROR_DOM_INVALID_NODE_TYPE_ERR;
}
- if (!IsValidOffset(aParent, aOffset)) {
+ if (!IsValidOffset(aContainer, aOffset)) {
return NS_ERROR_DOM_INDEX_SIZE_ERR;
}
// Collapse if not positioned yet, if positioned in another doc or
// if the new end is before start.
if (!mIsPositioned || newRoot != mRoot ||
nsContentUtils::ComparePoints(mStartContainer, mStartOffset,
- aParent, aOffset) == 1) {
- DoSetRange(aParent, aOffset, aParent, aOffset, newRoot);
+ aContainer, aOffset) == 1) {
+ DoSetRange(aContainer, aOffset, aContainer, aOffset, newRoot);
return NS_OK;
}
- DoSetRange(mStartContainer, mStartOffset, aParent, aOffset, mRoot);
+ DoSetRange(mStartContainer, mStartOffset, aContainer, aOffset, mRoot);
return NS_OK;
}
nsresult
nsRange::SetStartAndEnd(nsINode* aStartParent, int32_t aStartOffset,
nsINode* aEndParent, int32_t aEndOffset)
{
@@ -1962,21 +1962,21 @@ static nsresult SplitDataNode(nsIDOMChar
nsCOMPtr<nsIContent> newData;
rv = dataNode->SplitData(aStartIndex, getter_AddRefs(newData),
aCloneAfterOriginal);
NS_ENSURE_SUCCESS(rv, rv);
return CallQueryInterface(newData, aEndNode);
}
NS_IMETHODIMP
-PrependChild(nsINode* aParent, nsINode* aChild)
+PrependChild(nsINode* aContainer, nsINode* aChild)
{
- nsCOMPtr<nsINode> first = aParent->GetFirstChild();
+ nsCOMPtr<nsINode> first = aContainer->GetFirstChild();
ErrorResult rv;
- aParent->InsertBefore(*aChild, first, rv);
+ aContainer->InsertBefore(*aChild, first, rv);
return rv.StealNSResult();
}
// Helper function for CutContents, making sure that the current node wasn't
// removed by mutation events (bug 766426)
static bool
ValidateCurrentNode(nsRange* aRange, RangeSubtreeIterator& aIter)
{
--- a/dom/base/nsRange.h
+++ b/dom/base/nsRange.h
@@ -142,18 +142,18 @@ public:
void Reset();
/**
* SetStart() and SetEnd() sets start point or end point separately.
* However, this is expensive especially when it's a range of Selection.
* When you set both start and end of a range, you should use
* SetStartAndEnd() instead.
*/
- nsresult SetStart(nsINode* aParent, int32_t aOffset);
- nsresult SetEnd(nsINode* aParent, int32_t aOffset);
+ nsresult SetStart(nsINode* aContainer, int32_t aOffset);
+ nsresult SetEnd(nsINode* aContainer, int32_t aOffset);
already_AddRefed<nsRange> CloneRange() const;
/**
* SetStartAndEnd() works similar to call both SetStart() and SetEnd().
* Different from calls them separately, this does nothing if either
* the start point or the end point is invalid point.
* If the specified start point is after the end point, the range will be
@@ -161,21 +161,21 @@ public:
* the range will be collapsed at the end point.
*/
nsresult SetStartAndEnd(nsINode* aStartParent, int32_t aStartOffset,
nsINode* aEndParent, int32_t aEndOffset);
/**
* CollapseTo() works similar to call both SetStart() and SetEnd() with
* same node and offset. This just calls SetStartAndParent() to set
- * collapsed range at aParent and aOffset.
+ * collapsed range at aContainer and aOffset.
*/
- nsresult CollapseTo(nsINode* aParent, int32_t aOffset)
+ nsresult CollapseTo(nsINode* aContainer, int32_t aOffset)
{
- return SetStartAndEnd(aParent, aOffset, aParent, aOffset);
+ return SetStartAndEnd(aContainer, aOffset, aContainer, aOffset);
}
/**
* Retrieves node and offset for setting start or end of a range to
* before or after aNode.
*/
static nsINode* GetContainerAndOffsetAfter(nsINode* aNode, int32_t* aOffset)
{
@@ -217,28 +217,29 @@ public:
mStartOffset == mEndOffset;
}
already_AddRefed<mozilla::dom::DocumentFragment>
CreateContextualFragment(const nsAString& aString, ErrorResult& aError);
already_AddRefed<mozilla::dom::DocumentFragment>
CloneContents(ErrorResult& aErr);
int16_t CompareBoundaryPoints(uint16_t aHow, nsRange& aOther,
ErrorResult& aErr);
- int16_t ComparePoint(nsINode& aParent, uint32_t aOffset, ErrorResult& aErr);
+ int16_t ComparePoint(nsINode& aContainer, uint32_t aOffset,
+ ErrorResult& aErr);
void DeleteContents(ErrorResult& aRv);
already_AddRefed<mozilla::dom::DocumentFragment>
ExtractContents(ErrorResult& aErr);
nsINode* GetCommonAncestorContainer(ErrorResult& aRv) const;
nsINode* GetStartContainer(ErrorResult& aRv) const;
uint32_t GetStartOffset(ErrorResult& aRv) const;
nsINode* GetEndContainer(ErrorResult& aRv) const;
uint32_t GetEndOffset(ErrorResult& aRv) const;
void InsertNode(nsINode& aNode, ErrorResult& aErr);
bool IntersectsNode(nsINode& aNode, ErrorResult& aRv);
- bool IsPointInRange(nsINode& aParent, uint32_t aOffset, ErrorResult& aErr);
+ bool IsPointInRange(nsINode& aContainer, uint32_t aOffset, ErrorResult& aErr);
// *JS() methods are mapped to Range.*() of DOM.
// They may move focus only when the range represents normal selection.
// These methods shouldn't be used from internal.
void CollapseJS(bool aToStart);
void SelectNodeJS(nsINode& aNode, ErrorResult& aErr);
void SelectNodeContentsJS(nsINode& aNode, ErrorResult& aErr);
void SetEndJS(nsINode& aNode, uint32_t aOffset, ErrorResult& aErr);
--- a/layout/generic/nsFrameSelection.cpp
+++ b/layout/generic/nsFrameSelection.cpp
@@ -2844,25 +2844,27 @@ nsFrameSelection::SelectCellElement(nsIC
// Get child offset
int32_t offset = parent->IndexOf(aCellElement);
return CreateAndAddRange(parent, offset);
}
nsresult
-nsFrameSelection::CreateAndAddRange(nsINode *aParentNode, int32_t aOffset)
+nsFrameSelection::CreateAndAddRange(nsINode* aContainer, int32_t aOffset)
{
- if (!aParentNode) return NS_ERROR_NULL_POINTER;
-
- RefPtr<nsRange> range = new nsRange(aParentNode);
+ if (!aContainer) {
+ return NS_ERROR_NULL_POINTER;
+ }
+
+ RefPtr<nsRange> range = new nsRange(aContainer);
// Set range around child at given offset
- nsresult rv = range->SetStartAndEnd(aParentNode, aOffset,
- aParentNode, aOffset + 1);
+ nsresult rv = range->SetStartAndEnd(aContainer, aOffset,
+ aContainer, aOffset + 1);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
int8_t index = GetIndexFromSelectionType(SelectionType::eNormal);
if (!mDomSelections[index])
return NS_ERROR_NULL_POINTER;
--- a/layout/generic/nsFrameSelection.h
+++ b/layout/generic/nsFrameSelection.h
@@ -723,17 +723,17 @@ private:
// not return null, then the first node in the returned range is a cell
// (according to GetFirstCellNodeInRange).
nsRange* GetNextCellRange();
nsIContent* GetFirstCellNodeInRange(nsRange *aRange) const;
// Returns non-null table if in same table, null otherwise
nsIContent* IsInSameTable(nsIContent *aContent1, nsIContent *aContent2) const;
// Might return null
nsIContent* GetParentTable(nsIContent *aCellNode) const;
- nsresult CreateAndAddRange(nsINode *aParentNode, int32_t aOffset);
+ nsresult CreateAndAddRange(nsINode* aContainer, int32_t aOffset);
nsCOMPtr<nsINode> mCellParent; //used to snap to table selection
nsCOMPtr<nsIContent> mStartSelectedCell;
nsCOMPtr<nsIContent> mEndSelectedCell;
nsCOMPtr<nsIContent> mAppendStartSelectedCell;
nsCOMPtr<nsIContent> mUnselectCellOnMouseUp;
int32_t mSelectingTableCellMode;
int32_t mSelectedCellIndex;