зеркало из https://github.com/mozilla/gecko-dev.git
Bug 756754 - Part a: Return dom::Element* from CreateHTMLContent; r=ehsan
This commit is contained in:
Родитель
41f72448ff
Коммит
55cac76b93
|
@ -11,13 +11,14 @@
|
||||||
#include "nsIDOMElement.h"
|
#include "nsIDOMElement.h"
|
||||||
#include "nsReadableUtils.h"
|
#include "nsReadableUtils.h"
|
||||||
|
|
||||||
//included for new nsEditor::CreateContent()
|
#include "mozilla/dom/Element.h"
|
||||||
#include "nsIContent.h"
|
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
static bool gNoisy = false;
|
static bool gNoisy = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
using namespace mozilla;
|
||||||
|
|
||||||
CreateElementTxn::CreateElementTxn()
|
CreateElementTxn::CreateElementTxn()
|
||||||
: EditTxn()
|
: EditTxn()
|
||||||
{
|
{
|
||||||
|
@ -80,7 +81,7 @@ NS_IMETHODIMP CreateElementTxn::DoTransaction(void)
|
||||||
NS_ASSERTION(mEditor && mParent, "bad state");
|
NS_ASSERTION(mEditor && mParent, "bad state");
|
||||||
NS_ENSURE_TRUE(mEditor && mParent, NS_ERROR_NOT_INITIALIZED);
|
NS_ENSURE_TRUE(mEditor && mParent, NS_ERROR_NOT_INITIALIZED);
|
||||||
|
|
||||||
nsCOMPtr<nsIContent> newContent;
|
nsCOMPtr<dom::Element> newContent;
|
||||||
|
|
||||||
//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));
|
||||||
|
|
|
@ -1540,7 +1540,7 @@ nsEditor::ReplaceContainer(nsIDOMNode *inNode,
|
||||||
NS_ENSURE_SUCCESS(res, res);
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// create new container
|
// create new container
|
||||||
nsCOMPtr<nsIContent> newContent;
|
nsCOMPtr<dom::Element> newContent;
|
||||||
|
|
||||||
//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));
|
||||||
|
@ -1658,7 +1658,7 @@ nsEditor::InsertContainerAbove( nsIDOMNode *inNode,
|
||||||
NS_ENSURE_SUCCESS(res, res);
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// create new container
|
// create new container
|
||||||
nsCOMPtr<nsIContent> newContent;
|
nsCOMPtr<dom::Element> newContent;
|
||||||
|
|
||||||
//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));
|
||||||
|
@ -5034,7 +5034,7 @@ nsresult nsEditor::ClearSelection()
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsEditor::CreateHTMLContent(const nsAString& aTag, nsIContent** aContent)
|
nsEditor::CreateHTMLContent(const nsAString& aTag, dom::Element** aContent)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDocument> doc = GetDocument();
|
nsCOMPtr<nsIDocument> doc = GetDocument();
|
||||||
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
|
||||||
|
@ -5047,7 +5047,8 @@ nsEditor::CreateHTMLContent(const nsAString& aTag, nsIContent** aContent)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return doc->CreateElem(aTag, nsnull, kNameSpaceID_XHTML, aContent);
|
return doc->CreateElem(aTag, nsnull, kNameSpaceID_XHTML,
|
||||||
|
reinterpret_cast<nsIContent**>(aContent));
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
|
|
@ -201,7 +201,8 @@ public:
|
||||||
nsString& aTag - tag you want
|
nsString& aTag - tag you want
|
||||||
nsIContent** aContent - returned Content that was created with above namespace.
|
nsIContent** aContent - returned Content that was created with above namespace.
|
||||||
*/
|
*/
|
||||||
nsresult CreateHTMLContent(const nsAString& aTag, nsIContent** aContent);
|
nsresult CreateHTMLContent(const nsAString& aTag,
|
||||||
|
mozilla::dom::Element** aContent);
|
||||||
|
|
||||||
// IME event handlers
|
// IME event handlers
|
||||||
virtual nsresult BeginIMEComposition();
|
virtual nsresult BeginIMEComposition();
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#include "nsUnicharUtils.h"
|
#include "nsUnicharUtils.h"
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
|
|
||||||
|
using namespace mozilla;
|
||||||
|
|
||||||
// retrieve an integer stored into a CSS computed float value
|
// retrieve an integer stored into a CSS computed float value
|
||||||
static PRInt32 GetCSSFloatValue(nsIDOMCSSStyleDeclaration * aDecl,
|
static PRInt32 GetCSSFloatValue(nsIDOMCSSStyleDeclaration * aDecl,
|
||||||
const nsAString & aProperty)
|
const nsAString & aProperty)
|
||||||
|
@ -123,7 +125,7 @@ nsHTMLEditor::CreateAnonymousElement(const nsAString & aTag, nsIDOMNode * aPare
|
||||||
NS_ENSURE_TRUE(ps, NS_ERROR_NOT_INITIALIZED);
|
NS_ENSURE_TRUE(ps, NS_ERROR_NOT_INITIALIZED);
|
||||||
|
|
||||||
// Create a new node through the element factory
|
// Create a new node through the element factory
|
||||||
nsCOMPtr<nsIContent> newContent;
|
nsCOMPtr<dom::Element> newContent;
|
||||||
nsresult res = CreateHTMLContent(aTag, getter_AddRefs(newContent));
|
nsresult res = CreateHTMLContent(aTag, getter_AddRefs(newContent));
|
||||||
NS_ENSURE_SUCCESS(res, res);
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
|
|
|
@ -2856,7 +2856,7 @@ nsHTMLEditor::CreateElementWithDefaults(const nsAString& aTagName, nsIDOMElement
|
||||||
// go through the transaction system
|
// go through the transaction system
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMElement>newElement;
|
nsCOMPtr<nsIDOMElement>newElement;
|
||||||
nsCOMPtr<nsIContent> newContent;
|
nsCOMPtr<dom::Element> newContent;
|
||||||
nsCOMPtr<nsIDOMDocument> doc = do_QueryReferent(mDocWeak);
|
nsCOMPtr<nsIDOMDocument> doc = do_QueryReferent(mDocWeak);
|
||||||
NS_ENSURE_TRUE(doc, NS_ERROR_NOT_INITIALIZED);
|
NS_ENSURE_TRUE(doc, NS_ERROR_NOT_INITIALIZED);
|
||||||
|
|
||||||
|
|
|
@ -284,16 +284,16 @@ nsHTMLEditor::IsSimpleModifiableNode(nsIContent* aContent,
|
||||||
// "text-decoration: underline", which decomposes into four different text-*
|
// "text-decoration: underline", which decomposes into four different text-*
|
||||||
// properties. So for now, we just create a span, add the desired style, and
|
// properties. So for now, we just create a span, add the desired style, and
|
||||||
// see if it matches.
|
// see if it matches.
|
||||||
nsCOMPtr<nsIContent> newSpan;
|
nsCOMPtr<dom::Element> newSpan;
|
||||||
nsresult res = CreateHTMLContent(NS_LITERAL_STRING("span"),
|
nsresult res = CreateHTMLContent(NS_LITERAL_STRING("span"),
|
||||||
getter_AddRefs(newSpan));
|
getter_AddRefs(newSpan));
|
||||||
NS_ASSERTION(NS_SUCCEEDED(res), "CreateHTMLContent failed");
|
NS_ASSERTION(NS_SUCCEEDED(res), "CreateHTMLContent failed");
|
||||||
NS_ENSURE_SUCCESS(res, false);
|
NS_ENSURE_SUCCESS(res, false);
|
||||||
mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(newSpan->AsElement(), aProperty,
|
mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(newSpan, aProperty,
|
||||||
aAttribute, aValue,
|
aAttribute, aValue,
|
||||||
/*suppress transaction*/ true);
|
/*suppress transaction*/ true);
|
||||||
|
|
||||||
return mHTMLCSSUtils->ElementsSameStyle(newSpan->AsElement(), element);
|
return mHTMLCSSUtils->ElementsSameStyle(newSpan, element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1116,7 +1116,7 @@ nsTextEditRules::CreateBogusNodeIfNeeded(nsISelection *aSelection)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a br.
|
// Create a br.
|
||||||
nsCOMPtr<nsIContent> newContent;
|
nsCOMPtr<dom::Element> newContent;
|
||||||
nsresult rv = mEditor->CreateHTMLContent(NS_LITERAL_STRING("br"), getter_AddRefs(newContent));
|
nsresult rv = mEditor->CreateHTMLContent(NS_LITERAL_STRING("br"), getter_AddRefs(newContent));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче