зеркало из https://github.com/mozilla/pjs.git
Bug 572618 - Make debugging the editor easier - Part 1: Replace all if(NS_FAILED) checks with NS_ENSURE_SUCCESS; r=roc
This commit is contained in:
Родитель
c3b8ed0a41
Коммит
dbee1fa3ae
|
@ -317,7 +317,7 @@ nsListCommand::GetCurrentState(nsIEditor *aEditor, const char* aTagName,
|
||||||
PRBool bMixed;
|
PRBool bMixed;
|
||||||
PRUnichar *tagStr;
|
PRUnichar *tagStr;
|
||||||
nsresult rv = GetListState(aEditor,&bMixed, &tagStr);
|
nsresult rv = GetListState(aEditor,&bMixed, &tagStr);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// Need to use mTagName????
|
// Need to use mTagName????
|
||||||
PRBool inList = (0 == nsCRT::strcmp(tagStr,
|
PRBool inList = (0 == nsCRT::strcmp(tagStr,
|
||||||
|
@ -380,7 +380,7 @@ nsListItemCommand::GetCurrentState(nsIEditor *aEditor, const char* aTagName,
|
||||||
|
|
||||||
PRBool bMixed, bLI, bDT, bDD;
|
PRBool bMixed, bLI, bDT, bDD;
|
||||||
nsresult rv = htmlEditor->GetListItemState(&bMixed, &bLI, &bDT, &bDD);
|
nsresult rv = htmlEditor->GetListItemState(&bMixed, &bLI, &bDT, &bDD);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
PRBool inList = PR_FALSE;
|
PRBool inList = PR_FALSE;
|
||||||
if (!bMixed)
|
if (!bMixed)
|
||||||
|
@ -414,7 +414,7 @@ nsListItemCommand::ToggleState(nsIEditor *aEditor, const char* aTagName)
|
||||||
rv = params->GetBooleanValue(STATE_ALL,&inList);
|
rv = params->GetBooleanValue(STATE_ALL,&inList);
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return rv;
|
return rv;
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
if (inList)
|
if (inList)
|
||||||
{
|
{
|
||||||
|
@ -422,7 +422,7 @@ nsListItemCommand::ToggleState(nsIEditor *aEditor, const char* aTagName)
|
||||||
PRBool bMixed;
|
PRBool bMixed;
|
||||||
PRUnichar *tagStr;
|
PRUnichar *tagStr;
|
||||||
rv = GetListState(aEditor,&bMixed, &tagStr);
|
rv = GetListState(aEditor,&bMixed, &tagStr);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (tagStr)
|
if (tagStr)
|
||||||
{
|
{
|
||||||
if (!bMixed)
|
if (!bMixed)
|
||||||
|
@ -461,7 +461,7 @@ nsRemoveListCommand::IsCommandEnabled(const char * aCommandName,
|
||||||
PRBool bMixed;
|
PRBool bMixed;
|
||||||
PRUnichar *tagStr;
|
PRUnichar *tagStr;
|
||||||
nsresult rv = GetListState(editor, &bMixed, &tagStr);
|
nsresult rv = GetListState(editor, &bMixed, &tagStr);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
*outCmdEnabled = bMixed ? PR_TRUE : (tagStr && *tagStr);
|
*outCmdEnabled = bMixed ? PR_TRUE : (tagStr && *tagStr);
|
||||||
|
|
||||||
|
@ -816,7 +816,7 @@ nsFontSizeStateCommand::GetCurrentState(nsIEditor *aEditor,
|
||||||
EmptyString(),
|
EmptyString(),
|
||||||
&firstHas, &anyHas, &allHas,
|
&firstHas, &anyHas, &allHas,
|
||||||
outStateString);
|
outStateString);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCAutoString tOutStateString;
|
nsCAutoString tOutStateString;
|
||||||
tOutStateString.AssignWithConversion(outStateString);
|
tOutStateString.AssignWithConversion(outStateString);
|
||||||
|
@ -851,15 +851,15 @@ nsFontSizeStateCommand::SetState(nsIEditor *aEditor, nsString& newState)
|
||||||
newState.EqualsLiteral("medium")) {
|
newState.EqualsLiteral("medium")) {
|
||||||
// remove any existing font size, big or small
|
// remove any existing font size, big or small
|
||||||
rv = htmlEditor->RemoveInlineProperty(fontAtom, NS_LITERAL_STRING("size"));
|
rv = htmlEditor->RemoveInlineProperty(fontAtom, NS_LITERAL_STRING("size"));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsIAtom> bigAtom = do_GetAtom("big");
|
nsCOMPtr<nsIAtom> bigAtom = do_GetAtom("big");
|
||||||
rv = htmlEditor->RemoveInlineProperty(bigAtom, EmptyString());
|
rv = htmlEditor->RemoveInlineProperty(bigAtom, EmptyString());
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsIAtom> smallAtom = do_GetAtom("small");
|
nsCOMPtr<nsIAtom> smallAtom = do_GetAtom("small");
|
||||||
rv = htmlEditor->RemoveInlineProperty(smallAtom, EmptyString());
|
rv = htmlEditor->RemoveInlineProperty(smallAtom, EmptyString());
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
} else {
|
} else {
|
||||||
// set the size
|
// set the size
|
||||||
rv = htmlEditor->SetInlineProperty(fontAtom, NS_LITERAL_STRING("size"),
|
rv = htmlEditor->SetInlineProperty(fontAtom, NS_LITERAL_STRING("size"),
|
||||||
|
@ -1150,7 +1150,7 @@ nsAbsolutePositioningCommand::ToggleState(nsIEditor *aEditor, const char* aTagNa
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMElement> elt;
|
nsCOMPtr<nsIDOMElement> elt;
|
||||||
nsresult rv = htmlEditor->GetAbsolutelyPositionedSelectionContainer(getter_AddRefs(elt));
|
nsresult rv = htmlEditor->GetAbsolutelyPositionedSelectionContainer(getter_AddRefs(elt));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
if (elt) {
|
if (elt) {
|
||||||
// we have to remove positioning on an element
|
// we have to remove positioning on an element
|
||||||
|
@ -1185,7 +1185,7 @@ nsDecreaseZIndexCommand::IsCommandEnabled(const char * aCommandName,
|
||||||
if (positionedElement) {
|
if (positionedElement) {
|
||||||
PRInt32 z;
|
PRInt32 z;
|
||||||
nsresult res = htmlEditor->GetElementZIndex(positionedElement, &z);
|
nsresult res = htmlEditor->GetElementZIndex(positionedElement, &z);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
*outCmdEnabled = (z > 0);
|
*outCmdEnabled = (z > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -262,7 +262,7 @@ nsComposerCommandsUpdater::PrimeUpdateTimer()
|
||||||
{
|
{
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
mUpdateTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
|
mUpdateTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
const PRUint32 kUpdateTimerDelay = 150;
|
const PRUint32 kUpdateTimerDelay = 150;
|
||||||
|
|
|
@ -76,7 +76,7 @@ GetPresContextFromEditor(nsIEditor *aEditor, nsPresContext **aResult)
|
||||||
|
|
||||||
nsCOMPtr<nsISelectionController> selCon;
|
nsCOMPtr<nsISelectionController> selCon;
|
||||||
nsresult rv = aEditor->GetSelectionController(getter_AddRefs(selCon));
|
nsresult rv = aEditor->GetSelectionController(getter_AddRefs(selCon));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (!selCon) return NS_ERROR_FAILURE;
|
if (!selCon) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
nsCOMPtr<nsIPresShell> presShell = do_QueryInterface(selCon);
|
nsCOMPtr<nsIPresShell> presShell = do_QueryInterface(selCon);
|
||||||
|
@ -116,7 +116,7 @@ nsSetDocumentOptionsCommand::DoCommandParams(const char *aCommandName,
|
||||||
|
|
||||||
nsRefPtr<nsPresContext> presContext;
|
nsRefPtr<nsPresContext> presContext;
|
||||||
nsresult rv = GetPresContextFromEditor(editor, getter_AddRefs(presContext));
|
nsresult rv = GetPresContextFromEditor(editor, getter_AddRefs(presContext));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (!presContext) return NS_ERROR_FAILURE;
|
if (!presContext) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
PRInt32 animationMode;
|
PRInt32 animationMode;
|
||||||
|
@ -136,11 +136,11 @@ nsSetDocumentOptionsCommand::DoCommandParams(const char *aCommandName,
|
||||||
if (!container) return NS_ERROR_FAILURE;
|
if (!container) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container, &rv));
|
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container, &rv));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (!docShell) return NS_ERROR_FAILURE;
|
if (!docShell) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
rv = docShell->SetAllowPlugins(allowPlugins);
|
rv = docShell->SetAllowPlugins(allowPlugins);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -167,7 +167,7 @@ nsSetDocumentOptionsCommand::GetCommandStateParams(const char *aCommandName,
|
||||||
// get pres context
|
// get pres context
|
||||||
nsRefPtr<nsPresContext> presContext;
|
nsRefPtr<nsPresContext> presContext;
|
||||||
rv = GetPresContextFromEditor(editor, getter_AddRefs(presContext));
|
rv = GetPresContextFromEditor(editor, getter_AddRefs(presContext));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (!presContext) return NS_ERROR_FAILURE;
|
if (!presContext) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
PRInt32 animationMode;
|
PRInt32 animationMode;
|
||||||
|
@ -178,7 +178,7 @@ nsSetDocumentOptionsCommand::GetCommandStateParams(const char *aCommandName,
|
||||||
// http://lxr.mozilla.org/seamonkey/source/modules/libpr0n/public/imgIContainer.idl
|
// http://lxr.mozilla.org/seamonkey/source/modules/libpr0n/public/imgIContainer.idl
|
||||||
rv = aParams->SetLongValue("imageAnimation",
|
rv = aParams->SetLongValue("imageAnimation",
|
||||||
presContext->ImageAnimationMode());
|
presContext->ImageAnimationMode());
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool allowPlugins;
|
PRBool allowPlugins;
|
||||||
|
@ -189,14 +189,14 @@ nsSetDocumentOptionsCommand::GetCommandStateParams(const char *aCommandName,
|
||||||
if (!container) return NS_ERROR_FAILURE;
|
if (!container) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container, &rv));
|
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container, &rv));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (!docShell) return NS_ERROR_FAILURE;
|
if (!docShell) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
rv = docShell->GetAllowPlugins(&allowPlugins);
|
rv = docShell->GetAllowPlugins(&allowPlugins);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
rv = aParams->SetBooleanValue("plugins", allowPlugins);
|
rv = aParams->SetBooleanValue("plugins", allowPlugins);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
|
@ -126,19 +126,19 @@ CreateControllerWithSingletonCommandTable(const nsCID& inCommandTableCID, nsICon
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIController> controller = do_CreateInstance("@mozilla.org/embedcomp/base-command-controller;1", &rv);
|
nsCOMPtr<nsIController> controller = do_CreateInstance("@mozilla.org/embedcomp/base-command-controller;1", &rv);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsIControllerCommandTable> composerCommandTable = do_GetService(inCommandTableCID, &rv);
|
nsCOMPtr<nsIControllerCommandTable> composerCommandTable = do_GetService(inCommandTableCID, &rv);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// this guy is a singleton, so make it immutable
|
// this guy is a singleton, so make it immutable
|
||||||
composerCommandTable->MakeImmutable();
|
composerCommandTable->MakeImmutable();
|
||||||
|
|
||||||
nsCOMPtr<nsIControllerContext> controllerContext = do_QueryInterface(controller, &rv);
|
nsCOMPtr<nsIControllerContext> controllerContext = do_QueryInterface(controller, &rv);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
rv = controllerContext->Init(composerCommandTable);
|
rv = controllerContext->Init(composerCommandTable);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
*aResult = controller;
|
*aResult = controller;
|
||||||
NS_ADDREF(*aResult);
|
NS_ADDREF(*aResult);
|
||||||
|
@ -154,7 +154,7 @@ nsHTMLEditorDocStateControllerConstructor(nsISupports *aOuter, REFNSIID aIID,
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIController> controller;
|
nsCOMPtr<nsIController> controller;
|
||||||
nsresult rv = CreateControllerWithSingletonCommandTable(kHTMLEditorDocStateCommandTableCID, getter_AddRefs(controller));
|
nsresult rv = CreateControllerWithSingletonCommandTable(kHTMLEditorDocStateCommandTableCID, getter_AddRefs(controller));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
return controller->QueryInterface(aIID, aResult);
|
return controller->QueryInterface(aIID, aResult);
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ nsHTMLEditorControllerConstructor(nsISupports *aOuter, REFNSIID aIID, void **aRe
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIController> controller;
|
nsCOMPtr<nsIController> controller;
|
||||||
nsresult rv = CreateControllerWithSingletonCommandTable(kHTMLEditorCommandTableCID, getter_AddRefs(controller));
|
nsresult rv = CreateControllerWithSingletonCommandTable(kHTMLEditorCommandTableCID, getter_AddRefs(controller));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
return controller->QueryInterface(aIID, aResult);
|
return controller->QueryInterface(aIID, aResult);
|
||||||
}
|
}
|
||||||
|
@ -179,10 +179,10 @@ nsHTMLEditorCommandTableConstructor(nsISupports *aOuter, REFNSIID aIID,
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIControllerCommandTable> commandTable =
|
nsCOMPtr<nsIControllerCommandTable> commandTable =
|
||||||
do_CreateInstance(NS_CONTROLLERCOMMANDTABLE_CONTRACTID, &rv);
|
do_CreateInstance(NS_CONTROLLERCOMMANDTABLE_CONTRACTID, &rv);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
rv = nsComposerController::RegisterHTMLEditorCommands(commandTable);
|
rv = nsComposerController::RegisterHTMLEditorCommands(commandTable);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// we don't know here whether we're being created as an instance,
|
// we don't know here whether we're being created as an instance,
|
||||||
// or a service, so we can't become immutable
|
// or a service, so we can't become immutable
|
||||||
|
@ -199,10 +199,10 @@ nsHTMLEditorDocStateCommandTableConstructor(nsISupports *aOuter, REFNSIID aIID,
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIControllerCommandTable> commandTable =
|
nsCOMPtr<nsIControllerCommandTable> commandTable =
|
||||||
do_CreateInstance(NS_CONTROLLERCOMMANDTABLE_CONTRACTID, &rv);
|
do_CreateInstance(NS_CONTROLLERCOMMANDTABLE_CONTRACTID, &rv);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
rv = nsComposerController::RegisterEditorDocStateCommands(commandTable);
|
rv = nsComposerController::RegisterEditorDocStateCommands(commandTable);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// we don't know here whether we're being created as an instance,
|
// we don't know here whether we're being created as an instance,
|
||||||
// or a service, so we can't become immutable
|
// or a service, so we can't become immutable
|
||||||
|
|
|
@ -174,15 +174,15 @@ nsEditingSession::MakeWindowEditable(nsIDOMWindow *aWindow,
|
||||||
// if all this does is setup listeners and I don't need listeners,
|
// if all this does is setup listeners and I don't need listeners,
|
||||||
// can't this step be ignored?? (based on aDoAfterURILoad)
|
// can't this step be ignored?? (based on aDoAfterURILoad)
|
||||||
rv = PrepareForEditing(aWindow);
|
rv = PrepareForEditing(aWindow);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsIEditorDocShell> editorDocShell;
|
nsCOMPtr<nsIEditorDocShell> editorDocShell;
|
||||||
rv = GetEditorDocShellFromWindow(aWindow, getter_AddRefs(editorDocShell));
|
rv = GetEditorDocShellFromWindow(aWindow, getter_AddRefs(editorDocShell));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// set the flag on the docShell to say that it's editable
|
// set the flag on the docShell to say that it's editable
|
||||||
rv = editorDocShell->MakeEditable(aDoAfterUriLoad);
|
rv = editorDocShell->MakeEditable(aDoAfterUriLoad);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// Setup commands common to plaintext and html editors,
|
// Setup commands common to plaintext and html editors,
|
||||||
// including the document creation observers
|
// including the document creation observers
|
||||||
|
@ -191,7 +191,7 @@ nsEditingSession::MakeWindowEditable(nsIDOMWindow *aWindow,
|
||||||
aWindow,
|
aWindow,
|
||||||
static_cast<nsIEditingSession*>(this),
|
static_cast<nsIEditingSession*>(this),
|
||||||
&mBaseCommandControllerId);
|
&mBaseCommandControllerId);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// The second is a controller to monitor doc state,
|
// The second is a controller to monitor doc state,
|
||||||
// such as creation and "dirty flag"
|
// such as creation and "dirty flag"
|
||||||
|
@ -199,7 +199,7 @@ nsEditingSession::MakeWindowEditable(nsIDOMWindow *aWindow,
|
||||||
aWindow,
|
aWindow,
|
||||||
static_cast<nsIEditingSession*>(this),
|
static_cast<nsIEditingSession*>(this),
|
||||||
&mDocStateControllerId);
|
&mDocStateControllerId);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// aDoAfterUriLoad can be false only when making an existing window editable
|
// aDoAfterUriLoad can be false only when making an existing window editable
|
||||||
if (!aDoAfterUriLoad)
|
if (!aDoAfterUriLoad)
|
||||||
|
@ -274,7 +274,7 @@ nsEditingSession::WindowIsEditable(nsIDOMWindow *aWindow, PRBool *outIsEditable)
|
||||||
nsCOMPtr<nsIEditorDocShell> editorDocShell;
|
nsCOMPtr<nsIEditorDocShell> editorDocShell;
|
||||||
nsresult rv = GetEditorDocShellFromWindow(aWindow,
|
nsresult rv = GetEditorDocShellFromWindow(aWindow,
|
||||||
getter_AddRefs(editorDocShell));
|
getter_AddRefs(editorDocShell));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
return editorDocShell->GetEditable(outIsEditable);
|
return editorDocShell->GetEditable(outIsEditable);
|
||||||
}
|
}
|
||||||
|
@ -418,7 +418,7 @@ nsEditingSession::SetupEditorOnWindow(nsIDOMWindow *aWindow)
|
||||||
// This allows notification of error state
|
// This allows notification of error state
|
||||||
// even if we don't create an editor
|
// even if we don't create an editor
|
||||||
rv = mStateMaintainer->Init(aWindow);
|
rv = mStateMaintainer->Init(aWindow);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
if (mEditorStatus != eEditorCreationInProgress)
|
if (mEditorStatus != eEditorCreationInProgress)
|
||||||
{
|
{
|
||||||
|
@ -437,19 +437,19 @@ nsEditingSession::SetupEditorOnWindow(nsIDOMWindow *aWindow)
|
||||||
if (!utils) return NS_ERROR_FAILURE;
|
if (!utils) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
rv = utils->GetImageAnimationMode(&mImageAnimationMode);
|
rv = utils->GetImageAnimationMode(&mImageAnimationMode);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
utils->SetImageAnimationMode(imgIContainer::kDontAnimMode);
|
utils->SetImageAnimationMode(imgIContainer::kDontAnimMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create and set editor
|
// create and set editor
|
||||||
nsCOMPtr<nsIEditorDocShell> editorDocShell = do_QueryInterface(docShell, &rv);
|
nsCOMPtr<nsIEditorDocShell> editorDocShell = do_QueryInterface(docShell, &rv);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsIEditor> editor = do_CreateInstance(classString, &rv);
|
nsCOMPtr<nsIEditor> editor = do_CreateInstance(classString, &rv);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
// set the editor on the docShell. The docShell now owns it.
|
// set the editor on the docShell. The docShell now owns it.
|
||||||
rv = editorDocShell->SetEditor(editor);
|
rv = editorDocShell->SetEditor(editor);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// setup the HTML editor command controller
|
// setup the HTML editor command controller
|
||||||
if (needHTMLController)
|
if (needHTMLController)
|
||||||
|
@ -458,38 +458,38 @@ nsEditingSession::SetupEditorOnWindow(nsIDOMWindow *aWindow)
|
||||||
rv = SetupEditorCommandController("@mozilla.org/editor/htmleditorcontroller;1",
|
rv = SetupEditorCommandController("@mozilla.org/editor/htmleditorcontroller;1",
|
||||||
aWindow, editor,
|
aWindow, editor,
|
||||||
&mHTMLCommandControllerId);
|
&mHTMLCommandControllerId);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set mimetype on editor
|
// Set mimetype on editor
|
||||||
rv = editor->SetContentsMIMEType(mimeCType.get());
|
rv = editor->SetContentsMIMEType(mimeCType.get());
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsIContentViewer> contentViewer;
|
nsCOMPtr<nsIContentViewer> contentViewer;
|
||||||
rv = docShell->GetContentViewer(getter_AddRefs(contentViewer));
|
rv = docShell->GetContentViewer(getter_AddRefs(contentViewer));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (!contentViewer) return NS_ERROR_FAILURE;
|
if (!contentViewer) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||||
rv = contentViewer->GetDOMDocument(getter_AddRefs(domDoc));
|
rv = contentViewer->GetDOMDocument(getter_AddRefs(domDoc));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (!domDoc) return NS_ERROR_FAILURE;
|
if (!domDoc) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
// Set up as a doc state listener
|
// Set up as a doc state listener
|
||||||
// Important! We must have this to broadcast the "obs_documentCreated" message
|
// Important! We must have this to broadcast the "obs_documentCreated" message
|
||||||
rv = editor->AddDocumentStateListener(mStateMaintainer);
|
rv = editor->AddDocumentStateListener(mStateMaintainer);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// XXXbz we really shouldn't need a presShell here!
|
// XXXbz we really shouldn't need a presShell here!
|
||||||
nsCOMPtr<nsIPresShell> presShell;
|
nsCOMPtr<nsIPresShell> presShell;
|
||||||
rv = docShell->GetPresShell(getter_AddRefs(presShell));
|
rv = docShell->GetPresShell(getter_AddRefs(presShell));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (!presShell) return NS_ERROR_FAILURE;
|
if (!presShell) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
nsCOMPtr<nsISelectionController> selCon = do_QueryInterface(presShell);
|
nsCOMPtr<nsISelectionController> selCon = do_QueryInterface(presShell);
|
||||||
rv = editor->Init(domDoc, presShell, nsnull /* root content */,
|
rv = editor->Init(domDoc, presShell, nsnull /* root content */,
|
||||||
selCon, mEditorFlags);
|
selCon, mEditorFlags);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
editor->GetSelection(getter_AddRefs(selection));
|
editor->GetSelection(getter_AddRefs(selection));
|
||||||
|
@ -497,7 +497,7 @@ nsEditingSession::SetupEditorOnWindow(nsIDOMWindow *aWindow)
|
||||||
if (!selPriv) return NS_ERROR_FAILURE;
|
if (!selPriv) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
rv = selPriv->AddSelectionListener(mStateMaintainer);
|
rv = selPriv->AddSelectionListener(mStateMaintainer);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// and as a transaction listener
|
// and as a transaction listener
|
||||||
nsCOMPtr<nsITransactionManager> txnMgr;
|
nsCOMPtr<nsITransactionManager> txnMgr;
|
||||||
|
@ -507,7 +507,7 @@ nsEditingSession::SetupEditorOnWindow(nsIDOMWindow *aWindow)
|
||||||
|
|
||||||
// Set context on all controllers to be the editor
|
// Set context on all controllers to be the editor
|
||||||
rv = SetEditorOnControllers(aWindow, editor);
|
rv = SetEditorOnControllers(aWindow, editor);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// Everything went fine!
|
// Everything went fine!
|
||||||
mEditorStatus = eEditorOK;
|
mEditorStatus = eEditorOK;
|
||||||
|
@ -632,7 +632,7 @@ nsEditingSession::GetEditorForWindow(nsIDOMWindow *aWindow,
|
||||||
nsCOMPtr<nsIEditorDocShell> editorDocShell;
|
nsCOMPtr<nsIEditorDocShell> editorDocShell;
|
||||||
nsresult rv = GetEditorDocShellFromWindow(aWindow,
|
nsresult rv = GetEditorDocShellFromWindow(aWindow,
|
||||||
getter_AddRefs(editorDocShell));
|
getter_AddRefs(editorDocShell));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
return editorDocShell->GetEditor(outEditor);
|
return editorDocShell->GetEditor(outEditor);
|
||||||
}
|
}
|
||||||
|
@ -837,11 +837,11 @@ nsEditingSession::OnLocationChange(nsIWebProgress *aWebProgress,
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMWindow> domWindow;
|
nsCOMPtr<nsIDOMWindow> domWindow;
|
||||||
nsresult rv = aWebProgress->GetDOMWindow(getter_AddRefs(domWindow));
|
nsresult rv = aWebProgress->GetDOMWindow(getter_AddRefs(domWindow));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||||
rv = domWindow->GetDocument(getter_AddRefs(domDoc));
|
rv = domWindow->GetDocument(getter_AddRefs(domDoc));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
|
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
|
||||||
if (!doc) return NS_ERROR_FAILURE;
|
if (!doc) return NS_ERROR_FAILURE;
|
||||||
|
@ -1054,7 +1054,7 @@ nsEditingSession::EndDocumentLoad(nsIWebProgress *aWebProgress,
|
||||||
}
|
}
|
||||||
|
|
||||||
mLoadBlankDocTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
|
mLoadBlankDocTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
mEditorStatus = eEditorCreationInProgress;
|
mEditorStatus = eEditorCreationInProgress;
|
||||||
mDocShell = do_GetWeakReference(docShell);
|
mDocShell = do_GetWeakReference(docShell);
|
||||||
|
@ -1241,11 +1241,11 @@ nsEditingSession::SetupEditorCommandController(
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIDOMWindowInternal> domWindowInt =
|
nsCOMPtr<nsIDOMWindowInternal> domWindowInt =
|
||||||
do_QueryInterface(aWindow, &rv);
|
do_QueryInterface(aWindow, &rv);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsIControllers> controllers;
|
nsCOMPtr<nsIControllers> controllers;
|
||||||
rv = domWindowInt->GetControllers(getter_AddRefs(controllers));
|
rv = domWindowInt->GetControllers(getter_AddRefs(controllers));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// We only have to create each singleton controller once
|
// We only have to create each singleton controller once
|
||||||
// We know this has happened once we have a controllerId value
|
// We know this has happened once we have a controllerId value
|
||||||
|
@ -1254,17 +1254,17 @@ nsEditingSession::SetupEditorCommandController(
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIController> controller;
|
nsCOMPtr<nsIController> controller;
|
||||||
controller = do_CreateInstance(aControllerClassName, &rv);
|
controller = do_CreateInstance(aControllerClassName, &rv);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// We must insert at head of the list to be sure our
|
// We must insert at head of the list to be sure our
|
||||||
// controller is found before other implementations
|
// controller is found before other implementations
|
||||||
// (e.g., not-implemented versions by browser)
|
// (e.g., not-implemented versions by browser)
|
||||||
rv = controllers->InsertControllerAt(0, controller);
|
rv = controllers->InsertControllerAt(0, controller);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// Remember the ID for the controller
|
// Remember the ID for the controller
|
||||||
rv = controllers->GetControllerId(controller, aControllerId);
|
rv = controllers->GetControllerId(controller, aControllerId);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the context
|
// Set the context
|
||||||
|
@ -1286,25 +1286,25 @@ nsEditingSession::SetEditorOnControllers(nsIDOMWindow *aWindow,
|
||||||
// set the editor on the controller
|
// set the editor on the controller
|
||||||
nsCOMPtr<nsIDOMWindowInternal> domWindowInt =
|
nsCOMPtr<nsIDOMWindowInternal> domWindowInt =
|
||||||
do_QueryInterface(aWindow, &rv);
|
do_QueryInterface(aWindow, &rv);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsIControllers> controllers;
|
nsCOMPtr<nsIControllers> controllers;
|
||||||
rv = domWindowInt->GetControllers(getter_AddRefs(controllers));
|
rv = domWindowInt->GetControllers(getter_AddRefs(controllers));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsISupports> editorAsISupports = do_QueryInterface(aEditor);
|
nsCOMPtr<nsISupports> editorAsISupports = do_QueryInterface(aEditor);
|
||||||
if (mBaseCommandControllerId)
|
if (mBaseCommandControllerId)
|
||||||
{
|
{
|
||||||
rv = SetContextOnControllerById(controllers, editorAsISupports,
|
rv = SetContextOnControllerById(controllers, editorAsISupports,
|
||||||
mBaseCommandControllerId);
|
mBaseCommandControllerId);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mDocStateControllerId)
|
if (mDocStateControllerId)
|
||||||
{
|
{
|
||||||
rv = SetContextOnControllerById(controllers, editorAsISupports,
|
rv = SetContextOnControllerById(controllers, editorAsISupports,
|
||||||
mDocStateControllerId);
|
mDocStateControllerId);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mHTMLCommandControllerId)
|
if (mHTMLCommandControllerId)
|
||||||
|
|
|
@ -180,7 +180,7 @@ NS_IMETHODIMP ChangeCSSInlineStyleTxn::DoTransaction(void)
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
|
nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
|
||||||
nsresult result = inlineStyles->GetStyle(getter_AddRefs(cssDecl));
|
nsresult result = inlineStyles->GetStyle(getter_AddRefs(cssDecl));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!cssDecl) return NS_ERROR_NULL_POINTER;
|
if (!cssDecl) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
nsAutoString propertyNameString;
|
nsAutoString propertyNameString;
|
||||||
|
@ -188,11 +188,11 @@ NS_IMETHODIMP ChangeCSSInlineStyleTxn::DoTransaction(void)
|
||||||
|
|
||||||
NS_NAMED_LITERAL_STRING(styleAttr, "style");
|
NS_NAMED_LITERAL_STRING(styleAttr, "style");
|
||||||
result = mElement->HasAttribute(styleAttr, &mUndoAttributeWasSet);
|
result = mElement->HasAttribute(styleAttr, &mUndoAttributeWasSet);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
|
|
||||||
nsAutoString values;
|
nsAutoString values;
|
||||||
result = cssDecl->GetPropertyValue(propertyNameString, values);
|
result = cssDecl->GetPropertyValue(propertyNameString, values);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
mUndoValue.Assign(values);
|
mUndoValue.Assign(values);
|
||||||
|
|
||||||
// does this property accept more than 1 value ?
|
// does this property accept more than 1 value ?
|
||||||
|
@ -211,26 +211,26 @@ NS_IMETHODIMP ChangeCSSInlineStyleTxn::DoTransaction(void)
|
||||||
RemoveValueFromListOfValues(values, mValue);
|
RemoveValueFromListOfValues(values, mValue);
|
||||||
if (values.IsEmpty()) {
|
if (values.IsEmpty()) {
|
||||||
result = cssDecl->RemoveProperty(propertyNameString, returnString);
|
result = cssDecl->RemoveProperty(propertyNameString, returnString);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
nsAutoString priority;
|
nsAutoString priority;
|
||||||
result = cssDecl->GetPropertyPriority(propertyNameString, priority);
|
result = cssDecl->GetPropertyPriority(propertyNameString, priority);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
result = cssDecl->SetProperty(propertyNameString, values,
|
result = cssDecl->SetProperty(propertyNameString, values,
|
||||||
priority);
|
priority);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result = cssDecl->RemoveProperty(propertyNameString, returnString);
|
result = cssDecl->RemoveProperty(propertyNameString, returnString);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
nsAutoString priority;
|
nsAutoString priority;
|
||||||
result = cssDecl->GetPropertyPriority(propertyNameString, priority);
|
result = cssDecl->GetPropertyPriority(propertyNameString, priority);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (multiple) {
|
if (multiple) {
|
||||||
// the property can have more than one value, let's add
|
// the property can have more than one value, let's add
|
||||||
// the value we have to add to the others
|
// the value we have to add to the others
|
||||||
|
@ -243,16 +243,16 @@ NS_IMETHODIMP ChangeCSSInlineStyleTxn::DoTransaction(void)
|
||||||
values.Assign(mValue);
|
values.Assign(mValue);
|
||||||
result = cssDecl->SetProperty(propertyNameString, values,
|
result = cssDecl->SetProperty(propertyNameString, values,
|
||||||
priority);
|
priority);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// let's be sure we don't keep an empty style attribute
|
// let's be sure we don't keep an empty style attribute
|
||||||
PRUint32 length;
|
PRUint32 length;
|
||||||
result = cssDecl->GetLength(&length);
|
result = cssDecl->GetLength(&length);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!length) {
|
if (!length) {
|
||||||
result = mElement->RemoveAttribute(styleAttr);
|
result = mElement->RemoveAttribute(styleAttr);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mRedoAttributeWasSet = PR_TRUE;
|
mRedoAttributeWasSet = PR_TRUE;
|
||||||
|
@ -276,7 +276,7 @@ nsresult ChangeCSSInlineStyleTxn::SetStyle(PRBool aAttributeWasSet,
|
||||||
if (!inlineStyles) return NS_ERROR_NULL_POINTER;
|
if (!inlineStyles) return NS_ERROR_NULL_POINTER;
|
||||||
nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
|
nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
|
||||||
result = inlineStyles->GetStyle(getter_AddRefs(cssDecl));
|
result = inlineStyles->GetStyle(getter_AddRefs(cssDecl));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!cssDecl) return NS_ERROR_NULL_POINTER;
|
if (!cssDecl) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
if (aValue.IsEmpty()) {
|
if (aValue.IsEmpty()) {
|
||||||
|
@ -288,7 +288,7 @@ nsresult ChangeCSSInlineStyleTxn::SetStyle(PRBool aAttributeWasSet,
|
||||||
// let's recreate the declaration as it was
|
// let's recreate the declaration as it was
|
||||||
nsAutoString priority;
|
nsAutoString priority;
|
||||||
result = cssDecl->GetPropertyPriority(propertyNameString, priority);
|
result = cssDecl->GetPropertyPriority(propertyNameString, priority);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
result = cssDecl->SetProperty(propertyNameString, aValue, priority);
|
result = cssDecl->SetProperty(propertyNameString, aValue, priority);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ NS_IMETHODIMP CreateElementTxn::DoTransaction(void)
|
||||||
|
|
||||||
//new call to use instead to get proper HTML element, bug# 39919
|
//new call to use instead to get proper HTML element, bug# 39919
|
||||||
nsresult result = mEditor->CreateHTMLContent(mTag, getter_AddRefs(newContent));
|
nsresult result = mEditor->CreateHTMLContent(mTag, getter_AddRefs(newContent));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
nsCOMPtr<nsIDOMElement>newElement = do_QueryInterface(newContent);
|
nsCOMPtr<nsIDOMElement>newElement = do_QueryInterface(newContent);
|
||||||
if (!newElement) return NS_ERROR_NULL_POINTER;
|
if (!newElement) return NS_ERROR_NULL_POINTER;
|
||||||
mNewNode = do_QueryInterface(newElement);
|
mNewNode = do_QueryInterface(newElement);
|
||||||
|
@ -149,10 +149,10 @@ NS_IMETHODIMP CreateElementTxn::DoTransaction(void)
|
||||||
if (mOffsetInParent>count)
|
if (mOffsetInParent>count)
|
||||||
mOffsetInParent = count;
|
mOffsetInParent = count;
|
||||||
result = childNodes->Item(mOffsetInParent, getter_AddRefs(mRefNode));
|
result = childNodes->Item(mOffsetInParent, getter_AddRefs(mRefNode));
|
||||||
if (NS_FAILED(result)) return result; // note, it's ok for mRefNode to be null. that means append
|
NS_ENSURE_SUCCESS(result, result); // note, it's ok for mRefNode to be null. that means append
|
||||||
|
|
||||||
result = mParent->InsertBefore(mNewNode, mRefNode, getter_AddRefs(resultNode));
|
result = mParent->InsertBefore(mNewNode, mRefNode, getter_AddRefs(resultNode));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
|
|
||||||
// only set selection to insertion point if editor gives permission
|
// only set selection to insertion point if editor gives permission
|
||||||
PRBool bAdjustSelection;
|
PRBool bAdjustSelection;
|
||||||
|
@ -161,12 +161,12 @@ NS_IMETHODIMP CreateElementTxn::DoTransaction(void)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
result = mEditor->GetSelection(getter_AddRefs(selection));
|
result = mEditor->GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
PRInt32 offset=0;
|
PRInt32 offset=0;
|
||||||
result = nsEditor::GetChildOffset(mNewNode, mParent, offset);
|
result = nsEditor::GetChildOffset(mNewNode, mParent, offset);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
|
|
||||||
result = selection->Collapse(mParent, offset+1);
|
result = selection->Collapse(mParent, offset+1);
|
||||||
NS_ASSERTION((NS_SUCCEEDED(result)), "selection could not be collapsed after insert.");
|
NS_ASSERTION((NS_SUCCEEDED(result)), "selection could not be collapsed after insert.");
|
||||||
|
|
|
@ -196,7 +196,7 @@ NS_IMETHODIMP DeleteRangeTxn::DoTransaction(void)
|
||||||
result = EditAggregateTxn::DoTransaction();
|
result = EditAggregateTxn::DoTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
|
|
||||||
// only set selection to deletion point if editor gives permission
|
// only set selection to deletion point if editor gives permission
|
||||||
PRBool bAdjustSelection;
|
PRBool bAdjustSelection;
|
||||||
|
@ -205,7 +205,7 @@ NS_IMETHODIMP DeleteRangeTxn::DoTransaction(void)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
result = mEditor->GetSelection(getter_AddRefs(selection));
|
result = mEditor->GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
result = selection->Collapse(mStartParent, mStartOffset);
|
result = selection->Collapse(mStartParent, mStartOffset);
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,7 @@ DeleteRangeTxn::CreateTxnsToDeleteBetween(nsIDOMNode *aStartParent,
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMNodeList> children;
|
nsCOMPtr<nsIDOMNodeList> children;
|
||||||
result = aStartParent->GetChildNodes(getter_AddRefs(children));
|
result = aStartParent->GetChildNodes(getter_AddRefs(children));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!children) return NS_ERROR_NULL_POINTER;
|
if (!children) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -287,7 +287,7 @@ DeleteRangeTxn::CreateTxnsToDeleteBetween(nsIDOMNode *aStartParent,
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMNode> child;
|
nsCOMPtr<nsIDOMNode> child;
|
||||||
result = children->Item(i, getter_AddRefs(child));
|
result = children->Item(i, getter_AddRefs(child));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!child) return NS_ERROR_NULL_POINTER;
|
if (!child) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
nsRefPtr<DeleteElementTxn> txn = new DeleteElementTxn();
|
nsRefPtr<DeleteElementTxn> txn = new DeleteElementTxn();
|
||||||
|
@ -345,7 +345,7 @@ NS_IMETHODIMP DeleteRangeTxn::CreateTxnsToDeleteNodesBetween()
|
||||||
if (!iter) return NS_ERROR_NULL_POINTER;
|
if (!iter) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
nsresult result = iter->Init(mRange);
|
nsresult result = iter->Init(mRange);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
|
|
||||||
while (!iter->IsDone() && NS_SUCCEEDED(result))
|
while (!iter->IsDone() && NS_SUCCEEDED(result))
|
||||||
{
|
{
|
||||||
|
|
|
@ -107,7 +107,7 @@ NS_IMETHODIMP DeleteTextTxn::DoTransaction(void)
|
||||||
nsresult result = mElement->SubstringData(mOffset, mNumCharsToDelete, mDeletedText);
|
nsresult result = mElement->SubstringData(mOffset, mNumCharsToDelete, mDeletedText);
|
||||||
NS_ASSERTION(NS_SUCCEEDED(result), "could not get text to delete.");
|
NS_ASSERTION(NS_SUCCEEDED(result), "could not get text to delete.");
|
||||||
result = mElement->DeleteData(mOffset, mNumCharsToDelete);
|
result = mElement->DeleteData(mOffset, mNumCharsToDelete);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
|
|
||||||
if (mRangeUpdater)
|
if (mRangeUpdater)
|
||||||
mRangeUpdater->SelAdjDeleteText(mElement, mOffset, mNumCharsToDelete);
|
mRangeUpdater->SelAdjDeleteText(mElement, mOffset, mNumCharsToDelete);
|
||||||
|
@ -119,7 +119,7 @@ NS_IMETHODIMP DeleteTextTxn::DoTransaction(void)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
result = mEditor->GetSelection(getter_AddRefs(selection));
|
result = mEditor->GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
result = selection->Collapse(mElement, mOffset);
|
result = selection->Collapse(mElement, mOffset);
|
||||||
NS_ASSERTION((NS_SUCCEEDED(result)), "selection could not be collapsed after undo of deletetext.");
|
NS_ASSERTION((NS_SUCCEEDED(result)), "selection could not be collapsed after undo of deletetext.");
|
||||||
|
|
|
@ -109,7 +109,7 @@ NS_IMETHODIMP InsertElementTxn::DoTransaction(void)
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMNodeList> childNodes;
|
nsCOMPtr<nsIDOMNodeList> childNodes;
|
||||||
nsresult result = mParent->GetChildNodes(getter_AddRefs(childNodes));
|
nsresult result = mParent->GetChildNodes(getter_AddRefs(childNodes));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
nsCOMPtr<nsIDOMNode>refNode;
|
nsCOMPtr<nsIDOMNode>refNode;
|
||||||
if (childNodes)
|
if (childNodes)
|
||||||
{
|
{
|
||||||
|
@ -119,7 +119,7 @@ NS_IMETHODIMP InsertElementTxn::DoTransaction(void)
|
||||||
// -1 is sentinel value meaning "append at end"
|
// -1 is sentinel value meaning "append at end"
|
||||||
if (mOffset == -1) mOffset = count;
|
if (mOffset == -1) mOffset = count;
|
||||||
result = childNodes->Item(mOffset, getter_AddRefs(refNode));
|
result = childNodes->Item(mOffset, getter_AddRefs(refNode));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
// note, it's ok for mRefNode to be null. that means append
|
// note, it's ok for mRefNode to be null. that means append
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ NS_IMETHODIMP InsertElementTxn::DoTransaction(void)
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMNode> resultNode;
|
nsCOMPtr<nsIDOMNode> resultNode;
|
||||||
result = mParent->InsertBefore(mNode, refNode, getter_AddRefs(resultNode));
|
result = mParent->InsertBefore(mNode, refNode, getter_AddRefs(resultNode));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!resultNode) return NS_ERROR_NULL_POINTER;
|
if (!resultNode) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
// only set selection to insertion point if editor gives permission
|
// only set selection to insertion point if editor gives permission
|
||||||
|
@ -137,7 +137,7 @@ NS_IMETHODIMP InsertElementTxn::DoTransaction(void)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
result = mEditor->GetSelection(getter_AddRefs(selection));
|
result = mEditor->GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
// place the selection just after the inserted element
|
// place the selection just after the inserted element
|
||||||
selection->Collapse(mParent, mOffset+1);
|
selection->Collapse(mParent, mOffset+1);
|
||||||
|
|
|
@ -104,7 +104,7 @@ NS_IMETHODIMP InsertTextTxn::DoTransaction(void)
|
||||||
if (!mElement || !mEditor) { return NS_ERROR_NOT_INITIALIZED; }
|
if (!mElement || !mEditor) { return NS_ERROR_NOT_INITIALIZED; }
|
||||||
|
|
||||||
nsresult result = mElement->InsertData(mOffset, mStringToInsert);
|
nsresult result = mElement->InsertData(mOffset, mStringToInsert);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
|
|
||||||
// only set selection to insertion point if editor gives permission
|
// only set selection to insertion point if editor gives permission
|
||||||
PRBool bAdjustSelection;
|
PRBool bAdjustSelection;
|
||||||
|
@ -113,7 +113,7 @@ NS_IMETHODIMP InsertTextTxn::DoTransaction(void)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
result = mEditor->GetSelection(getter_AddRefs(selection));
|
result = mEditor->GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
result = selection->Collapse(mElement, mOffset+mStringToInsert.Length());
|
result = selection->Collapse(mElement, mOffset+mStringToInsert.Length());
|
||||||
NS_ASSERTION((NS_SUCCEEDED(result)), "selection could not be collapsed after insert.");
|
NS_ASSERTION((NS_SUCCEEDED(result)), "selection could not be collapsed after insert.");
|
||||||
|
|
|
@ -76,7 +76,7 @@ NS_IMETHODIMP JoinElementTxn::Init(nsEditor *aEditor,
|
||||||
mLeftNode = do_QueryInterface(aLeftNode);
|
mLeftNode = do_QueryInterface(aLeftNode);
|
||||||
nsCOMPtr<nsIDOMNode>leftParent;
|
nsCOMPtr<nsIDOMNode>leftParent;
|
||||||
nsresult result = mLeftNode->GetParentNode(getter_AddRefs(leftParent));
|
nsresult result = mLeftNode->GetParentNode(getter_AddRefs(leftParent));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!mEditor->IsModifiableNode(leftParent)) {
|
if (!mEditor->IsModifiableNode(leftParent)) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -104,13 +104,13 @@ NS_IMETHODIMP JoinElementTxn::DoTransaction(void)
|
||||||
// get the parent node
|
// get the parent node
|
||||||
nsCOMPtr<nsIDOMNode>leftParent;
|
nsCOMPtr<nsIDOMNode>leftParent;
|
||||||
nsresult result = mLeftNode->GetParentNode(getter_AddRefs(leftParent));
|
nsresult result = mLeftNode->GetParentNode(getter_AddRefs(leftParent));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!leftParent) return NS_ERROR_NULL_POINTER;
|
if (!leftParent) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
// verify that mLeftNode and mRightNode have the same parent
|
// verify that mLeftNode and mRightNode have the same parent
|
||||||
nsCOMPtr<nsIDOMNode>rightParent;
|
nsCOMPtr<nsIDOMNode>rightParent;
|
||||||
result = mRightNode->GetParentNode(getter_AddRefs(rightParent));
|
result = mRightNode->GetParentNode(getter_AddRefs(rightParent));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!rightParent) return NS_ERROR_NULL_POINTER;
|
if (!rightParent) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
if (leftParent==rightParent)
|
if (leftParent==rightParent)
|
||||||
|
@ -126,7 +126,7 @@ NS_IMETHODIMP JoinElementTxn::DoTransaction(void)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMNodeList> childNodes;
|
nsCOMPtr<nsIDOMNodeList> childNodes;
|
||||||
result = mLeftNode->GetChildNodes(getter_AddRefs(childNodes));
|
result = mLeftNode->GetChildNodes(getter_AddRefs(childNodes));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (childNodes)
|
if (childNodes)
|
||||||
{
|
{
|
||||||
childNodes->GetLength(&mOffset);
|
childNodes->GetLength(&mOffset);
|
||||||
|
|
|
@ -93,14 +93,14 @@ NS_IMETHODIMP PlaceholderTxn::UndoTransaction(void)
|
||||||
{
|
{
|
||||||
// undo txns
|
// undo txns
|
||||||
nsresult res = EditAggregateTxn::UndoTransaction();
|
nsresult res = EditAggregateTxn::UndoTransaction();
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
if (!mStartSel) return NS_ERROR_NULL_POINTER;
|
if (!mStartSel) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
// now restore selection
|
// now restore selection
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
res = mEditor->GetSelection(getter_AddRefs(selection));
|
res = mEditor->GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
return mStartSel->RestoreSelection(selection);
|
return mStartSel->RestoreSelection(selection);
|
||||||
}
|
}
|
||||||
|
@ -110,12 +110,12 @@ NS_IMETHODIMP PlaceholderTxn::RedoTransaction(void)
|
||||||
{
|
{
|
||||||
// redo txns
|
// redo txns
|
||||||
nsresult res = EditAggregateTxn::RedoTransaction();
|
nsresult res = EditAggregateTxn::RedoTransaction();
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// now restore selection
|
// now restore selection
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
res = mEditor->GetSelection(getter_AddRefs(selection));
|
res = mEditor->GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
return mEndSel.RestoreSelection(selection);
|
return mEndSel.RestoreSelection(selection);
|
||||||
}
|
}
|
||||||
|
@ -290,7 +290,7 @@ NS_IMETHODIMP PlaceholderTxn::RememberEndingSelection()
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
nsresult res = mEditor->GetSelection(getter_AddRefs(selection));
|
nsresult res = mEditor->GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
return mEndSel.SaveSelection(selection);
|
return mEndSel.SaveSelection(selection);
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ nsresult SetDocTitleTxn::SetDomTitle(const nsAString& aTitle)
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMNodeList> titleList;
|
nsCOMPtr<nsIDOMNodeList> titleList;
|
||||||
res = domDoc->GetElementsByTagName(NS_LITERAL_STRING("title"), getter_AddRefs(titleList));
|
res = domDoc->GetElementsByTagName(NS_LITERAL_STRING("title"), getter_AddRefs(titleList));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// First assume we will NOT really do anything
|
// First assume we will NOT really do anything
|
||||||
// (transaction will not be pushed on stack)
|
// (transaction will not be pushed on stack)
|
||||||
|
@ -101,7 +101,7 @@ nsresult SetDocTitleTxn::SetDomTitle(const nsAString& aTitle)
|
||||||
if(titleList)
|
if(titleList)
|
||||||
{
|
{
|
||||||
res = titleList->Item(0, getter_AddRefs(titleNode));
|
res = titleList->Item(0, getter_AddRefs(titleNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (titleNode)
|
if (titleNode)
|
||||||
{
|
{
|
||||||
// Delete existing child textnode of title node
|
// Delete existing child textnode of title node
|
||||||
|
@ -134,7 +134,7 @@ nsresult SetDocTitleTxn::SetDomTitle(const nsAString& aTitle)
|
||||||
// Get the <HEAD> node, create a <TITLE> and insert it under the HEAD
|
// Get the <HEAD> node, create a <TITLE> and insert it under the HEAD
|
||||||
nsCOMPtr<nsIDOMNodeList> headList;
|
nsCOMPtr<nsIDOMNodeList> headList;
|
||||||
res = domDoc->GetElementsByTagName(NS_LITERAL_STRING("head"),getter_AddRefs(headList));
|
res = domDoc->GetElementsByTagName(NS_LITERAL_STRING("head"),getter_AddRefs(headList));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!headList) return NS_ERROR_FAILURE;
|
if (!headList) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMNode>headNode;
|
nsCOMPtr<nsIDOMNode>headNode;
|
||||||
|
@ -149,7 +149,7 @@ nsresult SetDocTitleTxn::SetDomTitle(const nsAString& aTitle)
|
||||||
// Didn't find one above: Create a new one
|
// Didn't find one above: Create a new one
|
||||||
nsCOMPtr<nsIDOMElement>titleElement;
|
nsCOMPtr<nsIDOMElement>titleElement;
|
||||||
res = domDoc->CreateElement(NS_LITERAL_STRING("title"), getter_AddRefs(titleElement));
|
res = domDoc->CreateElement(NS_LITERAL_STRING("title"), getter_AddRefs(titleElement));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!titleElement) return NS_ERROR_FAILURE;
|
if (!titleElement) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
titleNode = do_QueryInterface(titleElement);
|
titleNode = do_QueryInterface(titleElement);
|
||||||
|
@ -159,7 +159,7 @@ nsresult SetDocTitleTxn::SetDomTitle(const nsAString& aTitle)
|
||||||
// after all existing HEAD children
|
// after all existing HEAD children
|
||||||
nsCOMPtr<nsIDOMNodeList> children;
|
nsCOMPtr<nsIDOMNodeList> children;
|
||||||
res = headNode->GetChildNodes(getter_AddRefs(children));
|
res = headNode->GetChildNodes(getter_AddRefs(children));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (children)
|
if (children)
|
||||||
children->GetLength(&newTitleIndex);
|
children->GetLength(&newTitleIndex);
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ nsresult SetDocTitleTxn::SetDomTitle(const nsAString& aTitle)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMText> textNode;
|
nsCOMPtr<nsIDOMText> textNode;
|
||||||
res = domDoc->CreateTextNode(aTitle, getter_AddRefs(textNode));
|
res = domDoc->CreateTextNode(aTitle, getter_AddRefs(textNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
nsCOMPtr<nsIDOMNode> newNode = do_QueryInterface(textNode);
|
nsCOMPtr<nsIDOMNode> newNode = do_QueryInterface(textNode);
|
||||||
if (!newNode) return NS_ERROR_FAILURE;
|
if (!newNode) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ nsresult SetDocTitleTxn::SetDomTitle(const nsAString& aTitle)
|
||||||
// This is an undoable transaction
|
// This is an undoable transaction
|
||||||
res = editor->InsertNode(newNode, titleNode, 0);
|
res = editor->InsertNode(newNode, titleNode, 0);
|
||||||
}
|
}
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newTitleNode)
|
if (newTitleNode)
|
||||||
|
|
|
@ -98,7 +98,7 @@ NS_IMETHODIMP SplitElementTxn::DoTransaction(void)
|
||||||
// create a new node
|
// create a new node
|
||||||
nsresult result = mExistingRightNode->CloneNode(PR_FALSE, getter_AddRefs(mNewLeftNode));
|
nsresult result = mExistingRightNode->CloneNode(PR_FALSE, getter_AddRefs(mNewLeftNode));
|
||||||
NS_ASSERTION(((NS_SUCCEEDED(result)) && (mNewLeftNode)), "could not create element.");
|
NS_ASSERTION(((NS_SUCCEEDED(result)) && (mNewLeftNode)), "could not create element.");
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!mNewLeftNode) return NS_ERROR_NULL_POINTER;
|
if (!mNewLeftNode) return NS_ERROR_NULL_POINTER;
|
||||||
mEditor->MarkNodeDirty(mExistingRightNode);
|
mEditor->MarkNodeDirty(mExistingRightNode);
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ NS_IMETHODIMP SplitElementTxn::DoTransaction(void)
|
||||||
|
|
||||||
// get the parent node
|
// get the parent node
|
||||||
result = mExistingRightNode->GetParentNode(getter_AddRefs(mParent));
|
result = mExistingRightNode->GetParentNode(getter_AddRefs(mParent));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!mParent) return NS_ERROR_NULL_POINTER;
|
if (!mParent) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
// insert the new node
|
// insert the new node
|
||||||
|
@ -121,7 +121,7 @@ NS_IMETHODIMP SplitElementTxn::DoTransaction(void)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsISelection>selection;
|
nsCOMPtr<nsISelection>selection;
|
||||||
mEditor->GetSelection(getter_AddRefs(selection));
|
mEditor->GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
result = selection->Collapse(mNewLeftNode, mOffset);
|
result = selection->Collapse(mNewLeftNode, mOffset);
|
||||||
}
|
}
|
||||||
|
|
|
@ -596,7 +596,7 @@ nsEditor::DoTransaction(nsITransaction *aTxn)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsITransaction> topTxn;
|
nsCOMPtr<nsITransaction> topTxn;
|
||||||
result = mTxnMgr->PeekUndoStack(getter_AddRefs(topTxn));
|
result = mTxnMgr->PeekUndoStack(getter_AddRefs(topTxn));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (topTxn)
|
if (topTxn)
|
||||||
{
|
{
|
||||||
plcTxn = do_QueryInterface(topTxn);
|
plcTxn = do_QueryInterface(topTxn);
|
||||||
|
@ -868,7 +868,7 @@ nsEditor::BeginPlaceHolderTransaction(nsIAtom *aName)
|
||||||
mPlaceHolderName = aName;
|
mPlaceHolderName = aName;
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
nsresult res = GetSelection(getter_AddRefs(selection));
|
nsresult res = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
mSelState = new nsSelectionState();
|
mSelState = new nsSelectionState();
|
||||||
if (!mSelState)
|
if (!mSelState)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
@ -1028,7 +1028,7 @@ NS_IMETHODIMP nsEditor::BeginningOfDocument()
|
||||||
if (!parentNode) { return NS_ERROR_NULL_POINTER; }
|
if (!parentNode) { return NS_ERROR_NULL_POINTER; }
|
||||||
PRInt32 offsetInParent;
|
PRInt32 offsetInParent;
|
||||||
result = nsEditor::GetChildOffset(firstNode, parentNode, offsetInParent);
|
result = nsEditor::GetChildOffset(firstNode, parentNode, offsetInParent);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
result = selection->Collapse(parentNode, offsetInParent);
|
result = selection->Collapse(parentNode, offsetInParent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1049,7 +1049,7 @@ nsEditor::EndOfDocument()
|
||||||
// get selection
|
// get selection
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
res = GetSelection(getter_AddRefs(selection));
|
res = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
// get the root element
|
// get the root element
|
||||||
|
@ -1060,7 +1060,7 @@ nsEditor::EndOfDocument()
|
||||||
// get the length of the rot element
|
// get the length of the rot element
|
||||||
PRUint32 len;
|
PRUint32 len;
|
||||||
res = GetLengthOfDOMNode(rootElement, len);
|
res = GetLengthOfDOMNode(rootElement, len);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// set the selection to after the last child of the root element
|
// set the selection to after the last child of the root element
|
||||||
return selection->Collapse(rootElement, (PRInt32)len);
|
return selection->Collapse(rootElement, (PRInt32)len);
|
||||||
|
@ -1409,11 +1409,11 @@ nsEditor::JoinNodes(nsIDOMNode * aLeftNode,
|
||||||
// remember some values; later used for saved selection updating.
|
// remember some values; later used for saved selection updating.
|
||||||
// find the offset between the nodes to be joined.
|
// find the offset between the nodes to be joined.
|
||||||
nsresult result = GetChildOffset(aRightNode, aParent, offset);
|
nsresult result = GetChildOffset(aRightNode, aParent, offset);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
// find the number of children of the lefthand node
|
// find the number of children of the lefthand node
|
||||||
PRUint32 oldLeftNodeLen;
|
PRUint32 oldLeftNodeLen;
|
||||||
result = GetLengthOfDOMNode(aLeftNode, oldLeftNodeLen);
|
result = GetLengthOfDOMNode(aLeftNode, oldLeftNodeLen);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
|
|
||||||
for (i = 0; i < mActionListeners.Count(); i++)
|
for (i = 0; i < mActionListeners.Count(); i++)
|
||||||
mActionListeners[i]->WillJoinNodes(aLeftNode, aRightNode, aParent);
|
mActionListeners[i]->WillJoinNodes(aLeftNode, aRightNode, aParent);
|
||||||
|
@ -1441,7 +1441,7 @@ NS_IMETHODIMP nsEditor::DeleteNode(nsIDOMNode * aElement)
|
||||||
|
|
||||||
// save node location for selection updating code.
|
// save node location for selection updating code.
|
||||||
nsresult result = GetNodeLocation(aElement, address_of(parent), &offset);
|
nsresult result = GetNodeLocation(aElement, address_of(parent), &offset);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
|
|
||||||
for (i = 0; i < mActionListeners.Count(); i++)
|
for (i = 0; i < mActionListeners.Count(); i++)
|
||||||
mActionListeners[i]->WillDeleteNode(aElement);
|
mActionListeners[i]->WillDeleteNode(aElement);
|
||||||
|
@ -1476,7 +1476,7 @@ nsEditor::ReplaceContainer(nsIDOMNode *inNode,
|
||||||
nsCOMPtr<nsIDOMNode> parent;
|
nsCOMPtr<nsIDOMNode> parent;
|
||||||
PRInt32 offset;
|
PRInt32 offset;
|
||||||
nsresult res = GetNodeLocation(inNode, address_of(parent), &offset);
|
nsresult res = GetNodeLocation(inNode, address_of(parent), &offset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// create new container
|
// create new container
|
||||||
nsCOMPtr<nsIContent> newContent;
|
nsCOMPtr<nsIContent> newContent;
|
||||||
|
@ -1484,20 +1484,20 @@ nsEditor::ReplaceContainer(nsIDOMNode *inNode,
|
||||||
//new call to use instead to get proper HTML element, bug# 39919
|
//new call to use instead to get proper HTML element, bug# 39919
|
||||||
res = CreateHTMLContent(aNodeType, getter_AddRefs(newContent));
|
res = CreateHTMLContent(aNodeType, getter_AddRefs(newContent));
|
||||||
nsCOMPtr<nsIDOMElement> elem = do_QueryInterface(newContent);
|
nsCOMPtr<nsIDOMElement> elem = do_QueryInterface(newContent);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
*outNode = do_QueryInterface(elem);
|
*outNode = do_QueryInterface(elem);
|
||||||
|
|
||||||
// set attribute if needed
|
// set attribute if needed
|
||||||
if (aAttribute && aValue && !aAttribute->IsEmpty())
|
if (aAttribute && aValue && !aAttribute->IsEmpty())
|
||||||
{
|
{
|
||||||
res = elem->SetAttribute(*aAttribute, *aValue);
|
res = elem->SetAttribute(*aAttribute, *aValue);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
if (aCloneAttributes)
|
if (aCloneAttributes)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMNode>newNode = do_QueryInterface(elem);
|
nsCOMPtr<nsIDOMNode>newNode = do_QueryInterface(elem);
|
||||||
res = CloneAttributes(newNode, inNode);
|
res = CloneAttributes(newNode, inNode);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// notify our internal selection state listener
|
// notify our internal selection state listener
|
||||||
|
@ -1513,16 +1513,16 @@ nsEditor::ReplaceContainer(nsIDOMNode *inNode,
|
||||||
{
|
{
|
||||||
inNode->GetFirstChild(getter_AddRefs(child));
|
inNode->GetFirstChild(getter_AddRefs(child));
|
||||||
res = DeleteNode(child);
|
res = DeleteNode(child);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
res = InsertNode(child, *outNode, -1);
|
res = InsertNode(child, *outNode, -1);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
inNode->HasChildNodes(&bHasMoreChildren);
|
inNode->HasChildNodes(&bHasMoreChildren);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// insert new container into tree
|
// insert new container into tree
|
||||||
res = InsertNode( *outNode, parent, offset);
|
res = InsertNode( *outNode, parent, offset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// delete old container
|
// delete old container
|
||||||
return DeleteNode(inNode);
|
return DeleteNode(inNode);
|
||||||
|
@ -1541,7 +1541,7 @@ nsEditor::RemoveContainer(nsIDOMNode *inNode)
|
||||||
PRInt32 offset;
|
PRInt32 offset;
|
||||||
|
|
||||||
nsresult res = GetNodeLocation(inNode, address_of(parent), &offset);
|
nsresult res = GetNodeLocation(inNode, address_of(parent), &offset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// loop through the child nodes of inNode and promote them
|
// loop through the child nodes of inNode and promote them
|
||||||
// into inNode's parent.
|
// into inNode's parent.
|
||||||
|
@ -1549,7 +1549,7 @@ nsEditor::RemoveContainer(nsIDOMNode *inNode)
|
||||||
inNode->HasChildNodes(&bHasMoreChildren);
|
inNode->HasChildNodes(&bHasMoreChildren);
|
||||||
nsCOMPtr<nsIDOMNodeList> nodeList;
|
nsCOMPtr<nsIDOMNodeList> nodeList;
|
||||||
res = inNode->GetChildNodes(getter_AddRefs(nodeList));
|
res = inNode->GetChildNodes(getter_AddRefs(nodeList));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!nodeList) return NS_ERROR_NULL_POINTER;
|
if (!nodeList) return NS_ERROR_NULL_POINTER;
|
||||||
PRUint32 nodeOrigLen;
|
PRUint32 nodeOrigLen;
|
||||||
nodeList->GetLength(&nodeOrigLen);
|
nodeList->GetLength(&nodeOrigLen);
|
||||||
|
@ -1562,9 +1562,9 @@ nsEditor::RemoveContainer(nsIDOMNode *inNode)
|
||||||
{
|
{
|
||||||
inNode->GetLastChild(getter_AddRefs(child));
|
inNode->GetLastChild(getter_AddRefs(child));
|
||||||
res = DeleteNode(child);
|
res = DeleteNode(child);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = InsertNode(child, parent, offset);
|
res = InsertNode(child, parent, offset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
inNode->HasChildNodes(&bHasMoreChildren);
|
inNode->HasChildNodes(&bHasMoreChildren);
|
||||||
}
|
}
|
||||||
return DeleteNode(inNode);
|
return DeleteNode(inNode);
|
||||||
|
@ -1589,7 +1589,7 @@ nsEditor::InsertContainerAbove( nsIDOMNode *inNode,
|
||||||
nsCOMPtr<nsIDOMNode> parent;
|
nsCOMPtr<nsIDOMNode> parent;
|
||||||
PRInt32 offset;
|
PRInt32 offset;
|
||||||
nsresult res = GetNodeLocation(inNode, address_of(parent), &offset);
|
nsresult res = GetNodeLocation(inNode, address_of(parent), &offset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// create new container
|
// create new container
|
||||||
nsCOMPtr<nsIContent> newContent;
|
nsCOMPtr<nsIContent> newContent;
|
||||||
|
@ -1597,14 +1597,14 @@ nsEditor::InsertContainerAbove( nsIDOMNode *inNode,
|
||||||
//new call to use instead to get proper HTML element, bug# 39919
|
//new call to use instead to get proper HTML element, bug# 39919
|
||||||
res = CreateHTMLContent(aNodeType, getter_AddRefs(newContent));
|
res = CreateHTMLContent(aNodeType, getter_AddRefs(newContent));
|
||||||
nsCOMPtr<nsIDOMElement> elem = do_QueryInterface(newContent);
|
nsCOMPtr<nsIDOMElement> elem = do_QueryInterface(newContent);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
*outNode = do_QueryInterface(elem);
|
*outNode = do_QueryInterface(elem);
|
||||||
|
|
||||||
// set attribute if needed
|
// set attribute if needed
|
||||||
if (aAttribute && aValue && !aAttribute->IsEmpty())
|
if (aAttribute && aValue && !aAttribute->IsEmpty())
|
||||||
{
|
{
|
||||||
res = elem->SetAttribute(*aAttribute, *aValue);
|
res = elem->SetAttribute(*aAttribute, *aValue);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// notify our internal selection state listener
|
// notify our internal selection state listener
|
||||||
|
@ -1612,12 +1612,12 @@ nsEditor::InsertContainerAbove( nsIDOMNode *inNode,
|
||||||
|
|
||||||
// put inNode in new parent, outNode
|
// put inNode in new parent, outNode
|
||||||
res = DeleteNode(inNode);
|
res = DeleteNode(inNode);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
{
|
{
|
||||||
nsAutoTxnsConserveSelection conserveSelection(this);
|
nsAutoTxnsConserveSelection conserveSelection(this);
|
||||||
res = InsertNode(inNode, *outNode, 0);
|
res = InsertNode(inNode, *outNode, 0);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// put new parent in doc
|
// put new parent in doc
|
||||||
|
@ -1641,7 +1641,7 @@ nsEditor::MoveNode(nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aOffset)
|
||||||
PRUint32 unsignedOffset;
|
PRUint32 unsignedOffset;
|
||||||
// magic value meaning "move to end of aParent"
|
// magic value meaning "move to end of aParent"
|
||||||
res = GetLengthOfDOMNode(aParent, unsignedOffset);
|
res = GetLengthOfDOMNode(aParent, unsignedOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
aOffset = (PRInt32)unsignedOffset;
|
aOffset = (PRInt32)unsignedOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1659,7 +1659,7 @@ nsEditor::MoveNode(nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aOffset)
|
||||||
|
|
||||||
// put aNode in new parent
|
// put aNode in new parent
|
||||||
res = DeleteNode(aNode);
|
res = DeleteNode(aNode);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
return InsertNode(aNode, aParent, aOffset);
|
return InsertNode(aNode, aParent, aOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2311,16 +2311,16 @@ NS_IMETHODIMP nsEditor::InsertTextImpl(const nsAString& aStringToInsert,
|
||||||
{
|
{
|
||||||
// create a text node
|
// create a text node
|
||||||
res = aDoc->CreateTextNode(EmptyString(), getter_AddRefs(nodeAsText));
|
res = aDoc->CreateTextNode(EmptyString(), getter_AddRefs(nodeAsText));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!nodeAsText) return NS_ERROR_NULL_POINTER;
|
if (!nodeAsText) return NS_ERROR_NULL_POINTER;
|
||||||
nsCOMPtr<nsIDOMNode> newNode = do_QueryInterface(nodeAsText);
|
nsCOMPtr<nsIDOMNode> newNode = do_QueryInterface(nodeAsText);
|
||||||
// then we insert it into the dom tree
|
// then we insert it into the dom tree
|
||||||
res = InsertNode(newNode, *aInOutNode, offset);
|
res = InsertNode(newNode, *aInOutNode, offset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
offset = 0;
|
offset = 0;
|
||||||
}
|
}
|
||||||
res = InsertTextIntoTextNodeImpl(aStringToInsert, nodeAsText, offset);
|
res = InsertTextIntoTextNodeImpl(aStringToInsert, nodeAsText, offset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2328,7 +2328,7 @@ NS_IMETHODIMP nsEditor::InsertTextImpl(const nsAString& aStringToInsert,
|
||||||
{
|
{
|
||||||
// we are inserting text into an existing text node.
|
// we are inserting text into an existing text node.
|
||||||
res = InsertTextIntoTextNodeImpl(aStringToInsert, nodeAsText, offset);
|
res = InsertTextIntoTextNodeImpl(aStringToInsert, nodeAsText, offset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
*aInOutOffset += aStringToInsert.Length();
|
*aInOutOffset += aStringToInsert.Length();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2336,12 +2336,12 @@ NS_IMETHODIMP nsEditor::InsertTextImpl(const nsAString& aStringToInsert,
|
||||||
// we are inserting text into a non-text node
|
// we are inserting text into a non-text node
|
||||||
// first we have to create a textnode (this also populates it with the text)
|
// first we have to create a textnode (this also populates it with the text)
|
||||||
res = aDoc->CreateTextNode(aStringToInsert, getter_AddRefs(nodeAsText));
|
res = aDoc->CreateTextNode(aStringToInsert, getter_AddRefs(nodeAsText));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!nodeAsText) return NS_ERROR_NULL_POINTER;
|
if (!nodeAsText) return NS_ERROR_NULL_POINTER;
|
||||||
nsCOMPtr<nsIDOMNode> newNode = do_QueryInterface(nodeAsText);
|
nsCOMPtr<nsIDOMNode> newNode = do_QueryInterface(nodeAsText);
|
||||||
// then we insert it into the dom tree
|
// then we insert it into the dom tree
|
||||||
res = InsertNode(newNode, *aInOutNode, offset);
|
res = InsertNode(newNode, *aInOutNode, offset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
*aInOutNode = newNode;
|
*aInOutNode = newNode;
|
||||||
*aInOutOffset = aStringToInsert.Length();
|
*aInOutOffset = aStringToInsert.Length();
|
||||||
}
|
}
|
||||||
|
@ -2417,7 +2417,7 @@ nsresult nsEditor::InsertTextIntoTextNodeImpl(const nsAString& aStringToInsert,
|
||||||
getter_AddRefs(insertTxn));
|
getter_AddRefs(insertTxn));
|
||||||
txn = insertTxn;
|
txn = insertTxn;
|
||||||
}
|
}
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
|
|
||||||
// let listeners know what's up
|
// let listeners know what's up
|
||||||
PRInt32 i;
|
PRInt32 i;
|
||||||
|
@ -2551,7 +2551,7 @@ nsEditor::NotifyDocumentListeners(TDocumentListenerNotification aNotificationTyp
|
||||||
{
|
{
|
||||||
PRBool docIsDirty;
|
PRBool docIsDirty;
|
||||||
rv = GetDocumentModified(&docIsDirty);
|
rv = GetDocumentModified(&docIsDirty);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
if (docIsDirty == mDocDirtyState)
|
if (docIsDirty == mDocDirtyState)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -2697,7 +2697,7 @@ nsEditor::SplitNodeImpl(nsIDOMNode * aExistingRightNode,
|
||||||
// get selection
|
// get selection
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
result = GetSelection(getter_AddRefs(selection));
|
result = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
// remember some selection points
|
// remember some selection points
|
||||||
|
@ -2838,12 +2838,12 @@ nsEditor::JoinNodesImpl(nsIDOMNode * aNodeToKeep,
|
||||||
|
|
||||||
PRUint32 firstNodeLength;
|
PRUint32 firstNodeLength;
|
||||||
result = GetLengthOfDOMNode(leftNode, firstNodeLength);
|
result = GetLengthOfDOMNode(leftNode, firstNodeLength);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
nsCOMPtr<nsIDOMNode> parent;
|
nsCOMPtr<nsIDOMNode> parent;
|
||||||
result = GetNodeLocation(aNodeToJoin, address_of(parent), &joinOffset);
|
result = GetNodeLocation(aNodeToJoin, address_of(parent), &joinOffset);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
result = GetNodeLocation(aNodeToKeep, address_of(parent), &keepOffset);
|
result = GetNodeLocation(aNodeToKeep, address_of(parent), &keepOffset);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
|
|
||||||
// if selection endpoint is between the nodes, remember it as being
|
// if selection endpoint is between the nodes, remember it as being
|
||||||
// in the one that is going away instead. This simplifies later selection
|
// in the one that is going away instead. This simplifies later selection
|
||||||
|
@ -3199,7 +3199,7 @@ nsEditor::GetPriorNode(nsIDOMNode *aCurrentNode,
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMNode> candidate;
|
nsCOMPtr<nsIDOMNode> candidate;
|
||||||
result = GetPriorNodeImpl(aCurrentNode, aEditableNode, address_of(candidate), bNoBlockCrossing);
|
result = GetPriorNodeImpl(aCurrentNode, aEditableNode, address_of(candidate), bNoBlockCrossing);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
|
|
||||||
if (!candidate)
|
if (!candidate)
|
||||||
{
|
{
|
||||||
|
@ -3310,7 +3310,7 @@ nsEditor::GetNextNode(nsIDOMNode *aCurrentNode,
|
||||||
nsCOMPtr<nsIDOMNode> candidate;
|
nsCOMPtr<nsIDOMNode> candidate;
|
||||||
nsresult result = GetNextNodeImpl(aCurrentNode, aEditableNode,
|
nsresult result = GetNextNodeImpl(aCurrentNode, aEditableNode,
|
||||||
address_of(candidate), bNoBlockCrossing);
|
address_of(candidate), bNoBlockCrossing);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
|
|
||||||
if (!candidate)
|
if (!candidate)
|
||||||
{
|
{
|
||||||
|
@ -3960,19 +3960,19 @@ nsEditor::SplitNodeDeep(nsIDOMNode *aNode,
|
||||||
PRUint32 len;
|
PRUint32 len;
|
||||||
PRBool bDoSplit = PR_FALSE;
|
PRBool bDoSplit = PR_FALSE;
|
||||||
res = GetLengthOfDOMNode(nodeToSplit, len);
|
res = GetLengthOfDOMNode(nodeToSplit, len);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
if (!(aNoEmptyContainers || nodeAsText) || (offset && (offset != (PRInt32)len)))
|
if (!(aNoEmptyContainers || nodeAsText) || (offset && (offset != (PRInt32)len)))
|
||||||
{
|
{
|
||||||
bDoSplit = PR_TRUE;
|
bDoSplit = PR_TRUE;
|
||||||
res = SplitNode(nodeToSplit, offset, getter_AddRefs(tempNode));
|
res = SplitNode(nodeToSplit, offset, getter_AddRefs(tempNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (outRightNode) *outRightNode = nodeToSplit;
|
if (outRightNode) *outRightNode = nodeToSplit;
|
||||||
if (outLeftNode) *outLeftNode = tempNode;
|
if (outLeftNode) *outLeftNode = tempNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = nodeToSplit->GetParentNode(getter_AddRefs(parentNode));
|
res = nodeToSplit->GetParentNode(getter_AddRefs(parentNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!parentNode) return NS_ERROR_FAILURE;
|
if (!parentNode) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
if (!bDoSplit && offset) // must be "end of text node" case, we didn't split it, just move past it
|
if (!bDoSplit && offset) // must be "end of text node" case, we didn't split it, just move past it
|
||||||
|
@ -4040,7 +4040,7 @@ nsEditor::JoinNodeDeep(nsIDOMNode *aLeftNode,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res = GetLengthOfDOMNode(leftNodeToJoin, length);
|
res = GetLengthOfDOMNode(leftNodeToJoin, length);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
*aOutJoinNode = rightNodeToJoin;
|
*aOutJoinNode = rightNodeToJoin;
|
||||||
|
@ -4048,7 +4048,7 @@ nsEditor::JoinNodeDeep(nsIDOMNode *aLeftNode,
|
||||||
|
|
||||||
// do the join
|
// do the join
|
||||||
res = JoinNodes(leftNodeToJoin, rightNodeToJoin, parentNode);
|
res = JoinNodes(leftNodeToJoin, rightNodeToJoin, parentNode);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
if (IsTextNode(parentNode)) // we've joined all the way down to text nodes, we're done!
|
if (IsTextNode(parentNode)) // we've joined all the way down to text nodes, we're done!
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -4201,7 +4201,7 @@ nsEditor::DeleteSelectionImpl(nsIEditor::EDirection aAction)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsISelection>selection;
|
nsCOMPtr<nsISelection>selection;
|
||||||
nsresult res = GetSelection(getter_AddRefs(selection));
|
nsresult res = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
nsRefPtr<EditAggregateTxn> txn;
|
nsRefPtr<EditAggregateTxn> txn;
|
||||||
nsCOMPtr<nsIDOMNode> deleteNode;
|
nsCOMPtr<nsIDOMNode> deleteNode;
|
||||||
PRInt32 deleteCharOffset = 0, deleteCharLength = 0;
|
PRInt32 deleteCharOffset = 0, deleteCharLength = 0;
|
||||||
|
@ -4265,7 +4265,7 @@ nsEditor::DeleteSelectionAndCreateNode(const nsAString& aTag,
|
||||||
// we want the selection to be just after the new node
|
// we want the selection to be just after the new node
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
result = GetSelection(getter_AddRefs(selection));
|
result = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
return selection->Collapse(parentSelectedNode, offsetOfNewNode+1);
|
return selection->Collapse(parentSelectedNode, offsetOfNewNode+1);
|
||||||
}
|
}
|
||||||
|
@ -4321,7 +4321,7 @@ nsEditor::DeleteSelectionAndPrepareToCreateNode(nsCOMPtr<nsIDOMNode> &parentSele
|
||||||
nsresult result=NS_ERROR_NOT_INITIALIZED;
|
nsresult result=NS_ERROR_NOT_INITIALIZED;
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
result = GetSelection(getter_AddRefs(selection));
|
result = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
PRBool collapsed;
|
PRBool collapsed;
|
||||||
|
@ -4905,21 +4905,21 @@ nsEditor::AppendNodeToSelectionAsRange(nsIDOMNode *aNode)
|
||||||
if (!aNode) return NS_ERROR_NULL_POINTER;
|
if (!aNode) return NS_ERROR_NULL_POINTER;
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
nsresult res = GetSelection(getter_AddRefs(selection));
|
nsresult res = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if(!selection) return NS_ERROR_FAILURE;
|
if(!selection) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMNode> parentNode;
|
nsCOMPtr<nsIDOMNode> parentNode;
|
||||||
res = aNode->GetParentNode(getter_AddRefs(parentNode));
|
res = aNode->GetParentNode(getter_AddRefs(parentNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!parentNode) return NS_ERROR_NULL_POINTER;
|
if (!parentNode) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
PRInt32 offset;
|
PRInt32 offset;
|
||||||
res = GetChildOffset(aNode, parentNode, offset);
|
res = GetChildOffset(aNode, parentNode, offset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMRange> range;
|
nsCOMPtr<nsIDOMRange> range;
|
||||||
res = CreateRange(parentNode, offset, parentNode, offset+1, getter_AddRefs(range));
|
res = CreateRange(parentNode, offset, parentNode, offset+1, getter_AddRefs(range));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!range) return NS_ERROR_NULL_POINTER;
|
if (!range) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
return selection->AddRange(range);
|
return selection->AddRange(range);
|
||||||
|
@ -4929,7 +4929,7 @@ nsresult nsEditor::ClearSelection()
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
nsresult res = nsEditor::GetSelection(getter_AddRefs(selection));
|
nsresult res = nsEditor::GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!selection) return NS_ERROR_FAILURE;
|
if (!selection) return NS_ERROR_FAILURE;
|
||||||
return selection->RemoveAllRanges();
|
return selection->RemoveAllRanges();
|
||||||
}
|
}
|
||||||
|
|
|
@ -572,7 +572,7 @@ nsEditorEventListener::DragOver(nsIDOMDragEvent* aDragEvent)
|
||||||
{
|
{
|
||||||
PRInt32 offset = 0;
|
PRInt32 offset = 0;
|
||||||
nsresult rv = nsuiEvent->GetRangeOffset(&offset);
|
nsresult rv = nsuiEvent->GetRangeOffset(&offset);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// to avoid flicker, we could track the node and offset to see if we moved
|
// to avoid flicker, we could track the node and offset to see if we moved
|
||||||
if (mCaretDrawn)
|
if (mCaretDrawn)
|
||||||
|
@ -721,11 +721,11 @@ nsEditorEventListener::CanDrop(nsIDOMDragEvent* aEvent)
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMDocument> domdoc;
|
nsCOMPtr<nsIDOMDocument> domdoc;
|
||||||
nsresult rv = mEditor->GetDocument(getter_AddRefs(domdoc));
|
nsresult rv = mEditor->GetDocument(getter_AddRefs(domdoc));
|
||||||
if (NS_FAILED(rv)) return PR_FALSE;
|
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMDocument> sourceDoc;
|
nsCOMPtr<nsIDOMDocument> sourceDoc;
|
||||||
rv = sourceNode->GetOwnerDocument(getter_AddRefs(sourceDoc));
|
rv = sourceNode->GetOwnerDocument(getter_AddRefs(sourceDoc));
|
||||||
if (NS_FAILED(rv)) return PR_FALSE;
|
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||||
if (domdoc == sourceDoc) // source and dest are the same document; disallow drops within the selection
|
if (domdoc == sourceDoc) // source and dest are the same document; disallow drops within the selection
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
|
@ -735,7 +735,7 @@ nsEditorEventListener::CanDrop(nsIDOMDragEvent* aEvent)
|
||||||
|
|
||||||
PRBool isCollapsed;
|
PRBool isCollapsed;
|
||||||
rv = selection->GetIsCollapsed(&isCollapsed);
|
rv = selection->GetIsCollapsed(&isCollapsed);
|
||||||
if (NS_FAILED(rv)) return PR_FALSE;
|
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||||
|
|
||||||
// Don't bother if collapsed - can always drop
|
// Don't bother if collapsed - can always drop
|
||||||
if (!isCollapsed)
|
if (!isCollapsed)
|
||||||
|
@ -749,11 +749,11 @@ nsEditorEventListener::CanDrop(nsIDOMDragEvent* aEvent)
|
||||||
|
|
||||||
PRInt32 offset = 0;
|
PRInt32 offset = 0;
|
||||||
rv = nsuiEvent->GetRangeOffset(&offset);
|
rv = nsuiEvent->GetRangeOffset(&offset);
|
||||||
if (NS_FAILED(rv)) return PR_FALSE;
|
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||||
|
|
||||||
PRInt32 rangeCount;
|
PRInt32 rangeCount;
|
||||||
rv = selection->GetRangeCount(&rangeCount);
|
rv = selection->GetRangeCount(&rangeCount);
|
||||||
if (NS_FAILED(rv)) return PR_FALSE;
|
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||||
|
|
||||||
for (PRInt32 i = 0; i < rangeCount; i++)
|
for (PRInt32 i = 0; i < rangeCount; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -105,7 +105,7 @@ nsDOMIterator::Init(nsIDOMRange* aRange)
|
||||||
{
|
{
|
||||||
nsresult res;
|
nsresult res;
|
||||||
mIter = do_CreateInstance("@mozilla.org/content/post-content-iterator;1", &res);
|
mIter = do_CreateInstance("@mozilla.org/content/post-content-iterator;1", &res);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!mIter) return NS_ERROR_FAILURE;
|
if (!mIter) return NS_ERROR_FAILURE;
|
||||||
return mIter->Init(aRange);
|
return mIter->Init(aRange);
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ nsDOMIterator::Init(nsIDOMNode* aNode)
|
||||||
{
|
{
|
||||||
nsresult res;
|
nsresult res;
|
||||||
mIter = do_CreateInstance("@mozilla.org/content/post-content-iterator;1", &res);
|
mIter = do_CreateInstance("@mozilla.org/content/post-content-iterator;1", &res);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!mIter) return NS_ERROR_FAILURE;
|
if (!mIter) return NS_ERROR_FAILURE;
|
||||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
|
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
|
||||||
return mIter->Init(content);
|
return mIter->Init(content);
|
||||||
|
@ -173,7 +173,7 @@ nsDOMSubtreeIterator::Init(nsIDOMRange* aRange)
|
||||||
{
|
{
|
||||||
nsresult res;
|
nsresult res;
|
||||||
mIter = do_CreateInstance("@mozilla.org/content/subtree-content-iterator;1", &res);
|
mIter = do_CreateInstance("@mozilla.org/content/subtree-content-iterator;1", &res);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!mIter) return NS_ERROR_FAILURE;
|
if (!mIter) return NS_ERROR_FAILURE;
|
||||||
return mIter->Init(aRange);
|
return mIter->Init(aRange);
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ nsDOMSubtreeIterator::Init(nsIDOMNode* aNode)
|
||||||
{
|
{
|
||||||
nsresult res;
|
nsresult res;
|
||||||
mIter = do_CreateInstance("@mozilla.org/content/subtree-content-iterator;1", &res);
|
mIter = do_CreateInstance("@mozilla.org/content/subtree-content-iterator;1", &res);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!mIter) return NS_ERROR_FAILURE;
|
if (!mIter) return NS_ERROR_FAILURE;
|
||||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
|
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
|
||||||
return mIter->Init(content);
|
return mIter->Init(content);
|
||||||
|
@ -205,7 +205,7 @@ nsEditorUtils::IsDescendantOf(nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 *a
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
res = node->GetParentNode(getter_AddRefs(parent));
|
res = node->GetParentNode(getter_AddRefs(parent));
|
||||||
if (NS_FAILED(res)) return PR_FALSE;
|
NS_ENSURE_SUCCESS(res, PR_FALSE);
|
||||||
if (parent == aParent)
|
if (parent == aParent)
|
||||||
{
|
{
|
||||||
if (aOffset)
|
if (aOffset)
|
||||||
|
|
|
@ -342,11 +342,11 @@ nsRangeUpdater::SelAdjSplitNode(nsIDOMNode *aOldRightNode, PRInt32 aOffset, nsID
|
||||||
nsCOMPtr<nsIDOMNode> parent;
|
nsCOMPtr<nsIDOMNode> parent;
|
||||||
PRInt32 offset;
|
PRInt32 offset;
|
||||||
nsresult result = nsEditor::GetNodeLocation(aOldRightNode, address_of(parent), &offset);
|
nsresult result = nsEditor::GetNodeLocation(aOldRightNode, address_of(parent), &offset);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
|
|
||||||
// first part is same as inserting aNewLeftnode
|
// first part is same as inserting aNewLeftnode
|
||||||
result = SelAdjInsertNode(parent,offset-1);
|
result = SelAdjInsertNode(parent,offset-1);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
|
|
||||||
// next step is to check for range enpoints inside aOldRightNode
|
// next step is to check for range enpoints inside aOldRightNode
|
||||||
nsRangeStore *item;
|
nsRangeStore *item;
|
||||||
|
|
|
@ -74,7 +74,7 @@ nsresult TypeInState::UpdateSelState(nsISelection *aSelection)
|
||||||
PRBool isCollapsed = PR_FALSE;
|
PRBool isCollapsed = PR_FALSE;
|
||||||
nsresult result = aSelection->GetIsCollapsed(&isCollapsed);
|
nsresult result = aSelection->GetIsCollapsed(&isCollapsed);
|
||||||
|
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
|
|
||||||
if (isCollapsed)
|
if (isCollapsed)
|
||||||
{
|
{
|
||||||
|
@ -101,7 +101,7 @@ NS_IMETHODIMP TypeInState::NotifySelectionChanged(nsIDOMDocument *, nsISelection
|
||||||
PRBool isCollapsed = PR_FALSE;
|
PRBool isCollapsed = PR_FALSE;
|
||||||
nsresult result = aSelection->GetIsCollapsed(&isCollapsed);
|
nsresult result = aSelection->GetIsCollapsed(&isCollapsed);
|
||||||
|
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
|
|
||||||
if (isCollapsed)
|
if (isCollapsed)
|
||||||
{
|
{
|
||||||
|
@ -110,7 +110,7 @@ NS_IMETHODIMP TypeInState::NotifySelectionChanged(nsIDOMDocument *, nsISelection
|
||||||
|
|
||||||
result = nsEditor::GetStartNodeAndOffset(aSelection, getter_AddRefs(selNode), &selOffset);
|
result = nsEditor::GetStartNodeAndOffset(aSelection, getter_AddRefs(selNode), &selOffset);
|
||||||
|
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
|
|
||||||
if (selNode && selNode == mLastSelectionContainer && selOffset == mLastSelectionOffset)
|
if (selNode && selNode == mLastSelectionContainer && selOffset == mLastSelectionOffset)
|
||||||
{
|
{
|
||||||
|
|
|
@ -81,7 +81,7 @@ nsHTMLEditor::AbsolutePositionSelection(PRBool aEnabled)
|
||||||
// Find out if the selection is collapsed:
|
// Find out if the selection is collapsed:
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
nsresult res = GetSelection(getter_AddRefs(selection));
|
nsresult res = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
nsTextRulesInfo ruleInfo(aEnabled ?
|
nsTextRulesInfo ruleInfo(aEnabled ?
|
||||||
|
@ -100,7 +100,7 @@ nsHTMLEditor::GetAbsolutelyPositionedSelectionContainer(nsIDOMElement **_retval)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMElement> element;
|
nsCOMPtr<nsIDOMElement> element;
|
||||||
nsresult res = GetSelectionContainer(getter_AddRefs(element));
|
nsresult res = GetSelectionContainer(getter_AddRefs(element));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
nsAutoString positionStr;
|
nsAutoString positionStr;
|
||||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(element);
|
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(element);
|
||||||
|
@ -109,13 +109,13 @@ nsHTMLEditor::GetAbsolutelyPositionedSelectionContainer(nsIDOMElement **_retval)
|
||||||
while (!resultNode && !nsEditor::NodeIsType(node, nsEditProperty::html)) {
|
while (!resultNode && !nsEditor::NodeIsType(node, nsEditProperty::html)) {
|
||||||
res = mHTMLCSSUtils->GetComputedProperty(node, nsEditProperty::cssPosition,
|
res = mHTMLCSSUtils->GetComputedProperty(node, nsEditProperty::cssPosition,
|
||||||
positionStr);
|
positionStr);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (positionStr.EqualsLiteral("absolute"))
|
if (positionStr.EqualsLiteral("absolute"))
|
||||||
resultNode = node;
|
resultNode = node;
|
||||||
else {
|
else {
|
||||||
nsCOMPtr<nsIDOMNode> parentNode;
|
nsCOMPtr<nsIDOMNode> parentNode;
|
||||||
res = node->GetParentNode(getter_AddRefs(parentNode));
|
res = node->GetParentNode(getter_AddRefs(parentNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
node.swap(parentNode);
|
node.swap(parentNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ nsHTMLEditor::RelativeChangeElementZIndex(nsIDOMElement * aElement,
|
||||||
|
|
||||||
PRInt32 zIndex;
|
PRInt32 zIndex;
|
||||||
nsresult res = GetElementZIndex(aElement, &zIndex);
|
nsresult res = GetElementZIndex(aElement, &zIndex);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
zIndex = NS_MAX(zIndex + aChange, 0);
|
zIndex = NS_MAX(zIndex + aChange, 0);
|
||||||
SetElementZIndex(aElement, zIndex);
|
SetElementZIndex(aElement, zIndex);
|
||||||
|
@ -197,7 +197,7 @@ nsHTMLEditor::RelativeChangeZIndex(PRInt32 aChange)
|
||||||
// Find out if the selection is collapsed:
|
// Find out if the selection is collapsed:
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
nsresult res = GetSelection(getter_AddRefs(selection));
|
nsresult res = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
nsTextRulesInfo ruleInfo((aChange < 0) ? nsTextEditRules::kDecreaseZIndex:
|
nsTextRulesInfo ruleInfo((aChange < 0) ? nsTextEditRules::kDecreaseZIndex:
|
||||||
nsTextEditRules::kIncreaseZIndex);
|
nsTextEditRules::kIncreaseZIndex);
|
||||||
|
@ -219,13 +219,13 @@ nsHTMLEditor::GetElementZIndex(nsIDOMElement * aElement,
|
||||||
nsresult res = mHTMLCSSUtils->GetSpecifiedProperty(aElement,
|
nsresult res = mHTMLCSSUtils->GetSpecifiedProperty(aElement,
|
||||||
nsEditProperty::cssZIndex,
|
nsEditProperty::cssZIndex,
|
||||||
zIndexStr);
|
zIndexStr);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (zIndexStr.EqualsLiteral("auto")) {
|
if (zIndexStr.EqualsLiteral("auto")) {
|
||||||
// we have to look at the positioned ancestors
|
// we have to look at the positioned ancestors
|
||||||
// cf. CSS 2 spec section 9.9.1
|
// cf. CSS 2 spec section 9.9.1
|
||||||
nsCOMPtr<nsIDOMNode> parentNode;
|
nsCOMPtr<nsIDOMNode> parentNode;
|
||||||
res = aElement->GetParentNode(getter_AddRefs(parentNode));
|
res = aElement->GetParentNode(getter_AddRefs(parentNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
nsCOMPtr<nsIDOMNode> node = parentNode;
|
nsCOMPtr<nsIDOMNode> node = parentNode;
|
||||||
nsAutoString positionStr;
|
nsAutoString positionStr;
|
||||||
while (node &&
|
while (node &&
|
||||||
|
@ -234,17 +234,17 @@ nsHTMLEditor::GetElementZIndex(nsIDOMElement * aElement,
|
||||||
res = mHTMLCSSUtils->GetComputedProperty(node,
|
res = mHTMLCSSUtils->GetComputedProperty(node,
|
||||||
nsEditProperty::cssPosition,
|
nsEditProperty::cssPosition,
|
||||||
positionStr);
|
positionStr);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (positionStr.EqualsLiteral("absolute")) {
|
if (positionStr.EqualsLiteral("absolute")) {
|
||||||
// ah, we found one, what's its z-index ? If its z-index is auto,
|
// ah, we found one, what's its z-index ? If its z-index is auto,
|
||||||
// we have to continue climbing the document's tree
|
// we have to continue climbing the document's tree
|
||||||
res = mHTMLCSSUtils->GetComputedProperty(node,
|
res = mHTMLCSSUtils->GetComputedProperty(node,
|
||||||
nsEditProperty::cssZIndex,
|
nsEditProperty::cssZIndex,
|
||||||
zIndexStr);
|
zIndexStr);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
res = node->GetParentNode(getter_AddRefs(parentNode));
|
res = node->GetParentNode(getter_AddRefs(parentNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
node = parentNode;
|
node = parentNode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -293,7 +293,7 @@ nsHTMLEditor::RefreshGrabber()
|
||||||
mPositionedObjectMarginLeft,
|
mPositionedObjectMarginLeft,
|
||||||
mPositionedObjectMarginTop);
|
mPositionedObjectMarginTop);
|
||||||
|
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
SetAnonymousElementPosition(mPositionedObjectX+12,
|
SetAnonymousElementPosition(mPositionedObjectX+12,
|
||||||
mPositionedObjectY-14,
|
mPositionedObjectY-14,
|
||||||
|
@ -306,7 +306,7 @@ nsHTMLEditor::HideGrabber()
|
||||||
{
|
{
|
||||||
nsresult res =
|
nsresult res =
|
||||||
mAbsolutelyPositionedObject->RemoveAttribute(NS_LITERAL_STRING("_moz_abspos"));
|
mAbsolutelyPositionedObject->RemoveAttribute(NS_LITERAL_STRING("_moz_abspos"));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
mAbsolutelyPositionedObject = nsnull;
|
mAbsolutelyPositionedObject = nsnull;
|
||||||
NS_ENSURE_TRUE(mGrabber, NS_ERROR_NULL_POINTER);
|
NS_ENSURE_TRUE(mGrabber, NS_ERROR_NULL_POINTER);
|
||||||
|
@ -344,11 +344,11 @@ nsHTMLEditor::ShowGrabberOnElement(nsIDOMElement * aElement)
|
||||||
|
|
||||||
nsAutoString classValue;
|
nsAutoString classValue;
|
||||||
nsresult res = CheckPositionedElementBGandFG(aElement, classValue);
|
nsresult res = CheckPositionedElementBGandFG(aElement, classValue);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
res = aElement->SetAttribute(NS_LITERAL_STRING("_moz_abspos"),
|
res = aElement->SetAttribute(NS_LITERAL_STRING("_moz_abspos"),
|
||||||
classValue);
|
classValue);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// first, let's keep track of that element...
|
// first, let's keep track of that element...
|
||||||
mAbsolutelyPositionedObject = aElement;
|
mAbsolutelyPositionedObject = aElement;
|
||||||
|
@ -467,7 +467,7 @@ nsresult
|
||||||
nsHTMLEditor::SetFinalPosition(PRInt32 aX, PRInt32 aY)
|
nsHTMLEditor::SetFinalPosition(PRInt32 aX, PRInt32 aY)
|
||||||
{
|
{
|
||||||
nsresult res = EndMoving();
|
nsresult res = EndMoving();
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// we have now to set the new width and height of the resized object
|
// we have now to set the new width and height of the resized object
|
||||||
// we don't set the x and y position because we don't control that in
|
// we don't set the x and y position because we don't control that in
|
||||||
|
@ -552,15 +552,15 @@ nsHTMLEditor::AbsolutelyPositionElement(nsIDOMElement * aElement,
|
||||||
// container
|
// container
|
||||||
nsCOMPtr<nsIDOMNode> parentNode;
|
nsCOMPtr<nsIDOMNode> parentNode;
|
||||||
res = aElement->GetParentNode(getter_AddRefs(parentNode));
|
res = aElement->GetParentNode(getter_AddRefs(parentNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMNodeList> childNodes;
|
nsCOMPtr<nsIDOMNodeList> childNodes;
|
||||||
res = parentNode->GetChildNodes(getter_AddRefs(childNodes));
|
res = parentNode->GetChildNodes(getter_AddRefs(childNodes));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!childNodes) return NS_ERROR_NULL_POINTER;
|
if (!childNodes) return NS_ERROR_NULL_POINTER;
|
||||||
PRUint32 childCount;
|
PRUint32 childCount;
|
||||||
res = childNodes->GetLength(&childCount);
|
res = childNodes->GetLength(&childCount);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
if (childCount == 1) {
|
if (childCount == 1) {
|
||||||
nsCOMPtr<nsIDOMNode> brNode;
|
nsCOMPtr<nsIDOMNode> brNode;
|
||||||
|
@ -592,12 +592,12 @@ nsHTMLEditor::AbsolutelyPositionElement(nsIDOMElement * aElement,
|
||||||
|
|
||||||
PRBool hasStyleOrIdOrClass;
|
PRBool hasStyleOrIdOrClass;
|
||||||
res = HasStyleOrIdOrClass(aElement, &hasStyleOrIdOrClass);
|
res = HasStyleOrIdOrClass(aElement, &hasStyleOrIdOrClass);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!hasStyleOrIdOrClass && nsHTMLEditUtils::IsDiv(aElement)) {
|
if (!hasStyleOrIdOrClass && nsHTMLEditUtils::IsDiv(aElement)) {
|
||||||
nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules);
|
nsCOMPtr<nsIHTMLEditRules> htmlRules = do_QueryInterface(mRules);
|
||||||
if (!htmlRules) return NS_ERROR_FAILURE;
|
if (!htmlRules) return NS_ERROR_FAILURE;
|
||||||
res = htmlRules->MakeSureElemStartsOrEndsOnCR(aElement);
|
res = htmlRules->MakeSureElemStartsOrEndsOnCR(aElement);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = RemoveContainer(aElement);
|
res = RemoveContainer(aElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -680,52 +680,52 @@ nsHTMLEditor::CheckPositionedElementBGandFG(nsIDOMElement * aElement,
|
||||||
mHTMLCSSUtils->GetComputedProperty(aElement,
|
mHTMLCSSUtils->GetComputedProperty(aElement,
|
||||||
nsEditProperty::cssBackgroundImage,
|
nsEditProperty::cssBackgroundImage,
|
||||||
bgImageStr);
|
bgImageStr);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (bgImageStr.EqualsLiteral("none")) {
|
if (bgImageStr.EqualsLiteral("none")) {
|
||||||
nsAutoString bgColorStr;
|
nsAutoString bgColorStr;
|
||||||
res =
|
res =
|
||||||
mHTMLCSSUtils->GetComputedProperty(aElement,
|
mHTMLCSSUtils->GetComputedProperty(aElement,
|
||||||
nsEditProperty::cssBackgroundColor,
|
nsEditProperty::cssBackgroundColor,
|
||||||
bgColorStr);
|
bgColorStr);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (bgColorStr.EqualsLiteral("transparent")) {
|
if (bgColorStr.EqualsLiteral("transparent")) {
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMViewCSS> viewCSS;
|
nsCOMPtr<nsIDOMViewCSS> viewCSS;
|
||||||
res = mHTMLCSSUtils->GetDefaultViewCSS(aElement, getter_AddRefs(viewCSS));
|
res = mHTMLCSSUtils->GetDefaultViewCSS(aElement, getter_AddRefs(viewCSS));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
|
nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
|
||||||
res = viewCSS->GetComputedStyle(aElement, EmptyString(), getter_AddRefs(cssDecl));
|
res = viewCSS->GetComputedStyle(aElement, EmptyString(), getter_AddRefs(cssDecl));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
// from these declarations, get the one we want and that one only
|
// from these declarations, get the one we want and that one only
|
||||||
nsCOMPtr<nsIDOMCSSValue> colorCssValue;
|
nsCOMPtr<nsIDOMCSSValue> colorCssValue;
|
||||||
res = cssDecl->GetPropertyCSSValue(NS_LITERAL_STRING("color"), getter_AddRefs(colorCssValue));
|
res = cssDecl->GetPropertyCSSValue(NS_LITERAL_STRING("color"), getter_AddRefs(colorCssValue));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
PRUint16 type;
|
PRUint16 type;
|
||||||
res = colorCssValue->GetCssValueType(&type);
|
res = colorCssValue->GetCssValueType(&type);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (nsIDOMCSSValue::CSS_PRIMITIVE_VALUE == type) {
|
if (nsIDOMCSSValue::CSS_PRIMITIVE_VALUE == type) {
|
||||||
nsCOMPtr<nsIDOMCSSPrimitiveValue> val = do_QueryInterface(colorCssValue);
|
nsCOMPtr<nsIDOMCSSPrimitiveValue> val = do_QueryInterface(colorCssValue);
|
||||||
res = val->GetPrimitiveType(&type);
|
res = val->GetPrimitiveType(&type);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (nsIDOMCSSPrimitiveValue::CSS_RGBCOLOR == type) {
|
if (nsIDOMCSSPrimitiveValue::CSS_RGBCOLOR == type) {
|
||||||
nsCOMPtr<nsIDOMRGBColor> rgbColor;
|
nsCOMPtr<nsIDOMRGBColor> rgbColor;
|
||||||
res = val->GetRGBColorValue(getter_AddRefs(rgbColor));
|
res = val->GetRGBColorValue(getter_AddRefs(rgbColor));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
nsCOMPtr<nsIDOMCSSPrimitiveValue> red, green, blue;
|
nsCOMPtr<nsIDOMCSSPrimitiveValue> red, green, blue;
|
||||||
float r, g, b;
|
float r, g, b;
|
||||||
res = rgbColor->GetRed(getter_AddRefs(red));
|
res = rgbColor->GetRed(getter_AddRefs(red));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = rgbColor->GetGreen(getter_AddRefs(green));
|
res = rgbColor->GetGreen(getter_AddRefs(green));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = rgbColor->GetBlue(getter_AddRefs(blue));
|
res = rgbColor->GetBlue(getter_AddRefs(blue));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = red->GetFloatValue(nsIDOMCSSPrimitiveValue::CSS_NUMBER, &r);
|
res = red->GetFloatValue(nsIDOMCSSPrimitiveValue::CSS_NUMBER, &r);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = green->GetFloatValue(nsIDOMCSSPrimitiveValue::CSS_NUMBER, &g);
|
res = green->GetFloatValue(nsIDOMCSSPrimitiveValue::CSS_NUMBER, &g);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = blue->GetFloatValue(nsIDOMCSSPrimitiveValue::CSS_NUMBER, &b);
|
res = blue->GetFloatValue(nsIDOMCSSPrimitiveValue::CSS_NUMBER, &b);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (r >= BLACK_BG_RGB_TRIGGER &&
|
if (r >= BLACK_BG_RGB_TRIGGER &&
|
||||||
g >= BLACK_BG_RGB_TRIGGER &&
|
g >= BLACK_BG_RGB_TRIGGER &&
|
||||||
b >= BLACK_BG_RGB_TRIGGER)
|
b >= BLACK_BG_RGB_TRIGGER)
|
||||||
|
|
|
@ -83,7 +83,7 @@ static PRInt32 GetCSSFloatValue(nsIDOMCSSStyleDeclaration * aDecl,
|
||||||
case nsIDOMCSSPrimitiveValue::CSS_PX:
|
case nsIDOMCSSPrimitiveValue::CSS_PX:
|
||||||
// the value is in pixels, just get it
|
// the value is in pixels, just get it
|
||||||
res = val->GetFloatValue(nsIDOMCSSPrimitiveValue::CSS_PX, &f);
|
res = val->GetFloatValue(nsIDOMCSSPrimitiveValue::CSS_PX, &f);
|
||||||
if (NS_FAILED(res)) return 0;
|
NS_ENSURE_SUCCESS(res, 0);
|
||||||
break;
|
break;
|
||||||
case nsIDOMCSSPrimitiveValue::CSS_IDENT: {
|
case nsIDOMCSSPrimitiveValue::CSS_IDENT: {
|
||||||
// the value is keyword, we have to map these keywords into
|
// the value is keyword, we have to map these keywords into
|
||||||
|
@ -163,7 +163,7 @@ nsHTMLEditor::CreateAnonymousElement(const nsAString & aTag, nsIDOMNode * aPare
|
||||||
// Create a new node through the element factory
|
// Create a new node through the element factory
|
||||||
nsCOMPtr<nsIContent> newContent;
|
nsCOMPtr<nsIContent> newContent;
|
||||||
nsresult res = CreateHTMLContent(aTag, getter_AddRefs(newContent));
|
nsresult res = CreateHTMLContent(aTag, getter_AddRefs(newContent));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMElement> newElement = do_QueryInterface(newContent);
|
nsCOMPtr<nsIDOMElement> newElement = do_QueryInterface(newContent);
|
||||||
if (!newElement)
|
if (!newElement)
|
||||||
|
@ -173,14 +173,14 @@ nsHTMLEditor::CreateAnonymousElement(const nsAString & aTag, nsIDOMNode * aPare
|
||||||
if (aIsCreatedHidden) {
|
if (aIsCreatedHidden) {
|
||||||
res = newElement->SetAttribute(NS_LITERAL_STRING("class"),
|
res = newElement->SetAttribute(NS_LITERAL_STRING("class"),
|
||||||
NS_LITERAL_STRING("hidden"));
|
NS_LITERAL_STRING("hidden"));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add an _moz_anonclass attribute if needed
|
// add an _moz_anonclass attribute if needed
|
||||||
if (!aAnonClass.IsEmpty()) {
|
if (!aAnonClass.IsEmpty()) {
|
||||||
res = newElement->SetAttribute(NS_LITERAL_STRING("_moz_anonclass"),
|
res = newElement->SetAttribute(NS_LITERAL_STRING("_moz_anonclass"),
|
||||||
aAnonClass);
|
aAnonClass);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -293,12 +293,12 @@ nsHTMLEditor::CheckSelectionStateForAnonymousButtons(nsISelection * aSelection)
|
||||||
// let's get the containing element of the selection
|
// let's get the containing element of the selection
|
||||||
nsresult res = GetSelectionContainer(getter_AddRefs(focusElement));
|
nsresult res = GetSelectionContainer(getter_AddRefs(focusElement));
|
||||||
if (!focusElement) return NS_OK;
|
if (!focusElement) return NS_OK;
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// what's its tag?
|
// what's its tag?
|
||||||
nsAutoString focusTagName;
|
nsAutoString focusTagName;
|
||||||
res = focusElement->GetTagName(focusTagName);
|
res = focusElement->GetTagName(focusTagName);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
ToLowerCase(focusTagName);
|
ToLowerCase(focusTagName);
|
||||||
nsCOMPtr<nsIAtom> focusTagAtom = do_GetAtom(focusTagName);
|
nsCOMPtr<nsIAtom> focusTagAtom = do_GetAtom(focusTagName);
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ nsHTMLEditor::CheckSelectionStateForAnonymousButtons(nsISelection * aSelection)
|
||||||
// Absolute Positioning support is enabled, is the selection contained
|
// Absolute Positioning support is enabled, is the selection contained
|
||||||
// in an absolutely positioned element ?
|
// in an absolutely positioned element ?
|
||||||
res = GetAbsolutelyPositionedSelectionContainer(getter_AddRefs(absPosElement));
|
res = GetAbsolutelyPositionedSelectionContainer(getter_AddRefs(absPosElement));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMElement> cellElement;
|
nsCOMPtr<nsIDOMElement> cellElement;
|
||||||
|
@ -317,7 +317,7 @@ nsHTMLEditor::CheckSelectionStateForAnonymousButtons(nsISelection * aSelection)
|
||||||
res = GetElementOrParentByTagName(NS_LITERAL_STRING("td"),
|
res = GetElementOrParentByTagName(NS_LITERAL_STRING("td"),
|
||||||
nsnull,
|
nsnull,
|
||||||
getter_AddRefs(cellElement));
|
getter_AddRefs(cellElement));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mIsObjectResizingEnabled && cellElement) {
|
if (mIsObjectResizingEnabled && cellElement) {
|
||||||
|
@ -351,21 +351,21 @@ nsHTMLEditor::CheckSelectionStateForAnonymousButtons(nsISelection * aSelection)
|
||||||
if (mIsAbsolutelyPositioningEnabled && mAbsolutelyPositionedObject &&
|
if (mIsAbsolutelyPositioningEnabled && mAbsolutelyPositionedObject &&
|
||||||
absPosElement != mAbsolutelyPositionedObject) {
|
absPosElement != mAbsolutelyPositionedObject) {
|
||||||
res = HideGrabber();
|
res = HideGrabber();
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
NS_ASSERTION(!mAbsolutelyPositionedObject, "HideGrabber failed");
|
NS_ASSERTION(!mAbsolutelyPositionedObject, "HideGrabber failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mIsObjectResizingEnabled && mResizedObject &&
|
if (mIsObjectResizingEnabled && mResizedObject &&
|
||||||
mResizedObject != focusElement) {
|
mResizedObject != focusElement) {
|
||||||
res = HideResizers();
|
res = HideResizers();
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
NS_ASSERTION(!mResizedObject, "HideResizers failed");
|
NS_ASSERTION(!mResizedObject, "HideResizers failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mIsInlineTableEditingEnabled && mInlineEditedCell &&
|
if (mIsInlineTableEditingEnabled && mInlineEditedCell &&
|
||||||
mInlineEditedCell != cellElement) {
|
mInlineEditedCell != cellElement) {
|
||||||
res = HideInlineTableEditingUI();
|
res = HideInlineTableEditingUI();
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
NS_ASSERTION(!mInlineEditedCell, "HideInlineTableEditingUI failed");
|
NS_ASSERTION(!mInlineEditedCell, "HideInlineTableEditingUI failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,7 +379,7 @@ nsHTMLEditor::CheckSelectionStateForAnonymousButtons(nsISelection * aSelection)
|
||||||
res = RefreshResizers();
|
res = RefreshResizers();
|
||||||
else
|
else
|
||||||
res = ShowResizers(focusElement);
|
res = ShowResizers(focusElement);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mIsAbsolutelyPositioningEnabled && absPosElement &&
|
if (mIsAbsolutelyPositioningEnabled && absPosElement &&
|
||||||
|
@ -388,7 +388,7 @@ nsHTMLEditor::CheckSelectionStateForAnonymousButtons(nsISelection * aSelection)
|
||||||
res = RefreshGrabber();
|
res = RefreshGrabber();
|
||||||
else
|
else
|
||||||
res = ShowGrabberOnElement(absPosElement);
|
res = ShowGrabberOnElement(absPosElement);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mIsInlineTableEditingEnabled && cellElement &&
|
if (mIsInlineTableEditingEnabled && cellElement &&
|
||||||
|
@ -418,7 +418,7 @@ nsHTMLEditor::GetPositionAndDimensions(nsIDOMElement * aElement,
|
||||||
// Is the element positioned ? let's check the cheap way first...
|
// Is the element positioned ? let's check the cheap way first...
|
||||||
PRBool isPositioned = PR_FALSE;
|
PRBool isPositioned = PR_FALSE;
|
||||||
nsresult res = aElement->HasAttribute(NS_LITERAL_STRING("_moz_abspos"), &isPositioned);
|
nsresult res = aElement->HasAttribute(NS_LITERAL_STRING("_moz_abspos"), &isPositioned);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!isPositioned) {
|
if (!isPositioned) {
|
||||||
// hmmm... the expensive way now...
|
// hmmm... the expensive way now...
|
||||||
nsAutoString positionStr;
|
nsAutoString positionStr;
|
||||||
|
@ -438,7 +438,7 @@ nsHTMLEditor::GetPositionAndDimensions(nsIDOMElement * aElement,
|
||||||
nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
|
nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
|
||||||
// Get the all the computed css styles attached to the element node
|
// Get the all the computed css styles attached to the element node
|
||||||
res = viewCSS->GetComputedStyle(aElement, EmptyString(), getter_AddRefs(cssDecl));
|
res = viewCSS->GetComputedStyle(aElement, EmptyString(), getter_AddRefs(cssDecl));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
aBorderLeft = GetCSSFloatValue(cssDecl, NS_LITERAL_STRING("border-left-width"));
|
aBorderLeft = GetCSSFloatValue(cssDecl, NS_LITERAL_STRING("border-left-width"));
|
||||||
aBorderTop = GetCSSFloatValue(cssDecl, NS_LITERAL_STRING("border-top-width"));
|
aBorderTop = GetCSSFloatValue(cssDecl, NS_LITERAL_STRING("border-top-width"));
|
||||||
|
@ -460,7 +460,7 @@ nsHTMLEditor::GetPositionAndDimensions(nsIDOMElement * aElement,
|
||||||
GetElementOrigin(aElement, aX, aY);
|
GetElementOrigin(aElement, aX, aY);
|
||||||
|
|
||||||
res = nsElement->GetOffsetWidth(&aW);
|
res = nsElement->GetOffsetWidth(&aW);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = nsElement->GetOffsetHeight(&aH);
|
res = nsElement->GetOffsetHeight(&aH);
|
||||||
|
|
||||||
aBorderLeft = 0;
|
aBorderLeft = 0;
|
||||||
|
|
|
@ -317,7 +317,7 @@ nsHTMLCSSUtils::Init(nsHTMLEditor *aEditor)
|
||||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &result);
|
do_GetService(NS_PREFSERVICE_CONTRACTID, &result);
|
||||||
if (NS_SUCCEEDED(result) && prefBranch) {
|
if (NS_SUCCEEDED(result) && prefBranch) {
|
||||||
result = prefBranch->GetBoolPref("editor.use_css", &mIsCSSPrefChecked);
|
result = prefBranch->GetBoolPref("editor.use_css", &mIsCSSPrefChecked);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -542,7 +542,7 @@ nsHTMLCSSUtils::GetComputedProperty(nsIDOMNode *aNode, nsIAtom *aProperty,
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMViewCSS> viewCSS = nsnull;
|
nsCOMPtr<nsIDOMViewCSS> viewCSS = nsnull;
|
||||||
nsresult res = GetDefaultViewCSS(aNode, getter_AddRefs(viewCSS));
|
nsresult res = GetDefaultViewCSS(aNode, getter_AddRefs(viewCSS));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
return GetCSSInlinePropertyBase(aNode, aProperty, aValue, viewCSS, COMPUTED_STYLE_TYPE);
|
return GetCSSInlinePropertyBase(aNode, aProperty, aValue, viewCSS, COMPUTED_STYLE_TYPE);
|
||||||
}
|
}
|
||||||
|
@ -558,7 +558,7 @@ nsHTMLCSSUtils::GetCSSInlinePropertyBase(nsIDOMNode *aNode, nsIAtom *aProperty,
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMElement>element;
|
nsCOMPtr<nsIDOMElement>element;
|
||||||
nsresult res = GetElementContainerOrSelf(aNode, getter_AddRefs(element));
|
nsresult res = GetElementContainerOrSelf(aNode, getter_AddRefs(element));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
switch (aStyleType) {
|
switch (aStyleType) {
|
||||||
case COMPUTED_STYLE_TYPE:
|
case COMPUTED_STYLE_TYPE:
|
||||||
|
@ -571,7 +571,7 @@ nsHTMLCSSUtils::GetCSSInlinePropertyBase(nsIDOMNode *aNode, nsIAtom *aProperty,
|
||||||
if (NS_FAILED(res) || !cssDecl) return res;
|
if (NS_FAILED(res) || !cssDecl) return res;
|
||||||
// from these declarations, get the one we want and that one only
|
// from these declarations, get the one we want and that one only
|
||||||
res = cssDecl->GetPropertyValue(propString, value);
|
res = cssDecl->GetPropertyValue(propString, value);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
aValue.Assign(value);
|
aValue.Assign(value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -584,7 +584,7 @@ nsHTMLCSSUtils::GetCSSInlinePropertyBase(nsIDOMNode *aNode, nsIAtom *aProperty,
|
||||||
nsAutoString value, propString;
|
nsAutoString value, propString;
|
||||||
aProperty->ToString(propString);
|
aProperty->ToString(propString);
|
||||||
res = cssDecl->GetPropertyValue(propString, value);
|
res = cssDecl->GetPropertyValue(propString, value);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
aValue.Assign(value);
|
aValue.Assign(value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -597,7 +597,7 @@ nsHTMLCSSUtils::GetDefaultViewCSS(nsIDOMNode *aNode, nsIDOMViewCSS **aViewCSS)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMElement>element;
|
nsCOMPtr<nsIDOMElement>element;
|
||||||
nsresult res = GetElementContainerOrSelf(aNode, getter_AddRefs(element));
|
nsresult res = GetElementContainerOrSelf(aNode, getter_AddRefs(element));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// if we have an element node
|
// if we have an element node
|
||||||
if (element) {
|
if (element) {
|
||||||
|
@ -605,13 +605,13 @@ nsHTMLCSSUtils::GetDefaultViewCSS(nsIDOMNode *aNode, nsIDOMViewCSS **aViewCSS)
|
||||||
nsCOMPtr<nsIDOMDocument> doc;
|
nsCOMPtr<nsIDOMDocument> doc;
|
||||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(element);
|
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(element);
|
||||||
res = node->GetOwnerDocument(getter_AddRefs(doc));
|
res = node->GetOwnerDocument(getter_AddRefs(doc));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (doc) {
|
if (doc) {
|
||||||
nsCOMPtr<nsIDOMDocumentView> documentView = do_QueryInterface(doc);
|
nsCOMPtr<nsIDOMDocumentView> documentView = do_QueryInterface(doc);
|
||||||
nsCOMPtr<nsIDOMAbstractView> abstractView;
|
nsCOMPtr<nsIDOMAbstractView> abstractView;
|
||||||
// from the document, get the abtractView
|
// from the document, get the abtractView
|
||||||
res = documentView->GetDefaultView(getter_AddRefs(abstractView));
|
res = documentView->GetDefaultView(getter_AddRefs(abstractView));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (abstractView) {
|
if (abstractView) {
|
||||||
// from the abstractView, get the CSS view
|
// from the abstractView, get the CSS view
|
||||||
CallQueryInterface(abstractView, aViewCSS);
|
CallQueryInterface(abstractView, aViewCSS);
|
||||||
|
@ -645,7 +645,7 @@ nsHTMLCSSUtils::RemoveCSSInlineStyle(nsIDOMNode *aNode, nsIAtom *aProperty, cons
|
||||||
|
|
||||||
// remove the property from the style attribute
|
// remove the property from the style attribute
|
||||||
nsresult res = RemoveCSSProperty(elem, aProperty, aPropertyValue, PR_FALSE);
|
nsresult res = RemoveCSSProperty(elem, aProperty, aPropertyValue, PR_FALSE);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
if (nsEditor::NodeIsType(aNode, nsEditProperty::span)) {
|
if (nsEditor::NodeIsType(aNode, nsEditProperty::span)) {
|
||||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
|
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
|
||||||
|
@ -654,13 +654,13 @@ nsHTMLCSSUtils::RemoveCSSInlineStyle(nsIDOMNode *aNode, nsIAtom *aProperty, cons
|
||||||
if (0 == attrCount) {
|
if (0 == attrCount) {
|
||||||
// no more attributes on this span, let's remove the element
|
// no more attributes on this span, let's remove the element
|
||||||
res = mHTMLEditor->RemoveContainer(aNode);
|
res = mHTMLEditor->RemoveContainer(aNode);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
else if (1 == attrCount) {
|
else if (1 == attrCount) {
|
||||||
// incredible hack in case the only remaining attribute is a _moz_dirty...
|
// incredible hack in case the only remaining attribute is a _moz_dirty...
|
||||||
if (content->GetAttrNameAt(0)->Equals(nsEditProperty::mozdirty)) {
|
if (content->GetAttrNameAt(0)->Equals(nsEditProperty::mozdirty)) {
|
||||||
res = mHTMLEditor->RemoveContainer(aNode);
|
res = mHTMLEditor->RemoveContainer(aNode);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -682,26 +682,26 @@ nsHTMLCSSUtils::GetDefaultBackgroundColor(nsAString & aColor)
|
||||||
nsresult result;
|
nsresult result;
|
||||||
nsCOMPtr<nsIPrefBranch> prefBranch =
|
nsCOMPtr<nsIPrefBranch> prefBranch =
|
||||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &result);
|
do_GetService(NS_PREFSERVICE_CONTRACTID, &result);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
aColor.AssignLiteral("#ffffff");
|
aColor.AssignLiteral("#ffffff");
|
||||||
nsXPIDLCString returnColor;
|
nsXPIDLCString returnColor;
|
||||||
if (prefBranch) {
|
if (prefBranch) {
|
||||||
PRBool useCustomColors;
|
PRBool useCustomColors;
|
||||||
result = prefBranch->GetBoolPref("editor.use_custom_colors", &useCustomColors);
|
result = prefBranch->GetBoolPref("editor.use_custom_colors", &useCustomColors);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (useCustomColors) {
|
if (useCustomColors) {
|
||||||
result = prefBranch->GetCharPref("editor.background_color",
|
result = prefBranch->GetCharPref("editor.background_color",
|
||||||
getter_Copies(returnColor));
|
getter_Copies(returnColor));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PRBool useSystemColors;
|
PRBool useSystemColors;
|
||||||
result = prefBranch->GetBoolPref("browser.display.use_system_colors", &useSystemColors);
|
result = prefBranch->GetBoolPref("browser.display.use_system_colors", &useSystemColors);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!useSystemColors) {
|
if (!useSystemColors) {
|
||||||
result = prefBranch->GetCharPref("browser.display.background_color",
|
result = prefBranch->GetCharPref("browser.display.background_color",
|
||||||
getter_Copies(returnColor));
|
getter_Copies(returnColor));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -718,13 +718,13 @@ nsHTMLCSSUtils::GetDefaultLengthUnit(nsAString & aLengthUnit)
|
||||||
nsresult result;
|
nsresult result;
|
||||||
nsCOMPtr<nsIPrefBranch> prefBranch =
|
nsCOMPtr<nsIPrefBranch> prefBranch =
|
||||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &result);
|
do_GetService(NS_PREFSERVICE_CONTRACTID, &result);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
aLengthUnit.AssignLiteral("px");
|
aLengthUnit.AssignLiteral("px");
|
||||||
if (NS_SUCCEEDED(result) && prefBranch) {
|
if (NS_SUCCEEDED(result) && prefBranch) {
|
||||||
nsXPIDLCString returnLengthUnit;
|
nsXPIDLCString returnLengthUnit;
|
||||||
result = prefBranch->GetCharPref("editor.css.default_length_unit",
|
result = prefBranch->GetCharPref("editor.css.default_length_unit",
|
||||||
getter_Copies(returnLengthUnit));
|
getter_Copies(returnLengthUnit));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (returnLengthUnit) {
|
if (returnLengthUnit) {
|
||||||
CopyASCIItoUTF16(returnLengthUnit, aLengthUnit);
|
CopyASCIItoUTF16(returnLengthUnit, aLengthUnit);
|
||||||
}
|
}
|
||||||
|
@ -1009,7 +1009,7 @@ nsHTMLCSSUtils::SetCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
|
||||||
nsCOMPtr<nsIDOMElement> theElement = do_QueryInterface(aNode);
|
nsCOMPtr<nsIDOMElement> theElement = do_QueryInterface(aNode);
|
||||||
res = SetCSSProperty(theElement, cssPropertyArray[index],
|
res = SetCSSProperty(theElement, cssPropertyArray[index],
|
||||||
cssValueArray[index], aSuppressTransaction);
|
cssValueArray[index], aSuppressTransaction);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -1044,7 +1044,7 @@ nsHTMLCSSUtils::RemoveCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
|
||||||
cssPropertyArray[index],
|
cssPropertyArray[index],
|
||||||
cssValueArray[index],
|
cssValueArray[index],
|
||||||
aSuppressTransaction);
|
aSuppressTransaction);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -1059,9 +1059,9 @@ nsHTMLCSSUtils::HasClassOrID(nsIDOMElement * aElement, PRBool & aReturn)
|
||||||
aReturn = PR_FALSE;
|
aReturn = PR_FALSE;
|
||||||
|
|
||||||
nsresult res = mHTMLEditor->GetAttributeValue(aElement, NS_LITERAL_STRING("class"), classVal, &isClassSet);
|
nsresult res = mHTMLEditor->GetAttributeValue(aElement, NS_LITERAL_STRING("class"), classVal, &isClassSet);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = mHTMLEditor->GetAttributeValue(aElement, NS_LITERAL_STRING("id"), idVal, &isIdSet);
|
res = mHTMLEditor->GetAttributeValue(aElement, NS_LITERAL_STRING("id"), idVal, &isIdSet);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// we need to make sure that if the element has an id or a class attribute,
|
// we need to make sure that if the element has an id or a class attribute,
|
||||||
// the attribute is not the empty string
|
// the attribute is not the empty string
|
||||||
|
@ -1084,7 +1084,7 @@ nsHTMLCSSUtils::GetCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode,
|
||||||
aValueString.Truncate();
|
aValueString.Truncate();
|
||||||
nsCOMPtr<nsIDOMElement> theElement;
|
nsCOMPtr<nsIDOMElement> theElement;
|
||||||
nsresult res = GetElementContainerOrSelf(aNode, getter_AddRefs(theElement));
|
nsresult res = GetElementContainerOrSelf(aNode, getter_AddRefs(theElement));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
if (theElement && IsCSSEditableProperty(theElement, aHTMLProperty, aAttribute)) {
|
if (theElement && IsCSSEditableProperty(theElement, aHTMLProperty, aAttribute)) {
|
||||||
// Yes, the requested HTML style has a CSS equivalence in this implementation
|
// Yes, the requested HTML style has a CSS equivalence in this implementation
|
||||||
|
@ -1092,7 +1092,7 @@ nsHTMLCSSUtils::GetCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode,
|
||||||
nsCOMPtr<nsIDOMViewCSS> viewCSS = nsnull;
|
nsCOMPtr<nsIDOMViewCSS> viewCSS = nsnull;
|
||||||
if (COMPUTED_STYLE_TYPE == aStyleType) {
|
if (COMPUTED_STYLE_TYPE == aStyleType) {
|
||||||
res = GetDefaultViewCSS(theElement, getter_AddRefs(viewCSS));
|
res = GetDefaultViewCSS(theElement, getter_AddRefs(viewCSS));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
nsTArray<nsIAtom*> cssPropertyArray;
|
nsTArray<nsIAtom*> cssPropertyArray;
|
||||||
nsTArray<nsString> cssValueArray;
|
nsTArray<nsString> cssValueArray;
|
||||||
|
@ -1107,7 +1107,7 @@ nsHTMLCSSUtils::GetCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode,
|
||||||
// retrieve the specified/computed value of the property
|
// retrieve the specified/computed value of the property
|
||||||
res = GetCSSInlinePropertyBase(theElement, cssPropertyArray[index],
|
res = GetCSSInlinePropertyBase(theElement, cssPropertyArray[index],
|
||||||
valueString, viewCSS, aStyleType);
|
valueString, viewCSS, aStyleType);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
// append the value to aValueString (possibly with a leading whitespace)
|
// append the value to aValueString (possibly with a leading whitespace)
|
||||||
if (index) aValueString.Append(PRUnichar(' '));
|
if (index) aValueString.Append(PRUnichar(' '));
|
||||||
aValueString.Append(valueString);
|
aValueString.Append(valueString);
|
||||||
|
@ -1140,7 +1140,7 @@ nsHTMLCSSUtils::IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode,
|
||||||
// get the value of the CSS equivalent styles
|
// get the value of the CSS equivalent styles
|
||||||
nsresult res = GetCSSEquivalentToHTMLInlineStyleSet(node, aHTMLProperty, aHTMLAttribute,
|
nsresult res = GetCSSEquivalentToHTMLInlineStyleSet(node, aHTMLProperty, aHTMLAttribute,
|
||||||
valueString, aStyleType);
|
valueString, aStyleType);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// early way out if we can
|
// early way out if we can
|
||||||
if (valueString.IsEmpty()) return NS_OK;
|
if (valueString.IsEmpty()) return NS_OK;
|
||||||
|
@ -1274,7 +1274,7 @@ nsHTMLCSSUtils::IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode,
|
||||||
// that means that we have to look at ancestors of node to see if they are underlined
|
// that means that we have to look at ancestors of node to see if they are underlined
|
||||||
nsCOMPtr<nsIDOMNode> tmp;
|
nsCOMPtr<nsIDOMNode> tmp;
|
||||||
res = node->GetParentNode(getter_AddRefs(tmp));
|
res = node->GetParentNode(getter_AddRefs(tmp));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(tmp);
|
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(tmp);
|
||||||
node = element; // set to null if it's not a dom element
|
node = element; // set to null if it's not a dom element
|
||||||
}
|
}
|
||||||
|
@ -1402,7 +1402,7 @@ nsHTMLCSSUtils::GetElementContainerOrSelf(nsIDOMNode * aNode, nsIDOMElement ** a
|
||||||
PRUint16 type;
|
PRUint16 type;
|
||||||
nsresult res;
|
nsresult res;
|
||||||
res = node->GetNodeType(&type);
|
res = node->GetNodeType(&type);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
if (nsIDOMNode::DOCUMENT_NODE == type) {
|
if (nsIDOMNode::DOCUMENT_NODE == type) {
|
||||||
return NS_ERROR_NULL_POINTER;
|
return NS_ERROR_NULL_POINTER;
|
||||||
|
@ -1412,10 +1412,10 @@ nsHTMLCSSUtils::GetElementContainerOrSelf(nsIDOMNode * aNode, nsIDOMElement ** a
|
||||||
while (node && nsIDOMNode::ELEMENT_NODE != type) {
|
while (node && nsIDOMNode::ELEMENT_NODE != type) {
|
||||||
parentNode = node;
|
parentNode = node;
|
||||||
res = parentNode->GetParentNode(getter_AddRefs(node));
|
res = parentNode->GetParentNode(getter_AddRefs(node));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (node) {
|
if (node) {
|
||||||
res = node->GetNodeType(&type);
|
res = node->GetNodeType(&type);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NS_ASSERTION(node, "we reached a null node ancestor !");
|
NS_ASSERTION(node, "we reached a null node ancestor !");
|
||||||
|
|
|
@ -184,24 +184,24 @@ NS_IMETHODIMP nsHTMLEditor::LoadHTML(const nsAString & aInputString)
|
||||||
// Get selection
|
// Get selection
|
||||||
nsCOMPtr<nsISelection>selection;
|
nsCOMPtr<nsISelection>selection;
|
||||||
nsresult res = GetSelection(getter_AddRefs(selection));
|
nsresult res = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
nsTextRulesInfo ruleInfo(nsTextEditRules::kLoadHTML);
|
nsTextRulesInfo ruleInfo(nsTextEditRules::kLoadHTML);
|
||||||
PRBool cancel, handled;
|
PRBool cancel, handled;
|
||||||
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (cancel) return NS_OK; // rules canceled the operation
|
if (cancel) return NS_OK; // rules canceled the operation
|
||||||
if (!handled)
|
if (!handled)
|
||||||
{
|
{
|
||||||
PRBool isCollapsed;
|
PRBool isCollapsed;
|
||||||
res = selection->GetIsCollapsed(&isCollapsed);
|
res = selection->GetIsCollapsed(&isCollapsed);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// Delete Selection, but only if it isn't collapsed, see bug #106269
|
// Delete Selection, but only if it isn't collapsed, see bug #106269
|
||||||
if (!isCollapsed)
|
if (!isCollapsed)
|
||||||
{
|
{
|
||||||
res = DeleteSelection(eNone);
|
res = DeleteSelection(eNone);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the first range in the selection, for context:
|
// Get the first range in the selection, for context:
|
||||||
|
@ -274,7 +274,7 @@ nsHTMLEditor::InsertHTMLWithContext(const nsAString & aInputString,
|
||||||
nsresult res;
|
nsresult res;
|
||||||
nsCOMPtr<nsISelection>selection;
|
nsCOMPtr<nsISelection>selection;
|
||||||
res = GetSelection(getter_AddRefs(selection));
|
res = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// create a dom document fragment that represents the structure to paste
|
// create a dom document fragment that represents the structure to paste
|
||||||
nsCOMPtr<nsIDOMNode> fragmentAsNode, streamStartParent, streamEndParent;
|
nsCOMPtr<nsIDOMNode> fragmentAsNode, streamStartParent, streamEndParent;
|
||||||
|
@ -297,7 +297,7 @@ nsHTMLEditor::InsertHTMLWithContext(const nsAString & aInputString,
|
||||||
// fetch the paste insertion point from our selection
|
// fetch the paste insertion point from our selection
|
||||||
res = GetStartNodeAndOffset(selection, getter_AddRefs(targetNode), &targetOffset);
|
res = GetStartNodeAndOffset(selection, getter_AddRefs(targetNode), &targetOffset);
|
||||||
if (!targetNode) res = NS_ERROR_FAILURE;
|
if (!targetNode) res = NS_ERROR_FAILURE;
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -411,7 +411,7 @@ nsHTMLEditor::InsertHTMLWithContext(const nsAString & aInputString,
|
||||||
nsTextRulesInfo ruleInfo(nsTextEditRules::kInsertElement);
|
nsTextRulesInfo ruleInfo(nsTextEditRules::kInsertElement);
|
||||||
PRBool cancel, handled;
|
PRBool cancel, handled;
|
||||||
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (cancel) return NS_OK; // rules canceled the operation
|
if (cancel) return NS_OK; // rules canceled the operation
|
||||||
if (!handled)
|
if (!handled)
|
||||||
{
|
{
|
||||||
|
@ -419,7 +419,7 @@ nsHTMLEditor::InsertHTMLWithContext(const nsAString & aInputString,
|
||||||
// refresh our memory...
|
// refresh our memory...
|
||||||
res = GetStartNodeAndOffset(selection, getter_AddRefs(parentNode), &offsetOfNewNode);
|
res = GetStartNodeAndOffset(selection, getter_AddRefs(parentNode), &offsetOfNewNode);
|
||||||
if (!parentNode) res = NS_ERROR_FAILURE;
|
if (!parentNode) res = NS_ERROR_FAILURE;
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// Adjust position based on the first node we are going to insert.
|
// Adjust position based on the first node we are going to insert.
|
||||||
NormalizeEOLInsertPosition(nodeList[0], address_of(parentNode), &offsetOfNewNode);
|
NormalizeEOLInsertPosition(nodeList[0], address_of(parentNode), &offsetOfNewNode);
|
||||||
|
@ -432,7 +432,7 @@ nsHTMLEditor::InsertHTMLWithContext(const nsAString & aInputString,
|
||||||
!IsVisBreak(wsObj.mEndReasonNode) )
|
!IsVisBreak(wsObj.mEndReasonNode) )
|
||||||
{
|
{
|
||||||
res = DeleteNode(wsObj.mEndReasonNode);
|
res = DeleteNode(wsObj.mEndReasonNode);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remeber if we are in a link.
|
// remeber if we are in a link.
|
||||||
|
@ -443,9 +443,9 @@ nsHTMLEditor::InsertHTMLWithContext(const nsAString & aInputString,
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMNode> temp;
|
nsCOMPtr<nsIDOMNode> temp;
|
||||||
res = SplitNodeDeep(parentNode, parentNode, offsetOfNewNode, &offsetOfNewNode);
|
res = SplitNodeDeep(parentNode, parentNode, offsetOfNewNode, &offsetOfNewNode);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = parentNode->GetParentNode(getter_AddRefs(temp));
|
res = parentNode->GetParentNode(getter_AddRefs(temp));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
parentNode = temp;
|
parentNode = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -654,7 +654,7 @@ nsHTMLEditor::InsertHTMLWithContext(const nsAString & aInputString,
|
||||||
if (!nsHTMLEditUtils::IsTable(lastInsertNode))
|
if (!nsHTMLEditUtils::IsTable(lastInsertNode))
|
||||||
{
|
{
|
||||||
res = GetLastEditableLeaf(lastInsertNode, address_of(selNode));
|
res = GetLastEditableLeaf(lastInsertNode, address_of(selNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
tmp = selNode;
|
tmp = selNode;
|
||||||
while (tmp && (tmp != lastInsertNode))
|
while (tmp && (tmp != lastInsertNode))
|
||||||
{
|
{
|
||||||
|
@ -672,14 +672,14 @@ nsHTMLEditor::InsertHTMLWithContext(const nsAString & aInputString,
|
||||||
if (IsTextNode(selNode) || (IsContainer(selNode) && !nsHTMLEditUtils::IsTable(selNode)))
|
if (IsTextNode(selNode) || (IsContainer(selNode) && !nsHTMLEditUtils::IsTable(selNode)))
|
||||||
{
|
{
|
||||||
res = GetLengthOfDOMNode(selNode, (PRUint32&)selOffset);
|
res = GetLengthOfDOMNode(selNode, (PRUint32&)selOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
else // we need to find a container for selection. Look up.
|
else // we need to find a container for selection. Look up.
|
||||||
{
|
{
|
||||||
tmp = selNode;
|
tmp = selNode;
|
||||||
res = GetNodeLocation(tmp, address_of(selNode), &selOffset);
|
res = GetNodeLocation(tmp, address_of(selNode), &selOffset);
|
||||||
++selOffset; // want to be *after* last leaf node in paste
|
++selOffset; // want to be *after* last leaf node in paste
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure we don't end up with selection collapsed after an invisible break node
|
// make sure we don't end up with selection collapsed after an invisible break node
|
||||||
|
@ -687,7 +687,7 @@ nsHTMLEditor::InsertHTMLWithContext(const nsAString & aInputString,
|
||||||
PRInt32 outVisOffset=0;
|
PRInt32 outVisOffset=0;
|
||||||
PRInt16 visType=0;
|
PRInt16 visType=0;
|
||||||
res = wsRunObj.PriorVisibleNode(selNode, selOffset, address_of(visNode), &outVisOffset, &visType);
|
res = wsRunObj.PriorVisibleNode(selNode, selOffset, address_of(visNode), &outVisOffset, &visType);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (visType == nsWSRunObject::eBreak)
|
if (visType == nsWSRunObject::eBreak)
|
||||||
{
|
{
|
||||||
// we are after a break. Is it visible? Despite the name,
|
// we are after a break. Is it visible? Despite the name,
|
||||||
|
@ -702,7 +702,7 @@ nsHTMLEditor::InsertHTMLWithContext(const nsAString & aInputString,
|
||||||
// we want to be inside any inline style prior to break
|
// we want to be inside any inline style prior to break
|
||||||
nsWSRunObject wsRunObj(this, selNode, selOffset);
|
nsWSRunObject wsRunObj(this, selNode, selOffset);
|
||||||
res = wsRunObj.PriorVisibleNode(selNode, selOffset, address_of(visNode), &outVisOffset, &visType);
|
res = wsRunObj.PriorVisibleNode(selNode, selOffset, address_of(visNode), &outVisOffset, &visType);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (visType == nsWSRunObject::eText ||
|
if (visType == nsWSRunObject::eText ||
|
||||||
visType == nsWSRunObject::eNormalWS)
|
visType == nsWSRunObject::eNormalWS)
|
||||||
{
|
{
|
||||||
|
@ -731,9 +731,9 @@ nsHTMLEditor::InsertHTMLWithContext(const nsAString & aInputString,
|
||||||
nsCOMPtr<nsIDOMNode> leftLink;
|
nsCOMPtr<nsIDOMNode> leftLink;
|
||||||
PRInt32 linkOffset;
|
PRInt32 linkOffset;
|
||||||
res = SplitNodeDeep(link, selNode, selOffset, &linkOffset, PR_TRUE, address_of(leftLink));
|
res = SplitNodeDeep(link, selNode, selOffset, &linkOffset, PR_TRUE, address_of(leftLink));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = GetNodeLocation(leftLink, address_of(selNode), &selOffset);
|
res = GetNodeLocation(leftLink, address_of(selNode), &selOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
selection->Collapse(selNode, selOffset+1);
|
selection->Collapse(selNode, selOffset+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1485,7 +1485,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIDragService> dragService =
|
nsCOMPtr<nsIDragService> dragService =
|
||||||
do_GetService("@mozilla.org/widget/dragservice;1", &rv);
|
do_GetService("@mozilla.org/widget/dragservice;1", &rv);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsIDragSession> dragSession;
|
nsCOMPtr<nsIDragSession> dragSession;
|
||||||
dragService->GetCurrentSession(getter_AddRefs(dragSession));
|
dragService->GetCurrentSession(getter_AddRefs(dragSession));
|
||||||
|
@ -1499,17 +1499,17 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
|
||||||
// around with cfhtml if we do.
|
// around with cfhtml if we do.
|
||||||
PRBool bHavePrivateHTMLFlavor = PR_FALSE;
|
PRBool bHavePrivateHTMLFlavor = PR_FALSE;
|
||||||
rv = dragSession->IsDataFlavorSupported(kHTMLContext, &bHavePrivateHTMLFlavor);
|
rv = dragSession->IsDataFlavorSupported(kHTMLContext, &bHavePrivateHTMLFlavor);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// Get the nsITransferable interface for getting the data from the drop
|
// Get the nsITransferable interface for getting the data from the drop
|
||||||
nsCOMPtr<nsITransferable> trans;
|
nsCOMPtr<nsITransferable> trans;
|
||||||
rv = PrepareHTMLTransferable(getter_AddRefs(trans), bHavePrivateHTMLFlavor);
|
rv = PrepareHTMLTransferable(getter_AddRefs(trans), bHavePrivateHTMLFlavor);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (!trans) return NS_OK; // NS_ERROR_FAILURE; SHOULD WE FAIL?
|
if (!trans) return NS_OK; // NS_ERROR_FAILURE; SHOULD WE FAIL?
|
||||||
|
|
||||||
PRUint32 numItems = 0;
|
PRUint32 numItems = 0;
|
||||||
rv = dragSession->GetNumDropItems(&numItems);
|
rv = dragSession->GetNumDropItems(&numItems);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// Combine any deletion and drop insertion into one transaction
|
// Combine any deletion and drop insertion into one transaction
|
||||||
nsAutoEditBatch beginBatching(this);
|
nsAutoEditBatch beginBatching(this);
|
||||||
|
@ -1522,14 +1522,14 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
|
||||||
// Source doc is null if source is *not* the current editor document
|
// Source doc is null if source is *not* the current editor document
|
||||||
nsCOMPtr<nsIDOMDocument> srcdomdoc;
|
nsCOMPtr<nsIDOMDocument> srcdomdoc;
|
||||||
rv = dragSession->GetSourceDocument(getter_AddRefs(srcdomdoc));
|
rv = dragSession->GetSourceDocument(getter_AddRefs(srcdomdoc));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
PRUint32 i;
|
PRUint32 i;
|
||||||
PRBool doPlaceCaret = PR_TRUE;
|
PRBool doPlaceCaret = PR_TRUE;
|
||||||
for (i = 0; i < numItems; ++i)
|
for (i = 0; i < numItems; ++i)
|
||||||
{
|
{
|
||||||
rv = dragSession->GetData(trans, i);
|
rv = dragSession->GetData(trans, i);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (!trans) return NS_OK; // NS_ERROR_FAILURE; Should we fail?
|
if (!trans) return NS_OK; // NS_ERROR_FAILURE; Should we fail?
|
||||||
|
|
||||||
// get additional html copy hints, if present
|
// get additional html copy hints, if present
|
||||||
|
@ -1591,24 +1591,24 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
|
||||||
// Current doc is destination
|
// Current doc is destination
|
||||||
nsCOMPtr<nsIDOMDocument>destdomdoc;
|
nsCOMPtr<nsIDOMDocument>destdomdoc;
|
||||||
rv = GetDocument(getter_AddRefs(destdomdoc));
|
rv = GetDocument(getter_AddRefs(destdomdoc));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
rv = GetSelection(getter_AddRefs(selection));
|
rv = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (!selection) return NS_ERROR_FAILURE;
|
if (!selection) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
PRBool isCollapsed;
|
PRBool isCollapsed;
|
||||||
rv = selection->GetIsCollapsed(&isCollapsed);
|
rv = selection->GetIsCollapsed(&isCollapsed);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// Parent and offset under the mouse cursor
|
// Parent and offset under the mouse cursor
|
||||||
rv = nsuiEvent->GetRangeParent(getter_AddRefs(newSelectionParent));
|
rv = nsuiEvent->GetRangeParent(getter_AddRefs(newSelectionParent));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (!newSelectionParent) return NS_ERROR_FAILURE;
|
if (!newSelectionParent) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
rv = nsuiEvent->GetRangeOffset(&newSelectionOffset);
|
rv = nsuiEvent->GetRangeOffset(&newSelectionOffset);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// XXX: This userSelectNode code is a workaround for bug 195957.
|
// XXX: This userSelectNode code is a workaround for bug 195957.
|
||||||
//
|
//
|
||||||
|
@ -1631,7 +1631,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
|
||||||
rv = GetNodeLocation(userSelectNode, address_of(newSelectionParent),
|
rv = GetNodeLocation(userSelectNode, address_of(newSelectionParent),
|
||||||
&newSelectionOffset);
|
&newSelectionOffset);
|
||||||
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (!newSelectionParent) return NS_ERROR_FAILURE;
|
if (!newSelectionParent) return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1720,7 +1720,7 @@ nsHTMLEditor::PutDragDataInTransferable(nsITransferable **aTransferable)
|
||||||
*aTransferable = nsnull;
|
*aTransferable = nsnull;
|
||||||
nsCOMPtr<nsIDocumentEncoder> docEncoder;
|
nsCOMPtr<nsIDocumentEncoder> docEncoder;
|
||||||
nsresult rv = SetupDocEncoder(getter_AddRefs(docEncoder));
|
nsresult rv = SetupDocEncoder(getter_AddRefs(docEncoder));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
NS_ENSURE_TRUE(docEncoder, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(docEncoder, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
// grab a string
|
// grab a string
|
||||||
|
@ -1731,13 +1731,13 @@ nsHTMLEditor::PutDragDataInTransferable(nsITransferable **aTransferable)
|
||||||
{
|
{
|
||||||
// encode the selection as html with contextual info
|
// encode the selection as html with contextual info
|
||||||
rv = docEncoder->EncodeToStringWithContext(parents, info, buffer);
|
rv = docEncoder->EncodeToStringWithContext(parents, info, buffer);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// encode the selection
|
// encode the selection
|
||||||
rv = docEncoder->EncodeToString(buffer);
|
rv = docEncoder->EncodeToString(buffer);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we have an empty string, we're done; otherwise continue
|
// if we have an empty string, we're done; otherwise continue
|
||||||
|
@ -1749,7 +1749,7 @@ nsHTMLEditor::PutDragDataInTransferable(nsITransferable **aTransferable)
|
||||||
dataWrapper = do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv);
|
dataWrapper = do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
rv = dataWrapper->SetData(buffer);
|
rv = dataWrapper->SetData(buffer);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
/* create html flavor transferable */
|
/* create html flavor transferable */
|
||||||
nsCOMPtr<nsITransferable> trans = do_CreateInstance("@mozilla.org/widget/transferable;1");
|
nsCOMPtr<nsITransferable> trans = do_CreateInstance("@mozilla.org/widget/transferable;1");
|
||||||
|
@ -1759,14 +1759,14 @@ nsHTMLEditor::PutDragDataInTransferable(nsITransferable **aTransferable)
|
||||||
{
|
{
|
||||||
// Add the unicode flavor to the transferable
|
// Add the unicode flavor to the transferable
|
||||||
rv = trans->AddDataFlavor(kUnicodeMime);
|
rv = trans->AddDataFlavor(kUnicodeMime);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// QI the data object an |nsISupports| so that when the transferable holds
|
// QI the data object an |nsISupports| so that when the transferable holds
|
||||||
// onto it, it will addref the correct interface.
|
// onto it, it will addref the correct interface.
|
||||||
nsCOMPtr<nsISupports> genericDataObj(do_QueryInterface(dataWrapper));
|
nsCOMPtr<nsISupports> genericDataObj(do_QueryInterface(dataWrapper));
|
||||||
rv = trans->SetTransferData(kUnicodeMime, genericDataObj,
|
rv = trans->SetTransferData(kUnicodeMime, genericDataObj,
|
||||||
buffer.Length() * sizeof(PRUnichar));
|
buffer.Length() * sizeof(PRUnichar));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1779,19 +1779,19 @@ nsHTMLEditor::PutDragDataInTransferable(nsITransferable **aTransferable)
|
||||||
infoWrapper->SetData(info);
|
infoWrapper->SetData(info);
|
||||||
|
|
||||||
rv = trans->AddDataFlavor(kHTMLMime);
|
rv = trans->AddDataFlavor(kHTMLMime);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsIFormatConverter> htmlConverter =
|
nsCOMPtr<nsIFormatConverter> htmlConverter =
|
||||||
do_CreateInstance("@mozilla.org/widget/htmlformatconverter;1");
|
do_CreateInstance("@mozilla.org/widget/htmlformatconverter;1");
|
||||||
NS_ENSURE_TRUE(htmlConverter, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(htmlConverter, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
rv = trans->SetConverter(htmlConverter);
|
rv = trans->SetConverter(htmlConverter);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsISupports> genericDataObj(do_QueryInterface(dataWrapper));
|
nsCOMPtr<nsISupports> genericDataObj(do_QueryInterface(dataWrapper));
|
||||||
rv = trans->SetTransferData(kHTMLMime, genericDataObj,
|
rv = trans->SetTransferData(kHTMLMime, genericDataObj,
|
||||||
buffer.Length() * sizeof(PRUnichar));
|
buffer.Length() * sizeof(PRUnichar));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
if (!parents.IsEmpty())
|
if (!parents.IsEmpty())
|
||||||
{
|
{
|
||||||
|
@ -1993,7 +1993,7 @@ NS_IMETHODIMP nsHTMLEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste)
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
|
nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
PRBool haveFlavors;
|
PRBool haveFlavors;
|
||||||
|
|
||||||
|
@ -2007,7 +2007,7 @@ NS_IMETHODIMP nsHTMLEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste)
|
||||||
NS_ARRAY_LENGTH(textHtmlEditorFlavors),
|
NS_ARRAY_LENGTH(textHtmlEditorFlavors),
|
||||||
aSelectionType, &haveFlavors);
|
aSelectionType, &haveFlavors);
|
||||||
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
*aCanPaste = haveFlavors;
|
*aCanPaste = haveFlavors;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -2080,20 +2080,20 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsAString & aCitation,
|
||||||
// get selection
|
// get selection
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
nsresult res = GetSelection(getter_AddRefs(selection));
|
nsresult res = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
// give rules a chance to handle or cancel
|
// give rules a chance to handle or cancel
|
||||||
nsTextRulesInfo ruleInfo(nsTextEditRules::kInsertElement);
|
nsTextRulesInfo ruleInfo(nsTextEditRules::kInsertElement);
|
||||||
PRBool cancel, handled;
|
PRBool cancel, handled;
|
||||||
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (cancel) return NS_OK; // rules canceled the operation
|
if (cancel) return NS_OK; // rules canceled the operation
|
||||||
if (!handled)
|
if (!handled)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMNode> newNode;
|
nsCOMPtr<nsIDOMNode> newNode;
|
||||||
res = DeleteSelectionAndCreateNode(NS_LITERAL_STRING("blockquote"), getter_AddRefs(newNode));
|
res = DeleteSelectionAndCreateNode(NS_LITERAL_STRING("blockquote"), getter_AddRefs(newNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!newNode) return NS_ERROR_NULL_POINTER;
|
if (!newNode) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
// Try to set type=cite. Ignore it if this fails.
|
// Try to set type=cite. Ignore it if this fails.
|
||||||
|
@ -2126,7 +2126,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsPlaintextQuotation(PRInt32 aSelectionType)
|
||||||
// Get Clipboard Service
|
// Get Clipboard Service
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
|
nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// Create generic Transferable for getting the data
|
// Create generic Transferable for getting the data
|
||||||
nsCOMPtr<nsITransferable> trans =
|
nsCOMPtr<nsITransferable> trans =
|
||||||
|
@ -2304,7 +2304,7 @@ nsHTMLEditor::InsertAsPlaintextQuotation(const nsAString & aQuotedText,
|
||||||
// get selection
|
// get selection
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
rv = GetSelection(getter_AddRefs(selection));
|
rv = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2315,7 +2315,7 @@ nsHTMLEditor::InsertAsPlaintextQuotation(const nsAString & aQuotedText,
|
||||||
nsTextRulesInfo ruleInfo(nsTextEditRules::kInsertElement);
|
nsTextRulesInfo ruleInfo(nsTextEditRules::kInsertElement);
|
||||||
PRBool cancel, handled;
|
PRBool cancel, handled;
|
||||||
rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (cancel) return NS_OK; // rules canceled the operation
|
if (cancel) return NS_OK; // rules canceled the operation
|
||||||
if (!handled)
|
if (!handled)
|
||||||
{
|
{
|
||||||
|
@ -2417,7 +2417,7 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsAString & aQuotedText,
|
||||||
// get selection
|
// get selection
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
res = GetSelection(getter_AddRefs(selection));
|
res = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2428,12 +2428,12 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsAString & aQuotedText,
|
||||||
nsTextRulesInfo ruleInfo(nsTextEditRules::kInsertElement);
|
nsTextRulesInfo ruleInfo(nsTextEditRules::kInsertElement);
|
||||||
PRBool cancel, handled;
|
PRBool cancel, handled;
|
||||||
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (cancel) return NS_OK; // rules canceled the operation
|
if (cancel) return NS_OK; // rules canceled the operation
|
||||||
if (!handled)
|
if (!handled)
|
||||||
{
|
{
|
||||||
res = DeleteSelectionAndCreateNode(NS_LITERAL_STRING("blockquote"), getter_AddRefs(newNode));
|
res = DeleteSelectionAndCreateNode(NS_LITERAL_STRING("blockquote"), getter_AddRefs(newNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!newNode) return NS_ERROR_NULL_POINTER;
|
if (!newNode) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
// Try to set type=cite. Ignore it if this fails.
|
// Try to set type=cite. Ignore it if this fails.
|
||||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -102,7 +102,7 @@ nsHTMLEditorEventListener::MouseUp(nsIDOMEvent* aMouseEvent)
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMEventTarget> target;
|
nsCOMPtr<nsIDOMEventTarget> target;
|
||||||
nsresult res = aMouseEvent->GetTarget(getter_AddRefs(target));
|
nsresult res = aMouseEvent->GetTarget(getter_AddRefs(target));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!target) return NS_ERROR_NULL_POINTER;
|
if (!target) return NS_ERROR_NULL_POINTER;
|
||||||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(target);
|
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(target);
|
||||||
|
|
||||||
|
@ -132,14 +132,14 @@ nsHTMLEditorEventListener::MouseDown(nsIDOMEvent* aMouseEvent)
|
||||||
// But eDOMEvents_contextmenu and NS_CONTEXTMENU is not exposed in any event interface :-(
|
// But eDOMEvents_contextmenu and NS_CONTEXTMENU is not exposed in any event interface :-(
|
||||||
PRUint16 buttonNumber;
|
PRUint16 buttonNumber;
|
||||||
nsresult res = mouseEvent->GetButton(&buttonNumber);
|
nsresult res = mouseEvent->GetButton(&buttonNumber);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
PRBool isContextClick;
|
PRBool isContextClick;
|
||||||
|
|
||||||
#if defined(XP_MAC) || defined(XP_MACOSX)
|
#if defined(XP_MAC) || defined(XP_MACOSX)
|
||||||
// Ctrl+Click for context menu
|
// Ctrl+Click for context menu
|
||||||
res = mouseEvent->GetCtrlKey(&isContextClick);
|
res = mouseEvent->GetCtrlKey(&isContextClick);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
#else
|
#else
|
||||||
// Right mouse button for Windows, UNIX
|
// Right mouse button for Windows, UNIX
|
||||||
isContextClick = buttonNumber == 2;
|
isContextClick = buttonNumber == 2;
|
||||||
|
@ -147,12 +147,12 @@ nsHTMLEditorEventListener::MouseDown(nsIDOMEvent* aMouseEvent)
|
||||||
|
|
||||||
PRInt32 clickCount;
|
PRInt32 clickCount;
|
||||||
res = mouseEvent->GetDetail(&clickCount);
|
res = mouseEvent->GetDetail(&clickCount);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMEventTarget> target;
|
nsCOMPtr<nsIDOMEventTarget> target;
|
||||||
nsCOMPtr<nsIDOMNSEvent> internalEvent = do_QueryInterface(aMouseEvent);
|
nsCOMPtr<nsIDOMNSEvent> internalEvent = do_QueryInterface(aMouseEvent);
|
||||||
res = internalEvent->GetExplicitOriginalTarget(getter_AddRefs(target));
|
res = internalEvent->GetExplicitOriginalTarget(getter_AddRefs(target));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!target) return NS_ERROR_NULL_POINTER;
|
if (!target) return NS_ERROR_NULL_POINTER;
|
||||||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(target);
|
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(target);
|
||||||
|
|
||||||
|
@ -170,11 +170,11 @@ nsHTMLEditorEventListener::MouseDown(nsIDOMEvent* aMouseEvent)
|
||||||
PRInt32 offset = 0;
|
PRInt32 offset = 0;
|
||||||
|
|
||||||
res = uiEvent->GetRangeParent(getter_AddRefs(parent));
|
res = uiEvent->GetRangeParent(getter_AddRefs(parent));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!parent) return NS_ERROR_FAILURE;
|
if (!parent) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
res = uiEvent->GetRangeOffset(&offset);
|
res = uiEvent->GetRangeOffset(&offset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// Detect if mouse point is within current selection for context click
|
// Detect if mouse point is within current selection for context click
|
||||||
PRBool nodeIsInSelection = PR_FALSE;
|
PRBool nodeIsInSelection = PR_FALSE;
|
||||||
|
@ -186,7 +186,7 @@ nsHTMLEditorEventListener::MouseDown(nsIDOMEvent* aMouseEvent)
|
||||||
{
|
{
|
||||||
PRInt32 rangeCount;
|
PRInt32 rangeCount;
|
||||||
res = selection->GetRangeCount(&rangeCount);
|
res = selection->GetRangeCount(&rangeCount);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
for (PRInt32 i = 0; i < rangeCount; i++)
|
for (PRInt32 i = 0; i < rangeCount; i++)
|
||||||
{
|
{
|
||||||
|
@ -223,7 +223,7 @@ nsHTMLEditorEventListener::MouseDown(nsIDOMEvent* aMouseEvent)
|
||||||
// Get enclosing link if in text so we can select the link
|
// Get enclosing link if in text so we can select the link
|
||||||
nsCOMPtr<nsIDOMElement> linkElement;
|
nsCOMPtr<nsIDOMElement> linkElement;
|
||||||
res = htmlEditor->GetElementOrParentByTagName(NS_LITERAL_STRING("href"), node, getter_AddRefs(linkElement));
|
res = htmlEditor->GetElementOrParentByTagName(NS_LITERAL_STRING("href"), node, getter_AddRefs(linkElement));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (linkElement)
|
if (linkElement)
|
||||||
element = linkElement;
|
element = linkElement;
|
||||||
}
|
}
|
||||||
|
@ -300,7 +300,7 @@ nsHTMLEditorEventListener::MouseClick(nsIDOMEvent* aMouseEvent)
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMEventTarget> target;
|
nsCOMPtr<nsIDOMEventTarget> target;
|
||||||
nsresult res = aMouseEvent->GetTarget(getter_AddRefs(target));
|
nsresult res = aMouseEvent->GetTarget(getter_AddRefs(target));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!target) return NS_ERROR_NULL_POINTER;
|
if (!target) return NS_ERROR_NULL_POINTER;
|
||||||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(target);
|
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(target);
|
||||||
|
|
||||||
|
|
|
@ -845,7 +845,7 @@ nsHTMLEditorLog::StartLogging(nsIFile *aLogFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
result = NS_NewLocalFileOutputStream(getter_AddRefs(mFileStream), aLogFile);
|
result = NS_NewLocalFileOutputStream(getter_AddRefs(mFileStream), aLogFile);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
|
|
||||||
if (mTxnMgr)
|
if (mTxnMgr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -132,7 +132,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
|
||||||
|
|
||||||
nsCOMPtr<nsISelection>selection;
|
nsCOMPtr<nsISelection>selection;
|
||||||
nsresult res = GetSelection(getter_AddRefs(selection));
|
nsresult res = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
nsCOMPtr<nsISelectionPrivate> selPriv(do_QueryInterface(selection));
|
nsCOMPtr<nsISelectionPrivate> selPriv(do_QueryInterface(selection));
|
||||||
|
|
||||||
|
@ -154,13 +154,13 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
|
||||||
PRBool cancel, handled;
|
PRBool cancel, handled;
|
||||||
nsTextRulesInfo ruleInfo(nsTextEditRules::kSetTextProperty);
|
nsTextRulesInfo ruleInfo(nsTextEditRules::kSetTextProperty);
|
||||||
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!cancel && !handled)
|
if (!cancel && !handled)
|
||||||
{
|
{
|
||||||
// get selection range enumerator
|
// get selection range enumerator
|
||||||
nsCOMPtr<nsIEnumerator> enumerator;
|
nsCOMPtr<nsIEnumerator> enumerator;
|
||||||
res = selPriv->GetEnumerator(getter_AddRefs(enumerator));
|
res = selPriv->GetEnumerator(getter_AddRefs(enumerator));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!enumerator) return NS_ERROR_FAILURE;
|
if (!enumerator) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
// loop thru the ranges in the selection
|
// loop thru the ranges in the selection
|
||||||
|
@ -169,21 +169,21 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
|
||||||
while ((NS_ENUMERATOR_FALSE == enumerator->IsDone()))
|
while ((NS_ENUMERATOR_FALSE == enumerator->IsDone()))
|
||||||
{
|
{
|
||||||
res = enumerator->CurrentItem(getter_AddRefs(currentItem));
|
res = enumerator->CurrentItem(getter_AddRefs(currentItem));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!currentItem) return NS_ERROR_FAILURE;
|
if (!currentItem) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMRange> range( do_QueryInterface(currentItem) );
|
nsCOMPtr<nsIDOMRange> range( do_QueryInterface(currentItem) );
|
||||||
|
|
||||||
// adjust range to include any ancestors who's children are entirely selected
|
// adjust range to include any ancestors who's children are entirely selected
|
||||||
res = PromoteInlineRange(range);
|
res = PromoteInlineRange(range);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// check for easy case: both range endpoints in same text node
|
// check for easy case: both range endpoints in same text node
|
||||||
nsCOMPtr<nsIDOMNode> startNode, endNode;
|
nsCOMPtr<nsIDOMNode> startNode, endNode;
|
||||||
res = range->GetStartContainer(getter_AddRefs(startNode));
|
res = range->GetStartContainer(getter_AddRefs(startNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = range->GetEndContainer(getter_AddRefs(endNode));
|
res = range->GetEndContainer(getter_AddRefs(endNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if ((startNode == endNode) && IsTextNode(startNode))
|
if ((startNode == endNode) && IsTextNode(startNode))
|
||||||
{
|
{
|
||||||
PRInt32 startOffset, endOffset;
|
PRInt32 startOffset, endOffset;
|
||||||
|
@ -191,7 +191,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
|
||||||
range->GetEndOffset(&endOffset);
|
range->GetEndOffset(&endOffset);
|
||||||
nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(startNode);
|
nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(startNode);
|
||||||
res = SetInlinePropertyOnTextNode(nodeAsText, startOffset, endOffset, aProperty, &aAttribute, &aValue);
|
res = SetInlinePropertyOnTextNode(nodeAsText, startOffset, endOffset, aProperty, &aAttribute, &aValue);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -208,7 +208,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
|
||||||
|
|
||||||
nsCOMPtr<nsIContentIterator> iter =
|
nsCOMPtr<nsIContentIterator> iter =
|
||||||
do_CreateInstance("@mozilla.org/content/subtree-content-iterator;1", &res);
|
do_CreateInstance("@mozilla.org/content/subtree-content-iterator;1", &res);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!iter) return NS_ERROR_FAILURE;
|
if (!iter) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
nsCOMArray<nsIDOMNode> arrayOfNodes;
|
nsCOMArray<nsIDOMNode> arrayOfNodes;
|
||||||
|
@ -247,7 +247,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
|
||||||
range->GetStartOffset(&startOffset);
|
range->GetStartOffset(&startOffset);
|
||||||
nodeAsText->GetLength(&textLen);
|
nodeAsText->GetLength(&textLen);
|
||||||
res = SetInlinePropertyOnTextNode(nodeAsText, startOffset, textLen, aProperty, &aAttribute, &aValue);
|
res = SetInlinePropertyOnTextNode(nodeAsText, startOffset, textLen, aProperty, &aAttribute, &aValue);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// then loop through the list, set the property on each node
|
// then loop through the list, set the property on each node
|
||||||
|
@ -257,7 +257,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
|
||||||
{
|
{
|
||||||
node = arrayOfNodes[j];
|
node = arrayOfNodes[j];
|
||||||
res = SetInlinePropertyOnNode(node, aProperty, &aAttribute, &aValue);
|
res = SetInlinePropertyOnNode(node, aProperty, &aAttribute, &aValue);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
arrayOfNodes.Clear();
|
arrayOfNodes.Clear();
|
||||||
|
|
||||||
|
@ -270,7 +270,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
|
||||||
PRInt32 endOffset;
|
PRInt32 endOffset;
|
||||||
range->GetEndOffset(&endOffset);
|
range->GetEndOffset(&endOffset);
|
||||||
res = SetInlinePropertyOnTextNode(nodeAsText, 0, endOffset, aProperty, &aAttribute, &aValue);
|
res = SetInlinePropertyOnTextNode(nodeAsText, 0, endOffset, aProperty, &aAttribute, &aValue);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
enumerator->Next();
|
enumerator->Next();
|
||||||
|
@ -297,7 +297,7 @@ nsHTMLEditor::SetInlinePropertyOnTextNode( nsIDOMCharacterData *aTextNode,
|
||||||
if (!aTextNode) return NS_ERROR_NULL_POINTER;
|
if (!aTextNode) return NS_ERROR_NULL_POINTER;
|
||||||
nsCOMPtr<nsIDOMNode> parent;
|
nsCOMPtr<nsIDOMNode> parent;
|
||||||
nsresult res = aTextNode->GetParentNode(getter_AddRefs(parent));
|
nsresult res = aTextNode->GetParentNode(getter_AddRefs(parent));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
nsAutoString tagString;
|
nsAutoString tagString;
|
||||||
aProperty->ToString(tagString);
|
aProperty->ToString(tagString);
|
||||||
|
@ -340,14 +340,14 @@ nsHTMLEditor::SetInlinePropertyOnTextNode( nsIDOMCharacterData *aTextNode,
|
||||||
{
|
{
|
||||||
// we need to split off back of text node
|
// we need to split off back of text node
|
||||||
res = SplitNode(node, aEndOffset, getter_AddRefs(tmp));
|
res = SplitNode(node, aEndOffset, getter_AddRefs(tmp));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
node = tmp; // remember left node
|
node = tmp; // remember left node
|
||||||
}
|
}
|
||||||
if ( aStartOffset )
|
if ( aStartOffset )
|
||||||
{
|
{
|
||||||
// we need to split off front of text node
|
// we need to split off front of text node
|
||||||
res = SplitNode(node, aStartOffset, getter_AddRefs(tmp));
|
res = SplitNode(node, aStartOffset, getter_AddRefs(tmp));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// look for siblings that are correct type of node
|
// look for siblings that are correct type of node
|
||||||
|
@ -417,11 +417,11 @@ nsHTMLEditor::SetInlinePropertyOnNode( nsIDOMNode *aNode,
|
||||||
// first we have to remove occurences of the same style hint in the
|
// first we have to remove occurences of the same style hint in the
|
||||||
// children of the aNode
|
// children of the aNode
|
||||||
res = RemoveStyleInside(tmp, aProperty, aAttribute, PR_TRUE);
|
res = RemoveStyleInside(tmp, aProperty, aAttribute, PR_TRUE);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
PRInt32 count;
|
PRInt32 count;
|
||||||
// then we add the css styles corresponding to the HTML style request
|
// then we add the css styles corresponding to the HTML style request
|
||||||
res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, aProperty, aAttribute, aValue, &count, PR_FALSE);
|
res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, aProperty, aAttribute, aValue, &count, PR_FALSE);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMNode> nextSibling, previousSibling;
|
nsCOMPtr<nsIDOMNode> nextSibling, previousSibling;
|
||||||
GetNextHTMLSibling(tmp, address_of(nextSibling));
|
GetNextHTMLSibling(tmp, address_of(nextSibling));
|
||||||
|
@ -430,13 +430,13 @@ nsHTMLEditor::SetInlinePropertyOnNode( nsIDOMNode *aNode,
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMNode> mergeParent;
|
nsCOMPtr<nsIDOMNode> mergeParent;
|
||||||
res = tmp->GetParentNode(getter_AddRefs(mergeParent));
|
res = tmp->GetParentNode(getter_AddRefs(mergeParent));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (previousSibling &&
|
if (previousSibling &&
|
||||||
nsEditor::NodeIsType(previousSibling, nsEditProperty::span) &&
|
nsEditor::NodeIsType(previousSibling, nsEditProperty::span) &&
|
||||||
NodesSameType(tmp, previousSibling))
|
NodesSameType(tmp, previousSibling))
|
||||||
{
|
{
|
||||||
res = JoinNodes(previousSibling, tmp, mergeParent);
|
res = JoinNodes(previousSibling, tmp, mergeParent);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
if (nextSibling &&
|
if (nextSibling &&
|
||||||
nsEditor::NodeIsType(nextSibling, nsEditProperty::span) &&
|
nsEditor::NodeIsType(nextSibling, nsEditProperty::span) &&
|
||||||
|
@ -461,7 +461,7 @@ nsHTMLEditor::SetInlinePropertyOnNode( nsIDOMNode *aNode,
|
||||||
// just set the attribute on it.
|
// just set the attribute on it.
|
||||||
// but first remove any contrary style in it's children.
|
// but first remove any contrary style in it's children.
|
||||||
res = RemoveStyleInside(aNode, aProperty, aAttribute, PR_TRUE);
|
res = RemoveStyleInside(aNode, aProperty, aAttribute, PR_TRUE);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
nsCOMPtr<nsIDOMElement> elem = do_QueryInterface(aNode);
|
nsCOMPtr<nsIDOMElement> elem = do_QueryInterface(aNode);
|
||||||
return SetAttribute(elem, *aAttribute, *aValue);
|
return SetAttribute(elem, *aAttribute, *aValue);
|
||||||
}
|
}
|
||||||
|
@ -492,13 +492,13 @@ nsHTMLEditor::SetInlinePropertyOnNode( nsIDOMNode *aNode,
|
||||||
// ok, chuck it in it's very own container
|
// ok, chuck it in it's very own container
|
||||||
res = InsertContainerAbove(aNode, address_of(tmp), tag, aAttribute, aValue);
|
res = InsertContainerAbove(aNode, address_of(tmp), tag, aAttribute, aValue);
|
||||||
}
|
}
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
return RemoveStyleInside(aNode, aProperty, aAttribute);
|
return RemoveStyleInside(aNode, aProperty, aAttribute);
|
||||||
}
|
}
|
||||||
// none of the above? then cycle through the children.
|
// none of the above? then cycle through the children.
|
||||||
nsCOMPtr<nsIDOMNodeList> childNodes;
|
nsCOMPtr<nsIDOMNodeList> childNodes;
|
||||||
res = aNode->GetChildNodes(getter_AddRefs(childNodes));
|
res = aNode->GetChildNodes(getter_AddRefs(childNodes));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (childNodes)
|
if (childNodes)
|
||||||
{
|
{
|
||||||
PRInt32 j;
|
PRInt32 j;
|
||||||
|
@ -526,7 +526,7 @@ nsHTMLEditor::SetInlinePropertyOnNode( nsIDOMNode *aNode,
|
||||||
{
|
{
|
||||||
node = arrayOfNodes[j];
|
node = arrayOfNodes[j];
|
||||||
res = SetInlinePropertyOnNode(node, aProperty, aAttribute, aValue);
|
res = SetInlinePropertyOnNode(node, aProperty, aAttribute, aValue);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
arrayOfNodes.Clear();
|
arrayOfNodes.Clear();
|
||||||
}
|
}
|
||||||
|
@ -545,13 +545,13 @@ nsresult nsHTMLEditor::SplitStyleAboveRange(nsIDOMRange *inRange,
|
||||||
PRInt32 startOffset, endOffset, origStartOffset;
|
PRInt32 startOffset, endOffset, origStartOffset;
|
||||||
|
|
||||||
res = inRange->GetStartContainer(getter_AddRefs(startNode));
|
res = inRange->GetStartContainer(getter_AddRefs(startNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = inRange->GetStartOffset(&startOffset);
|
res = inRange->GetStartOffset(&startOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = inRange->GetEndContainer(getter_AddRefs(endNode));
|
res = inRange->GetEndContainer(getter_AddRefs(endNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = inRange->GetEndOffset(&endOffset);
|
res = inRange->GetEndOffset(&endOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
origStartNode = startNode;
|
origStartNode = startNode;
|
||||||
origStartOffset = startOffset;
|
origStartOffset = startOffset;
|
||||||
|
@ -560,16 +560,16 @@ nsresult nsHTMLEditor::SplitStyleAboveRange(nsIDOMRange *inRange,
|
||||||
{
|
{
|
||||||
nsAutoTrackDOMPoint tracker(mRangeUpdater, address_of(endNode), &endOffset);
|
nsAutoTrackDOMPoint tracker(mRangeUpdater, address_of(endNode), &endOffset);
|
||||||
res = SplitStyleAbovePoint(address_of(startNode), &startOffset, aProperty, aAttribute);
|
res = SplitStyleAbovePoint(address_of(startNode), &startOffset, aProperty, aAttribute);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// second verse, same as the first...
|
// second verse, same as the first...
|
||||||
res = SplitStyleAbovePoint(address_of(endNode), &endOffset, aProperty, aAttribute);
|
res = SplitStyleAbovePoint(address_of(endNode), &endOffset, aProperty, aAttribute);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// reset the range
|
// reset the range
|
||||||
res = inRange->SetStart(startNode, startOffset);
|
res = inRange->SetStart(startNode, startOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = inRange->SetEnd(endNode, endOffset);
|
res = inRange->SetEnd(endNode, endOffset);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -643,7 +643,7 @@ nsresult nsHTMLEditor::ApplyDefaultProperties()
|
||||||
if (!propItem)
|
if (!propItem)
|
||||||
return NS_ERROR_NULL_POINTER;
|
return NS_ERROR_NULL_POINTER;
|
||||||
res = SetInlineProperty(propItem->tag, propItem->attr, propItem->value);
|
res = SetInlineProperty(propItem->tag, propItem->attr, propItem->value);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -665,7 +665,7 @@ nsresult nsHTMLEditor::RemoveStyleInside(nsIDOMNode *aNode,
|
||||||
// cache next sibling since we might remove child
|
// cache next sibling since we might remove child
|
||||||
child->GetNextSibling(getter_AddRefs(tmp));
|
child->GetNextSibling(getter_AddRefs(tmp));
|
||||||
res = RemoveStyleInside(child, aProperty, aAttribute);
|
res = RemoveStyleInside(child, aProperty, aAttribute);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
child = tmp;
|
child = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -859,13 +859,13 @@ nsresult nsHTMLEditor::PromoteRangeIfStartsOrEndsInNamedAnchor(nsIDOMRange *inRa
|
||||||
PRInt32 startOffset, endOffset, tmpOffset;
|
PRInt32 startOffset, endOffset, tmpOffset;
|
||||||
|
|
||||||
res = inRange->GetStartContainer(getter_AddRefs(startNode));
|
res = inRange->GetStartContainer(getter_AddRefs(startNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = inRange->GetStartOffset(&startOffset);
|
res = inRange->GetStartOffset(&startOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = inRange->GetEndContainer(getter_AddRefs(endNode));
|
res = inRange->GetEndContainer(getter_AddRefs(endNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = inRange->GetEndOffset(&endOffset);
|
res = inRange->GetEndOffset(&endOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
tmp = startNode;
|
tmp = startNode;
|
||||||
while ( tmp &&
|
while ( tmp &&
|
||||||
|
@ -873,14 +873,14 @@ nsresult nsHTMLEditor::PromoteRangeIfStartsOrEndsInNamedAnchor(nsIDOMRange *inRa
|
||||||
!nsHTMLEditUtils::IsNamedAnchor(tmp))
|
!nsHTMLEditUtils::IsNamedAnchor(tmp))
|
||||||
{
|
{
|
||||||
res = GetNodeLocation(tmp, address_of(parent), &tmpOffset);
|
res = GetNodeLocation(tmp, address_of(parent), &tmpOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
tmp = parent;
|
tmp = parent;
|
||||||
}
|
}
|
||||||
if (!tmp) return NS_ERROR_NULL_POINTER;
|
if (!tmp) return NS_ERROR_NULL_POINTER;
|
||||||
if (nsHTMLEditUtils::IsNamedAnchor(tmp))
|
if (nsHTMLEditUtils::IsNamedAnchor(tmp))
|
||||||
{
|
{
|
||||||
res = GetNodeLocation(tmp, address_of(parent), &tmpOffset);
|
res = GetNodeLocation(tmp, address_of(parent), &tmpOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
startNode = parent;
|
startNode = parent;
|
||||||
startOffset = tmpOffset;
|
startOffset = tmpOffset;
|
||||||
}
|
}
|
||||||
|
@ -891,20 +891,20 @@ nsresult nsHTMLEditor::PromoteRangeIfStartsOrEndsInNamedAnchor(nsIDOMRange *inRa
|
||||||
!nsHTMLEditUtils::IsNamedAnchor(tmp))
|
!nsHTMLEditUtils::IsNamedAnchor(tmp))
|
||||||
{
|
{
|
||||||
res = GetNodeLocation(tmp, address_of(parent), &tmpOffset);
|
res = GetNodeLocation(tmp, address_of(parent), &tmpOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
tmp = parent;
|
tmp = parent;
|
||||||
}
|
}
|
||||||
if (!tmp) return NS_ERROR_NULL_POINTER;
|
if (!tmp) return NS_ERROR_NULL_POINTER;
|
||||||
if (nsHTMLEditUtils::IsNamedAnchor(tmp))
|
if (nsHTMLEditUtils::IsNamedAnchor(tmp))
|
||||||
{
|
{
|
||||||
res = GetNodeLocation(tmp, address_of(parent), &tmpOffset);
|
res = GetNodeLocation(tmp, address_of(parent), &tmpOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
endNode = parent;
|
endNode = parent;
|
||||||
endOffset = tmpOffset + 1;
|
endOffset = tmpOffset + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = inRange->SetStart(startNode, startOffset);
|
res = inRange->SetStart(startNode, startOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = inRange->SetEnd(endNode, endOffset);
|
res = inRange->SetEnd(endNode, endOffset);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -917,13 +917,13 @@ nsresult nsHTMLEditor::PromoteInlineRange(nsIDOMRange *inRange)
|
||||||
PRInt32 startOffset, endOffset;
|
PRInt32 startOffset, endOffset;
|
||||||
|
|
||||||
res = inRange->GetStartContainer(getter_AddRefs(startNode));
|
res = inRange->GetStartContainer(getter_AddRefs(startNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = inRange->GetStartOffset(&startOffset);
|
res = inRange->GetStartOffset(&startOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = inRange->GetEndContainer(getter_AddRefs(endNode));
|
res = inRange->GetEndContainer(getter_AddRefs(endNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = inRange->GetEndOffset(&endOffset);
|
res = inRange->GetEndOffset(&endOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
while ( startNode &&
|
while ( startNode &&
|
||||||
!nsTextEditUtils::IsBody(startNode) &&
|
!nsTextEditUtils::IsBody(startNode) &&
|
||||||
|
@ -931,7 +931,7 @@ nsresult nsHTMLEditor::PromoteInlineRange(nsIDOMRange *inRange)
|
||||||
IsAtFrontOfNode(startNode, startOffset) )
|
IsAtFrontOfNode(startNode, startOffset) )
|
||||||
{
|
{
|
||||||
res = GetNodeLocation(startNode, address_of(parent), &startOffset);
|
res = GetNodeLocation(startNode, address_of(parent), &startOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
startNode = parent;
|
startNode = parent;
|
||||||
}
|
}
|
||||||
if (!startNode) return NS_ERROR_NULL_POINTER;
|
if (!startNode) return NS_ERROR_NULL_POINTER;
|
||||||
|
@ -942,14 +942,14 @@ nsresult nsHTMLEditor::PromoteInlineRange(nsIDOMRange *inRange)
|
||||||
IsAtEndOfNode(endNode, endOffset) )
|
IsAtEndOfNode(endNode, endOffset) )
|
||||||
{
|
{
|
||||||
res = GetNodeLocation(endNode, address_of(parent), &endOffset);
|
res = GetNodeLocation(endNode, address_of(parent), &endOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
endNode = parent;
|
endNode = parent;
|
||||||
endOffset++; // we are AFTER this node
|
endOffset++; // we are AFTER this node
|
||||||
}
|
}
|
||||||
if (!endNode) return NS_ERROR_NULL_POINTER;
|
if (!endNode) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
res = inRange->SetStart(startNode, startOffset);
|
res = inRange->SetStart(startNode, startOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = inRange->SetEnd(endNode, endOffset);
|
res = inRange->SetEnd(endNode, endOffset);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -1023,7 +1023,7 @@ nsHTMLEditor::GetInlinePropertyBase(nsIAtom *aProperty,
|
||||||
|
|
||||||
nsCOMPtr<nsISelection>selection;
|
nsCOMPtr<nsISelection>selection;
|
||||||
result = GetSelection(getter_AddRefs(selection));
|
result = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
nsCOMPtr<nsISelectionPrivate> selPriv(do_QueryInterface(selection));
|
nsCOMPtr<nsISelectionPrivate> selPriv(do_QueryInterface(selection));
|
||||||
|
|
||||||
|
@ -1032,7 +1032,7 @@ nsHTMLEditor::GetInlinePropertyBase(nsIAtom *aProperty,
|
||||||
nsCOMPtr<nsIDOMNode> collapsedNode;
|
nsCOMPtr<nsIDOMNode> collapsedNode;
|
||||||
nsCOMPtr<nsIEnumerator> enumerator;
|
nsCOMPtr<nsIEnumerator> enumerator;
|
||||||
result = selPriv->GetEnumerator(getter_AddRefs(enumerator));
|
result = selPriv->GetEnumerator(getter_AddRefs(enumerator));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!enumerator) return NS_ERROR_NULL_POINTER;
|
if (!enumerator) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
enumerator->First();
|
enumerator->First();
|
||||||
|
@ -1101,9 +1101,9 @@ nsHTMLEditor::GetInlinePropertyBase(nsIAtom *aProperty,
|
||||||
nsCOMPtr<nsIDOMNode> endNode;
|
nsCOMPtr<nsIDOMNode> endNode;
|
||||||
PRInt32 endOffset;
|
PRInt32 endOffset;
|
||||||
result = range->GetEndContainer(getter_AddRefs(endNode));
|
result = range->GetEndContainer(getter_AddRefs(endNode));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
result = range->GetEndOffset(&endOffset);
|
result = range->GetEndOffset(&endOffset);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
while (!iter->IsDone())
|
while (!iter->IsDone())
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIContent> content = do_QueryInterface(iter->GetCurrentNode());
|
nsCOMPtr<nsIContent> content = do_QueryInterface(iter->GetCurrentNode());
|
||||||
|
@ -1255,7 +1255,7 @@ NS_IMETHODIMP nsHTMLEditor::RemoveAllInlineProperties()
|
||||||
nsAutoRules beginRulesSniffing(this, kOpResetTextProperties, nsIEditor::eNext);
|
nsAutoRules beginRulesSniffing(this, kOpResetTextProperties, nsIEditor::eNext);
|
||||||
|
|
||||||
nsresult res = RemoveInlinePropertyImpl(nsnull, nsnull);
|
nsresult res = RemoveInlinePropertyImpl(nsnull, nsnull);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
return ApplyDefaultProperties();
|
return ApplyDefaultProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1272,7 +1272,7 @@ nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAStr
|
||||||
nsresult res;
|
nsresult res;
|
||||||
nsCOMPtr<nsISelection>selection;
|
nsCOMPtr<nsISelection>selection;
|
||||||
res = GetSelection(getter_AddRefs(selection));
|
res = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
nsCOMPtr<nsISelectionPrivate> selPriv(do_QueryInterface(selection));
|
nsCOMPtr<nsISelectionPrivate> selPriv(do_QueryInterface(selection));
|
||||||
|
|
||||||
|
@ -1302,13 +1302,13 @@ nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAStr
|
||||||
PRBool cancel, handled;
|
PRBool cancel, handled;
|
||||||
nsTextRulesInfo ruleInfo(nsTextEditRules::kRemoveTextProperty);
|
nsTextRulesInfo ruleInfo(nsTextEditRules::kRemoveTextProperty);
|
||||||
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!cancel && !handled)
|
if (!cancel && !handled)
|
||||||
{
|
{
|
||||||
// get selection range enumerator
|
// get selection range enumerator
|
||||||
nsCOMPtr<nsIEnumerator> enumerator;
|
nsCOMPtr<nsIEnumerator> enumerator;
|
||||||
res = selPriv->GetEnumerator(getter_AddRefs(enumerator));
|
res = selPriv->GetEnumerator(getter_AddRefs(enumerator));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!enumerator) return NS_ERROR_FAILURE;
|
if (!enumerator) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
// loop thru the ranges in the selection
|
// loop thru the ranges in the selection
|
||||||
|
@ -1317,7 +1317,7 @@ nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAStr
|
||||||
while ((NS_ENUMERATOR_FALSE == enumerator->IsDone()))
|
while ((NS_ENUMERATOR_FALSE == enumerator->IsDone()))
|
||||||
{
|
{
|
||||||
res = enumerator->CurrentItem(getter_AddRefs(currentItem));
|
res = enumerator->CurrentItem(getter_AddRefs(currentItem));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!currentItem) return NS_ERROR_FAILURE;
|
if (!currentItem) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMRange> range( do_QueryInterface(currentItem) );
|
nsCOMPtr<nsIDOMRange> range( do_QueryInterface(currentItem) );
|
||||||
|
@ -1332,19 +1332,19 @@ nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAStr
|
||||||
// adjust range to include any ancestors who's children are entirely selected
|
// adjust range to include any ancestors who's children are entirely selected
|
||||||
res = PromoteInlineRange(range);
|
res = PromoteInlineRange(range);
|
||||||
}
|
}
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// remove this style from ancestors of our range endpoints,
|
// remove this style from ancestors of our range endpoints,
|
||||||
// splitting them as appropriate
|
// splitting them as appropriate
|
||||||
res = SplitStyleAboveRange(range, aProperty, aAttribute);
|
res = SplitStyleAboveRange(range, aProperty, aAttribute);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// check for easy case: both range endpoints in same text node
|
// check for easy case: both range endpoints in same text node
|
||||||
nsCOMPtr<nsIDOMNode> startNode, endNode;
|
nsCOMPtr<nsIDOMNode> startNode, endNode;
|
||||||
res = range->GetStartContainer(getter_AddRefs(startNode));
|
res = range->GetStartContainer(getter_AddRefs(startNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = range->GetEndContainer(getter_AddRefs(endNode));
|
res = range->GetEndContainer(getter_AddRefs(endNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if ((startNode == endNode) && IsTextNode(startNode))
|
if ((startNode == endNode) && IsTextNode(startNode))
|
||||||
{
|
{
|
||||||
// we're done with this range!
|
// we're done with this range!
|
||||||
|
@ -1380,7 +1380,7 @@ nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAStr
|
||||||
// not the easy case. range not contained in single text node.
|
// not the easy case. range not contained in single text node.
|
||||||
nsCOMPtr<nsIContentIterator> iter =
|
nsCOMPtr<nsIContentIterator> iter =
|
||||||
do_CreateInstance("@mozilla.org/content/subtree-content-iterator;1", &res);
|
do_CreateInstance("@mozilla.org/content/subtree-content-iterator;1", &res);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!iter) return NS_ERROR_FAILURE;
|
if (!iter) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
nsCOMArray<nsIDOMNode> arrayOfNodes;
|
nsCOMArray<nsIDOMNode> arrayOfNodes;
|
||||||
|
@ -1409,7 +1409,7 @@ nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAStr
|
||||||
{
|
{
|
||||||
node = arrayOfNodes[j];
|
node = arrayOfNodes[j];
|
||||||
res = RemoveStyleInside(node, aProperty, aAttribute);
|
res = RemoveStyleInside(node, aProperty, aAttribute);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (useCSS && mHTMLCSSUtils->IsCSSEditableProperty(node, aProperty, aAttribute)) {
|
if (useCSS && mHTMLCSSUtils->IsCSSEditableProperty(node, aProperty, aAttribute)) {
|
||||||
// the HTML style defined by aProperty/aAttribute has a CSS equivalence
|
// the HTML style defined by aProperty/aAttribute has a CSS equivalence
|
||||||
// in this implementation for node
|
// in this implementation for node
|
||||||
|
@ -1468,13 +1468,13 @@ nsHTMLEditor::RelativeFontChange( PRInt32 aSizeChange)
|
||||||
// Get the selection
|
// Get the selection
|
||||||
nsCOMPtr<nsISelection>selection;
|
nsCOMPtr<nsISelection>selection;
|
||||||
nsresult res = GetSelection(getter_AddRefs(selection));
|
nsresult res = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!selection) return NS_ERROR_FAILURE;
|
if (!selection) return NS_ERROR_FAILURE;
|
||||||
nsCOMPtr<nsISelectionPrivate> selPriv(do_QueryInterface(selection));
|
nsCOMPtr<nsISelectionPrivate> selPriv(do_QueryInterface(selection));
|
||||||
// Is the selection collapsed?
|
// Is the selection collapsed?
|
||||||
PRBool bCollapsed;
|
PRBool bCollapsed;
|
||||||
res = selection->GetIsCollapsed(&bCollapsed);
|
res = selection->GetIsCollapsed(&bCollapsed);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// if it's collapsed set typing state
|
// if it's collapsed set typing state
|
||||||
if (bCollapsed)
|
if (bCollapsed)
|
||||||
|
@ -1490,7 +1490,7 @@ nsHTMLEditor::RelativeFontChange( PRInt32 aSizeChange)
|
||||||
if (IsTextNode(selectedNode)) {
|
if (IsTextNode(selectedNode)) {
|
||||||
nsCOMPtr<nsIDOMNode> parent;
|
nsCOMPtr<nsIDOMNode> parent;
|
||||||
res = selectedNode->GetParentNode(getter_AddRefs(parent));
|
res = selectedNode->GetParentNode(getter_AddRefs(parent));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
selectedNode = parent;
|
selectedNode = parent;
|
||||||
}
|
}
|
||||||
nsAutoString tag;
|
nsAutoString tag;
|
||||||
|
@ -1510,7 +1510,7 @@ nsHTMLEditor::RelativeFontChange( PRInt32 aSizeChange)
|
||||||
// get selection range enumerator
|
// get selection range enumerator
|
||||||
nsCOMPtr<nsIEnumerator> enumerator;
|
nsCOMPtr<nsIEnumerator> enumerator;
|
||||||
res = selPriv->GetEnumerator(getter_AddRefs(enumerator));
|
res = selPriv->GetEnumerator(getter_AddRefs(enumerator));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!enumerator) return NS_ERROR_FAILURE;
|
if (!enumerator) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
// loop thru the ranges in the selection
|
// loop thru the ranges in the selection
|
||||||
|
@ -1519,21 +1519,21 @@ nsHTMLEditor::RelativeFontChange( PRInt32 aSizeChange)
|
||||||
while ((NS_ENUMERATOR_FALSE == enumerator->IsDone()))
|
while ((NS_ENUMERATOR_FALSE == enumerator->IsDone()))
|
||||||
{
|
{
|
||||||
res = enumerator->CurrentItem(getter_AddRefs(currentItem));
|
res = enumerator->CurrentItem(getter_AddRefs(currentItem));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!currentItem) return NS_ERROR_FAILURE;
|
if (!currentItem) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMRange> range( do_QueryInterface(currentItem) );
|
nsCOMPtr<nsIDOMRange> range( do_QueryInterface(currentItem) );
|
||||||
|
|
||||||
// adjust range to include any ancestors who's children are entirely selected
|
// adjust range to include any ancestors who's children are entirely selected
|
||||||
res = PromoteInlineRange(range);
|
res = PromoteInlineRange(range);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// check for easy case: both range endpoints in same text node
|
// check for easy case: both range endpoints in same text node
|
||||||
nsCOMPtr<nsIDOMNode> startNode, endNode;
|
nsCOMPtr<nsIDOMNode> startNode, endNode;
|
||||||
res = range->GetStartContainer(getter_AddRefs(startNode));
|
res = range->GetStartContainer(getter_AddRefs(startNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = range->GetEndContainer(getter_AddRefs(endNode));
|
res = range->GetEndContainer(getter_AddRefs(endNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if ((startNode == endNode) && IsTextNode(startNode))
|
if ((startNode == endNode) && IsTextNode(startNode))
|
||||||
{
|
{
|
||||||
PRInt32 startOffset, endOffset;
|
PRInt32 startOffset, endOffset;
|
||||||
|
@ -1541,7 +1541,7 @@ nsHTMLEditor::RelativeFontChange( PRInt32 aSizeChange)
|
||||||
range->GetEndOffset(&endOffset);
|
range->GetEndOffset(&endOffset);
|
||||||
nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(startNode);
|
nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(startNode);
|
||||||
res = RelativeFontChangeOnTextNode(aSizeChange, nodeAsText, startOffset, endOffset);
|
res = RelativeFontChangeOnTextNode(aSizeChange, nodeAsText, startOffset, endOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1558,7 +1558,7 @@ nsHTMLEditor::RelativeFontChange( PRInt32 aSizeChange)
|
||||||
|
|
||||||
nsCOMPtr<nsIContentIterator> iter =
|
nsCOMPtr<nsIContentIterator> iter =
|
||||||
do_CreateInstance("@mozilla.org/content/subtree-content-iterator;1", &res);
|
do_CreateInstance("@mozilla.org/content/subtree-content-iterator;1", &res);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!iter) return NS_ERROR_FAILURE;
|
if (!iter) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
nsCOMArray<nsIDOMNode> arrayOfNodes;
|
nsCOMArray<nsIDOMNode> arrayOfNodes;
|
||||||
|
@ -1589,7 +1589,7 @@ nsHTMLEditor::RelativeFontChange( PRInt32 aSizeChange)
|
||||||
{
|
{
|
||||||
node = arrayOfNodes[j];
|
node = arrayOfNodes[j];
|
||||||
res = RelativeFontChangeOnNode(aSizeChange, node);
|
res = RelativeFontChangeOnNode(aSizeChange, node);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
arrayOfNodes.Clear();
|
arrayOfNodes.Clear();
|
||||||
}
|
}
|
||||||
|
@ -1604,7 +1604,7 @@ nsHTMLEditor::RelativeFontChange( PRInt32 aSizeChange)
|
||||||
range->GetStartOffset(&startOffset);
|
range->GetStartOffset(&startOffset);
|
||||||
nodeAsText->GetLength(&textLen);
|
nodeAsText->GetLength(&textLen);
|
||||||
res = RelativeFontChangeOnTextNode(aSizeChange, nodeAsText, startOffset, textLen);
|
res = RelativeFontChangeOnTextNode(aSizeChange, nodeAsText, startOffset, textLen);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
if (IsTextNode(endNode) && IsEditable(endNode))
|
if (IsTextNode(endNode) && IsEditable(endNode))
|
||||||
{
|
{
|
||||||
|
@ -1612,7 +1612,7 @@ nsHTMLEditor::RelativeFontChange( PRInt32 aSizeChange)
|
||||||
PRInt32 endOffset;
|
PRInt32 endOffset;
|
||||||
range->GetEndOffset(&endOffset);
|
range->GetEndOffset(&endOffset);
|
||||||
res = RelativeFontChangeOnTextNode(aSizeChange, nodeAsText, 0, endOffset);
|
res = RelativeFontChangeOnTextNode(aSizeChange, nodeAsText, 0, endOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
enumerator->Next();
|
enumerator->Next();
|
||||||
|
@ -1638,7 +1638,7 @@ nsHTMLEditor::RelativeFontChangeOnTextNode( PRInt32 aSizeChange,
|
||||||
nsresult res = NS_OK;
|
nsresult res = NS_OK;
|
||||||
nsCOMPtr<nsIDOMNode> parent;
|
nsCOMPtr<nsIDOMNode> parent;
|
||||||
res = aTextNode->GetParentNode(getter_AddRefs(parent));
|
res = aTextNode->GetParentNode(getter_AddRefs(parent));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!CanContainTag(parent, NS_LITERAL_STRING("big"))) return NS_OK;
|
if (!CanContainTag(parent, NS_LITERAL_STRING("big"))) return NS_OK;
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMNode> tmp, node = do_QueryInterface(aTextNode);
|
nsCOMPtr<nsIDOMNode> tmp, node = do_QueryInterface(aTextNode);
|
||||||
|
@ -1654,14 +1654,14 @@ nsHTMLEditor::RelativeFontChangeOnTextNode( PRInt32 aSizeChange,
|
||||||
{
|
{
|
||||||
// we need to split off back of text node
|
// we need to split off back of text node
|
||||||
res = SplitNode(node, aEndOffset, getter_AddRefs(tmp));
|
res = SplitNode(node, aEndOffset, getter_AddRefs(tmp));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
node = tmp; // remember left node
|
node = tmp; // remember left node
|
||||||
}
|
}
|
||||||
if ( aStartOffset )
|
if ( aStartOffset )
|
||||||
{
|
{
|
||||||
// we need to split off front of text node
|
// we need to split off front of text node
|
||||||
res = SplitNode(node, aStartOffset, getter_AddRefs(tmp));
|
res = SplitNode(node, aStartOffset, getter_AddRefs(tmp));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_NAMED_LITERAL_STRING(bigSize, "big");
|
NS_NAMED_LITERAL_STRING(bigSize, "big");
|
||||||
|
@ -1721,7 +1721,7 @@ nsHTMLEditor::RelativeFontChangeHelper( PRInt32 aSizeChange,
|
||||||
{
|
{
|
||||||
// cycle through children and adjust relative font size
|
// cycle through children and adjust relative font size
|
||||||
res = aNode->GetChildNodes(getter_AddRefs(childNodes));
|
res = aNode->GetChildNodes(getter_AddRefs(childNodes));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (childNodes)
|
if (childNodes)
|
||||||
{
|
{
|
||||||
childNodes->GetLength(&childCount);
|
childNodes->GetLength(&childCount);
|
||||||
|
@ -1731,7 +1731,7 @@ nsHTMLEditor::RelativeFontChangeHelper( PRInt32 aSizeChange,
|
||||||
if ((NS_SUCCEEDED(res)) && (childNode))
|
if ((NS_SUCCEEDED(res)) && (childNode))
|
||||||
{
|
{
|
||||||
res = RelativeFontChangeOnNode(aSizeChange, childNode);
|
res = RelativeFontChangeOnNode(aSizeChange, childNode);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1740,7 +1740,7 @@ nsHTMLEditor::RelativeFontChangeHelper( PRInt32 aSizeChange,
|
||||||
childNodes = nsnull;
|
childNodes = nsnull;
|
||||||
// now cycle through the children.
|
// now cycle through the children.
|
||||||
res = aNode->GetChildNodes(getter_AddRefs(childNodes));
|
res = aNode->GetChildNodes(getter_AddRefs(childNodes));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (childNodes)
|
if (childNodes)
|
||||||
{
|
{
|
||||||
childNodes->GetLength(&childCount);
|
childNodes->GetLength(&childCount);
|
||||||
|
@ -1750,7 +1750,7 @@ nsHTMLEditor::RelativeFontChangeHelper( PRInt32 aSizeChange,
|
||||||
if ((NS_SUCCEEDED(res)) && (childNode))
|
if ((NS_SUCCEEDED(res)) && (childNode))
|
||||||
{
|
{
|
||||||
res = RelativeFontChangeHelper(aSizeChange, childNode);
|
res = RelativeFontChangeHelper(aSizeChange, childNode);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1780,7 +1780,7 @@ nsHTMLEditor::RelativeFontChangeOnNode( PRInt32 aSizeChange,
|
||||||
{
|
{
|
||||||
// first populate any nested font tags that have the size attr set
|
// first populate any nested font tags that have the size attr set
|
||||||
res = RelativeFontChangeHelper(aSizeChange, aNode);
|
res = RelativeFontChangeHelper(aSizeChange, aNode);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
// in that case, just remove this node and pull up the children
|
// in that case, just remove this node and pull up the children
|
||||||
res = RemoveContainer(aNode);
|
res = RemoveContainer(aNode);
|
||||||
return res;
|
return res;
|
||||||
|
@ -1790,7 +1790,7 @@ nsHTMLEditor::RelativeFontChangeOnNode( PRInt32 aSizeChange,
|
||||||
{
|
{
|
||||||
// first populate any nested font tags that have the size attr set
|
// first populate any nested font tags that have the size attr set
|
||||||
res = RelativeFontChangeHelper(aSizeChange, aNode);
|
res = RelativeFontChangeHelper(aSizeChange, aNode);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
// ok, chuck it in.
|
// ok, chuck it in.
|
||||||
// first look at siblings of aNode for matching bigs or smalls.
|
// first look at siblings of aNode for matching bigs or smalls.
|
||||||
// if we find one, move aNode into it.
|
// if we find one, move aNode into it.
|
||||||
|
@ -1820,7 +1820,7 @@ nsHTMLEditor::RelativeFontChangeOnNode( PRInt32 aSizeChange,
|
||||||
// each getting their own.
|
// each getting their own.
|
||||||
nsCOMPtr<nsIDOMNodeList> childNodes;
|
nsCOMPtr<nsIDOMNodeList> childNodes;
|
||||||
res = aNode->GetChildNodes(getter_AddRefs(childNodes));
|
res = aNode->GetChildNodes(getter_AddRefs(childNodes));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (childNodes)
|
if (childNodes)
|
||||||
{
|
{
|
||||||
PRInt32 j;
|
PRInt32 j;
|
||||||
|
@ -1833,7 +1833,7 @@ nsHTMLEditor::RelativeFontChangeOnNode( PRInt32 aSizeChange,
|
||||||
if ((NS_SUCCEEDED(res)) && (childNode))
|
if ((NS_SUCCEEDED(res)) && (childNode))
|
||||||
{
|
{
|
||||||
res = RelativeFontChangeOnNode(aSizeChange, childNode);
|
res = RelativeFontChangeOnNode(aSizeChange, childNode);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1853,7 +1853,7 @@ nsHTMLEditor::GetFontFaceState(PRBool *aMixed, nsAString &outFace)
|
||||||
|
|
||||||
NS_NAMED_LITERAL_STRING(attr, "face");
|
NS_NAMED_LITERAL_STRING(attr, "face");
|
||||||
res = GetInlinePropertyBase(nsEditProperty::font, &attr, nsnull, &first, &any, &all, &outFace);
|
res = GetInlinePropertyBase(nsEditProperty::font, &attr, nsnull, &first, &any, &all, &outFace);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (any && !all) return res; // mixed
|
if (any && !all) return res; // mixed
|
||||||
if (all)
|
if (all)
|
||||||
{
|
{
|
||||||
|
@ -1863,7 +1863,7 @@ nsHTMLEditor::GetFontFaceState(PRBool *aMixed, nsAString &outFace)
|
||||||
|
|
||||||
// if there is no font face, check for tt
|
// if there is no font face, check for tt
|
||||||
res = GetInlinePropertyBase(nsEditProperty::tt, nsnull, nsnull, &first, &any, &all,nsnull);
|
res = GetInlinePropertyBase(nsEditProperty::tt, nsnull, nsnull, &first, &any, &all,nsnull);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (any && !all) return res; // mixed
|
if (any && !all) return res; // mixed
|
||||||
if (all)
|
if (all)
|
||||||
{
|
{
|
||||||
|
@ -1893,7 +1893,7 @@ nsHTMLEditor::GetFontColorState(PRBool *aMixed, nsAString &aOutColor)
|
||||||
PRBool first, any, all;
|
PRBool first, any, all;
|
||||||
|
|
||||||
res = GetInlinePropertyBase(nsEditProperty::font, &colorStr, nsnull, &first, &any, &all, &aOutColor);
|
res = GetInlinePropertyBase(nsEditProperty::font, &colorStr, nsnull, &first, &any, &all, &aOutColor);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (any && !all) return res; // mixed
|
if (any && !all) return res; // mixed
|
||||||
if (all)
|
if (all)
|
||||||
{
|
{
|
||||||
|
@ -1939,10 +1939,10 @@ nsHTMLEditor::HasStyleOrIdOrClass(nsIDOMElement * aElement, PRBool *aHasStyleOrI
|
||||||
PRBool isStyleSet;
|
PRBool isStyleSet;
|
||||||
*aHasStyleOrIdOrClass = PR_TRUE;
|
*aHasStyleOrIdOrClass = PR_TRUE;
|
||||||
nsresult res = GetAttributeValue(aElement, NS_LITERAL_STRING("style"), styleVal, &isStyleSet);
|
nsresult res = GetAttributeValue(aElement, NS_LITERAL_STRING("style"), styleVal, &isStyleSet);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!isStyleSet || styleVal.IsEmpty()) {
|
if (!isStyleSet || styleVal.IsEmpty()) {
|
||||||
res = mHTMLCSSUtils->HasClassOrID(aElement, *aHasStyleOrIdOrClass);
|
res = mHTMLCSSUtils->HasClassOrID(aElement, *aHasStyleOrIdOrClass);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,7 +162,7 @@ nsHTMLEditor::DoInlineTableEditingAction(nsIDOMElement * aElement)
|
||||||
anonElement) {
|
anonElement) {
|
||||||
nsAutoString anonclass;
|
nsAutoString anonclass;
|
||||||
nsresult res = aElement->GetAttribute(NS_LITERAL_STRING("_moz_anonclass"), anonclass);
|
nsresult res = aElement->GetAttribute(NS_LITERAL_STRING("_moz_anonclass"), anonclass);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
if (!StringBeginsWith(anonclass, NS_LITERAL_STRING("mozTable")))
|
if (!StringBeginsWith(anonclass, NS_LITERAL_STRING("mozTable")))
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -171,7 +171,7 @@ nsHTMLEditor::DoInlineTableEditingAction(nsIDOMElement * aElement)
|
||||||
nsCOMPtr<nsIDOMElement> tableElement = do_QueryInterface(tableNode);
|
nsCOMPtr<nsIDOMElement> tableElement = do_QueryInterface(tableNode);
|
||||||
PRInt32 rowCount, colCount;
|
PRInt32 rowCount, colCount;
|
||||||
res = GetTableSize(tableElement, &rowCount, &colCount);
|
res = GetTableSize(tableElement, &rowCount, &colCount);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
PRBool hideUI = PR_FALSE;
|
PRBool hideUI = PR_FALSE;
|
||||||
PRBool hideResizersWithInlineTableUI = (mResizedObject == tableElement);
|
PRBool hideResizersWithInlineTableUI = (mResizedObject == tableElement);
|
||||||
|
@ -239,9 +239,9 @@ nsHTMLEditor::RefreshInlineTableEditingUI()
|
||||||
GetElementOrigin(mInlineEditedCell, xCell, yCell);
|
GetElementOrigin(mInlineEditedCell, xCell, yCell);
|
||||||
|
|
||||||
nsresult res = nsElement->GetOffsetWidth(&wCell);
|
nsresult res = nsElement->GetOffsetWidth(&wCell);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = nsElement->GetOffsetHeight(&hCell);
|
res = nsElement->GetOffsetHeight(&hCell);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
PRInt32 xHoriz = xCell + wCell/2;
|
PRInt32 xHoriz = xCell + wCell/2;
|
||||||
PRInt32 yVert = yCell + hCell/2;
|
PRInt32 yVert = yCell + hCell/2;
|
||||||
|
@ -250,7 +250,7 @@ nsHTMLEditor::RefreshInlineTableEditingUI()
|
||||||
nsCOMPtr<nsIDOMElement> tableElement = do_QueryInterface(tableNode);
|
nsCOMPtr<nsIDOMElement> tableElement = do_QueryInterface(tableNode);
|
||||||
PRInt32 rowCount, colCount;
|
PRInt32 rowCount, colCount;
|
||||||
res = GetTableSize(tableElement, &rowCount, &colCount);
|
res = GetTableSize(tableElement, &rowCount, &colCount);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
SetAnonymousElementPosition(xHoriz-10, yCell-7, mAddColumnBeforeButton);
|
SetAnonymousElementPosition(xHoriz-10, yCell-7, mAddColumnBeforeButton);
|
||||||
#ifdef DISABLE_TABLE_DELETION
|
#ifdef DISABLE_TABLE_DELETION
|
||||||
|
|
|
@ -187,7 +187,7 @@ nsHTMLEditor::CreateResizer(nsIDOMElement ** aReturn, PRInt16 aLocation, nsIDOMN
|
||||||
PR_FALSE,
|
PR_FALSE,
|
||||||
aReturn);
|
aReturn);
|
||||||
|
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!*aReturn)
|
if (!*aReturn)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
@ -325,9 +325,9 @@ nsHTMLEditor::RefreshResizers()
|
||||||
mResizedObjectMarginLeft,
|
mResizedObjectMarginLeft,
|
||||||
mResizedObjectMarginTop);
|
mResizedObjectMarginTop);
|
||||||
|
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = SetAllResizersPosition();
|
res = SetAllResizersPosition();
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
return SetShadowPosition(mResizingShadow, mResizedObject,
|
return SetShadowPosition(mResizingShadow, mResizedObject,
|
||||||
mResizedObjectX, mResizedObjectY);
|
mResizedObjectX, mResizedObjectY);
|
||||||
}
|
}
|
||||||
|
@ -360,30 +360,30 @@ nsHTMLEditor::ShowResizersInner(nsIDOMElement *aResizedElement)
|
||||||
// The resizers and the shadow will be anonymous siblings of the element.
|
// The resizers and the shadow will be anonymous siblings of the element.
|
||||||
res = CreateResizer(getter_AddRefs(mTopLeftHandle),
|
res = CreateResizer(getter_AddRefs(mTopLeftHandle),
|
||||||
nsIHTMLObjectResizer::eTopLeft, parentNode);
|
nsIHTMLObjectResizer::eTopLeft, parentNode);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = CreateResizer(getter_AddRefs(mTopHandle),
|
res = CreateResizer(getter_AddRefs(mTopHandle),
|
||||||
nsIHTMLObjectResizer::eTop, parentNode);
|
nsIHTMLObjectResizer::eTop, parentNode);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = CreateResizer(getter_AddRefs(mTopRightHandle),
|
res = CreateResizer(getter_AddRefs(mTopRightHandle),
|
||||||
nsIHTMLObjectResizer::eTopRight, parentNode);
|
nsIHTMLObjectResizer::eTopRight, parentNode);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
res = CreateResizer(getter_AddRefs(mLeftHandle),
|
res = CreateResizer(getter_AddRefs(mLeftHandle),
|
||||||
nsIHTMLObjectResizer::eLeft, parentNode);
|
nsIHTMLObjectResizer::eLeft, parentNode);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = CreateResizer(getter_AddRefs(mRightHandle),
|
res = CreateResizer(getter_AddRefs(mRightHandle),
|
||||||
nsIHTMLObjectResizer::eRight, parentNode);
|
nsIHTMLObjectResizer::eRight, parentNode);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
res = CreateResizer(getter_AddRefs(mBottomLeftHandle),
|
res = CreateResizer(getter_AddRefs(mBottomLeftHandle),
|
||||||
nsIHTMLObjectResizer::eBottomLeft, parentNode);
|
nsIHTMLObjectResizer::eBottomLeft, parentNode);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = CreateResizer(getter_AddRefs(mBottomHandle),
|
res = CreateResizer(getter_AddRefs(mBottomHandle),
|
||||||
nsIHTMLObjectResizer::eBottom, parentNode);
|
nsIHTMLObjectResizer::eBottom, parentNode);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = CreateResizer(getter_AddRefs(mBottomRightHandle),
|
res = CreateResizer(getter_AddRefs(mBottomRightHandle),
|
||||||
nsIHTMLObjectResizer::eBottomRight, parentNode);
|
nsIHTMLObjectResizer::eBottomRight, parentNode);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
res = GetPositionAndDimensions(aResizedElement,
|
res = GetPositionAndDimensions(aResizedElement,
|
||||||
mResizedObjectX,
|
mResizedObjectX,
|
||||||
|
@ -394,24 +394,24 @@ nsHTMLEditor::ShowResizersInner(nsIDOMElement *aResizedElement)
|
||||||
mResizedObjectBorderTop,
|
mResizedObjectBorderTop,
|
||||||
mResizedObjectMarginLeft,
|
mResizedObjectMarginLeft,
|
||||||
mResizedObjectMarginTop);
|
mResizedObjectMarginTop);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// and let's set their absolute positions in the document
|
// and let's set their absolute positions in the document
|
||||||
res = SetAllResizersPosition();
|
res = SetAllResizersPosition();
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// now, let's create the resizing shadow
|
// now, let's create the resizing shadow
|
||||||
res = CreateShadow(getter_AddRefs(mResizingShadow), parentNode,
|
res = CreateShadow(getter_AddRefs(mResizingShadow), parentNode,
|
||||||
aResizedElement);
|
aResizedElement);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
// and set its position
|
// and set its position
|
||||||
res = SetShadowPosition(mResizingShadow, mResizedObject,
|
res = SetShadowPosition(mResizingShadow, mResizedObject,
|
||||||
mResizedObjectX, mResizedObjectY);
|
mResizedObjectX, mResizedObjectY);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// and then the resizing info tooltip
|
// and then the resizing info tooltip
|
||||||
res = CreateResizingInfo(getter_AddRefs(mResizingInfo), parentNode);
|
res = CreateResizingInfo(getter_AddRefs(mResizingInfo), parentNode);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// and listen to the "resize" event on the window first, get the
|
// and listen to the "resize" event on the window first, get the
|
||||||
// window from the document...
|
// window from the document...
|
||||||
|
@ -644,7 +644,7 @@ nsHTMLEditor::MouseDown(PRInt32 aClientX, PRInt32 aClientY,
|
||||||
if (anonElement) {
|
if (anonElement) {
|
||||||
nsAutoString anonclass;
|
nsAutoString anonclass;
|
||||||
nsresult res = aTarget->GetAttribute(NS_LITERAL_STRING("_moz_anonclass"), anonclass);
|
nsresult res = aTarget->GetAttribute(NS_LITERAL_STRING("_moz_anonclass"), anonclass);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (anonclass.EqualsLiteral("mozResizer")) {
|
if (anonclass.EqualsLiteral("mozResizer")) {
|
||||||
// and that element is a resizer, let's start resizing!
|
// and that element is a resizer, let's start resizing!
|
||||||
aEvent->PreventDefault();
|
aEvent->PreventDefault();
|
||||||
|
@ -749,11 +749,11 @@ nsHTMLEditor::SetResizingInfoPosition(PRInt32 aX, PRInt32 aY, PRInt32 aW, PRInt3
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMNode> textInfo;
|
nsCOMPtr<nsIDOMNode> textInfo;
|
||||||
nsresult res = mResizingInfo->GetFirstChild(getter_AddRefs(textInfo));
|
nsresult res = mResizingInfo->GetFirstChild(getter_AddRefs(textInfo));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
nsCOMPtr<nsIDOMNode> junk;
|
nsCOMPtr<nsIDOMNode> junk;
|
||||||
if (textInfo) {
|
if (textInfo) {
|
||||||
res = mResizingInfo->RemoveChild(textInfo, getter_AddRefs(junk));
|
res = mResizingInfo->RemoveChild(textInfo, getter_AddRefs(junk));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
textInfo = nsnull;
|
textInfo = nsnull;
|
||||||
junk = nsnull;
|
junk = nsnull;
|
||||||
}
|
}
|
||||||
|
@ -777,10 +777,10 @@ nsHTMLEditor::SetResizingInfoPosition(PRInt32 aX, PRInt32 aY, PRInt32 aW, PRInt3
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMText> nodeAsText;
|
nsCOMPtr<nsIDOMText> nodeAsText;
|
||||||
res = domdoc->CreateTextNode(info, getter_AddRefs(nodeAsText));
|
res = domdoc->CreateTextNode(info, getter_AddRefs(nodeAsText));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
textInfo = do_QueryInterface(nodeAsText);
|
textInfo = do_QueryInterface(nodeAsText);
|
||||||
res = mResizingInfo->AppendChild(textInfo, getter_AddRefs(junk));
|
res = mResizingInfo->AppendChild(textInfo, getter_AddRefs(junk));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
PRBool hasClass = PR_FALSE;
|
PRBool hasClass = PR_FALSE;
|
||||||
if (NS_SUCCEEDED(mResizingInfo->HasAttribute(NS_LITERAL_STRING("class"), &hasClass )) && hasClass)
|
if (NS_SUCCEEDED(mResizingInfo->HasAttribute(NS_LITERAL_STRING("class"), &hasClass )) && hasClass)
|
||||||
|
@ -801,9 +801,9 @@ nsHTMLEditor::SetShadowPosition(nsIDOMElement * aShadow,
|
||||||
nsAutoString imageSource;
|
nsAutoString imageSource;
|
||||||
nsresult res = aOriginalObject->GetAttribute(NS_LITERAL_STRING("src"),
|
nsresult res = aOriginalObject->GetAttribute(NS_LITERAL_STRING("src"),
|
||||||
imageSource);
|
imageSource);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = aShadow->SetAttribute(NS_LITERAL_STRING("src"), imageSource);
|
res = aShadow->SetAttribute(NS_LITERAL_STRING("src"), imageSource);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -158,7 +158,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIDragService> dragService =
|
nsCOMPtr<nsIDragService> dragService =
|
||||||
do_GetService("@mozilla.org/widget/dragservice;1", &rv);
|
do_GetService("@mozilla.org/widget/dragservice;1", &rv);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsIDragSession> dragSession;
|
nsCOMPtr<nsIDragSession> dragSession;
|
||||||
dragService->GetCurrentSession(getter_AddRefs(dragSession));
|
dragService->GetCurrentSession(getter_AddRefs(dragSession));
|
||||||
|
@ -167,17 +167,17 @@ NS_IMETHODIMP nsPlaintextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
|
||||||
// Current doc is destination
|
// Current doc is destination
|
||||||
nsCOMPtr<nsIDOMDocument> destdomdoc;
|
nsCOMPtr<nsIDOMDocument> destdomdoc;
|
||||||
rv = GetDocument(getter_AddRefs(destdomdoc));
|
rv = GetDocument(getter_AddRefs(destdomdoc));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// Get the nsITransferable interface for getting the data from the drop
|
// Get the nsITransferable interface for getting the data from the drop
|
||||||
nsCOMPtr<nsITransferable> trans;
|
nsCOMPtr<nsITransferable> trans;
|
||||||
rv = PrepareTransferable(getter_AddRefs(trans));
|
rv = PrepareTransferable(getter_AddRefs(trans));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (!trans) return NS_OK; // NS_ERROR_FAILURE; SHOULD WE FAIL?
|
if (!trans) return NS_OK; // NS_ERROR_FAILURE; SHOULD WE FAIL?
|
||||||
|
|
||||||
PRUint32 numItems = 0;
|
PRUint32 numItems = 0;
|
||||||
rv = dragSession->GetNumDropItems(&numItems);
|
rv = dragSession->GetNumDropItems(&numItems);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (numItems < 1) return NS_ERROR_FAILURE; // nothing to drop?
|
if (numItems < 1) return NS_ERROR_FAILURE; // nothing to drop?
|
||||||
|
|
||||||
// Combine any deletion and drop insertion into one transaction
|
// Combine any deletion and drop insertion into one transaction
|
||||||
|
@ -192,21 +192,21 @@ NS_IMETHODIMP nsPlaintextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMNode> newSelectionParent;
|
nsCOMPtr<nsIDOMNode> newSelectionParent;
|
||||||
rv = nsuiEvent->GetRangeParent(getter_AddRefs(newSelectionParent));
|
rv = nsuiEvent->GetRangeParent(getter_AddRefs(newSelectionParent));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (!newSelectionParent) return NS_ERROR_FAILURE;
|
if (!newSelectionParent) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
PRInt32 newSelectionOffset;
|
PRInt32 newSelectionOffset;
|
||||||
rv = nsuiEvent->GetRangeOffset(&newSelectionOffset);
|
rv = nsuiEvent->GetRangeOffset(&newSelectionOffset);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
rv = GetSelection(getter_AddRefs(selection));
|
rv = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (!selection) return NS_ERROR_FAILURE;
|
if (!selection) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
PRBool isCollapsed;
|
PRBool isCollapsed;
|
||||||
rv = selection->GetIsCollapsed(&isCollapsed);
|
rv = selection->GetIsCollapsed(&isCollapsed);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// Check if mouse is in the selection
|
// Check if mouse is in the selection
|
||||||
// if so, jump through some hoops to determine if mouse is over selection (bail)
|
// if so, jump through some hoops to determine if mouse is over selection (bail)
|
||||||
|
@ -218,7 +218,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
|
||||||
|
|
||||||
PRInt32 rangeCount;
|
PRInt32 rangeCount;
|
||||||
rv = selection->GetRangeCount(&rangeCount);
|
rv = selection->GetRangeCount(&rangeCount);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
for (PRInt32 j = 0; j < rangeCount; j++)
|
for (PRInt32 j = 0; j < rangeCount; j++)
|
||||||
{
|
{
|
||||||
|
@ -237,7 +237,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
|
||||||
// Current doc is destination (set earlier)
|
// Current doc is destination (set earlier)
|
||||||
nsCOMPtr<nsIDOMDocument> srcdomdoc;
|
nsCOMPtr<nsIDOMDocument> srcdomdoc;
|
||||||
rv = dragSession->GetSourceDocument(getter_AddRefs(srcdomdoc));
|
rv = dragSession->GetSourceDocument(getter_AddRefs(srcdomdoc));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
if (cursorIsInSelection)
|
if (cursorIsInSelection)
|
||||||
{
|
{
|
||||||
|
@ -289,7 +289,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
|
||||||
for (i = 0; i < numItems; ++i)
|
for (i = 0; i < numItems; ++i)
|
||||||
{
|
{
|
||||||
rv = dragSession->GetData(trans, i);
|
rv = dragSession->GetData(trans, i);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (!trans) return NS_OK; // NS_ERROR_FAILURE; Should we fail?
|
if (!trans) return NS_OK; // NS_ERROR_FAILURE; Should we fail?
|
||||||
|
|
||||||
// Beware! This may flush notifications via synchronous
|
// Beware! This may flush notifications via synchronous
|
||||||
|
@ -320,11 +320,11 @@ NS_IMETHODIMP nsPlaintextEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDr
|
||||||
|
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
nsresult res = GetSelection(getter_AddRefs(selection));
|
nsresult res = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
PRBool isCollapsed;
|
PRBool isCollapsed;
|
||||||
res = selection->GetIsCollapsed(&isCollapsed);
|
res = selection->GetIsCollapsed(&isCollapsed);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// if we are collapsed, we have no selection so nothing to drag
|
// if we are collapsed, we have no selection so nothing to drag
|
||||||
if ( isCollapsed )
|
if ( isCollapsed )
|
||||||
|
@ -335,7 +335,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDr
|
||||||
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aDragEvent));
|
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aDragEvent));
|
||||||
if (nsevent) {
|
if (nsevent) {
|
||||||
res = nsevent->GetTmpRealOriginalTarget(getter_AddRefs(eventTarget));
|
res = nsevent->GetTmpRealOriginalTarget(getter_AddRefs(eventTarget));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eventTarget)
|
if (eventTarget)
|
||||||
|
@ -345,7 +345,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool *aCanDr
|
||||||
{
|
{
|
||||||
PRBool isTargetedCorrectly = PR_FALSE;
|
PRBool isTargetedCorrectly = PR_FALSE;
|
||||||
res = selection->ContainsNode(eventTargetDomNode, PR_FALSE, &isTargetedCorrectly);
|
res = selection->ContainsNode(eventTargetDomNode, PR_FALSE, &isTargetedCorrectly);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
*aCanDrag = isTargetedCorrectly;
|
*aCanDrag = isTargetedCorrectly;
|
||||||
}
|
}
|
||||||
|
@ -360,13 +360,13 @@ NS_IMETHODIMP nsPlaintextEditor::DoDrag(nsIDOMEvent *aDragEvent)
|
||||||
|
|
||||||
nsCOMPtr<nsITransferable> trans;
|
nsCOMPtr<nsITransferable> trans;
|
||||||
rv = PutDragDataInTransferable(getter_AddRefs(trans));
|
rv = PutDragDataInTransferable(getter_AddRefs(trans));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (!trans) return NS_OK; // maybe there was nothing to copy?
|
if (!trans) return NS_OK; // maybe there was nothing to copy?
|
||||||
|
|
||||||
/* get the drag service */
|
/* get the drag service */
|
||||||
nsCOMPtr<nsIDragService> dragService =
|
nsCOMPtr<nsIDragService> dragService =
|
||||||
do_GetService("@mozilla.org/widget/dragservice;1", &rv);
|
do_GetService("@mozilla.org/widget/dragservice;1", &rv);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
/* create an array of transferables */
|
/* create an array of transferables */
|
||||||
nsCOMPtr<nsISupportsArray> transferableArray;
|
nsCOMPtr<nsISupportsArray> transferableArray;
|
||||||
|
@ -376,7 +376,7 @@ NS_IMETHODIMP nsPlaintextEditor::DoDrag(nsIDOMEvent *aDragEvent)
|
||||||
|
|
||||||
/* add the transferable to the array */
|
/* add the transferable to the array */
|
||||||
rv = transferableArray->AppendElement(trans);
|
rv = transferableArray->AppendElement(trans);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// check our transferable hooks (if any)
|
// check our transferable hooks (if any)
|
||||||
nsCOMPtr<nsIDOMDocument> domdoc;
|
nsCOMPtr<nsIDOMDocument> domdoc;
|
||||||
|
@ -385,13 +385,13 @@ NS_IMETHODIMP nsPlaintextEditor::DoDrag(nsIDOMEvent *aDragEvent)
|
||||||
/* invoke drag */
|
/* invoke drag */
|
||||||
nsCOMPtr<nsIDOMEventTarget> eventTarget;
|
nsCOMPtr<nsIDOMEventTarget> eventTarget;
|
||||||
rv = aDragEvent->GetTarget(getter_AddRefs(eventTarget));
|
rv = aDragEvent->GetTarget(getter_AddRefs(eventTarget));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
nsCOMPtr<nsIDOMNode> domnode = do_QueryInterface(eventTarget);
|
nsCOMPtr<nsIDOMNode> domnode = do_QueryInterface(eventTarget);
|
||||||
|
|
||||||
nsCOMPtr<nsIScriptableRegion> selRegion;
|
nsCOMPtr<nsIScriptableRegion> selRegion;
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
rv = GetSelection(getter_AddRefs(selection));
|
rv = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
// in some cases we'll want to cut rather than copy... hmmmmm...
|
// in some cases we'll want to cut rather than copy... hmmmmm...
|
||||||
|
@ -400,7 +400,7 @@ NS_IMETHODIMP nsPlaintextEditor::DoDrag(nsIDOMEvent *aDragEvent)
|
||||||
nsCOMPtr<nsIDOMDragEvent> dragEvent(do_QueryInterface(aDragEvent));
|
nsCOMPtr<nsIDOMDragEvent> dragEvent(do_QueryInterface(aDragEvent));
|
||||||
rv = dragService->InvokeDragSessionWithSelection(selection, transferableArray,
|
rv = dragService->InvokeDragSessionWithSelection(selection, transferableArray,
|
||||||
flags, dragEvent, nsnull);
|
flags, dragEvent, nsnull);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
aDragEvent->StopPropagation();
|
aDragEvent->StopPropagation();
|
||||||
aDragEvent->PreventDefault();
|
aDragEvent->PreventDefault();
|
||||||
|
@ -472,7 +472,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPa
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
|
nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// the flavors that we can deal with
|
// the flavors that we can deal with
|
||||||
const char* textEditorFlavors[] = { kUnicodeMime };
|
const char* textEditorFlavors[] = { kUnicodeMime };
|
||||||
|
@ -481,7 +481,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPa
|
||||||
rv = clipboard->HasDataMatchingFlavors(textEditorFlavors,
|
rv = clipboard->HasDataMatchingFlavors(textEditorFlavors,
|
||||||
NS_ARRAY_LENGTH(textEditorFlavors),
|
NS_ARRAY_LENGTH(textEditorFlavors),
|
||||||
aSelectionType, &haveFlavors);
|
aSelectionType, &haveFlavors);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
*aCanPaste = haveFlavors;
|
*aCanPaste = haveFlavors;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -523,7 +523,7 @@ nsPlaintextEditor::SetupDocEncoder(nsIDocumentEncoder **aDocEncoder)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||||
nsresult rv = GetDocument(getter_AddRefs(domDoc));
|
nsresult rv = GetDocument(getter_AddRefs(domDoc));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// find out if we're a plaintext control or not
|
// find out if we're a plaintext control or not
|
||||||
// get correct mimeType and document encoder flags set
|
// get correct mimeType and document encoder flags set
|
||||||
|
@ -543,15 +543,15 @@ nsPlaintextEditor::SetupDocEncoder(nsIDocumentEncoder **aDocEncoder)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
rv = encoder->Init(domDoc, mimeType, docEncoderFlags);
|
rv = encoder->Init(domDoc, mimeType, docEncoderFlags);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
/* get the selection to be dragged */
|
/* get the selection to be dragged */
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
rv = GetSelection(getter_AddRefs(selection));
|
rv = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
rv = encoder->SetSelection(selection);
|
rv = encoder->SetSelection(selection);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
*aDocEncoder = encoder;
|
*aDocEncoder = encoder;
|
||||||
NS_ADDREF(*aDocEncoder);
|
NS_ADDREF(*aDocEncoder);
|
||||||
|
@ -564,12 +564,12 @@ nsPlaintextEditor::PutDragDataInTransferable(nsITransferable **aTransferable)
|
||||||
*aTransferable = nsnull;
|
*aTransferable = nsnull;
|
||||||
nsCOMPtr<nsIDocumentEncoder> docEncoder;
|
nsCOMPtr<nsIDocumentEncoder> docEncoder;
|
||||||
nsresult rv = SetupDocEncoder(getter_AddRefs(docEncoder));
|
nsresult rv = SetupDocEncoder(getter_AddRefs(docEncoder));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// grab a string
|
// grab a string
|
||||||
nsAutoString buffer;
|
nsAutoString buffer;
|
||||||
rv = docEncoder->EncodeToString(buffer);
|
rv = docEncoder->EncodeToString(buffer);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// if we have an empty string, we're done; otherwise continue
|
// if we have an empty string, we're done; otherwise continue
|
||||||
if (buffer.IsEmpty())
|
if (buffer.IsEmpty())
|
||||||
|
@ -580,7 +580,7 @@ nsPlaintextEditor::PutDragDataInTransferable(nsITransferable **aTransferable)
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
rv = dataWrapper->SetData(buffer);
|
rv = dataWrapper->SetData(buffer);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
/* create html flavor transferable */
|
/* create html flavor transferable */
|
||||||
nsCOMPtr<nsITransferable> trans = do_CreateInstance("@mozilla.org/widget/transferable;1", &rv);
|
nsCOMPtr<nsITransferable> trans = do_CreateInstance("@mozilla.org/widget/transferable;1", &rv);
|
||||||
|
@ -591,18 +591,18 @@ nsPlaintextEditor::PutDragDataInTransferable(nsITransferable **aTransferable)
|
||||||
{
|
{
|
||||||
// Add the unicode flavor to the transferable
|
// Add the unicode flavor to the transferable
|
||||||
rv = trans->AddDataFlavor(kUnicodeMime);
|
rv = trans->AddDataFlavor(kUnicodeMime);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rv = trans->AddDataFlavor(kHTMLMime);
|
rv = trans->AddDataFlavor(kHTMLMime);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsIFormatConverter> htmlConverter = do_CreateInstance("@mozilla.org/widget/htmlformatconverter;1");
|
nsCOMPtr<nsIFormatConverter> htmlConverter = do_CreateInstance("@mozilla.org/widget/htmlformatconverter;1");
|
||||||
NS_ENSURE_TRUE(htmlConverter, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(htmlConverter, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
rv = trans->SetConverter(htmlConverter);
|
rv = trans->SetConverter(htmlConverter);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
// QI the data object an |nsISupports| so that when the transferable holds
|
// QI the data object an |nsISupports| so that when the transferable holds
|
||||||
|
@ -610,7 +610,7 @@ nsPlaintextEditor::PutDragDataInTransferable(nsITransferable **aTransferable)
|
||||||
nsCOMPtr<nsISupports> nsisupportsDataWrapper = do_QueryInterface(dataWrapper);
|
nsCOMPtr<nsISupports> nsisupportsDataWrapper = do_QueryInterface(dataWrapper);
|
||||||
rv = trans->SetTransferData(IsPlaintextEditor() ? kUnicodeMime : kHTMLMime,
|
rv = trans->SetTransferData(IsPlaintextEditor() ? kUnicodeMime : kHTMLMime,
|
||||||
nsisupportsDataWrapper, buffer.Length() * sizeof(PRUnichar));
|
nsisupportsDataWrapper, buffer.Length() * sizeof(PRUnichar));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
*aTransferable = trans;
|
*aTransferable = trans;
|
||||||
NS_ADDREF(*aTransferable);
|
NS_ADDREF(*aTransferable);
|
||||||
|
|
|
@ -167,7 +167,7 @@ NS_IMETHODIMP nsPlaintextEditor::Init(nsIDOMDocument *aDoc,
|
||||||
// and "caret behaviour in selection" prefs
|
// and "caret behaviour in selection" prefs
|
||||||
GetDefaultEditorPrefs(mNewlineHandling, mCaretStyle);
|
GetDefaultEditorPrefs(mNewlineHandling, mCaretStyle);
|
||||||
|
|
||||||
if (NS_FAILED(rulesRes)) return rulesRes;
|
NS_ENSURE_SUCCESS(rulesRes, rulesRes);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ NS_IMETHODIMP nsPlaintextEditor::InitRules()
|
||||||
{
|
{
|
||||||
// instantiate the rules for this text editor
|
// instantiate the rules for this text editor
|
||||||
nsresult res = NS_NewTextEditRules(getter_AddRefs(mRules));
|
nsresult res = NS_NewTextEditRules(getter_AddRefs(mRules));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!mRules) return NS_ERROR_UNEXPECTED;
|
if (!mRules) return NS_ERROR_UNEXPECTED;
|
||||||
return mRules->Init(this);
|
return mRules->Init(this);
|
||||||
}
|
}
|
||||||
|
@ -483,20 +483,20 @@ NS_IMETHODIMP nsPlaintextEditor::CreateBRImpl(nsCOMPtr<nsIDOMNode> *aInOutParent
|
||||||
{
|
{
|
||||||
// split the text node
|
// split the text node
|
||||||
res = SplitNode(node, theOffset, getter_AddRefs(tmp));
|
res = SplitNode(node, theOffset, getter_AddRefs(tmp));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = GetNodeLocation(node, address_of(tmp), &offset);
|
res = GetNodeLocation(node, address_of(tmp), &offset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
// create br
|
// create br
|
||||||
res = CreateNode(brType, tmp, offset, getter_AddRefs(brNode));
|
res = CreateNode(brType, tmp, offset, getter_AddRefs(brNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
*aInOutParent = tmp;
|
*aInOutParent = tmp;
|
||||||
*aInOutOffset = offset+1;
|
*aInOutOffset = offset+1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res = CreateNode(brType, node, theOffset, getter_AddRefs(brNode));
|
res = CreateNode(brType, node, theOffset, getter_AddRefs(brNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
(*aInOutOffset)++;
|
(*aInOutOffset)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -506,11 +506,11 @@ NS_IMETHODIMP nsPlaintextEditor::CreateBRImpl(nsCOMPtr<nsIDOMNode> *aInOutParent
|
||||||
nsCOMPtr<nsIDOMNode> parent;
|
nsCOMPtr<nsIDOMNode> parent;
|
||||||
PRInt32 offset;
|
PRInt32 offset;
|
||||||
res = GetNodeLocation(*outBRNode, address_of(parent), &offset);
|
res = GetNodeLocation(*outBRNode, address_of(parent), &offset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
res = GetSelection(getter_AddRefs(selection));
|
res = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
nsCOMPtr<nsISelectionPrivate> selPriv(do_QueryInterface(selection));
|
nsCOMPtr<nsISelectionPrivate> selPriv(do_QueryInterface(selection));
|
||||||
if (aSelect == eNext)
|
if (aSelect == eNext)
|
||||||
{
|
{
|
||||||
|
@ -546,26 +546,26 @@ NS_IMETHODIMP nsPlaintextEditor::InsertBR(nsCOMPtr<nsIDOMNode> *outBRNode)
|
||||||
|
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
nsresult res = GetSelection(getter_AddRefs(selection));
|
nsresult res = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
PRBool bCollapsed;
|
PRBool bCollapsed;
|
||||||
res = selection->GetIsCollapsed(&bCollapsed);
|
res = selection->GetIsCollapsed(&bCollapsed);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!bCollapsed)
|
if (!bCollapsed)
|
||||||
{
|
{
|
||||||
res = DeleteSelection(nsIEditor::eNone);
|
res = DeleteSelection(nsIEditor::eNone);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
nsCOMPtr<nsIDOMNode> selNode;
|
nsCOMPtr<nsIDOMNode> selNode;
|
||||||
PRInt32 selOffset;
|
PRInt32 selOffset;
|
||||||
res = GetStartNodeAndOffset(selection, getter_AddRefs(selNode), &selOffset);
|
res = GetStartNodeAndOffset(selection, getter_AddRefs(selNode), &selOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
res = CreateBR(selNode, selOffset, outBRNode);
|
res = CreateBR(selNode, selOffset, outBRNode);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// position selection after br
|
// position selection after br
|
||||||
res = GetNodeLocation(*outBRNode, address_of(selNode), &selOffset);
|
res = GetNodeLocation(*outBRNode, address_of(selNode), &selOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
nsCOMPtr<nsISelectionPrivate> selPriv(do_QueryInterface(selection));
|
nsCOMPtr<nsISelectionPrivate> selPriv(do_QueryInterface(selection));
|
||||||
selPriv->SetInterlinePosition(PR_TRUE);
|
selPriv->SetInterlinePosition(PR_TRUE);
|
||||||
return selection->Collapse(selNode, selOffset+1);
|
return selection->Collapse(selNode, selOffset+1);
|
||||||
|
@ -661,7 +661,7 @@ nsPlaintextEditor::ExtendSelectionForDelete(nsISelection *aSelection,
|
||||||
|
|
||||||
PRBool bCollapsed;
|
PRBool bCollapsed;
|
||||||
result = aSelection->GetIsCollapsed(&bCollapsed);
|
result = aSelection->GetIsCollapsed(&bCollapsed);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
|
|
||||||
if (*aAction == eNextWord || *aAction == ePreviousWord
|
if (*aAction == eNextWord || *aAction == ePreviousWord
|
||||||
|| (*aAction == eNext && bCollapsed)
|
|| (*aAction == eNext && bCollapsed)
|
||||||
|
@ -748,7 +748,7 @@ NS_IMETHODIMP nsPlaintextEditor::DeleteSelection(nsIEditor::EDirection aAction)
|
||||||
// pre-process
|
// pre-process
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
result = GetSelection(getter_AddRefs(selection));
|
result = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
// If there is an existing selection when an extended delete is requested,
|
// If there is an existing selection when an extended delete is requested,
|
||||||
|
@ -758,7 +758,7 @@ NS_IMETHODIMP nsPlaintextEditor::DeleteSelection(nsIEditor::EDirection aAction)
|
||||||
// existing selection without extending it.
|
// existing selection without extending it.
|
||||||
PRBool bCollapsed;
|
PRBool bCollapsed;
|
||||||
result = selection->GetIsCollapsed(&bCollapsed);
|
result = selection->GetIsCollapsed(&bCollapsed);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!bCollapsed &&
|
if (!bCollapsed &&
|
||||||
(aAction == eNextWord || aAction == ePreviousWord ||
|
(aAction == eNextWord || aAction == ePreviousWord ||
|
||||||
aAction == eToBeginningOfLine || aAction == eToEndOfLine))
|
aAction == eToBeginningOfLine || aAction == eToEndOfLine))
|
||||||
|
@ -766,7 +766,7 @@ NS_IMETHODIMP nsPlaintextEditor::DeleteSelection(nsIEditor::EDirection aAction)
|
||||||
if (mCaretStyle == 1)
|
if (mCaretStyle == 1)
|
||||||
{
|
{
|
||||||
result = selection->CollapseToStart();
|
result = selection->CollapseToStart();
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -778,7 +778,7 @@ NS_IMETHODIMP nsPlaintextEditor::DeleteSelection(nsIEditor::EDirection aAction)
|
||||||
ruleInfo.collapsedAction = aAction;
|
ruleInfo.collapsedAction = aAction;
|
||||||
PRBool cancel, handled;
|
PRBool cancel, handled;
|
||||||
result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!cancel && !handled)
|
if (!cancel && !handled)
|
||||||
{
|
{
|
||||||
result = DeleteSelectionImpl(aAction);
|
result = DeleteSelectionImpl(aAction);
|
||||||
|
@ -812,7 +812,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertText(const nsAString &aStringToInsert)
|
||||||
// pre-process
|
// pre-process
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
nsresult result = GetSelection(getter_AddRefs(selection));
|
nsresult result = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
nsAutoString resultString;
|
nsAutoString resultString;
|
||||||
// XXX can we trust instring to outlive ruleInfo,
|
// XXX can we trust instring to outlive ruleInfo,
|
||||||
|
@ -825,7 +825,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertText(const nsAString &aStringToInsert)
|
||||||
|
|
||||||
PRBool cancel, handled;
|
PRBool cancel, handled;
|
||||||
result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
if (!cancel && !handled)
|
if (!cancel && !handled)
|
||||||
{
|
{
|
||||||
// we rely on rules code for now - no default implementation
|
// we rely on rules code for now - no default implementation
|
||||||
|
@ -852,20 +852,20 @@ NS_IMETHODIMP nsPlaintextEditor::InsertLineBreak()
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
nsresult res;
|
nsresult res;
|
||||||
res = GetSelection(getter_AddRefs(selection));
|
res = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
// Batching the selection and moving nodes out from under the caret causes
|
// Batching the selection and moving nodes out from under the caret causes
|
||||||
// caret turds. Ask the shell to invalidate the caret now to avoid the turds.
|
// caret turds. Ask the shell to invalidate the caret now to avoid the turds.
|
||||||
nsCOMPtr<nsIPresShell> shell;
|
nsCOMPtr<nsIPresShell> shell;
|
||||||
res = GetPresShell(getter_AddRefs(shell));
|
res = GetPresShell(getter_AddRefs(shell));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
shell->MaybeInvalidateCaretPosition();
|
shell->MaybeInvalidateCaretPosition();
|
||||||
|
|
||||||
nsTextRulesInfo ruleInfo(nsTextEditRules::kInsertBreak);
|
nsTextRulesInfo ruleInfo(nsTextEditRules::kInsertBreak);
|
||||||
PRBool cancel, handled;
|
PRBool cancel, handled;
|
||||||
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!cancel && !handled)
|
if (!cancel && !handled)
|
||||||
{
|
{
|
||||||
// create the new BR node
|
// create the new BR node
|
||||||
|
@ -1073,7 +1073,7 @@ nsPlaintextEditor::SetWrapWidth(PRInt32 aWrapColumn)
|
||||||
NS_NAMED_LITERAL_STRING(styleName, "style");
|
NS_NAMED_LITERAL_STRING(styleName, "style");
|
||||||
nsAutoString styleValue;
|
nsAutoString styleValue;
|
||||||
nsresult res = rootElement->GetAttribute(styleName, styleValue);
|
nsresult res = rootElement->GetAttribute(styleName, styleValue);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// We'll replace styles for these values:
|
// We'll replace styles for these values:
|
||||||
CutStyle("white-space", styleValue);
|
CutStyle("white-space", styleValue);
|
||||||
|
@ -1282,7 +1282,7 @@ nsPlaintextEditor::GetAndInitDocEncoder(const nsAString& aFormatType,
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIPresShell> presShell;
|
nsCOMPtr<nsIPresShell> presShell;
|
||||||
nsresult rv = GetPresShell(getter_AddRefs(presShell));
|
nsresult rv = GetPresShell(getter_AddRefs(presShell));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (!presShell) return NS_ERROR_FAILURE;
|
if (!presShell) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
nsCAutoString formatType(NS_DOC_ENCODER_CONTRACTID_BASE);
|
nsCAutoString formatType(NS_DOC_ENCODER_CONTRACTID_BASE);
|
||||||
|
@ -1385,7 +1385,7 @@ nsPlaintextEditor::OutputToStream(nsIOutputStream* aOutputStream,
|
||||||
{
|
{
|
||||||
PRBool docEmpty;
|
PRBool docEmpty;
|
||||||
rv = GetDocumentIsEmpty(&docEmpty);
|
rv = GetDocumentIsEmpty(&docEmpty);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
if (docEmpty)
|
if (docEmpty)
|
||||||
return NS_OK; // output nothing
|
return NS_OK; // output nothing
|
||||||
|
@ -1420,7 +1420,7 @@ nsPlaintextEditor::PasteAsQuotation(PRInt32 aSelectionType)
|
||||||
// Get Clipboard Service
|
// Get Clipboard Service
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
|
nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// Create generic Transferable for getting the data
|
// Create generic Transferable for getting the data
|
||||||
nsCOMPtr<nsITransferable> trans = do_CreateInstance("@mozilla.org/widget/transferable;1", &rv);
|
nsCOMPtr<nsITransferable> trans = do_CreateInstance("@mozilla.org/widget/transferable;1", &rv);
|
||||||
|
@ -1491,7 +1491,7 @@ nsPlaintextEditor::InsertAsQuotation(const nsAString& aQuotedText,
|
||||||
// get selection
|
// get selection
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
rv = GetSelection(getter_AddRefs(selection));
|
rv = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
nsAutoEditBatch beginBatching(this);
|
nsAutoEditBatch beginBatching(this);
|
||||||
|
@ -1501,7 +1501,7 @@ nsPlaintextEditor::InsertAsQuotation(const nsAString& aQuotedText,
|
||||||
nsTextRulesInfo ruleInfo(nsTextEditRules::kInsertElement);
|
nsTextRulesInfo ruleInfo(nsTextEditRules::kInsertElement);
|
||||||
PRBool cancel, handled;
|
PRBool cancel, handled;
|
||||||
rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (cancel) return NS_OK; // rules canceled the operation
|
if (cancel) return NS_OK; // rules canceled the operation
|
||||||
if (!handled)
|
if (!handled)
|
||||||
{
|
{
|
||||||
|
@ -1575,17 +1575,17 @@ nsPlaintextEditor::Rewrap(PRBool aRespectNewlines)
|
||||||
rv = SharedOutputString(nsIDocumentEncoder::OutputFormatted
|
rv = SharedOutputString(nsIDocumentEncoder::OutputFormatted
|
||||||
| nsIDocumentEncoder::OutputLFLineBreak,
|
| nsIDocumentEncoder::OutputLFLineBreak,
|
||||||
&isCollapsed, current);
|
&isCollapsed, current);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsICiter> citer = new nsInternetCiter();
|
nsCOMPtr<nsICiter> citer = new nsInternetCiter();
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
if (!citer) return NS_ERROR_UNEXPECTED;
|
if (!citer) return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
nsString wrapped;
|
nsString wrapped;
|
||||||
PRUint32 firstLineOffset = 0; // XXX need to reset this if there is a selection
|
PRUint32 firstLineOffset = 0; // XXX need to reset this if there is a selection
|
||||||
rv = citer->Rewrap(current, wrapCol, firstLineOffset, aRespectNewlines,
|
rv = citer->Rewrap(current, wrapCol, firstLineOffset, aRespectNewlines,
|
||||||
wrapped);
|
wrapped);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
if (isCollapsed) // rewrap the whole document
|
if (isCollapsed) // rewrap the whole document
|
||||||
SelectAll();
|
SelectAll();
|
||||||
|
@ -1604,19 +1604,19 @@ nsPlaintextEditor::StripCites()
|
||||||
PRBool isCollapsed;
|
PRBool isCollapsed;
|
||||||
nsresult rv = SharedOutputString(nsIDocumentEncoder::OutputFormatted,
|
nsresult rv = SharedOutputString(nsIDocumentEncoder::OutputFormatted,
|
||||||
&isCollapsed, current);
|
&isCollapsed, current);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsICiter> citer = new nsInternetCiter();
|
nsCOMPtr<nsICiter> citer = new nsInternetCiter();
|
||||||
if (!citer) return NS_ERROR_UNEXPECTED;
|
if (!citer) return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
nsString stripped;
|
nsString stripped;
|
||||||
rv = citer->StripCites(current, stripped);
|
rv = citer->StripCites(current, stripped);
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
if (isCollapsed) // rewrap the whole document
|
if (isCollapsed) // rewrap the whole document
|
||||||
{
|
{
|
||||||
rv = SelectAll();
|
rv = SelectAll();
|
||||||
if (NS_FAILED(rv)) return rv;
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
return InsertText(stripped);
|
return InsertText(stripped);
|
||||||
|
@ -1652,7 +1652,7 @@ nsPlaintextEditor::SetCompositionString(const nsAString& aCompositionString,
|
||||||
|
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
nsresult result = GetSelection(getter_AddRefs(selection));
|
nsresult result = GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(result)) return result;
|
NS_ENSURE_SUCCESS(result, result);
|
||||||
|
|
||||||
nsRefPtr<nsCaret> caretP = ps->GetCaret();
|
nsRefPtr<nsCaret> caretP = ps->GetCaret();
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@ nsTextEditRules::Init(nsPlaintextEditor *aEditor)
|
||||||
// Put in a magic br if needed. This method handles null selection,
|
// Put in a magic br if needed. This method handles null selection,
|
||||||
// which should never happen anyway
|
// which should never happen anyway
|
||||||
nsresult res = CreateBogusNodeIfNeeded(selection);
|
nsresult res = CreateBogusNodeIfNeeded(selection);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// If the selection hasn't been set up yet, set it up collapsed to the end of
|
// If the selection hasn't been set up yet, set it up collapsed to the end of
|
||||||
// our editable content.
|
// our editable content.
|
||||||
|
@ -167,7 +167,7 @@ nsTextEditRules::Init(nsPlaintextEditor *aEditor)
|
||||||
{
|
{
|
||||||
// ensure trailing br node
|
// ensure trailing br node
|
||||||
res = CreateTrailingBRIfNeeded();
|
res = CreateTrailingBRIfNeeded();
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (body)
|
if (body)
|
||||||
|
@ -179,15 +179,15 @@ nsTextEditRules::Init(nsPlaintextEditor *aEditor)
|
||||||
wholeDoc->SetStart(body,0);
|
wholeDoc->SetStart(body,0);
|
||||||
nsCOMPtr<nsIDOMNodeList> list;
|
nsCOMPtr<nsIDOMNodeList> list;
|
||||||
res = body->GetChildNodes(getter_AddRefs(list));
|
res = body->GetChildNodes(getter_AddRefs(list));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!list) return NS_ERROR_FAILURE;
|
if (!list) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
PRUint32 listCount;
|
PRUint32 listCount;
|
||||||
res = list->GetLength(&listCount);
|
res = list->GetLength(&listCount);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
res = wholeDoc->SetEnd(body, listCount);
|
res = wholeDoc->SetEnd(body, listCount);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// replace newlines in that range with breaks
|
// replace newlines in that range with breaks
|
||||||
res = ReplaceNewlines(wholeDoc);
|
res = ReplaceNewlines(wholeDoc);
|
||||||
|
@ -254,7 +254,7 @@ nsTextEditRules::AfterEdit(PRInt32 action, nsIEditor::EDirection aDirection)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsISelection>selection;
|
nsCOMPtr<nsISelection>selection;
|
||||||
res = mEditor->GetSelection(getter_AddRefs(selection));
|
res = mEditor->GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
res = mEditor->HandleInlineSpellCheck(action, selection,
|
res = mEditor->HandleInlineSpellCheck(action, selection,
|
||||||
mCachedSelectionNode, mCachedSelectionOffset,
|
mCachedSelectionNode, mCachedSelectionOffset,
|
||||||
|
@ -443,15 +443,15 @@ nsTextEditRules::WillInsertBreak(nsISelection *aSelection, PRBool *aCancel, PRBo
|
||||||
// if the selection isn't collapsed, delete it.
|
// if the selection isn't collapsed, delete it.
|
||||||
PRBool bCollapsed;
|
PRBool bCollapsed;
|
||||||
nsresult res = aSelection->GetIsCollapsed(&bCollapsed);
|
nsresult res = aSelection->GetIsCollapsed(&bCollapsed);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!bCollapsed)
|
if (!bCollapsed)
|
||||||
{
|
{
|
||||||
res = mEditor->DeleteSelection(nsIEditor::eNone);
|
res = mEditor->DeleteSelection(nsIEditor::eNone);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
res = WillInsert(aSelection, aCancel);
|
res = WillInsert(aSelection, aCancel);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
// initialize out param
|
// initialize out param
|
||||||
// we want to ignore result of WillInsert()
|
// we want to ignore result of WillInsert()
|
||||||
*aCancel = PR_FALSE;
|
*aCancel = PR_FALSE;
|
||||||
|
@ -477,7 +477,7 @@ nsTextEditRules::DidInsertBreak(nsISelection *aSelection, nsresult aResult)
|
||||||
nsCOMPtr<nsIDOMNode> selNode;
|
nsCOMPtr<nsIDOMNode> selNode;
|
||||||
nsresult res;
|
nsresult res;
|
||||||
res = mEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(selNode), &selOffset);
|
res = mEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(selNode), &selOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
// confirm we are at end of document
|
// confirm we are at end of document
|
||||||
if (selOffset == 0) return NS_OK; // can't be after a br if we are at offset 0
|
if (selOffset == 0) return NS_OK; // can't be after a br if we are at offset 0
|
||||||
nsIDOMElement *rootElem = mEditor->GetRoot();
|
nsIDOMElement *rootElem = mEditor->GetRoot();
|
||||||
|
@ -498,13 +498,13 @@ nsTextEditRules::DidInsertBreak(nsISelection *aSelection, nsresult aResult)
|
||||||
// like table cells won't grow in height.
|
// like table cells won't grow in height.
|
||||||
nsCOMPtr<nsIDOMNode> brNode;
|
nsCOMPtr<nsIDOMNode> brNode;
|
||||||
res = CreateMozBR(selNode, selOffset, address_of(brNode));
|
res = CreateMozBR(selNode, selOffset, address_of(brNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
res = nsEditor::GetNodeLocation(brNode, address_of(selNode), &selOffset);
|
res = nsEditor::GetNodeLocation(brNode, address_of(selNode), &selOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
selPrivate->SetInterlinePosition(PR_TRUE);
|
selPrivate->SetInterlinePosition(PR_TRUE);
|
||||||
res = aSelection->Collapse(selNode, selOffset);
|
res = aSelection->Collapse(selNode, selOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -514,7 +514,7 @@ GetTextNode(nsISelection *selection, nsEditor *editor) {
|
||||||
PRInt32 selOffset;
|
PRInt32 selOffset;
|
||||||
nsCOMPtr<nsIDOMNode> selNode;
|
nsCOMPtr<nsIDOMNode> selNode;
|
||||||
nsresult res = editor->GetStartNodeAndOffset(selection, getter_AddRefs(selNode), &selOffset);
|
nsresult res = editor->GetStartNodeAndOffset(selection, getter_AddRefs(selNode), &selOffset);
|
||||||
if (NS_FAILED(res)) return nsnull;
|
NS_ENSURE_SUCCESS(res, nsnull);
|
||||||
if (!editor->IsTextNode(selNode)) {
|
if (!editor->IsTextNode(selNode)) {
|
||||||
// Get an nsINode from the nsIDOMNode
|
// Get an nsINode from the nsIDOMNode
|
||||||
nsCOMPtr<nsINode> node = do_QueryInterface(selNode);
|
nsCOMPtr<nsINode> node = do_QueryInterface(selNode);
|
||||||
|
@ -641,7 +641,7 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
|
||||||
// handle docs with a max length
|
// handle docs with a max length
|
||||||
// NOTE, this function copies inString into outString for us.
|
// NOTE, this function copies inString into outString for us.
|
||||||
nsresult res = TruncateInsertionIfNeeded(aSelection, inString, outString, aMaxLength);
|
nsresult res = TruncateInsertionIfNeeded(aSelection, inString, outString, aMaxLength);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
PRUint32 start = 0;
|
PRUint32 start = 0;
|
||||||
PRUint32 end = 0;
|
PRUint32 end = 0;
|
||||||
|
@ -651,21 +651,21 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
|
||||||
{
|
{
|
||||||
res = mEditor->GetTextSelectionOffsets(aSelection, start, end);
|
res = mEditor->GetTextSelectionOffsets(aSelection, start, end);
|
||||||
NS_ASSERTION((NS_SUCCEEDED(res)), "getTextSelectionOffsets failed!");
|
NS_ASSERTION((NS_SUCCEEDED(res)), "getTextSelectionOffsets failed!");
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the selection isn't collapsed, delete it.
|
// if the selection isn't collapsed, delete it.
|
||||||
PRBool bCollapsed;
|
PRBool bCollapsed;
|
||||||
res = aSelection->GetIsCollapsed(&bCollapsed);
|
res = aSelection->GetIsCollapsed(&bCollapsed);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!bCollapsed)
|
if (!bCollapsed)
|
||||||
{
|
{
|
||||||
res = mEditor->DeleteSelection(nsIEditor::eNone);
|
res = mEditor->DeleteSelection(nsIEditor::eNone);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
res = WillInsert(aSelection, aCancel);
|
res = WillInsert(aSelection, aCancel);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
// initialize out param
|
// initialize out param
|
||||||
// we want to ignore result of WillInsert()
|
// we want to ignore result of WillInsert()
|
||||||
*aCancel = PR_FALSE;
|
*aCancel = PR_FALSE;
|
||||||
|
@ -677,7 +677,7 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
|
||||||
{
|
{
|
||||||
if (aAction == kInsertTextIME) {
|
if (aAction == kInsertTextIME) {
|
||||||
res = RemoveIMETextFromPWBuf(start, outString);
|
res = RemoveIMETextFromPWBuf(start, outString);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -717,14 +717,14 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mTimer = do_CreateInstance("@mozilla.org/timer;1", &res);
|
mTimer = do_CreateInstance("@mozilla.org/timer;1", &res);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
mTimer->InitWithCallback(this, 600, nsITimer::TYPE_ONE_SHOT);
|
mTimer->InitWithCallback(this, 600, nsITimer::TYPE_ONE_SHOT);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res = FillBufWithPWChars(outString, outString->Length());
|
res = FillBufWithPWChars(outString, outString->Length());
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -732,7 +732,7 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
|
||||||
nsCOMPtr<nsIDOMNode> selNode;
|
nsCOMPtr<nsIDOMNode> selNode;
|
||||||
PRInt32 selOffset;
|
PRInt32 selOffset;
|
||||||
res = mEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(selNode), &selOffset);
|
res = mEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(selNode), &selOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// don't put text in places that can't have it
|
// don't put text in places that can't have it
|
||||||
if (!mEditor->IsTextNode(selNode) && !mEditor->CanContainTag(selNode, NS_LITERAL_STRING("#text")))
|
if (!mEditor->IsTextNode(selNode) && !mEditor->CanContainTag(selNode, NS_LITERAL_STRING("#text")))
|
||||||
|
@ -741,13 +741,13 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
|
||||||
// we need to get the doc
|
// we need to get the doc
|
||||||
nsCOMPtr<nsIDOMDocument>doc;
|
nsCOMPtr<nsIDOMDocument>doc;
|
||||||
res = mEditor->GetDocument(getter_AddRefs(doc));
|
res = mEditor->GetDocument(getter_AddRefs(doc));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!doc) return NS_ERROR_NULL_POINTER;
|
if (!doc) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
if (aAction == kInsertTextIME)
|
if (aAction == kInsertTextIME)
|
||||||
{
|
{
|
||||||
res = mEditor->InsertTextImpl(*outString, address_of(selNode), &selOffset, doc);
|
res = mEditor->InsertTextImpl(*outString, address_of(selNode), &selOffset, doc);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
else // aAction == kInsertText
|
else // aAction == kInsertText
|
||||||
{
|
{
|
||||||
|
@ -759,7 +759,7 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
|
||||||
// We remember this so that we know how to handle tabs.
|
// We remember this so that we know how to handle tabs.
|
||||||
PRBool isPRE;
|
PRBool isPRE;
|
||||||
res = mEditor->IsPreformatted(selNode, &isPRE);
|
res = mEditor->IsPreformatted(selNode, &isPRE);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// don't spaz my selection in subtransactions
|
// don't spaz my selection in subtransactions
|
||||||
nsAutoTxnsConserveSelection dontSpazMySelection(mEditor);
|
nsAutoTxnsConserveSelection dontSpazMySelection(mEditor);
|
||||||
|
@ -835,7 +835,7 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
|
||||||
{
|
{
|
||||||
res = mEditor->InsertTextImpl(subStr, address_of(curNode), &curOffset, doc);
|
res = mEditor->InsertTextImpl(subStr, address_of(curNode), &curOffset, doc);
|
||||||
}
|
}
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -878,7 +878,7 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
|
||||||
{
|
{
|
||||||
res = mEditor->InsertTextImpl(subStr, address_of(curNode), &curOffset, doc);
|
res = mEditor->InsertTextImpl(subStr, address_of(curNode), &curOffset, doc);
|
||||||
}
|
}
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
outString->Assign(tString);
|
outString->Assign(tString);
|
||||||
|
@ -1006,18 +1006,18 @@ nsTextEditRules::WillDeleteSelection(nsISelection *aSelection,
|
||||||
nsCOMPtr<nsIDOMNode> startNode;
|
nsCOMPtr<nsIDOMNode> startNode;
|
||||||
PRInt32 startOffset;
|
PRInt32 startOffset;
|
||||||
res = mEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(startNode), &startOffset);
|
res = mEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(startNode), &startOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!startNode) return NS_ERROR_FAILURE;
|
if (!startNode) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
PRBool bCollapsed;
|
PRBool bCollapsed;
|
||||||
res = aSelection->GetIsCollapsed(&bCollapsed);
|
res = aSelection->GetIsCollapsed(&bCollapsed);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
if (!bCollapsed) return NS_OK;
|
if (!bCollapsed) return NS_OK;
|
||||||
|
|
||||||
// Test for distance between caret and text that will be deleted
|
// Test for distance between caret and text that will be deleted
|
||||||
res = CheckBidiLevelForDeletion(aSelection, startNode, startOffset, aCollapsedAction, aCancel);
|
res = CheckBidiLevelForDeletion(aSelection, startNode, startOffset, aCollapsedAction, aCancel);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (*aCancel) return NS_OK;
|
if (*aCancel) return NS_OK;
|
||||||
|
|
||||||
res = mEditor->ExtendSelectionForDelete(aSelection, &aCollapsedAction);
|
res = mEditor->ExtendSelectionForDelete(aSelection, &aCollapsedAction);
|
||||||
|
@ -1040,7 +1040,7 @@ nsTextEditRules::DidDeleteSelection(nsISelection *aSelection,
|
||||||
nsCOMPtr<nsIDOMNode> startNode;
|
nsCOMPtr<nsIDOMNode> startNode;
|
||||||
PRInt32 startOffset;
|
PRInt32 startOffset;
|
||||||
nsresult res = mEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(startNode), &startOffset);
|
nsresult res = mEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(startNode), &startOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!startNode) return NS_ERROR_FAILURE;
|
if (!startNode) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
// delete empty text nodes at selection
|
// delete empty text nodes at selection
|
||||||
|
@ -1049,13 +1049,13 @@ nsTextEditRules::DidDeleteSelection(nsISelection *aSelection,
|
||||||
nsCOMPtr<nsIDOMText> textNode = do_QueryInterface(startNode);
|
nsCOMPtr<nsIDOMText> textNode = do_QueryInterface(startNode);
|
||||||
PRUint32 strLength;
|
PRUint32 strLength;
|
||||||
res = textNode->GetLength(&strLength);
|
res = textNode->GetLength(&strLength);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// are we in an empty text node?
|
// are we in an empty text node?
|
||||||
if (!strLength)
|
if (!strLength)
|
||||||
{
|
{
|
||||||
res = mEditor->DeleteNode(startNode);
|
res = mEditor->DeleteNode(startNode);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!mDidExplicitlySetInterline)
|
if (!mDidExplicitlySetInterline)
|
||||||
|
@ -1135,7 +1135,7 @@ nsTextEditRules::DidRedo(nsISelection *aSelection, nsresult aResult)
|
||||||
nsCOMPtr<nsIDOMNodeList> nodeList;
|
nsCOMPtr<nsIDOMNodeList> nodeList;
|
||||||
res = theRoot->GetElementsByTagName(NS_LITERAL_STRING("br"),
|
res = theRoot->GetElementsByTagName(NS_LITERAL_STRING("br"),
|
||||||
getter_AddRefs(nodeList));
|
getter_AddRefs(nodeList));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (nodeList)
|
if (nodeList)
|
||||||
{
|
{
|
||||||
PRUint32 len;
|
PRUint32 len;
|
||||||
|
@ -1204,10 +1204,10 @@ nsTextEditRules::ReplaceNewlines(nsIDOMRange *aRange)
|
||||||
nsresult res;
|
nsresult res;
|
||||||
nsCOMPtr<nsIContentIterator> iter =
|
nsCOMPtr<nsIContentIterator> iter =
|
||||||
do_CreateInstance("@mozilla.org/content/post-content-iterator;1", &res);
|
do_CreateInstance("@mozilla.org/content/post-content-iterator;1", &res);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
res = iter->Init(aRange);
|
res = iter->Init(aRange);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
nsCOMArray<nsIDOMCharacterData> arrayOfNodes;
|
nsCOMArray<nsIDOMCharacterData> arrayOfNodes;
|
||||||
|
|
||||||
|
@ -1222,7 +1222,7 @@ nsTextEditRules::ReplaceNewlines(nsIDOMRange *aRange)
|
||||||
{
|
{
|
||||||
PRBool isPRE;
|
PRBool isPRE;
|
||||||
res = mEditor->IsPreformatted(node, &isPRE);
|
res = mEditor->IsPreformatted(node, &isPRE);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (isPRE)
|
if (isPRE)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMCharacterData> data = do_QueryInterface(node);
|
nsCOMPtr<nsIDOMCharacterData> data = do_QueryInterface(node);
|
||||||
|
@ -1257,14 +1257,14 @@ nsTextEditRules::ReplaceNewlines(nsIDOMRange *aRange)
|
||||||
// or, failing that, undo is disabled
|
// or, failing that, undo is disabled
|
||||||
res = mEditor->CreateTxnForDeleteText(textNode, offset, 1,
|
res = mEditor->CreateTxnForDeleteText(textNode, offset, 1,
|
||||||
getter_AddRefs(txn));
|
getter_AddRefs(txn));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!txn) return NS_ERROR_OUT_OF_MEMORY;
|
if (!txn) return NS_ERROR_OUT_OF_MEMORY;
|
||||||
res = mEditor->DoTransaction(txn);
|
res = mEditor->DoTransaction(txn);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// insert a break
|
// insert a break
|
||||||
res = mEditor->CreateBR(textNode, offset, address_of(brNode));
|
res = mEditor->CreateBR(textNode, offset, address_of(brNode));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
} while (1); // break used to exit while loop
|
} while (1); // break used to exit while loop
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
@ -1282,7 +1282,7 @@ nsTextEditRules::CreateTrailingBRIfNeeded()
|
||||||
nsCOMPtr<nsIDOMNode> lastChild;
|
nsCOMPtr<nsIDOMNode> lastChild;
|
||||||
nsresult res = body->GetLastChild(getter_AddRefs(lastChild));
|
nsresult res = body->GetLastChild(getter_AddRefs(lastChild));
|
||||||
// assuming CreateBogusNodeIfNeeded() has been called first
|
// assuming CreateBogusNodeIfNeeded() has been called first
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
if (!lastChild) return NS_ERROR_NULL_POINTER;
|
if (!lastChild) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
if (!nsTextEditUtils::IsBreak(lastChild))
|
if (!nsTextEditUtils::IsBreak(lastChild))
|
||||||
|
@ -1290,7 +1290,7 @@ nsTextEditRules::CreateTrailingBRIfNeeded()
|
||||||
nsAutoTxnsConserveSelection dontSpazMySelection(mEditor);
|
nsAutoTxnsConserveSelection dontSpazMySelection(mEditor);
|
||||||
PRUint32 rootLen;
|
PRUint32 rootLen;
|
||||||
res = mEditor->GetLengthOfDOMNode(body, rootLen);
|
res = mEditor->GetLengthOfDOMNode(body, rootLen);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
nsCOMPtr<nsIDOMNode> unused;
|
nsCOMPtr<nsIDOMNode> unused;
|
||||||
res = CreateMozBR(body, rootLen, address_of(unused));
|
res = CreateMozBR(body, rootLen, address_of(unused));
|
||||||
}
|
}
|
||||||
|
@ -1340,7 +1340,7 @@ nsTextEditRules::CreateBogusNodeIfNeeded(nsISelection *aSelection)
|
||||||
// create a br
|
// create a br
|
||||||
nsCOMPtr<nsIContent> newContent;
|
nsCOMPtr<nsIContent> newContent;
|
||||||
res = mEditor->CreateHTMLContent(NS_LITERAL_STRING("br"), getter_AddRefs(newContent));
|
res = mEditor->CreateHTMLContent(NS_LITERAL_STRING("br"), getter_AddRefs(newContent));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
nsCOMPtr<nsIDOMElement>brElement = do_QueryInterface(newContent);
|
nsCOMPtr<nsIDOMElement>brElement = do_QueryInterface(newContent);
|
||||||
|
|
||||||
// set mBogusNode to be the newly created <br>
|
// set mBogusNode to be the newly created <br>
|
||||||
|
@ -1353,7 +1353,7 @@ nsTextEditRules::CreateBogusNodeIfNeeded(nsISelection *aSelection)
|
||||||
|
|
||||||
// put the node in the document
|
// put the node in the document
|
||||||
res = mEditor->InsertNode(mBogusNode, body, 0);
|
res = mEditor->InsertNode(mBogusNode, body, 0);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// set selection
|
// set selection
|
||||||
aSelection->Collapse(body, 0);
|
aSelection->Collapse(body, 0);
|
||||||
|
@ -1464,9 +1464,9 @@ nsresult nsTextEditRules::HideLastPWInput() {
|
||||||
nsCOMPtr<nsISelection> selection;
|
nsCOMPtr<nsISelection> selection;
|
||||||
PRUint32 start, end;
|
PRUint32 start, end;
|
||||||
nsresult res = mEditor->GetSelection(getter_AddRefs(selection));
|
nsresult res = mEditor->GetSelection(getter_AddRefs(selection));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
res = mEditor->GetTextSelectionOffsets(selection, start, end);
|
res = mEditor->GetTextSelectionOffsets(selection, start, end);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMNode> selNode = GetTextNode(selection, mEditor);
|
nsCOMPtr<nsIDOMNode> selNode = GetTextNode(selection, mEditor);
|
||||||
if (!selNode)
|
if (!selNode)
|
||||||
|
@ -1515,14 +1515,14 @@ nsTextEditRules::CreateMozBR(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<ns
|
||||||
if (!inParent || !outBRNode) return NS_ERROR_NULL_POINTER;
|
if (!inParent || !outBRNode) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
nsresult res = mEditor->CreateBR(inParent, inOffset, outBRNode);
|
nsresult res = mEditor->CreateBR(inParent, inOffset, outBRNode);
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// give it special moz attr
|
// give it special moz attr
|
||||||
nsCOMPtr<nsIDOMElement> brElem = do_QueryInterface(*outBRNode);
|
nsCOMPtr<nsIDOMElement> brElem = do_QueryInterface(*outBRNode);
|
||||||
if (brElem)
|
if (brElem)
|
||||||
{
|
{
|
||||||
res = mEditor->SetAttribute(brElem, NS_LITERAL_STRING("type"), NS_LITERAL_STRING("_moz"));
|
res = mEditor->SetAttribute(brElem, NS_LITERAL_STRING("type"), NS_LITERAL_STRING("_moz"));
|
||||||
if (NS_FAILED(res)) return res;
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,10 +271,10 @@ ContentIsInTraversalRange(nsIContent *aContent, PRBool aIsPreMode,
|
||||||
PRInt32 startRes;
|
PRInt32 startRes;
|
||||||
PRInt32 endRes;
|
PRInt32 endRes;
|
||||||
nsresult rv = nsTextServicesDocument::ComparePoints(aStartNode, aStartOffset, parentNode, indx, &startRes);
|
nsresult rv = nsTextServicesDocument::ComparePoints(aStartNode, aStartOffset, parentNode, indx, &startRes);
|
||||||
if (NS_FAILED(rv)) return PR_FALSE;
|
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||||
|
|
||||||
rv = nsTextServicesDocument::ComparePoints(aEndNode, aEndOffset, parentNode, indx, &endRes);
|
rv = nsTextServicesDocument::ComparePoints(aEndNode, aEndOffset, parentNode, indx, &endRes);
|
||||||
if (NS_FAILED(rv)) return PR_FALSE;
|
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||||
|
|
||||||
return (startRes <= 0) && (endRes >= 0);
|
return (startRes <= 0) && (endRes >= 0);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче