зеркало из https://github.com/mozilla/gecko-dev.git
Adapt to fixed selection interface
This commit is contained in:
Родитель
90555ec5dc
Коммит
a497442a45
|
@ -1099,8 +1099,8 @@ nsEditor::InsertText(const nsString& aStringToInsert)
|
|||
{
|
||||
nsCOMPtr<nsIDOMNode> selectedNode;
|
||||
PRInt32 offset;
|
||||
result = selection->GetAnchorNodeAndOffset(getter_AddRefs(selectedNode), &offset);
|
||||
if ((NS_SUCCEEDED(result)) && selectedNode)
|
||||
result = selection->GetAnchorNode(getter_AddRefs(selectedNode));
|
||||
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(&offset)) && selectedNode)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> newNode;
|
||||
result = CreateNode(GetTextNodeTag(), selectedNode, offset+1,
|
||||
|
@ -1334,8 +1334,7 @@ NS_IMETHODIMP nsEditor::DeleteSelectionAndPrepareToCreateNode(nsCOMPtr<nsIDOMNod
|
|||
}
|
||||
#ifdef NS_DEBUG
|
||||
nsCOMPtr<nsIDOMNode>testSelectedNode;
|
||||
PRInt32 testOffset;
|
||||
nsresult debugResult = selection->GetAnchorNodeAndOffset(getter_AddRefs(testSelectedNode), &testOffset);
|
||||
nsresult debugResult = selection->GetAnchorNode(getter_AddRefs(testSelectedNode));
|
||||
// no selection is ok.
|
||||
// if there is a selection, it must be collapsed
|
||||
if (testSelectedNode)
|
||||
|
@ -1349,8 +1348,8 @@ NS_IMETHODIMP nsEditor::DeleteSelectionAndPrepareToCreateNode(nsCOMPtr<nsIDOMNod
|
|||
}
|
||||
// split the selected node
|
||||
PRInt32 offsetOfSelectedNode;
|
||||
result = selection->GetAnchorNodeAndOffset(getter_AddRefs(parentSelectedNode), &offsetOfSelectedNode);
|
||||
if ((NS_SUCCEEDED(result)) && parentSelectedNode)
|
||||
result = selection->GetAnchorNode(getter_AddRefs(parentSelectedNode));
|
||||
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(&offsetOfSelectedNode)) && parentSelectedNode)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> selectedNode;
|
||||
PRUint32 selectedNodeContentCount=0;
|
||||
|
|
|
@ -261,8 +261,8 @@ nsTextEditRules::CreateStyleForInsertText(nsIDOMSelection *aSelection, TypeInSta
|
|||
// Otherwise, create the text node and the new inline style parents.
|
||||
nsCOMPtr<nsIDOMNode>anchor;
|
||||
PRInt32 offset;
|
||||
nsresult result = aSelection->GetAnchorNodeAndOffset(getter_AddRefs(anchor), &offset);
|
||||
if ((NS_SUCCEEDED(result)) && anchor)
|
||||
nsresult result = aSelection->GetAnchorNode(getter_AddRefs(anchor));
|
||||
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && anchor)
|
||||
{
|
||||
nsCOMPtr<nsIDOMCharacterData>anchorAsText;
|
||||
anchorAsText = do_QueryInterface(anchor);
|
||||
|
@ -417,8 +417,8 @@ nsTextEditRules::InsertStyleAndNewTextNode(nsIDOMNode *aParentNode, nsIAtom *aTa
|
|||
{
|
||||
nsCOMPtr<nsIDOMNode>anchor;
|
||||
PRInt32 offset;
|
||||
nsresult result = aSelection->GetAnchorNodeAndOffset(getter_AddRefs(anchor), &offset);
|
||||
if ((NS_SUCCEEDED(result)) && anchor)
|
||||
nsresult result = aSelection->GetAnchorNode(getter_AddRefs(anchor));
|
||||
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && anchor)
|
||||
{
|
||||
nsCOMPtr<nsIDOMCharacterData>anchorAsText;
|
||||
anchorAsText = do_QueryInterface(anchor);
|
||||
|
@ -558,8 +558,8 @@ nsTextEditRules::DidDeleteSelection(nsIDOMSelection *aSelection, nsresult aResul
|
|||
{
|
||||
nsCOMPtr<nsIDOMNode>anchor;
|
||||
PRInt32 offset;
|
||||
nsresult result = aSelection->GetAnchorNodeAndOffset(getter_AddRefs(anchor), &offset);
|
||||
if ((NS_SUCCEEDED(result)) && anchor)
|
||||
nsresult result = aSelection->GetAnchorNode(getter_AddRefs(anchor));
|
||||
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && anchor)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNodeList> anchorChildren;
|
||||
result = anchor->GetChildNodes(getter_AddRefs(anchorChildren));
|
||||
|
@ -645,8 +645,8 @@ nsTextEditRules:: DidUndo(nsIDOMSelection *aSelection, nsresult aResult)
|
|||
{
|
||||
nsCOMPtr<nsIDOMNode>node;
|
||||
PRInt32 offset;
|
||||
nsresult result = aSelection->GetAnchorNodeAndOffset(getter_AddRefs(node), &offset);
|
||||
while ((NS_SUCCEEDED(result)) && node)
|
||||
nsresult result = aSelection->GetAnchorNode(getter_AddRefs(node));
|
||||
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && node)
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement>element;
|
||||
element = do_QueryInterface(node);
|
||||
|
@ -691,8 +691,8 @@ nsTextEditRules::DidRedo(nsIDOMSelection *aSelection, nsresult aResult)
|
|||
{
|
||||
nsCOMPtr<nsIDOMNode>node;
|
||||
PRInt32 offset;
|
||||
nsresult result = aSelection->GetAnchorNodeAndOffset(getter_AddRefs(node), &offset);
|
||||
while ((NS_SUCCEEDED(result)) && node)
|
||||
nsresult result = aSelection->GetAnchorNode(getter_AddRefs(node));
|
||||
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && node)
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement>element;
|
||||
element = do_QueryInterface(node);
|
||||
|
|
|
@ -337,12 +337,18 @@ NS_IMETHODIMP nsTextEditor::SetTextProperty(nsIAtom *aProperty,
|
|||
{
|
||||
// remember start and end points of selection
|
||||
// XXX: this won't work for discontiguous selections
|
||||
|
||||
#if 0
|
||||
// these don't seem to be used. sfraser
|
||||
nsCOMPtr<nsIDOMNode> selStartNode;
|
||||
PRInt32 selStartOffset;
|
||||
nsCOMPtr<nsIDOMNode> selEndNode;
|
||||
PRInt32 selEndOffset;
|
||||
selection->GetAnchorNodeAndOffset(getter_AddRefs(selStartNode), &selStartOffset);
|
||||
selection->GetFocusNodeAndOffset(getter_AddRefs(selEndNode), &selEndOffset);
|
||||
selection->GetAnchorNode(getter_AddRefs(selStartNode));
|
||||
selection->GetAnchorOffset(&selStartOffset);
|
||||
selection->GetFocusNode(getter_AddRefs(selEndNode));
|
||||
selection->GetFocusOffset(&selEndOffset);
|
||||
#endif
|
||||
|
||||
// set the text property for all selected ranges
|
||||
nsEditor::BeginTransaction();
|
||||
|
|
|
@ -1099,8 +1099,8 @@ nsEditor::InsertText(const nsString& aStringToInsert)
|
|||
{
|
||||
nsCOMPtr<nsIDOMNode> selectedNode;
|
||||
PRInt32 offset;
|
||||
result = selection->GetAnchorNodeAndOffset(getter_AddRefs(selectedNode), &offset);
|
||||
if ((NS_SUCCEEDED(result)) && selectedNode)
|
||||
result = selection->GetAnchorNode(getter_AddRefs(selectedNode));
|
||||
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(&offset)) && selectedNode)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> newNode;
|
||||
result = CreateNode(GetTextNodeTag(), selectedNode, offset+1,
|
||||
|
@ -1334,8 +1334,7 @@ NS_IMETHODIMP nsEditor::DeleteSelectionAndPrepareToCreateNode(nsCOMPtr<nsIDOMNod
|
|||
}
|
||||
#ifdef NS_DEBUG
|
||||
nsCOMPtr<nsIDOMNode>testSelectedNode;
|
||||
PRInt32 testOffset;
|
||||
nsresult debugResult = selection->GetAnchorNodeAndOffset(getter_AddRefs(testSelectedNode), &testOffset);
|
||||
nsresult debugResult = selection->GetAnchorNode(getter_AddRefs(testSelectedNode));
|
||||
// no selection is ok.
|
||||
// if there is a selection, it must be collapsed
|
||||
if (testSelectedNode)
|
||||
|
@ -1349,8 +1348,8 @@ NS_IMETHODIMP nsEditor::DeleteSelectionAndPrepareToCreateNode(nsCOMPtr<nsIDOMNod
|
|||
}
|
||||
// split the selected node
|
||||
PRInt32 offsetOfSelectedNode;
|
||||
result = selection->GetAnchorNodeAndOffset(getter_AddRefs(parentSelectedNode), &offsetOfSelectedNode);
|
||||
if ((NS_SUCCEEDED(result)) && parentSelectedNode)
|
||||
result = selection->GetAnchorNode(getter_AddRefs(parentSelectedNode));
|
||||
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(&offsetOfSelectedNode)) && parentSelectedNode)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> selectedNode;
|
||||
PRUint32 selectedNodeContentCount=0;
|
||||
|
|
|
@ -261,8 +261,8 @@ nsTextEditRules::CreateStyleForInsertText(nsIDOMSelection *aSelection, TypeInSta
|
|||
// Otherwise, create the text node and the new inline style parents.
|
||||
nsCOMPtr<nsIDOMNode>anchor;
|
||||
PRInt32 offset;
|
||||
nsresult result = aSelection->GetAnchorNodeAndOffset(getter_AddRefs(anchor), &offset);
|
||||
if ((NS_SUCCEEDED(result)) && anchor)
|
||||
nsresult result = aSelection->GetAnchorNode(getter_AddRefs(anchor));
|
||||
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && anchor)
|
||||
{
|
||||
nsCOMPtr<nsIDOMCharacterData>anchorAsText;
|
||||
anchorAsText = do_QueryInterface(anchor);
|
||||
|
@ -417,8 +417,8 @@ nsTextEditRules::InsertStyleAndNewTextNode(nsIDOMNode *aParentNode, nsIAtom *aTa
|
|||
{
|
||||
nsCOMPtr<nsIDOMNode>anchor;
|
||||
PRInt32 offset;
|
||||
nsresult result = aSelection->GetAnchorNodeAndOffset(getter_AddRefs(anchor), &offset);
|
||||
if ((NS_SUCCEEDED(result)) && anchor)
|
||||
nsresult result = aSelection->GetAnchorNode(getter_AddRefs(anchor));
|
||||
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && anchor)
|
||||
{
|
||||
nsCOMPtr<nsIDOMCharacterData>anchorAsText;
|
||||
anchorAsText = do_QueryInterface(anchor);
|
||||
|
@ -558,8 +558,8 @@ nsTextEditRules::DidDeleteSelection(nsIDOMSelection *aSelection, nsresult aResul
|
|||
{
|
||||
nsCOMPtr<nsIDOMNode>anchor;
|
||||
PRInt32 offset;
|
||||
nsresult result = aSelection->GetAnchorNodeAndOffset(getter_AddRefs(anchor), &offset);
|
||||
if ((NS_SUCCEEDED(result)) && anchor)
|
||||
nsresult result = aSelection->GetAnchorNode(getter_AddRefs(anchor));
|
||||
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && anchor)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNodeList> anchorChildren;
|
||||
result = anchor->GetChildNodes(getter_AddRefs(anchorChildren));
|
||||
|
@ -645,8 +645,8 @@ nsTextEditRules:: DidUndo(nsIDOMSelection *aSelection, nsresult aResult)
|
|||
{
|
||||
nsCOMPtr<nsIDOMNode>node;
|
||||
PRInt32 offset;
|
||||
nsresult result = aSelection->GetAnchorNodeAndOffset(getter_AddRefs(node), &offset);
|
||||
while ((NS_SUCCEEDED(result)) && node)
|
||||
nsresult result = aSelection->GetAnchorNode(getter_AddRefs(node));
|
||||
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && node)
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement>element;
|
||||
element = do_QueryInterface(node);
|
||||
|
@ -691,8 +691,8 @@ nsTextEditRules::DidRedo(nsIDOMSelection *aSelection, nsresult aResult)
|
|||
{
|
||||
nsCOMPtr<nsIDOMNode>node;
|
||||
PRInt32 offset;
|
||||
nsresult result = aSelection->GetAnchorNodeAndOffset(getter_AddRefs(node), &offset);
|
||||
while ((NS_SUCCEEDED(result)) && node)
|
||||
nsresult result = aSelection->GetAnchorNode(getter_AddRefs(node));
|
||||
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && node)
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement>element;
|
||||
element = do_QueryInterface(node);
|
||||
|
|
Загрузка…
Ссылка в новой задаче