added the notion of contain vs. replace for block transformations.

This commit is contained in:
buster%netscape.com 1999-04-21 21:01:59 +00:00
Родитель cdc6b41ae9
Коммит 58c31945cb
6 изменённых файлов: 44 добавлений и 2 удалений

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

@ -425,6 +425,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
// hard-coded ChangeTextAttributes test -- font color red
case nsIDOMEvent::VK_1:
case nsIDOMEvent::VK_F:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;

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

@ -582,7 +582,9 @@ nsHTMLEditor::ReParentBlockContent(nsIDOMNode *aNode,
if ((NS_SUCCEEDED(result)) && leftNode && rightNode)
{
PRInt32 offsetInParent=0;
if (aBlockParentTag.EqualsIgnoreCase("body"))
PRBool canContain;
CanContainBlock(aParentTag, aBlockParentTag, canContain);
if (PR_TRUE==canContain)
{
result = nsIEditorSupport::GetChildOffset(leftNode, aBlockParentNode, offsetInParent);
NS_ASSERTION((NS_SUCCEEDED(result)), "bad result from GetChildOffset");
@ -650,6 +652,22 @@ nsHTMLEditor::ReParentContentOfRange(nsIDOMRange *aRange, nsString &aParentTag)
return result;
}
// this should probably get moved into rules? is this an app-level choice, or
// a restriction of HTML itself?
NS_IMETHODIMP
nsHTMLEditor::CanContainBlock(nsString &aBlockChild, nsString &aBlockParent, PRBool &aCanContain)
{
if (aBlockParent.EqualsIgnoreCase("body") ||
aBlockParent.EqualsIgnoreCase("td") ||
aBlockParent.EqualsIgnoreCase("th") ||
aBlockParent.EqualsIgnoreCase("blockquote") )
{
aCanContain = PR_TRUE;
return NS_OK;
}
aCanContain = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsHTMLEditor::RemoveBlockParent()

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

@ -147,6 +147,8 @@ protected:
NS_IMETHOD ReParentContentOfRange(nsIDOMRange *aRange, nsString &aParentTag);
NS_IMETHOD CanContainBlock(nsString &aBlockChild, nsString &aBlockParent, PRBool &aCanContain);
// EVENT LISTENERS AND COMMAND ROUTING NEEDS WORK
// For now, the listners are tied to the nsTextEditor class
//

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

@ -582,7 +582,9 @@ nsHTMLEditor::ReParentBlockContent(nsIDOMNode *aNode,
if ((NS_SUCCEEDED(result)) && leftNode && rightNode)
{
PRInt32 offsetInParent=0;
if (aBlockParentTag.EqualsIgnoreCase("body"))
PRBool canContain;
CanContainBlock(aParentTag, aBlockParentTag, canContain);
if (PR_TRUE==canContain)
{
result = nsIEditorSupport::GetChildOffset(leftNode, aBlockParentNode, offsetInParent);
NS_ASSERTION((NS_SUCCEEDED(result)), "bad result from GetChildOffset");
@ -650,6 +652,22 @@ nsHTMLEditor::ReParentContentOfRange(nsIDOMRange *aRange, nsString &aParentTag)
return result;
}
// this should probably get moved into rules? is this an app-level choice, or
// a restriction of HTML itself?
NS_IMETHODIMP
nsHTMLEditor::CanContainBlock(nsString &aBlockChild, nsString &aBlockParent, PRBool &aCanContain)
{
if (aBlockParent.EqualsIgnoreCase("body") ||
aBlockParent.EqualsIgnoreCase("td") ||
aBlockParent.EqualsIgnoreCase("th") ||
aBlockParent.EqualsIgnoreCase("blockquote") )
{
aCanContain = PR_TRUE;
return NS_OK;
}
aCanContain = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsHTMLEditor::RemoveBlockParent()

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

@ -147,6 +147,8 @@ protected:
NS_IMETHOD ReParentContentOfRange(nsIDOMRange *aRange, nsString &aParentTag);
NS_IMETHOD CanContainBlock(nsString &aBlockChild, nsString &aBlockParent, PRBool &aCanContain);
// EVENT LISTENERS AND COMMAND ROUTING NEEDS WORK
// For now, the listners are tied to the nsTextEditor class
//

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

@ -425,6 +425,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
// hard-coded ChangeTextAttributes test -- font color red
case nsIDOMEvent::VK_1:
case nsIDOMEvent::VK_F:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;