diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index 3e5a24ef7f5..3658c875ad1 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -107,7 +107,6 @@ #include "nsICaret.h" #include "nsILookAndFeel.h" #include "nsWidgetsCID.h" -#include "nsIFormControl.h" #include "nsIFrameTraversal.h" #include "nsLayoutCID.h" @@ -1113,7 +1112,8 @@ nsEventStateManager :: FireContextClick ( ) nsCOMPtr tag; lastContent->GetTag ( *getter_AddRefs(tag) ); nsCOMPtr inputElm ( do_QueryInterface(lastContent) ); - nsCOMPtr formControl ( do_QueryInterface(lastContent) ); + PRBool isFormControl = + lastContent->IsContentOfType(nsIContent::eHTML_FORM_CONTROL); if ( inputElm ) { // of all input elements, only ones dealing with text are allowed to have context menus if ( tag == nsHTMLAtoms::input ) { @@ -1124,11 +1124,12 @@ nsEventStateManager :: FireContextClick ( ) allowedToDispatch = PR_FALSE; } } - else if ( formControl ) // catches combo-boxes + else if ( isFormControl && tag != nsHTMLAtoms::textarea ) + // catches combo-boxes, allowedToDispatch = PR_FALSE; else if ( tag == nsXULAtoms::scrollbar || tag == nsXULAtoms::scrollbarbutton || tag == nsXULAtoms::button ) allowedToDispatch = PR_FALSE; - else if ( tag == nsHTMLAtoms::applet || tag == nsHTMLAtoms::object || tag == nsHTMLAtoms::embed ) + else if ( tag == nsHTMLAtoms::applet || tag == nsHTMLAtoms::embed ) allowedToDispatch = PR_FALSE; else if ( tag == nsXULAtoms::toolbarbutton ) { // a that has the container attribute set will already have its @@ -4373,9 +4374,11 @@ nsresult nsEventStateManager::GetDocSelectionLocation(nsIContent **aStartContent nsAutoString nodeValue; domNode->GetNodeValue(nodeValue); - nsCOMPtr formControl(do_QueryInterface(startContent)); + PRBool isFormControl = + startContent->IsContentOfType(nsIContent::eHTML_FORM_CONTROL); - if (nodeValue.Length() == *aStartOffset && !formControl && startContent != rootContent) { + if (nodeValue.Length() == *aStartOffset && !isFormControl && + startContent != rootContent) { // Yes, indeed we were at the end of the last node nsCOMPtr frameTraversal; diff --git a/mozilla/content/html/content/public/nsIFormControl.h b/mozilla/content/html/content/public/nsIFormControl.h index 8cb1c408276..4cea6ec1e44 100644 --- a/mozilla/content/html/content/public/nsIFormControl.h +++ b/mozilla/content/html/content/public/nsIFormControl.h @@ -68,6 +68,7 @@ class nsIFormSubmission; #define NS_FORM_LEGEND 18 #define NS_FORM_SELECT 19 #define NS_FORM_TEXTAREA 20 +#define NS_FORM_OBJECT 21 #define NS_FORM_NOTOK 0xFFFFFFF7 #define NS_FORM_NOTSET 0xFFFFFFF7 diff --git a/mozilla/content/html/content/src/nsHTMLObjectElement.cpp b/mozilla/content/html/content/src/nsHTMLObjectElement.cpp index 898df0ab117..5133c9ebdd4 100644 --- a/mozilla/content/html/content/src/nsHTMLObjectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLObjectElement.cpp @@ -45,8 +45,9 @@ #include "nsIPresShell.h" #include "nsIDOMDocument.h" #include "nsIWebNavigation.h" +#include "nsIFormControl.h" -class nsHTMLObjectElement : public nsGenericHTMLContainerElement, +class nsHTMLObjectElement : public nsGenericHTMLContainerFormElement, public nsIDOMHTMLObjectElement { public: @@ -68,6 +69,16 @@ public: // nsIDOMHTMLObjectElement NS_DECL_NSIDOMHTMLOBJECTELEMENT + // Overriden nsIFormControl methods + NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm, + PRBool aRemoveFromForm = PR_TRUE); + NS_IMETHOD GetType(PRInt32* aType); + NS_IMETHOD Reset(); + NS_IMETHOD SubmitNamesValues(nsIFormSubmission* aFormSubmission, + nsIContent* aSubmitElement); + NS_IMETHOD SaveState(); + NS_IMETHOD RestoreState(nsIPresState* aState); + NS_IMETHOD StringToAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsHTMLValue& aResult); @@ -115,6 +126,8 @@ nsHTMLObjectElement::nsHTMLObjectElement() nsHTMLObjectElement::~nsHTMLObjectElement() { + // Null out form's pointer to us - no ref counting here! + SetForm(nsnull); } @@ -123,7 +136,7 @@ NS_IMPL_RELEASE_INHERITED(nsHTMLObjectElement, nsGenericElement) // QueryInterface implementation for nsHTMLObjectElement NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLObjectElement, - nsGenericHTMLContainerElement) + nsGenericHTMLContainerFormElement) NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLObjectElement) NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLObjectElement) NS_HTML_CONTENT_INTERFACE_MAP_END @@ -159,10 +172,48 @@ nsHTMLObjectElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn) NS_IMETHODIMP nsHTMLObjectElement::GetForm(nsIDOMHTMLFormElement** aForm) { - *aForm = nsnull;/* XXX */ + return nsGenericHTMLContainerFormElement::GetForm(aForm); +} + +NS_IMETHODIMP +nsHTMLObjectElement::SetForm(nsIDOMHTMLFormElement* aForm, + PRBool aRemoveFromForm) +{ + return nsGenericHTMLContainerFormElement::SetForm(aForm, aRemoveFromForm); +} + +NS_IMETHODIMP +nsHTMLObjectElement::GetType(PRInt32* aType) +{ + NS_PRECONDITION(aType, "aType must not be null!"); + *aType = NS_FORM_OBJECT; return NS_OK; } +NS_IMETHODIMP +nsHTMLObjectElement::Reset() +{ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLObjectElement::SubmitNamesValues(nsIFormSubmission* aFormSubmission, + nsIContent* aSubmitElement) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLObjectElement::SaveState() +{ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLObjectElement::RestoreState(nsIPresState* aState) +{ + return NS_OK; +} NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Code, code) NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Align, align) diff --git a/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp b/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp index 898df0ab117..5133c9ebdd4 100644 --- a/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp @@ -45,8 +45,9 @@ #include "nsIPresShell.h" #include "nsIDOMDocument.h" #include "nsIWebNavigation.h" +#include "nsIFormControl.h" -class nsHTMLObjectElement : public nsGenericHTMLContainerElement, +class nsHTMLObjectElement : public nsGenericHTMLContainerFormElement, public nsIDOMHTMLObjectElement { public: @@ -68,6 +69,16 @@ public: // nsIDOMHTMLObjectElement NS_DECL_NSIDOMHTMLOBJECTELEMENT + // Overriden nsIFormControl methods + NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm, + PRBool aRemoveFromForm = PR_TRUE); + NS_IMETHOD GetType(PRInt32* aType); + NS_IMETHOD Reset(); + NS_IMETHOD SubmitNamesValues(nsIFormSubmission* aFormSubmission, + nsIContent* aSubmitElement); + NS_IMETHOD SaveState(); + NS_IMETHOD RestoreState(nsIPresState* aState); + NS_IMETHOD StringToAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsHTMLValue& aResult); @@ -115,6 +126,8 @@ nsHTMLObjectElement::nsHTMLObjectElement() nsHTMLObjectElement::~nsHTMLObjectElement() { + // Null out form's pointer to us - no ref counting here! + SetForm(nsnull); } @@ -123,7 +136,7 @@ NS_IMPL_RELEASE_INHERITED(nsHTMLObjectElement, nsGenericElement) // QueryInterface implementation for nsHTMLObjectElement NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLObjectElement, - nsGenericHTMLContainerElement) + nsGenericHTMLContainerFormElement) NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLObjectElement) NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLObjectElement) NS_HTML_CONTENT_INTERFACE_MAP_END @@ -159,10 +172,48 @@ nsHTMLObjectElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn) NS_IMETHODIMP nsHTMLObjectElement::GetForm(nsIDOMHTMLFormElement** aForm) { - *aForm = nsnull;/* XXX */ + return nsGenericHTMLContainerFormElement::GetForm(aForm); +} + +NS_IMETHODIMP +nsHTMLObjectElement::SetForm(nsIDOMHTMLFormElement* aForm, + PRBool aRemoveFromForm) +{ + return nsGenericHTMLContainerFormElement::SetForm(aForm, aRemoveFromForm); +} + +NS_IMETHODIMP +nsHTMLObjectElement::GetType(PRInt32* aType) +{ + NS_PRECONDITION(aType, "aType must not be null!"); + *aType = NS_FORM_OBJECT; return NS_OK; } +NS_IMETHODIMP +nsHTMLObjectElement::Reset() +{ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLObjectElement::SubmitNamesValues(nsIFormSubmission* aFormSubmission, + nsIContent* aSubmitElement) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLObjectElement::SaveState() +{ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLObjectElement::RestoreState(nsIPresState* aState) +{ + return NS_OK; +} NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Code, code) NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Align, align) diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index 5623394aac2..168fa86d73f 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -1114,6 +1114,9 @@ MakeContentObject(nsHTMLTag aNodeType, break; case eHTMLTag_object: rv = NS_NewHTMLObjectElement(aResult, aNodeInfo); + if (!aInsideNoXXXTag) { + SetForm(*aResult, aForm); + } break; case eHTMLTag_ol: rv = NS_NewHTMLOListElement(aResult, aNodeInfo);