diff --git a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp new file mode 100644 index 00000000000..6ac6bd8cf94 --- /dev/null +++ b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp @@ -0,0 +1,275 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ +#include "nsIDOMHTMLButtonElement.h" +#include "nsIScriptObjectOwner.h" +#include "nsIDOMEventReceiver.h" +#include "nsIHTMLContent.h" +#include "nsGenericHTMLElement.h" +#include "nsHTMLAtoms.h" +#include "nsHTMLIIDs.h" +#include "nsIStyleContext.h" +#include "nsStyleConsts.h" +#include "nsIPresContext.h" + +#include "nsIEventStateManager.h" +#include "nsDOMEvent.h" + +static NS_DEFINE_IID(kIDOMHTMLButtonElementIID, NS_IDOMHTMLBUTTONELEMENT_IID); + +class nsHTMLButtonElement : public nsIDOMHTMLButtonElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLButtonElement(nsIAtom* aTag); + ~nsHTMLButtonElement(); + + // nsISupports + NS_DECL_ISUPPORTS + + // nsIDOMNode + NS_IMPL_IDOMNODE_USING_GENERIC(mInner) + + // nsIDOMElement + NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLElement + NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLButtonElement + NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm); + NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm); + NS_IMETHOD GetAccessKey(nsString& aAccessKey); + NS_IMETHOD SetAccessKey(const nsString& aAccessKey); + NS_IMETHOD GetDisabled(PRBool* aDisabled); + NS_IMETHOD SetDisabled(PRBool aDisabled); + NS_IMETHOD GetName(nsString& aName); + NS_IMETHOD SetName(const nsString& aName); + NS_IMETHOD GetTabIndex(PRInt32* aTabIndex); + NS_IMETHOD SetTabIndex(PRInt32 aTabIndex); + NS_IMETHOD GetType(nsString& aType); + NS_IMETHOD SetType(const nsString& aType); + NS_IMETHOD GetValue(nsString& aValue); + NS_IMETHOD SetValue(const nsString& aValue); + + // nsIScriptObjectOwner + NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner) + + // nsIDOMEventReceiver + NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner) + + // nsIContent + NS_IMPL_ICONTENT_USING_GENERIC(mInner) + + // nsIHTMLContent + NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner) + +protected: + nsHTMLGenericContainerContent mInner; +}; + +nsresult +NS_NewHTMLButtonElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLButtonElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLButtonElement::nsHTMLButtonElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLButtonElement::~nsHTMLButtonElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLButtonElement) + +NS_IMPL_RELEASE(nsHTMLButtonElement) + +nsresult +nsHTMLButtonElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLButtonElementIID)) { + nsIDOMHTMLButtonElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLButtonElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLButtonElement* it = new nsHTMLButtonElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMETHODIMP +nsHTMLButtonElement::GetForm(nsIDOMHTMLFormElement** aForm) +{ + *aForm = nsnull;/* XXX */ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLButtonElement::SetForm(nsIDOMHTMLFormElement* aForm) +{ + return NS_OK; +} + +NS_IMPL_STRING_ATTR(nsHTMLButtonElement, AccessKey, accesskey, eSetAttrNotify_None) +NS_IMPL_BOOL_ATTR(nsHTMLButtonElement, Disabled, disabled, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLButtonElement, Name, name, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLButtonElement, Type, type, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLButtonElement, Value, value, eSetAttrNotify_Render) + +NS_IMETHODIMP +nsHTMLButtonElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + if (aAttribute == nsHTMLAtoms::tabindex) { + nsHTMLGenericContent::ParseValue(aValue, 0, 32767, aResult, + eHTMLUnit_Integer); + return NS_CONTENT_ATTR_HAS_VALUE; + } + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLButtonElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLButtonElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLButtonElement::HandleDOMEvent(nsIPresContext& aPresContext, + nsEvent* aEvent, + nsIDOMEvent** aDOMEvent, + PRUint32 aFlags, + nsEventStatus& aEventStatus) +{ + // Try script event handlers first + nsresult ret = mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent, + aFlags, aEventStatus); + + if ((NS_OK == ret) && (nsEventStatus_eIgnore == aEventStatus)) { + switch (aEvent->message) { + case NS_MOUSE_LEFT_BUTTON_DOWN: + { + nsIEventStateManager *stateManager; + if (NS_OK == aPresContext.GetEventStateManager(&stateManager)) { + stateManager->SetActiveLink(this); + NS_RELEASE(stateManager); + } + aEventStatus = nsEventStatus_eConsumeNoDefault; + } + break; + + case NS_MOUSE_LEFT_BUTTON_UP: + { + nsIEventStateManager *stateManager; + nsIContent *activeLink; + if (NS_OK == aPresContext.GetEventStateManager(&stateManager)) { + stateManager->GetActiveLink(&activeLink); + NS_RELEASE(stateManager); + } + + if (activeLink == this) { + nsEventStatus status; + nsMouseEvent event; + event.eventStructType = NS_MOUSE_EVENT; + event.message = NS_MOUSE_LEFT_CLICK; + HandleDOMEvent(aPresContext, &event, nsnull, DOM_EVENT_INIT, status); + + if (nsEventStatus_eConsumeNoDefault != status) { + nsAutoString base, href, target; + GetAttribute(nsString(NS_HTML_BASE_HREF), base); + GetAttribute(nsString("href"), href); + GetAttribute(nsString("target"), target); + if (target.Length() == 0) { + GetAttribute(nsString(NS_HTML_BASE_TARGET), target); + } + mInner.TriggerLink(aPresContext, base, href, target, PR_TRUE); + aEventStatus = nsEventStatus_eConsumeNoDefault; + } + } + } + break; + + case NS_MOUSE_RIGHT_BUTTON_DOWN: + // XXX Bring up a contextual menu provided by the application + break; + + case NS_MOUSE_ENTER: + //mouse enter doesn't work yet. Use move until then. + { + nsAutoString base, href, target; + GetAttribute(nsString(NS_HTML_BASE_HREF), base); + GetAttribute(nsString("href"), href); + GetAttribute(nsString("target"), target); + if (target.Length() == 0) { + GetAttribute(nsString(NS_HTML_BASE_TARGET), target); + } + mInner.TriggerLink(aPresContext, base, href, target, PR_FALSE); + aEventStatus = nsEventStatus_eConsumeDoDefault; + } + break; + + // XXX this doesn't seem to do anything yet + case NS_MOUSE_EXIT: + { + nsAutoString empty; + mInner.TriggerLink(aPresContext, empty, empty, empty, PR_FALSE); + aEventStatus = nsEventStatus_eConsumeDoDefault; + } + break; + + default: + break; + } + } + return ret; +} diff --git a/mozilla/content/html/content/src/nsHTMLFrameElement.cpp b/mozilla/content/html/content/src/nsHTMLFrameElement.cpp new file mode 100644 index 00000000000..c6947dafc7c --- /dev/null +++ b/mozilla/content/html/content/src/nsHTMLFrameElement.cpp @@ -0,0 +1,183 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ +#include "nsIDOMHTMLFrameElement.h" +#include "nsIScriptObjectOwner.h" +#include "nsIDOMEventReceiver.h" +#include "nsIHTMLContent.h" +#include "nsGenericHTMLElement.h" +#include "nsHTMLAtoms.h" +#include "nsHTMLIIDs.h" +#include "nsIStyleContext.h" +#include "nsStyleConsts.h" +#include "nsIPresContext.h" + +static NS_DEFINE_IID(kIDOMHTMLFrameElementIID, NS_IDOMHTMLFRAMEELEMENT_IID); + +class nsHTMLFrameElement : public nsIDOMHTMLFrameElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLFrameElement(nsIAtom* aTag); + ~nsHTMLFrameElement(); + + // nsISupports + NS_DECL_ISUPPORTS + + // nsIDOMNode + NS_IMPL_IDOMNODE_USING_GENERIC(mInner) + + // nsIDOMElement + NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLElement + NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLFrameElement + NS_IMETHOD GetFrameBorder(nsString& aFrameBorder); + NS_IMETHOD SetFrameBorder(const nsString& aFrameBorder); + NS_IMETHOD GetLongDesc(nsString& aLongDesc); + NS_IMETHOD SetLongDesc(const nsString& aLongDesc); + NS_IMETHOD GetMarginHeight(nsString& aMarginHeight); + NS_IMETHOD SetMarginHeight(const nsString& aMarginHeight); + NS_IMETHOD GetMarginWidth(nsString& aMarginWidth); + NS_IMETHOD SetMarginWidth(const nsString& aMarginWidth); + NS_IMETHOD GetName(nsString& aName); + NS_IMETHOD SetName(const nsString& aName); + NS_IMETHOD GetNoResize(PRBool* aNoResize); + NS_IMETHOD SetNoResize(PRBool aNoResize); + NS_IMETHOD GetScrolling(nsString& aScrolling); + NS_IMETHOD SetScrolling(const nsString& aScrolling); + NS_IMETHOD GetSrc(nsString& aSrc); + NS_IMETHOD SetSrc(const nsString& aSrc); + + // nsIScriptObjectOwner + NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner) + + // nsIDOMEventReceiver + NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner) + + // nsIContent + NS_IMPL_ICONTENT_USING_GENERIC(mInner) + + // nsIHTMLContent + NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner) + +protected: + nsHTMLGenericLeafContent mInner; +}; + +nsresult +NS_NewHTMLFrameElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLFrameElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLFrameElement::nsHTMLFrameElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLFrameElement::~nsHTMLFrameElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLFrameElement) + +NS_IMPL_RELEASE(nsHTMLFrameElement) + +nsresult +nsHTMLFrameElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLFrameElementIID)) { + nsIDOMHTMLFrameElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLFrameElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLFrameElement* it = new nsHTMLFrameElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMPL_STRING_ATTR(nsHTMLFrameElement, FrameBorder, frameborder, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLFrameElement, LongDesc, longdesc, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLFrameElement, MarginHeight, marginheight, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLFrameElement, MarginWidth, marginwidth, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLFrameElement, Name, name, eSetAttrNotify_Restart) +NS_IMPL_BOOL_ATTR(nsHTMLFrameElement, NoResize, noresize, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLFrameElement, Scrolling, scrolling, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLFrameElement, Src, src, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLFrameElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLFrameElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLFrameElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLFrameElement::HandleDOMEvent(nsIPresContext& aPresContext, + nsEvent* aEvent, + nsIDOMEvent** aDOMEvent, + PRUint32 aFlags, + nsEventStatus& aEventStatus) +{ + return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent, + aFlags, aEventStatus); +} diff --git a/mozilla/content/html/content/src/nsHTMLFrameSetElement.cpp b/mozilla/content/html/content/src/nsHTMLFrameSetElement.cpp new file mode 100644 index 00000000000..9eb22def7d4 --- /dev/null +++ b/mozilla/content/html/content/src/nsHTMLFrameSetElement.cpp @@ -0,0 +1,165 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ +#include "nsIDOMHTMLFrameSetElement.h" +#include "nsIScriptObjectOwner.h" +#include "nsIDOMEventReceiver.h" +#include "nsIHTMLContent.h" +#include "nsGenericHTMLElement.h" +#include "nsHTMLAtoms.h" +#include "nsHTMLIIDs.h" +#include "nsIStyleContext.h" +#include "nsStyleConsts.h" +#include "nsIPresContext.h" + +static NS_DEFINE_IID(kIDOMHTMLFrameSetElementIID, NS_IDOMHTMLFRAMESETELEMENT_IID); + +class nsHTMLFrameSetElement : public nsIDOMHTMLFrameSetElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLFrameSetElement(nsIAtom* aTag); + ~nsHTMLFrameSetElement(); + + // nsISupports + NS_DECL_ISUPPORTS + + // nsIDOMNode + NS_IMPL_IDOMNODE_USING_GENERIC(mInner) + + // nsIDOMElement + NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLElement + NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLFrameSetElement + NS_IMETHOD GetCols(nsString& aCols); + NS_IMETHOD SetCols(const nsString& aCols); + NS_IMETHOD GetRows(nsString& aRows); + NS_IMETHOD SetRows(const nsString& aRows); + + // nsIScriptObjectOwner + NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner) + + // nsIDOMEventReceiver + NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner) + + // nsIContent + NS_IMPL_ICONTENT_USING_GENERIC(mInner) + + // nsIHTMLContent + NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner) + +protected: + nsHTMLGenericContainerContent mInner; +}; + +nsresult +NS_NewHTMLFrameSetElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLFrameSetElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLFrameSetElement::nsHTMLFrameSetElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLFrameSetElement::~nsHTMLFrameSetElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLFrameSetElement) + +NS_IMPL_RELEASE(nsHTMLFrameSetElement) + +nsresult +nsHTMLFrameSetElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLFrameSetElementIID)) { + nsIDOMHTMLFrameSetElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLFrameSetElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLFrameSetElement* it = new nsHTMLFrameSetElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMPL_STRING_ATTR(nsHTMLFrameSetElement, Cols, cols, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLFrameSetElement, Rows, rows, eSetAttrNotify_Restart) + +NS_IMETHODIMP +nsHTMLFrameSetElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLFrameSetElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLFrameSetElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLFrameSetElement::HandleDOMEvent(nsIPresContext& aPresContext, + nsEvent* aEvent, + nsIDOMEvent** aDOMEvent, + PRUint32 aFlags, + nsEventStatus& aEventStatus) +{ + return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent, + aFlags, aEventStatus); +} diff --git a/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp b/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp new file mode 100644 index 00000000000..6306b11c837 --- /dev/null +++ b/mozilla/content/html/content/src/nsHTMLIFrameElement.cpp @@ -0,0 +1,189 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ +#include "nsIDOMHTMLIFrameElement.h" +#include "nsIScriptObjectOwner.h" +#include "nsIDOMEventReceiver.h" +#include "nsIHTMLContent.h" +#include "nsGenericHTMLElement.h" +#include "nsHTMLAtoms.h" +#include "nsHTMLIIDs.h" +#include "nsIStyleContext.h" +#include "nsStyleConsts.h" +#include "nsIPresContext.h" + +static NS_DEFINE_IID(kIDOMHTMLIFrameElementIID, NS_IDOMHTMLIFRAMEELEMENT_IID); + +class nsHTMLIFrameElement : public nsIDOMHTMLIFrameElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLIFrameElement(nsIAtom* aTag); + ~nsHTMLIFrameElement(); + + // nsISupports + NS_DECL_ISUPPORTS + + // nsIDOMNode + NS_IMPL_IDOMNODE_USING_GENERIC(mInner) + + // nsIDOMElement + NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLElement + NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLIFrameElement + NS_IMETHOD GetAlign(nsString& aAlign); + NS_IMETHOD SetAlign(const nsString& aAlign); + NS_IMETHOD GetFrameBorder(nsString& aFrameBorder); + NS_IMETHOD SetFrameBorder(const nsString& aFrameBorder); + NS_IMETHOD GetHeight(nsString& aHeight); + NS_IMETHOD SetHeight(const nsString& aHeight); + NS_IMETHOD GetLongDesc(nsString& aLongDesc); + NS_IMETHOD SetLongDesc(const nsString& aLongDesc); + NS_IMETHOD GetMarginHeight(nsString& aMarginHeight); + NS_IMETHOD SetMarginHeight(const nsString& aMarginHeight); + NS_IMETHOD GetMarginWidth(nsString& aMarginWidth); + NS_IMETHOD SetMarginWidth(const nsString& aMarginWidth); + NS_IMETHOD GetName(nsString& aName); + NS_IMETHOD SetName(const nsString& aName); + NS_IMETHOD GetScrolling(nsString& aScrolling); + NS_IMETHOD SetScrolling(const nsString& aScrolling); + NS_IMETHOD GetSrc(nsString& aSrc); + NS_IMETHOD SetSrc(const nsString& aSrc); + NS_IMETHOD GetWidth(nsString& aWidth); + NS_IMETHOD SetWidth(const nsString& aWidth); + + // nsIScriptObjectOwner + NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner) + + // nsIDOMEventReceiver + NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner) + + // nsIContent + NS_IMPL_ICONTENT_USING_GENERIC(mInner) + + // nsIHTMLContent + NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner) + +protected: + nsHTMLGenericContainerContent mInner; +}; + +nsresult +NS_NewHTMLIFrameElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLIFrameElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLIFrameElement::nsHTMLIFrameElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLIFrameElement::~nsHTMLIFrameElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLIFrameElement) + +NS_IMPL_RELEASE(nsHTMLIFrameElement) + +nsresult +nsHTMLIFrameElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLIFrameElementIID)) { + nsIDOMHTMLIFrameElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLIFrameElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLIFrameElement* it = new nsHTMLIFrameElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, FrameBorder, frameborder, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Height, height, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, LongDesc, longdesc, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, MarginHeight, marginheight, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, MarginWidth, marginwidth, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Name, name, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Scrolling, scrolling, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Src, src, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Width, width, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLIFrameElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLIFrameElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLIFrameElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLIFrameElement::HandleDOMEvent(nsIPresContext& aPresContext, + nsEvent* aEvent, + nsIDOMEvent** aDOMEvent, + PRUint32 aFlags, + nsEventStatus& aEventStatus) +{ + return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent, + aFlags, aEventStatus); +} diff --git a/mozilla/content/html/content/src/nsHTMLImageElement.cpp b/mozilla/content/html/content/src/nsHTMLImageElement.cpp new file mode 100644 index 00000000000..e0b60a3bb6f --- /dev/null +++ b/mozilla/content/html/content/src/nsHTMLImageElement.cpp @@ -0,0 +1,217 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ +#include "nsIDOMHTMLImageElement.h" +#include "nsIScriptObjectOwner.h" +#include "nsIDOMEventReceiver.h" +#include "nsIHTMLContent.h" +#include "nsGenericHTMLElement.h" +#include "nsHTMLAtoms.h" +#include "nsHTMLIIDs.h" +#include "nsIStyleContext.h" +#include "nsStyleConsts.h" +#include "nsIPresContext.h" + +static NS_DEFINE_IID(kIDOMHTMLImageElementIID, NS_IDOMHTMLIMAGEELEMENT_IID); + +class nsHTMLImageElement : public nsIDOMHTMLImageElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLImageElement(nsIAtom* aTag); + ~nsHTMLImageElement(); + + // nsISupports + NS_DECL_ISUPPORTS + + // nsIDOMNode + NS_IMPL_IDOMNODE_USING_GENERIC(mInner) + + // nsIDOMElement + NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLElement + NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLImageElement + NS_IMETHOD GetLowSrc(nsString& aLowSrc); + NS_IMETHOD SetLowSrc(const nsString& aLowSrc); + NS_IMETHOD GetName(nsString& aName); + NS_IMETHOD SetName(const nsString& aName); + NS_IMETHOD GetAlign(nsString& aAlign); + NS_IMETHOD SetAlign(const nsString& aAlign); + NS_IMETHOD GetAlt(nsString& aAlt); + NS_IMETHOD SetAlt(const nsString& aAlt); + NS_IMETHOD GetBorder(nsString& aBorder); + NS_IMETHOD SetBorder(const nsString& aBorder); + NS_IMETHOD GetHeight(nsString& aHeight); + NS_IMETHOD SetHeight(const nsString& aHeight); + NS_IMETHOD GetHspace(nsString& aHspace); + NS_IMETHOD SetHspace(const nsString& aHspace); + NS_IMETHOD GetIsMap(PRBool* aIsMap); + NS_IMETHOD SetIsMap(PRBool aIsMap); + NS_IMETHOD GetLongDesc(nsString& aLongDesc); + NS_IMETHOD SetLongDesc(const nsString& aLongDesc); + NS_IMETHOD GetSrc(nsString& aSrc); + NS_IMETHOD SetSrc(const nsString& aSrc); + NS_IMETHOD GetUseMap(nsString& aUseMap); + NS_IMETHOD SetUseMap(const nsString& aUseMap); + NS_IMETHOD GetVspace(nsString& aVspace); + NS_IMETHOD SetVspace(const nsString& aVspace); + NS_IMETHOD GetWidth(nsString& aWidth); + NS_IMETHOD SetWidth(const nsString& aWidth); + + // nsIScriptObjectOwner + NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner) + + // nsIDOMEventReceiver + NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner) + + // nsIContent + NS_IMPL_ICONTENT_USING_GENERIC(mInner) + + // nsIHTMLContent + NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner) + +protected: + nsHTMLGenericContainerContent mInner; +}; + +nsresult +NS_NewHTMLImageElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLImageElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLImageElement::nsHTMLImageElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLImageElement::~nsHTMLImageElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLImageElement) + +NS_IMPL_RELEASE(nsHTMLImageElement) + +nsresult +nsHTMLImageElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLImageElementIID)) { + nsIDOMHTMLImageElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLImageElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLImageElement* it = new nsHTMLImageElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMPL_STRING_ATTR(nsHTMLImageElement, LowSrc, lowsrc, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLImageElement, Name, name, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLImageElement, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLImageElement, Alt, alt, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLImageElement, Border, border, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLImageElement, Height, height, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLImageElement, Hspace, hspace, eSetAttrNotify_Reflow) +NS_IMPL_BOOL_ATTR(nsHTMLImageElement, IsMap, ismap, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLImageElement, LongDesc, longdesc, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLImageElement, Src, src, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLImageElement, UseMap, usemap, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLImageElement, Vspace, vspace, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLImageElement, Width, width, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLImageElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + if (aAttribute == nsHTMLAtoms::align) { + if (nsHTMLGenericContent::ParseAlignValue(aValue, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } + } + else if (nsHTMLGenericContent::ParseImageAttribute(aAttribute, + aValue, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLImageElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + if (aAttribute == nsHTMLAtoms::align) { + if (eHTMLUnit_Enumerated == aValue.GetUnit()) { + nsHTMLGenericContent::AlignValueToString(aValue, aResult); + return NS_CONTENT_ATTR_HAS_VALUE; + } + } + else if (nsHTMLGenericContent::ImageAttributeToString(aAttribute, + aValue, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLImageElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + mInner.MapImageAlignAttributeInto(aContext, aPresContext); + mInner.MapImageAttributesInto(aContext, aPresContext); + mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull); + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImageElement::HandleDOMEvent(nsIPresContext& aPresContext, + nsEvent* aEvent, + nsIDOMEvent** aDOMEvent, + PRUint32 aFlags, + nsEventStatus& aEventStatus) +{ + return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent, + aFlags, aEventStatus); +} diff --git a/mozilla/content/html/content/src/nsHTMLIsIndexElement.cpp b/mozilla/content/html/content/src/nsHTMLIsIndexElement.cpp new file mode 100644 index 00000000000..3ed14aff59d --- /dev/null +++ b/mozilla/content/html/content/src/nsHTMLIsIndexElement.cpp @@ -0,0 +1,177 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ +#include "nsIDOMHTMLIsIndexElement.h" +#include "nsIScriptObjectOwner.h" +#include "nsIDOMEventReceiver.h" +#include "nsIHTMLContent.h" +#include "nsGenericHTMLElement.h" +#include "nsHTMLAtoms.h" +#include "nsHTMLIIDs.h" +#include "nsIStyleContext.h" +#include "nsStyleConsts.h" +#include "nsIPresContext.h" + +static NS_DEFINE_IID(kIDOMHTMLIsIndexElementIID, NS_IDOMHTMLISINDEXELEMENT_IID); + +class nsHTMLIsIndexElement : public nsIDOMHTMLIsIndexElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLIsIndexElement(nsIAtom* aTag); + ~nsHTMLIsIndexElement(); + + // nsISupports + NS_DECL_ISUPPORTS + + // nsIDOMNode + NS_IMPL_IDOMNODE_USING_GENERIC(mInner) + + // nsIDOMElement + NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLElement + NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLIsIndexElement + NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm); + NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm); + NS_IMETHOD GetPrompt(nsString& aPrompt); + NS_IMETHOD SetPrompt(const nsString& aPrompt); + + // nsIScriptObjectOwner + NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner) + + // nsIDOMEventReceiver + NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner) + + // nsIContent + NS_IMPL_ICONTENT_USING_GENERIC(mInner) + + // nsIHTMLContent + NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner) + +protected: + nsHTMLGenericContainerContent mInner; +}; + +nsresult +NS_NewHTMLIsIndexElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLIsIndexElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLIsIndexElement::nsHTMLIsIndexElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLIsIndexElement::~nsHTMLIsIndexElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLIsIndexElement) + +NS_IMPL_RELEASE(nsHTMLIsIndexElement) + +nsresult +nsHTMLIsIndexElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLIsIndexElementIID)) { + nsIDOMHTMLIsIndexElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLIsIndexElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLIsIndexElement* it = new nsHTMLIsIndexElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMETHODIMP +nsHTMLIsIndexElement::GetForm(nsIDOMHTMLFormElement** aForm) +{ + *aForm = nsnull;/* XXX */ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLIsIndexElement::SetForm(nsIDOMHTMLFormElement* aForm) +{ + return NS_OK; +} + +NS_IMPL_STRING_ATTR(nsHTMLIsIndexElement, Prompt, prompt, eSetAttrNotify_Restart) + +NS_IMETHODIMP +nsHTMLIsIndexElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLIsIndexElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLIsIndexElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLIsIndexElement::HandleDOMEvent(nsIPresContext& aPresContext, + nsEvent* aEvent, + nsIDOMEvent** aDOMEvent, + PRUint32 aFlags, + nsEventStatus& aEventStatus) +{ + return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent, + aFlags, aEventStatus); +} diff --git a/mozilla/content/html/content/src/nsHTMLLabelElement.cpp b/mozilla/content/html/content/src/nsHTMLLabelElement.cpp new file mode 100644 index 00000000000..9404513c32d --- /dev/null +++ b/mozilla/content/html/content/src/nsHTMLLabelElement.cpp @@ -0,0 +1,180 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ +#include "nsIDOMHTMLLabelElement.h" +#include "nsIScriptObjectOwner.h" +#include "nsIDOMEventReceiver.h" +#include "nsIHTMLContent.h" +#include "nsGenericHTMLElement.h" +#include "nsHTMLAtoms.h" +#include "nsHTMLIIDs.h" +#include "nsIStyleContext.h" +#include "nsStyleConsts.h" +#include "nsIPresContext.h" + +static NS_DEFINE_IID(kIDOMHTMLLabelElementIID, NS_IDOMHTMLLABELELEMENT_IID); + +class nsHTMLLabelElement : public nsIDOMHTMLLabelElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLLabelElement(nsIAtom* aTag); + ~nsHTMLLabelElement(); + + // nsISupports + NS_DECL_ISUPPORTS + + // nsIDOMNode + NS_IMPL_IDOMNODE_USING_GENERIC(mInner) + + // nsIDOMElement + NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLElement + NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLLabelElement + NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm); + NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm); + NS_IMETHOD GetAccessKey(nsString& aAccessKey); + NS_IMETHOD SetAccessKey(const nsString& aAccessKey); + NS_IMETHOD GetHtmlFor(nsString& aHtmlFor); + NS_IMETHOD SetHtmlFor(const nsString& aHtmlFor); + + // nsIScriptObjectOwner + NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner) + + // nsIDOMEventReceiver + NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner) + + // nsIContent + NS_IMPL_ICONTENT_USING_GENERIC(mInner) + + // nsIHTMLContent + NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner) + +protected: + nsHTMLGenericContainerContent mInner; +}; + +nsresult +NS_NewHTMLLabelElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLLabelElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLLabelElement::nsHTMLLabelElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLLabelElement::~nsHTMLLabelElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLLabelElement) + +NS_IMPL_RELEASE(nsHTMLLabelElement) + +nsresult +nsHTMLLabelElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLLabelElementIID)) { + nsIDOMHTMLLabelElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLLabelElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLLabelElement* it = new nsHTMLLabelElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMETHODIMP +nsHTMLLabelElement::GetForm(nsIDOMHTMLFormElement** aForm) +{ + *aForm = nsnull;/* XXX */ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLLabelElement::SetForm(nsIDOMHTMLFormElement* aForm) +{ + return NS_OK; +} + +NS_IMPL_STRING_ATTR(nsHTMLLabelElement, AccessKey, accesskey, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLLabelElement, HtmlFor, _for, eSetAttrNotify_None) + +NS_IMETHODIMP +nsHTMLLabelElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLLabelElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLLabelElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLLabelElement::HandleDOMEvent(nsIPresContext& aPresContext, + nsEvent* aEvent, + nsIDOMEvent** aDOMEvent, + PRUint32 aFlags, + nsEventStatus& aEventStatus) +{ + return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent, + aFlags, aEventStatus); +} diff --git a/mozilla/content/html/content/src/nsHTMLLegendElement.cpp b/mozilla/content/html/content/src/nsHTMLLegendElement.cpp new file mode 100644 index 00000000000..1313ee788db --- /dev/null +++ b/mozilla/content/html/content/src/nsHTMLLegendElement.cpp @@ -0,0 +1,180 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ +#include "nsIDOMHTMLLegendElement.h" +#include "nsIScriptObjectOwner.h" +#include "nsIDOMEventReceiver.h" +#include "nsIHTMLContent.h" +#include "nsGenericHTMLElement.h" +#include "nsHTMLAtoms.h" +#include "nsHTMLIIDs.h" +#include "nsIStyleContext.h" +#include "nsStyleConsts.h" +#include "nsIPresContext.h" + +static NS_DEFINE_IID(kIDOMHTMLLegendElementIID, NS_IDOMHTMLLEGENDELEMENT_IID); + +class nsHTMLLegendElement : public nsIDOMHTMLLegendElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLLegendElement(nsIAtom* aTag); + ~nsHTMLLegendElement(); + + // nsISupports + NS_DECL_ISUPPORTS + + // nsIDOMNode + NS_IMPL_IDOMNODE_USING_GENERIC(mInner) + + // nsIDOMElement + NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLElement + NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLLegendElement + NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm); + NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm); + NS_IMETHOD GetAccessKey(nsString& aAccessKey); + NS_IMETHOD SetAccessKey(const nsString& aAccessKey); + NS_IMETHOD GetAlign(nsString& aAlign); + NS_IMETHOD SetAlign(const nsString& aAlign); + + // nsIScriptObjectOwner + NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner) + + // nsIDOMEventReceiver + NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner) + + // nsIContent + NS_IMPL_ICONTENT_USING_GENERIC(mInner) + + // nsIHTMLContent + NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner) + +protected: + nsHTMLGenericContainerContent mInner; +}; + +nsresult +NS_NewHTMLLegendElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLLegendElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLLegendElement::nsHTMLLegendElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLLegendElement::~nsHTMLLegendElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLLegendElement) + +NS_IMPL_RELEASE(nsHTMLLegendElement) + +nsresult +nsHTMLLegendElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLLegendElementIID)) { + nsIDOMHTMLLegendElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLLegendElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLLegendElement* it = new nsHTMLLegendElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMETHODIMP +nsHTMLLegendElement::GetForm(nsIDOMHTMLFormElement** aForm) +{ + *aForm = nsnull;/* XXX */ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLLegendElement::SetForm(nsIDOMHTMLFormElement* aForm) +{ + return NS_OK; +} + +NS_IMPL_STRING_ATTR(nsHTMLLegendElement, AccessKey, accesskey, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLLegendElement, Align, align, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLLegendElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLLegendElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLLegendElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLLegendElement::HandleDOMEvent(nsIPresContext& aPresContext, + nsEvent* aEvent, + nsIDOMEvent** aDOMEvent, + PRUint32 aFlags, + nsEventStatus& aEventStatus) +{ + return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent, + aFlags, aEventStatus); +} diff --git a/mozilla/content/html/content/src/nsHTMLOptGroupElement.cpp b/mozilla/content/html/content/src/nsHTMLOptGroupElement.cpp new file mode 100644 index 00000000000..2bc599fcd92 --- /dev/null +++ b/mozilla/content/html/content/src/nsHTMLOptGroupElement.cpp @@ -0,0 +1,165 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ +#include "nsIDOMHTMLOptGroupElement.h" +#include "nsIScriptObjectOwner.h" +#include "nsIDOMEventReceiver.h" +#include "nsIHTMLContent.h" +#include "nsGenericHTMLElement.h" +#include "nsHTMLAtoms.h" +#include "nsHTMLIIDs.h" +#include "nsIStyleContext.h" +#include "nsStyleConsts.h" +#include "nsIPresContext.h" + +static NS_DEFINE_IID(kIDOMHTMLOptGroupElementIID, NS_IDOMHTMLOPTGROUPELEMENT_IID); + +class nsHTMLOptGroupElement : public nsIDOMHTMLOptGroupElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLOptGroupElement(nsIAtom* aTag); + ~nsHTMLOptGroupElement(); + + // nsISupports + NS_DECL_ISUPPORTS + + // nsIDOMNode + NS_IMPL_IDOMNODE_USING_GENERIC(mInner) + + // nsIDOMElement + NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLElement + NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLOptGroupElement + NS_IMETHOD GetDisabled(PRBool* aDisabled); + NS_IMETHOD SetDisabled(PRBool aDisabled); + NS_IMETHOD GetLabel(nsString& aLabel); + NS_IMETHOD SetLabel(const nsString& aLabel); + + // nsIScriptObjectOwner + NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner) + + // nsIDOMEventReceiver + NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner) + + // nsIContent + NS_IMPL_ICONTENT_USING_GENERIC(mInner) + + // nsIHTMLContent + NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner) + +protected: + nsHTMLGenericContainerContent mInner; +}; + +nsresult +NS_NewHTMLOptGroupElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLOptGroupElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLOptGroupElement::nsHTMLOptGroupElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLOptGroupElement::~nsHTMLOptGroupElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLOptGroupElement) + +NS_IMPL_RELEASE(nsHTMLOptGroupElement) + +nsresult +nsHTMLOptGroupElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLOptGroupElementIID)) { + nsIDOMHTMLOptGroupElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLOptGroupElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLOptGroupElement* it = new nsHTMLOptGroupElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMPL_BOOL_ATTR(nsHTMLOptGroupElement, Disabled, disabled, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLOptGroupElement, Label, label, eSetAttrNotify_None) + +NS_IMETHODIMP +nsHTMLOptGroupElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLOptGroupElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLOptGroupElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLOptGroupElement::HandleDOMEvent(nsIPresContext& aPresContext, + nsEvent* aEvent, + nsIDOMEvent** aDOMEvent, + PRUint32 aFlags, + nsEventStatus& aEventStatus) +{ + return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent, + aFlags, aEventStatus); +} diff --git a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp new file mode 100644 index 00000000000..831f18aeca1 --- /dev/null +++ b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp @@ -0,0 +1,222 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ +#include "nsIDOMHTMLTextAreaElement.h" +#include "nsIScriptObjectOwner.h" +#include "nsIDOMEventReceiver.h" +#include "nsIHTMLContent.h" +#include "nsGenericHTMLElement.h" +#include "nsHTMLAtoms.h" +#include "nsHTMLIIDs.h" +#include "nsIStyleContext.h" +#include "nsStyleConsts.h" +#include "nsIPresContext.h" + +static NS_DEFINE_IID(kIDOMHTMLTextAreaElementIID, NS_IDOMHTMLTEXTAREAELEMENT_IID); + +class nsHTMLTextAreaElement : public nsIDOMHTMLTextAreaElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLTextAreaElement(nsIAtom* aTag); + ~nsHTMLTextAreaElement(); + + // nsISupports + NS_DECL_ISUPPORTS + + // nsIDOMNode + NS_IMPL_IDOMNODE_USING_GENERIC(mInner) + + // nsIDOMElement + NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLElement + NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLTextAreaElement + NS_IMETHOD GetDefaultValue(nsString& aDefaultValue); + NS_IMETHOD SetDefaultValue(const nsString& aDefaultValue); + NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm); + NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm); + NS_IMETHOD GetAccessKey(nsString& aAccessKey); + NS_IMETHOD SetAccessKey(const nsString& aAccessKey); + NS_IMETHOD GetCols(PRInt32* aCols); + NS_IMETHOD SetCols(PRInt32 aCols); + NS_IMETHOD GetDisabled(PRBool* aDisabled); + NS_IMETHOD SetDisabled(PRBool aDisabled); + NS_IMETHOD GetName(nsString& aName); + NS_IMETHOD SetName(const nsString& aName); + NS_IMETHOD GetReadOnly(PRBool* aReadOnly); + NS_IMETHOD SetReadOnly(PRBool aReadOnly); + NS_IMETHOD GetRows(PRInt32* aRows); + NS_IMETHOD SetRows(PRInt32 aRows); + NS_IMETHOD GetTabIndex(PRInt32* aTabIndex); + NS_IMETHOD SetTabIndex(PRInt32 aTabIndex); + NS_IMETHOD Blur(); + NS_IMETHOD Focus(); + NS_IMETHOD Select(); + + // nsIScriptObjectOwner + NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner) + + // nsIDOMEventReceiver + NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner) + + // nsIContent + NS_IMPL_ICONTENT_USING_GENERIC(mInner) + + // nsIHTMLContent + NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner) + +protected: + nsHTMLGenericContainerContent mInner; +}; + +nsresult +NS_NewHTMLTextAreaElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLTextAreaElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLTextAreaElement::nsHTMLTextAreaElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLTextAreaElement::~nsHTMLTextAreaElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLTextAreaElement) + +NS_IMPL_RELEASE(nsHTMLTextAreaElement) + +nsresult +nsHTMLTextAreaElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLTextAreaElementIID)) { + nsIDOMHTMLTextAreaElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLTextAreaElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLTextAreaElement* it = new nsHTMLTextAreaElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMETHODIMP +nsHTMLTextAreaElement::GetForm(nsIDOMHTMLFormElement** aForm) +{ + *aForm = nsnull;/* XXX */ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTextAreaElement::SetForm(nsIDOMHTMLFormElement* aForm) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTextAreaElement::Blur() +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTextAreaElement::Focus() +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTextAreaElement::Select() +{ + // XXX write me + return NS_OK; +} + +NS_IMPL_STRING_ATTR(nsHTMLTextAreaElement, DefaultValue, defaultvalue, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLTextAreaElement, AccessKey, accesskey, eSetAttrNotify_None) +NS_IMPL_INT_ATTR(nsHTMLTextAreaElement, Cols, cols, eSetAttrNotify_Reflow) +NS_IMPL_BOOL_ATTR(nsHTMLTextAreaElement, Disabled, disabled, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLTextAreaElement, Name, name, eSetAttrNotify_Restart) +NS_IMPL_BOOL_ATTR(nsHTMLTextAreaElement, ReadOnly, readonly, eSetAttrNotify_Render) +NS_IMPL_INT_ATTR(nsHTMLTextAreaElement, Rows, rows, eSetAttrNotify_Reflow) +NS_IMPL_INT_ATTR(nsHTMLTextAreaElement, TabIndex, tabindex, eSetAttrNotify_None) + +NS_IMETHODIMP +nsHTMLTextAreaElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLTextAreaElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLTextAreaElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTextAreaElement::HandleDOMEvent(nsIPresContext& aPresContext, + nsEvent* aEvent, + nsIDOMEvent** aDOMEvent, + PRUint32 aFlags, + nsEventStatus& aEventStatus) +{ + return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent, + aFlags, aEventStatus); +} diff --git a/mozilla/layout/html/content/src/nsHTMLButtonElement.cpp b/mozilla/layout/html/content/src/nsHTMLButtonElement.cpp new file mode 100644 index 00000000000..6ac6bd8cf94 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLButtonElement.cpp @@ -0,0 +1,275 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ +#include "nsIDOMHTMLButtonElement.h" +#include "nsIScriptObjectOwner.h" +#include "nsIDOMEventReceiver.h" +#include "nsIHTMLContent.h" +#include "nsGenericHTMLElement.h" +#include "nsHTMLAtoms.h" +#include "nsHTMLIIDs.h" +#include "nsIStyleContext.h" +#include "nsStyleConsts.h" +#include "nsIPresContext.h" + +#include "nsIEventStateManager.h" +#include "nsDOMEvent.h" + +static NS_DEFINE_IID(kIDOMHTMLButtonElementIID, NS_IDOMHTMLBUTTONELEMENT_IID); + +class nsHTMLButtonElement : public nsIDOMHTMLButtonElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLButtonElement(nsIAtom* aTag); + ~nsHTMLButtonElement(); + + // nsISupports + NS_DECL_ISUPPORTS + + // nsIDOMNode + NS_IMPL_IDOMNODE_USING_GENERIC(mInner) + + // nsIDOMElement + NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLElement + NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLButtonElement + NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm); + NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm); + NS_IMETHOD GetAccessKey(nsString& aAccessKey); + NS_IMETHOD SetAccessKey(const nsString& aAccessKey); + NS_IMETHOD GetDisabled(PRBool* aDisabled); + NS_IMETHOD SetDisabled(PRBool aDisabled); + NS_IMETHOD GetName(nsString& aName); + NS_IMETHOD SetName(const nsString& aName); + NS_IMETHOD GetTabIndex(PRInt32* aTabIndex); + NS_IMETHOD SetTabIndex(PRInt32 aTabIndex); + NS_IMETHOD GetType(nsString& aType); + NS_IMETHOD SetType(const nsString& aType); + NS_IMETHOD GetValue(nsString& aValue); + NS_IMETHOD SetValue(const nsString& aValue); + + // nsIScriptObjectOwner + NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner) + + // nsIDOMEventReceiver + NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner) + + // nsIContent + NS_IMPL_ICONTENT_USING_GENERIC(mInner) + + // nsIHTMLContent + NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner) + +protected: + nsHTMLGenericContainerContent mInner; +}; + +nsresult +NS_NewHTMLButtonElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLButtonElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLButtonElement::nsHTMLButtonElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLButtonElement::~nsHTMLButtonElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLButtonElement) + +NS_IMPL_RELEASE(nsHTMLButtonElement) + +nsresult +nsHTMLButtonElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLButtonElementIID)) { + nsIDOMHTMLButtonElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLButtonElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLButtonElement* it = new nsHTMLButtonElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMETHODIMP +nsHTMLButtonElement::GetForm(nsIDOMHTMLFormElement** aForm) +{ + *aForm = nsnull;/* XXX */ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLButtonElement::SetForm(nsIDOMHTMLFormElement* aForm) +{ + return NS_OK; +} + +NS_IMPL_STRING_ATTR(nsHTMLButtonElement, AccessKey, accesskey, eSetAttrNotify_None) +NS_IMPL_BOOL_ATTR(nsHTMLButtonElement, Disabled, disabled, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLButtonElement, Name, name, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLButtonElement, Type, type, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLButtonElement, Value, value, eSetAttrNotify_Render) + +NS_IMETHODIMP +nsHTMLButtonElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + if (aAttribute == nsHTMLAtoms::tabindex) { + nsHTMLGenericContent::ParseValue(aValue, 0, 32767, aResult, + eHTMLUnit_Integer); + return NS_CONTENT_ATTR_HAS_VALUE; + } + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLButtonElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLButtonElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLButtonElement::HandleDOMEvent(nsIPresContext& aPresContext, + nsEvent* aEvent, + nsIDOMEvent** aDOMEvent, + PRUint32 aFlags, + nsEventStatus& aEventStatus) +{ + // Try script event handlers first + nsresult ret = mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent, + aFlags, aEventStatus); + + if ((NS_OK == ret) && (nsEventStatus_eIgnore == aEventStatus)) { + switch (aEvent->message) { + case NS_MOUSE_LEFT_BUTTON_DOWN: + { + nsIEventStateManager *stateManager; + if (NS_OK == aPresContext.GetEventStateManager(&stateManager)) { + stateManager->SetActiveLink(this); + NS_RELEASE(stateManager); + } + aEventStatus = nsEventStatus_eConsumeNoDefault; + } + break; + + case NS_MOUSE_LEFT_BUTTON_UP: + { + nsIEventStateManager *stateManager; + nsIContent *activeLink; + if (NS_OK == aPresContext.GetEventStateManager(&stateManager)) { + stateManager->GetActiveLink(&activeLink); + NS_RELEASE(stateManager); + } + + if (activeLink == this) { + nsEventStatus status; + nsMouseEvent event; + event.eventStructType = NS_MOUSE_EVENT; + event.message = NS_MOUSE_LEFT_CLICK; + HandleDOMEvent(aPresContext, &event, nsnull, DOM_EVENT_INIT, status); + + if (nsEventStatus_eConsumeNoDefault != status) { + nsAutoString base, href, target; + GetAttribute(nsString(NS_HTML_BASE_HREF), base); + GetAttribute(nsString("href"), href); + GetAttribute(nsString("target"), target); + if (target.Length() == 0) { + GetAttribute(nsString(NS_HTML_BASE_TARGET), target); + } + mInner.TriggerLink(aPresContext, base, href, target, PR_TRUE); + aEventStatus = nsEventStatus_eConsumeNoDefault; + } + } + } + break; + + case NS_MOUSE_RIGHT_BUTTON_DOWN: + // XXX Bring up a contextual menu provided by the application + break; + + case NS_MOUSE_ENTER: + //mouse enter doesn't work yet. Use move until then. + { + nsAutoString base, href, target; + GetAttribute(nsString(NS_HTML_BASE_HREF), base); + GetAttribute(nsString("href"), href); + GetAttribute(nsString("target"), target); + if (target.Length() == 0) { + GetAttribute(nsString(NS_HTML_BASE_TARGET), target); + } + mInner.TriggerLink(aPresContext, base, href, target, PR_FALSE); + aEventStatus = nsEventStatus_eConsumeDoDefault; + } + break; + + // XXX this doesn't seem to do anything yet + case NS_MOUSE_EXIT: + { + nsAutoString empty; + mInner.TriggerLink(aPresContext, empty, empty, empty, PR_FALSE); + aEventStatus = nsEventStatus_eConsumeDoDefault; + } + break; + + default: + break; + } + } + return ret; +} diff --git a/mozilla/layout/html/content/src/nsHTMLFrameElement.cpp b/mozilla/layout/html/content/src/nsHTMLFrameElement.cpp new file mode 100644 index 00000000000..c6947dafc7c --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLFrameElement.cpp @@ -0,0 +1,183 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ +#include "nsIDOMHTMLFrameElement.h" +#include "nsIScriptObjectOwner.h" +#include "nsIDOMEventReceiver.h" +#include "nsIHTMLContent.h" +#include "nsGenericHTMLElement.h" +#include "nsHTMLAtoms.h" +#include "nsHTMLIIDs.h" +#include "nsIStyleContext.h" +#include "nsStyleConsts.h" +#include "nsIPresContext.h" + +static NS_DEFINE_IID(kIDOMHTMLFrameElementIID, NS_IDOMHTMLFRAMEELEMENT_IID); + +class nsHTMLFrameElement : public nsIDOMHTMLFrameElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLFrameElement(nsIAtom* aTag); + ~nsHTMLFrameElement(); + + // nsISupports + NS_DECL_ISUPPORTS + + // nsIDOMNode + NS_IMPL_IDOMNODE_USING_GENERIC(mInner) + + // nsIDOMElement + NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLElement + NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLFrameElement + NS_IMETHOD GetFrameBorder(nsString& aFrameBorder); + NS_IMETHOD SetFrameBorder(const nsString& aFrameBorder); + NS_IMETHOD GetLongDesc(nsString& aLongDesc); + NS_IMETHOD SetLongDesc(const nsString& aLongDesc); + NS_IMETHOD GetMarginHeight(nsString& aMarginHeight); + NS_IMETHOD SetMarginHeight(const nsString& aMarginHeight); + NS_IMETHOD GetMarginWidth(nsString& aMarginWidth); + NS_IMETHOD SetMarginWidth(const nsString& aMarginWidth); + NS_IMETHOD GetName(nsString& aName); + NS_IMETHOD SetName(const nsString& aName); + NS_IMETHOD GetNoResize(PRBool* aNoResize); + NS_IMETHOD SetNoResize(PRBool aNoResize); + NS_IMETHOD GetScrolling(nsString& aScrolling); + NS_IMETHOD SetScrolling(const nsString& aScrolling); + NS_IMETHOD GetSrc(nsString& aSrc); + NS_IMETHOD SetSrc(const nsString& aSrc); + + // nsIScriptObjectOwner + NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner) + + // nsIDOMEventReceiver + NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner) + + // nsIContent + NS_IMPL_ICONTENT_USING_GENERIC(mInner) + + // nsIHTMLContent + NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner) + +protected: + nsHTMLGenericLeafContent mInner; +}; + +nsresult +NS_NewHTMLFrameElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLFrameElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLFrameElement::nsHTMLFrameElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLFrameElement::~nsHTMLFrameElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLFrameElement) + +NS_IMPL_RELEASE(nsHTMLFrameElement) + +nsresult +nsHTMLFrameElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLFrameElementIID)) { + nsIDOMHTMLFrameElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLFrameElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLFrameElement* it = new nsHTMLFrameElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMPL_STRING_ATTR(nsHTMLFrameElement, FrameBorder, frameborder, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLFrameElement, LongDesc, longdesc, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLFrameElement, MarginHeight, marginheight, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLFrameElement, MarginWidth, marginwidth, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLFrameElement, Name, name, eSetAttrNotify_Restart) +NS_IMPL_BOOL_ATTR(nsHTMLFrameElement, NoResize, noresize, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLFrameElement, Scrolling, scrolling, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLFrameElement, Src, src, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLFrameElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLFrameElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLFrameElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLFrameElement::HandleDOMEvent(nsIPresContext& aPresContext, + nsEvent* aEvent, + nsIDOMEvent** aDOMEvent, + PRUint32 aFlags, + nsEventStatus& aEventStatus) +{ + return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent, + aFlags, aEventStatus); +} diff --git a/mozilla/layout/html/content/src/nsHTMLFrameSetElement.cpp b/mozilla/layout/html/content/src/nsHTMLFrameSetElement.cpp new file mode 100644 index 00000000000..9eb22def7d4 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLFrameSetElement.cpp @@ -0,0 +1,165 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ +#include "nsIDOMHTMLFrameSetElement.h" +#include "nsIScriptObjectOwner.h" +#include "nsIDOMEventReceiver.h" +#include "nsIHTMLContent.h" +#include "nsGenericHTMLElement.h" +#include "nsHTMLAtoms.h" +#include "nsHTMLIIDs.h" +#include "nsIStyleContext.h" +#include "nsStyleConsts.h" +#include "nsIPresContext.h" + +static NS_DEFINE_IID(kIDOMHTMLFrameSetElementIID, NS_IDOMHTMLFRAMESETELEMENT_IID); + +class nsHTMLFrameSetElement : public nsIDOMHTMLFrameSetElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLFrameSetElement(nsIAtom* aTag); + ~nsHTMLFrameSetElement(); + + // nsISupports + NS_DECL_ISUPPORTS + + // nsIDOMNode + NS_IMPL_IDOMNODE_USING_GENERIC(mInner) + + // nsIDOMElement + NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLElement + NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLFrameSetElement + NS_IMETHOD GetCols(nsString& aCols); + NS_IMETHOD SetCols(const nsString& aCols); + NS_IMETHOD GetRows(nsString& aRows); + NS_IMETHOD SetRows(const nsString& aRows); + + // nsIScriptObjectOwner + NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner) + + // nsIDOMEventReceiver + NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner) + + // nsIContent + NS_IMPL_ICONTENT_USING_GENERIC(mInner) + + // nsIHTMLContent + NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner) + +protected: + nsHTMLGenericContainerContent mInner; +}; + +nsresult +NS_NewHTMLFrameSetElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLFrameSetElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLFrameSetElement::nsHTMLFrameSetElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLFrameSetElement::~nsHTMLFrameSetElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLFrameSetElement) + +NS_IMPL_RELEASE(nsHTMLFrameSetElement) + +nsresult +nsHTMLFrameSetElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLFrameSetElementIID)) { + nsIDOMHTMLFrameSetElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLFrameSetElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLFrameSetElement* it = new nsHTMLFrameSetElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMPL_STRING_ATTR(nsHTMLFrameSetElement, Cols, cols, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLFrameSetElement, Rows, rows, eSetAttrNotify_Restart) + +NS_IMETHODIMP +nsHTMLFrameSetElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLFrameSetElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLFrameSetElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLFrameSetElement::HandleDOMEvent(nsIPresContext& aPresContext, + nsEvent* aEvent, + nsIDOMEvent** aDOMEvent, + PRUint32 aFlags, + nsEventStatus& aEventStatus) +{ + return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent, + aFlags, aEventStatus); +} diff --git a/mozilla/layout/html/content/src/nsHTMLIFrameElement.cpp b/mozilla/layout/html/content/src/nsHTMLIFrameElement.cpp new file mode 100644 index 00000000000..6306b11c837 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLIFrameElement.cpp @@ -0,0 +1,189 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ +#include "nsIDOMHTMLIFrameElement.h" +#include "nsIScriptObjectOwner.h" +#include "nsIDOMEventReceiver.h" +#include "nsIHTMLContent.h" +#include "nsGenericHTMLElement.h" +#include "nsHTMLAtoms.h" +#include "nsHTMLIIDs.h" +#include "nsIStyleContext.h" +#include "nsStyleConsts.h" +#include "nsIPresContext.h" + +static NS_DEFINE_IID(kIDOMHTMLIFrameElementIID, NS_IDOMHTMLIFRAMEELEMENT_IID); + +class nsHTMLIFrameElement : public nsIDOMHTMLIFrameElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLIFrameElement(nsIAtom* aTag); + ~nsHTMLIFrameElement(); + + // nsISupports + NS_DECL_ISUPPORTS + + // nsIDOMNode + NS_IMPL_IDOMNODE_USING_GENERIC(mInner) + + // nsIDOMElement + NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLElement + NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLIFrameElement + NS_IMETHOD GetAlign(nsString& aAlign); + NS_IMETHOD SetAlign(const nsString& aAlign); + NS_IMETHOD GetFrameBorder(nsString& aFrameBorder); + NS_IMETHOD SetFrameBorder(const nsString& aFrameBorder); + NS_IMETHOD GetHeight(nsString& aHeight); + NS_IMETHOD SetHeight(const nsString& aHeight); + NS_IMETHOD GetLongDesc(nsString& aLongDesc); + NS_IMETHOD SetLongDesc(const nsString& aLongDesc); + NS_IMETHOD GetMarginHeight(nsString& aMarginHeight); + NS_IMETHOD SetMarginHeight(const nsString& aMarginHeight); + NS_IMETHOD GetMarginWidth(nsString& aMarginWidth); + NS_IMETHOD SetMarginWidth(const nsString& aMarginWidth); + NS_IMETHOD GetName(nsString& aName); + NS_IMETHOD SetName(const nsString& aName); + NS_IMETHOD GetScrolling(nsString& aScrolling); + NS_IMETHOD SetScrolling(const nsString& aScrolling); + NS_IMETHOD GetSrc(nsString& aSrc); + NS_IMETHOD SetSrc(const nsString& aSrc); + NS_IMETHOD GetWidth(nsString& aWidth); + NS_IMETHOD SetWidth(const nsString& aWidth); + + // nsIScriptObjectOwner + NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner) + + // nsIDOMEventReceiver + NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner) + + // nsIContent + NS_IMPL_ICONTENT_USING_GENERIC(mInner) + + // nsIHTMLContent + NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner) + +protected: + nsHTMLGenericContainerContent mInner; +}; + +nsresult +NS_NewHTMLIFrameElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLIFrameElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLIFrameElement::nsHTMLIFrameElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLIFrameElement::~nsHTMLIFrameElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLIFrameElement) + +NS_IMPL_RELEASE(nsHTMLIFrameElement) + +nsresult +nsHTMLIFrameElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLIFrameElementIID)) { + nsIDOMHTMLIFrameElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLIFrameElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLIFrameElement* it = new nsHTMLIFrameElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, FrameBorder, frameborder, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Height, height, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, LongDesc, longdesc, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, MarginHeight, marginheight, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, MarginWidth, marginwidth, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Name, name, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Scrolling, scrolling, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Src, src, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Width, width, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLIFrameElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLIFrameElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLIFrameElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLIFrameElement::HandleDOMEvent(nsIPresContext& aPresContext, + nsEvent* aEvent, + nsIDOMEvent** aDOMEvent, + PRUint32 aFlags, + nsEventStatus& aEventStatus) +{ + return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent, + aFlags, aEventStatus); +} diff --git a/mozilla/layout/html/content/src/nsHTMLImageElement.cpp b/mozilla/layout/html/content/src/nsHTMLImageElement.cpp new file mode 100644 index 00000000000..e0b60a3bb6f --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLImageElement.cpp @@ -0,0 +1,217 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ +#include "nsIDOMHTMLImageElement.h" +#include "nsIScriptObjectOwner.h" +#include "nsIDOMEventReceiver.h" +#include "nsIHTMLContent.h" +#include "nsGenericHTMLElement.h" +#include "nsHTMLAtoms.h" +#include "nsHTMLIIDs.h" +#include "nsIStyleContext.h" +#include "nsStyleConsts.h" +#include "nsIPresContext.h" + +static NS_DEFINE_IID(kIDOMHTMLImageElementIID, NS_IDOMHTMLIMAGEELEMENT_IID); + +class nsHTMLImageElement : public nsIDOMHTMLImageElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLImageElement(nsIAtom* aTag); + ~nsHTMLImageElement(); + + // nsISupports + NS_DECL_ISUPPORTS + + // nsIDOMNode + NS_IMPL_IDOMNODE_USING_GENERIC(mInner) + + // nsIDOMElement + NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLElement + NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLImageElement + NS_IMETHOD GetLowSrc(nsString& aLowSrc); + NS_IMETHOD SetLowSrc(const nsString& aLowSrc); + NS_IMETHOD GetName(nsString& aName); + NS_IMETHOD SetName(const nsString& aName); + NS_IMETHOD GetAlign(nsString& aAlign); + NS_IMETHOD SetAlign(const nsString& aAlign); + NS_IMETHOD GetAlt(nsString& aAlt); + NS_IMETHOD SetAlt(const nsString& aAlt); + NS_IMETHOD GetBorder(nsString& aBorder); + NS_IMETHOD SetBorder(const nsString& aBorder); + NS_IMETHOD GetHeight(nsString& aHeight); + NS_IMETHOD SetHeight(const nsString& aHeight); + NS_IMETHOD GetHspace(nsString& aHspace); + NS_IMETHOD SetHspace(const nsString& aHspace); + NS_IMETHOD GetIsMap(PRBool* aIsMap); + NS_IMETHOD SetIsMap(PRBool aIsMap); + NS_IMETHOD GetLongDesc(nsString& aLongDesc); + NS_IMETHOD SetLongDesc(const nsString& aLongDesc); + NS_IMETHOD GetSrc(nsString& aSrc); + NS_IMETHOD SetSrc(const nsString& aSrc); + NS_IMETHOD GetUseMap(nsString& aUseMap); + NS_IMETHOD SetUseMap(const nsString& aUseMap); + NS_IMETHOD GetVspace(nsString& aVspace); + NS_IMETHOD SetVspace(const nsString& aVspace); + NS_IMETHOD GetWidth(nsString& aWidth); + NS_IMETHOD SetWidth(const nsString& aWidth); + + // nsIScriptObjectOwner + NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner) + + // nsIDOMEventReceiver + NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner) + + // nsIContent + NS_IMPL_ICONTENT_USING_GENERIC(mInner) + + // nsIHTMLContent + NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner) + +protected: + nsHTMLGenericContainerContent mInner; +}; + +nsresult +NS_NewHTMLImageElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLImageElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLImageElement::nsHTMLImageElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLImageElement::~nsHTMLImageElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLImageElement) + +NS_IMPL_RELEASE(nsHTMLImageElement) + +nsresult +nsHTMLImageElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLImageElementIID)) { + nsIDOMHTMLImageElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLImageElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLImageElement* it = new nsHTMLImageElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMPL_STRING_ATTR(nsHTMLImageElement, LowSrc, lowsrc, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLImageElement, Name, name, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLImageElement, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLImageElement, Alt, alt, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLImageElement, Border, border, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLImageElement, Height, height, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLImageElement, Hspace, hspace, eSetAttrNotify_Reflow) +NS_IMPL_BOOL_ATTR(nsHTMLImageElement, IsMap, ismap, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLImageElement, LongDesc, longdesc, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLImageElement, Src, src, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLImageElement, UseMap, usemap, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLImageElement, Vspace, vspace, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLImageElement, Width, width, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLImageElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + if (aAttribute == nsHTMLAtoms::align) { + if (nsHTMLGenericContent::ParseAlignValue(aValue, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } + } + else if (nsHTMLGenericContent::ParseImageAttribute(aAttribute, + aValue, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLImageElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + if (aAttribute == nsHTMLAtoms::align) { + if (eHTMLUnit_Enumerated == aValue.GetUnit()) { + nsHTMLGenericContent::AlignValueToString(aValue, aResult); + return NS_CONTENT_ATTR_HAS_VALUE; + } + } + else if (nsHTMLGenericContent::ImageAttributeToString(aAttribute, + aValue, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLImageElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + mInner.MapImageAlignAttributeInto(aContext, aPresContext); + mInner.MapImageAttributesInto(aContext, aPresContext); + mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull); + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLImageElement::HandleDOMEvent(nsIPresContext& aPresContext, + nsEvent* aEvent, + nsIDOMEvent** aDOMEvent, + PRUint32 aFlags, + nsEventStatus& aEventStatus) +{ + return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent, + aFlags, aEventStatus); +} diff --git a/mozilla/layout/html/content/src/nsHTMLIsIndexElement.cpp b/mozilla/layout/html/content/src/nsHTMLIsIndexElement.cpp new file mode 100644 index 00000000000..3ed14aff59d --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLIsIndexElement.cpp @@ -0,0 +1,177 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ +#include "nsIDOMHTMLIsIndexElement.h" +#include "nsIScriptObjectOwner.h" +#include "nsIDOMEventReceiver.h" +#include "nsIHTMLContent.h" +#include "nsGenericHTMLElement.h" +#include "nsHTMLAtoms.h" +#include "nsHTMLIIDs.h" +#include "nsIStyleContext.h" +#include "nsStyleConsts.h" +#include "nsIPresContext.h" + +static NS_DEFINE_IID(kIDOMHTMLIsIndexElementIID, NS_IDOMHTMLISINDEXELEMENT_IID); + +class nsHTMLIsIndexElement : public nsIDOMHTMLIsIndexElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLIsIndexElement(nsIAtom* aTag); + ~nsHTMLIsIndexElement(); + + // nsISupports + NS_DECL_ISUPPORTS + + // nsIDOMNode + NS_IMPL_IDOMNODE_USING_GENERIC(mInner) + + // nsIDOMElement + NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLElement + NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLIsIndexElement + NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm); + NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm); + NS_IMETHOD GetPrompt(nsString& aPrompt); + NS_IMETHOD SetPrompt(const nsString& aPrompt); + + // nsIScriptObjectOwner + NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner) + + // nsIDOMEventReceiver + NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner) + + // nsIContent + NS_IMPL_ICONTENT_USING_GENERIC(mInner) + + // nsIHTMLContent + NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner) + +protected: + nsHTMLGenericContainerContent mInner; +}; + +nsresult +NS_NewHTMLIsIndexElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLIsIndexElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLIsIndexElement::nsHTMLIsIndexElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLIsIndexElement::~nsHTMLIsIndexElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLIsIndexElement) + +NS_IMPL_RELEASE(nsHTMLIsIndexElement) + +nsresult +nsHTMLIsIndexElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLIsIndexElementIID)) { + nsIDOMHTMLIsIndexElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLIsIndexElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLIsIndexElement* it = new nsHTMLIsIndexElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMETHODIMP +nsHTMLIsIndexElement::GetForm(nsIDOMHTMLFormElement** aForm) +{ + *aForm = nsnull;/* XXX */ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLIsIndexElement::SetForm(nsIDOMHTMLFormElement* aForm) +{ + return NS_OK; +} + +NS_IMPL_STRING_ATTR(nsHTMLIsIndexElement, Prompt, prompt, eSetAttrNotify_Restart) + +NS_IMETHODIMP +nsHTMLIsIndexElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLIsIndexElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLIsIndexElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLIsIndexElement::HandleDOMEvent(nsIPresContext& aPresContext, + nsEvent* aEvent, + nsIDOMEvent** aDOMEvent, + PRUint32 aFlags, + nsEventStatus& aEventStatus) +{ + return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent, + aFlags, aEventStatus); +} diff --git a/mozilla/layout/html/content/src/nsHTMLLabelElement.cpp b/mozilla/layout/html/content/src/nsHTMLLabelElement.cpp new file mode 100644 index 00000000000..9404513c32d --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLLabelElement.cpp @@ -0,0 +1,180 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ +#include "nsIDOMHTMLLabelElement.h" +#include "nsIScriptObjectOwner.h" +#include "nsIDOMEventReceiver.h" +#include "nsIHTMLContent.h" +#include "nsGenericHTMLElement.h" +#include "nsHTMLAtoms.h" +#include "nsHTMLIIDs.h" +#include "nsIStyleContext.h" +#include "nsStyleConsts.h" +#include "nsIPresContext.h" + +static NS_DEFINE_IID(kIDOMHTMLLabelElementIID, NS_IDOMHTMLLABELELEMENT_IID); + +class nsHTMLLabelElement : public nsIDOMHTMLLabelElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLLabelElement(nsIAtom* aTag); + ~nsHTMLLabelElement(); + + // nsISupports + NS_DECL_ISUPPORTS + + // nsIDOMNode + NS_IMPL_IDOMNODE_USING_GENERIC(mInner) + + // nsIDOMElement + NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLElement + NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLLabelElement + NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm); + NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm); + NS_IMETHOD GetAccessKey(nsString& aAccessKey); + NS_IMETHOD SetAccessKey(const nsString& aAccessKey); + NS_IMETHOD GetHtmlFor(nsString& aHtmlFor); + NS_IMETHOD SetHtmlFor(const nsString& aHtmlFor); + + // nsIScriptObjectOwner + NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner) + + // nsIDOMEventReceiver + NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner) + + // nsIContent + NS_IMPL_ICONTENT_USING_GENERIC(mInner) + + // nsIHTMLContent + NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner) + +protected: + nsHTMLGenericContainerContent mInner; +}; + +nsresult +NS_NewHTMLLabelElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLLabelElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLLabelElement::nsHTMLLabelElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLLabelElement::~nsHTMLLabelElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLLabelElement) + +NS_IMPL_RELEASE(nsHTMLLabelElement) + +nsresult +nsHTMLLabelElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLLabelElementIID)) { + nsIDOMHTMLLabelElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLLabelElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLLabelElement* it = new nsHTMLLabelElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMETHODIMP +nsHTMLLabelElement::GetForm(nsIDOMHTMLFormElement** aForm) +{ + *aForm = nsnull;/* XXX */ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLLabelElement::SetForm(nsIDOMHTMLFormElement* aForm) +{ + return NS_OK; +} + +NS_IMPL_STRING_ATTR(nsHTMLLabelElement, AccessKey, accesskey, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLLabelElement, HtmlFor, _for, eSetAttrNotify_None) + +NS_IMETHODIMP +nsHTMLLabelElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLLabelElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLLabelElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLLabelElement::HandleDOMEvent(nsIPresContext& aPresContext, + nsEvent* aEvent, + nsIDOMEvent** aDOMEvent, + PRUint32 aFlags, + nsEventStatus& aEventStatus) +{ + return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent, + aFlags, aEventStatus); +} diff --git a/mozilla/layout/html/content/src/nsHTMLLegendElement.cpp b/mozilla/layout/html/content/src/nsHTMLLegendElement.cpp new file mode 100644 index 00000000000..1313ee788db --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLLegendElement.cpp @@ -0,0 +1,180 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ +#include "nsIDOMHTMLLegendElement.h" +#include "nsIScriptObjectOwner.h" +#include "nsIDOMEventReceiver.h" +#include "nsIHTMLContent.h" +#include "nsGenericHTMLElement.h" +#include "nsHTMLAtoms.h" +#include "nsHTMLIIDs.h" +#include "nsIStyleContext.h" +#include "nsStyleConsts.h" +#include "nsIPresContext.h" + +static NS_DEFINE_IID(kIDOMHTMLLegendElementIID, NS_IDOMHTMLLEGENDELEMENT_IID); + +class nsHTMLLegendElement : public nsIDOMHTMLLegendElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLLegendElement(nsIAtom* aTag); + ~nsHTMLLegendElement(); + + // nsISupports + NS_DECL_ISUPPORTS + + // nsIDOMNode + NS_IMPL_IDOMNODE_USING_GENERIC(mInner) + + // nsIDOMElement + NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLElement + NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLLegendElement + NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm); + NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm); + NS_IMETHOD GetAccessKey(nsString& aAccessKey); + NS_IMETHOD SetAccessKey(const nsString& aAccessKey); + NS_IMETHOD GetAlign(nsString& aAlign); + NS_IMETHOD SetAlign(const nsString& aAlign); + + // nsIScriptObjectOwner + NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner) + + // nsIDOMEventReceiver + NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner) + + // nsIContent + NS_IMPL_ICONTENT_USING_GENERIC(mInner) + + // nsIHTMLContent + NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner) + +protected: + nsHTMLGenericContainerContent mInner; +}; + +nsresult +NS_NewHTMLLegendElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLLegendElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLLegendElement::nsHTMLLegendElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLLegendElement::~nsHTMLLegendElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLLegendElement) + +NS_IMPL_RELEASE(nsHTMLLegendElement) + +nsresult +nsHTMLLegendElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLLegendElementIID)) { + nsIDOMHTMLLegendElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLLegendElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLLegendElement* it = new nsHTMLLegendElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMETHODIMP +nsHTMLLegendElement::GetForm(nsIDOMHTMLFormElement** aForm) +{ + *aForm = nsnull;/* XXX */ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLLegendElement::SetForm(nsIDOMHTMLFormElement* aForm) +{ + return NS_OK; +} + +NS_IMPL_STRING_ATTR(nsHTMLLegendElement, AccessKey, accesskey, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLLegendElement, Align, align, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLLegendElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLLegendElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLLegendElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLLegendElement::HandleDOMEvent(nsIPresContext& aPresContext, + nsEvent* aEvent, + nsIDOMEvent** aDOMEvent, + PRUint32 aFlags, + nsEventStatus& aEventStatus) +{ + return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent, + aFlags, aEventStatus); +} diff --git a/mozilla/layout/html/content/src/nsHTMLOptGroupElement.cpp b/mozilla/layout/html/content/src/nsHTMLOptGroupElement.cpp new file mode 100644 index 00000000000..2bc599fcd92 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLOptGroupElement.cpp @@ -0,0 +1,165 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ +#include "nsIDOMHTMLOptGroupElement.h" +#include "nsIScriptObjectOwner.h" +#include "nsIDOMEventReceiver.h" +#include "nsIHTMLContent.h" +#include "nsGenericHTMLElement.h" +#include "nsHTMLAtoms.h" +#include "nsHTMLIIDs.h" +#include "nsIStyleContext.h" +#include "nsStyleConsts.h" +#include "nsIPresContext.h" + +static NS_DEFINE_IID(kIDOMHTMLOptGroupElementIID, NS_IDOMHTMLOPTGROUPELEMENT_IID); + +class nsHTMLOptGroupElement : public nsIDOMHTMLOptGroupElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLOptGroupElement(nsIAtom* aTag); + ~nsHTMLOptGroupElement(); + + // nsISupports + NS_DECL_ISUPPORTS + + // nsIDOMNode + NS_IMPL_IDOMNODE_USING_GENERIC(mInner) + + // nsIDOMElement + NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLElement + NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLOptGroupElement + NS_IMETHOD GetDisabled(PRBool* aDisabled); + NS_IMETHOD SetDisabled(PRBool aDisabled); + NS_IMETHOD GetLabel(nsString& aLabel); + NS_IMETHOD SetLabel(const nsString& aLabel); + + // nsIScriptObjectOwner + NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner) + + // nsIDOMEventReceiver + NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner) + + // nsIContent + NS_IMPL_ICONTENT_USING_GENERIC(mInner) + + // nsIHTMLContent + NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner) + +protected: + nsHTMLGenericContainerContent mInner; +}; + +nsresult +NS_NewHTMLOptGroupElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLOptGroupElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLOptGroupElement::nsHTMLOptGroupElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLOptGroupElement::~nsHTMLOptGroupElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLOptGroupElement) + +NS_IMPL_RELEASE(nsHTMLOptGroupElement) + +nsresult +nsHTMLOptGroupElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLOptGroupElementIID)) { + nsIDOMHTMLOptGroupElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLOptGroupElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLOptGroupElement* it = new nsHTMLOptGroupElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMPL_BOOL_ATTR(nsHTMLOptGroupElement, Disabled, disabled, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLOptGroupElement, Label, label, eSetAttrNotify_None) + +NS_IMETHODIMP +nsHTMLOptGroupElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLOptGroupElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLOptGroupElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLOptGroupElement::HandleDOMEvent(nsIPresContext& aPresContext, + nsEvent* aEvent, + nsIDOMEvent** aDOMEvent, + PRUint32 aFlags, + nsEventStatus& aEventStatus) +{ + return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent, + aFlags, aEventStatus); +} diff --git a/mozilla/layout/html/content/src/nsHTMLTextAreaElement.cpp b/mozilla/layout/html/content/src/nsHTMLTextAreaElement.cpp new file mode 100644 index 00000000000..831f18aeca1 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLTextAreaElement.cpp @@ -0,0 +1,222 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ +#include "nsIDOMHTMLTextAreaElement.h" +#include "nsIScriptObjectOwner.h" +#include "nsIDOMEventReceiver.h" +#include "nsIHTMLContent.h" +#include "nsGenericHTMLElement.h" +#include "nsHTMLAtoms.h" +#include "nsHTMLIIDs.h" +#include "nsIStyleContext.h" +#include "nsStyleConsts.h" +#include "nsIPresContext.h" + +static NS_DEFINE_IID(kIDOMHTMLTextAreaElementIID, NS_IDOMHTMLTEXTAREAELEMENT_IID); + +class nsHTMLTextAreaElement : public nsIDOMHTMLTextAreaElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLTextAreaElement(nsIAtom* aTag); + ~nsHTMLTextAreaElement(); + + // nsISupports + NS_DECL_ISUPPORTS + + // nsIDOMNode + NS_IMPL_IDOMNODE_USING_GENERIC(mInner) + + // nsIDOMElement + NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLElement + NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLTextAreaElement + NS_IMETHOD GetDefaultValue(nsString& aDefaultValue); + NS_IMETHOD SetDefaultValue(const nsString& aDefaultValue); + NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm); + NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm); + NS_IMETHOD GetAccessKey(nsString& aAccessKey); + NS_IMETHOD SetAccessKey(const nsString& aAccessKey); + NS_IMETHOD GetCols(PRInt32* aCols); + NS_IMETHOD SetCols(PRInt32 aCols); + NS_IMETHOD GetDisabled(PRBool* aDisabled); + NS_IMETHOD SetDisabled(PRBool aDisabled); + NS_IMETHOD GetName(nsString& aName); + NS_IMETHOD SetName(const nsString& aName); + NS_IMETHOD GetReadOnly(PRBool* aReadOnly); + NS_IMETHOD SetReadOnly(PRBool aReadOnly); + NS_IMETHOD GetRows(PRInt32* aRows); + NS_IMETHOD SetRows(PRInt32 aRows); + NS_IMETHOD GetTabIndex(PRInt32* aTabIndex); + NS_IMETHOD SetTabIndex(PRInt32 aTabIndex); + NS_IMETHOD Blur(); + NS_IMETHOD Focus(); + NS_IMETHOD Select(); + + // nsIScriptObjectOwner + NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner) + + // nsIDOMEventReceiver + NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(mInner) + + // nsIContent + NS_IMPL_ICONTENT_USING_GENERIC(mInner) + + // nsIHTMLContent + NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner) + +protected: + nsHTMLGenericContainerContent mInner; +}; + +nsresult +NS_NewHTMLTextAreaElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLTextAreaElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLTextAreaElement::nsHTMLTextAreaElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLTextAreaElement::~nsHTMLTextAreaElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLTextAreaElement) + +NS_IMPL_RELEASE(nsHTMLTextAreaElement) + +nsresult +nsHTMLTextAreaElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLTextAreaElementIID)) { + nsIDOMHTMLTextAreaElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLTextAreaElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLTextAreaElement* it = new nsHTMLTextAreaElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMETHODIMP +nsHTMLTextAreaElement::GetForm(nsIDOMHTMLFormElement** aForm) +{ + *aForm = nsnull;/* XXX */ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTextAreaElement::SetForm(nsIDOMHTMLFormElement* aForm) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTextAreaElement::Blur() +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTextAreaElement::Focus() +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTextAreaElement::Select() +{ + // XXX write me + return NS_OK; +} + +NS_IMPL_STRING_ATTR(nsHTMLTextAreaElement, DefaultValue, defaultvalue, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLTextAreaElement, AccessKey, accesskey, eSetAttrNotify_None) +NS_IMPL_INT_ATTR(nsHTMLTextAreaElement, Cols, cols, eSetAttrNotify_Reflow) +NS_IMPL_BOOL_ATTR(nsHTMLTextAreaElement, Disabled, disabled, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLTextAreaElement, Name, name, eSetAttrNotify_Restart) +NS_IMPL_BOOL_ATTR(nsHTMLTextAreaElement, ReadOnly, readonly, eSetAttrNotify_Render) +NS_IMPL_INT_ATTR(nsHTMLTextAreaElement, Rows, rows, eSetAttrNotify_Reflow) +NS_IMPL_INT_ATTR(nsHTMLTextAreaElement, TabIndex, tabindex, eSetAttrNotify_None) + +NS_IMETHODIMP +nsHTMLTextAreaElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLTextAreaElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLTextAreaElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTextAreaElement::HandleDOMEvent(nsIPresContext& aPresContext, + nsEvent* aEvent, + nsIDOMEvent** aDOMEvent, + PRUint32 aFlags, + nsEventStatus& aEventStatus) +{ + return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent, + aFlags, aEventStatus); +}