Fixed busted double-click word selection in Composer, b=131739, sr=scc, a=asa

This commit is contained in:
cmanske%netscape.com 2002-03-21 02:47:52 +00:00
Родитель 3ded9c54cd
Коммит f4962c5548
1 изменённых файлов: 24 добавлений и 17 удалений

Просмотреть файл

@ -143,7 +143,7 @@ nsHTMLEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent)
// Detect if mouse point is within current selection for context click
PRBool nodeIsInSelection = PR_FALSE;
if ( !(buttonNumber == 0 && clickCount == 2) )
if (isContextClick)
{
PRBool isCollapsed;
selection->GetIsCollapsed(&isCollapsed);
@ -177,12 +177,7 @@ nsHTMLEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent)
if (node && !nodeIsInSelection)
{
PRBool elementIsLink = PR_FALSE;
if (element)
{
// Set caret just before an element
selection->Collapse(parent, offset);
}
else
if (!element)
{
// Get enclosing link if in text so we can select the link
//XXX Although I'd prefer to not select a link on context click,
@ -196,21 +191,33 @@ nsHTMLEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent)
}
// Select entire element clicked on if NOT within an existing selection
// and not the entire body, or table-related elements
if (element && !nodeIsInSelection &&
!nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("body")) &&
!nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("td")) &&
!nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("th")) &&
!nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("caption")) &&
!nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("tr")) &&
!nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("table")))
if (element)
{
if (nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("body")) ||
nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("td")) ||
nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("th")) ||
nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("caption")) ||
nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("tr")) ||
nsTextEditUtils::NodeIsType(node, NS_LITERAL_STRING("table")))
{
// This will place caret just inside table cell or at start of body
selection->Collapse(parent, offset);
}
else
{
htmlEditor->SelectElement(element);
}
}
}
// Prevent bubbling if we changed selection or
// for all context clicks
if (element || isContextClick)
{
mouseEvent->PreventDefault();
return NS_OK;
}
}
}
return nsTextEditorMouseListener::MouseDown(aMouseEvent);
}