зеркало из https://github.com/mozilla/gecko-dev.git
Restrict nsEditorShellMouseListener to HTML editor; fix to optimize GetSelectedNode for named anchors, b=47687, r=sfraser
This commit is contained in:
Родитель
205eefc4a7
Коммит
37cbf70bba
|
@ -511,27 +511,29 @@ nsEditorShell::PrepareDocumentForEditing(nsIDocumentLoader* aLoader, nsIURI *aUr
|
|||
mEditorController->SetCommandRefCon(editorAsISupports);
|
||||
}
|
||||
|
||||
|
||||
// get a mouse listener for double click on tags
|
||||
// We can't use nsEditor listener because core editor shouldn't call UI commands
|
||||
rv = NS_NewEditorShellMouseListener(getter_AddRefs(mMouseListenerP), this);
|
||||
if (NS_FAILED(rv))
|
||||
if (mEditorType == eHTMLTextEditorType)
|
||||
{
|
||||
mMouseListenerP = nsnull;
|
||||
return rv;
|
||||
}
|
||||
// get a mouse listener for double click on tags
|
||||
// We can't use nsEditor listener because core editor shouldn't call UI commands
|
||||
rv = NS_NewEditorShellMouseListener(getter_AddRefs(mMouseListenerP), this);
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
mMouseListenerP = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Add mouse listener to document
|
||||
nsCOMPtr<nsIDOMEventReceiver> erP;
|
||||
rv = GetDocumentEventReceiver(getter_AddRefs(erP));
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
mMouseListenerP = nsnull;
|
||||
return rv;
|
||||
}
|
||||
// Add mouse listener to document
|
||||
nsCOMPtr<nsIDOMEventReceiver> erP;
|
||||
rv = GetDocumentEventReceiver(getter_AddRefs(erP));
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
mMouseListenerP = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = erP->AddEventListenerByIID(mMouseListenerP, NS_GET_IID(nsIDOMMouseListener));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = erP->AddEventListenerByIID(mMouseListenerP, NS_GET_IID(nsIDOMMouseListener));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
// now all the listeners are set up, we can call PostCreate
|
||||
rv = editor->PostCreate();
|
||||
|
|
|
@ -3562,7 +3562,7 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu
|
|||
// Empty string indicates we should match any element tag
|
||||
PRBool anyTag = (TagName.IsEmpty());
|
||||
PRBool isLinkTag = IsLink(TagName);
|
||||
PRBool isNamedAnchorTag = IsLink(TagName);
|
||||
PRBool isNamedAnchorTag = IsNamedAnchor(TagName);
|
||||
|
||||
nsCOMPtr<nsIDOMElement> selectedElement;
|
||||
nsCOMPtr<nsIDOMRange> range;
|
||||
|
@ -3592,11 +3592,10 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu
|
|||
selectedNode->GetNodeName(domTagName);
|
||||
domTagName.ToLowerCase();
|
||||
|
||||
// Only consider this node if requested to find a link or "any" tagname
|
||||
if (anyTag ||
|
||||
isLinkTag && IsLinkNode(selectedNode) ||
|
||||
isNamedAnchorTag && IsNamedAnchorNode(selectedNode) ||
|
||||
TagName == domTagName )
|
||||
// Test for appropriate node type requested
|
||||
if (anyTag || (TagName == domTagName) ||
|
||||
(isLinkTag && IsLinkNode(selectedNode)) ||
|
||||
(isNamedAnchorTag && IsNamedAnchorNode(selectedNode)))
|
||||
{
|
||||
bNodeFound = PR_TRUE;
|
||||
selectedElement = do_QueryInterface(selectedNode);
|
||||
|
|
|
@ -511,27 +511,29 @@ nsEditorShell::PrepareDocumentForEditing(nsIDocumentLoader* aLoader, nsIURI *aUr
|
|||
mEditorController->SetCommandRefCon(editorAsISupports);
|
||||
}
|
||||
|
||||
|
||||
// get a mouse listener for double click on tags
|
||||
// We can't use nsEditor listener because core editor shouldn't call UI commands
|
||||
rv = NS_NewEditorShellMouseListener(getter_AddRefs(mMouseListenerP), this);
|
||||
if (NS_FAILED(rv))
|
||||
if (mEditorType == eHTMLTextEditorType)
|
||||
{
|
||||
mMouseListenerP = nsnull;
|
||||
return rv;
|
||||
}
|
||||
// get a mouse listener for double click on tags
|
||||
// We can't use nsEditor listener because core editor shouldn't call UI commands
|
||||
rv = NS_NewEditorShellMouseListener(getter_AddRefs(mMouseListenerP), this);
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
mMouseListenerP = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Add mouse listener to document
|
||||
nsCOMPtr<nsIDOMEventReceiver> erP;
|
||||
rv = GetDocumentEventReceiver(getter_AddRefs(erP));
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
mMouseListenerP = nsnull;
|
||||
return rv;
|
||||
}
|
||||
// Add mouse listener to document
|
||||
nsCOMPtr<nsIDOMEventReceiver> erP;
|
||||
rv = GetDocumentEventReceiver(getter_AddRefs(erP));
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
mMouseListenerP = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = erP->AddEventListenerByIID(mMouseListenerP, NS_GET_IID(nsIDOMMouseListener));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = erP->AddEventListenerByIID(mMouseListenerP, NS_GET_IID(nsIDOMMouseListener));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
// now all the listeners are set up, we can call PostCreate
|
||||
rv = editor->PostCreate();
|
||||
|
|
|
@ -3562,7 +3562,7 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu
|
|||
// Empty string indicates we should match any element tag
|
||||
PRBool anyTag = (TagName.IsEmpty());
|
||||
PRBool isLinkTag = IsLink(TagName);
|
||||
PRBool isNamedAnchorTag = IsLink(TagName);
|
||||
PRBool isNamedAnchorTag = IsNamedAnchor(TagName);
|
||||
|
||||
nsCOMPtr<nsIDOMElement> selectedElement;
|
||||
nsCOMPtr<nsIDOMRange> range;
|
||||
|
@ -3592,11 +3592,10 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu
|
|||
selectedNode->GetNodeName(domTagName);
|
||||
domTagName.ToLowerCase();
|
||||
|
||||
// Only consider this node if requested to find a link or "any" tagname
|
||||
if (anyTag ||
|
||||
isLinkTag && IsLinkNode(selectedNode) ||
|
||||
isNamedAnchorTag && IsNamedAnchorNode(selectedNode) ||
|
||||
TagName == domTagName )
|
||||
// Test for appropriate node type requested
|
||||
if (anyTag || (TagName == domTagName) ||
|
||||
(isLinkTag && IsLinkNode(selectedNode)) ||
|
||||
(isNamedAnchorTag && IsNamedAnchorNode(selectedNode)))
|
||||
{
|
||||
bNodeFound = PR_TRUE;
|
||||
selectedElement = do_QueryInterface(selectedNode);
|
||||
|
|
Загрузка…
Ссылка в новой задаче