mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 684187 - Use dom::Element instead of nsIDOMElement for nsEditor::mRootElement; r=ehsan
This commit is contained in:
parent
501b6f1760
commit
9a367e43a4
@ -1022,7 +1022,7 @@ nsEditor::GetDocumentIsEmpty(bool *aDocumentIsEmpty)
|
||||
{
|
||||
*aDocumentIsEmpty = true;
|
||||
|
||||
nsIDOMElement *rootElement = GetRoot();
|
||||
nsCOMPtr<nsIDOMElement> rootElement = do_QueryInterface(GetRoot());
|
||||
NS_ENSURE_TRUE(rootElement, NS_ERROR_NULL_POINTER);
|
||||
|
||||
bool hasChildNodes;
|
||||
@ -1063,7 +1063,7 @@ NS_IMETHODIMP nsEditor::BeginningOfDocument()
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
// get the root element
|
||||
nsIDOMElement *rootElement = GetRoot();
|
||||
nsCOMPtr<nsIDOMElement> rootElement = do_QueryInterface(GetRoot());
|
||||
NS_ENSURE_TRUE(rootElement, NS_ERROR_NULL_POINTER);
|
||||
|
||||
// find first editable thingy
|
||||
@ -1109,12 +1109,9 @@ nsEditor::EndOfDocument()
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
|
||||
// get the root element
|
||||
nsIDOMElement *rootElement = GetRoot();
|
||||
NS_ENSURE_TRUE(rootElement, NS_ERROR_NULL_POINTER);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(rootElement);
|
||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(GetRoot());
|
||||
NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
|
||||
nsCOMPtr<nsIDOMNode> child;
|
||||
NS_ASSERTION(node, "Invalid root element");
|
||||
|
||||
do {
|
||||
node->GetLastChild(getter_AddRefs(child));
|
||||
@ -1978,18 +1975,14 @@ nsEditor::GetPhonetic(nsAString& aPhonetic)
|
||||
|
||||
|
||||
static nsresult
|
||||
GetEditorContentWindow(nsIDOMElement *aRoot, nsIWidget **aResult)
|
||||
GetEditorContentWindow(dom::Element *aRoot, nsIWidget **aResult)
|
||||
{
|
||||
NS_ENSURE_TRUE(aRoot && aResult, NS_ERROR_NULL_POINTER);
|
||||
|
||||
*aResult = 0;
|
||||
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aRoot);
|
||||
|
||||
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
|
||||
|
||||
// Not ref counted
|
||||
nsIFrame *frame = content->GetPrimaryFrame();
|
||||
nsIFrame *frame = aRoot->GetPrimaryFrame();
|
||||
|
||||
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
|
||||
|
||||
@ -2103,8 +2096,8 @@ nsEditor::GetRootElement(nsIDOMElement **aRootElement)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRootElement);
|
||||
NS_ENSURE_TRUE(mRootElement, NS_ERROR_NOT_AVAILABLE);
|
||||
*aRootElement = mRootElement;
|
||||
NS_ADDREF(*aRootElement);
|
||||
nsCOMPtr<nsIDOMElement> rootElement = do_QueryInterface(mRootElement);
|
||||
rootElement.forget(aRootElement);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -2175,12 +2168,10 @@ nsEditor::CloneAttributes(nsIDOMNode *aDestNode, nsIDOMNode *aSourceNode)
|
||||
|
||||
// Use transaction system for undo only if destination
|
||||
// is already in the document
|
||||
nsIDOMElement *rootElement = GetRoot();
|
||||
NS_ENSURE_TRUE(rootElement, NS_ERROR_NULL_POINTER);
|
||||
|
||||
bool destInBody = true;
|
||||
nsCOMPtr<nsIDOMNode> rootNode = do_QueryInterface(rootElement);
|
||||
nsCOMPtr<nsIDOMNode> p = aDestNode;
|
||||
nsCOMPtr<nsIDOMNode> rootNode = do_QueryInterface(GetRoot());
|
||||
NS_ENSURE_TRUE(rootNode, NS_ERROR_NULL_POINTER);
|
||||
bool destInBody = true;
|
||||
while (p && p != rootNode)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> tmp;
|
||||
@ -2292,11 +2283,12 @@ NS_IMETHODIMP nsEditor::InsertTextImpl(const nsAString& aStringToInsert,
|
||||
if (!mInIMEMode && aStringToInsert.IsEmpty()) return NS_OK;
|
||||
nsCOMPtr<nsIDOMText> nodeAsText = do_QueryInterface(*aInOutNode);
|
||||
if (!nodeAsText && IsPlaintextEditor()) {
|
||||
nsCOMPtr<nsIDOMNode> rootNode = do_QueryInterface(GetRoot());
|
||||
// In some cases, aInOutNode is the anonymous DIV, and aInOutOffset is 0.
|
||||
// To avoid injecting unneeded text nodes, we first look to see if we have
|
||||
// one available. In that case, we'll just adjust aInOutNode and aInOutOffset
|
||||
// accordingly.
|
||||
if (*aInOutNode == GetRoot() && *aInOutOffset == 0) {
|
||||
if (*aInOutNode == rootNode && *aInOutOffset == 0) {
|
||||
nsCOMPtr<nsIDOMNode> possibleTextNode;
|
||||
res = (*aInOutNode)->GetFirstChild(getter_AddRefs(possibleTextNode));
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
@ -2309,7 +2301,7 @@ NS_IMETHODIMP nsEditor::InsertTextImpl(const nsAString& aStringToInsert,
|
||||
// In some other cases, aInOutNode is the anonymous DIV, and aInOutOffset points
|
||||
// to the terminating mozBR. In that case, we'll adjust aInOutNode and aInOutOffset
|
||||
// to the preceding text node, if any.
|
||||
if (!nodeAsText && *aInOutNode == GetRoot() && *aInOutOffset > 0) {
|
||||
if (!nodeAsText && *aInOutNode == rootNode && *aInOutOffset > 0) {
|
||||
nsCOMPtr<nsIDOMNodeList> children;
|
||||
res = (*aInOutNode)->GetChildNodes(getter_AddRefs(children));
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
@ -2363,7 +2355,7 @@ NS_IMETHODIMP nsEditor::InsertTextImpl(const nsAString& aStringToInsert,
|
||||
} else {
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
(*aInOutNode)->GetParentNode(getter_AddRefs(parent));
|
||||
if (parent == GetRoot()) {
|
||||
if (parent == rootNode) {
|
||||
*aInOutNode = parent;
|
||||
}
|
||||
}
|
||||
@ -2530,7 +2522,7 @@ NS_IMETHODIMP nsEditor::SelectEntireDocument(nsISelection *aSelection)
|
||||
{
|
||||
if (!aSelection) { return NS_ERROR_NULL_POINTER; }
|
||||
|
||||
nsIDOMElement *rootElement = GetRoot();
|
||||
nsCOMPtr<nsIDOMElement> rootElement = do_QueryInterface(GetRoot());
|
||||
if (!rootElement) { return NS_ERROR_NOT_INITIALIZED; }
|
||||
|
||||
return aSelection->SelectAllChildren(rootElement);
|
||||
@ -3546,7 +3538,9 @@ nsEditor::IsRootNode(nsIDOMNode *inNode)
|
||||
{
|
||||
NS_ENSURE_TRUE(inNode, false);
|
||||
|
||||
return inNode == GetRoot();
|
||||
nsCOMPtr<nsIDOMNode> rootNode = do_QueryInterface(GetRoot());
|
||||
|
||||
return inNode == rootNode;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -3554,11 +3548,9 @@ nsEditor::IsRootNode(nsINode *inNode)
|
||||
{
|
||||
NS_ENSURE_TRUE(inNode, false);
|
||||
|
||||
nsIDOMElement *rootElement = GetRoot();
|
||||
nsCOMPtr<nsINode> rootNode = GetRoot();
|
||||
|
||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(inNode);
|
||||
|
||||
return node == rootElement;
|
||||
return inNode == rootNode;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -3572,7 +3564,7 @@ bool
|
||||
nsEditor::IsDescendantOfBody(nsINode *inNode)
|
||||
{
|
||||
NS_ENSURE_TRUE(inNode, false);
|
||||
nsCOMPtr<nsIContent> root = do_QueryInterface(GetRoot());
|
||||
nsCOMPtr<nsIContent> root = GetRoot();
|
||||
NS_ENSURE_TRUE(root, false);
|
||||
|
||||
return nsContentUtils::ContentIsDescendantOf(inNode, root);
|
||||
@ -5149,7 +5141,7 @@ nsEditor::HandleInlineSpellCheck(PRInt32 action,
|
||||
already_AddRefed<nsIContent>
|
||||
nsEditor::FindSelectionRoot(nsINode *aNode)
|
||||
{
|
||||
nsCOMPtr<nsIContent> rootContent = do_QueryInterface(GetRoot());
|
||||
nsCOMPtr<nsIContent> rootContent = GetRoot();
|
||||
return rootContent.forget();
|
||||
}
|
||||
|
||||
@ -5218,7 +5210,7 @@ nsEditor::InitializeSelection(nsIDOMEventTarget* aFocusEventTarget)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIDOMElement *
|
||||
dom::Element *
|
||||
nsEditor::GetRoot()
|
||||
{
|
||||
if (!mRootElement)
|
||||
@ -5236,18 +5228,14 @@ nsresult
|
||||
nsEditor::DetermineCurrentDirection()
|
||||
{
|
||||
// Get the current root direction from its frame
|
||||
nsIDOMElement *rootElement = GetRoot();
|
||||
|
||||
nsresult rv;
|
||||
dom::Element *rootElement = GetRoot();
|
||||
|
||||
// If we don't have an explicit direction, determine our direction
|
||||
// from the content's direction
|
||||
if (!(mFlags & (nsIPlaintextEditor::eEditorLeftToRight |
|
||||
nsIPlaintextEditor::eEditorRightToLeft))) {
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(rootElement, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsIFrame* frame = content->GetPrimaryFrame();
|
||||
nsIFrame* frame = rootElement->GetPrimaryFrame();
|
||||
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
|
||||
|
||||
// Set the flag here, to enable us to use the same code path below.
|
||||
@ -5266,8 +5254,7 @@ NS_IMETHODIMP
|
||||
nsEditor::SwitchTextDirection()
|
||||
{
|
||||
// Get the current root direction from its frame
|
||||
nsIDOMElement *rootElement = GetRoot();
|
||||
|
||||
dom::Element *rootElement = GetRoot();
|
||||
nsresult rv = DetermineCurrentDirection();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -5277,13 +5264,13 @@ nsEditor::SwitchTextDirection()
|
||||
"Unexpected mutually exclusive flag");
|
||||
mFlags &= ~nsIPlaintextEditor::eEditorRightToLeft;
|
||||
mFlags |= nsIPlaintextEditor::eEditorLeftToRight;
|
||||
rv = rootElement->SetAttribute(NS_LITERAL_STRING("dir"), NS_LITERAL_STRING("ltr"));
|
||||
rv = rootElement->SetAttr(kNameSpaceID_None, nsGkAtoms::dir, NS_LITERAL_STRING("ltr"), true);
|
||||
} else if (mFlags & nsIPlaintextEditor::eEditorLeftToRight) {
|
||||
NS_ASSERTION(!(mFlags & nsIPlaintextEditor::eEditorRightToLeft),
|
||||
"Unexpected mutually exclusive flag");
|
||||
mFlags |= nsIPlaintextEditor::eEditorRightToLeft;
|
||||
mFlags &= ~nsIPlaintextEditor::eEditorLeftToRight;
|
||||
rv = rootElement->SetAttribute(NS_LITERAL_STRING("dir"), NS_LITERAL_STRING("rtl"));
|
||||
rv = rootElement->SetAttr(kNameSpaceID_None, nsGkAtoms::dir, NS_LITERAL_STRING("rtl"), true);
|
||||
}
|
||||
|
||||
return rv;
|
||||
@ -5293,8 +5280,7 @@ void
|
||||
nsEditor::SwitchTextDirectionTo(PRUint32 aDirection)
|
||||
{
|
||||
// Get the current root direction from its frame
|
||||
nsIDOMElement *rootElement = GetRoot();
|
||||
|
||||
dom::Element *rootElement = GetRoot();
|
||||
nsresult rv = DetermineCurrentDirection();
|
||||
NS_ENSURE_SUCCESS(rv, );
|
||||
|
||||
@ -5305,14 +5291,14 @@ nsEditor::SwitchTextDirectionTo(PRUint32 aDirection)
|
||||
"Unexpected mutually exclusive flag");
|
||||
mFlags &= ~nsIPlaintextEditor::eEditorRightToLeft;
|
||||
mFlags |= nsIPlaintextEditor::eEditorLeftToRight;
|
||||
rootElement->SetAttribute(NS_LITERAL_STRING("dir"), NS_LITERAL_STRING("ltr"));
|
||||
rootElement->SetAttr(kNameSpaceID_None, nsGkAtoms::dir, NS_LITERAL_STRING("ltr"), true);
|
||||
} else if (aDirection == nsIPlaintextEditor::eEditorRightToLeft &&
|
||||
(mFlags & nsIPlaintextEditor::eEditorLeftToRight)) {
|
||||
NS_ASSERTION(!(mFlags & nsIPlaintextEditor::eEditorRightToLeft),
|
||||
"Unexpected mutually exclusive flag");
|
||||
mFlags |= nsIPlaintextEditor::eEditorRightToLeft;
|
||||
mFlags &= ~nsIPlaintextEditor::eEditorLeftToRight;
|
||||
rootElement->SetAttribute(NS_LITERAL_STRING("dir"), NS_LITERAL_STRING("rtl"));
|
||||
rootElement->SetAttr(kNameSpaceID_None, nsGkAtoms::dir, NS_LITERAL_STRING("rtl"), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -651,7 +651,7 @@ public:
|
||||
virtual already_AddRefed<nsIDOMEventTarget> GetDOMEventTarget() = 0;
|
||||
|
||||
// Fast non-refcounting editor root element accessor
|
||||
nsIDOMElement *GetRoot();
|
||||
mozilla::dom::Element *GetRoot();
|
||||
|
||||
// Accessor methods to flags
|
||||
bool IsPlaintextEditor() const
|
||||
@ -763,8 +763,8 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
PRUint32 mModCount; // number of modifications (for undo/redo stack)
|
||||
PRUint32 mFlags; // behavior flags. See nsIPlaintextEditor.idl for the flags we use.
|
||||
PRUint32 mModCount; // number of modifications (for undo/redo stack)
|
||||
PRUint32 mFlags; // behavior flags. See nsIPlaintextEditor.idl for the flags we use.
|
||||
|
||||
nsWeakPtr mSelConWeak; // weak reference to the nsISelectionController
|
||||
PRInt32 mUpdateCount;
|
||||
@ -785,7 +785,7 @@ protected:
|
||||
nsSelectionState *mSelState; // saved selection state for placeholder txn batching
|
||||
nsSelectionState mSavedSel; // cached selection for nsAutoSelectionReset
|
||||
nsRangeUpdater mRangeUpdater; // utility class object for maintaining preserved ranges
|
||||
nsCOMPtr<nsIDOMElement> mRootElement; // cached root node
|
||||
nsCOMPtr<mozilla::dom::Element> mRootElement; // cached root node
|
||||
PRInt32 mAction; // the current editor action
|
||||
EDirection mDirection; // the current direction of editor action
|
||||
|
||||
|
@ -81,6 +81,7 @@
|
||||
#include "nsIHTMLDocument.h"
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -256,7 +257,7 @@ nsHTMLEditRules::Init(nsPlaintextEditor *aEditor)
|
||||
NS_ENSURE_TRUE(mUtilRange, NS_ERROR_NULL_POINTER);
|
||||
|
||||
// set up mDocChangeRange to be whole doc
|
||||
nsIDOMElement *rootElem = mHTMLEditor->GetRoot();
|
||||
nsCOMPtr<nsIDOMElement> rootElem = do_QueryInterface(mHTMLEditor->GetRoot());
|
||||
if (rootElem)
|
||||
{
|
||||
// temporarily turn off rules sniffing
|
||||
@ -805,7 +806,7 @@ nsHTMLEditRules::GetAlignment(bool *aMixed, nsIHTMLEditor::EAlignment *aAlign)
|
||||
|
||||
// get selection location
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
nsIDOMElement *rootElem = mHTMLEditor->GetRoot();
|
||||
nsCOMPtr<nsIDOMElement> rootElem = do_QueryInterface(mHTMLEditor->GetRoot());
|
||||
NS_ENSURE_TRUE(rootElem, NS_ERROR_FAILURE);
|
||||
|
||||
PRInt32 offset, rootOffset;
|
||||
@ -1012,13 +1013,10 @@ nsHTMLEditRules::GetIndentState(bool *aCanIndent, bool *aCanOutdent)
|
||||
// in the parent hierarchy.
|
||||
|
||||
// gather up info we need for test
|
||||
nsCOMPtr<nsIDOMNode> parent, tmp, root;
|
||||
nsIDOMElement *rootElem = mHTMLEditor->GetRoot();
|
||||
NS_ENSURE_TRUE(rootElem, NS_ERROR_NULL_POINTER);
|
||||
nsCOMPtr<nsIDOMNode> parent, tmp, root = do_QueryInterface(mHTMLEditor->GetRoot());
|
||||
NS_ENSURE_TRUE(root, NS_ERROR_NULL_POINTER);
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
PRInt32 selOffset;
|
||||
root = do_QueryInterface(rootElem);
|
||||
NS_ENSURE_TRUE(root, NS_ERROR_NO_INTERFACE);
|
||||
res = mHTMLEditor->GetSelection(getter_AddRefs(selection));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
@ -1108,7 +1106,7 @@ nsHTMLEditRules::GetParagraphState(bool *aMixed, nsAString &outFormat)
|
||||
}
|
||||
|
||||
// remember root node
|
||||
nsIDOMElement *rootElem = mHTMLEditor->GetRoot();
|
||||
nsCOMPtr<nsIDOMElement> rootElem = do_QueryInterface(mHTMLEditor->GetRoot());
|
||||
NS_ENSURE_TRUE(rootElem, NS_ERROR_NULL_POINTER);
|
||||
|
||||
// loop through the nodes in selection and examine their paragraph format
|
||||
@ -7778,9 +7776,8 @@ nsHTMLEditRules::AdjustSelection(nsISelection *aSelection, nsIEditor::EDirection
|
||||
// check if br can go into the destination node
|
||||
if (bIsEmptyNode && mHTMLEditor->CanContainTag(selNode, NS_LITERAL_STRING("br")))
|
||||
{
|
||||
nsIDOMElement *rootElement = mHTMLEditor->GetRoot();
|
||||
NS_ENSURE_TRUE(rootElement, NS_ERROR_FAILURE);
|
||||
nsCOMPtr<nsIDOMNode> rootNode(do_QueryInterface(rootElement));
|
||||
nsCOMPtr<nsIDOMNode> rootNode = do_QueryInterface(mHTMLEditor->GetRoot());
|
||||
NS_ENSURE_TRUE(rootNode, NS_ERROR_FAILURE);
|
||||
if (selNode == rootNode)
|
||||
{
|
||||
// Our root node is completely empty. Don't add a <br> here.
|
||||
@ -8359,7 +8356,7 @@ nsHTMLEditRules::ConfirmSelectionInBody()
|
||||
nsresult res = NS_OK;
|
||||
|
||||
// get the body
|
||||
nsIDOMElement *rootElement = mHTMLEditor->GetRoot();
|
||||
nsCOMPtr<nsIDOMElement> rootElement = do_QueryInterface(mHTMLEditor->GetRoot());
|
||||
NS_ENSURE_TRUE(rootElement, NS_ERROR_UNEXPECTED);
|
||||
|
||||
// get the selection
|
||||
|
@ -381,28 +381,29 @@ nsHTMLEditor::GetRootElement(nsIDOMElement **aRootElement)
|
||||
// Use the HTML documents body element as the editor root if we didn't
|
||||
// get a root element during initialization.
|
||||
|
||||
nsCOMPtr<nsIDOMElement> rootElement;
|
||||
nsCOMPtr<nsIDOMHTMLElement> bodyElement;
|
||||
nsresult rv = GetBodyElement(getter_AddRefs(bodyElement));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (bodyElement) {
|
||||
mRootElement = bodyElement;
|
||||
rootElement = bodyElement;
|
||||
} else {
|
||||
// If there is no HTML body element,
|
||||
// we should use the document root element instead.
|
||||
nsCOMPtr<nsIDOMDocument> doc = do_QueryReferent(mDocWeak);
|
||||
NS_ENSURE_TRUE(doc, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
rv = doc->GetDocumentElement(getter_AddRefs(mRootElement));
|
||||
rv = doc->GetDocumentElement(getter_AddRefs(rootElement));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// Document can have no elements
|
||||
if (!mRootElement) {
|
||||
if (!rootElement) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
*aRootElement = mRootElement;
|
||||
NS_ADDREF(*aRootElement);
|
||||
mRootElement = do_QueryInterface(rootElement);
|
||||
rootElement.forget(aRootElement);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -544,7 +545,7 @@ nsHTMLEditor::BeginningOfDocument()
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
// Get the root element.
|
||||
nsIDOMElement *rootElement = GetRoot();
|
||||
nsCOMPtr<nsIDOMElement> rootElement = do_QueryInterface(GetRoot());
|
||||
if (!rootElement) {
|
||||
NS_WARNING("GetRoot() returned a null pointer (mRootElement is null)");
|
||||
return NS_OK;
|
||||
@ -1809,8 +1810,7 @@ nsHTMLEditor::RebuildDocumentFromSource(const nsAString& aSourceString)
|
||||
nsresult res = GetSelection(getter_AddRefs(selection));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
nsIDOMElement *bodyElement = GetRoot();
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
nsCOMPtr<nsIDOMElement> bodyElement = do_QueryInterface(GetRoot());
|
||||
NS_ENSURE_TRUE(bodyElement, NS_ERROR_NULL_POINTER);
|
||||
|
||||
// Find where the <body> tag starts.
|
||||
@ -2452,10 +2452,10 @@ nsHTMLEditor::GetHTMLBackgroundColorState(bool *aMixed, nsAString &aOutColor)
|
||||
}
|
||||
|
||||
// If no table or cell found, get page body
|
||||
element = GetRoot();
|
||||
NS_ENSURE_TRUE(element, NS_ERROR_NULL_POINTER);
|
||||
mozilla::dom::Element *bodyElement = GetRoot();
|
||||
NS_ENSURE_TRUE(bodyElement, NS_ERROR_NULL_POINTER);
|
||||
|
||||
return element->GetAttribute(styleName, aOutColor);
|
||||
return bodyElement->GetAttr(kNameSpaceID_None, nsGkAtoms::bgcolor, aOutColor);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -3392,7 +3392,7 @@ nsHTMLEditor::SetHTMLBackgroundColor(const nsAString& aColor)
|
||||
// If we failed to find a cell, fall through to use originally-found element
|
||||
} else {
|
||||
// No table element -- set the background color on the body tag
|
||||
element = GetRoot();
|
||||
element = do_QueryInterface(GetRoot());
|
||||
NS_ENSURE_TRUE(element, NS_ERROR_NULL_POINTER);
|
||||
}
|
||||
// Use the editor method that goes through the transaction system
|
||||
@ -3411,8 +3411,7 @@ NS_IMETHODIMP nsHTMLEditor::SetBodyAttribute(const nsAString& aAttribute, const
|
||||
NS_ASSERTION(mDocWeak, "Missing Editor DOM Document");
|
||||
|
||||
// Set the background color attribute on the body tag
|
||||
nsIDOMElement *bodyElement = GetRoot();
|
||||
|
||||
nsCOMPtr<nsIDOMElement> bodyElement = do_QueryInterface(GetRoot());
|
||||
NS_ENSURE_TRUE(bodyElement, NS_ERROR_NULL_POINTER);
|
||||
|
||||
// Use the editor method that goes through the transaction system
|
||||
@ -3880,7 +3879,7 @@ already_AddRefed<nsIDOMNode>
|
||||
nsHTMLEditor::FindUserSelectAllNode(nsIDOMNode* aNode)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> node = aNode;
|
||||
nsIDOMElement *root = GetRoot();
|
||||
nsCOMPtr<nsIDOMElement> root = do_QueryInterface(GetRoot());
|
||||
if (!nsEditorUtils::IsDescendantOf(aNode, root))
|
||||
return nsnull;
|
||||
|
||||
@ -4145,7 +4144,7 @@ nsHTMLEditor::SelectEntireDocument(nsISelection *aSelection)
|
||||
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
|
||||
|
||||
// get editor root node
|
||||
nsIDOMElement *rootElement = GetRoot();
|
||||
nsCOMPtr<nsIDOMElement> rootElement = do_QueryInterface(GetRoot());
|
||||
|
||||
// is doc empty?
|
||||
bool bDocIsEmpty;
|
||||
@ -4190,7 +4189,9 @@ nsHTMLEditor::SelectAll()
|
||||
NS_ENSURE_TRUE(selPriv, NS_ERROR_UNEXPECTED);
|
||||
rv = selPriv->SetAncestorLimiter(nsnull);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return selection->SelectAllChildren(mRootElement);
|
||||
nsCOMPtr<nsIDOMNode> rootElement = do_QueryInterface(mRootElement, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return selection->SelectAllChildren(rootElement);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> ps = GetPresShell();
|
||||
@ -4481,7 +4482,7 @@ nsHTMLEditor::CollapseAdjacentTextNodes(nsIDOMRange *aInRange)
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::SetSelectionAtDocumentStart(nsISelection *aSelection)
|
||||
{
|
||||
nsIDOMElement *rootElement = GetRoot();
|
||||
nsCOMPtr<nsIDOMElement> rootElement = do_QueryInterface(GetRoot());
|
||||
NS_ENSURE_TRUE(rootElement, NS_ERROR_NULL_POINTER);
|
||||
|
||||
return aSelection->Collapse(rootElement,0);
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "nsIContent.h"
|
||||
#include "nsHTMLEditUtils.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
||||
// Uncomment the following line if you want to disable
|
||||
// table deletion when the only column/row is removed
|
||||
@ -77,7 +78,7 @@ nsHTMLEditor::ShowInlineTableEditingUI(nsIDOMElement * aCell)
|
||||
}
|
||||
|
||||
// the resizers and the shadow will be anonymous children of the body
|
||||
nsIDOMElement *bodyElement = GetRoot();
|
||||
nsCOMPtr<nsIDOMElement> bodyElement = do_QueryInterface(GetRoot());
|
||||
NS_ENSURE_TRUE(bodyElement, NS_ERROR_NULL_POINTER);
|
||||
|
||||
CreateAnonymousElement(NS_LITERAL_STRING("a"), bodyElement,
|
||||
@ -130,10 +131,7 @@ nsHTMLEditor::HideInlineTableEditingUI()
|
||||
// UnbindFromTree.
|
||||
|
||||
// get the root content node.
|
||||
|
||||
nsIDOMElement *bodyElement = GetRoot();
|
||||
|
||||
nsCOMPtr<nsIContent> bodyContent( do_QueryInterface(bodyElement) );
|
||||
nsCOMPtr<nsIContent> bodyContent = GetRoot();
|
||||
NS_ENSURE_TRUE(bodyContent, NS_ERROR_FAILURE);
|
||||
|
||||
DeleteRefToAnonymousNode(mAddColumnBeforeButton, bodyContent, ps);
|
||||
|
@ -75,6 +75,7 @@
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsDebug.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
||||
// Drag & Drop, Clipboard
|
||||
#include "nsIClipboard.h"
|
||||
@ -571,7 +572,8 @@ nsPlaintextEditor::GetTextSelectionOffsets(nsISelection *aSelection,
|
||||
aSelection->GetFocusNode(getter_AddRefs(endNode));
|
||||
aSelection->GetFocusOffset(&endNodeOffset);
|
||||
|
||||
nsIDOMElement* rootNode = GetRoot();
|
||||
dom::Element *rootElement = GetRoot();
|
||||
nsCOMPtr<nsIDOMNode> rootNode = do_QueryInterface(rootElement);
|
||||
NS_ENSURE_TRUE(rootNode, NS_ERROR_NULL_POINTER);
|
||||
|
||||
PRInt32 startOffset = -1;
|
||||
@ -585,8 +587,7 @@ nsPlaintextEditor::GetTextSelectionOffsets(nsISelection *aSelection,
|
||||
PRInt32 nodeCount = 0; // only needed for the assertions below
|
||||
#endif
|
||||
PRUint32 totalLength = 0;
|
||||
nsCOMPtr<nsIContent> rootContent = do_QueryInterface(rootNode);
|
||||
iter->Init(rootContent);
|
||||
iter->Init(rootElement);
|
||||
for (; !iter->IsDone() && (startOffset == -1 || endOffset == -1); iter->Next()) {
|
||||
nsCOMPtr<nsIDOMNode> currentNode = do_QueryInterface(iter->GetCurrentNode());
|
||||
nsCOMPtr<nsIDOMCharacterData> textNode = do_QueryInterface(currentNode);
|
||||
@ -1020,16 +1021,15 @@ nsPlaintextEditor::GetTextLength(PRInt32 *aCount)
|
||||
if (docEmpty)
|
||||
return NS_OK;
|
||||
|
||||
nsIDOMElement* rootNode = GetRoot();
|
||||
NS_ENSURE_TRUE(rootNode, NS_ERROR_NULL_POINTER);
|
||||
dom::Element *rootElement = GetRoot();
|
||||
NS_ENSURE_TRUE(rootElement, NS_ERROR_NULL_POINTER);
|
||||
|
||||
nsCOMPtr<nsIContentIterator> iter =
|
||||
do_CreateInstance("@mozilla.org/content/post-content-iterator;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRUint32 totalLength = 0;
|
||||
nsCOMPtr<nsIContent> rootContent = do_QueryInterface(rootNode);
|
||||
iter->Init(rootContent);
|
||||
iter->Init(rootElement);
|
||||
for (; !iter->IsDone(); iter->Next()) {
|
||||
nsCOMPtr<nsIDOMNode> currentNode = do_QueryInterface(iter->GetCurrentNode());
|
||||
nsCOMPtr<nsIDOMCharacterData> textNode = do_QueryInterface(currentNode);
|
||||
@ -1104,13 +1104,12 @@ nsPlaintextEditor::SetWrapWidth(PRInt32 aWrapColumn)
|
||||
|
||||
// Ought to set a style sheet here ...
|
||||
// Probably should keep around an mPlaintextStyleSheet for this purpose.
|
||||
nsIDOMElement *rootElement = GetRoot();
|
||||
dom::Element *rootElement = GetRoot();
|
||||
NS_ENSURE_TRUE(rootElement, NS_ERROR_NULL_POINTER);
|
||||
|
||||
// Get the current style for this root element:
|
||||
NS_NAMED_LITERAL_STRING(styleName, "style");
|
||||
nsAutoString styleValue;
|
||||
nsresult res = rootElement->GetAttribute(styleName, styleValue);
|
||||
nsresult res = rootElement->GetAttr(kNameSpaceID_None, nsGkAtoms::style, styleValue);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
// We'll replace styles for these values:
|
||||
@ -1154,7 +1153,7 @@ nsPlaintextEditor::SetWrapWidth(PRInt32 aWrapColumn)
|
||||
else
|
||||
styleValue.AppendLiteral("white-space: pre;");
|
||||
|
||||
return rootElement->SetAttribute(styleName, styleValue);
|
||||
return rootElement->SetAttr(kNameSpaceID_None, nsGkAtoms::style, styleValue, true);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1354,7 +1353,7 @@ nsPlaintextEditor::GetAndInitDocEncoder(const nsAString& aFormatType,
|
||||
// in which case we set the selection to encompass the root.
|
||||
else
|
||||
{
|
||||
nsIDOMElement *rootElement = GetRoot();
|
||||
nsCOMPtr<nsIDOMElement> rootElement = do_QueryInterface(GetRoot());
|
||||
NS_ENSURE_TRUE(rootElement, NS_ERROR_FAILURE);
|
||||
if (!nsTextEditUtils::IsBody(rootElement))
|
||||
{
|
||||
@ -1684,7 +1683,7 @@ nsPlaintextEditor::SelectEntireDocument(nsISelection *aSelection)
|
||||
if (NS_SUCCEEDED(mRules->DocumentIsEmpty(&bDocIsEmpty)) && bDocIsEmpty)
|
||||
{
|
||||
// get root node
|
||||
nsIDOMElement *rootElement = GetRoot();
|
||||
nsCOMPtr<nsIDOMElement> rootElement = do_QueryInterface(GetRoot());
|
||||
NS_ENSURE_TRUE(rootElement, NS_ERROR_FAILURE);
|
||||
|
||||
// if it's empty don't select entire doc - that would select the bogus node
|
||||
|
@ -68,6 +68,7 @@
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/LookAndFeel.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -460,8 +461,7 @@ nsTextEditRules::CollapseSelectionToTrailingBRIfNeeded(nsISelection* aSelection)
|
||||
&parentOffset);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
nsIDOMElement *rootElem = mEditor->GetRoot();
|
||||
nsCOMPtr<nsIDOMNode> root = do_QueryInterface(rootElem);
|
||||
nsCOMPtr<nsIDOMNode> root = do_QueryInterface(mEditor->GetRoot());
|
||||
NS_ENSURE_TRUE(root, NS_ERROR_NULL_POINTER);
|
||||
if (parentNode != root) return NS_OK;
|
||||
|
||||
@ -949,7 +949,7 @@ nsTextEditRules::DidUndo(nsISelection *aSelection, nsresult aResult)
|
||||
}
|
||||
else
|
||||
{
|
||||
nsIDOMElement *theRoot = mEditor->GetRoot();
|
||||
nsCOMPtr<nsIDOMElement> theRoot = do_QueryInterface(mEditor->GetRoot());
|
||||
NS_ENSURE_TRUE(theRoot, NS_ERROR_FAILURE);
|
||||
nsCOMPtr<nsIDOMNode> node = mEditor->GetLeftmostChild(theRoot);
|
||||
if (node && mEditor->IsMozEditorBogusNode(node))
|
||||
@ -982,7 +982,7 @@ nsTextEditRules::DidRedo(nsISelection *aSelection, nsresult aResult)
|
||||
}
|
||||
else
|
||||
{
|
||||
nsIDOMElement *theRoot = mEditor->GetRoot();
|
||||
nsCOMPtr<nsIDOMElement> theRoot = do_QueryInterface(mEditor->GetRoot());
|
||||
NS_ENSURE_TRUE(theRoot, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDOMNodeList> nodeList;
|
||||
@ -1056,7 +1056,7 @@ nsTextEditRules::RemoveRedundantTrailingBR()
|
||||
if (IsSingleLineEditor())
|
||||
return NS_OK;
|
||||
|
||||
nsIDOMNode* body = mEditor->GetRoot();
|
||||
nsCOMPtr<nsIDOMNode> body = do_QueryInterface(mEditor->GetRoot());
|
||||
if (!body)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
@ -1111,7 +1111,7 @@ nsTextEditRules::CreateTrailingBRIfNeeded()
|
||||
// but only if we aren't a single line edit field
|
||||
if (IsSingleLineEditor())
|
||||
return NS_OK;
|
||||
nsIDOMNode *body = mEditor->GetRoot();
|
||||
nsCOMPtr<nsIDOMNode> body = do_QueryInterface(mEditor->GetRoot());
|
||||
NS_ENSURE_TRUE(body, NS_ERROR_NULL_POINTER);
|
||||
nsCOMPtr<nsIDOMNode> lastChild;
|
||||
nsresult res = body->GetLastChild(getter_AddRefs(lastChild));
|
||||
@ -1141,7 +1141,7 @@ nsTextEditRules::CreateBogusNodeIfNeeded(nsISelection *aSelection)
|
||||
// tell rules system to not do any post-processing
|
||||
nsAutoRules beginRulesSniffing(mEditor, nsEditor::kOpIgnore, nsIEditor::eNone);
|
||||
|
||||
nsIDOMNode* body = mEditor->GetRoot();
|
||||
nsCOMPtr<nsIDOMNode> body = do_QueryInterface(mEditor->GetRoot());
|
||||
if (!body)
|
||||
{
|
||||
// we don't even have a body yet, don't insert any bogus nodes at
|
||||
|
Loading…
Reference in New Issue
Block a user