зеркало из https://github.com/mozilla/pjs.git
added the notion of contain vs. replace for block transformations.
This commit is contained in:
Родитель
cdc6b41ae9
Коммит
58c31945cb
|
@ -425,6 +425,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr
|
||||||
|
|
||||||
// hard-coded ChangeTextAttributes test -- font color red
|
// hard-coded ChangeTextAttributes test -- font color red
|
||||||
case nsIDOMEvent::VK_1:
|
case nsIDOMEvent::VK_1:
|
||||||
|
case nsIDOMEvent::VK_F:
|
||||||
if (PR_TRUE==ctrlKey)
|
if (PR_TRUE==ctrlKey)
|
||||||
{
|
{
|
||||||
aProcessed=PR_TRUE;
|
aProcessed=PR_TRUE;
|
||||||
|
|
|
@ -582,7 +582,9 @@ nsHTMLEditor::ReParentBlockContent(nsIDOMNode *aNode,
|
||||||
if ((NS_SUCCEEDED(result)) && leftNode && rightNode)
|
if ((NS_SUCCEEDED(result)) && leftNode && rightNode)
|
||||||
{
|
{
|
||||||
PRInt32 offsetInParent=0;
|
PRInt32 offsetInParent=0;
|
||||||
if (aBlockParentTag.EqualsIgnoreCase("body"))
|
PRBool canContain;
|
||||||
|
CanContainBlock(aParentTag, aBlockParentTag, canContain);
|
||||||
|
if (PR_TRUE==canContain)
|
||||||
{
|
{
|
||||||
result = nsIEditorSupport::GetChildOffset(leftNode, aBlockParentNode, offsetInParent);
|
result = nsIEditorSupport::GetChildOffset(leftNode, aBlockParentNode, offsetInParent);
|
||||||
NS_ASSERTION((NS_SUCCEEDED(result)), "bad result from GetChildOffset");
|
NS_ASSERTION((NS_SUCCEEDED(result)), "bad result from GetChildOffset");
|
||||||
|
@ -650,6 +652,22 @@ nsHTMLEditor::ReParentContentOfRange(nsIDOMRange *aRange, nsString &aParentTag)
|
||||||
return result;
|
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
|
NS_IMETHODIMP
|
||||||
nsHTMLEditor::RemoveBlockParent()
|
nsHTMLEditor::RemoveBlockParent()
|
||||||
|
|
|
@ -147,6 +147,8 @@ protected:
|
||||||
|
|
||||||
NS_IMETHOD ReParentContentOfRange(nsIDOMRange *aRange, nsString &aParentTag);
|
NS_IMETHOD ReParentContentOfRange(nsIDOMRange *aRange, nsString &aParentTag);
|
||||||
|
|
||||||
|
NS_IMETHOD CanContainBlock(nsString &aBlockChild, nsString &aBlockParent, PRBool &aCanContain);
|
||||||
|
|
||||||
// EVENT LISTENERS AND COMMAND ROUTING NEEDS WORK
|
// EVENT LISTENERS AND COMMAND ROUTING NEEDS WORK
|
||||||
// For now, the listners are tied to the nsTextEditor class
|
// For now, the listners are tied to the nsTextEditor class
|
||||||
//
|
//
|
||||||
|
|
|
@ -582,7 +582,9 @@ nsHTMLEditor::ReParentBlockContent(nsIDOMNode *aNode,
|
||||||
if ((NS_SUCCEEDED(result)) && leftNode && rightNode)
|
if ((NS_SUCCEEDED(result)) && leftNode && rightNode)
|
||||||
{
|
{
|
||||||
PRInt32 offsetInParent=0;
|
PRInt32 offsetInParent=0;
|
||||||
if (aBlockParentTag.EqualsIgnoreCase("body"))
|
PRBool canContain;
|
||||||
|
CanContainBlock(aParentTag, aBlockParentTag, canContain);
|
||||||
|
if (PR_TRUE==canContain)
|
||||||
{
|
{
|
||||||
result = nsIEditorSupport::GetChildOffset(leftNode, aBlockParentNode, offsetInParent);
|
result = nsIEditorSupport::GetChildOffset(leftNode, aBlockParentNode, offsetInParent);
|
||||||
NS_ASSERTION((NS_SUCCEEDED(result)), "bad result from GetChildOffset");
|
NS_ASSERTION((NS_SUCCEEDED(result)), "bad result from GetChildOffset");
|
||||||
|
@ -650,6 +652,22 @@ nsHTMLEditor::ReParentContentOfRange(nsIDOMRange *aRange, nsString &aParentTag)
|
||||||
return result;
|
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
|
NS_IMETHODIMP
|
||||||
nsHTMLEditor::RemoveBlockParent()
|
nsHTMLEditor::RemoveBlockParent()
|
||||||
|
|
|
@ -147,6 +147,8 @@ protected:
|
||||||
|
|
||||||
NS_IMETHOD ReParentContentOfRange(nsIDOMRange *aRange, nsString &aParentTag);
|
NS_IMETHOD ReParentContentOfRange(nsIDOMRange *aRange, nsString &aParentTag);
|
||||||
|
|
||||||
|
NS_IMETHOD CanContainBlock(nsString &aBlockChild, nsString &aBlockParent, PRBool &aCanContain);
|
||||||
|
|
||||||
// EVENT LISTENERS AND COMMAND ROUTING NEEDS WORK
|
// EVENT LISTENERS AND COMMAND ROUTING NEEDS WORK
|
||||||
// For now, the listners are tied to the nsTextEditor class
|
// 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
|
// hard-coded ChangeTextAttributes test -- font color red
|
||||||
case nsIDOMEvent::VK_1:
|
case nsIDOMEvent::VK_1:
|
||||||
|
case nsIDOMEvent::VK_F:
|
||||||
if (PR_TRUE==ctrlKey)
|
if (PR_TRUE==ctrlKey)
|
||||||
{
|
{
|
||||||
aProcessed=PR_TRUE;
|
aProcessed=PR_TRUE;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче