diff --git a/mozilla/editor/base/nsEditor.cpp b/mozilla/editor/base/nsEditor.cpp index 32340722d91..91d6d7a6aeb 100644 --- a/mozilla/editor/base/nsEditor.cpp +++ b/mozilla/editor/base/nsEditor.cpp @@ -459,7 +459,11 @@ nsEditor::GetBodyElement(nsIDOMElement **aBodyElement) // Is above equivalent to this: nsCOMPtr bodyElement = do_QueryInterface(node); if (bodyElement) + { *aBodyElement = bodyElement; + // A "getter" method should always addref + NS_ADDREF(*aBodyElement); + } } return result; } @@ -2548,7 +2552,7 @@ nsEditor::IsNodeInline(nsIDOMNode *aNode, PRBool &aIsInline) tagAtom==nsIEditProperty::sub || tagAtom==nsIEditProperty::sup || tagAtom==nsIEditProperty::tt || - tagAtom==nsIEditProperty::u ) + tagAtom==nsIEditProperty::u ) { aIsInline = PR_TRUE; } diff --git a/mozilla/editor/base/nsEditorEventListeners.cpp b/mozilla/editor/base/nsEditorEventListeners.cpp index edc79678245..ec542457787 100644 --- a/mozilla/editor/base/nsEditorEventListeners.cpp +++ b/mozilla/editor/base/nsEditorEventListeners.cpp @@ -987,6 +987,26 @@ nsTextEditorMouseListener::MouseClick(nsIDOMEvent* aMouseEvent) nsresult nsTextEditorMouseListener::MouseDblClick(nsIDOMEvent* aMouseEvent) { + if (mEditor) + { + nsIHTMLEditor * HTMLEditor; + if (NS_SUCCEEDED(mEditor->QueryInterface(nsIHTMLEditor::GetIID(), (void**)&HTMLEditor))) + { + nsCOMPtr selectedElement; + if (NS_SUCCEEDED(HTMLEditor->GetSelectedElement("", getter_AddRefs(selectedElement))) && selectedElement) + { + nsAutoString TagName; + selectedElement->GetTagName(TagName); + TagName.ToLowerCase(); + +#if DEBUG_cmanske + char szTagName[64]; + TagName.ToCString(szTagName, 64); + printf("Single Selected element found: %s\n", szTagName); +#endif + } + } + } return NS_OK; } diff --git a/mozilla/editor/base/nsHTMLEditor.cpp b/mozilla/editor/base/nsHTMLEditor.cpp index 597bdc8ab9b..54694d4f053 100644 --- a/mozilla/editor/base/nsHTMLEditor.cpp +++ b/mozilla/editor/base/nsHTMLEditor.cpp @@ -190,6 +190,7 @@ NS_IMETHODIMP nsHTMLEditor::SetBackgroundColor(const nsString& aColor) NS_IMETHODIMP nsHTMLEditor::SetBodyAttribute(const nsString& aAttribute, const nsString& aValue) { + #ifdef ENABLE_JS_EDITOR_LOG nsAutoJSEditorLogLock logLock(mJSEditorLog); @@ -1859,6 +1860,8 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu nsAutoString TagName = aTagName; TagName.ToLowerCase(); + // Empty string indicates we should match any element tag + PRBool anyTag = (TagName == ""); //Note that this doesn't need to go through the transaction system @@ -1919,6 +1922,14 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu selectedElement->GetNodeName(domTagName); domTagName.ToLowerCase(); + if (anyTag) + { + // Get name of first selected element + selectedElement->GetTagName(TagName); + TagName.ToLowerCase(); + anyTag = PR_FALSE; + } + // The "A" tag is a pain, // used for both link(href is set) and "Named Anchor" if (TagName == "href" || (TagName == "anchor")) @@ -2138,16 +2149,20 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection) selection->ClearSelection(); } } - + PRBool isInline; + + // res = DeleteSelectionAndPrepareToCreateNode(parentSelectedNode, offsetOfNewNode); if (NS_SUCCEEDED(res)) { nsCOMPtr newNode = do_QueryInterface(aElement); - - res = InsertNode(aElement, parentSelectedNode, offsetOfNewNode); - + res = IsNodeInline(newNode, isInline); + if( NS_SUCCEEDED(res)) + { + // The simple case of an inline node + res = InsertNode(aElement, parentSelectedNode, offsetOfNewNode); + } } - return res; } diff --git a/mozilla/editor/libeditor/base/nsEditor.cpp b/mozilla/editor/libeditor/base/nsEditor.cpp index 32340722d91..91d6d7a6aeb 100644 --- a/mozilla/editor/libeditor/base/nsEditor.cpp +++ b/mozilla/editor/libeditor/base/nsEditor.cpp @@ -459,7 +459,11 @@ nsEditor::GetBodyElement(nsIDOMElement **aBodyElement) // Is above equivalent to this: nsCOMPtr bodyElement = do_QueryInterface(node); if (bodyElement) + { *aBodyElement = bodyElement; + // A "getter" method should always addref + NS_ADDREF(*aBodyElement); + } } return result; } @@ -2548,7 +2552,7 @@ nsEditor::IsNodeInline(nsIDOMNode *aNode, PRBool &aIsInline) tagAtom==nsIEditProperty::sub || tagAtom==nsIEditProperty::sup || tagAtom==nsIEditProperty::tt || - tagAtom==nsIEditProperty::u ) + tagAtom==nsIEditProperty::u ) { aIsInline = PR_TRUE; } diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp index 597bdc8ab9b..54694d4f053 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp @@ -190,6 +190,7 @@ NS_IMETHODIMP nsHTMLEditor::SetBackgroundColor(const nsString& aColor) NS_IMETHODIMP nsHTMLEditor::SetBodyAttribute(const nsString& aAttribute, const nsString& aValue) { + #ifdef ENABLE_JS_EDITOR_LOG nsAutoJSEditorLogLock logLock(mJSEditorLog); @@ -1859,6 +1860,8 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu nsAutoString TagName = aTagName; TagName.ToLowerCase(); + // Empty string indicates we should match any element tag + PRBool anyTag = (TagName == ""); //Note that this doesn't need to go through the transaction system @@ -1919,6 +1922,14 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu selectedElement->GetNodeName(domTagName); domTagName.ToLowerCase(); + if (anyTag) + { + // Get name of first selected element + selectedElement->GetTagName(TagName); + TagName.ToLowerCase(); + anyTag = PR_FALSE; + } + // The "A" tag is a pain, // used for both link(href is set) and "Named Anchor" if (TagName == "href" || (TagName == "anchor")) @@ -2138,16 +2149,20 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection) selection->ClearSelection(); } } - + PRBool isInline; + + // res = DeleteSelectionAndPrepareToCreateNode(parentSelectedNode, offsetOfNewNode); if (NS_SUCCEEDED(res)) { nsCOMPtr newNode = do_QueryInterface(aElement); - - res = InsertNode(aElement, parentSelectedNode, offsetOfNewNode); - + res = IsNodeInline(newNode, isInline); + if( NS_SUCCEEDED(res)) + { + // The simple case of an inline node + res = InsertNode(aElement, parentSelectedNode, offsetOfNewNode); + } } - return res; } diff --git a/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp b/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp index edc79678245..ec542457787 100644 --- a/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp +++ b/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp @@ -987,6 +987,26 @@ nsTextEditorMouseListener::MouseClick(nsIDOMEvent* aMouseEvent) nsresult nsTextEditorMouseListener::MouseDblClick(nsIDOMEvent* aMouseEvent) { + if (mEditor) + { + nsIHTMLEditor * HTMLEditor; + if (NS_SUCCEEDED(mEditor->QueryInterface(nsIHTMLEditor::GetIID(), (void**)&HTMLEditor))) + { + nsCOMPtr selectedElement; + if (NS_SUCCEEDED(HTMLEditor->GetSelectedElement("", getter_AddRefs(selectedElement))) && selectedElement) + { + nsAutoString TagName; + selectedElement->GetTagName(TagName); + TagName.ToLowerCase(); + +#if DEBUG_cmanske + char szTagName[64]; + TagName.ToCString(szTagName, 64); + printf("Single Selected element found: %s\n", szTagName); +#endif + } + } + } return NS_OK; } diff --git a/mozilla/editor/ui/composer/content/EditorInitPage.html b/mozilla/editor/ui/composer/content/EditorInitPage.html index e28a27802ce..d981efffdb6 100644 --- a/mozilla/editor/ui/composer/content/EditorInitPage.html +++ b/mozilla/editor/ui/composer/content/EditorInitPage.html @@ -3,13 +3,11 @@ Ender HTML Test Page - +

Here's the deal...

diff --git a/mozilla/editor/ui/dialogs/content/EdLinkProps.js b/mozilla/editor/ui/dialogs/content/EdLinkProps.js index e244c43a544..6be5d8d8c6a 100644 --- a/mozilla/editor/ui/dialogs/content/EdLinkProps.js +++ b/mozilla/editor/ui/dialogs/content/EdLinkProps.js @@ -137,7 +137,6 @@ function onOK() // Set the HREF directly on the editor document's anchor node // or on the newly-created node if insertNew is true -// dump(anchorElement + "\n"); anchorElement.setAttribute("href",dialog.hrefInput.value); // Get text to use for a new link diff --git a/mozilla/suite/debugQA/content/EditorInitPage.html b/mozilla/suite/debugQA/content/EditorInitPage.html index e28a27802ce..d981efffdb6 100644 --- a/mozilla/suite/debugQA/content/EditorInitPage.html +++ b/mozilla/suite/debugQA/content/EditorInitPage.html @@ -3,13 +3,11 @@ Ender HTML Test Page - +

Here's the deal...