From af61e4b99f44d0bc47408c20536416591931b566 Mon Sep 17 00:00:00 2001 From: "kipp%netscape.com" Date: Wed, 2 Sep 1998 23:53:16 +0000 Subject: [PATCH] Spanked git-svn-id: svn://10.0.0.236/trunk@9173 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/html/content/src/makefile.win | 188 +- .../content/src/nsGenericHTMLElement.cpp} | 8 +- .../html/content/src/nsGenericHTMLElement.h} | 0 .../html/content/src/nsHTMLAnchorElement.cpp} | 86 +- .../html/content/src/nsHTMLAppletElement.cpp} | 80 +- .../html/content/src/nsHTMLAreaElement.cpp} | 68 +- .../html/content/src/nsHTMLBRElement.cpp} | 60 +- .../html/content/src/nsHTMLBaseElement.cpp | 162 + .../content/src/nsHTMLBaseFontElement.cpp} | 64 +- .../html/content/src/nsHTMLBodyElement.cpp} | 70 +- .../html/content/src/nsHTMLDListElement.cpp | 162 + .../html/content/src/nsHTMLDelElement.cpp} | 38 +- .../content/src/nsHTMLDirectoryElement.cpp} | 36 +- .../html/content/src/nsHTMLDivElement.cpp} | 36 +- .../html/content/src/nsHTMLEmbedElement.cpp | 181 ++ .../html/content/src/nsHTMLFontElement.cpp} | 40 +- .../html/content/src/nsHTMLFormElement.cpp | 206 ++ .../html/content/src/nsHTMLHRElement.cpp} | 42 +- .../html/content/src/nsHTMLHeadElement.cpp | 159 + .../content/src/nsHTMLHeadingElement.cpp} | 36 +- .../html/content/src/nsHTMLHtmlElement.cpp} | 36 +- .../html/content/src/nsHTMLInputElement.cpp} | 78 +- .../html/content/src/nsHTMLInsElement.cpp} | 38 +- .../html/content/src/nsHTMLLIElement.cpp} | 38 +- .../html/content/src/nsHTMLLinkElement.cpp} | 52 +- .../html/content/src/nsHTMLMapElement.cpp} | 40 +- .../html/content/src/nsHTMLMenuElement.cpp} | 36 +- .../html/content/src/nsHTMLMetaElement.cpp | 168 + .../html/content/src/nsHTMLModElement.cpp} | 38 +- .../html/content/src/nsHTMLOListElement.cpp} | 40 +- .../html/content/src/nsHTMLObjectElement.cpp | 244 ++ .../html/content/src/nsHTMLOptionElement.cpp} | 50 +- .../content/src/nsHTMLParagraphElement.cpp} | 36 +- .../html/content/src/nsHTMLParamElement.cpp} | 42 +- .../html/content/src/nsHTMLPreElement.cpp} | 36 +- .../html/content/src/nsHTMLQuoteElement.cpp} | 36 +- .../html/content/src/nsHTMLScriptElement.cpp} | 54 +- .../html/content/src/nsHTMLSelectElement.cpp | 234 ++ .../content/src/nsHTMLSharedObjectElement.cpp | 244 ++ .../html/content/src/nsHTMLStyleElement.cpp} | 40 +- .../src/nsHTMLTableCaptionElement.cpp} | 36 +- .../content/src/nsHTMLTableCellElement.cpp} | 66 +- .../content/src/nsHTMLTableColElement.cpp} | 46 +- .../html/content/src/nsHTMLTableElement.cpp} | 88 +- .../content/src/nsHTMLTableRowElement.cpp} | 60 +- .../src/nsHTMLTableSectionElement.cpp} | 46 +- .../html/content/src/nsHTMLTitleElement.cpp} | 26 +- .../html/content/src/nsHTMLUListElement.cpp} | 38 +- mozilla/layout/html/content/src/makefile.win | 188 +- .../{nsHTMLComment.cpp => nsCommentNode.cpp} | 24 +- .../html/content/src/nsGenericHTMLElement.cpp | 2738 +++++++++++++++++ .../html/content/src/nsGenericHTMLElement.h | 814 +++++ .../html/content/src/nsHTMLAnchorElement.cpp | 295 ++ .../html/content/src/nsHTMLAppletElement.cpp | 211 ++ .../html/content/src/nsHTMLAreaElement.cpp | 180 ++ .../html/content/src/nsHTMLBRElement.cpp | 187 ++ .../html/content/src/nsHTMLBaseElement.cpp | 162 + .../content/src/nsHTMLBaseFontElement.cpp | 168 + .../html/content/src/nsHTMLBodyElement.cpp | 177 ++ .../html/content/src/nsHTMLDListElement.cpp | 162 + .../html/content/src/nsHTMLDelElement.cpp | 165 + .../content/src/nsHTMLDirectoryElement.cpp | 162 + .../html/content/src/nsHTMLDivElement.cpp | 173 ++ .../layout/html/content/src/nsHTMLEmbed.cpp | 55 - .../html/content/src/nsHTMLEmbedElement.cpp | 181 ++ .../{nsHTMLFont.cpp => nsHTMLFontElement.cpp} | 40 +- .../html/content/src/nsHTMLFormElement.cpp | 206 ++ .../html/content/src/nsHTMLHRElement.cpp | 222 ++ .../layout/html/content/src/nsHTMLHead.cpp | 74 - .../html/content/src/nsHTMLHeadElement.cpp | 159 + .../html/content/src/nsHTMLHeadingElement.cpp | 162 + .../{nsHTMLBase.cpp => nsHTMLHtmlElement.cpp} | 57 +- .../html/content/src/nsHTMLInputElement.cpp | 257 ++ .../html/content/src/nsHTMLInsElement.cpp | 165 + .../html/content/src/nsHTMLLIElement.cpp | 165 + ...nsHTMLLayer.cpp => nsHTMLLayerElement.cpp} | 236 +- .../html/content/src/nsHTMLLinkElement.cpp | 183 ++ .../html/content/src/nsHTMLMapElement.cpp | 178 ++ .../html/content/src/nsHTMLMenuElement.cpp | 162 + .../layout/html/content/src/nsHTMLMeta.cpp | 76 - .../html/content/src/nsHTMLMetaElement.cpp | 168 + .../html/content/src/nsHTMLModElement.cpp | 165 + .../html/content/src/nsHTMLOListElement.cpp | 168 + .../layout/html/content/src/nsHTMLObject.cpp | 55 - .../html/content/src/nsHTMLObjectElement.cpp | 244 ++ .../html/content/src/nsHTMLOptionElement.cpp | 189 ++ .../content/src/nsHTMLParagraphElement.cpp | 173 ++ .../html/content/src/nsHTMLParamElement.cpp | 171 + .../html/content/src/nsHTMLPreElement.cpp | 173 ++ ...nsHTMLDList.cpp => nsHTMLQuoteElement.cpp} | 50 +- .../html/content/src/nsHTMLScriptElement.cpp | 223 ++ .../html/content/src/nsHTMLSelectElement.cpp | 234 ++ .../html/content/src/nsHTMLStyleElement.cpp | 167 + .../content/src/nsHTMLTableCaptionElement.cpp | 162 + .../content/src/nsHTMLTableCellElement.cpp | 217 ++ .../content/src/nsHTMLTableColElement.cpp | 177 ++ .../html/content/src/nsHTMLTableElement.cpp | 321 ++ .../content/src/nsHTMLTableRowElement.cpp | 242 ++ .../content/src/nsHTMLTableSectionElement.cpp | 199 ++ .../html/content/src/nsHTMLTitleElement.cpp | 152 + .../html/content/src/nsHTMLUListElement.cpp | 165 + 101 files changed, 14399 insertions(+), 1508 deletions(-) rename mozilla/{layout/html/content/src/nsHTMLGenericContent.cpp => content/html/content/src/nsGenericHTMLElement.cpp} (99%) rename mozilla/{layout/html/content/src/nsHTMLGenericContent.h => content/html/content/src/nsGenericHTMLElement.h} (100%) rename mozilla/{layout/html/content/src/nsHTMLAnchor.cpp => content/html/content/src/nsHTMLAnchorElement.cpp} (72%) rename mozilla/{layout/html/content/src/nsHTMLApplet.cpp => content/html/content/src/nsHTMLAppletElement.cpp} (65%) rename mozilla/{layout/html/content/src/nsHTMLArea.cpp => content/html/content/src/nsHTMLAreaElement.cpp} (64%) rename mozilla/{layout/html/content/src/nsHTMLBR.cpp => content/html/content/src/nsHTMLBRElement.cpp} (71%) create mode 100644 mozilla/content/html/content/src/nsHTMLBaseElement.cpp rename mozilla/{layout/html/content/src/nsHTMLBaseFont.cpp => content/html/content/src/nsHTMLBaseFontElement.cpp} (62%) rename mozilla/{layout/html/content/src/nsHTMLBody.cpp => content/html/content/src/nsHTMLBodyElement.cpp} (63%) create mode 100644 mozilla/content/html/content/src/nsHTMLDListElement.cpp rename mozilla/{layout/html/content/src/nsHTMLDel.cpp => content/html/content/src/nsHTMLDelElement.cpp} (78%) rename mozilla/{layout/html/content/src/nsHTMLDirectory.cpp => content/html/content/src/nsHTMLDirectoryElement.cpp} (77%) rename mozilla/{layout/html/content/src/nsHTMLDiv.cpp => content/html/content/src/nsHTMLDivElement.cpp} (81%) create mode 100644 mozilla/content/html/content/src/nsHTMLEmbedElement.cpp rename mozilla/{layout/html/content/src/nsHTMLSelect.cpp => content/html/content/src/nsHTMLFontElement.cpp} (77%) create mode 100644 mozilla/content/html/content/src/nsHTMLFormElement.cpp rename mozilla/{layout/html/content/src/nsHTMLHR.cpp => content/html/content/src/nsHTMLHRElement.cpp} (83%) create mode 100644 mozilla/content/html/content/src/nsHTMLHeadElement.cpp rename mozilla/{layout/html/content/src/nsHTMLHeading.cpp => content/html/content/src/nsHTMLHeadingElement.cpp} (78%) rename mozilla/{layout/html/content/src/nsHTMLHtml.cpp => content/html/content/src/nsHTMLHtmlElement.cpp} (79%) rename mozilla/{layout/html/content/src/nsHTMLInput.cpp => content/html/content/src/nsHTMLInputElement.cpp} (70%) rename mozilla/{layout/html/content/src/nsHTMLIns.cpp => content/html/content/src/nsHTMLInsElement.cpp} (78%) rename mozilla/{layout/html/content/src/nsHTMLLI.cpp => content/html/content/src/nsHTMLLIElement.cpp} (79%) rename mozilla/{layout/html/content/src/nsHTMLLink.cpp => content/html/content/src/nsHTMLLinkElement.cpp} (73%) rename mozilla/{layout/html/content/src/nsHTMLMap.cpp => content/html/content/src/nsHTMLMapElement.cpp} (78%) rename mozilla/{layout/html/content/src/nsHTMLMenu.cpp => content/html/content/src/nsHTMLMenuElement.cpp} (79%) create mode 100644 mozilla/content/html/content/src/nsHTMLMetaElement.cpp rename mozilla/{layout/html/content/src/nsHTMLMod.cpp => content/html/content/src/nsHTMLModElement.cpp} (78%) rename mozilla/{layout/html/content/src/nsHTMLOList.cpp => content/html/content/src/nsHTMLOListElement.cpp} (77%) create mode 100644 mozilla/content/html/content/src/nsHTMLObjectElement.cpp rename mozilla/{layout/html/content/src/nsHTMLOption.cpp => content/html/content/src/nsHTMLOptionElement.cpp} (74%) rename mozilla/{layout/html/content/src/nsHTMLParagraph.cpp => content/html/content/src/nsHTMLParagraphElement.cpp} (79%) rename mozilla/{layout/html/content/src/nsHTMLParam.cpp => content/html/content/src/nsHTMLParamElement.cpp} (76%) rename mozilla/{layout/html/content/src/nsHTMLPre.cpp => content/html/content/src/nsHTMLPreElement.cpp} (81%) rename mozilla/{layout/html/content/src/nsHTMLQuote.cpp => content/html/content/src/nsHTMLQuoteElement.cpp} (79%) rename mozilla/{layout/html/content/src/nsHTMLScript.cpp => content/html/content/src/nsHTMLScriptElement.cpp} (75%) create mode 100644 mozilla/content/html/content/src/nsHTMLSelectElement.cpp create mode 100644 mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp rename mozilla/{layout/html/content/src/nsHTMLStyle.cpp => content/html/content/src/nsHTMLStyleElement.cpp} (77%) rename mozilla/{layout/html/content/src/nsHTMLTableCaption.cpp => content/html/content/src/nsHTMLTableCaptionElement.cpp} (77%) rename mozilla/{layout/html/content/src/nsHTMLTableCell.cpp => content/html/content/src/nsHTMLTableCellElement.cpp} (69%) rename mozilla/{layout/html/content/src/nsHTMLTableCol.cpp => content/html/content/src/nsHTMLTableColElement.cpp} (74%) rename mozilla/{layout/html/content/src/nsHTMLTable.cpp => content/html/content/src/nsHTMLTableElement.cpp} (70%) rename mozilla/{layout/html/content/src/nsHTMLTableRow.cpp => content/html/content/src/nsHTMLTableRowElement.cpp} (73%) rename mozilla/{layout/html/content/src/nsHTMLTableSection.cpp => content/html/content/src/nsHTMLTableSectionElement.cpp} (74%) rename mozilla/{layout/html/content/src/nsHTMLTitle.cpp => content/html/content/src/nsHTMLTitleElement.cpp} (81%) rename mozilla/{layout/html/content/src/nsHTMLUList.cpp => content/html/content/src/nsHTMLUListElement.cpp} (78%) rename mozilla/layout/html/content/src/{nsHTMLComment.cpp => nsCommentNode.cpp} (81%) create mode 100644 mozilla/layout/html/content/src/nsGenericHTMLElement.cpp create mode 100644 mozilla/layout/html/content/src/nsGenericHTMLElement.h create mode 100644 mozilla/layout/html/content/src/nsHTMLAnchorElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLAppletElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLAreaElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLBRElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLBaseElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLBaseFontElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLBodyElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLDListElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLDelElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLDirectoryElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLDivElement.cpp delete mode 100644 mozilla/layout/html/content/src/nsHTMLEmbed.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLEmbedElement.cpp rename mozilla/layout/html/content/src/{nsHTMLFont.cpp => nsHTMLFontElement.cpp} (77%) create mode 100644 mozilla/layout/html/content/src/nsHTMLFormElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLHRElement.cpp delete mode 100644 mozilla/layout/html/content/src/nsHTMLHead.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLHeadElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLHeadingElement.cpp rename mozilla/layout/html/content/src/{nsHTMLBase.cpp => nsHTMLHtmlElement.cpp} (71%) create mode 100644 mozilla/layout/html/content/src/nsHTMLInputElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLInsElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLLIElement.cpp rename mozilla/layout/html/content/src/{nsHTMLLayer.cpp => nsHTMLLayerElement.cpp} (52%) create mode 100644 mozilla/layout/html/content/src/nsHTMLLinkElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLMapElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLMenuElement.cpp delete mode 100644 mozilla/layout/html/content/src/nsHTMLMeta.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLMetaElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLModElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLOListElement.cpp delete mode 100644 mozilla/layout/html/content/src/nsHTMLObject.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLObjectElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLOptionElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLParagraphElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLParamElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLPreElement.cpp rename mozilla/layout/html/content/src/{nsHTMLDList.cpp => nsHTMLQuoteElement.cpp} (72%) create mode 100644 mozilla/layout/html/content/src/nsHTMLScriptElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLSelectElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLStyleElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLTableCaptionElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLTableCellElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLTableColElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLTableElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLTableRowElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLTableSectionElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLTitleElement.cpp create mode 100644 mozilla/layout/html/content/src/nsHTMLUListElement.cpp diff --git a/mozilla/content/html/content/src/makefile.win b/mozilla/content/html/content/src/makefile.win index 9516c6e806b..309b52a4c1e 100644 --- a/mozilla/content/html/content/src/makefile.win +++ b/mozilla/content/html/content/src/makefile.win @@ -23,101 +23,103 @@ REQUIRES=xpcom raptor js DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN CPPSRCS= \ - nsHTMLAnchor.cpp \ - nsHTMLApplet.cpp \ - nsHTMLArea.cpp \ - nsHTMLBR.cpp \ - nsHTMLBase.cpp \ - nsHTMLBaseFont.cpp \ - nsHTMLBody.cpp \ - nsHTMLComment.cpp \ - nsHTMLDList.cpp \ - nsHTMLDel.cpp \ - nsHTMLDirectory.cpp \ - nsHTMLDiv.cpp \ - nsHTMLEmbed.cpp \ - nsHTMLFont.cpp \ - nsHTMLGenericContent.cpp \ - nsHTMLHR.cpp \ - nsHTMLHead.cpp \ - nsHTMLHeading.cpp \ - nsHTMLHtml.cpp \ - nsHTMLInput.cpp \ - nsHTMLIns.cpp \ - nsHTMLLI.cpp \ - nsHTMLLayer.cpp \ - nsHTMLLink.cpp \ - nsHTMLMap.cpp \ - nsHTMLMenu.cpp \ - nsHTMLMeta.cpp \ - nsHTMLMod.cpp \ - nsHTMLOList.cpp \ - nsHTMLObject.cpp \ - nsHTMLOption.cpp \ - nsHTMLParagraph.cpp \ - nsHTMLParam.cpp \ - nsHTMLPre.cpp \ - nsHTMLQuote.cpp \ - nsHTMLScript.cpp \ - nsHTMLStyle.cpp \ - nsHTMLTable.cpp \ - nsHTMLTableCaption.cpp \ - nsHTMLTableCell.cpp \ - nsHTMLTableCol.cpp \ - nsHTMLTableRow.cpp \ - nsHTMLTableSection.cpp \ - nsHTMLTitle.cpp \ - nsHTMLUList.cpp \ - nsObjectContent.cpp \ + nsCommentNode.cpp \ + nsGenericHTMLElement.cpp \ + nsHTMLAnchorElement.cpp \ + nsHTMLAppletElement.cpp \ + nsHTMLAreaElement.cpp \ + nsHTMLBRElement.cpp \ + nsHTMLBaseElement.cpp \ + nsHTMLBaseFontElement.cpp \ + nsHTMLBodyElement.cpp \ + nsHTMLDListElement.cpp \ + nsHTMLDelElement.cpp \ + nsHTMLDirectoryElement.cpp \ + nsHTMLDivElement.cpp \ + nsHTMLEmbedElement.cpp \ + nsHTMLFontElement.cpp \ + nsHTMLFormElement.cpp \ + nsHTMLHRElement.cpp \ + nsHTMLHeadElement.cpp \ + nsHTMLHeadingElement.cpp \ + nsHTMLHtmlElement.cpp \ + nsHTMLInputElement.cpp \ + nsHTMLInsElement.cpp \ + nsHTMLLIElement.cpp \ + nsHTMLLayerElement.cpp \ + nsHTMLLinkElement.cpp \ + nsHTMLMapElement.cpp \ + nsHTMLMenuElement.cpp \ + nsHTMLMetaElement.cpp \ + nsHTMLModElement.cpp \ + nsHTMLOListElement.cpp \ + nsHTMLObjectElement.cpp \ + nsHTMLOptionElement.cpp \ + nsHTMLParagraphElement.cpp \ + nsHTMLParamElement.cpp \ + nsHTMLPreElement.cpp \ + nsHTMLQuoteElement.cpp \ + nsHTMLScriptElement.cpp \ + nsHTMLSelectElement.cpp \ + nsHTMLStyleElement.cpp \ + nsHTMLTableElement.cpp \ + nsHTMLTableCaptionElement.cpp \ + nsHTMLTableCellElement.cpp \ + nsHTMLTableColElement.cpp \ + nsHTMLTableRowElement.cpp \ + nsHTMLTableSectionElement.cpp \ + nsHTMLTitleElement.cpp \ + nsHTMLUListElement.cpp \ $(NULL) -CPP_OBJS= \ - .\$(OBJDIR)\nsHTMLAnchor.obj \ - .\$(OBJDIR)\nsHTMLApplet.obj \ - .\$(OBJDIR)\nsHTMLArea.obj \ - .\$(OBJDIR)\nsHTMLBR.obj \ - .\$(OBJDIR)\nsHTMLBase.obj \ - .\$(OBJDIR)\nsHTMLBaseFont.obj \ - .\$(OBJDIR)\nsHTMLBody.obj \ - .\$(OBJDIR)\nsHTMLComment.obj \ - .\$(OBJDIR)\nsHTMLDList.obj \ - .\$(OBJDIR)\nsHTMLDel.obj \ - .\$(OBJDIR)\nsHTMLDirectory.obj \ - .\$(OBJDIR)\nsHTMLDiv.obj \ - .\$(OBJDIR)\nsHTMLEmbed.obj \ - .\$(OBJDIR)\nsHTMLFont.obj \ - .\$(OBJDIR)\nsHTMLGenericContent.obj \ - .\$(OBJDIR)\nsHTMLHR.obj \ - .\$(OBJDIR)\nsHTMLHead.obj \ - .\$(OBJDIR)\nsHTMLHeading.obj \ - .\$(OBJDIR)\nsHTMLHtml.obj \ - .\$(OBJDIR)\nsHTMLInput.obj \ - .\$(OBJDIR)\nsHTMLIns.obj \ - .\$(OBJDIR)\nsHTMLLI.obj \ - .\$(OBJDIR)\nsHTMLLayer.obj \ - .\$(OBJDIR)\nsHTMLLink.obj \ - .\$(OBJDIR)\nsHTMLMap.obj \ - .\$(OBJDIR)\nsHTMLMenu.obj \ - .\$(OBJDIR)\nsHTMLMeta.obj \ - .\$(OBJDIR)\nsHTMLMod.obj \ - .\$(OBJDIR)\nsHTMLOList.obj \ - .\$(OBJDIR)\nsHTMLObject.obj \ - .\$(OBJDIR)\nsHTMLOption.obj \ - .\$(OBJDIR)\nsHTMLParagraph.obj \ - .\$(OBJDIR)\nsHTMLParam.obj \ - .\$(OBJDIR)\nsHTMLPre.obj \ - .\$(OBJDIR)\nsHTMLQuote.obj \ - .\$(OBJDIR)\nsHTMLScript.obj \ - .\$(OBJDIR)\nsHTMLStyle.obj \ - .\$(OBJDIR)\nsHTMLTable.obj \ - .\$(OBJDIR)\nsHTMLTableCaption.obj \ - .\$(OBJDIR)\nsHTMLTableCell.obj \ - .\$(OBJDIR)\nsHTMLTableCol.obj \ - .\$(OBJDIR)\nsHTMLTableRow.obj \ - .\$(OBJDIR)\nsHTMLTableSection.obj \ - .\$(OBJDIR)\nsHTMLTitle.obj \ - .\$(OBJDIR)\nsHTMLUList.obj \ - .\$(OBJDIR)\nsObjectContent.obj \ +CPP_OBJS= \ + .\$(OBJDIR)\nsCommentNode.obj \ + .\$(OBJDIR)\nsGenericHTMLElement.obj \ + .\$(OBJDIR)\nsHTMLAnchorElement.obj \ + .\$(OBJDIR)\nsHTMLAppletElement.obj \ + .\$(OBJDIR)\nsHTMLAreaElement.obj \ + .\$(OBJDIR)\nsHTMLBRElement.obj \ + .\$(OBJDIR)\nsHTMLBaseElement.obj \ + .\$(OBJDIR)\nsHTMLBaseFontElement.obj \ + .\$(OBJDIR)\nsHTMLBodyElement.obj \ + .\$(OBJDIR)\nsHTMLDListElement.obj \ + .\$(OBJDIR)\nsHTMLDelElement.obj \ + .\$(OBJDIR)\nsHTMLDirectoryElement.obj \ + .\$(OBJDIR)\nsHTMLDivElement.obj \ + .\$(OBJDIR)\nsHTMLEmbedElement.obj \ + .\$(OBJDIR)\nsHTMLFontElement.obj \ + .\$(OBJDIR)\nsHTMLFormElement.obj \ + .\$(OBJDIR)\nsHTMLHRElement.obj \ + .\$(OBJDIR)\nsHTMLHeadElement.obj \ + .\$(OBJDIR)\nsHTMLHeadingElement.obj \ + .\$(OBJDIR)\nsHTMLHtmlElement.obj \ + .\$(OBJDIR)\nsHTMLInputElement.obj \ + .\$(OBJDIR)\nsHTMLInsElement.obj \ + .\$(OBJDIR)\nsHTMLLIElement.obj \ + .\$(OBJDIR)\nsHTMLLayerElement.obj \ + .\$(OBJDIR)\nsHTMLLinkElement.obj \ + .\$(OBJDIR)\nsHTMLMapElement.obj \ + .\$(OBJDIR)\nsHTMLMenuElement.obj \ + .\$(OBJDIR)\nsHTMLMetaElement.obj \ + .\$(OBJDIR)\nsHTMLModElement.obj \ + .\$(OBJDIR)\nsHTMLOListElement.obj \ + .\$(OBJDIR)\nsHTMLObjectElement.obj \ + .\$(OBJDIR)\nsHTMLOptionElement.obj \ + .\$(OBJDIR)\nsHTMLParagraphElement.obj \ + .\$(OBJDIR)\nsHTMLParamElement.obj \ + .\$(OBJDIR)\nsHTMLPreElement.obj \ + .\$(OBJDIR)\nsHTMLQuoteElement.obj \ + .\$(OBJDIR)\nsHTMLScriptElement.obj \ + .\$(OBJDIR)\nsHTMLSelectElement.obj \ + .\$(OBJDIR)\nsHTMLStyleElement.obj \ + .\$(OBJDIR)\nsHTMLTableElement.obj \ + .\$(OBJDIR)\nsHTMLTableCaptionElement.obj \ + .\$(OBJDIR)\nsHTMLTableCellElement.obj \ + .\$(OBJDIR)\nsHTMLTableColElement.obj \ + .\$(OBJDIR)\nsHTMLTableRowElement.obj \ + .\$(OBJDIR)\nsHTMLTableSectionElement.obj \ + .\$(OBJDIR)\nsHTMLTitleElement.obj \ + .\$(OBJDIR)\nsHTMLUListElement.obj \ $(NULL) LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \ diff --git a/mozilla/layout/html/content/src/nsHTMLGenericContent.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp similarity index 99% rename from mozilla/layout/html/content/src/nsHTMLGenericContent.cpp rename to mozilla/content/html/content/src/nsGenericHTMLElement.cpp index b22b493a1aa..9af8a32f0d9 100644 --- a/mozilla/layout/html/content/src/nsHTMLGenericContent.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -16,7 +16,7 @@ * Corporation. Portions created by Netscape are Copyright (C) 1998 * Netscape Communications Corporation. All Rights Reserved. */ -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsIAtom.h" #include "nsIContentDelegate.h" @@ -1576,9 +1576,15 @@ nsHTMLGenericContent::CreateFrame(nsIPresContext* aPresContext, else if (mTag == nsHTMLAtoms::br) { rv = NS_NewBRFrame(mContent, aParentFrame, frame); } + else if (mTag == nsHTMLAtoms::embed) { + rv = NS_NewObjectFrame(mContent, aParentFrame, frame); + } else if (mTag == nsHTMLAtoms::hr) { rv = NS_NewHRFrame(mContent, aParentFrame, frame); } + else if (mTag == nsHTMLAtoms::object) { + rv = NS_NewObjectFrame(mContent, aParentFrame, frame); + } if (NS_OK != rv) { return rv; } diff --git a/mozilla/layout/html/content/src/nsHTMLGenericContent.h b/mozilla/content/html/content/src/nsGenericHTMLElement.h similarity index 100% rename from mozilla/layout/html/content/src/nsHTMLGenericContent.h rename to mozilla/content/html/content/src/nsGenericHTMLElement.h diff --git a/mozilla/layout/html/content/src/nsHTMLAnchor.cpp b/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp similarity index 72% rename from mozilla/layout/html/content/src/nsHTMLAnchor.cpp rename to mozilla/content/html/content/src/nsHTMLAnchorElement.cpp index defdb0751ae..05e7072a7f2 100644 --- a/mozilla/layout/html/content/src/nsHTMLAnchor.cpp +++ b/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -32,14 +32,14 @@ static NS_DEFINE_IID(kIDOMHTMLAnchorElementIID, NS_IDOMHTMLANCHORELEMENT_IID); -class nsHTMLAnchor : public nsIDOMHTMLAnchorElement, - public nsIScriptObjectOwner, - public nsIDOMEventReceiver, - public nsIHTMLContent +class nsHTMLAnchorElement : public nsIDOMHTMLAnchorElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent { public: - nsHTMLAnchor(nsIAtom* aTag); - ~nsHTMLAnchor(); + nsHTMLAnchorElement(nsIAtom* aTag); + ~nsHTMLAnchorElement(); // nsISupports NS_DECL_ISUPPORTS @@ -98,35 +98,35 @@ protected: }; nsresult -NS_NewHTMLAnchor(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLAnchorElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLAnchor(aTag); + nsIHTMLContent* it = new nsHTMLAnchorElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLAnchor::nsHTMLAnchor(nsIAtom* aTag) +nsHTMLAnchorElement::nsHTMLAnchorElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLAnchor::~nsHTMLAnchor() +nsHTMLAnchorElement::~nsHTMLAnchorElement() { } -NS_IMPL_ADDREF(nsHTMLAnchor) +NS_IMPL_ADDREF(nsHTMLAnchorElement) -NS_IMPL_RELEASE(nsHTMLAnchor) +NS_IMPL_RELEASE(nsHTMLAnchorElement) nsresult -nsHTMLAnchor::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLAnchorElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLAnchorElementIID)) { @@ -139,9 +139,9 @@ nsHTMLAnchor::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLAnchor::CloneNode(nsIDOMNode** aReturn) +nsHTMLAnchorElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLAnchor* it = new nsHTMLAnchor(mInner.mTag); + nsHTMLAnchorElement* it = new nsHTMLAnchorElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -149,37 +149,37 @@ nsHTMLAnchor::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_STRING_ATTR(nsHTMLAnchor, AccessKey, accesskey, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLAnchor, Charset, charset, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLAnchor, Coords, coords, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLAnchor, Href, href, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLAnchor, Hreflang, hreflang, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLAnchor, Name, name, eSetAttrNotify_Restart) -NS_IMPL_STRING_ATTR(nsHTMLAnchor, Rel, rel, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLAnchor, Rev, rev, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLAnchor, Shape, shape, eSetAttrNotify_None) -NS_IMPL_INT_ATTR(nsHTMLAnchor, TabIndex, tabindex, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLAnchor, Target, target, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLAnchor, Type, type, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, AccessKey, accesskey, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Charset, charset, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Coords, coords, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Href, href, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Hreflang, hreflang, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Name, name, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Rel, rel, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Rev, rev, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Shape, shape, eSetAttrNotify_None) +NS_IMPL_INT_ATTR(nsHTMLAnchorElement, TabIndex, tabindex, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Target, target, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Type, type, eSetAttrNotify_None) NS_IMETHODIMP -nsHTMLAnchor::Blur() +nsHTMLAnchorElement::Blur() { // XXX write me return NS_OK; } NS_IMETHODIMP -nsHTMLAnchor::Focus() +nsHTMLAnchorElement::Focus() { // XXX write me return NS_OK; } NS_IMETHODIMP -nsHTMLAnchor::StringToAttribute(nsIAtom* aAttribute, - const nsString& aValue, - nsHTMLValue& aResult) +nsHTMLAnchorElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::tabindex) { nsHTMLGenericContent::ParseValue(aValue, 0, 32767, aResult, @@ -190,26 +190,26 @@ nsHTMLAnchor::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLAnchor::AttributeToString(nsIAtom* aAttribute, - nsHTMLValue& aValue, - nsString& aResult) const +nsHTMLAnchorElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const { return mInner.AttributeToString(aAttribute, aValue, aResult); } NS_IMETHODIMP -nsHTMLAnchor::MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext) +nsHTMLAnchorElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) { return NS_OK; } NS_IMETHODIMP -nsHTMLAnchor::HandleDOMEvent(nsIPresContext& aPresContext, - nsEvent* aEvent, - nsIDOMEvent** aDOMEvent, - PRUint32 aFlags, - nsEventStatus& aEventStatus) +nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext, + nsEvent* aEvent, + nsIDOMEvent** aDOMEvent, + PRUint32 aFlags, + nsEventStatus& aEventStatus) { // Try script event handlers first nsresult ret = mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent, diff --git a/mozilla/layout/html/content/src/nsHTMLApplet.cpp b/mozilla/content/html/content/src/nsHTMLAppletElement.cpp similarity index 65% rename from mozilla/layout/html/content/src/nsHTMLApplet.cpp rename to mozilla/content/html/content/src/nsHTMLAppletElement.cpp index 88d62d40859..e4f369d17a0 100644 --- a/mozilla/layout/html/content/src/nsHTMLApplet.cpp +++ b/mozilla/content/html/content/src/nsHTMLAppletElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLAppletElementIID, NS_IDOMHTMLAPPLETELEMENT_IID); -class nsHTMLApplet : public nsIDOMHTMLAppletElement, - public nsIScriptObjectOwner, - public nsIDOMEventReceiver, - public nsIHTMLContent +class nsHTMLAppletElement : public nsIDOMHTMLAppletElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent { public: - nsHTMLApplet(nsIAtom* aTag); - ~nsHTMLApplet(); + nsHTMLAppletElement(nsIAtom* aTag); + ~nsHTMLAppletElement(); // nsISupports NS_DECL_ISUPPORTS @@ -91,35 +91,35 @@ protected: }; nsresult -NS_NewHTMLApplet(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLAppletElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLApplet(aTag); + nsIHTMLContent* it = new nsHTMLAppletElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLApplet::nsHTMLApplet(nsIAtom* aTag) +nsHTMLAppletElement::nsHTMLAppletElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLApplet::~nsHTMLApplet() +nsHTMLAppletElement::~nsHTMLAppletElement() { } -NS_IMPL_ADDREF(nsHTMLApplet) +NS_IMPL_ADDREF(nsHTMLAppletElement) -NS_IMPL_RELEASE(nsHTMLApplet) +NS_IMPL_RELEASE(nsHTMLAppletElement) nsresult -nsHTMLApplet::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLAppletElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLAppletElementIID)) { @@ -132,9 +132,9 @@ nsHTMLApplet::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLApplet::CloneNode(nsIDOMNode** aReturn) +nsHTMLAppletElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLApplet* it = new nsHTMLApplet(mInner.mTag); + nsHTMLAppletElement* it = new nsHTMLAppletElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -142,22 +142,22 @@ nsHTMLApplet::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_STRING_ATTR(nsHTMLApplet, Align, align, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLApplet, Alt, alt, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLApplet, Archive, archive, eSetAttrNotify_Restart) -NS_IMPL_STRING_ATTR(nsHTMLApplet, Code, code, eSetAttrNotify_Restart) -NS_IMPL_STRING_ATTR(nsHTMLApplet, CodeBase, codebase, eSetAttrNotify_Restart) -NS_IMPL_STRING_ATTR(nsHTMLApplet, Height, height, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLApplet, Hspace, hspace, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLApplet, Name, name, eSetAttrNotify_Restart) -NS_IMPL_STRING_ATTR(nsHTMLApplet, Object, object, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLApplet, Vspace, vspace, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLApplet, Width, width, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Alt, alt, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Archive, archive, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Code, code, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLAppletElement, CodeBase, codebase, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Height, height, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Hspace, hspace, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Name, name, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Object, object, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Vspace, vspace, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Width, width, eSetAttrNotify_Reflow) NS_IMETHODIMP -nsHTMLApplet::StringToAttribute(nsIAtom* aAttribute, - const nsString& aValue, - nsHTMLValue& aResult) +nsHTMLAppletElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::align) { if (nsHTMLGenericContent::ParseAlignValue(aValue, aResult)) { @@ -172,9 +172,9 @@ nsHTMLApplet::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLApplet::AttributeToString(nsIAtom* aAttribute, - nsHTMLValue& aValue, - nsString& aResult) const +nsHTMLAppletElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const { if (aAttribute == nsHTMLAtoms::align) { if (eHTMLUnit_Enumerated == aValue.GetUnit()) { @@ -190,8 +190,8 @@ nsHTMLApplet::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLApplet::MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext) +nsHTMLAppletElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) { mInner.MapImageAlignAttributeInto(aContext, aPresContext); mInner.MapImageAttributesInto(aContext, aPresContext); @@ -200,11 +200,11 @@ nsHTMLApplet::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLApplet::HandleDOMEvent(nsIPresContext& aPresContext, - nsEvent* aEvent, - nsIDOMEvent** aDOMEvent, - PRUint32 aFlags, - nsEventStatus& aEventStatus) +nsHTMLAppletElement::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/nsHTMLArea.cpp b/mozilla/content/html/content/src/nsHTMLAreaElement.cpp similarity index 64% rename from mozilla/layout/html/content/src/nsHTMLArea.cpp rename to mozilla/content/html/content/src/nsHTMLAreaElement.cpp index 4e5711c2386..19cfa3b1f76 100644 --- a/mozilla/layout/html/content/src/nsHTMLArea.cpp +++ b/mozilla/content/html/content/src/nsHTMLAreaElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLAreaElementIID, NS_IDOMHTMLAREAELEMENT_IID); -class nsHTMLArea : public nsIDOMHTMLAreaElement, +class nsHTMLAreaElement : public nsIDOMHTMLAreaElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLArea(nsIAtom* aTag); - ~nsHTMLArea(); + nsHTMLAreaElement(nsIAtom* aTag); + ~nsHTMLAreaElement(); // nsISupports NS_DECL_ISUPPORTS @@ -85,35 +85,35 @@ protected: }; nsresult -NS_NewHTMLArea(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLAreaElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLArea(aTag); + nsIHTMLContent* it = new nsHTMLAreaElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLArea::nsHTMLArea(nsIAtom* aTag) +nsHTMLAreaElement::nsHTMLAreaElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLArea::~nsHTMLArea() +nsHTMLAreaElement::~nsHTMLAreaElement() { } -NS_IMPL_ADDREF(nsHTMLArea) +NS_IMPL_ADDREF(nsHTMLAreaElement) -NS_IMPL_RELEASE(nsHTMLArea) +NS_IMPL_RELEASE(nsHTMLAreaElement) nsresult -nsHTMLArea::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLAreaElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLAreaElementIID)) { @@ -126,9 +126,9 @@ nsHTMLArea::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLArea::CloneNode(nsIDOMNode** aReturn) +nsHTMLAreaElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLArea* it = new nsHTMLArea(mInner.mTag); + nsHTMLAreaElement* it = new nsHTMLAreaElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -136,44 +136,44 @@ nsHTMLArea::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_STRING_ATTR(nsHTMLArea, AccessKey, accesskey, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLArea, Alt, alt, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLArea, Coords, coords, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLArea, Href, href, eSetAttrNotify_None) -NS_IMPL_BOOL_ATTR(nsHTMLArea, NoHref, nohref, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLArea, Shape, shape, eSetAttrNotify_None) -NS_IMPL_INT_ATTR(nsHTMLArea, TabIndex, tabindex, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLArea, Target, target, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAreaElement, AccessKey, accesskey, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAreaElement, Alt, alt, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAreaElement, Coords, coords, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAreaElement, Href, href, eSetAttrNotify_None) +NS_IMPL_BOOL_ATTR(nsHTMLAreaElement, NoHref, nohref, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAreaElement, Shape, shape, eSetAttrNotify_None) +NS_IMPL_INT_ATTR(nsHTMLAreaElement, TabIndex, tabindex, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAreaElement, Target, target, eSetAttrNotify_None) NS_IMETHODIMP -nsHTMLArea::StringToAttribute(nsIAtom* aAttribute, - const nsString& aValue, - nsHTMLValue& aResult) +nsHTMLAreaElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) { return NS_CONTENT_ATTR_NOT_THERE; } NS_IMETHODIMP -nsHTMLArea::AttributeToString(nsIAtom* aAttribute, - nsHTMLValue& aValue, - nsString& aResult) const +nsHTMLAreaElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const { return mInner.AttributeToString(aAttribute, aValue, aResult); } NS_IMETHODIMP -nsHTMLArea::MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext) +nsHTMLAreaElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) { return NS_OK; } NS_IMETHODIMP -nsHTMLArea::HandleDOMEvent(nsIPresContext& aPresContext, - nsEvent* aEvent, - nsIDOMEvent** aDOMEvent, - PRUint32 aFlags, - nsEventStatus& aEventStatus) +nsHTMLAreaElement::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/nsHTMLBR.cpp b/mozilla/content/html/content/src/nsHTMLBRElement.cpp similarity index 71% rename from mozilla/layout/html/content/src/nsHTMLBR.cpp rename to mozilla/content/html/content/src/nsHTMLBRElement.cpp index 797bd84da49..ecb0c1ec88c 100644 --- a/mozilla/layout/html/content/src/nsHTMLBR.cpp +++ b/mozilla/content/html/content/src/nsHTMLBRElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLBRElementIID, NS_IDOMHTMLBRELEMENT_IID); -class nsHTMLBR : public nsIDOMHTMLBRElement, - public nsIScriptObjectOwner, - public nsIDOMEventReceiver, - public nsIHTMLContent +class nsHTMLBRElement : public nsIDOMHTMLBRElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent { public: - nsHTMLBR(nsIAtom* aTag); - ~nsHTMLBR(); + nsHTMLBRElement(nsIAtom* aTag); + ~nsHTMLBRElement(); // nsISupports NS_DECL_ISUPPORTS @@ -71,35 +71,35 @@ protected: }; nsresult -NS_NewHTMLBR(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLBRElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLBR(aTag); + nsIHTMLContent* it = new nsHTMLBRElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLBR::nsHTMLBR(nsIAtom* aTag) +nsHTMLBRElement::nsHTMLBRElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLBR::~nsHTMLBR() +nsHTMLBRElement::~nsHTMLBRElement() { } -NS_IMPL_ADDREF(nsHTMLBR) +NS_IMPL_ADDREF(nsHTMLBRElement) -NS_IMPL_RELEASE(nsHTMLBR) +NS_IMPL_RELEASE(nsHTMLBRElement) nsresult -nsHTMLBR::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLBRElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLBRElementIID)) { @@ -112,9 +112,9 @@ nsHTMLBR::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLBR::CloneNode(nsIDOMNode** aReturn) +nsHTMLBRElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLBR* it = new nsHTMLBR(mInner.mTag); + nsHTMLBRElement* it = new nsHTMLBRElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -122,7 +122,7 @@ nsHTMLBR::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_STRING_ATTR(nsHTMLBR, Clear, clear, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLBRElement, Clear, clear, eSetAttrNotify_Reflow) static nsHTMLGenericContent::EnumTable kClearTable[] = { { "left", NS_STYLE_CLEAR_LEFT }, @@ -133,9 +133,9 @@ static nsHTMLGenericContent::EnumTable kClearTable[] = { }; NS_IMETHODIMP -nsHTMLBR::StringToAttribute(nsIAtom* aAttribute, - const nsString& aValue, - nsHTMLValue& aResult) +nsHTMLBRElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::clear) { if (nsHTMLGenericContent::ParseEnumValue(aValue, kClearTable, aResult)) { @@ -146,9 +146,9 @@ nsHTMLBR::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLBR::AttributeToString(nsIAtom* aAttribute, - nsHTMLValue& aValue, - nsString& aResult) const +nsHTMLBRElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const { if (aAttribute == nsHTMLAtoms::clear) { if (eHTMLUnit_Enumerated == aValue.GetUnit()) { @@ -160,8 +160,8 @@ nsHTMLBR::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLBR::MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext) +nsHTMLBRElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) { if (nsnull != mInner.mAttributes) { nsStyleDisplay* display = (nsStyleDisplay*) @@ -176,11 +176,11 @@ nsHTMLBR::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLBR::HandleDOMEvent(nsIPresContext& aPresContext, - nsEvent* aEvent, - nsIDOMEvent** aDOMEvent, - PRUint32 aFlags, - nsEventStatus& aEventStatus) +nsHTMLBRElement::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/nsHTMLBaseElement.cpp b/mozilla/content/html/content/src/nsHTMLBaseElement.cpp new file mode 100644 index 00000000000..f3f53eadb9d --- /dev/null +++ b/mozilla/content/html/content/src/nsHTMLBaseElement.cpp @@ -0,0 +1,162 @@ +/* -*- 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 "nsIDOMHTMLBaseElement.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(kIDOMHTMLBaseElementIID, NS_IDOMHTMLBASEELEMENT_IID); + +class nsHTMLBaseElement : public nsIDOMHTMLBaseElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLBaseElement(nsIAtom* aTag); + ~nsHTMLBaseElement(); + + // 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) + + // nsIDOMHTMLBaseElement + NS_IMETHOD GetHref(nsString& aHref); + NS_IMETHOD SetHref(const nsString& aHref); + NS_IMETHOD GetTarget(nsString& aTarget); + NS_IMETHOD SetTarget(const nsString& aTarget); + + // 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_NewHTMLBaseElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLBaseElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLBaseElement::nsHTMLBaseElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLBaseElement::~nsHTMLBaseElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLBaseElement) + +NS_IMPL_RELEASE(nsHTMLBaseElement) + +nsresult +nsHTMLBaseElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLBaseElementIID)) { + nsIDOMHTMLBaseElement* tmp = this; + *aInstancePtr = (void*) tmp; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLBaseElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLBaseElement* it = new nsHTMLBaseElement(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(nsHTMLBaseElement, Href, href, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLBaseElement, Target, target, eSetAttrNotify_None) + +NS_IMETHODIMP +nsHTMLBaseElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLBaseElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLBaseElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLBaseElement::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/nsHTMLBaseFont.cpp b/mozilla/content/html/content/src/nsHTMLBaseFontElement.cpp similarity index 62% rename from mozilla/layout/html/content/src/nsHTMLBaseFont.cpp rename to mozilla/content/html/content/src/nsHTMLBaseFontElement.cpp index e1c792cc042..40726de9282 100644 --- a/mozilla/layout/html/content/src/nsHTMLBaseFont.cpp +++ b/mozilla/content/html/content/src/nsHTMLBaseFontElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLBaseFontElementIID, NS_IDOMHTMLBASEFONTELEMENT_IID); -class nsHTMLBaseFont : public nsIDOMHTMLBaseFontElement, - public nsIScriptObjectOwner, - public nsIDOMEventReceiver, - public nsIHTMLContent +class nsHTMLBaseFontElement : public nsIDOMHTMLBaseFontElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent { public: - nsHTMLBaseFont(nsIAtom* aTag); - ~nsHTMLBaseFont(); + nsHTMLBaseFontElement(nsIAtom* aTag); + ~nsHTMLBaseFontElement(); // nsISupports NS_DECL_ISUPPORTS @@ -75,35 +75,35 @@ protected: }; nsresult -NS_NewHTMLBaseFont(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLBaseFontElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLBaseFont(aTag); + nsIHTMLContent* it = new nsHTMLBaseFontElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLBaseFont::nsHTMLBaseFont(nsIAtom* aTag) +nsHTMLBaseFontElement::nsHTMLBaseFontElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLBaseFont::~nsHTMLBaseFont() +nsHTMLBaseFontElement::~nsHTMLBaseFontElement() { } -NS_IMPL_ADDREF(nsHTMLBaseFont) +NS_IMPL_ADDREF(nsHTMLBaseFontElement) -NS_IMPL_RELEASE(nsHTMLBaseFont) +NS_IMPL_RELEASE(nsHTMLBaseFontElement) nsresult -nsHTMLBaseFont::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLBaseFontElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLBaseFontElementIID)) { @@ -116,9 +116,9 @@ nsHTMLBaseFont::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLBaseFont::CloneNode(nsIDOMNode** aReturn) +nsHTMLBaseFontElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLBaseFont* it = new nsHTMLBaseFont(mInner.mTag); + nsHTMLBaseFontElement* it = new nsHTMLBaseFontElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -126,42 +126,42 @@ nsHTMLBaseFont::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_STRING_ATTR(nsHTMLBaseFont, Color, color, eSetAttrNotify_Render) -NS_IMPL_STRING_ATTR(nsHTMLBaseFont, Face, face, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLBaseFont, Size, size, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLBaseFontElement, Color, color, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLBaseFontElement, Face, face, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLBaseFontElement, Size, size, eSetAttrNotify_Reflow) NS_IMETHODIMP -nsHTMLBaseFont::StringToAttribute(nsIAtom* aAttribute, - const nsString& aValue, - nsHTMLValue& aResult) +nsHTMLBaseFontElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) { // XXX write me return NS_CONTENT_ATTR_NOT_THERE; } NS_IMETHODIMP -nsHTMLBaseFont::AttributeToString(nsIAtom* aAttribute, - nsHTMLValue& aValue, - nsString& aResult) const +nsHTMLBaseFontElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const { // XXX write me return mInner.AttributeToString(aAttribute, aValue, aResult); } NS_IMETHODIMP -nsHTMLBaseFont::MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext) +nsHTMLBaseFontElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) { // XXX write me? return NS_OK; } NS_IMETHODIMP -nsHTMLBaseFont::HandleDOMEvent(nsIPresContext& aPresContext, - nsEvent* aEvent, - nsIDOMEvent** aDOMEvent, - PRUint32 aFlags, - nsEventStatus& aEventStatus) +nsHTMLBaseFontElement::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/nsHTMLBody.cpp b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp similarity index 63% rename from mozilla/layout/html/content/src/nsHTMLBody.cpp rename to mozilla/content/html/content/src/nsHTMLBodyElement.cpp index a3da83b070a..688d348e1df 100644 --- a/mozilla/layout/html/content/src/nsHTMLBody.cpp +++ b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLBodyElementIID, NS_IDOMHTMLBODYELEMENT_IID); -class nsHTMLBody : public nsIDOMHTMLBodyElement, - public nsIScriptObjectOwner, - public nsIDOMEventReceiver, - public nsIHTMLContent +class nsHTMLBodyElement : public nsIDOMHTMLBodyElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent { public: - nsHTMLBody(nsIAtom* aTag); - ~nsHTMLBody(); + nsHTMLBodyElement(nsIAtom* aTag); + ~nsHTMLBodyElement(); // nsISupports NS_DECL_ISUPPORTS @@ -81,35 +81,35 @@ protected: }; nsresult -NS_NewHTMLBody(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLBodyElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLBody(aTag); + nsIHTMLContent* it = new nsHTMLBodyElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLBody::nsHTMLBody(nsIAtom* aTag) +nsHTMLBodyElement::nsHTMLBodyElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLBody::~nsHTMLBody() +nsHTMLBodyElement::~nsHTMLBodyElement() { } -NS_IMPL_ADDREF(nsHTMLBody) +NS_IMPL_ADDREF(nsHTMLBodyElement) -NS_IMPL_RELEASE(nsHTMLBody) +NS_IMPL_RELEASE(nsHTMLBodyElement) nsresult -nsHTMLBody::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLBodyElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLBodyElementIID)) { @@ -122,9 +122,9 @@ nsHTMLBody::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLBody::CloneNode(nsIDOMNode** aReturn) +nsHTMLBodyElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLBody* it = new nsHTMLBody(mInner.mTag); + nsHTMLBodyElement* it = new nsHTMLBodyElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -132,45 +132,45 @@ nsHTMLBody::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_STRING_ATTR(nsHTMLBody, ALink, alink, eSetAttrNotify_Render) -NS_IMPL_STRING_ATTR(nsHTMLBody, Background, background, eSetAttrNotify_Render) -NS_IMPL_STRING_ATTR(nsHTMLBody, BgColor, bgcolor, eSetAttrNotify_Render) -NS_IMPL_STRING_ATTR(nsHTMLBody, Link, link, eSetAttrNotify_Render) -NS_IMPL_STRING_ATTR(nsHTMLBody, Text, text, eSetAttrNotify_Render) -NS_IMPL_STRING_ATTR(nsHTMLBody, VLink, vlink, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLBodyElement, ALink, alink, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLBodyElement, Background, background, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLBodyElement, BgColor, bgcolor, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLBodyElement, Link, link, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLBodyElement, Text, text, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLBodyElement, VLink, vlink, eSetAttrNotify_Render) NS_IMETHODIMP -nsHTMLBody::StringToAttribute(nsIAtom* aAttribute, - const nsString& aValue, - nsHTMLValue& aResult) +nsHTMLBodyElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) { // XXX write me return NS_CONTENT_ATTR_NOT_THERE; } NS_IMETHODIMP -nsHTMLBody::AttributeToString(nsIAtom* aAttribute, - nsHTMLValue& aValue, - nsString& aResult) const +nsHTMLBodyElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const { // XXX write me return mInner.AttributeToString(aAttribute, aValue, aResult); } NS_IMETHODIMP -nsHTMLBody::MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext) +nsHTMLBodyElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) { // XXX write me return NS_OK; } NS_IMETHODIMP -nsHTMLBody::HandleDOMEvent(nsIPresContext& aPresContext, - nsEvent* aEvent, - nsIDOMEvent** aDOMEvent, - PRUint32 aFlags, - nsEventStatus& aEventStatus) +nsHTMLBodyElement::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/nsHTMLDListElement.cpp b/mozilla/content/html/content/src/nsHTMLDListElement.cpp new file mode 100644 index 00000000000..66c536cdcbc --- /dev/null +++ b/mozilla/content/html/content/src/nsHTMLDListElement.cpp @@ -0,0 +1,162 @@ +/* -*- 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 "nsIDOMHTMLDListElement.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(kIDOMHTMLDListElementIID, NS_IDOMHTMLDLISTELEMENT_IID); + +class nsHTMLDListElement : public nsIDOMHTMLDListElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLDListElement(nsIAtom* aTag); + ~nsHTMLDListElement(); + + // 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) + + // nsIDOMHTMLDListElement + NS_IMETHOD GetCompact(PRBool* aCompact); + NS_IMETHOD SetCompact(PRBool aCompact); + + // 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_NewHTMLDListElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLDListElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLDListElement::nsHTMLDListElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLDListElement::~nsHTMLDListElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLDListElement) + +NS_IMPL_RELEASE(nsHTMLDListElement) + +nsresult +nsHTMLDListElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLDListElementIID)) { + nsIDOMHTMLDListElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLDListElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLDListElement* it = new nsHTMLDListElement(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(nsHTMLDListElement, Compact, compact, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLDListElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLDListElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLDListElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLDListElement::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/nsHTMLDel.cpp b/mozilla/content/html/content/src/nsHTMLDelElement.cpp similarity index 78% rename from mozilla/layout/html/content/src/nsHTMLDel.cpp rename to mozilla/content/html/content/src/nsHTMLDelElement.cpp index 719b6c598c0..4db504ac163 100644 --- a/mozilla/layout/html/content/src/nsHTMLDel.cpp +++ b/mozilla/content/html/content/src/nsHTMLDelElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLDelElementIID, NS_IDOMHTMLDELELEMENT_IID); -class nsHTMLDel : public nsIDOMHTMLDelElement, +class nsHTMLDelElement : public nsIDOMHTMLDelElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLDel(nsIAtom* aTag); - ~nsHTMLDel(); + nsHTMLDelElement(nsIAtom* aTag); + ~nsHTMLDelElement(); // nsISupports NS_DECL_ISUPPORTS @@ -73,35 +73,35 @@ protected: }; nsresult -NS_NewHTMLDel(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLDelElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLDel(aTag); + nsIHTMLContent* it = new nsHTMLDelElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLDel::nsHTMLDel(nsIAtom* aTag) +nsHTMLDelElement::nsHTMLDelElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLDel::~nsHTMLDel() +nsHTMLDelElement::~nsHTMLDelElement() { } -NS_IMPL_ADDREF(nsHTMLDel) +NS_IMPL_ADDREF(nsHTMLDelElement) -NS_IMPL_RELEASE(nsHTMLDel) +NS_IMPL_RELEASE(nsHTMLDelElement) nsresult -nsHTMLDel::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLDelElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLDelElementIID)) { @@ -114,9 +114,9 @@ nsHTMLDel::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLDel::CloneNode(nsIDOMNode** aReturn) +nsHTMLDelElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLDel* it = new nsHTMLDel(mInner.mTag); + nsHTMLDelElement* it = new nsHTMLDelElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -124,11 +124,11 @@ nsHTMLDel::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_STRING_ATTR(nsHTMLDel, Cite, cite, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLDel, DateTime, datetime, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLDelElement, Cite, cite, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLDelElement, DateTime, datetime, eSetAttrNotify_None) NS_IMETHODIMP -nsHTMLDel::StringToAttribute(nsIAtom* aAttribute, +nsHTMLDelElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -137,7 +137,7 @@ nsHTMLDel::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLDel::AttributeToString(nsIAtom* aAttribute, +nsHTMLDelElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -146,7 +146,7 @@ nsHTMLDel::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLDel::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLDelElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { // XXX write me @@ -154,7 +154,7 @@ nsHTMLDel::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLDel::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLDelElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/layout/html/content/src/nsHTMLDirectory.cpp b/mozilla/content/html/content/src/nsHTMLDirectoryElement.cpp similarity index 77% rename from mozilla/layout/html/content/src/nsHTMLDirectory.cpp rename to mozilla/content/html/content/src/nsHTMLDirectoryElement.cpp index 39340b485df..aea1a95b0a9 100644 --- a/mozilla/layout/html/content/src/nsHTMLDirectory.cpp +++ b/mozilla/content/html/content/src/nsHTMLDirectoryElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLDirectoryElementIID, NS_IDOMHTMLDIRECTORYELEMENT_IID); -class nsHTMLDirectory : public nsIDOMHTMLDirectoryElement, +class nsHTMLDirectoryElement : public nsIDOMHTMLDirectoryElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLDirectory(nsIAtom* aTag); - ~nsHTMLDirectory(); + nsHTMLDirectoryElement(nsIAtom* aTag); + ~nsHTMLDirectoryElement(); // nsISupports NS_DECL_ISUPPORTS @@ -71,35 +71,35 @@ protected: }; nsresult -NS_NewHTMLDirectory(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLDirectoryElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLDirectory(aTag); + nsIHTMLContent* it = new nsHTMLDirectoryElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLDirectory::nsHTMLDirectory(nsIAtom* aTag) +nsHTMLDirectoryElement::nsHTMLDirectoryElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLDirectory::~nsHTMLDirectory() +nsHTMLDirectoryElement::~nsHTMLDirectoryElement() { } -NS_IMPL_ADDREF(nsHTMLDirectory) +NS_IMPL_ADDREF(nsHTMLDirectoryElement) -NS_IMPL_RELEASE(nsHTMLDirectory) +NS_IMPL_RELEASE(nsHTMLDirectoryElement) nsresult -nsHTMLDirectory::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLDirectoryElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLDirectoryElementIID)) { @@ -112,9 +112,9 @@ nsHTMLDirectory::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLDirectory::CloneNode(nsIDOMNode** aReturn) +nsHTMLDirectoryElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLDirectory* it = new nsHTMLDirectory(mInner.mTag); + nsHTMLDirectoryElement* it = new nsHTMLDirectoryElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -122,10 +122,10 @@ nsHTMLDirectory::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_BOOL_ATTR(nsHTMLDirectory, Compact, compact, eSetAttrNotify_Reflow) +NS_IMPL_BOOL_ATTR(nsHTMLDirectoryElement, Compact, compact, eSetAttrNotify_Reflow) NS_IMETHODIMP -nsHTMLDirectory::StringToAttribute(nsIAtom* aAttribute, +nsHTMLDirectoryElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -134,7 +134,7 @@ nsHTMLDirectory::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLDirectory::AttributeToString(nsIAtom* aAttribute, +nsHTMLDirectoryElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -143,7 +143,7 @@ nsHTMLDirectory::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLDirectory::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLDirectoryElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { // XXX write me @@ -151,7 +151,7 @@ nsHTMLDirectory::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLDirectory::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLDirectoryElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/layout/html/content/src/nsHTMLDiv.cpp b/mozilla/content/html/content/src/nsHTMLDivElement.cpp similarity index 81% rename from mozilla/layout/html/content/src/nsHTMLDiv.cpp rename to mozilla/content/html/content/src/nsHTMLDivElement.cpp index a61b4d19854..28bee113049 100644 --- a/mozilla/layout/html/content/src/nsHTMLDiv.cpp +++ b/mozilla/content/html/content/src/nsHTMLDivElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -31,14 +31,14 @@ static NS_DEFINE_IID(kIDOMHTMLDivElementIID, NS_IDOMHTMLDIVELEMENT_IID); -class nsHTMLDiv : public nsIDOMHTMLDivElement, +class nsHTMLDivElement : public nsIDOMHTMLDivElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLDiv(nsIAtom* aTag); - ~nsHTMLDiv(); + nsHTMLDivElement(nsIAtom* aTag); + ~nsHTMLDivElement(); // nsISupports NS_DECL_ISUPPORTS @@ -73,35 +73,35 @@ protected: }; nsresult -NS_NewHTMLDiv(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLDivElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLDiv(aTag); + nsIHTMLContent* it = new nsHTMLDivElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLDiv::nsHTMLDiv(nsIAtom* aTag) +nsHTMLDivElement::nsHTMLDivElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLDiv::~nsHTMLDiv() +nsHTMLDivElement::~nsHTMLDivElement() { } -NS_IMPL_ADDREF(nsHTMLDiv) +NS_IMPL_ADDREF(nsHTMLDivElement) -NS_IMPL_RELEASE(nsHTMLDiv) +NS_IMPL_RELEASE(nsHTMLDivElement) nsresult -nsHTMLDiv::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLDivElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLDivElementIID)) { @@ -114,9 +114,9 @@ nsHTMLDiv::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLDiv::CloneNode(nsIDOMNode** aReturn) +nsHTMLDivElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLDiv* it = new nsHTMLDiv(mInner.mTag); + nsHTMLDivElement* it = new nsHTMLDivElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -124,10 +124,10 @@ nsHTMLDiv::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_STRING_ATTR(nsHTMLDiv, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLDivElement, Align, align, eSetAttrNotify_Reflow) NS_IMETHODIMP -nsHTMLDiv::StringToAttribute(nsIAtom* aAttribute, +nsHTMLDivElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -140,7 +140,7 @@ nsHTMLDiv::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLDiv::AttributeToString(nsIAtom* aAttribute, +nsHTMLDivElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -154,7 +154,7 @@ nsHTMLDiv::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLDiv::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLDivElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { // XXX write me @@ -162,7 +162,7 @@ nsHTMLDiv::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLDiv::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLDivElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/content/html/content/src/nsHTMLEmbedElement.cpp b/mozilla/content/html/content/src/nsHTMLEmbedElement.cpp new file mode 100644 index 00000000000..660906d04a2 --- /dev/null +++ b/mozilla/content/html/content/src/nsHTMLEmbedElement.cpp @@ -0,0 +1,181 @@ +/* -*- 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 "nsIDOMHTMLElement.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" + +// XXX define nsIDOMHTMLEmbedElement; add in nav attrs + +//static NS_DEFINE_IID(kIDOMHTMLEmbedElementIID, NS_IDOMHTMLEmbedELEMENT_IID); + +class nsHTMLEmbedElement : public nsIDOMHTMLElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLEmbedElement(nsIAtom* aTag); + ~nsHTMLEmbedElement(); + + // 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) + + // nsIDOMHTMLEmbedElement + + // 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_NewHTMLEmbedElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLEmbedElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLEmbedElement::nsHTMLEmbedElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLEmbedElement::~nsHTMLEmbedElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLEmbedElement) + +NS_IMPL_RELEASE(nsHTMLEmbedElement) + +nsresult +nsHTMLEmbedElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) +#if XXX + if (aIID.Equals(kIDOMHTMLEmbedElementIID)) { + nsIDOMHTMLEmbedElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } +#endif + return NS_NOINTERFACE; +} + +nsresult +nsHTMLEmbedElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLEmbedElement* it = new nsHTMLEmbedElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMETHODIMP +nsHTMLEmbedElement::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 +nsHTMLEmbedElement::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 +nsHTMLEmbedElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + mInner.MapImageAlignAttributeInto(aContext, aPresContext); + mInner.MapImageAttributesInto(aContext, aPresContext); + mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull); + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLEmbedElement::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/nsHTMLSelect.cpp b/mozilla/content/html/content/src/nsHTMLFontElement.cpp similarity index 77% rename from mozilla/layout/html/content/src/nsHTMLSelect.cpp rename to mozilla/content/html/content/src/nsHTMLFontElement.cpp index 3a0f6fb17d2..3daf247b8b2 100644 --- a/mozilla/layout/html/content/src/nsHTMLSelect.cpp +++ b/mozilla/content/html/content/src/nsHTMLFontElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLFontElementIID, NS_IDOMHTMLFONTELEMENT_IID); -class nsHTMLFont : public nsIDOMHTMLFontElement, +class nsHTMLFontElement : public nsIDOMHTMLFontElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLFont(nsIAtom* aTag); - ~nsHTMLFont(); + nsHTMLFontElement(nsIAtom* aTag); + ~nsHTMLFontElement(); // nsISupports NS_DECL_ISUPPORTS @@ -75,35 +75,35 @@ protected: }; nsresult -NS_NewHTMLFont(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLFontElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLFont(aTag); + nsIHTMLContent* it = new nsHTMLFontElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLFont::nsHTMLFont(nsIAtom* aTag) +nsHTMLFontElement::nsHTMLFontElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLFont::~nsHTMLFont() +nsHTMLFontElement::~nsHTMLFontElement() { } -NS_IMPL_ADDREF(nsHTMLFont) +NS_IMPL_ADDREF(nsHTMLFontElement) -NS_IMPL_RELEASE(nsHTMLFont) +NS_IMPL_RELEASE(nsHTMLFontElement) nsresult -nsHTMLFont::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLFontElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLFontElementIID)) { @@ -116,9 +116,9 @@ nsHTMLFont::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLFont::CloneNode(nsIDOMNode** aReturn) +nsHTMLFontElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLFont* it = new nsHTMLFont(mInner.mTag); + nsHTMLFontElement* it = new nsHTMLFontElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -126,12 +126,12 @@ nsHTMLFont::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_STRING_ATTR(nsHTMLFont, Color, face, eSetAttrNotify_Render) -NS_IMPL_STRING_ATTR(nsHTMLFont, Face, face, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLFont, Size, size, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLFontElement, Color, face, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLFontElement, Face, face, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLFontElement, Size, size, eSetAttrNotify_Reflow) NS_IMETHODIMP -nsHTMLFont::StringToAttribute(nsIAtom* aAttribute, +nsHTMLFontElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -140,7 +140,7 @@ nsHTMLFont::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLFont::AttributeToString(nsIAtom* aAttribute, +nsHTMLFontElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -149,7 +149,7 @@ nsHTMLFont::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLFont::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLFontElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { // XXX write me @@ -157,7 +157,7 @@ nsHTMLFont::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLFont::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLFontElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/content/html/content/src/nsHTMLFormElement.cpp b/mozilla/content/html/content/src/nsHTMLFormElement.cpp new file mode 100644 index 00000000000..c0e070be8e2 --- /dev/null +++ b/mozilla/content/html/content/src/nsHTMLFormElement.cpp @@ -0,0 +1,206 @@ +/* -*- 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 "nsIDOMHTMLFormElement.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(kIDOMHTMLFormElementIID, NS_IDOMHTMLFORMELEMENT_IID); + +class nsHTMLFormElement : public nsIDOMHTMLFormElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLFormElement(nsIAtom* aTag); + ~nsHTMLFormElement(); + + // 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) + + // nsIDOMHTMLFormElement + NS_IMETHOD GetElements(nsIDOMHTMLCollection** aElements); + NS_IMETHOD GetName(nsString& aName); + NS_IMETHOD GetAcceptCharset(nsString& aAcceptCharset); + NS_IMETHOD SetAcceptCharset(const nsString& aAcceptCharset); + NS_IMETHOD GetAction(nsString& aAction); + NS_IMETHOD SetAction(const nsString& aAction); + NS_IMETHOD GetEnctype(nsString& aEnctype); + NS_IMETHOD SetEnctype(const nsString& aEnctype); + NS_IMETHOD GetMethod(nsString& aMethod); + NS_IMETHOD SetMethod(const nsString& aMethod); + NS_IMETHOD GetTarget(nsString& aTarget); + NS_IMETHOD SetTarget(const nsString& aTarget); + NS_IMETHOD Reset(); + NS_IMETHOD Submit(); + + // 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_NewHTMLFormElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLFormElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLFormElement::nsHTMLFormElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLFormElement::~nsHTMLFormElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLFormElement) + +NS_IMPL_RELEASE(nsHTMLFormElement) + +nsresult +nsHTMLFormElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLFormElementIID)) { + nsIDOMHTMLFormElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLFormElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLFormElement* it = new nsHTMLFormElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMETHODIMP +nsHTMLFormElement::GetElements(nsIDOMHTMLCollection** aResult) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLFormElement::GetName(nsString& aValue) +{ + return mInner.GetAttribute(nsHTMLAtoms::name, aValue); +} + +NS_IMPL_STRING_ATTR(nsHTMLFormElement, AcceptCharset, acceptcharset, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLFormElement, Action, action, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLFormElement, Enctype, enctype, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLFormElement, Method, method, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLFormElement, Target, target, eSetAttrNotify_None) + +NS_IMETHODIMP +nsHTMLFormElement::Reset() +{ + // XXX + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLFormElement::Submit() +{ + // XXX + return NS_OK; +} + + +NS_IMETHODIMP +nsHTMLFormElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLFormElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLFormElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLFormElement::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/nsHTMLHR.cpp b/mozilla/content/html/content/src/nsHTMLHRElement.cpp similarity index 83% rename from mozilla/layout/html/content/src/nsHTMLHR.cpp rename to mozilla/content/html/content/src/nsHTMLHRElement.cpp index e1facf2f024..6c6c4f8fcbe 100644 --- a/mozilla/layout/html/content/src/nsHTMLHR.cpp +++ b/mozilla/content/html/content/src/nsHTMLHRElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLHRElementIID, NS_IDOMHTMLHRELEMENT_IID); -class nsHTMLHR : public nsIDOMHTMLHRElement, +class nsHTMLHRElement : public nsIDOMHTMLHRElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLHR(nsIAtom* aTag); - ~nsHTMLHR(); + nsHTMLHRElement(nsIAtom* aTag); + ~nsHTMLHRElement(); // nsISupports NS_DECL_ISUPPORTS @@ -77,35 +77,35 @@ protected: }; nsresult -NS_NewHTMLHR(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLHRElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLHR(aTag); + nsIHTMLContent* it = new nsHTMLHRElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLHR::nsHTMLHR(nsIAtom* aTag) +nsHTMLHRElement::nsHTMLHRElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLHR::~nsHTMLHR() +nsHTMLHRElement::~nsHTMLHRElement() { } -NS_IMPL_ADDREF(nsHTMLHR) +NS_IMPL_ADDREF(nsHTMLHRElement) -NS_IMPL_RELEASE(nsHTMLHR) +NS_IMPL_RELEASE(nsHTMLHRElement) nsresult -nsHTMLHR::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLHRElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLHRElementIID)) { @@ -118,9 +118,9 @@ nsHTMLHR::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLHR::CloneNode(nsIDOMNode** aReturn) +nsHTMLHRElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLHR* it = new nsHTMLHR(mInner.mTag); + nsHTMLHRElement* it = new nsHTMLHRElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -128,10 +128,10 @@ nsHTMLHR::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_STRING_ATTR(nsHTMLHR, Align, align, eSetAttrNotify_Reflow) -NS_IMPL_BOOL_ATTR(nsHTMLHR, NoShade, noshade, eSetAttrNotify_Render) -NS_IMPL_STRING_ATTR(nsHTMLHR, Size, size, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLHR, Width, width, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLHRElement, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_BOOL_ATTR(nsHTMLHRElement, NoShade, noshade, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLHRElement, Size, size, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLHRElement, Width, width, eSetAttrNotify_Reflow) static nsHTMLGenericContent::EnumTable kAlignTable[] = { { "left", NS_STYLE_TEXT_ALIGN_LEFT }, @@ -141,7 +141,7 @@ static nsHTMLGenericContent::EnumTable kAlignTable[] = { }; NS_IMETHODIMP -nsHTMLHR::StringToAttribute(nsIAtom* aAttribute, +nsHTMLHRElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -167,7 +167,7 @@ nsHTMLHR::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLHR::AttributeToString(nsIAtom* aAttribute, +nsHTMLHRElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -181,7 +181,7 @@ nsHTMLHR::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLHR::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLHRElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { if (nsnull != mInner.mAttributes) { @@ -211,7 +211,7 @@ nsHTMLHR::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLHR::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLHRElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/content/html/content/src/nsHTMLHeadElement.cpp b/mozilla/content/html/content/src/nsHTMLHeadElement.cpp new file mode 100644 index 00000000000..1e8ab45bd27 --- /dev/null +++ b/mozilla/content/html/content/src/nsHTMLHeadElement.cpp @@ -0,0 +1,159 @@ +/* -*- 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 "nsIDOMHTMLHeadElement.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(kIDOMHTMLHeadElementIID, NS_IDOMHTMLHEADELEMENT_IID); + +class nsHTMLHeadElement : public nsIDOMHTMLHeadElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLHeadElement(nsIAtom* aTag); + ~nsHTMLHeadElement(); + + // 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) + + // nsIDOMHTMLHeadElement + NS_IMETHOD GetProfile(nsString& aProfile); + NS_IMETHOD SetProfile(const nsString& aProfile); + + // 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_NewHTMLHeadElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLHeadElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLHeadElement::nsHTMLHeadElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLHeadElement::~nsHTMLHeadElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLHeadElement) + +NS_IMPL_RELEASE(nsHTMLHeadElement) + +nsresult +nsHTMLHeadElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLHeadElementIID)) { + nsIDOMHTMLHeadElement* tmp = this; + *aInstancePtr = (void*) tmp; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLHeadElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLHeadElement* it = new nsHTMLHeadElement(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(nsHTMLHeadElement, Profile, profile, eSetAttrNotify_None) + +NS_IMETHODIMP +nsHTMLHeadElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLHeadElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLHeadElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLHeadElement::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/nsHTMLHeading.cpp b/mozilla/content/html/content/src/nsHTMLHeadingElement.cpp similarity index 78% rename from mozilla/layout/html/content/src/nsHTMLHeading.cpp rename to mozilla/content/html/content/src/nsHTMLHeadingElement.cpp index 1582657cb1f..cb6ef14aff0 100644 --- a/mozilla/layout/html/content/src/nsHTMLHeading.cpp +++ b/mozilla/content/html/content/src/nsHTMLHeadingElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLHeadingElementIID, NS_IDOMHTMLHEADINGELEMENT_IID); -class nsHTMLHeading : public nsIDOMHTMLHeadingElement, +class nsHTMLHeadingElement : public nsIDOMHTMLHeadingElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLHeading(nsIAtom* aTag); - ~nsHTMLHeading(); + nsHTMLHeadingElement(nsIAtom* aTag); + ~nsHTMLHeadingElement(); // nsISupports NS_DECL_ISUPPORTS @@ -71,35 +71,35 @@ protected: }; nsresult -NS_NewHTMLHeading(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLHeadingElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLHeading(aTag); + nsIHTMLContent* it = new nsHTMLHeadingElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLHeading::nsHTMLHeading(nsIAtom* aTag) +nsHTMLHeadingElement::nsHTMLHeadingElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLHeading::~nsHTMLHeading() +nsHTMLHeadingElement::~nsHTMLHeadingElement() { } -NS_IMPL_ADDREF(nsHTMLHeading) +NS_IMPL_ADDREF(nsHTMLHeadingElement) -NS_IMPL_RELEASE(nsHTMLHeading) +NS_IMPL_RELEASE(nsHTMLHeadingElement) nsresult -nsHTMLHeading::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLHeadingElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLHeadingElementIID)) { @@ -112,9 +112,9 @@ nsHTMLHeading::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLHeading::CloneNode(nsIDOMNode** aReturn) +nsHTMLHeadingElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLHeading* it = new nsHTMLHeading(mInner.mTag); + nsHTMLHeadingElement* it = new nsHTMLHeadingElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -122,10 +122,10 @@ nsHTMLHeading::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_STRING_ATTR(nsHTMLHeading, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLHeadingElement, Align, align, eSetAttrNotify_Reflow) NS_IMETHODIMP -nsHTMLHeading::StringToAttribute(nsIAtom* aAttribute, +nsHTMLHeadingElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -134,7 +134,7 @@ nsHTMLHeading::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLHeading::AttributeToString(nsIAtom* aAttribute, +nsHTMLHeadingElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -143,7 +143,7 @@ nsHTMLHeading::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLHeading::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLHeadingElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { // XXX write me @@ -151,7 +151,7 @@ nsHTMLHeading::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLHeading::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLHeadingElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/layout/html/content/src/nsHTMLHtml.cpp b/mozilla/content/html/content/src/nsHTMLHtmlElement.cpp similarity index 79% rename from mozilla/layout/html/content/src/nsHTMLHtml.cpp rename to mozilla/content/html/content/src/nsHTMLHtmlElement.cpp index 55a7fe92ab8..6ed7c41f22d 100644 --- a/mozilla/layout/html/content/src/nsHTMLHtml.cpp +++ b/mozilla/content/html/content/src/nsHTMLHtmlElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLHtmlElementIID, NS_IDOMHTMLHTMLELEMENT_IID); -class nsHTMLHtml : public nsIDOMHTMLHtmlElement, +class nsHTMLHtmlElement : public nsIDOMHTMLHtmlElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLHtml(nsIAtom* aTag); - ~nsHTMLHtml(); + nsHTMLHtmlElement(nsIAtom* aTag); + ~nsHTMLHtmlElement(); // nsISupports NS_DECL_ISUPPORTS @@ -71,35 +71,35 @@ protected: }; nsresult -NS_NewHTMLHtml(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLHtmlElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLHtml(aTag); + nsIHTMLContent* it = new nsHTMLHtmlElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLHtml::nsHTMLHtml(nsIAtom* aTag) +nsHTMLHtmlElement::nsHTMLHtmlElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLHtml::~nsHTMLHtml() +nsHTMLHtmlElement::~nsHTMLHtmlElement() { } -NS_IMPL_ADDREF(nsHTMLHtml) +NS_IMPL_ADDREF(nsHTMLHtmlElement) -NS_IMPL_RELEASE(nsHTMLHtml) +NS_IMPL_RELEASE(nsHTMLHtmlElement) nsresult -nsHTMLHtml::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLHtmlElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLHtmlElementIID)) { @@ -112,9 +112,9 @@ nsHTMLHtml::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLHtml::CloneNode(nsIDOMNode** aReturn) +nsHTMLHtmlElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLHtml* it = new nsHTMLHtml(mInner.mTag); + nsHTMLHtmlElement* it = new nsHTMLHtmlElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -122,10 +122,10 @@ nsHTMLHtml::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_STRING_ATTR(nsHTMLHtml, Version, version, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLHtmlElement, Version, version, eSetAttrNotify_None) NS_IMETHODIMP -nsHTMLHtml::StringToAttribute(nsIAtom* aAttribute, +nsHTMLHtmlElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -133,7 +133,7 @@ nsHTMLHtml::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLHtml::AttributeToString(nsIAtom* aAttribute, +nsHTMLHtmlElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -141,14 +141,14 @@ nsHTMLHtml::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLHtml::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLHtmlElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { return NS_OK; } NS_IMETHODIMP -nsHTMLHtml::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLHtmlElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/layout/html/content/src/nsHTMLInput.cpp b/mozilla/content/html/content/src/nsHTMLInputElement.cpp similarity index 70% rename from mozilla/layout/html/content/src/nsHTMLInput.cpp rename to mozilla/content/html/content/src/nsHTMLInputElement.cpp index 4c5fc79bf94..bfbdcebec5e 100644 --- a/mozilla/layout/html/content/src/nsHTMLInput.cpp +++ b/mozilla/content/html/content/src/nsHTMLInputElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -31,14 +31,14 @@ static NS_DEFINE_IID(kIDOMHTMLInputElementIID, NS_IDOMHTMLINPUTELEMENT_IID); -class nsHTMLInput : public nsIDOMHTMLInputElement, +class nsHTMLInputElement : public nsIDOMHTMLInputElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLInput(nsIAtom* aTag); - ~nsHTMLInput(); + nsHTMLInputElement(nsIAtom* aTag); + ~nsHTMLInputElement(); // nsISupports NS_DECL_ISUPPORTS @@ -109,35 +109,35 @@ protected: }; nsresult -NS_NewHTMLInput(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLInputElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLInput(aTag); + nsIHTMLContent* it = new nsHTMLInputElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLInput::nsHTMLInput(nsIAtom* aTag) +nsHTMLInputElement::nsHTMLInputElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLInput::~nsHTMLInput() +nsHTMLInputElement::~nsHTMLInputElement() { } -NS_IMPL_ADDREF(nsHTMLInput) +NS_IMPL_ADDREF(nsHTMLInputElement) -NS_IMPL_RELEASE(nsHTMLInput) +NS_IMPL_RELEASE(nsHTMLInputElement) nsresult -nsHTMLInput::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLInputElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLInputElementIID)) { @@ -150,9 +150,9 @@ nsHTMLInput::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLInput::CloneNode(nsIDOMNode** aReturn) +nsHTMLInputElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLInput* it = new nsHTMLInput(mInner.mTag); + nsHTMLInputElement* it = new nsHTMLInputElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -161,66 +161,66 @@ nsHTMLInput::CloneNode(nsIDOMNode** aReturn) } NS_IMETHODIMP -nsHTMLInput::GetForm(nsIDOMHTMLFormElement** aForm) +nsHTMLInputElement::GetForm(nsIDOMHTMLFormElement** aForm) { *aForm = nsnull;/* XXX */ return NS_OK; } -NS_IMPL_STRING_ATTR(nsHTMLInput, DefaultValue, defaultvalue, eSetAttrNotify_None) -NS_IMPL_BOOL_ATTR(nsHTMLInput, DefaultChecked, defaultchecked, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLInput, Accept, accept, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLInput, AccessKey, accesskey, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLInput, Align, align, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLInput, Alt, alt, eSetAttrNotify_None) -NS_IMPL_BOOL_ATTR(nsHTMLInput, Checked, checked, eSetAttrNotify_Render) -NS_IMPL_BOOL_ATTR(nsHTMLInput, Disabled, disabled, eSetAttrNotify_Render) -NS_IMPL_INT_ATTR(nsHTMLInput, MaxLength, maxlength, eSetAttrNotify_Render) -NS_IMPL_STRING_ATTR(nsHTMLInput, Name, name, eSetAttrNotify_Restart) -NS_IMPL_BOOL_ATTR(nsHTMLInput, ReadOnly, readonly, eSetAttrNotify_Render) -NS_IMPL_STRING_ATTR(nsHTMLInput, Size, size, eSetAttrNotify_Render) -NS_IMPL_STRING_ATTR(nsHTMLInput, Src, src, eSetAttrNotify_Render) -NS_IMPL_INT_ATTR(nsHTMLInput, TabIndex, tabindex, eSetAttrNotify_Render) -NS_IMPL_STRING_ATTR(nsHTMLInput, UseMap, usemap, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLInput, Value, value, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLInputElement, DefaultValue, defaultvalue, eSetAttrNotify_None) +NS_IMPL_BOOL_ATTR(nsHTMLInputElement, DefaultChecked, defaultchecked, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLInputElement, Accept, accept, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLInputElement, AccessKey, accesskey, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLInputElement, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLInputElement, Alt, alt, eSetAttrNotify_None) +NS_IMPL_BOOL_ATTR(nsHTMLInputElement, Checked, checked, eSetAttrNotify_Render) +NS_IMPL_BOOL_ATTR(nsHTMLInputElement, Disabled, disabled, eSetAttrNotify_Render) +NS_IMPL_INT_ATTR(nsHTMLInputElement, MaxLength, maxlength, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLInputElement, Name, name, eSetAttrNotify_Restart) +NS_IMPL_BOOL_ATTR(nsHTMLInputElement, ReadOnly, readonly, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLInputElement, Size, size, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLInputElement, Src, src, eSetAttrNotify_Render) +NS_IMPL_INT_ATTR(nsHTMLInputElement, TabIndex, tabindex, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLInputElement, UseMap, usemap, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLInputElement, Value, value, eSetAttrNotify_Render) NS_IMETHODIMP -nsHTMLInput::GetType(nsString& aValue) +nsHTMLInputElement::GetType(nsString& aValue) { mInner.GetAttribute(nsHTMLAtoms::type, aValue); return NS_OK; } NS_IMETHODIMP -nsHTMLInput::Blur() +nsHTMLInputElement::Blur() { // XXX write me return NS_OK; } NS_IMETHODIMP -nsHTMLInput::Focus() +nsHTMLInputElement::Focus() { // XXX write me return NS_OK; } NS_IMETHODIMP -nsHTMLInput::Select() +nsHTMLInputElement::Select() { // XXX write me return NS_OK; } NS_IMETHODIMP -nsHTMLInput::Click() +nsHTMLInputElement::Click() { // XXX write me return NS_OK; } NS_IMETHODIMP -nsHTMLInput::StringToAttribute(nsIAtom* aAttribute, +nsHTMLInputElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -229,7 +229,7 @@ nsHTMLInput::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLInput::AttributeToString(nsIAtom* aAttribute, +nsHTMLInputElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -238,7 +238,7 @@ nsHTMLInput::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLInput::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLInputElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { // XXX align @@ -246,7 +246,7 @@ nsHTMLInput::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLInput::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLInputElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/layout/html/content/src/nsHTMLIns.cpp b/mozilla/content/html/content/src/nsHTMLInsElement.cpp similarity index 78% rename from mozilla/layout/html/content/src/nsHTMLIns.cpp rename to mozilla/content/html/content/src/nsHTMLInsElement.cpp index 4c3e04cca9f..bdd8b1fb01a 100644 --- a/mozilla/layout/html/content/src/nsHTMLIns.cpp +++ b/mozilla/content/html/content/src/nsHTMLInsElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLInsElementIID, NS_IDOMHTMLINSELEMENT_IID); -class nsHTMLIns : public nsIDOMHTMLInsElement, +class nsHTMLInsElement : public nsIDOMHTMLInsElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLIns(nsIAtom* aTag); - ~nsHTMLIns(); + nsHTMLInsElement(nsIAtom* aTag); + ~nsHTMLInsElement(); // nsISupports NS_DECL_ISUPPORTS @@ -73,35 +73,35 @@ protected: }; nsresult -NS_NewHTMLIns(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLInsElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLIns(aTag); + nsIHTMLContent* it = new nsHTMLInsElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLIns::nsHTMLIns(nsIAtom* aTag) +nsHTMLInsElement::nsHTMLInsElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLIns::~nsHTMLIns() +nsHTMLInsElement::~nsHTMLInsElement() { } -NS_IMPL_ADDREF(nsHTMLIns) +NS_IMPL_ADDREF(nsHTMLInsElement) -NS_IMPL_RELEASE(nsHTMLIns) +NS_IMPL_RELEASE(nsHTMLInsElement) nsresult -nsHTMLIns::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLInsElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLInsElementIID)) { @@ -114,9 +114,9 @@ nsHTMLIns::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLIns::CloneNode(nsIDOMNode** aReturn) +nsHTMLInsElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLIns* it = new nsHTMLIns(mInner.mTag); + nsHTMLInsElement* it = new nsHTMLInsElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -124,11 +124,11 @@ nsHTMLIns::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_STRING_ATTR(nsHTMLIns, Cite, cite, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLIns, DateTime, datetime, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLInsElement, Cite, cite, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLInsElement, DateTime, datetime, eSetAttrNotify_None) NS_IMETHODIMP -nsHTMLIns::StringToAttribute(nsIAtom* aAttribute, +nsHTMLInsElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -137,7 +137,7 @@ nsHTMLIns::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLIns::AttributeToString(nsIAtom* aAttribute, +nsHTMLInsElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -146,7 +146,7 @@ nsHTMLIns::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLIns::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLInsElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { // XXX write me @@ -154,7 +154,7 @@ nsHTMLIns::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLIns::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLInsElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/layout/html/content/src/nsHTMLLI.cpp b/mozilla/content/html/content/src/nsHTMLLIElement.cpp similarity index 79% rename from mozilla/layout/html/content/src/nsHTMLLI.cpp rename to mozilla/content/html/content/src/nsHTMLLIElement.cpp index 130feee53b8..80e2d2ebabd 100644 --- a/mozilla/layout/html/content/src/nsHTMLLI.cpp +++ b/mozilla/content/html/content/src/nsHTMLLIElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLLIElementIID, NS_IDOMHTMLLIELEMENT_IID); -class nsHTMLLI : public nsIDOMHTMLLIElement, +class nsHTMLLIElement : public nsIDOMHTMLLIElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLLI(nsIAtom* aTag); - ~nsHTMLLI(); + nsHTMLLIElement(nsIAtom* aTag); + ~nsHTMLLIElement(); // nsISupports NS_DECL_ISUPPORTS @@ -73,35 +73,35 @@ protected: }; nsresult -NS_NewHTMLLI(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLLIElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLLI(aTag); + nsIHTMLContent* it = new nsHTMLLIElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLLI::nsHTMLLI(nsIAtom* aTag) +nsHTMLLIElement::nsHTMLLIElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLLI::~nsHTMLLI() +nsHTMLLIElement::~nsHTMLLIElement() { } -NS_IMPL_ADDREF(nsHTMLLI) +NS_IMPL_ADDREF(nsHTMLLIElement) -NS_IMPL_RELEASE(nsHTMLLI) +NS_IMPL_RELEASE(nsHTMLLIElement) nsresult -nsHTMLLI::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLLIElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLLIElementIID)) { @@ -114,9 +114,9 @@ nsHTMLLI::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLLI::CloneNode(nsIDOMNode** aReturn) +nsHTMLLIElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLLI* it = new nsHTMLLI(mInner.mTag); + nsHTMLLIElement* it = new nsHTMLLIElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -124,11 +124,11 @@ nsHTMLLI::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_STRING_ATTR(nsHTMLLI, Type, type, eSetAttrNotify_Reflow) -NS_IMPL_INT_ATTR(nsHTMLLI, Value, value, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLLIElement, Type, type, eSetAttrNotify_Reflow) +NS_IMPL_INT_ATTR(nsHTMLLIElement, Value, value, eSetAttrNotify_Reflow) NS_IMETHODIMP -nsHTMLLI::StringToAttribute(nsIAtom* aAttribute, +nsHTMLLIElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -137,7 +137,7 @@ nsHTMLLI::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLLI::AttributeToString(nsIAtom* aAttribute, +nsHTMLLIElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -146,7 +146,7 @@ nsHTMLLI::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLLI::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLLIElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { // XXX write me @@ -154,7 +154,7 @@ nsHTMLLI::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLLI::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLLIElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/layout/html/content/src/nsHTMLLink.cpp b/mozilla/content/html/content/src/nsHTMLLinkElement.cpp similarity index 73% rename from mozilla/layout/html/content/src/nsHTMLLink.cpp rename to mozilla/content/html/content/src/nsHTMLLinkElement.cpp index 49f57d8b995..3dfd93f064e 100644 --- a/mozilla/layout/html/content/src/nsHTMLLink.cpp +++ b/mozilla/content/html/content/src/nsHTMLLinkElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLLinkElementIID, NS_IDOMHTMLLINKELEMENT_IID); -class nsHTMLLink : public nsIDOMHTMLLinkElement, +class nsHTMLLinkElement : public nsIDOMHTMLLinkElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLLink(nsIAtom* aTag); - ~nsHTMLLink(); + nsHTMLLinkElement(nsIAtom* aTag); + ~nsHTMLLinkElement(); // nsISupports NS_DECL_ISUPPORTS @@ -87,35 +87,35 @@ protected: }; nsresult -NS_NewHTMLLink(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLLinkElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLLink(aTag); + nsIHTMLContent* it = new nsHTMLLinkElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLLink::nsHTMLLink(nsIAtom* aTag) +nsHTMLLinkElement::nsHTMLLinkElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLLink::~nsHTMLLink() +nsHTMLLinkElement::~nsHTMLLinkElement() { } -NS_IMPL_ADDREF(nsHTMLLink) +NS_IMPL_ADDREF(nsHTMLLinkElement) -NS_IMPL_RELEASE(nsHTMLLink) +NS_IMPL_RELEASE(nsHTMLLinkElement) nsresult -nsHTMLLink::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLLinkElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLLinkElementIID)) { @@ -128,9 +128,9 @@ nsHTMLLink::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLLink::CloneNode(nsIDOMNode** aReturn) +nsHTMLLinkElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLLink* it = new nsHTMLLink(mInner.mTag); + nsHTMLLinkElement* it = new nsHTMLLinkElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -138,18 +138,18 @@ nsHTMLLink::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_BOOL_ATTR(nsHTMLLink, Disabled, disabled, eSetAttrNotify_Restart) -NS_IMPL_STRING_ATTR(nsHTMLLink, Charset, charset, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLLink, Href, href, eSetAttrNotify_Restart) -NS_IMPL_STRING_ATTR(nsHTMLLink, Hreflang, hreflang, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLLink, Media, media, eSetAttrNotify_Restart) -NS_IMPL_STRING_ATTR(nsHTMLLink, Rel, rel, eSetAttrNotify_Restart) -NS_IMPL_STRING_ATTR(nsHTMLLink, Rev, rev, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLLink, Target, target, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLLink, Type, type, eSetAttrNotify_Restart) +NS_IMPL_BOOL_ATTR(nsHTMLLinkElement, Disabled, disabled, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLLinkElement, Charset, charset, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLLinkElement, Href, href, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLLinkElement, Hreflang, hreflang, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLLinkElement, Media, media, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLLinkElement, Rel, rel, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLLinkElement, Rev, rev, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLLinkElement, Target, target, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLLinkElement, Type, type, eSetAttrNotify_Restart) NS_IMETHODIMP -nsHTMLLink::StringToAttribute(nsIAtom* aAttribute, +nsHTMLLinkElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -157,7 +157,7 @@ nsHTMLLink::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLLink::AttributeToString(nsIAtom* aAttribute, +nsHTMLLinkElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -165,14 +165,14 @@ nsHTMLLink::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLLink::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLLinkElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { return NS_OK; } NS_IMETHODIMP -nsHTMLLink::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLLinkElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/layout/html/content/src/nsHTMLMap.cpp b/mozilla/content/html/content/src/nsHTMLMapElement.cpp similarity index 78% rename from mozilla/layout/html/content/src/nsHTMLMap.cpp rename to mozilla/content/html/content/src/nsHTMLMapElement.cpp index 97bcc757387..5668db1c1b0 100644 --- a/mozilla/layout/html/content/src/nsHTMLMap.cpp +++ b/mozilla/content/html/content/src/nsHTMLMapElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLMapElementIID, NS_IDOMHTMLMAPELEMENT_IID); -class nsHTMLMap : public nsIDOMHTMLMapElement, +class nsHTMLMapElement : public nsIDOMHTMLMapElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLMap(nsIAtom* aTag); - ~nsHTMLMap(); + nsHTMLMapElement(nsIAtom* aTag); + ~nsHTMLMapElement(); // nsISupports NS_DECL_ISUPPORTS @@ -73,35 +73,35 @@ protected: }; nsresult -NS_NewHTMLMap(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLMapElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLMap(aTag); + nsIHTMLContent* it = new nsHTMLMapElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLMap::nsHTMLMap(nsIAtom* aTag) +nsHTMLMapElement::nsHTMLMapElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLMap::~nsHTMLMap() +nsHTMLMapElement::~nsHTMLMapElement() { } -NS_IMPL_ADDREF(nsHTMLMap) +NS_IMPL_ADDREF(nsHTMLMapElement) -NS_IMPL_RELEASE(nsHTMLMap) +NS_IMPL_RELEASE(nsHTMLMapElement) nsresult -nsHTMLMap::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLMapElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLMapElementIID)) { @@ -114,9 +114,9 @@ nsHTMLMap::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLMap::CloneNode(nsIDOMNode** aReturn) +nsHTMLMapElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLMap* it = new nsHTMLMap(mInner.mTag); + nsHTMLMapElement* it = new nsHTMLMapElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -125,23 +125,23 @@ nsHTMLMap::CloneNode(nsIDOMNode** aReturn) } NS_IMETHODIMP -nsHTMLMap::GetAreas(nsIDOMHTMLCollection** aAreas) +nsHTMLMapElement::GetAreas(nsIDOMHTMLCollection** aAreas) { *aAreas = nsnull; return NS_ERROR_OUT_OF_MEMORY;/* XXX */ } NS_IMETHODIMP -nsHTMLMap::SetAreas(nsIDOMHTMLCollection* aAreas) +nsHTMLMapElement::SetAreas(nsIDOMHTMLCollection* aAreas) { // XXX write me return NS_OK; } -NS_IMPL_STRING_ATTR(nsHTMLMap, Name, name, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLMapElement, Name, name, eSetAttrNotify_Restart) NS_IMETHODIMP -nsHTMLMap::StringToAttribute(nsIAtom* aAttribute, +nsHTMLMapElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -150,7 +150,7 @@ nsHTMLMap::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLMap::AttributeToString(nsIAtom* aAttribute, +nsHTMLMapElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -159,7 +159,7 @@ nsHTMLMap::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLMap::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLMapElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { // XXX write me @@ -167,7 +167,7 @@ nsHTMLMap::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLMap::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLMapElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/layout/html/content/src/nsHTMLMenu.cpp b/mozilla/content/html/content/src/nsHTMLMenuElement.cpp similarity index 79% rename from mozilla/layout/html/content/src/nsHTMLMenu.cpp rename to mozilla/content/html/content/src/nsHTMLMenuElement.cpp index 4365ed2e334..1880cb63c50 100644 --- a/mozilla/layout/html/content/src/nsHTMLMenu.cpp +++ b/mozilla/content/html/content/src/nsHTMLMenuElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLMenuElementIID, NS_IDOMHTMLMENUELEMENT_IID); -class nsHTMLMenu : public nsIDOMHTMLMenuElement, +class nsHTMLMenuElement : public nsIDOMHTMLMenuElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLMenu(nsIAtom* aTag); - ~nsHTMLMenu(); + nsHTMLMenuElement(nsIAtom* aTag); + ~nsHTMLMenuElement(); // nsISupports NS_DECL_ISUPPORTS @@ -71,35 +71,35 @@ protected: }; nsresult -NS_NewHTMLMenu(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLMenuElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLMenu(aTag); + nsIHTMLContent* it = new nsHTMLMenuElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLMenu::nsHTMLMenu(nsIAtom* aTag) +nsHTMLMenuElement::nsHTMLMenuElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLMenu::~nsHTMLMenu() +nsHTMLMenuElement::~nsHTMLMenuElement() { } -NS_IMPL_ADDREF(nsHTMLMenu) +NS_IMPL_ADDREF(nsHTMLMenuElement) -NS_IMPL_RELEASE(nsHTMLMenu) +NS_IMPL_RELEASE(nsHTMLMenuElement) nsresult -nsHTMLMenu::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLMenuElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLMenuElementIID)) { @@ -112,9 +112,9 @@ nsHTMLMenu::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLMenu::CloneNode(nsIDOMNode** aReturn) +nsHTMLMenuElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLMenu* it = new nsHTMLMenu(mInner.mTag); + nsHTMLMenuElement* it = new nsHTMLMenuElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -122,10 +122,10 @@ nsHTMLMenu::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_BOOL_ATTR(nsHTMLMenu, Compact, compact, eSetAttrNotify_Reflow) +NS_IMPL_BOOL_ATTR(nsHTMLMenuElement, Compact, compact, eSetAttrNotify_Reflow) NS_IMETHODIMP -nsHTMLMenu::StringToAttribute(nsIAtom* aAttribute, +nsHTMLMenuElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -134,7 +134,7 @@ nsHTMLMenu::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLMenu::AttributeToString(nsIAtom* aAttribute, +nsHTMLMenuElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -143,7 +143,7 @@ nsHTMLMenu::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLMenu::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLMenuElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { // XXX write me @@ -151,7 +151,7 @@ nsHTMLMenu::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLMenu::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLMenuElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/content/html/content/src/nsHTMLMetaElement.cpp b/mozilla/content/html/content/src/nsHTMLMetaElement.cpp new file mode 100644 index 00000000000..21c93653bdb --- /dev/null +++ b/mozilla/content/html/content/src/nsHTMLMetaElement.cpp @@ -0,0 +1,168 @@ +/* -*- 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 "nsIDOMHTMLMetaElement.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(kIDOMHTMLMetaElementIID, NS_IDOMHTMLMETAELEMENT_IID); + +class nsHTMLMetaElement : public nsIDOMHTMLMetaElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLMetaElement(nsIAtom* aTag); + ~nsHTMLMetaElement(); + + // 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) + + // nsIDOMHTMLMetaElement + NS_IMETHOD GetContent(nsString& aContent); + NS_IMETHOD SetContent(const nsString& aContent); + NS_IMETHOD GetHttpEquiv(nsString& aHttpEquiv); + NS_IMETHOD SetHttpEquiv(const nsString& aHttpEquiv); + NS_IMETHOD GetName(nsString& aName); + NS_IMETHOD SetName(const nsString& aName); + NS_IMETHOD GetScheme(nsString& aScheme); + NS_IMETHOD SetScheme(const nsString& aScheme); + + // 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_NewHTMLMetaElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLMetaElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLMetaElement::nsHTMLMetaElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLMetaElement::~nsHTMLMetaElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLMetaElement) + +NS_IMPL_RELEASE(nsHTMLMetaElement) + +nsresult +nsHTMLMetaElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLMetaElementIID)) { + nsIDOMHTMLMetaElement* tmp = this; + *aInstancePtr = (void*) tmp; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLMetaElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLMetaElement* it = new nsHTMLMetaElement(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(nsHTMLMetaElement, Content, content, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLMetaElement, HttpEquiv, httpEquiv, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLMetaElement, Name, name, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLMetaElement, Scheme, scheme, eSetAttrNotify_None) + +NS_IMETHODIMP +nsHTMLMetaElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLMetaElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLMetaElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLMetaElement::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/nsHTMLMod.cpp b/mozilla/content/html/content/src/nsHTMLModElement.cpp similarity index 78% rename from mozilla/layout/html/content/src/nsHTMLMod.cpp rename to mozilla/content/html/content/src/nsHTMLModElement.cpp index 7fe53ea4f5d..31f684098ba 100644 --- a/mozilla/layout/html/content/src/nsHTMLMod.cpp +++ b/mozilla/content/html/content/src/nsHTMLModElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLModElementIID, NS_IDOMHTMLMODELEMENT_IID); -class nsHTMLMod : public nsIDOMHTMLModElement, +class nsHTMLModElement : public nsIDOMHTMLModElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLMod(nsIAtom* aTag); - ~nsHTMLMod(); + nsHTMLModElement(nsIAtom* aTag); + ~nsHTMLModElement(); // nsISupports NS_DECL_ISUPPORTS @@ -73,35 +73,35 @@ protected: }; nsresult -NS_NewHTMLMod(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLModElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLMod(aTag); + nsIHTMLContent* it = new nsHTMLModElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLMod::nsHTMLMod(nsIAtom* aTag) +nsHTMLModElement::nsHTMLModElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLMod::~nsHTMLMod() +nsHTMLModElement::~nsHTMLModElement() { } -NS_IMPL_ADDREF(nsHTMLMod) +NS_IMPL_ADDREF(nsHTMLModElement) -NS_IMPL_RELEASE(nsHTMLMod) +NS_IMPL_RELEASE(nsHTMLModElement) nsresult -nsHTMLMod::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLModElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLModElementIID)) { @@ -114,9 +114,9 @@ nsHTMLMod::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLMod::CloneNode(nsIDOMNode** aReturn) +nsHTMLModElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLMod* it = new nsHTMLMod(mInner.mTag); + nsHTMLModElement* it = new nsHTMLModElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -124,11 +124,11 @@ nsHTMLMod::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_STRING_ATTR(nsHTMLMod, Cite, cite, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLMod, DateTime, datetime, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLModElement, Cite, cite, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLModElement, DateTime, datetime, eSetAttrNotify_None) NS_IMETHODIMP -nsHTMLMod::StringToAttribute(nsIAtom* aAttribute, +nsHTMLModElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -137,7 +137,7 @@ nsHTMLMod::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLMod::AttributeToString(nsIAtom* aAttribute, +nsHTMLModElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -146,7 +146,7 @@ nsHTMLMod::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLMod::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLModElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { // XXX write me @@ -154,7 +154,7 @@ nsHTMLMod::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLMod::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLModElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/layout/html/content/src/nsHTMLOList.cpp b/mozilla/content/html/content/src/nsHTMLOListElement.cpp similarity index 77% rename from mozilla/layout/html/content/src/nsHTMLOList.cpp rename to mozilla/content/html/content/src/nsHTMLOListElement.cpp index d476e9ccecf..206ab62f18c 100644 --- a/mozilla/layout/html/content/src/nsHTMLOList.cpp +++ b/mozilla/content/html/content/src/nsHTMLOListElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLOListElementIID, NS_IDOMHTMLOLISTELEMENT_IID); -class nsHTMLOList : public nsIDOMHTMLOListElement, +class nsHTMLOListElement : public nsIDOMHTMLOListElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLOList(nsIAtom* aTag); - ~nsHTMLOList(); + nsHTMLOListElement(nsIAtom* aTag); + ~nsHTMLOListElement(); // nsISupports NS_DECL_ISUPPORTS @@ -75,35 +75,35 @@ protected: }; nsresult -NS_NewHTMLOList(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLOListElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLOList(aTag); + nsIHTMLContent* it = new nsHTMLOListElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLOList::nsHTMLOList(nsIAtom* aTag) +nsHTMLOListElement::nsHTMLOListElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLOList::~nsHTMLOList() +nsHTMLOListElement::~nsHTMLOListElement() { } -NS_IMPL_ADDREF(nsHTMLOList) +NS_IMPL_ADDREF(nsHTMLOListElement) -NS_IMPL_RELEASE(nsHTMLOList) +NS_IMPL_RELEASE(nsHTMLOListElement) nsresult -nsHTMLOList::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLOListElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLOListElementIID)) { @@ -116,9 +116,9 @@ nsHTMLOList::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLOList::CloneNode(nsIDOMNode** aReturn) +nsHTMLOListElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLOList* it = new nsHTMLOList(mInner.mTag); + nsHTMLOListElement* it = new nsHTMLOListElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -126,12 +126,12 @@ nsHTMLOList::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_BOOL_ATTR(nsHTMLOList, Compact, compact, eSetAttrNotify_Reflow) -NS_IMPL_INT_ATTR(nsHTMLOList, Start, compact, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLOList, Type, compact, eSetAttrNotify_Reflow) +NS_IMPL_BOOL_ATTR(nsHTMLOListElement, Compact, compact, eSetAttrNotify_Reflow) +NS_IMPL_INT_ATTR(nsHTMLOListElement, Start, compact, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLOListElement, Type, compact, eSetAttrNotify_Reflow) NS_IMETHODIMP -nsHTMLOList::StringToAttribute(nsIAtom* aAttribute, +nsHTMLOListElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -140,7 +140,7 @@ nsHTMLOList::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLOList::AttributeToString(nsIAtom* aAttribute, +nsHTMLOListElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -149,7 +149,7 @@ nsHTMLOList::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLOList::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLOListElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { // XXX write me @@ -157,7 +157,7 @@ nsHTMLOList::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLOList::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLOListElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/content/html/content/src/nsHTMLObjectElement.cpp b/mozilla/content/html/content/src/nsHTMLObjectElement.cpp new file mode 100644 index 00000000000..8837ceed6d1 --- /dev/null +++ b/mozilla/content/html/content/src/nsHTMLObjectElement.cpp @@ -0,0 +1,244 @@ +/* -*- 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 "nsIDOMHTMLObjectElement.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(kIDOMHTMLObjectElementIID, NS_IDOMHTMLOBJECTELEMENT_IID); + +class nsHTMLObjectElement : public nsIDOMHTMLObjectElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLObjectElement(nsIAtom* aTag); + ~nsHTMLObjectElement(); + + // 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) + + // nsIDOMHTMLObjectElement + NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm); + NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm); + NS_IMETHOD GetCode(nsString& aCode); + NS_IMETHOD SetCode(const nsString& aCode); + NS_IMETHOD GetAlign(nsString& aAlign); + NS_IMETHOD SetAlign(const nsString& aAlign); + NS_IMETHOD GetArchive(nsString& aArchive); + NS_IMETHOD SetArchive(const nsString& aArchive); + NS_IMETHOD GetBorder(nsString& aBorder); + NS_IMETHOD SetBorder(const nsString& aBorder); + NS_IMETHOD GetCodeBase(nsString& aCodeBase); + NS_IMETHOD SetCodeBase(const nsString& aCodeBase); + NS_IMETHOD GetCodeType(nsString& aCodeType); + NS_IMETHOD SetCodeType(const nsString& aCodeType); + NS_IMETHOD GetData(nsString& aData); + NS_IMETHOD SetData(const nsString& aData); + NS_IMETHOD GetDeclare(PRBool* aDeclare); + NS_IMETHOD SetDeclare(PRBool aDeclare); + NS_IMETHOD GetHeight(nsString& aHeight); + NS_IMETHOD SetHeight(const nsString& aHeight); + NS_IMETHOD GetHspace(nsString& aHspace); + NS_IMETHOD SetHspace(const nsString& aHspace); + NS_IMETHOD GetName(nsString& aName); + NS_IMETHOD SetName(const nsString& aName); + NS_IMETHOD GetStandby(nsString& aStandby); + NS_IMETHOD SetStandby(const nsString& aStandby); + NS_IMETHOD GetTabIndex(PRInt32* aTabIndex); + NS_IMETHOD SetTabIndex(PRInt32 aTabIndex); + NS_IMETHOD GetType(nsString& aType); + NS_IMETHOD SetType(const nsString& aType); + 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_NewHTMLObjectElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLObjectElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLObjectElement::nsHTMLObjectElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLObjectElement::~nsHTMLObjectElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLObjectElement) + +NS_IMPL_RELEASE(nsHTMLObjectElement) + +nsresult +nsHTMLObjectElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLObjectElementIID)) { + nsIDOMHTMLObjectElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLObjectElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLObjectElement* it = new nsHTMLObjectElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMETHODIMP +nsHTMLObjectElement::GetForm(nsIDOMHTMLFormElement** aForm) +{ + *aForm = nsnull;/* XXX */ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLObjectElement::SetForm(nsIDOMHTMLFormElement* aForm) +{ + return NS_OK; +} + +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Code, code, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Archive, archive, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Border, border, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, CodeBase, codebase, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, CodeType, codetype, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Data, data, eSetAttrNotify_None) +NS_IMPL_BOOL_ATTR(nsHTMLObjectElement, Declare, declare, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Height, height, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Hspace, hspace, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Name, name, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Standby, standby, eSetAttrNotify_None) +NS_IMPL_INT_ATTR(nsHTMLObjectElement, TabIndex, tabindex, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Type, type, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, UseMap, usemap, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Vspace, vspace, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Width, width, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLObjectElement::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 +nsHTMLObjectElement::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 +nsHTMLObjectElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + mInner.MapImageAlignAttributeInto(aContext, aPresContext); + mInner.MapImageAttributesInto(aContext, aPresContext); + mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull); + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLObjectElement::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/nsHTMLOption.cpp b/mozilla/content/html/content/src/nsHTMLOptionElement.cpp similarity index 74% rename from mozilla/layout/html/content/src/nsHTMLOption.cpp rename to mozilla/content/html/content/src/nsHTMLOptionElement.cpp index a8a6b7c7c5e..cab9b6a3655 100644 --- a/mozilla/layout/html/content/src/nsHTMLOption.cpp +++ b/mozilla/content/html/content/src/nsHTMLOptionElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLOptionElementIID, NS_IDOMHTMLOPTIONELEMENT_IID); -class nsHTMLOption : public nsIDOMHTMLOptionElement, +class nsHTMLOptionElement : public nsIDOMHTMLOptionElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLOption(nsIAtom* aTag); - ~nsHTMLOption(); + nsHTMLOptionElement(nsIAtom* aTag); + ~nsHTMLOptionElement(); // nsISupports NS_DECL_ISUPPORTS @@ -85,35 +85,35 @@ protected: }; nsresult -NS_NewHTMLOption(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLOptionElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLOption(aTag); + nsIHTMLContent* it = new nsHTMLOptionElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLOption::nsHTMLOption(nsIAtom* aTag) +nsHTMLOptionElement::nsHTMLOptionElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLOption::~nsHTMLOption() +nsHTMLOptionElement::~nsHTMLOptionElement() { } -NS_IMPL_ADDREF(nsHTMLOption) +NS_IMPL_ADDREF(nsHTMLOptionElement) -NS_IMPL_RELEASE(nsHTMLOption) +NS_IMPL_RELEASE(nsHTMLOptionElement) nsresult -nsHTMLOption::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLOptionElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLOptionElementIID)) { @@ -126,9 +126,9 @@ nsHTMLOption::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLOption::CloneNode(nsIDOMNode** aReturn) +nsHTMLOptionElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLOption* it = new nsHTMLOption(mInner.mTag); + nsHTMLOptionElement* it = new nsHTMLOptionElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -137,22 +137,22 @@ nsHTMLOption::CloneNode(nsIDOMNode** aReturn) } NS_IMETHODIMP -nsHTMLOption::GetForm(nsIDOMHTMLFormElement** aForm) +nsHTMLOptionElement::GetForm(nsIDOMHTMLFormElement** aForm) { *aForm = nsnull;/* XXX */ return NS_OK; } -NS_IMPL_BOOL_ATTR(nsHTMLOption, DefaultSelected, defaultselected, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLOption, Text, text, eSetAttrNotify_Render) -NS_IMPL_INT_ATTR(nsHTMLOption, Index, index, eSetAttrNotify_None) -NS_IMPL_BOOL_ATTR(nsHTMLOption, Disabled, disabled, eSetAttrNotify_Render) -NS_IMPL_STRING_ATTR(nsHTMLOption, Label, label, eSetAttrNotify_Render) -NS_IMPL_BOOL_ATTR(nsHTMLOption, Selected, selected, eSetAttrNotify_Render) -NS_IMPL_STRING_ATTR(nsHTMLOption, Value, value, eSetAttrNotify_Render) +NS_IMPL_BOOL_ATTR(nsHTMLOptionElement, DefaultSelected, defaultselected, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLOptionElement, Text, text, eSetAttrNotify_Render) +NS_IMPL_INT_ATTR(nsHTMLOptionElement, Index, index, eSetAttrNotify_None) +NS_IMPL_BOOL_ATTR(nsHTMLOptionElement, Disabled, disabled, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLOptionElement, Label, label, eSetAttrNotify_Render) +NS_IMPL_BOOL_ATTR(nsHTMLOptionElement, Selected, selected, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLOptionElement, Value, value, eSetAttrNotify_Render) NS_IMETHODIMP -nsHTMLOption::StringToAttribute(nsIAtom* aAttribute, +nsHTMLOptionElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -161,7 +161,7 @@ nsHTMLOption::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLOption::AttributeToString(nsIAtom* aAttribute, +nsHTMLOptionElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -170,7 +170,7 @@ nsHTMLOption::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLOption::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLOptionElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { // XXX write me @@ -178,7 +178,7 @@ nsHTMLOption::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLOption::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLOptionElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/layout/html/content/src/nsHTMLParagraph.cpp b/mozilla/content/html/content/src/nsHTMLParagraphElement.cpp similarity index 79% rename from mozilla/layout/html/content/src/nsHTMLParagraph.cpp rename to mozilla/content/html/content/src/nsHTMLParagraphElement.cpp index 4878fbe3b69..fa3bffa68d9 100644 --- a/mozilla/layout/html/content/src/nsHTMLParagraph.cpp +++ b/mozilla/content/html/content/src/nsHTMLParagraphElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -31,14 +31,14 @@ static NS_DEFINE_IID(kIDOMHTMLParagraphElementIID, NS_IDOMHTMLPARAGRAPHELEMENT_IID); -class nsHTMLParagraph : public nsIDOMHTMLParagraphElement, +class nsHTMLParagraphElement : public nsIDOMHTMLParagraphElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLParagraph(nsIAtom* aTag); - ~nsHTMLParagraph(); + nsHTMLParagraphElement(nsIAtom* aTag); + ~nsHTMLParagraphElement(); // nsISupports NS_DECL_ISUPPORTS @@ -73,35 +73,35 @@ protected: }; nsresult -NS_NewHTMLParagraph(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLParagraphElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLParagraph(aTag); + nsIHTMLContent* it = new nsHTMLParagraphElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLParagraph::nsHTMLParagraph(nsIAtom* aTag) +nsHTMLParagraphElement::nsHTMLParagraphElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLParagraph::~nsHTMLParagraph() +nsHTMLParagraphElement::~nsHTMLParagraphElement() { } -NS_IMPL_ADDREF(nsHTMLParagraph) +NS_IMPL_ADDREF(nsHTMLParagraphElement) -NS_IMPL_RELEASE(nsHTMLParagraph) +NS_IMPL_RELEASE(nsHTMLParagraphElement) nsresult -nsHTMLParagraph::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLParagraphElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLParagraphElementIID)) { @@ -114,9 +114,9 @@ nsHTMLParagraph::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLParagraph::CloneNode(nsIDOMNode** aReturn) +nsHTMLParagraphElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLParagraph* it = new nsHTMLParagraph(mInner.mTag); + nsHTMLParagraphElement* it = new nsHTMLParagraphElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -124,10 +124,10 @@ nsHTMLParagraph::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_STRING_ATTR(nsHTMLParagraph, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLParagraphElement, Align, align, eSetAttrNotify_Reflow) NS_IMETHODIMP -nsHTMLParagraph::StringToAttribute(nsIAtom* aAttribute, +nsHTMLParagraphElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -140,7 +140,7 @@ nsHTMLParagraph::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLParagraph::AttributeToString(nsIAtom* aAttribute, +nsHTMLParagraphElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -154,7 +154,7 @@ nsHTMLParagraph::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLParagraph::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLParagraphElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { // XXX write me @@ -162,7 +162,7 @@ nsHTMLParagraph::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLParagraph::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLParagraphElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/layout/html/content/src/nsHTMLParam.cpp b/mozilla/content/html/content/src/nsHTMLParamElement.cpp similarity index 76% rename from mozilla/layout/html/content/src/nsHTMLParam.cpp rename to mozilla/content/html/content/src/nsHTMLParamElement.cpp index 131215382ba..1efbffa79e6 100644 --- a/mozilla/layout/html/content/src/nsHTMLParam.cpp +++ b/mozilla/content/html/content/src/nsHTMLParamElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLParamElementIID, NS_IDOMHTMLPARAMELEMENT_IID); -class nsHTMLParam : public nsIDOMHTMLParamElement, +class nsHTMLParamElement : public nsIDOMHTMLParamElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLParam(nsIAtom* aTag); - ~nsHTMLParam(); + nsHTMLParamElement(nsIAtom* aTag); + ~nsHTMLParamElement(); // nsISupports NS_DECL_ISUPPORTS @@ -77,35 +77,35 @@ protected: }; nsresult -NS_NewHTMLParam(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLParamElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLParam(aTag); + nsIHTMLContent* it = new nsHTMLParamElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLParam::nsHTMLParam(nsIAtom* aTag) +nsHTMLParamElement::nsHTMLParamElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLParam::~nsHTMLParam() +nsHTMLParamElement::~nsHTMLParamElement() { } -NS_IMPL_ADDREF(nsHTMLParam) +NS_IMPL_ADDREF(nsHTMLParamElement) -NS_IMPL_RELEASE(nsHTMLParam) +NS_IMPL_RELEASE(nsHTMLParamElement) nsresult -nsHTMLParam::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLParamElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLParamElementIID)) { @@ -118,9 +118,9 @@ nsHTMLParam::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLParam::CloneNode(nsIDOMNode** aReturn) +nsHTMLParamElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLParam* it = new nsHTMLParam(mInner.mTag); + nsHTMLParamElement* it = new nsHTMLParamElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -128,13 +128,13 @@ nsHTMLParam::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_STRING_ATTR(nsHTMLParam, Name, name, eSetAttrNotify_Restart) -NS_IMPL_STRING_ATTR(nsHTMLParam, Type, type, eSetAttrNotify_Restart) -NS_IMPL_STRING_ATTR(nsHTMLParam, Value, value, eSetAttrNotify_Restart) -NS_IMPL_STRING_ATTR(nsHTMLParam, ValueType, valuetype, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLParamElement, Name, name, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLParamElement, Type, type, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLParamElement, Value, value, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLParamElement, ValueType, valuetype, eSetAttrNotify_Restart) NS_IMETHODIMP -nsHTMLParam::StringToAttribute(nsIAtom* aAttribute, +nsHTMLParamElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -143,7 +143,7 @@ nsHTMLParam::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLParam::AttributeToString(nsIAtom* aAttribute, +nsHTMLParamElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -152,7 +152,7 @@ nsHTMLParam::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLParam::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLParamElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { // XXX write me @@ -160,7 +160,7 @@ nsHTMLParam::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLParam::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLParamElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/layout/html/content/src/nsHTMLPre.cpp b/mozilla/content/html/content/src/nsHTMLPreElement.cpp similarity index 81% rename from mozilla/layout/html/content/src/nsHTMLPre.cpp rename to mozilla/content/html/content/src/nsHTMLPreElement.cpp index 0c096d35c6a..507574ec6aa 100644 --- a/mozilla/layout/html/content/src/nsHTMLPre.cpp +++ b/mozilla/content/html/content/src/nsHTMLPreElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -31,14 +31,14 @@ static NS_DEFINE_IID(kIDOMHTMLPreElementIID, NS_IDOMHTMLPREELEMENT_IID); -class nsHTMLPre : public nsIDOMHTMLPreElement, +class nsHTMLPreElement : public nsIDOMHTMLPreElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLPre(nsIAtom* aTag); - ~nsHTMLPre(); + nsHTMLPreElement(nsIAtom* aTag); + ~nsHTMLPreElement(); // nsISupports NS_DECL_ISUPPORTS @@ -73,35 +73,35 @@ protected: }; nsresult -NS_NewHTMLPre(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLPreElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLPre(aTag); + nsIHTMLContent* it = new nsHTMLPreElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLPre::nsHTMLPre(nsIAtom* aTag) +nsHTMLPreElement::nsHTMLPreElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLPre::~nsHTMLPre() +nsHTMLPreElement::~nsHTMLPreElement() { } -NS_IMPL_ADDREF(nsHTMLPre) +NS_IMPL_ADDREF(nsHTMLPreElement) -NS_IMPL_RELEASE(nsHTMLPre) +NS_IMPL_RELEASE(nsHTMLPreElement) nsresult -nsHTMLPre::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLPreElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLPreElementIID)) { @@ -114,9 +114,9 @@ nsHTMLPre::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLPre::CloneNode(nsIDOMNode** aReturn) +nsHTMLPreElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLPre* it = new nsHTMLPre(mInner.mTag); + nsHTMLPreElement* it = new nsHTMLPreElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -124,10 +124,10 @@ nsHTMLPre::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_INT_ATTR(nsHTMLPre, Width, width, eSetAttrNotify_Reflow) +NS_IMPL_INT_ATTR(nsHTMLPreElement, Width, width, eSetAttrNotify_Reflow) NS_IMETHODIMP -nsHTMLPre::StringToAttribute(nsIAtom* aAttribute, +nsHTMLPreElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -140,7 +140,7 @@ nsHTMLPre::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLPre::AttributeToString(nsIAtom* aAttribute, +nsHTMLPreElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -154,7 +154,7 @@ nsHTMLPre::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLPre::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLPreElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { // XXX write me @@ -162,7 +162,7 @@ nsHTMLPre::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLPre::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLPreElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/layout/html/content/src/nsHTMLQuote.cpp b/mozilla/content/html/content/src/nsHTMLQuoteElement.cpp similarity index 79% rename from mozilla/layout/html/content/src/nsHTMLQuote.cpp rename to mozilla/content/html/content/src/nsHTMLQuoteElement.cpp index ee026171b35..f0b4522dd57 100644 --- a/mozilla/layout/html/content/src/nsHTMLQuote.cpp +++ b/mozilla/content/html/content/src/nsHTMLQuoteElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLQuoteElementIID, NS_IDOMHTMLQUOTEELEMENT_IID); -class nsHTMLQuote : public nsIDOMHTMLQuoteElement, +class nsHTMLQuoteElement : public nsIDOMHTMLQuoteElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLQuote(nsIAtom* aTag); - ~nsHTMLQuote(); + nsHTMLQuoteElement(nsIAtom* aTag); + ~nsHTMLQuoteElement(); // nsISupports NS_DECL_ISUPPORTS @@ -71,35 +71,35 @@ protected: }; nsresult -NS_NewHTMLQuote(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLQuoteElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLQuote(aTag); + nsIHTMLContent* it = new nsHTMLQuoteElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLQuote::nsHTMLQuote(nsIAtom* aTag) +nsHTMLQuoteElement::nsHTMLQuoteElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLQuote::~nsHTMLQuote() +nsHTMLQuoteElement::~nsHTMLQuoteElement() { } -NS_IMPL_ADDREF(nsHTMLQuote) +NS_IMPL_ADDREF(nsHTMLQuoteElement) -NS_IMPL_RELEASE(nsHTMLQuote) +NS_IMPL_RELEASE(nsHTMLQuoteElement) nsresult -nsHTMLQuote::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLQuoteElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLQuoteElementIID)) { @@ -112,9 +112,9 @@ nsHTMLQuote::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLQuote::CloneNode(nsIDOMNode** aReturn) +nsHTMLQuoteElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLQuote* it = new nsHTMLQuote(mInner.mTag); + nsHTMLQuoteElement* it = new nsHTMLQuoteElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -122,10 +122,10 @@ nsHTMLQuote::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_STRING_ATTR(nsHTMLQuote, Cite, cite, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLQuoteElement, Cite, cite, eSetAttrNotify_None) NS_IMETHODIMP -nsHTMLQuote::StringToAttribute(nsIAtom* aAttribute, +nsHTMLQuoteElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -134,7 +134,7 @@ nsHTMLQuote::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLQuote::AttributeToString(nsIAtom* aAttribute, +nsHTMLQuoteElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -143,7 +143,7 @@ nsHTMLQuote::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLQuote::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLQuoteElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { // XXX write me @@ -151,7 +151,7 @@ nsHTMLQuote::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLQuote::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLQuoteElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/layout/html/content/src/nsHTMLScript.cpp b/mozilla/content/html/content/src/nsHTMLScriptElement.cpp similarity index 75% rename from mozilla/layout/html/content/src/nsHTMLScript.cpp rename to mozilla/content/html/content/src/nsHTMLScriptElement.cpp index b1dfcd83969..504436522b0 100644 --- a/mozilla/layout/html/content/src/nsHTMLScript.cpp +++ b/mozilla/content/html/content/src/nsHTMLScriptElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLScriptElementIID, NS_IDOMHTMLSCRIPTELEMENT_IID); -class nsHTMLScript : public nsIDOMHTMLScriptElement, +class nsHTMLScriptElement : public nsIDOMHTMLScriptElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLScript(nsIAtom* aTag); - ~nsHTMLScript(); + nsHTMLScriptElement(nsIAtom* aTag); + ~nsHTMLScriptElement(); // nsISupports NS_DECL_ISUPPORTS @@ -84,35 +84,35 @@ protected: }; nsresult -NS_NewHTMLScript(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLScriptElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLScript(aTag); + nsIHTMLContent* it = new nsHTMLScriptElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLScript::nsHTMLScript(nsIAtom* aTag) +nsHTMLScriptElement::nsHTMLScriptElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLScript::~nsHTMLScript() +nsHTMLScriptElement::~nsHTMLScriptElement() { } -NS_IMPL_ADDREF(nsHTMLScript) +NS_IMPL_ADDREF(nsHTMLScriptElement) -NS_IMPL_RELEASE(nsHTMLScript) +NS_IMPL_RELEASE(nsHTMLScriptElement) nsresult -nsHTMLScript::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLScriptElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLScriptElementIID)) { @@ -125,9 +125,9 @@ nsHTMLScript::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLScript::CloneNode(nsIDOMNode** aReturn) +nsHTMLScriptElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLScript* it = new nsHTMLScript(mInner.mTag); + nsHTMLScriptElement* it = new nsHTMLScriptElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -136,7 +136,7 @@ nsHTMLScript::CloneNode(nsIDOMNode** aReturn) } NS_IMETHODIMP -nsHTMLScript::GetText(nsString& aValue) +nsHTMLScriptElement::GetText(nsString& aValue) { // XXX out of memory errors aValue = mText; @@ -144,7 +144,7 @@ nsHTMLScript::GetText(nsString& aValue) } NS_IMETHODIMP -nsHTMLScript::SetText(const nsString& aValue) +nsHTMLScriptElement::SetText(const nsString& aValue) { // XXX out of memory errors mText = aValue; @@ -152,7 +152,7 @@ nsHTMLScript::SetText(const nsString& aValue) } NS_IMETHODIMP -nsHTMLScript::GetHtmlFor(nsString& aValue) +nsHTMLScriptElement::GetHtmlFor(nsString& aValue) { // XXX write me // mInner.GetAttribute(nsHTMLAtoms::charset, aValue); @@ -160,7 +160,7 @@ nsHTMLScript::GetHtmlFor(nsString& aValue) } NS_IMETHODIMP -nsHTMLScript::SetHtmlFor(const nsString& aValue) +nsHTMLScriptElement::SetHtmlFor(const nsString& aValue) { // XXX write me // return mInner.SetAttr(nsHTMLAtoms::charset, aValue, eSetAttrNotify_None); @@ -168,7 +168,7 @@ nsHTMLScript::SetHtmlFor(const nsString& aValue) } NS_IMETHODIMP -nsHTMLScript::GetEvent(nsString& aValue) +nsHTMLScriptElement::GetEvent(nsString& aValue) { // XXX write me // mInner.GetAttribute(nsHTMLAtoms::charset, aValue); @@ -176,20 +176,20 @@ nsHTMLScript::GetEvent(nsString& aValue) } NS_IMETHODIMP -nsHTMLScript::SetEvent(const nsString& aValue) +nsHTMLScriptElement::SetEvent(const nsString& aValue) { // XXX write me // return mInner.SetAttr(nsHTMLAtoms::charset, aValue, eSetAttrNotify_None); return NS_OK; } -NS_IMPL_STRING_ATTR(nsHTMLScript, Charset, charset, eSetAttrNotify_None) -NS_IMPL_BOOL_ATTR(nsHTMLScript, Defer, defer, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLScript, Src, src, eSetAttrNotify_Restart) -NS_IMPL_STRING_ATTR(nsHTMLScript, Type, type, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLScriptElement, Charset, charset, eSetAttrNotify_None) +NS_IMPL_BOOL_ATTR(nsHTMLScriptElement, Defer, defer, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLScriptElement, Src, src, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLScriptElement, Type, type, eSetAttrNotify_Restart) NS_IMETHODIMP -nsHTMLScript::StringToAttribute(nsIAtom* aAttribute, +nsHTMLScriptElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -197,7 +197,7 @@ nsHTMLScript::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLScript::AttributeToString(nsIAtom* aAttribute, +nsHTMLScriptElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -205,14 +205,14 @@ nsHTMLScript::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLScript::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLScriptElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { return NS_OK; } NS_IMETHODIMP -nsHTMLScript::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLScriptElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp new file mode 100644 index 00000000000..b5c4e777b41 --- /dev/null +++ b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp @@ -0,0 +1,234 @@ +/* -*- 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 "nsIDOMHTMLSelectElement.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(kIDOMHTMLSelectElementIID, NS_IDOMHTMLSELECTELEMENT_IID); + +class nsHTMLSelectElement : public nsIDOMHTMLSelectElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLSelectElement(nsIAtom* aTag); + ~nsHTMLSelectElement(); + + // 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) + + // nsIDOMHTMLSelectElement + NS_IMETHOD GetType(nsString& aType); + NS_IMETHOD SetType(const nsString& aType); + NS_IMETHOD GetSelectedIndex(PRInt32* aSelectedIndex); + NS_IMETHOD SetSelectedIndex(PRInt32 aSelectedIndex); + NS_IMETHOD GetValue(nsString& aValue); + NS_IMETHOD SetValue(const nsString& aValue); + NS_IMETHOD GetLength(PRInt32* aLength); + NS_IMETHOD SetLength(PRInt32 aLength); + NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm); + NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm); + NS_IMETHOD GetOptions(nsIDOMHTMLCollection** aOptions); + NS_IMETHOD SetOptions(nsIDOMHTMLCollection* aOptions); + NS_IMETHOD GetDisabled(PRBool* aDisabled); + NS_IMETHOD SetDisabled(PRBool aDisabled); + NS_IMETHOD GetMultiple(PRBool* aMultiple); + NS_IMETHOD SetMultiple(PRBool aMultiple); + NS_IMETHOD GetName(nsString& aName); + NS_IMETHOD SetName(const nsString& aName); + NS_IMETHOD GetSize(PRInt32* aSize); + NS_IMETHOD SetSize(PRInt32 aSize); + NS_IMETHOD GetTabIndex(PRInt32* aTabIndex); + NS_IMETHOD SetTabIndex(PRInt32 aTabIndex); + NS_IMETHOD Add(nsIDOMHTMLElement* aElement, nsIDOMHTMLElement* aBefore); + NS_IMETHOD Remove(PRInt32 aIndex); + NS_IMETHOD Blur(); + NS_IMETHOD Focus(); + + // 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_NewHTMLSelectElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLSelectElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLSelectElement::nsHTMLSelectElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLSelectElement::~nsHTMLSelectElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLSelectElement) + +NS_IMPL_RELEASE(nsHTMLSelectElement) + +nsresult +nsHTMLSelectElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLSelectElementIID)) { + nsIDOMHTMLSelectElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLSelectElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLSelectElement* it = new nsHTMLSelectElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMETHODIMP +nsHTMLSelectElement::GetForm(nsIDOMHTMLFormElement** aForm) +{ + *aForm = nsnull;/* XXX */ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLSelectElement::SetForm(nsIDOMHTMLFormElement* aForm) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLSelectElement::GetOptions(nsIDOMHTMLCollection** aValue) +{ + *aValue = nsnull;/* XXX */ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLSelectElement::SetOptions(nsIDOMHTMLCollection* aValue) +{ + return NS_OK; +} + +NS_IMPL_STRING_ATTR(nsHTMLSelectElement, Type, type, eSetAttrNotify_Restart) +NS_IMPL_INT_ATTR(nsHTMLSelectElement, SelectedIndex, selectedindex, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLSelectElement, Value, value, eSetAttrNotify_Render) +NS_IMPL_INT_ATTR(nsHTMLSelectElement, Length, length, eSetAttrNotify_Restart) +NS_IMPL_BOOL_ATTR(nsHTMLSelectElement, Disabled, disabled, eSetAttrNotify_Render) +NS_IMPL_INT_ATTR(nsHTMLSelectElement, Multiple, multiple, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLSelectElement, Name, name, eSetAttrNotify_Restart) +NS_IMPL_INT_ATTR(nsHTMLSelectElement, Size, size, eSetAttrNotify_Render) +NS_IMPL_INT_ATTR(nsHTMLSelectElement, TabIndex, tabindex, eSetAttrNotify_Render) + +NS_IMETHODIMP +nsHTMLSelectElement::Blur() +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLSelectElement::Focus() +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLSelectElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLSelectElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLSelectElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLSelectElement::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/nsHTMLSharedObjectElement.cpp b/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp new file mode 100644 index 00000000000..8837ceed6d1 --- /dev/null +++ b/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp @@ -0,0 +1,244 @@ +/* -*- 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 "nsIDOMHTMLObjectElement.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(kIDOMHTMLObjectElementIID, NS_IDOMHTMLOBJECTELEMENT_IID); + +class nsHTMLObjectElement : public nsIDOMHTMLObjectElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLObjectElement(nsIAtom* aTag); + ~nsHTMLObjectElement(); + + // 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) + + // nsIDOMHTMLObjectElement + NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm); + NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm); + NS_IMETHOD GetCode(nsString& aCode); + NS_IMETHOD SetCode(const nsString& aCode); + NS_IMETHOD GetAlign(nsString& aAlign); + NS_IMETHOD SetAlign(const nsString& aAlign); + NS_IMETHOD GetArchive(nsString& aArchive); + NS_IMETHOD SetArchive(const nsString& aArchive); + NS_IMETHOD GetBorder(nsString& aBorder); + NS_IMETHOD SetBorder(const nsString& aBorder); + NS_IMETHOD GetCodeBase(nsString& aCodeBase); + NS_IMETHOD SetCodeBase(const nsString& aCodeBase); + NS_IMETHOD GetCodeType(nsString& aCodeType); + NS_IMETHOD SetCodeType(const nsString& aCodeType); + NS_IMETHOD GetData(nsString& aData); + NS_IMETHOD SetData(const nsString& aData); + NS_IMETHOD GetDeclare(PRBool* aDeclare); + NS_IMETHOD SetDeclare(PRBool aDeclare); + NS_IMETHOD GetHeight(nsString& aHeight); + NS_IMETHOD SetHeight(const nsString& aHeight); + NS_IMETHOD GetHspace(nsString& aHspace); + NS_IMETHOD SetHspace(const nsString& aHspace); + NS_IMETHOD GetName(nsString& aName); + NS_IMETHOD SetName(const nsString& aName); + NS_IMETHOD GetStandby(nsString& aStandby); + NS_IMETHOD SetStandby(const nsString& aStandby); + NS_IMETHOD GetTabIndex(PRInt32* aTabIndex); + NS_IMETHOD SetTabIndex(PRInt32 aTabIndex); + NS_IMETHOD GetType(nsString& aType); + NS_IMETHOD SetType(const nsString& aType); + 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_NewHTMLObjectElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLObjectElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLObjectElement::nsHTMLObjectElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLObjectElement::~nsHTMLObjectElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLObjectElement) + +NS_IMPL_RELEASE(nsHTMLObjectElement) + +nsresult +nsHTMLObjectElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLObjectElementIID)) { + nsIDOMHTMLObjectElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLObjectElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLObjectElement* it = new nsHTMLObjectElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMETHODIMP +nsHTMLObjectElement::GetForm(nsIDOMHTMLFormElement** aForm) +{ + *aForm = nsnull;/* XXX */ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLObjectElement::SetForm(nsIDOMHTMLFormElement* aForm) +{ + return NS_OK; +} + +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Code, code, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Archive, archive, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Border, border, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, CodeBase, codebase, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, CodeType, codetype, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Data, data, eSetAttrNotify_None) +NS_IMPL_BOOL_ATTR(nsHTMLObjectElement, Declare, declare, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Height, height, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Hspace, hspace, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Name, name, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Standby, standby, eSetAttrNotify_None) +NS_IMPL_INT_ATTR(nsHTMLObjectElement, TabIndex, tabindex, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Type, type, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, UseMap, usemap, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Vspace, vspace, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Width, width, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLObjectElement::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 +nsHTMLObjectElement::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 +nsHTMLObjectElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + mInner.MapImageAlignAttributeInto(aContext, aPresContext); + mInner.MapImageAttributesInto(aContext, aPresContext); + mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull); + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLObjectElement::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/nsHTMLStyle.cpp b/mozilla/content/html/content/src/nsHTMLStyleElement.cpp similarity index 77% rename from mozilla/layout/html/content/src/nsHTMLStyle.cpp rename to mozilla/content/html/content/src/nsHTMLStyleElement.cpp index ad598961630..db961cf8f80 100644 --- a/mozilla/layout/html/content/src/nsHTMLStyle.cpp +++ b/mozilla/content/html/content/src/nsHTMLStyleElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -31,14 +31,14 @@ static NS_DEFINE_IID(kIDOMHTMLStyleElementIID, NS_IDOMHTMLSTYLEELEMENT_IID); -class nsHTMLStyle : public nsIDOMHTMLStyleElement, +class nsHTMLStyleElement : public nsIDOMHTMLStyleElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLStyle(nsIAtom* aTag); - ~nsHTMLStyle(); + nsHTMLStyleElement(nsIAtom* aTag); + ~nsHTMLStyleElement(); // nsISupports NS_DECL_ISUPPORTS @@ -77,35 +77,35 @@ protected: }; nsresult -NS_NewHTMLStyle(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLStyleElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLStyle(aTag); + nsIHTMLContent* it = new nsHTMLStyleElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLStyle::nsHTMLStyle(nsIAtom* aTag) +nsHTMLStyleElement::nsHTMLStyleElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLStyle::~nsHTMLStyle() +nsHTMLStyleElement::~nsHTMLStyleElement() { } -NS_IMPL_ADDREF(nsHTMLStyle) +NS_IMPL_ADDREF(nsHTMLStyleElement) -NS_IMPL_RELEASE(nsHTMLStyle) +NS_IMPL_RELEASE(nsHTMLStyleElement) nsresult -nsHTMLStyle::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLStyleElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLStyleElementIID)) { @@ -118,9 +118,9 @@ nsHTMLStyle::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLStyle::CloneNode(nsIDOMNode** aReturn) +nsHTMLStyleElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLStyle* it = new nsHTMLStyle(mInner.mTag); + nsHTMLStyleElement* it = new nsHTMLStyleElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -128,12 +128,12 @@ nsHTMLStyle::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_BOOL_ATTR(nsHTMLStyle, Disabled, disabled, eSetAttrNotify_Render) -NS_IMPL_STRING_ATTR(nsHTMLStyle, Media, media, eSetAttrNotify_Restart) -NS_IMPL_STRING_ATTR(nsHTMLStyle, Type, type, eSetAttrNotify_Restart) +NS_IMPL_BOOL_ATTR(nsHTMLStyleElement, Disabled, disabled, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLStyleElement, Media, media, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLStyleElement, Type, type, eSetAttrNotify_Restart) NS_IMETHODIMP -nsHTMLStyle::StringToAttribute(nsIAtom* aAttribute, +nsHTMLStyleElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -141,7 +141,7 @@ nsHTMLStyle::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLStyle::AttributeToString(nsIAtom* aAttribute, +nsHTMLStyleElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -149,14 +149,14 @@ nsHTMLStyle::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLStyle::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLStyleElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { return NS_OK; } NS_IMETHODIMP -nsHTMLStyle::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLStyleElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/layout/html/content/src/nsHTMLTableCaption.cpp b/mozilla/content/html/content/src/nsHTMLTableCaptionElement.cpp similarity index 77% rename from mozilla/layout/html/content/src/nsHTMLTableCaption.cpp rename to mozilla/content/html/content/src/nsHTMLTableCaptionElement.cpp index ca1233ab137..35178ad56d9 100644 --- a/mozilla/layout/html/content/src/nsHTMLTableCaption.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableCaptionElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLTableCaptionElementIID, NS_IDOMHTMLTABLECAPTIONELEMENT_IID); -class nsHTMLTableCaption : public nsIDOMHTMLTableCaptionElement, +class nsHTMLTableCaptionElement : public nsIDOMHTMLTableCaptionElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLTableCaption(nsIAtom* aTag); - ~nsHTMLTableCaption(); + nsHTMLTableCaptionElement(nsIAtom* aTag); + ~nsHTMLTableCaptionElement(); // nsISupports NS_DECL_ISUPPORTS @@ -71,35 +71,35 @@ protected: }; nsresult -NS_NewHTMLTableCaption(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLTableCaptionElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLTableCaption(aTag); + nsIHTMLContent* it = new nsHTMLTableCaptionElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLTableCaption::nsHTMLTableCaption(nsIAtom* aTag) +nsHTMLTableCaptionElement::nsHTMLTableCaptionElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLTableCaption::~nsHTMLTableCaption() +nsHTMLTableCaptionElement::~nsHTMLTableCaptionElement() { } -NS_IMPL_ADDREF(nsHTMLTableCaption) +NS_IMPL_ADDREF(nsHTMLTableCaptionElement) -NS_IMPL_RELEASE(nsHTMLTableCaption) +NS_IMPL_RELEASE(nsHTMLTableCaptionElement) nsresult -nsHTMLTableCaption::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLTableCaptionElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLTableCaptionElementIID)) { @@ -112,9 +112,9 @@ nsHTMLTableCaption::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLTableCaption::CloneNode(nsIDOMNode** aReturn) +nsHTMLTableCaptionElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLTableCaption* it = new nsHTMLTableCaption(mInner.mTag); + nsHTMLTableCaptionElement* it = new nsHTMLTableCaptionElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -122,10 +122,10 @@ nsHTMLTableCaption::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_STRING_ATTR(nsHTMLTableCaption, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableCaptionElement, Align, align, eSetAttrNotify_Reflow) NS_IMETHODIMP -nsHTMLTableCaption::StringToAttribute(nsIAtom* aAttribute, +nsHTMLTableCaptionElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -134,7 +134,7 @@ nsHTMLTableCaption::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLTableCaption::AttributeToString(nsIAtom* aAttribute, +nsHTMLTableCaptionElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -143,7 +143,7 @@ nsHTMLTableCaption::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLTableCaption::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLTableCaptionElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { // XXX write me @@ -151,7 +151,7 @@ nsHTMLTableCaption::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLTableCaption::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLTableCaptionElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/layout/html/content/src/nsHTMLTableCell.cpp b/mozilla/content/html/content/src/nsHTMLTableCellElement.cpp similarity index 69% rename from mozilla/layout/html/content/src/nsHTMLTableCell.cpp rename to mozilla/content/html/content/src/nsHTMLTableCellElement.cpp index 5e210a992a3..29cb75d57de 100644 --- a/mozilla/layout/html/content/src/nsHTMLTableCell.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableCellElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLTableCellElementIID, NS_IDOMHTMLTABLECELLELEMENT_IID); -class nsHTMLTableCell : public nsIDOMHTMLTableCellElement, +class nsHTMLTableCellElement : public nsIDOMHTMLTableCellElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLTableCell(nsIAtom* aTag); - ~nsHTMLTableCell(); + nsHTMLTableCellElement(nsIAtom* aTag); + ~nsHTMLTableCellElement(); // nsISupports NS_DECL_ISUPPORTS @@ -99,35 +99,35 @@ protected: }; nsresult -NS_NewHTMLTableCell(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLTableCellElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLTableCell(aTag); + nsIHTMLContent* it = new nsHTMLTableCellElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLTableCell::nsHTMLTableCell(nsIAtom* aTag) +nsHTMLTableCellElement::nsHTMLTableCellElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLTableCell::~nsHTMLTableCell() +nsHTMLTableCellElement::~nsHTMLTableCellElement() { } -NS_IMPL_ADDREF(nsHTMLTableCell) +NS_IMPL_ADDREF(nsHTMLTableCellElement) -NS_IMPL_RELEASE(nsHTMLTableCell) +NS_IMPL_RELEASE(nsHTMLTableCellElement) nsresult -nsHTMLTableCell::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLTableCellElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLTableCellElementIID)) { @@ -140,9 +140,9 @@ nsHTMLTableCell::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLTableCell::CloneNode(nsIDOMNode** aReturn) +nsHTMLTableCellElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLTableCell* it = new nsHTMLTableCell(mInner.mTag); + nsHTMLTableCellElement* it = new nsHTMLTableCellElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -151,36 +151,36 @@ nsHTMLTableCell::CloneNode(nsIDOMNode** aReturn) } NS_IMETHODIMP -nsHTMLTableCell::GetCellIndex(PRInt32* aCellIndex) +nsHTMLTableCellElement::GetCellIndex(PRInt32* aCellIndex) { *aCellIndex = 0;/* XXX */ return NS_OK; } NS_IMETHODIMP -nsHTMLTableCell::SetCellIndex(PRInt32 aCellIndex) +nsHTMLTableCellElement::SetCellIndex(PRInt32 aCellIndex) { // XXX write me return NS_OK; } -NS_IMPL_STRING_ATTR(nsHTMLTableCell, Abbr, abbr, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLTableCell, Align, align, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLTableCell, Axis, axis, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLTableCell, BgColor, bgcolor, eSetAttrNotify_Render) -NS_IMPL_STRING_ATTR(nsHTMLTableCell, Ch, ch, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLTableCell, ChOff, choff, eSetAttrNotify_Reflow) -NS_IMPL_INT_ATTR(nsHTMLTableCell, ColSpan, colspan, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLTableCell, Headers, headers, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLTableCell, Height, height, eSetAttrNotify_Reflow) -NS_IMPL_BOOL_ATTR(nsHTMLTableCell, NoWrap, nowrap, eSetAttrNotify_Reflow) -NS_IMPL_INT_ATTR(nsHTMLTableCell, RowSpan, rowspan, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLTableCell, Scope, scope, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLTableCell, VAlign, valign, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLTableCell, Width, width, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Abbr, abbr, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Axis, axis, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, BgColor, bgcolor, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Ch, ch, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, ChOff, choff, eSetAttrNotify_Reflow) +NS_IMPL_INT_ATTR(nsHTMLTableCellElement, ColSpan, colspan, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Headers, headers, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Height, height, eSetAttrNotify_Reflow) +NS_IMPL_BOOL_ATTR(nsHTMLTableCellElement, NoWrap, nowrap, eSetAttrNotify_Reflow) +NS_IMPL_INT_ATTR(nsHTMLTableCellElement, RowSpan, rowspan, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Scope, scope, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, VAlign, valign, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Width, width, eSetAttrNotify_Reflow) NS_IMETHODIMP -nsHTMLTableCell::StringToAttribute(nsIAtom* aAttribute, +nsHTMLTableCellElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -189,7 +189,7 @@ nsHTMLTableCell::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLTableCell::AttributeToString(nsIAtom* aAttribute, +nsHTMLTableCellElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -198,7 +198,7 @@ nsHTMLTableCell::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLTableCell::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLTableCellElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { // XXX write me @@ -206,7 +206,7 @@ nsHTMLTableCell::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLTableCell::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLTableCellElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/layout/html/content/src/nsHTMLTableCol.cpp b/mozilla/content/html/content/src/nsHTMLTableColElement.cpp similarity index 74% rename from mozilla/layout/html/content/src/nsHTMLTableCol.cpp rename to mozilla/content/html/content/src/nsHTMLTableColElement.cpp index 78594520e8a..7dc7a63480c 100644 --- a/mozilla/layout/html/content/src/nsHTMLTableCol.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableColElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLTableColElementIID, NS_IDOMHTMLTABLECOLELEMENT_IID); -class nsHTMLTableCol : public nsIDOMHTMLTableColElement, +class nsHTMLTableColElement : public nsIDOMHTMLTableColElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLTableCol(nsIAtom* aTag); - ~nsHTMLTableCol(); + nsHTMLTableColElement(nsIAtom* aTag); + ~nsHTMLTableColElement(); // nsISupports NS_DECL_ISUPPORTS @@ -81,35 +81,35 @@ protected: }; nsresult -NS_NewHTMLTableCol(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLTableColElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLTableCol(aTag); + nsIHTMLContent* it = new nsHTMLTableColElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLTableCol::nsHTMLTableCol(nsIAtom* aTag) +nsHTMLTableColElement::nsHTMLTableColElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLTableCol::~nsHTMLTableCol() +nsHTMLTableColElement::~nsHTMLTableColElement() { } -NS_IMPL_ADDREF(nsHTMLTableCol) +NS_IMPL_ADDREF(nsHTMLTableColElement) -NS_IMPL_RELEASE(nsHTMLTableCol) +NS_IMPL_RELEASE(nsHTMLTableColElement) nsresult -nsHTMLTableCol::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLTableColElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLTableColElementIID)) { @@ -122,9 +122,9 @@ nsHTMLTableCol::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLTableCol::CloneNode(nsIDOMNode** aReturn) +nsHTMLTableColElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLTableCol* it = new nsHTMLTableCol(mInner.mTag); + nsHTMLTableColElement* it = new nsHTMLTableColElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -132,15 +132,15 @@ nsHTMLTableCol::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_STRING_ATTR(nsHTMLTableCol, Align, align, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLTableCol, Ch, ch, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLTableCol, ChOff, choff, eSetAttrNotify_Reflow) -NS_IMPL_INT_ATTR(nsHTMLTableCol, Span, span, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLTableCol, VAlign, valign, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLTableCol, Width, width, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableColElement, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableColElement, Ch, ch, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableColElement, ChOff, choff, eSetAttrNotify_Reflow) +NS_IMPL_INT_ATTR(nsHTMLTableColElement, Span, span, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableColElement, VAlign, valign, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableColElement, Width, width, eSetAttrNotify_Reflow) NS_IMETHODIMP -nsHTMLTableCol::StringToAttribute(nsIAtom* aAttribute, +nsHTMLTableColElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -149,7 +149,7 @@ nsHTMLTableCol::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLTableCol::AttributeToString(nsIAtom* aAttribute, +nsHTMLTableColElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -158,7 +158,7 @@ nsHTMLTableCol::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLTableCol::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLTableColElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { // XXX write me @@ -166,7 +166,7 @@ nsHTMLTableCol::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLTableCol::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLTableColElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/layout/html/content/src/nsHTMLTable.cpp b/mozilla/content/html/content/src/nsHTMLTableElement.cpp similarity index 70% rename from mozilla/layout/html/content/src/nsHTMLTable.cpp rename to mozilla/content/html/content/src/nsHTMLTableElement.cpp index bdefb0380de..be711b1cfb0 100644 --- a/mozilla/layout/html/content/src/nsHTMLTable.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLTableElementIID, NS_IDOMHTMLTABLEELEMENT_IID); -class nsHTMLTable : public nsIDOMHTMLTableElement, +class nsHTMLTableElement : public nsIDOMHTMLTableElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLTable(nsIAtom* aTag); - ~nsHTMLTable(); + nsHTMLTableElement(nsIAtom* aTag); + ~nsHTMLTableElement(); // nsISupports NS_DECL_ISUPPORTS @@ -105,35 +105,35 @@ protected: }; nsresult -NS_NewHTMLTable(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLTableElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLTable(aTag); + nsIHTMLContent* it = new nsHTMLTableElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLTable::nsHTMLTable(nsIAtom* aTag) +nsHTMLTableElement::nsHTMLTableElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLTable::~nsHTMLTable() +nsHTMLTableElement::~nsHTMLTableElement() { } -NS_IMPL_ADDREF(nsHTMLTable) +NS_IMPL_ADDREF(nsHTMLTableElement) -NS_IMPL_RELEASE(nsHTMLTable) +NS_IMPL_RELEASE(nsHTMLTableElement) nsresult -nsHTMLTable::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLTableElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLTableElementIID)) { @@ -146,9 +146,9 @@ nsHTMLTable::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLTable::CloneNode(nsIDOMNode** aReturn) +nsHTMLTableElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLTable* it = new nsHTMLTable(mInner.mTag); + nsHTMLTableElement* it = new nsHTMLTableElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -156,135 +156,135 @@ nsHTMLTable::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_STRING_ATTR(nsHTMLTable, Align, align, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLTable, BgColor, bgcolor, eSetAttrNotify_Render) -NS_IMPL_STRING_ATTR(nsHTMLTable, Border, border, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLTable, CellPadding, cellpadding, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLTable, CellSpacing, cellspacing, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLTable, Frame, frame, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLTable, Rules, rules, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLTable, Summary, summary, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLTable, Width, width, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLTableElement, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableElement, BgColor, bgcolor, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLTableElement, Border, border, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableElement, CellPadding, cellpadding, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableElement, CellSpacing, cellspacing, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableElement, Frame, frame, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLTableElement, Rules, rules, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLTableElement, Summary, summary, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLTableElement, Width, width, eSetAttrNotify_None) NS_IMETHODIMP -nsHTMLTable::GetCaption(nsIDOMHTMLTableCaptionElement** aValue) +nsHTMLTableElement::GetCaption(nsIDOMHTMLTableCaptionElement** aValue) { *aValue = nsnull; return NS_OK; // XXX write me } NS_IMETHODIMP -nsHTMLTable::SetCaption(nsIDOMHTMLTableCaptionElement* aValue) +nsHTMLTableElement::SetCaption(nsIDOMHTMLTableCaptionElement* aValue) { return NS_OK; // XXX write me } NS_IMETHODIMP -nsHTMLTable::GetTHead(nsIDOMHTMLTableSectionElement** aValue) +nsHTMLTableElement::GetTHead(nsIDOMHTMLTableSectionElement** aValue) { *aValue = nsnull; return NS_OK; // XXX write me } NS_IMETHODIMP -nsHTMLTable::SetTHead(nsIDOMHTMLTableSectionElement* aValue) +nsHTMLTableElement::SetTHead(nsIDOMHTMLTableSectionElement* aValue) { return NS_OK; // XXX write me } NS_IMETHODIMP -nsHTMLTable::GetTFoot(nsIDOMHTMLTableSectionElement** aValue) +nsHTMLTableElement::GetTFoot(nsIDOMHTMLTableSectionElement** aValue) { *aValue = nsnull; return NS_OK; // XXX write me } NS_IMETHODIMP -nsHTMLTable::SetTFoot(nsIDOMHTMLTableSectionElement* aValue) +nsHTMLTableElement::SetTFoot(nsIDOMHTMLTableSectionElement* aValue) { return NS_OK; // XXX write me } NS_IMETHODIMP -nsHTMLTable::GetRows(nsIDOMHTMLCollection** aValue) +nsHTMLTableElement::GetRows(nsIDOMHTMLCollection** aValue) { *aValue = nsnull; return NS_OK; // XXX write me } NS_IMETHODIMP -nsHTMLTable::SetRows(nsIDOMHTMLCollection* aValue) +nsHTMLTableElement::SetRows(nsIDOMHTMLCollection* aValue) { return NS_OK; // XXX write me } NS_IMETHODIMP -nsHTMLTable::GetTBodies(nsIDOMHTMLCollection** aValue) +nsHTMLTableElement::GetTBodies(nsIDOMHTMLCollection** aValue) { *aValue = nsnull; return NS_OK; // XXX write me } NS_IMETHODIMP -nsHTMLTable::SetTBodies(nsIDOMHTMLCollection* aValue) +nsHTMLTableElement::SetTBodies(nsIDOMHTMLCollection* aValue) { return NS_OK; // XXX write me } NS_IMETHODIMP -nsHTMLTable::CreateTHead(nsIDOMHTMLElement** aValue) +nsHTMLTableElement::CreateTHead(nsIDOMHTMLElement** aValue) { *aValue = nsnull; return NS_OK; // XXX write me } NS_IMETHODIMP -nsHTMLTable::DeleteTHead() +nsHTMLTableElement::DeleteTHead() { return NS_OK; // XXX write me } NS_IMETHODIMP -nsHTMLTable::CreateTFoot(nsIDOMHTMLElement** aValue) +nsHTMLTableElement::CreateTFoot(nsIDOMHTMLElement** aValue) { *aValue = nsnull; return NS_OK; // XXX write me } NS_IMETHODIMP -nsHTMLTable::DeleteTFoot() +nsHTMLTableElement::DeleteTFoot() { return NS_OK; // XXX write me } NS_IMETHODIMP -nsHTMLTable::CreateCaption(nsIDOMHTMLElement** aValue) +nsHTMLTableElement::CreateCaption(nsIDOMHTMLElement** aValue) { *aValue = nsnull; return NS_OK; // XXX write me } NS_IMETHODIMP -nsHTMLTable::DeleteCaption() +nsHTMLTableElement::DeleteCaption() { return NS_OK; // XXX write me } NS_IMETHODIMP -nsHTMLTable::InsertRow(PRInt32 aIndex, nsIDOMHTMLElement** aValue) +nsHTMLTableElement::InsertRow(PRInt32 aIndex, nsIDOMHTMLElement** aValue) { *aValue = nsnull; return NS_OK; // XXX write me } NS_IMETHODIMP -nsHTMLTable::DeleteRow(PRInt32 aValue) +nsHTMLTableElement::DeleteRow(PRInt32 aValue) { return NS_OK; // XXX write me } NS_IMETHODIMP -nsHTMLTable::StringToAttribute(nsIAtom* aAttribute, +nsHTMLTableElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -293,7 +293,7 @@ nsHTMLTable::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLTable::AttributeToString(nsIAtom* aAttribute, +nsHTMLTableElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -302,7 +302,7 @@ nsHTMLTable::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLTable::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLTableElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { // XXX write me @@ -310,7 +310,7 @@ nsHTMLTable::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLTable::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLTableElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/layout/html/content/src/nsHTMLTableRow.cpp b/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp similarity index 73% rename from mozilla/layout/html/content/src/nsHTMLTableRow.cpp rename to mozilla/content/html/content/src/nsHTMLTableRowElement.cpp index f2a5780c91f..6188c52f93c 100644 --- a/mozilla/layout/html/content/src/nsHTMLTableRow.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLTableRowElementIID, NS_IDOMHTMLTABLEROWELEMENT_IID); -class nsHTMLTableRow : public nsIDOMHTMLTableRowElement, +class nsHTMLTableRowElement : public nsIDOMHTMLTableRowElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLTableRow(nsIAtom* aTag); - ~nsHTMLTableRow(); + nsHTMLTableRowElement(nsIAtom* aTag); + ~nsHTMLTableRowElement(); // nsISupports NS_DECL_ISUPPORTS @@ -87,35 +87,35 @@ protected: }; nsresult -NS_NewHTMLTableRow(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLTableRowElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLTableRow(aTag); + nsIHTMLContent* it = new nsHTMLTableRowElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLTableRow::nsHTMLTableRow(nsIAtom* aTag) +nsHTMLTableRowElement::nsHTMLTableRowElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLTableRow::~nsHTMLTableRow() +nsHTMLTableRowElement::~nsHTMLTableRowElement() { } -NS_IMPL_ADDREF(nsHTMLTableRow) +NS_IMPL_ADDREF(nsHTMLTableRowElement) -NS_IMPL_RELEASE(nsHTMLTableRow) +NS_IMPL_RELEASE(nsHTMLTableRowElement) nsresult -nsHTMLTableRow::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLTableRowElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLTableRowElementIID)) { @@ -128,9 +128,9 @@ nsHTMLTableRow::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLTableRow::CloneNode(nsIDOMNode** aReturn) +nsHTMLTableRowElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLTableRow* it = new nsHTMLTableRow(mInner.mTag); + nsHTMLTableRowElement* it = new nsHTMLTableRowElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -139,7 +139,7 @@ nsHTMLTableRow::CloneNode(nsIDOMNode** aReturn) } NS_IMETHODIMP -nsHTMLTableRow::GetRowIndex(PRInt32* aValue) +nsHTMLTableRowElement::GetRowIndex(PRInt32* aValue) { *aValue = 0; // XXX write me @@ -147,14 +147,14 @@ nsHTMLTableRow::GetRowIndex(PRInt32* aValue) } NS_IMETHODIMP -nsHTMLTableRow::SetRowIndex(PRInt32 aValue) +nsHTMLTableRowElement::SetRowIndex(PRInt32 aValue) { // XXX write me return NS_OK; } NS_IMETHODIMP -nsHTMLTableRow::GetSectionRowIndex(PRInt32* aValue) +nsHTMLTableRowElement::GetSectionRowIndex(PRInt32* aValue) { *aValue = 0; // XXX write me @@ -162,14 +162,14 @@ nsHTMLTableRow::GetSectionRowIndex(PRInt32* aValue) } NS_IMETHODIMP -nsHTMLTableRow::SetSectionRowIndex(PRInt32 aValue) +nsHTMLTableRowElement::SetSectionRowIndex(PRInt32 aValue) { // XXX write me return NS_OK; } NS_IMETHODIMP -nsHTMLTableRow::GetCells(nsIDOMHTMLCollection** aValue) +nsHTMLTableRowElement::GetCells(nsIDOMHTMLCollection** aValue) { *aValue = 0; // XXX write me @@ -177,14 +177,14 @@ nsHTMLTableRow::GetCells(nsIDOMHTMLCollection** aValue) } NS_IMETHODIMP -nsHTMLTableRow::SetCells(nsIDOMHTMLCollection* aValue) +nsHTMLTableRowElement::SetCells(nsIDOMHTMLCollection* aValue) { // XXX write me return NS_OK; } NS_IMETHODIMP -nsHTMLTableRow::InsertCell(PRInt32 aIndex, nsIDOMHTMLElement** aValue) +nsHTMLTableRowElement::InsertCell(PRInt32 aIndex, nsIDOMHTMLElement** aValue) { *aValue = 0; // XXX write me @@ -192,20 +192,20 @@ nsHTMLTableRow::InsertCell(PRInt32 aIndex, nsIDOMHTMLElement** aValue) } NS_IMETHODIMP -nsHTMLTableRow::DeleteCell(PRInt32 aValue) +nsHTMLTableRowElement::DeleteCell(PRInt32 aValue) { // XXX write me return NS_OK; } -NS_IMPL_STRING_ATTR(nsHTMLTableRow, Align, align, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLTableRow, BgColor, bgcolor, eSetAttrNotify_Render) -NS_IMPL_STRING_ATTR(nsHTMLTableRow, Ch, ch, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLTableRow, ChOff, choff, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLTableRow, VAlign, valign, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableRowElement, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableRowElement, BgColor, bgcolor, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLTableRowElement, Ch, ch, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableRowElement, ChOff, choff, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableRowElement, VAlign, valign, eSetAttrNotify_Reflow) NS_IMETHODIMP -nsHTMLTableRow::StringToAttribute(nsIAtom* aAttribute, +nsHTMLTableRowElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -214,7 +214,7 @@ nsHTMLTableRow::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLTableRow::AttributeToString(nsIAtom* aAttribute, +nsHTMLTableRowElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -223,7 +223,7 @@ nsHTMLTableRow::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLTableRow::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLTableRowElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { // XXX write me @@ -231,7 +231,7 @@ nsHTMLTableRow::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLTableRow::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLTableRowElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/layout/html/content/src/nsHTMLTableSection.cpp b/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp similarity index 74% rename from mozilla/layout/html/content/src/nsHTMLTableSection.cpp rename to mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp index 80ff7639d27..aa0ec1cced0 100644 --- a/mozilla/layout/html/content/src/nsHTMLTableSection.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLTableSectionElementIID, NS_IDOMHTMLTABLESECTIONELEMENT_IID); -class nsHTMLTableSection : public nsIDOMHTMLTableSectionElement, +class nsHTMLTableSectionElement : public nsIDOMHTMLTableSectionElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLTableSection(nsIAtom* aTag); - ~nsHTMLTableSection(); + nsHTMLTableSectionElement(nsIAtom* aTag); + ~nsHTMLTableSectionElement(); // nsISupports NS_DECL_ISUPPORTS @@ -77,35 +77,35 @@ protected: }; nsresult -NS_NewHTMLTableSection(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLTableSectionElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLTableSection(aTag); + nsIHTMLContent* it = new nsHTMLTableSectionElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLTableSection::nsHTMLTableSection(nsIAtom* aTag) +nsHTMLTableSectionElement::nsHTMLTableSectionElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLTableSection::~nsHTMLTableSection() +nsHTMLTableSectionElement::~nsHTMLTableSectionElement() { } -NS_IMPL_ADDREF(nsHTMLTableSection) +NS_IMPL_ADDREF(nsHTMLTableSectionElement) -NS_IMPL_RELEASE(nsHTMLTableSection) +NS_IMPL_RELEASE(nsHTMLTableSectionElement) nsresult -nsHTMLTableSection::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLTableSectionElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLTableSectionElementIID)) { @@ -118,9 +118,9 @@ nsHTMLTableSection::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLTableSection::CloneNode(nsIDOMNode** aReturn) +nsHTMLTableSectionElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLTableSection* it = new nsHTMLTableSection(mInner.mTag); + nsHTMLTableSectionElement* it = new nsHTMLTableSectionElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -128,11 +128,11 @@ nsHTMLTableSection::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_STRING_ATTR(nsHTMLTableSection, Align, align, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLTableSection, VAlign, valign, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableSectionElement, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableSectionElement, VAlign, valign, eSetAttrNotify_Reflow) NS_IMETHODIMP -nsHTMLTableSection::GetRows(nsIDOMHTMLCollection** aValue) +nsHTMLTableSectionElement::GetRows(nsIDOMHTMLCollection** aValue) { *aValue = 0; // XXX write me @@ -140,14 +140,14 @@ nsHTMLTableSection::GetRows(nsIDOMHTMLCollection** aValue) } NS_IMETHODIMP -nsHTMLTableSection::SetRows(nsIDOMHTMLCollection* aValue) +nsHTMLTableSectionElement::SetRows(nsIDOMHTMLCollection* aValue) { // XXX write me return NS_OK; } NS_IMETHODIMP -nsHTMLTableSection::InsertRow(PRInt32 aIndex, nsIDOMHTMLElement** aValue) +nsHTMLTableSectionElement::InsertRow(PRInt32 aIndex, nsIDOMHTMLElement** aValue) { *aValue = 0; // XXX write me @@ -155,14 +155,14 @@ nsHTMLTableSection::InsertRow(PRInt32 aIndex, nsIDOMHTMLElement** aValue) } NS_IMETHODIMP -nsHTMLTableSection::DeleteRow(PRInt32 aIndex) +nsHTMLTableSectionElement::DeleteRow(PRInt32 aIndex) { // XXX write me return NS_OK; } NS_IMETHODIMP -nsHTMLTableSection::StringToAttribute(nsIAtom* aAttribute, +nsHTMLTableSectionElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -171,7 +171,7 @@ nsHTMLTableSection::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLTableSection::AttributeToString(nsIAtom* aAttribute, +nsHTMLTableSectionElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -180,7 +180,7 @@ nsHTMLTableSection::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLTableSection::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLTableSectionElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { // XXX write me @@ -188,7 +188,7 @@ nsHTMLTableSection::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLTableSection::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLTableSectionElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/layout/html/content/src/nsHTMLTitle.cpp b/mozilla/content/html/content/src/nsHTMLTitleElement.cpp similarity index 81% rename from mozilla/layout/html/content/src/nsHTMLTitle.cpp rename to mozilla/content/html/content/src/nsHTMLTitleElement.cpp index f69d9b8667f..49b24c1c3dd 100644 --- a/mozilla/layout/html/content/src/nsHTMLTitle.cpp +++ b/mozilla/content/html/content/src/nsHTMLTitleElement.cpp @@ -21,11 +21,11 @@ #include "nsHTMLIIDs.h" #include "nsXIFConverter.h" -#define nsHTMLTitleSuper nsHTMLTagContent +#define nsHTMLTitleElementSuper nsHTMLTagContent -class nsHTMLTitle : public nsHTMLTitleSuper { +class nsHTMLTitleElement : public nsHTMLTitleElementSuper { public: - nsHTMLTitle(nsIAtom* aTag, const nsString& aTitle); + nsHTMLTitleElement(nsIAtom* aTag, const nsString& aTitle); NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame, @@ -40,7 +40,7 @@ public: NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const; protected: - virtual ~nsHTMLTitle(); + virtual ~nsHTMLTitleElement(); nsString mTitle; }; @@ -52,24 +52,24 @@ NS_NewHTMLTitle(nsIHTMLContent** aInstancePtrResult, if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLTitle(aTag, aTitle); + nsIHTMLContent* it = new nsHTMLTitleElement(aTag, aTitle); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void **) aInstancePtrResult); } -nsHTMLTitle::nsHTMLTitle(nsIAtom* aTag, const nsString& aTitle) - : nsHTMLTitleSuper(aTag), mTitle(aTitle) +nsHTMLTitleElement::nsHTMLTitleElement(nsIAtom* aTag, const nsString& aTitle) + : nsHTMLTitleElementSuper(aTag), mTitle(aTitle) { } -nsHTMLTitle::~nsHTMLTitle() +nsHTMLTitleElement::~nsHTMLTitleElement() { } NS_IMETHODIMP -nsHTMLTitle::CreateFrame(nsIPresContext* aPresContext, +nsHTMLTitleElement::CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame, nsIStyleContext* aStyleContext, nsIFrame*& aResult) @@ -85,7 +85,7 @@ nsHTMLTitle::CreateFrame(nsIPresContext* aPresContext, } NS_IMETHODIMP -nsHTMLTitle::List(FILE* out, PRInt32 aIndent) const +nsHTMLTitleElement::List(FILE* out, PRInt32 aIndent) const { NS_PRECONDITION(nsnull != mDocument, "bad content"); @@ -121,7 +121,7 @@ nsHTMLTitle::List(FILE* out, PRInt32 aIndent) const */ NS_IMETHODIMP -nsHTMLTitle::BeginConvertToXIF(nsXIFConverter& aConverter) const +nsHTMLTitleElement::BeginConvertToXIF(nsXIFConverter& aConverter) const { if (nsnull != mTag) { @@ -133,14 +133,14 @@ nsHTMLTitle::BeginConvertToXIF(nsXIFConverter& aConverter) const } NS_IMETHODIMP -nsHTMLTitle::ConvertContentToXIF(nsXIFConverter& aConverter) const +nsHTMLTitleElement::ConvertContentToXIF(nsXIFConverter& aConverter) const { aConverter.AddContent(mTitle); return NS_OK; } NS_IMETHODIMP -nsHTMLTitle::FinishConvertToXIF(nsXIFConverter& aConverter) const +nsHTMLTitleElement::FinishConvertToXIF(nsXIFConverter& aConverter) const { if (nsnull != mTag) { diff --git a/mozilla/layout/html/content/src/nsHTMLUList.cpp b/mozilla/content/html/content/src/nsHTMLUListElement.cpp similarity index 78% rename from mozilla/layout/html/content/src/nsHTMLUList.cpp rename to mozilla/content/html/content/src/nsHTMLUListElement.cpp index 1116c395e82..fb7fbaba07a 100644 --- a/mozilla/layout/html/content/src/nsHTMLUList.cpp +++ b/mozilla/content/html/content/src/nsHTMLUListElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLUListElementIID, NS_IDOMHTMLULISTELEMENT_IID); -class nsHTMLUList : public nsIDOMHTMLUListElement, +class nsHTMLUListElement : public nsIDOMHTMLUListElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLUList(nsIAtom* aTag); - ~nsHTMLUList(); + nsHTMLUListElement(nsIAtom* aTag); + ~nsHTMLUListElement(); // nsISupports NS_DECL_ISUPPORTS @@ -73,35 +73,35 @@ protected: }; nsresult -NS_NewHTMLUList(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLUListElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLUList(aTag); + nsIHTMLContent* it = new nsHTMLUListElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLUList::nsHTMLUList(nsIAtom* aTag) +nsHTMLUListElement::nsHTMLUListElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLUList::~nsHTMLUList() +nsHTMLUListElement::~nsHTMLUListElement() { } -NS_IMPL_ADDREF(nsHTMLUList) +NS_IMPL_ADDREF(nsHTMLUListElement) -NS_IMPL_RELEASE(nsHTMLUList) +NS_IMPL_RELEASE(nsHTMLUListElement) nsresult -nsHTMLUList::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLUListElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLUListElementIID)) { @@ -114,9 +114,9 @@ nsHTMLUList::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLUList::CloneNode(nsIDOMNode** aReturn) +nsHTMLUListElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLUList* it = new nsHTMLUList(mInner.mTag); + nsHTMLUListElement* it = new nsHTMLUListElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -124,11 +124,11 @@ nsHTMLUList::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_BOOL_ATTR(nsHTMLUList, Compact, compact, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLUList, Type, compact, eSetAttrNotify_Reflow) +NS_IMPL_BOOL_ATTR(nsHTMLUListElement, Compact, compact, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLUListElement, Type, compact, eSetAttrNotify_Reflow) NS_IMETHODIMP -nsHTMLUList::StringToAttribute(nsIAtom* aAttribute, +nsHTMLUListElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -137,7 +137,7 @@ nsHTMLUList::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLUList::AttributeToString(nsIAtom* aAttribute, +nsHTMLUListElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -146,7 +146,7 @@ nsHTMLUList::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLUList::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLUListElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { // XXX write me @@ -154,7 +154,7 @@ nsHTMLUList::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLUList::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLUListElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/layout/html/content/src/makefile.win b/mozilla/layout/html/content/src/makefile.win index 9516c6e806b..309b52a4c1e 100644 --- a/mozilla/layout/html/content/src/makefile.win +++ b/mozilla/layout/html/content/src/makefile.win @@ -23,101 +23,103 @@ REQUIRES=xpcom raptor js DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN CPPSRCS= \ - nsHTMLAnchor.cpp \ - nsHTMLApplet.cpp \ - nsHTMLArea.cpp \ - nsHTMLBR.cpp \ - nsHTMLBase.cpp \ - nsHTMLBaseFont.cpp \ - nsHTMLBody.cpp \ - nsHTMLComment.cpp \ - nsHTMLDList.cpp \ - nsHTMLDel.cpp \ - nsHTMLDirectory.cpp \ - nsHTMLDiv.cpp \ - nsHTMLEmbed.cpp \ - nsHTMLFont.cpp \ - nsHTMLGenericContent.cpp \ - nsHTMLHR.cpp \ - nsHTMLHead.cpp \ - nsHTMLHeading.cpp \ - nsHTMLHtml.cpp \ - nsHTMLInput.cpp \ - nsHTMLIns.cpp \ - nsHTMLLI.cpp \ - nsHTMLLayer.cpp \ - nsHTMLLink.cpp \ - nsHTMLMap.cpp \ - nsHTMLMenu.cpp \ - nsHTMLMeta.cpp \ - nsHTMLMod.cpp \ - nsHTMLOList.cpp \ - nsHTMLObject.cpp \ - nsHTMLOption.cpp \ - nsHTMLParagraph.cpp \ - nsHTMLParam.cpp \ - nsHTMLPre.cpp \ - nsHTMLQuote.cpp \ - nsHTMLScript.cpp \ - nsHTMLStyle.cpp \ - nsHTMLTable.cpp \ - nsHTMLTableCaption.cpp \ - nsHTMLTableCell.cpp \ - nsHTMLTableCol.cpp \ - nsHTMLTableRow.cpp \ - nsHTMLTableSection.cpp \ - nsHTMLTitle.cpp \ - nsHTMLUList.cpp \ - nsObjectContent.cpp \ + nsCommentNode.cpp \ + nsGenericHTMLElement.cpp \ + nsHTMLAnchorElement.cpp \ + nsHTMLAppletElement.cpp \ + nsHTMLAreaElement.cpp \ + nsHTMLBRElement.cpp \ + nsHTMLBaseElement.cpp \ + nsHTMLBaseFontElement.cpp \ + nsHTMLBodyElement.cpp \ + nsHTMLDListElement.cpp \ + nsHTMLDelElement.cpp \ + nsHTMLDirectoryElement.cpp \ + nsHTMLDivElement.cpp \ + nsHTMLEmbedElement.cpp \ + nsHTMLFontElement.cpp \ + nsHTMLFormElement.cpp \ + nsHTMLHRElement.cpp \ + nsHTMLHeadElement.cpp \ + nsHTMLHeadingElement.cpp \ + nsHTMLHtmlElement.cpp \ + nsHTMLInputElement.cpp \ + nsHTMLInsElement.cpp \ + nsHTMLLIElement.cpp \ + nsHTMLLayerElement.cpp \ + nsHTMLLinkElement.cpp \ + nsHTMLMapElement.cpp \ + nsHTMLMenuElement.cpp \ + nsHTMLMetaElement.cpp \ + nsHTMLModElement.cpp \ + nsHTMLOListElement.cpp \ + nsHTMLObjectElement.cpp \ + nsHTMLOptionElement.cpp \ + nsHTMLParagraphElement.cpp \ + nsHTMLParamElement.cpp \ + nsHTMLPreElement.cpp \ + nsHTMLQuoteElement.cpp \ + nsHTMLScriptElement.cpp \ + nsHTMLSelectElement.cpp \ + nsHTMLStyleElement.cpp \ + nsHTMLTableElement.cpp \ + nsHTMLTableCaptionElement.cpp \ + nsHTMLTableCellElement.cpp \ + nsHTMLTableColElement.cpp \ + nsHTMLTableRowElement.cpp \ + nsHTMLTableSectionElement.cpp \ + nsHTMLTitleElement.cpp \ + nsHTMLUListElement.cpp \ $(NULL) -CPP_OBJS= \ - .\$(OBJDIR)\nsHTMLAnchor.obj \ - .\$(OBJDIR)\nsHTMLApplet.obj \ - .\$(OBJDIR)\nsHTMLArea.obj \ - .\$(OBJDIR)\nsHTMLBR.obj \ - .\$(OBJDIR)\nsHTMLBase.obj \ - .\$(OBJDIR)\nsHTMLBaseFont.obj \ - .\$(OBJDIR)\nsHTMLBody.obj \ - .\$(OBJDIR)\nsHTMLComment.obj \ - .\$(OBJDIR)\nsHTMLDList.obj \ - .\$(OBJDIR)\nsHTMLDel.obj \ - .\$(OBJDIR)\nsHTMLDirectory.obj \ - .\$(OBJDIR)\nsHTMLDiv.obj \ - .\$(OBJDIR)\nsHTMLEmbed.obj \ - .\$(OBJDIR)\nsHTMLFont.obj \ - .\$(OBJDIR)\nsHTMLGenericContent.obj \ - .\$(OBJDIR)\nsHTMLHR.obj \ - .\$(OBJDIR)\nsHTMLHead.obj \ - .\$(OBJDIR)\nsHTMLHeading.obj \ - .\$(OBJDIR)\nsHTMLHtml.obj \ - .\$(OBJDIR)\nsHTMLInput.obj \ - .\$(OBJDIR)\nsHTMLIns.obj \ - .\$(OBJDIR)\nsHTMLLI.obj \ - .\$(OBJDIR)\nsHTMLLayer.obj \ - .\$(OBJDIR)\nsHTMLLink.obj \ - .\$(OBJDIR)\nsHTMLMap.obj \ - .\$(OBJDIR)\nsHTMLMenu.obj \ - .\$(OBJDIR)\nsHTMLMeta.obj \ - .\$(OBJDIR)\nsHTMLMod.obj \ - .\$(OBJDIR)\nsHTMLOList.obj \ - .\$(OBJDIR)\nsHTMLObject.obj \ - .\$(OBJDIR)\nsHTMLOption.obj \ - .\$(OBJDIR)\nsHTMLParagraph.obj \ - .\$(OBJDIR)\nsHTMLParam.obj \ - .\$(OBJDIR)\nsHTMLPre.obj \ - .\$(OBJDIR)\nsHTMLQuote.obj \ - .\$(OBJDIR)\nsHTMLScript.obj \ - .\$(OBJDIR)\nsHTMLStyle.obj \ - .\$(OBJDIR)\nsHTMLTable.obj \ - .\$(OBJDIR)\nsHTMLTableCaption.obj \ - .\$(OBJDIR)\nsHTMLTableCell.obj \ - .\$(OBJDIR)\nsHTMLTableCol.obj \ - .\$(OBJDIR)\nsHTMLTableRow.obj \ - .\$(OBJDIR)\nsHTMLTableSection.obj \ - .\$(OBJDIR)\nsHTMLTitle.obj \ - .\$(OBJDIR)\nsHTMLUList.obj \ - .\$(OBJDIR)\nsObjectContent.obj \ +CPP_OBJS= \ + .\$(OBJDIR)\nsCommentNode.obj \ + .\$(OBJDIR)\nsGenericHTMLElement.obj \ + .\$(OBJDIR)\nsHTMLAnchorElement.obj \ + .\$(OBJDIR)\nsHTMLAppletElement.obj \ + .\$(OBJDIR)\nsHTMLAreaElement.obj \ + .\$(OBJDIR)\nsHTMLBRElement.obj \ + .\$(OBJDIR)\nsHTMLBaseElement.obj \ + .\$(OBJDIR)\nsHTMLBaseFontElement.obj \ + .\$(OBJDIR)\nsHTMLBodyElement.obj \ + .\$(OBJDIR)\nsHTMLDListElement.obj \ + .\$(OBJDIR)\nsHTMLDelElement.obj \ + .\$(OBJDIR)\nsHTMLDirectoryElement.obj \ + .\$(OBJDIR)\nsHTMLDivElement.obj \ + .\$(OBJDIR)\nsHTMLEmbedElement.obj \ + .\$(OBJDIR)\nsHTMLFontElement.obj \ + .\$(OBJDIR)\nsHTMLFormElement.obj \ + .\$(OBJDIR)\nsHTMLHRElement.obj \ + .\$(OBJDIR)\nsHTMLHeadElement.obj \ + .\$(OBJDIR)\nsHTMLHeadingElement.obj \ + .\$(OBJDIR)\nsHTMLHtmlElement.obj \ + .\$(OBJDIR)\nsHTMLInputElement.obj \ + .\$(OBJDIR)\nsHTMLInsElement.obj \ + .\$(OBJDIR)\nsHTMLLIElement.obj \ + .\$(OBJDIR)\nsHTMLLayerElement.obj \ + .\$(OBJDIR)\nsHTMLLinkElement.obj \ + .\$(OBJDIR)\nsHTMLMapElement.obj \ + .\$(OBJDIR)\nsHTMLMenuElement.obj \ + .\$(OBJDIR)\nsHTMLMetaElement.obj \ + .\$(OBJDIR)\nsHTMLModElement.obj \ + .\$(OBJDIR)\nsHTMLOListElement.obj \ + .\$(OBJDIR)\nsHTMLObjectElement.obj \ + .\$(OBJDIR)\nsHTMLOptionElement.obj \ + .\$(OBJDIR)\nsHTMLParagraphElement.obj \ + .\$(OBJDIR)\nsHTMLParamElement.obj \ + .\$(OBJDIR)\nsHTMLPreElement.obj \ + .\$(OBJDIR)\nsHTMLQuoteElement.obj \ + .\$(OBJDIR)\nsHTMLScriptElement.obj \ + .\$(OBJDIR)\nsHTMLSelectElement.obj \ + .\$(OBJDIR)\nsHTMLStyleElement.obj \ + .\$(OBJDIR)\nsHTMLTableElement.obj \ + .\$(OBJDIR)\nsHTMLTableCaptionElement.obj \ + .\$(OBJDIR)\nsHTMLTableCellElement.obj \ + .\$(OBJDIR)\nsHTMLTableColElement.obj \ + .\$(OBJDIR)\nsHTMLTableRowElement.obj \ + .\$(OBJDIR)\nsHTMLTableSectionElement.obj \ + .\$(OBJDIR)\nsHTMLTitleElement.obj \ + .\$(OBJDIR)\nsHTMLUListElement.obj \ $(NULL) LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \ diff --git a/mozilla/layout/html/content/src/nsHTMLComment.cpp b/mozilla/layout/html/content/src/nsCommentNode.cpp similarity index 81% rename from mozilla/layout/html/content/src/nsHTMLComment.cpp rename to mozilla/layout/html/content/src/nsCommentNode.cpp index 59001306623..e3e36c285a3 100644 --- a/mozilla/layout/html/content/src/nsHTMLComment.cpp +++ b/mozilla/layout/html/content/src/nsCommentNode.cpp @@ -20,11 +20,13 @@ #include "nsFrame.h" #include "nsHTMLIIDs.h" -#define nsHTMLCommentSuper nsHTMLTagContent +// XXX rework this -class nsHTMLComment : public nsHTMLCommentSuper { +#define nsCommentNodeSuper nsHTMLTagContent + +class nsCommentNode : public nsCommentNodeSuper { public: - nsHTMLComment(nsIAtom* aTag, const nsString& aComment); + nsCommentNode(nsIAtom* aTag, const nsString& aComment); NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame, @@ -34,22 +36,22 @@ public: NS_IMETHOD List(FILE* out, PRInt32 aIndent) const; protected: - virtual ~nsHTMLComment(); + virtual ~nsCommentNode(); nsString mComment; }; -nsHTMLComment::nsHTMLComment(nsIAtom* aTag, const nsString& aComment) - : nsHTMLCommentSuper(aTag), +nsCommentNode::nsCommentNode(nsIAtom* aTag, const nsString& aComment) + : nsCommentNodeSuper(aTag), mComment(aComment) { } -nsHTMLComment::~nsHTMLComment() +nsCommentNode::~nsCommentNode() { } NS_IMETHODIMP -nsHTMLComment::CreateFrame(nsIPresContext* aPresContext, +nsCommentNode::CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame, nsIStyleContext* aStyleContext, nsIFrame*& aResult) @@ -65,7 +67,7 @@ nsHTMLComment::CreateFrame(nsIPresContext* aPresContext, } NS_IMETHODIMP -nsHTMLComment::List(FILE* out, PRInt32 aIndent) const +nsCommentNode::List(FILE* out, PRInt32 aIndent) const { NS_PRECONDITION(nsnull != mDocument, "bad content"); @@ -90,14 +92,14 @@ nsHTMLComment::List(FILE* out, PRInt32 aIndent) const } nsresult -NS_NewHTMLComment(nsIHTMLContent** aInstancePtrResult, +NS_NewCommentNode(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag, const nsString& aComment) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLComment(aTag, aComment); + nsIHTMLContent* it = new nsCommentNode(aTag, aComment); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp b/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp new file mode 100644 index 00000000000..9af8a32f0d9 --- /dev/null +++ b/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp @@ -0,0 +1,2738 @@ +/* -*- 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 "nsGenericHTMLElement.h" + +#include "nsIAtom.h" +#include "nsIContentDelegate.h" +#include "nsICSSParser.h" +#include "nsIDocument.h" +#include "nsIDOMAttribute.h" +#include "nsIDOMEventReceiver.h" +#include "nsIDOMNamedNodeMap.h" +#include "nsIEventListenerManager.h" +#include "nsIHTMLAttributes.h" +#include "nsIHTMLStyleSheet.h" +#include "nsIHTMLDocument.h" +#include "nsIHTMLContent.h" +#include "nsILinkHandler.h" +#include "nsIScriptContextOwner.h" +#include "nsIScriptGlobalObject.h" +#include "nsIScriptObjectOwner.h" +#include "nsISizeOfHandler.h" +#include "nsIStyleContext.h" +#include "nsIStyleRule.h" +#include "nsISupportsArray.h" +#include "nsIURL.h" +#include "nsStyleConsts.h" +#include "nsXIFConverter.h" +#include "nsFrame.h" + +#include "nsString.h" +#include "nsHTMLAtoms.h" +#include "nsDOMEventsIIDs.h" +#include "nsCSSBlockFrame.h" +#include "nsCSSInlineFrame.h" +#include "nsIEventStateManager.h" +#include "nsDOMEvent.h" +#include "nsIPrivateDOMEvent.h" +#include "prprf.h" + +// XXX todo: add in missing out-of-memory checks + +NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID); +NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID); +NS_DEFINE_IID(kIDOMHTMLElementIID, NS_IDOMHTMLELEMENT_IID); +NS_DEFINE_IID(kIDOMEventReceiverIID, NS_IDOMEVENTRECEIVER_IID); +NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); +NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID); +//NS_DEFINE_IID(kIHTMLContentIID, NS_IHTMLCONTENT_IID); + +static NS_DEFINE_IID(kIContentDelegateIID, NS_ICONTENTDELEGATE_IID); +static NS_DEFINE_IID(kIDOMAttributeIID, NS_IDOMATTRIBUTE_IID); +static NS_DEFINE_IID(kIDOMNamedNodeMapIID, NS_IDOMNAMEDNODEMAP_IID); +static NS_DEFINE_IID(kIPrivateDOMEventIID, NS_IPRIVATEDOMEVENT_IID); +static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID); +static NS_DEFINE_IID(kIHTMLDocumentIID, NS_IHTMLDOCUMENT_IID); + +static nsIContentDelegate* gContentDelegate; + +/** + * THE html content delegate. There is exactly one instance of this + * class and it's used for all html content. It just turns around + * and asks the content object to create the frame. + */ +class ZContentDelegate : public nsIContentDelegate { +public: + ZContentDelegate(); + NS_DECL_ISUPPORTS + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIContent* aContent, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); +protected: + ~ZContentDelegate(); +}; + +// Attribute helper class used to wrap up an attribute with a dom +// object that implements nsIDOMAttribute and nsIDOMNode and +// nsIScriptObjectOwner +class DOMAttribute : public nsIDOMAttribute, public nsIScriptObjectOwner { +public: + DOMAttribute(const nsString &aName, const nsString &aValue); + ~DOMAttribute(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD GetScriptObject(nsIScriptContext* aContext, void** aScriptObject); + NS_IMETHOD ResetScriptObject(); + + // nsIDOMAttribute interface + NS_IMETHOD GetSpecified(PRBool* aSpecified); + NS_IMETHOD SetSpecified(PRBool aSpecified); + NS_IMETHOD GetName(nsString& aReturn); + NS_IMETHOD GetValue(nsString& aReturn); + + // nsIDOMNode interface + NS_IMETHOD GetNodeName(nsString& aNodeName); + NS_IMETHOD GetNodeValue(nsString& aNodeValue); + NS_IMETHOD SetNodeValue(const nsString& aNodeValue); + NS_IMETHOD GetNodeType(PRInt32* aNodeType); + NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode); + NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes); + NS_IMETHOD GetHasChildNodes(PRBool* aHasChildNodes); + NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild); + NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild); + NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling); + NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling); + NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes); + NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, + nsIDOMNode** aReturn); + NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, + nsIDOMNode** aReturn); + NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn); + NS_IMETHOD AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn); + NS_IMETHOD CloneNode(nsIDOMNode** aReturn); + NS_IMETHOD Equals(nsIDOMNode* aNode, PRBool aDeep, PRBool* aReturn); + +private: + nsString mName; + nsString mValue; + void* mScriptObject; +}; + +// Another helper class that implements the nsIDOMNamedNodeMap interface. +class DOMAttributeMap : public nsIDOMNamedNodeMap, + public nsIScriptObjectOwner +{ +public: + DOMAttributeMap(nsIHTMLContent &aContent); + virtual ~DOMAttributeMap(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD GetScriptObject(nsIScriptContext* aContext, void** aScriptObject); + NS_IMETHOD ResetScriptObject(); + + // nsIDOMNamedNodeMap interface + NS_IMETHOD GetLength(PRUint32* aSize); + NS_IMETHOD GetNamedItem(const nsString& aName, nsIDOMNode** aReturn); + NS_IMETHOD SetNamedItem(nsIDOMNode* aNode); + NS_IMETHOD RemoveNamedItem(const nsString& aName, nsIDOMNode** aReturn); + NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn); + +private: + nsIHTMLContent& mContent; + void* mScriptObject; +}; + +//---------------------------------------------------------------------- + +ZContentDelegate::ZContentDelegate() +{ + NS_INIT_REFCNT(); +} + +NS_IMPL_ISUPPORTS(ZContentDelegate, kIContentDelegateIID); + +ZContentDelegate::~ZContentDelegate() +{ +} + +NS_METHOD +ZContentDelegate::CreateFrame(nsIPresContext* aPresContext, + nsIContent* aContent, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) +{ + NS_PRECONDITION(nsnull != aContent, "null ptr"); + + // Make sure the content is html content + nsIHTMLContent* hc; + nsIFrame* frame = nsnull; + nsresult rv = aContent->QueryInterface(kIHTMLContentIID, (void**) &hc); + if (NS_OK != rv) { + // This means that *somehow* somebody which is not an html + // content object got ahold of this delegate and tried to + // create a frame with it. Give them back an nsFrame. + rv = nsFrame::NewFrame(&frame, aContent, aParentFrame); + if (NS_OK == rv) { + frame->SetStyleContext(aPresContext, aStyleContext); + } + } + else { + // Ask the content object to create the frame + rv = hc->CreateFrame(aPresContext, aParentFrame, aStyleContext, frame); + NS_RELEASE(hc); + } + aResult = frame; + return rv; +} + +//---------------------------------------------------------------------- + +DOMAttribute::DOMAttribute(const nsString& aName, const nsString& aValue) + : mName(aName), mValue(aValue) +{ + mRefCnt = 1; + mScriptObject = nsnull; +} + +DOMAttribute::~DOMAttribute() +{ +} + +nsresult +DOMAttribute::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + if (NULL == aInstancePtr) { + return NS_ERROR_NULL_POINTER; + } + if (aIID.Equals(kIDOMAttributeIID)) { + nsIDOMAttribute* tmp = this; + *aInstancePtr = (void*)tmp; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kIScriptObjectOwnerIID)) { + nsIScriptObjectOwner* tmp = this; + *aInstancePtr = (void*)tmp; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kISupportsIID)) { + nsIDOMAttribute* tmp1 = this; + nsISupports* tmp2 = tmp1; + *aInstancePtr = (void*)tmp2; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +NS_IMPL_ADDREF(DOMAttribute) + +NS_IMPL_RELEASE(DOMAttribute) + +nsresult +DOMAttribute::GetScriptObject(nsIScriptContext *aContext, + void** aScriptObject) +{ + nsresult res = NS_OK; + if (nsnull == mScriptObject) { + res = NS_NewScriptAttribute(aContext, this, nsnull, + (void **)&mScriptObject); + } + *aScriptObject = mScriptObject; + return res; +} + +nsresult +DOMAttribute::ResetScriptObject() +{ + mScriptObject = nsnull; + return NS_OK; +} + +nsresult +DOMAttribute::GetName(nsString& aName) +{ + aName = mName; + return NS_OK; +} + +nsresult +DOMAttribute::GetValue(nsString& aValue) +{ + aValue = mValue; + return NS_OK; +} + +nsresult +DOMAttribute::GetSpecified(PRBool* aSpecified) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +nsresult +DOMAttribute::SetSpecified(PRBool specified) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +DOMAttribute::GetNodeName(nsString& aNodeName) +{ + return GetName(aNodeName); +} + +NS_IMETHODIMP +DOMAttribute::GetNodeValue(nsString& aNodeValue) +{ + return GetValue(aNodeValue); +} + +NS_IMETHODIMP +DOMAttribute::SetNodeValue(const nsString& aNodeValue) +{ + // You can't actually do this, but we'll fail silently + return NS_OK; +} + +NS_IMETHODIMP +DOMAttribute::GetNodeType(PRInt32* aNodeType) +{ + *aNodeType = (PRInt32)nsIDOMNode::ATTRIBUTE; + return NS_OK; +} + +NS_IMETHODIMP +DOMAttribute::GetParentNode(nsIDOMNode** aParentNode) +{ + *aParentNode = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +DOMAttribute::GetChildNodes(nsIDOMNodeList** aChildNodes) +{ + *aChildNodes = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +DOMAttribute::GetHasChildNodes(PRBool* aHasChildNodes) +{ + *aHasChildNodes = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +DOMAttribute::GetFirstChild(nsIDOMNode** aFirstChild) +{ + *aFirstChild = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +DOMAttribute::GetLastChild(nsIDOMNode** aLastChild) +{ + *aLastChild = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +DOMAttribute::GetPreviousSibling(nsIDOMNode** aPreviousSibling) +{ + *aPreviousSibling = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +DOMAttribute::GetNextSibling(nsIDOMNode** aNextSibling) +{ + *aNextSibling = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +DOMAttribute::GetAttributes(nsIDOMNamedNodeMap** aAttributes) +{ + *aAttributes = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +DOMAttribute::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMNode** aReturn) +{ + return NS_ERROR_FAILURE; +} + +NS_IMETHODIMP +DOMAttribute::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMNode** aReturn) +{ + return NS_ERROR_FAILURE; +} + +NS_IMETHODIMP +DOMAttribute::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) +{ + return NS_ERROR_FAILURE; +} + +NS_IMETHODIMP +DOMAttribute::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn) +{ + return NS_ERROR_FAILURE; +} + +NS_IMETHODIMP +DOMAttribute::CloneNode(nsIDOMNode** aReturn) +{ + DOMAttribute* newAttr = new DOMAttribute(mName, mValue); + if (nsnull == newAttr) { + return NS_ERROR_OUT_OF_MEMORY; + } + + *aReturn = newAttr; + return NS_OK; +} + +NS_IMETHODIMP +DOMAttribute::Equals(nsIDOMNode* aNode, PRBool aDeep, PRBool* aReturn) +{ + // XXX TBI + return NS_OK; +} + +//---------------------------------------------------------------------- + +DOMAttributeMap::DOMAttributeMap(nsIHTMLContent& aContent) + : mContent(aContent) +{ + mRefCnt = 1; + mContent.AddRef(); + mScriptObject = nsnull; +} + +DOMAttributeMap::~DOMAttributeMap() +{ + mContent.Release(); +} + +nsresult +DOMAttributeMap::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + if (NULL == aInstancePtr) { + return NS_ERROR_NULL_POINTER; + } + if (aIID.Equals(kIDOMNamedNodeMapIID)) { + nsIDOMNamedNodeMap* tmp = this; + *aInstancePtr = (void*)tmp; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kIScriptObjectOwnerIID)) { + nsIScriptObjectOwner* tmp = this; + *aInstancePtr = (void*)tmp; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kISupportsIID)) { + nsIDOMNamedNodeMap* tmp1 = this; + nsISupports* tmp2 = tmp1; + *aInstancePtr = (void*)tmp2; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +NS_IMPL_ADDREF(DOMAttributeMap) + +NS_IMPL_RELEASE(DOMAttributeMap) + +nsresult +DOMAttributeMap::GetScriptObject(nsIScriptContext *aContext, + void** aScriptObject) +{ + nsresult res = NS_OK; + if (nsnull == mScriptObject) { + res = NS_NewScriptNamedNodeMap(aContext, this, nsnull, + (void**)&mScriptObject); + } + *aScriptObject = mScriptObject; + return res; +} + +nsresult +DOMAttributeMap::ResetScriptObject() +{ + mScriptObject = nsnull; + return NS_OK; +} + +nsresult +DOMAttributeMap::GetNamedItem(const nsString &aAttrName, + nsIDOMNode** aAttribute) +{ + nsAutoString value; + mContent.GetAttribute(aAttrName, value); + *aAttribute = (nsIDOMNode *) new DOMAttribute(aAttrName, value); + return NS_OK; +} + +nsresult +DOMAttributeMap::SetNamedItem(nsIDOMNode *aNode) +{ + nsIDOMAttribute *attribute; + nsAutoString name, value; + nsresult err; + + if (NS_OK != (err = aNode->QueryInterface(kIDOMAttributeIID, + (void **)&attribute))) { + return err; + } + + attribute->GetName(name); + attribute->GetValue(value); + NS_RELEASE(attribute); + + mContent.SetAttribute(name, value, PR_TRUE); + return NS_OK; +} + +NS_IMETHODIMP +DOMAttributeMap::RemoveNamedItem(const nsString& aName, nsIDOMNode** aReturn) +{ + nsresult res = GetNamedItem(aName, aReturn); + if (NS_OK == res) { + nsAutoString upper; + aName.ToUpperCase(upper); + nsIAtom* attr = NS_NewAtom(upper); + mContent.UnsetAttribute(attr); + } + + return res; +} + +nsresult +DOMAttributeMap::Item(PRUint32 aIndex, nsIDOMNode** aReturn) +{ + nsresult res = NS_ERROR_FAILURE; + nsAutoString name, value; + nsISupportsArray *attributes = nsnull; + if (NS_OK == NS_NewISupportsArray(&attributes)) { + PRInt32 count; + mContent.GetAllAttributeNames(attributes, count); + if (count > 0) { + if ((PRInt32)aIndex < count) { + nsISupports *att = attributes->ElementAt(aIndex); + static NS_DEFINE_IID(kIAtom, NS_IATOM_IID); + nsIAtom *atName = nsnull; + if (nsnull != att && NS_OK == att->QueryInterface(kIAtom, (void**)&atName)) { + atName->ToString(name); + if (NS_CONTENT_ATTR_NOT_THERE != mContent.GetAttribute(name, value)) { + *aReturn = (nsIDOMNode *)new DOMAttribute(name, value); + res = NS_OK; + } + NS_RELEASE(atName); + } + } + } + NS_RELEASE(attributes); + } + + return res; +} + +nsresult +DOMAttributeMap::GetLength(PRUint32 *aLength) +{ + PRInt32 n; + nsresult rv = mContent.GetAttributeCount(n); + *aLength = PRUint32(n); + return rv; +} + +//---------------------------------------------------------------------- + +static nsresult EnsureWritableAttributes(nsIHTMLAttributes*& aAttributes, PRBool aCreate) +{ + nsresult result = NS_OK; + + if (nsnull == aAttributes) { + if (PR_TRUE == aCreate) { + result = NS_NewHTMLAttributes(&aAttributes); + if (NS_OK == result) { + aAttributes->AddContentRef(); + } + } + } + else { + PRInt32 contentRefCount; + aAttributes->GetContentRefCount(contentRefCount); + if (1 < contentRefCount) { + nsIHTMLAttributes* attrs; + result = aAttributes->Clone(&attrs); + if (NS_OK == result) { + aAttributes->ReleaseContentRef(); + NS_RELEASE(aAttributes); + aAttributes = attrs; + aAttributes->AddContentRef(); + } + } + } + return result; +} + +static void ReleaseAttributes(nsIHTMLAttributes*& aAttributes) +{ + aAttributes->ReleaseContentRef(); + NS_RELEASE(aAttributes); +} + + +nsHTMLGenericContent::nsHTMLGenericContent() +{ + mDocument = nsnull; + mParent = nsnull; + mAttributes = nsnull; + mTag = nsnull; + mContent = nsnull; + mScriptObject = nsnull; + mListenerManager = nsnull; + + // Create shared content delegate if this is the first html content + // object being created. + if (nsnull == gContentDelegate) { + gContentDelegate = new ZContentDelegate(); + } + + // Add a reference to the shared content delegate object + NS_ADDREF(gContentDelegate); +} + +nsHTMLGenericContent::~nsHTMLGenericContent() +{ + if (nsnull != mAttributes) { + ReleaseAttributes(mAttributes); + } + NS_IF_RELEASE(mTag); + NS_IF_RELEASE(mListenerManager); + // XXX what about mScriptObject? it's now safe to GC it... + + NS_PRECONDITION(nsnull != gContentDelegate, "null content delegate"); + if (nsnull != gContentDelegate) { + // Remove our reference to the shared content delegate object. If + // the last reference just went away, null out gContentDelegate. + nsrefcnt rc = gContentDelegate->Release(); + if (0 == rc) { + gContentDelegate = nsnull; + } + } +} + +void +nsHTMLGenericContent::Init(nsIHTMLContent* aOuterContentObject, + nsIAtom* aTag) +{ + NS_ASSERTION((nsnull == mContent) && (nsnull != aOuterContentObject), + "null ptr"); + mContent = aOuterContentObject; + mTag = aTag; + NS_IF_ADDREF(aTag); +} + +nsresult +nsHTMLGenericContent::GetNodeName(nsString& aNodeName) +{ + return GetTagName(aNodeName); +} + +nsresult +nsHTMLGenericContent::GetNodeValue(nsString& aNodeValue) +{ + aNodeValue.Truncate(); + return NS_OK; +} + +nsresult +nsHTMLGenericContent::SetNodeValue(const nsString& aNodeValue) +{ + return NS_OK; +} + +nsresult +nsHTMLGenericContent::GetNodeType(PRInt32* aNodeType) +{ + *aNodeType = nsIDOMNode::ELEMENT; + return NS_OK; +} + +nsresult +nsHTMLGenericContent::GetParentNode(nsIDOMNode** aParentNode) +{ + if (nsnull != mParent) { + nsresult res = mParent->QueryInterface(kIDOMNodeIID, (void**)aParentNode); + NS_ASSERTION(NS_OK == res, "Must be a DOM Node"); + return res; + } + else { + *aParentNode = nsnull; + } + return NS_OK; +} + +nsresult +nsHTMLGenericContent::GetPreviousSibling(nsIDOMNode** aNode) +{ + if (nsnull != mParent) { + PRInt32 pos; + mParent->IndexOf(mContent, pos); + if (pos > -1) { + nsIContent* prev; + mParent->ChildAt(--pos, prev); + if (nsnull != prev) { + nsresult res = prev->QueryInterface(kIDOMNodeIID, (void**)aNode); + NS_ASSERTION(NS_OK == res, "Must be a DOM Node"); + NS_RELEASE(prev); // balance the AddRef in ChildAt() + return res; + } + } + } + *aNode = nsnull; + return NS_OK; +} + +nsresult +nsHTMLGenericContent::GetNextSibling(nsIDOMNode** aNextSibling) +{ + if (nsnull != mParent) { + PRInt32 pos; + mParent->IndexOf(mContent, pos); + if (pos > -1 ) { + nsIContent* prev; + mParent->ChildAt(++pos, prev); + if (nsnull != prev) { + nsresult res = prev->QueryInterface(kIDOMNodeIID,(void**)aNextSibling); + NS_ASSERTION(NS_OK == res, "Must be a DOM Node"); + NS_RELEASE(prev); // balance the AddRef in ChildAt() + return res; + } + } + } + *aNextSibling = nsnull; + return NS_OK; +} + +nsresult +nsHTMLGenericContent::GetAttributes(nsIDOMNamedNodeMap** aAttributes) +{ + NS_PRECONDITION(nsnull != aAttributes, "null pointer argument"); + if (nsnull != mAttributes) { + // XXX Should we create a new one every time or should we + // cache one after we create it? If we find that this is + // something that's called often, we might need to do the + // latter. + *aAttributes = new DOMAttributeMap(*mContent); + } + else { + *aAttributes = nsnull; + } + return NS_OK; +} + +nsresult +nsHTMLGenericContent::GetTagName(nsString& aTagName) +{ + aTagName.Truncate(); + if (nsnull != mTag) { + mTag->ToString(aTagName); + } + return NS_OK; +} + +nsresult +nsHTMLGenericContent::GetDOMAttribute(const nsString& aName, nsString& aReturn) +{ + GetAttribute(aName, aReturn); + return NS_OK; +} + +nsresult +nsHTMLGenericContent::SetDOMAttribute(const nsString& aName, + const nsString& aValue) +{ + SetAttribute(aName, aValue, PR_TRUE); + return NS_OK; +} + +nsresult +nsHTMLGenericContent::RemoveAttribute(const nsString& aName) +{ + nsAutoString upper; + aName.ToUpperCase(upper); + nsIAtom* attr = NS_NewAtom(upper); + UnsetAttribute(attr); + NS_RELEASE(attr); + return NS_OK; +} + +nsresult +nsHTMLGenericContent::GetAttributeNode(const nsString& aName, + nsIDOMAttribute** aReturn) +{ + nsAutoString value; + if (NS_CONTENT_ATTR_NOT_THERE != GetAttribute(aName, value)) { + *aReturn = new DOMAttribute(aName, value); + } + return NS_OK; +} + +nsresult +nsHTMLGenericContent::SetAttributeNode(nsIDOMAttribute* aAttribute) +{ + NS_PRECONDITION(nsnull != aAttribute, "null attribute"); + + nsresult res = NS_ERROR_FAILURE; + + if (nsnull != aAttribute) { + nsAutoString name, value; + res = aAttribute->GetName(name); + if (NS_OK == res) { + res = aAttribute->GetValue(value); + if (NS_OK == res) { + SetAttribute(name, value, PR_TRUE); + } + } + } + return res; +} + +nsresult +nsHTMLGenericContent::RemoveAttributeNode(nsIDOMAttribute* aAttribute) +{ + NS_PRECONDITION(nsnull != aAttribute, "null attribute"); + + nsresult res = NS_ERROR_FAILURE; + + if (nsnull != aAttribute) { + nsAutoString name; + res = aAttribute->GetName(name); + if (NS_OK == res) { + nsAutoString upper; + name.ToUpperCase(upper); + nsIAtom* attr = NS_NewAtom(upper); + UnsetAttribute(attr); + } + } + + return res; +} + +nsresult +nsHTMLGenericContent::GetElementsByTagName(const nsString& aTagname, + nsIDOMNodeList** aReturn) +{ + return NS_ERROR_NOT_IMPLEMENTED;/* XXX */ +} + +nsresult +nsHTMLGenericContent::Normalize() +{ + return NS_ERROR_NOT_IMPLEMENTED;/* XXX */ +} + +nsresult +nsHTMLGenericContent::GetId(nsString& aId) +{ + GetAttribute(nsHTMLAtoms::id, aId); + return NS_OK; +} + +nsresult +nsHTMLGenericContent::SetId(const nsString& aId) +{ + SetAttr(nsHTMLAtoms::id, aId, eSetAttrNotify_Restart); + return NS_OK; +} + +nsresult +nsHTMLGenericContent::GetTitle(nsString& aTitle) +{ + GetAttribute(nsHTMLAtoms::title, aTitle); + return NS_OK; +} + +nsresult +nsHTMLGenericContent::SetTitle(const nsString& aTitle) +{ + SetAttr(nsHTMLAtoms::title, aTitle, eSetAttrNotify_None); + return NS_OK; +} + +nsresult +nsHTMLGenericContent::GetLang(nsString& aLang) +{ + GetAttribute(nsHTMLAtoms::lang, aLang); + return NS_OK; +} + +nsresult +nsHTMLGenericContent::SetLang(const nsString& aLang) +{ + SetAttr(nsHTMLAtoms::lang, aLang, eSetAttrNotify_Reflow); + return NS_OK; +} + +nsresult +nsHTMLGenericContent::GetDir(nsString& aDir) +{ + GetAttribute(nsHTMLAtoms::dir, aDir); + return NS_OK; +} + +nsresult +nsHTMLGenericContent::SetDir(const nsString& aDir) +{ + SetAttr(nsHTMLAtoms::dir, aDir, eSetAttrNotify_Reflow); + return NS_OK; +} + +nsresult +nsHTMLGenericContent::GetClassName(nsString& aClassName) +{ + GetAttribute(nsHTMLAtoms::kClass, aClassName); + return NS_OK; +} + +nsresult +nsHTMLGenericContent::SetClassName(const nsString& aClassName) +{ + SetAttr(nsHTMLAtoms::kClass, aClassName, eSetAttrNotify_Restart); + return NS_OK; +} + +nsresult +nsHTMLGenericContent::GetDocument(nsIDocument*& aResult) const +{ + aResult = mDocument; + NS_IF_ADDREF(mDocument); + return NS_OK; +} + +static nsIHTMLStyleSheet* GetAttrStyleSheet(nsIDocument* aDocument) +{ + nsIHTMLStyleSheet* sheet = nsnull; + nsIHTMLDocument* htmlDoc; + + if (nsnull != aDocument) { + if (NS_OK == aDocument->QueryInterface(kIHTMLDocumentIID, (void**)&htmlDoc)) { + htmlDoc->GetAttributeStyleSheet(&sheet); + } + } + NS_ASSERTION(nsnull != sheet, "can't get attribute style sheet"); + return sheet; +} + +nsresult +nsHTMLGenericContent::SetDocument(nsIDocument* aDocument) +{ + mDocument = aDocument; + + // Once the element is added to the doc tree we need to check if + // event handler were registered on it. Unfortunately, this means + // doing a GetAttribute for every type of handler. + if (nsnull != mAttributes) { + nsHTMLValue val; + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onclick, val)) + AddScriptEventListener(nsHTMLAtoms::onclick, val, kIDOMMouseListenerIID); + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::ondblclick, val)) + AddScriptEventListener(nsHTMLAtoms::onclick, val, kIDOMMouseListenerIID); + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onmousedown, val)) + AddScriptEventListener(nsHTMLAtoms::onmousedown, val, kIDOMMouseListenerIID); + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onmouseup, val)) + AddScriptEventListener(nsHTMLAtoms::onmouseup, val, kIDOMMouseListenerIID); + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onmouseover, val)) + AddScriptEventListener(nsHTMLAtoms::onmouseover, val, kIDOMMouseListenerIID); + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onmouseout, val)) + AddScriptEventListener(nsHTMLAtoms::onmouseout, val, kIDOMMouseListenerIID); + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onkeydown, val)) + AddScriptEventListener(nsHTMLAtoms::onkeydown, val, kIDOMKeyListenerIID); + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onkeyup, val)) + AddScriptEventListener(nsHTMLAtoms::onkeyup, val, kIDOMKeyListenerIID); + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onkeypress, val)) + AddScriptEventListener(nsHTMLAtoms::onkeypress, val, kIDOMKeyListenerIID); + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onmousemove, val)) + AddScriptEventListener(nsHTMLAtoms::onmousemove, val, kIDOMMouseMotionListenerIID); + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onload, val)) + AddScriptEventListener(nsHTMLAtoms::onload, val, kIDOMLoadListenerIID); + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onunload, val)) + AddScriptEventListener(nsHTMLAtoms::onunload, val, kIDOMLoadListenerIID); + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onabort, val)) + AddScriptEventListener(nsHTMLAtoms::onabort, val, kIDOMLoadListenerIID); + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onerror, val)) + AddScriptEventListener(nsHTMLAtoms::onerror, val, kIDOMLoadListenerIID); + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onfocus, val)) + AddScriptEventListener(nsHTMLAtoms::onfocus, val, kIDOMFocusListenerIID); + if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onblur, val)) + AddScriptEventListener(nsHTMLAtoms::onblur, val, kIDOMFocusListenerIID); + + nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument); + sheet->SetAttributesFor(mTag, mAttributes); // sync attributes with sheet + } + + return NS_OK; +} + +nsresult +nsHTMLGenericContent::GetParent(nsIContent*& aResult) const +{ + NS_IF_ADDREF(mParent); + aResult = mParent; + return NS_OK;; +} + +nsresult +nsHTMLGenericContent::SetParent(nsIContent* aParent) +{ + mParent = aParent; + return NS_OK; +} + +nsresult +nsHTMLGenericContent::IsSynthetic(PRBool& aResult) +{ + return PR_FALSE; +} + + +nsresult +nsHTMLGenericContent::GetTag(nsIAtom*& aResult) const +{ + NS_IF_ADDREF(mTag); + aResult = mTag; + return NS_OK; +} + +//void +//nsHTMLTagContent::SizeOfWithoutThis(nsISizeOfHandler* aHandler) const +//{ +// if (!aHandler->HaveSeen(mTag)) { +// mTag->SizeOf(aHandler); +// } +// if (!aHandler->HaveSeen(mAttributes)) { +// mAttributes->SizeOf(aHandler); +// } +//} + +nsresult +nsHTMLGenericContent::HandleDOMEvent(nsIPresContext& aPresContext, + nsEvent* aEvent, + nsIDOMEvent** aDOMEvent, + PRUint32 aFlags, + nsEventStatus& aEventStatus) +{ + nsresult ret = NS_OK; + + nsIDOMEvent* domEvent = nsnull; + if (DOM_EVENT_INIT == aFlags) { + nsIEventStateManager *manager; + if (NS_OK == aPresContext.GetEventStateManager(&manager)) { + manager->SetEventTarget(mContent); + NS_RELEASE(manager); + } + aDOMEvent = &domEvent; + } + + //Capturing stage + + //Local handling stage + if (nsnull != mListenerManager) { + mListenerManager->HandleEvent(aPresContext, aEvent, aDOMEvent, aEventStatus); + } + + //Bubbling stage + if (DOM_EVENT_CAPTURE != aFlags && mParent != nsnull) { + ret = mParent->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, + DOM_EVENT_BUBBLE, aEventStatus); + } + + if (DOM_EVENT_INIT == aFlags) { + // We're leaving the DOM event loop so if we created a DOM event, + // release here. + if (nsnull != *aDOMEvent) { + if (0 != (*aDOMEvent)->Release()) { + // Okay, so someone in the DOM loop (a listener, JS object) + // still has a ref to the DOM Event but the internal data + // hasn't been malloc'd. Force a copy of the data here so the + // DOM Event is still valid. + nsIPrivateDOMEvent *privateEvent; + if (NS_OK == (*aDOMEvent)->QueryInterface(kIPrivateDOMEventIID, (void**)&privateEvent)) { + privateEvent->DuplicatePrivateData(); + NS_RELEASE(privateEvent); + } + } + } + aDOMEvent = nsnull; + } + return ret; +} + +nsresult +nsHTMLGenericContent::SetAttribute(const nsString& aName, + const nsString& aValue, + PRBool aNotify) +{ + nsAutoString upper; + aName.ToUpperCase(upper); + nsIAtom* attr = NS_NewAtom(upper); + nsresult rv = SetAttribute(attr, aValue, aNotify); + NS_RELEASE(attr); + return rv; +} + +nsresult +nsHTMLGenericContent::SetAttribute(nsIAtom* aAttribute, + const nsString& aValue, + PRBool aNotify) +{ + nsresult result = NS_OK; + if (nsHTMLAtoms::style == aAttribute) { + // XXX the style sheet language is a document property that + // should be used to lookup the style sheet parser to parse the + // attribute. + nsICSSParser* css; + result = NS_NewCSSParser(&css); + if (NS_OK != result) { + return result; + } + nsIStyleRule* rule; + result = css->ParseDeclarations(aValue, nsnull, rule); + if ((NS_OK == result) && (nsnull != rule)) { + result = SetAttribute(aAttribute, nsHTMLValue(rule), aNotify); + NS_RELEASE(rule); + } + NS_RELEASE(css); + } + else { + if (nsnull != mDocument) { // set attr via style sheet + nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument); + result = sheet->SetAttributeFor(aAttribute, aValue, mTag, mAttributes); + } + else { // manage this ourselves and re-sync when we connect to doc + result = EnsureWritableAttributes(mAttributes, PR_TRUE); + if (nsnull != mAttributes) { + PRInt32 count; + result = mAttributes->SetAttribute(aAttribute, aValue, count); + if (0 == count) { + ReleaseAttributes(mAttributes); + } + } + } + } + return result; +} + +nsresult +nsHTMLGenericContent::SetAttribute(nsIAtom* aAttribute, + const nsHTMLValue& aValue, + PRBool aNotify) +{ + nsresult result = NS_OK; + if (nsnull != mDocument) { // set attr via style sheet + nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument); + result = sheet->SetAttributeFor(aAttribute, aValue, mTag, mAttributes); + } + else { // manage this ourselves and re-sync when we connect to doc + result = EnsureWritableAttributes(mAttributes, PR_TRUE); + if (nsnull != mAttributes) { + PRInt32 count; + result = mAttributes->SetAttribute(aAttribute, aValue, count); + if (0 == count) { + ReleaseAttributes(mAttributes); + } + } + } + return result; +} + +nsresult +nsHTMLGenericContent::SetAttr(nsIAtom* aAttribute, + const nsString& aValue, + nsSetAttrNotify aNotify) +{ + // XXX cheesy code for now + return SetAttribute(aAttribute, aValue, PR_TRUE); +} + +nsresult +nsHTMLGenericContent::SetAttr(nsIAtom* aAttribute, + const nsHTMLValue& aValue, + nsSetAttrNotify aNotify) +{ + // XXX cheesy code for now + return SetAttribute(aAttribute, aValue, PR_TRUE); +} + +nsresult +nsHTMLGenericContent::UnsetAttribute(nsIAtom* aAttribute) +{ + nsresult result = NS_OK; + if (nsnull != mDocument) { // set attr via style sheet + nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument); + result = sheet->UnsetAttributeFor(aAttribute, mTag, mAttributes); + } + else { // manage this ourselves and re-sync when we connect to doc + result = EnsureWritableAttributes(mAttributes, PR_FALSE); + if (nsnull != mAttributes) { + PRInt32 count; + result = mAttributes->UnsetAttribute(aAttribute, count); + if (0 == count) { + ReleaseAttributes(mAttributes); + } + } + } + return result; +} + +nsresult +nsHTMLGenericContent::GetAttribute(const nsString& aName, + nsString& aResult) const +{ + nsAutoString upper; + aName.ToUpperCase(upper); + nsIAtom* attr = NS_NewAtom(upper); + nsresult result = GetAttribute(attr, aResult); + NS_RELEASE(attr); + return result; +} + +nsresult +nsHTMLGenericContent::GetAttribute(nsIAtom *aAttribute, + nsString &aResult) const +{ + nsHTMLValue value; + nsresult result = GetAttribute(aAttribute, value); + + char cbuf[20]; + nscolor color; + if (NS_CONTENT_ATTR_HAS_VALUE == result) { + // Try subclass conversion routine first + if (NS_CONTENT_ATTR_HAS_VALUE == + mContent->AttributeToString(aAttribute, value, aResult)) { + return result; + } + + // Provide default conversions for most everything + switch (value.GetUnit()) { + case eHTMLUnit_Empty: + aResult.Truncate(); + break; + + case eHTMLUnit_String: + case eHTMLUnit_Null: + value.GetStringValue(aResult); + break; + + case eHTMLUnit_Integer: + aResult.Truncate(); + aResult.Append(value.GetIntValue(), 10); + break; + + case eHTMLUnit_Pixel: + aResult.Truncate(); + aResult.Append(value.GetPixelValue(), 10); + break; + + case eHTMLUnit_Percent: + aResult.Truncate(0); + aResult.Append(PRInt32(value.GetPercentValue() * 100.0f), 10); + aResult.Append('%'); + break; + + case eHTMLUnit_Color: + color = nscolor(value.GetColorValue()); + PR_snprintf(cbuf, sizeof(cbuf), "#%02x%02x%02x", + NS_GET_R(color), NS_GET_G(color), NS_GET_B(color)); + aResult.Truncate(0); + aResult.Append(cbuf); + break; + + default: + case eHTMLUnit_Enumerated: + NS_NOTREACHED("no default enumerated value to string conversion"); + result = NS_CONTENT_ATTR_NOT_THERE; + break; + } + } + return result; +} + +nsresult +nsHTMLGenericContent::GetAttribute(nsIAtom* aAttribute, + nsHTMLValue& aValue) const +{ + if (nsnull != mAttributes) { + return mAttributes->GetAttribute(aAttribute, aValue); + } + aValue.Reset(); + return NS_CONTENT_ATTR_NOT_THERE; +} + +nsresult +nsHTMLGenericContent::GetAllAttributeNames(nsISupportsArray* aArray, + PRInt32& aCount) const +{ + if (nsnull != mAttributes) { + return mAttributes->GetAllAttributeNames(aArray, aCount); + } + aCount = 0; + return NS_OK; +} + +nsresult +nsHTMLGenericContent::GetAttributeCount(PRInt32& aCount) const +{ + if (nsnull != mAttributes) { + return mAttributes->Count(aCount); + } + aCount = 0; + return NS_OK; +} + +nsresult +nsHTMLGenericContent::SetID(nsIAtom* aID) +{ + nsresult result = NS_OK; + if (nsnull != mDocument) { // set attr via style sheet + nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument); + result = sheet->SetIDFor(aID, mTag, mAttributes); + } + else { // manage this ourselves and re-sync when we connect to doc + EnsureWritableAttributes(mAttributes, PRBool(nsnull != aID)); + if (nsnull != mAttributes) { + PRInt32 count; + result = mAttributes->SetID(aID, count); + if (0 == count) { + ReleaseAttributes(mAttributes); + } + } + } + return result; +} + +nsresult +nsHTMLGenericContent::GetID(nsIAtom*& aResult) const +{ + if (nsnull != mAttributes) { + return mAttributes->GetID(aResult); + } + aResult = nsnull; + return NS_OK; +} + +nsresult +nsHTMLGenericContent::SetClass(nsIAtom* aClass) +{ + nsresult result = NS_OK; + if (nsnull != mDocument) { // set attr via style sheet + nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument); + result = sheet->SetClassFor(aClass, mTag, mAttributes); + } + else { // manage this ourselves and re-sync when we connect to doc + EnsureWritableAttributes(mAttributes, PRBool(nsnull != aClass)); + if (nsnull != mAttributes) { + PRInt32 count; + result = mAttributes->SetClass(aClass, count); + if (0 == count) { + ReleaseAttributes(mAttributes); + } + } + } + return result; +} + +nsresult +nsHTMLGenericContent::GetClass(nsIAtom*& aResult) const +{ + if (nsnull != mAttributes) { + return mAttributes->GetClass(aResult); + } + aResult = nsnull; + return NS_OK; +} + +nsresult +nsHTMLGenericContent::GetStyleRule(nsIStyleRule*& aResult) +{ + nsIStyleRule* result = nsnull; + + if (nsnull != mAttributes) { + mAttributes->QueryInterface(kIStyleRuleIID, (void**)&result); + } + aResult = result; + return NS_OK; +} + +nsIContentDelegate* +nsHTMLGenericContent::GetDelegate(nsIPresContext* aCX) +{ + gContentDelegate->AddRef(); + return gContentDelegate; +} + +void +nsHTMLGenericContent::ListAttributes(FILE* out) const +{ + nsISupportsArray* attrs; + if (NS_OK == NS_NewISupportsArray(&attrs)) { + PRInt32 index, count; + GetAllAttributeNames(attrs, count); + for (index = 0; index < count; index++) { + // name + nsIAtom* attr = (nsIAtom*)attrs->ElementAt(index); + nsAutoString buffer; + attr->ToString(buffer); + + // value + nsAutoString value; + GetAttribute(buffer, value); + buffer.Append("="); + buffer.Append(value); + + fputs(" ", out); + fputs(buffer, out); + NS_RELEASE(attr); + } + NS_RELEASE(attrs); + } +} + +nsresult +nsHTMLGenericContent::List(FILE* out, PRInt32 aIndent) const +{ + NS_PRECONDITION(nsnull != mDocument, "bad content"); + + PRInt32 index; + for (index = aIndent; --index >= 0; ) fputs(" ", out); + + nsIAtom* tag; + GetTag(tag); + if (tag != nsnull) { + nsAutoString buf; + tag->ToString(buf); + fputs(buf, out); + NS_RELEASE(tag); + } + + ListAttributes(out); + + nsrefcnt r = mContent->AddRef() - 1; + mContent->Release(); + fprintf(out, " refcount=%d<", r); + + PRBool canHaveKids; + mContent->CanContainChildren(canHaveKids); + if (canHaveKids) { + fputs("\n", out); + PRInt32 kids; + mContent->ChildCount(kids); + for (index = 0; index < kids; index++) { + nsIContent* kid; + mContent->ChildAt(index, kid); + kid->List(out, aIndent + 1); + NS_RELEASE(kid); + } + for (index = aIndent; --index >= 0; ) fputs(" ", out); + } + fputs(">\n", out); + + return NS_OK; +} + +nsresult +nsHTMLGenericContent::ToHTML(FILE* out) const +{ + nsAutoString tmp; + nsresult rv = ToHTMLString(tmp); + fputs(tmp, out); + return rv; +} + +// XXX i18n: this is wrong (?) because we need to know the outgoing +// character set (I think) +static void +QuoteForHTML(const nsString& aValue, nsString& aResult) +{ + aResult.Truncate(); + const PRUnichar* cp = aValue.GetUnicode(); + const PRUnichar* end = aValue.GetUnicode() + aValue.Length(); + aResult.Append('"'); + while (cp < end) { + PRUnichar ch = *cp++; + if ((ch >= 0x20) && (ch <= 0x7f)) { + if (ch == '\"') { + aResult.Append("""); + } + else { + aResult.Append(ch); + } + } + else { + aResult.Append("&#"); + aResult.Append((PRInt32) ch, 10); + aResult.Append(';'); + } + } + aResult.Append('"'); +} + +nsresult +nsHTMLGenericContent::ToHTMLString(nsString& aBuf) const +{ + aBuf.Truncate(0); + aBuf.Append('<'); + + if (nsnull != mTag) { + nsAutoString tmp; + mTag->ToString(tmp); + aBuf.Append(tmp); + } else { + aBuf.Append("?NULL"); + } + + if (nsnull != mAttributes) { + nsISupportsArray* attrs; + nsresult rv = NS_NewISupportsArray(&attrs); + if (NS_OK == rv) { + PRInt32 i, n; + mAttributes->GetAllAttributeNames(attrs, n); + nsAutoString name, value, quotedValue; + for (i = 0; i < n; i++) { + nsIAtom* atom = (nsIAtom*) attrs->ElementAt(i); + atom->ToString(name); + aBuf.Append(' '); + aBuf.Append(name); + value.Truncate(); + GetAttribute(name, value); + if (value.Length() > 0) { + aBuf.Append('='); + QuoteForHTML(value, quotedValue); + aBuf.Append(quotedValue); + } + } + NS_RELEASE(attrs); + } + } + + aBuf.Append('>'); + return NS_OK; +} + +//---------------------------------------------------------------------- + +// XXX this is REALLY temporary code + +extern nsresult NS_NewBRFrame(nsIContent* aContent, nsIFrame* aParentFrame, + nsIFrame*& aNewFrame); +extern nsresult NS_NewHRFrame(nsIContent* aContent, nsIFrame* aParentFrame, + nsIFrame*& aNewFrame); +extern nsresult NS_NewObjectFrame(nsIContent* aContent, nsIFrame* aParentFrame, + nsIFrame*& aNewFrame); + +nsresult +nsHTMLGenericContent::CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) +{ + nsIFrame* frame = nsnull; + nsresult rv = NS_OK; + + // Handle specific frame types + if (mTag == nsHTMLAtoms::applet) { + rv = NS_NewObjectFrame(mContent, aParentFrame, frame); + } + else if (mTag == nsHTMLAtoms::br) { + rv = NS_NewBRFrame(mContent, aParentFrame, frame); + } + else if (mTag == nsHTMLAtoms::embed) { + rv = NS_NewObjectFrame(mContent, aParentFrame, frame); + } + else if (mTag == nsHTMLAtoms::hr) { + rv = NS_NewHRFrame(mContent, aParentFrame, frame); + } + else if (mTag == nsHTMLAtoms::object) { + rv = NS_NewObjectFrame(mContent, aParentFrame, frame); + } + if (NS_OK != rv) { + return rv; + } + + // XXX add code in here to force the odd ones into the empty frame? + // AREA, HEAD, META, MAP, etc... + + if (nsnull == frame) { + // When there is no explicit frame to create, assume it's a + // container and let style dictate the rest. + const nsStyleDisplay* styleDisplay = (const nsStyleDisplay*) + aStyleContext->GetStyleData(eStyleStruct_Display); + + // Use style to choose what kind of frame to create + nsresult rv; + switch (styleDisplay->mDisplay) { + case NS_STYLE_DISPLAY_BLOCK: + case NS_STYLE_DISPLAY_LIST_ITEM: + rv = NS_NewCSSBlockFrame(&frame, mContent, aParentFrame); + break; + + case NS_STYLE_DISPLAY_INLINE: + rv = NS_NewCSSInlineFrame(&frame, mContent, aParentFrame); + break; + + default: + // Create an empty frame for holding content that is not being + // reflowed. + rv = nsFrame::NewFrame(&frame, mContent, aParentFrame); + break; + } + if (NS_OK != rv) { + return rv; + } + } + + frame->SetStyleContext(aPresContext, aStyleContext); + aResult = frame; + return NS_OK; +} + +//---------------------------------------------------------------------- + +// nsIScriptObjectOwner implementation + +nsresult +nsHTMLGenericContent::GetScriptObject(nsIScriptContext* aContext, + void** aScriptObject) +{ + nsresult res = NS_OK; + if (nsnull == mScriptObject) { + nsIDOMElement* ele = nsnull; + mContent->QueryInterface(kIDOMElementIID, (void**) &ele); + res = NS_NewScriptElement(aContext, ele, mParent, (void**)&mScriptObject); + NS_RELEASE(ele); + } + *aScriptObject = mScriptObject; + return res; +} + +nsresult +nsHTMLGenericContent::ResetScriptObject() +{ + mScriptObject = nsnull; + return NS_OK; +} + +//---------------------------------------------------------------------- + +// nsIDOMEventReceiver implementation + +nsresult +nsHTMLGenericContent::GetListenerManager(nsIEventListenerManager** aResult) +{ + if (nsnull != mListenerManager) { + NS_ADDREF(mListenerManager); + *aResult = mListenerManager; + return NS_OK; + } + nsresult rv = NS_NewEventListenerManager(aResult); + if (NS_OK == rv) { + mListenerManager = *aResult; + NS_ADDREF(mListenerManager); + } + return rv; +} + +nsresult +nsHTMLGenericContent::GetNewListenerManager(nsIEventListenerManager** aResult) +{ + return NS_NewEventListenerManager(aResult); +} + +nsresult +nsHTMLGenericContent::AddEventListener(nsIDOMEventListener* aListener, + const nsIID& aIID) +{ + nsIEventListenerManager *manager; + + if (NS_OK == GetListenerManager(&manager)) { + manager->AddEventListener(aListener, aIID); + NS_RELEASE(manager); + return NS_OK; + } + return NS_ERROR_FAILURE; +} + +nsresult +nsHTMLGenericContent::RemoveEventListener(nsIDOMEventListener* aListener, + const nsIID& aIID) +{ + if (nsnull != mListenerManager) { + mListenerManager->RemoveEventListener(aListener, aIID); + return NS_OK; + } + return NS_ERROR_FAILURE; +} + +//---------------------------------------------------------------------- + +nsresult +nsHTMLGenericContent::AddScriptEventListener(nsIAtom* aAttribute, + nsHTMLValue& aValue, + REFNSIID aIID) +{ + nsresult ret = NS_OK; + nsIScriptContext* context; + nsIScriptContextOwner* owner; + + if (nsnull != mDocument) { + owner = mDocument->GetScriptContextOwner(); + if (NS_OK == owner->GetScriptContext(&context)) { + if (nsHTMLAtoms::body == mTag || nsHTMLAtoms::frameset == mTag) { + nsIDOMEventReceiver *receiver; + nsIScriptGlobalObject *global = context->GetGlobalObject(); + + if (nsnull != global && NS_OK == global->QueryInterface(kIDOMEventReceiverIID, (void**)&receiver)) { + nsIEventListenerManager *manager; + if (NS_OK == receiver->GetListenerManager(&manager)) { + nsIScriptObjectOwner *mObjectOwner; + if (NS_OK == global->QueryInterface(kIScriptObjectOwnerIID, (void**)&mObjectOwner)) { + nsString value; + aValue.GetStringValue(value); + ret = manager->AddScriptEventListener(context, mObjectOwner, aAttribute, value, aIID); + NS_RELEASE(mObjectOwner); + } + NS_RELEASE(manager); + } + NS_RELEASE(receiver); + } + NS_IF_RELEASE(global); + } + else { + nsIEventListenerManager *manager; + if (NS_OK == GetListenerManager(&manager)) { + nsString value; + aValue.GetStringValue(value); + nsIScriptObjectOwner* owner; + if (NS_OK == mContent->QueryInterface(kIScriptObjectOwnerIID, + (void**) &owner)) { + ret = manager->AddScriptEventListener(context, owner, + aAttribute, value, aIID); + NS_RELEASE(owner); + } + NS_RELEASE(manager); + } + } + NS_RELEASE(context); + } + NS_RELEASE(owner); + } + return ret; +} + +nsresult +nsHTMLGenericContent::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + if (nsHTMLAtoms::style == aAttribute) { + if (eHTMLUnit_ISupports == aValue.GetUnit()) { + nsIStyleRule* rule = (nsIStyleRule*) aValue.GetISupportsValue(); + // rule->ToString(str); + aResult = "XXX style rule ToString goes here"; + return NS_CONTENT_ATTR_HAS_VALUE; + } + } + aResult.Truncate(); + return NS_CONTENT_ATTR_NOT_THERE; +} + +PRBool +nsHTMLGenericContent::ParseEnumValue(const nsString& aValue, + EnumTable* aTable, + nsHTMLValue& aResult) +{ + while (nsnull != aTable->tag) { + if (aValue.EqualsIgnoreCase(aTable->tag)) { + aResult.SetIntValue(aTable->value, eHTMLUnit_Enumerated); + return PR_TRUE; + } + aTable++; + } + return PR_FALSE; +} + +PRBool +nsHTMLGenericContent::EnumValueToString(const nsHTMLValue& aValue, + EnumTable* aTable, + nsString& aResult) +{ + aResult.Truncate(0); + if (aValue.GetUnit() == eHTMLUnit_Enumerated) { + PRInt32 v = aValue.GetIntValue(); + while (nsnull != aTable->tag) { + if (aTable->value == v) { + aResult.Append(aTable->tag); + return PR_TRUE; + } + aTable++; + } + } + return PR_FALSE; +} + +PRBool +nsHTMLGenericContent::ParseValueOrPercent(const nsString& aString, + nsHTMLValue& aResult, + nsHTMLUnit aValueUnit) +{ // XXX should vave min/max values? + nsAutoString tmp(aString); + tmp.CompressWhitespace(PR_TRUE, PR_TRUE); + PRInt32 ec, val = tmp.ToInteger(&ec); + if (NS_OK == ec) { + if (tmp.Last() == '%') {/* XXX not 100% compatible with ebina's code */ + if (val < 0) val = 0; + if (val > 100) val = 100; + aResult.SetPercentValue(float(val)/100.0f); + } else { + if (eHTMLUnit_Pixel == aValueUnit) { + aResult.SetPixelValue(val); + } + else { + aResult.SetIntValue(val, aValueUnit); + } + } + return PR_TRUE; + } + + // Illegal values are mapped to empty + aResult.SetEmptyValue(); + return PR_FALSE; +} + +/* used to parse attribute values that could be either: + * integer (n), + * percent (n%), + * or proportional (n*) + */ +void +nsHTMLGenericContent::ParseValueOrPercentOrProportional(const nsString& aString, + nsHTMLValue& aResult, + nsHTMLUnit aValueUnit) +{ // XXX should have min/max values? + nsAutoString tmp(aString); + tmp.CompressWhitespace(PR_TRUE, PR_TRUE); + PRInt32 ec, val = tmp.ToInteger(&ec); + if (tmp.Last() == '%') {/* XXX not 100% compatible with ebina's code */ + if (val < 0) val = 0; + if (val > 100) val = 100; + aResult.SetPercentValue(float(val)/100.0f); + } else if (tmp.Last() == '*') { + if (val < 0) val = 0; + aResult.SetIntValue(val, eHTMLUnit_Proportional); // proportional values are integers + } else { + if (eHTMLUnit_Pixel == aValueUnit) { + aResult.SetPixelValue(val); + } + else { + aResult.SetIntValue(val, aValueUnit); + } + } +} + +PRBool +nsHTMLGenericContent::ValueOrPercentToString(const nsHTMLValue& aValue, + nsString& aResult) +{ + aResult.Truncate(0); + switch (aValue.GetUnit()) { + case eHTMLUnit_Integer: + aResult.Append(aValue.GetIntValue(), 10); + return PR_TRUE; + case eHTMLUnit_Pixel: + aResult.Append(aValue.GetPixelValue(), 10); + return PR_TRUE; + case eHTMLUnit_Percent: + aResult.Append(PRInt32(aValue.GetPercentValue() * 100.0f), 10); + aResult.Append('%'); + return PR_TRUE; + } + return PR_FALSE; +} + +PRBool +nsHTMLGenericContent::ParseValue(const nsString& aString, PRInt32 aMin, + nsHTMLValue& aResult, nsHTMLUnit aValueUnit) +{ + PRInt32 ec, val = aString.ToInteger(&ec); + if (NS_OK == ec) { + if (val < aMin) val = aMin; + if (eHTMLUnit_Pixel == aValueUnit) { + aResult.SetPixelValue(val); + } + else { + aResult.SetIntValue(val, aValueUnit); + } + return PR_TRUE; + } + + // Illegal values are mapped to empty + aResult.SetEmptyValue(); + return PR_FALSE; +} + +PRBool +nsHTMLGenericContent::ParseValue(const nsString& aString, PRInt32 aMin, + PRInt32 aMax, + nsHTMLValue& aResult, nsHTMLUnit aValueUnit) +{ + PRInt32 ec, val = aString.ToInteger(&ec); + if (NS_OK == ec) { + if (val < aMin) val = aMin; + if (val > aMax) val = aMax; + if (eHTMLUnit_Pixel == aValueUnit) { + aResult.SetPixelValue(val); + } + else { + aResult.SetIntValue(val, aValueUnit); + } + return PR_TRUE; + } + + // Illegal values are mapped to empty + aResult.SetEmptyValue(); + return PR_FALSE; +} + +PRBool +nsHTMLGenericContent::ParseColor(const nsString& aString, + nsHTMLValue& aResult) +{ + if (aString.Length() > 0) { + nsAutoString colorStr (aString); + colorStr.CompressWhitespace(); + char cbuf[40]; + colorStr.ToCString(cbuf, sizeof(cbuf)); + nscolor color; + if (NS_ColorNameToRGB(cbuf, &color)) { + aResult.SetStringValue(colorStr); + return PR_TRUE; + } + if (NS_HexToRGB(cbuf, &color)) { + aResult.SetColorValue(color); + return PR_TRUE; + } + } + + // Illegal values are mapped to empty + aResult.SetEmptyValue(); + return PR_FALSE; +} + +PRBool +nsHTMLGenericContent::ColorToString(const nsHTMLValue& aValue, + nsString& aResult) +{ + if (aValue.GetUnit() == eHTMLUnit_Color) { + nscolor v = aValue.GetColorValue(); + char buf[10]; + PR_snprintf(buf, sizeof(buf), "#%02x%02x%02x", + NS_GET_R(v), NS_GET_G(v), NS_GET_B(v)); + aResult.Truncate(0); + aResult.Append(buf); + return PR_TRUE; + } + if (aValue.GetUnit() == eHTMLUnit_String) { + aValue.GetStringValue(aResult); + return PR_TRUE; + } + if (aValue.GetUnit() == eHTMLUnit_Empty) { // was illegal + aResult.Truncate(); + return PR_TRUE; + } + return PR_FALSE; +} + +// XXX check all mappings against ebina's usage +static nsHTMLGenericContent::EnumTable kAlignTable[] = { + { "left", NS_STYLE_TEXT_ALIGN_LEFT }, + { "right", NS_STYLE_TEXT_ALIGN_RIGHT }, + { "texttop", NS_STYLE_VERTICAL_ALIGN_TEXT_TOP }, + { "baseline", NS_STYLE_VERTICAL_ALIGN_BASELINE }, + { "center", NS_STYLE_TEXT_ALIGN_CENTER }, + { "bottom", NS_STYLE_VERTICAL_ALIGN_BOTTOM }, + { "top", NS_STYLE_VERTICAL_ALIGN_TOP }, + { "middle", NS_STYLE_VERTICAL_ALIGN_MIDDLE }, + { "absbottom", NS_STYLE_VERTICAL_ALIGN_BOTTOM }, + { "abscenter", NS_STYLE_VERTICAL_ALIGN_MIDDLE }, + { "absmiddle", NS_STYLE_VERTICAL_ALIGN_MIDDLE }, + { 0 } +}; + +PRBool +nsHTMLGenericContent::ParseAlignValue(const nsString& aString, + nsHTMLValue& aResult) +{ + return ParseEnumValue(aString, kAlignTable, aResult); +} + +PRBool +nsHTMLGenericContent::AlignValueToString(const nsHTMLValue& aValue, + nsString& aResult) +{ + return EnumValueToString(aValue, kAlignTable, aResult); +} + +PRBool +nsHTMLGenericContent::ParseImageAttribute(nsIAtom* aAttribute, + const nsString& aString, + nsHTMLValue& aResult) +{ + if ((aAttribute == nsHTMLAtoms::width) || + (aAttribute == nsHTMLAtoms::height)) { + ParseValueOrPercent(aString, aResult, eHTMLUnit_Pixel); + return PR_TRUE; + } + else if ((aAttribute == nsHTMLAtoms::hspace) || + (aAttribute == nsHTMLAtoms::vspace) || + (aAttribute == nsHTMLAtoms::border)) { + ParseValue(aString, 0, aResult, eHTMLUnit_Pixel); + return PR_TRUE; + } + return PR_FALSE; +} + +PRBool +nsHTMLGenericContent::ImageAttributeToString(nsIAtom* aAttribute, + const nsHTMLValue& aValue, + nsString& aResult) +{ + if ((aAttribute == nsHTMLAtoms::width) || + (aAttribute == nsHTMLAtoms::height) || + (aAttribute == nsHTMLAtoms::border) || + (aAttribute == nsHTMLAtoms::hspace) || + (aAttribute == nsHTMLAtoms::vspace)) { + return ValueOrPercentToString(aValue, aResult); + } + return PR_FALSE; +} + +void +nsHTMLGenericContent::MapImageAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + if (nsnull != mAttributes) { + nsHTMLValue value; + + float p2t = aPresContext->GetPixelsToTwips(); + nsStylePosition* pos = (nsStylePosition*) + aContext->GetMutableStyleData(eStyleStruct_Position); + nsStyleSpacing* spacing = (nsStyleSpacing*) + aContext->GetMutableStyleData(eStyleStruct_Spacing); + + // width: value + GetAttribute(nsHTMLAtoms::width, value); + if (value.GetUnit() == eHTMLUnit_Pixel) { + nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t); + pos->mWidth.SetCoordValue(twips); + } + else if (value.GetUnit() == eHTMLUnit_Percent) { + pos->mWidth.SetPercentValue(value.GetPercentValue()); + } + + // height: value + GetAttribute(nsHTMLAtoms::height, value); + if (value.GetUnit() == eHTMLUnit_Pixel) { + nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t); + pos->mHeight.SetCoordValue(twips); + } + else if (value.GetUnit() == eHTMLUnit_Percent) { + pos->mHeight.SetPercentValue(value.GetPercentValue()); + } + + // hspace: value + GetAttribute(nsHTMLAtoms::hspace, value); + if (value.GetUnit() == eHTMLUnit_Pixel) { + nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t); + spacing->mMargin.SetRight(nsStyleCoord(twips)); + } + else if (value.GetUnit() == eHTMLUnit_Percent) { + spacing->mMargin.SetRight(nsStyleCoord(value.GetPercentValue(), + eStyleUnit_Coord)); + } + + // vspace: value + GetAttribute(nsHTMLAtoms::vspace, value); + if (value.GetUnit() == eHTMLUnit_Pixel) { + nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t); + spacing->mMargin.SetBottom(nsStyleCoord(twips)); + } + else if (value.GetUnit() == eHTMLUnit_Percent) { + spacing->mMargin.SetBottom(nsStyleCoord(value.GetPercentValue(), + eStyleUnit_Coord)); + } + } +} + +void +nsHTMLGenericContent::MapImageAlignAttributeInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + if (nsnull != mAttributes) { + nsHTMLValue value; + GetAttribute(nsHTMLAtoms::align, value); + if (value.GetUnit() == eHTMLUnit_Enumerated) { + PRUint8 align = value.GetIntValue(); + nsStyleDisplay* display = (nsStyleDisplay*) + aContext->GetMutableStyleData(eStyleStruct_Display); + nsStyleText* text = (nsStyleText*) + aContext->GetMutableStyleData(eStyleStruct_Text); + nsStyleSpacing* spacing = (nsStyleSpacing*) + aContext->GetMutableStyleData(eStyleStruct_Spacing); + float p2t = aPresContext->GetPixelsToTwips(); + nsStyleCoord three(NSIntPixelsToTwips(3, p2t)); + switch (align) { + case NS_STYLE_TEXT_ALIGN_LEFT: + display->mFloats = NS_STYLE_FLOAT_LEFT; + spacing->mMargin.SetLeft(three); + spacing->mMargin.SetRight(three); + break; + case NS_STYLE_TEXT_ALIGN_RIGHT: + display->mFloats = NS_STYLE_FLOAT_RIGHT; + spacing->mMargin.SetLeft(three); + spacing->mMargin.SetRight(three); + break; + default: + text->mVerticalAlign.SetIntValue(align, eStyleUnit_Enumerated); + break; + } + } + } +} + +void +nsHTMLGenericContent::MapImageBorderAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext, + nscolor aBorderColors[4]) +{ + if (nsnull != mAttributes) { + nsHTMLValue value; + + // border: pixels + GetAttribute(nsHTMLAtoms::border, value); + if (value.GetUnit() != eHTMLUnit_Pixel) { + if (nsnull == aBorderColors) { + return; + } + // If no border is defined and we are forcing a border, force + // the size to 2 pixels. + value.SetPixelValue(2); + } + + float p2t = aPresContext->GetPixelsToTwips(); + nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t); + + // Fixup border-padding sums: subtract out the old size and then + // add in the new size. + nsStyleSpacing* spacing = (nsStyleSpacing*) + aContext->GetMutableStyleData(eStyleStruct_Spacing); + nsStyleCoord coord; + coord.SetCoordValue(twips); + spacing->mBorder.SetTop(coord); + spacing->mBorder.SetRight(coord); + spacing->mBorder.SetBottom(coord); + spacing->mBorder.SetLeft(coord); + spacing->mBorderStyle[0] = NS_STYLE_BORDER_STYLE_SOLID; + spacing->mBorderStyle[1] = NS_STYLE_BORDER_STYLE_SOLID; + spacing->mBorderStyle[2] = NS_STYLE_BORDER_STYLE_SOLID; + spacing->mBorderStyle[3] = NS_STYLE_BORDER_STYLE_SOLID; + + // Use supplied colors if provided, otherwise use color for border + // color + if (nsnull != aBorderColors) { + spacing->mBorderColor[0] = aBorderColors[0]; + spacing->mBorderColor[1] = aBorderColors[1]; + spacing->mBorderColor[2] = aBorderColors[2]; + spacing->mBorderColor[3] = aBorderColors[3]; + } + else { + // Color is inherited from "color" + const nsStyleColor* styleColor = (const nsStyleColor*) + aContext->GetStyleData(eStyleStruct_Color); + nscolor color = styleColor->mColor; + spacing->mBorderColor[0] = color; + spacing->mBorderColor[1] = color; + spacing->mBorderColor[2] = color; + spacing->mBorderColor[3] = color; + } + } +} + +void +nsHTMLGenericContent::TriggerLink(nsIPresContext& aPresContext, + const nsString& aBase, + const nsString& aURLSpec, + const nsString& aTargetSpec, + PRBool aClick) +{ + nsILinkHandler* handler; + if (NS_OK == aPresContext.GetLinkHandler(&handler) && (nsnull != handler)) { + // Resolve url to an absolute url + nsIURL* docURL = nsnull; + nsIDocument* doc; + if (NS_OK == GetDocument(doc)) { + docURL = doc->GetDocumentURL(); + NS_RELEASE(doc); + } + + nsAutoString absURLSpec; + if (aURLSpec.Length() > 0) { + nsresult rv = NS_MakeAbsoluteURL(docURL, aBase, aURLSpec, absURLSpec); + } + else { + absURLSpec = aURLSpec; + } + + if (nsnull != docURL) { + NS_RELEASE(docURL); + } + + // Now pass on absolute url to the click handler + if (aClick) { + handler->OnLinkClick(nsnull, absURLSpec, aTargetSpec); + } + else { + handler->OnOverLink(nsnull, absURLSpec, aTargetSpec); + } + NS_RELEASE(handler); + } +} + +//---------------------------------------------------------------------- + +nsHTMLGenericLeafContent::nsHTMLGenericLeafContent() +{ +} + +nsHTMLGenericLeafContent::~nsHTMLGenericLeafContent() +{ +} + +nsresult +nsHTMLGenericLeafContent::CopyInnerTo(nsIHTMLContent* aSrcContent, + nsHTMLGenericLeafContent* aDst) +{ + aDst->mContent = aSrcContent; + // XXX should the node's document be set? + // XXX copy attributes not yet impelemented + return NS_OK; +} + +nsresult +nsHTMLGenericLeafContent::Equals(nsIDOMNode* aNode, PRBool aDeep, + PRBool* aReturn) +{ + // XXX not yet implemented + *aReturn = PR_FALSE; + return NS_OK; +} + +nsresult +nsHTMLGenericLeafContent::BeginConvertToXIF(nsXIFConverter& aConverter) const +{ + nsresult rv = NS_OK; + if (nsnull != mTag) + { + nsAutoString name; + mTag->ToString(name); + aConverter.BeginLeaf(name); + } + + // Add all attributes to the convert + if (nsnull != mAttributes) + { + nsISupportsArray* attrs; + rv = NS_NewISupportsArray(&attrs); + if (NS_OK == rv) + { + PRInt32 i, n; + mAttributes->GetAllAttributeNames(attrs, n); + nsAutoString name, value; + for (i = 0; i < n; i++) + { + nsIAtom* atom = (nsIAtom*) attrs->ElementAt(i); + atom->ToString(name); + + value.Truncate(); + GetAttribute(name, value); + + aConverter.AddHTMLAttribute(name,value); + } + NS_RELEASE(attrs); + } + } + return rv; +} + +nsresult +nsHTMLGenericLeafContent::ConvertContentToXIF(nsXIFConverter& aConverter) const +{ + return NS_OK; +} + +nsresult +nsHTMLGenericLeafContent::FinishConvertToXIF(nsXIFConverter& aConverter) const +{ + if (nsnull != mTag) + { + nsAutoString name; + mTag->ToString(name); + aConverter.EndLeaf(name); + } + return NS_OK; +} + +// XXX not really implemented (yet) +nsresult +nsHTMLGenericLeafContent::SizeOf(nsISizeOfHandler* aHandler) const +{ + aHandler->Add(sizeof(*this)); + return NS_OK; +} + +//---------------------------------------------------------------------- + +nsHTMLGenericContainerContent::nsHTMLGenericContainerContent() +{ +} + +nsHTMLGenericContainerContent::~nsHTMLGenericContainerContent() +{ + PRInt32 n = mChildren.Count(); + for (PRInt32 i = 0; i < n; i++) { + nsIContent* kid = (nsIContent*) mChildren.ElementAt(i); + NS_RELEASE(kid); + } +// if (nsnull != mChildNodes) { +// mChildNodes->ReleaseContent(); +// NS_RELEASE(mChildNodes); +// } +} + +nsresult +nsHTMLGenericContainerContent:: CopyInnerTo(nsIHTMLContent* aSrcContent, + nsHTMLGenericContainerContent* aDst) +{ + aDst->mContent = aSrcContent; + // XXX should the node's document be set? + // XXX copy attributes not yet impelemented + // XXX deep copy? + return NS_OK; +} + +nsresult +nsHTMLGenericContainerContent::Equals(nsIDOMNode* aNode, PRBool aDeep, + PRBool* aReturn) +{ + // XXX not yet implemented + *aReturn = PR_FALSE; + return NS_OK; +} + +nsresult +nsHTMLGenericContainerContent::GetChildNodes(nsIDOMNodeList** aChildNodes) +{ + *aChildNodes = nsnull; + return NS_OK; +// NS_PRECONDITION(nsnull != aChildNodes, "null pointer"); +// if (nsnull == mChildNodes) { +// mChildNodes = new nsDOMNodeList(this); +// NS_ADDREF(mChildNodes); +// } +// *aChildNodes = mChildNodes; +// NS_ADDREF(mChildNodes); +// return NS_OK; +} + +nsresult +nsHTMLGenericContainerContent::GetHasChildNodes(PRBool* aReturn) +{ + if (0 != mChildren.Count()) { + *aReturn = PR_TRUE; + } + else { + *aReturn = PR_FALSE; + } + return NS_OK; +} + +nsresult +nsHTMLGenericContainerContent::GetFirstChild(nsIDOMNode** aNode) +{ + nsIContent *child = (nsIContent*) mChildren.ElementAt(0); + if (nsnull != child) { + nsresult res = child->QueryInterface(kIDOMNodeIID, (void**)aNode); + NS_ASSERTION(NS_OK == res, "Must be a DOM Node"); // must be a DOM Node + return res; + } + aNode = nsnull; + return NS_OK; +} + +nsresult +nsHTMLGenericContainerContent::GetLastChild(nsIDOMNode** aNode) +{ + nsIContent *child = (nsIContent*) mChildren.ElementAt(mChildren.Count()-1); + if (nsnull != child) { + nsresult res = child->QueryInterface(kIDOMNodeIID, (void**)aNode); + NS_ASSERTION(NS_OK == res, "Must be a DOM Node"); // must be a DOM Node + return res; + } + aNode = nsnull; + return NS_OK; +} + +static void +SetDocumentInChildrenOf(nsIContent* aContent, nsIDocument* aDocument) +{ + PRInt32 i, n; + aContent->ChildCount(n); + for (i = 0; i < n; i++) { + nsIContent* child; + aContent->ChildAt(i, child); + if (nsnull != child) { + child->SetDocument(aDocument); + SetDocumentInChildrenOf(child, aDocument); + } + } +} + +// XXX It's possible that newChild has already been inserted in the +// tree; if this is the case then we need to remove it from where it +// was before placing it in it's new home + +nsresult +nsHTMLGenericContainerContent::InsertBefore(nsIDOMNode* aNewChild, + nsIDOMNode* aRefChild, + nsIDOMNode** aReturn) +{ + if (nsnull == aNewChild) { + *aReturn = nsnull; + return NS_OK;/* XXX wrong error value */ + } + + // Get the nsIContent interface for the new content + nsIContent* newContent = nsnull; + nsresult res = aNewChild->QueryInterface(kIContentIID, (void**)&newContent); + NS_ASSERTION(NS_OK == res, "New child must be an nsIContent"); + if (NS_OK == res) { + if (nsnull == aRefChild) { + // Append the new child to the end + SetDocumentInChildrenOf(newContent, mDocument); + res = AppendChildTo(newContent, PR_TRUE); + } + else { + // Get the index of where to insert the new child + nsIContent* refContent = nsnull; + res = aRefChild->QueryInterface(kIContentIID, (void**)&refContent); + NS_ASSERTION(NS_OK == res, "Ref child must be an nsIContent"); + if (NS_OK == res) { + PRInt32 pos; + IndexOf(refContent, pos); + if (pos >= 0) { + SetDocumentInChildrenOf(newContent, mDocument); + res = InsertChildAt(newContent, pos, PR_TRUE); + } + NS_RELEASE(refContent); + } + } + NS_RELEASE(newContent); + + *aReturn = aNewChild; + NS_ADDREF(aNewChild); + } + else { + *aReturn = nsnull; + } + + return res; +} + +nsresult +nsHTMLGenericContainerContent::ReplaceChild(nsIDOMNode* aNewChild, + nsIDOMNode* aOldChild, + nsIDOMNode** aReturn) +{ + nsIContent* content = nsnull; + *aReturn = nsnull; + nsresult res = aOldChild->QueryInterface(kIContentIID, (void**)&content); + NS_ASSERTION(NS_OK == res, "Must be an nsIContent"); + if (NS_OK == res) { + PRInt32 pos; + IndexOf(content, pos); + if (pos >= 0) { + nsIContent* newContent = nsnull; + nsresult res = aNewChild->QueryInterface(kIContentIID, (void**)&newContent); + NS_ASSERTION(NS_OK == res, "Must be an nsIContent"); + if (NS_OK == res) { + res = ReplaceChildAt(newContent, pos, PR_TRUE); + NS_RELEASE(newContent); + } + *aReturn = aOldChild; + NS_ADDREF(aOldChild); + } + NS_RELEASE(content); + } + + return res; +} + +nsresult +nsHTMLGenericContainerContent::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) +{ + nsIContent* content = nsnull; + *aReturn = nsnull; + nsresult res = aOldChild->QueryInterface(kIContentIID, (void**)&content); + NS_ASSERTION(NS_OK == res, "Must be an nsIContent"); + if (NS_OK == res) { + PRInt32 pos; + IndexOf(content, pos); + if (pos >= 0) { + res = RemoveChildAt(pos, PR_TRUE); + *aReturn = aOldChild; + NS_ADDREF(aOldChild); + } + NS_RELEASE(content); + } + + return res; +} + +nsresult +nsHTMLGenericContainerContent::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn) +{ + return InsertBefore(aNewChild, nsnull, aReturn); +} + +nsresult +nsHTMLGenericContainerContent::SizeOf(nsISizeOfHandler* aHandler) const +{ + aHandler->Add(sizeof(*this)); + return NS_OK; +} + +nsresult +nsHTMLGenericContainerContent::BeginConvertToXIF(nsXIFConverter& aConverter) const +{ + nsresult rv = NS_OK; + if (nsnull != mTag) + { + nsAutoString name; + mTag->ToString(name); + aConverter.BeginContainer(name); + } + + // Add all attributes to the convert + if (nsnull != mAttributes) + { + nsISupportsArray* attrs; + rv = NS_NewISupportsArray(&attrs); + if (NS_OK == rv) + { + PRInt32 i, n; + mAttributes->GetAllAttributeNames(attrs, n); + nsAutoString name, value; + for (i = 0; i < n; i++) + { + nsIAtom* atom = (nsIAtom*) attrs->ElementAt(i); + atom->ToString(name); + + value.Truncate(); + GetAttribute(name, value); + + aConverter.AddHTMLAttribute(name,value); + } + NS_RELEASE(attrs); + } + } + return NS_OK; +} + +nsresult +nsHTMLGenericContainerContent::ConvertContentToXIF(nsXIFConverter& aConverter) const +{ + return NS_OK; +} + +nsresult +nsHTMLGenericContainerContent::FinishConvertToXIF(nsXIFConverter& aConverter) const +{ + if (nsnull != mTag) + { + nsAutoString name; + mTag->ToString(name); + aConverter.EndContainer(name); + } + return NS_OK; +} + +nsresult +nsHTMLGenericContainerContent::Compact() +{ + mChildren.Compact(); + return NS_OK; +} + +nsresult +nsHTMLGenericContainerContent::CanContainChildren(PRBool& aResult) const +{ + aResult = PR_TRUE; + return NS_OK; +} + +nsresult +nsHTMLGenericContainerContent::ChildCount(PRInt32& aCount) const +{ + aCount = mChildren.Count(); + return NS_OK; +} + +nsresult +nsHTMLGenericContainerContent::ChildAt(PRInt32 aIndex, + nsIContent*& aResult) const +{ + nsIContent *child = (nsIContent*) mChildren.ElementAt(aIndex); + if (nsnull != child) { + NS_ADDREF(child); + } + aResult = child; + return NS_OK; +} + +nsresult +nsHTMLGenericContainerContent::IndexOf(nsIContent* aPossibleChild, + PRInt32& aIndex) const +{ + NS_PRECONDITION(nsnull != aPossibleChild, "null ptr"); + aIndex = mChildren.IndexOf(aPossibleChild); + return NS_OK; +} + +nsresult +nsHTMLGenericContainerContent::InsertChildAt(nsIContent* aKid, + PRInt32 aIndex, + PRBool aNotify) +{ + NS_PRECONDITION(nsnull != aKid, "null ptr"); + PRBool rv = mChildren.InsertElementAt(aKid, aIndex);/* XXX fix up void array api to use nsresult's*/ + if (rv) { + NS_ADDREF(aKid); + aKid->SetParent(mContent); + nsIDocument* doc = mDocument; + if (nsnull != doc) { + aKid->SetDocument(doc); + if (aNotify) { + doc->ContentInserted(mContent, aKid, aIndex); + } + } + } + return NS_OK; +} + +nsresult +nsHTMLGenericContainerContent::ReplaceChildAt(nsIContent* aKid, + PRInt32 aIndex, + PRBool aNotify) +{ + NS_PRECONDITION(nsnull != aKid, "null ptr"); + nsIContent* oldKid = (nsIContent*) mChildren.ElementAt(aIndex); + PRBool rv = mChildren.ReplaceElementAt(aKid, aIndex); + if (rv) { + NS_ADDREF(aKid); + aKid->SetParent(mContent); + nsIDocument* doc = mDocument; + if (nsnull != doc) { + aKid->SetDocument(doc); + if (aNotify) { + doc->ContentReplaced(mContent, oldKid, aKid, aIndex); + } + } + oldKid->SetDocument(nsnull); + oldKid->SetParent(nsnull); + NS_RELEASE(oldKid); + } + return NS_OK; +} + +nsresult +nsHTMLGenericContainerContent::AppendChildTo(nsIContent* aKid, PRBool aNotify) +{ + NS_PRECONDITION((nsnull != aKid) && (aKid != mContent), "null ptr"); + PRBool rv = mChildren.AppendElement(aKid); + if (rv) { + NS_ADDREF(aKid); + aKid->SetParent(mContent); + nsIDocument* doc = mDocument; + if (nsnull != doc) { + aKid->SetDocument(doc); + if (aNotify) { + doc->ContentAppended(mContent); + } + } + } + return NS_OK; +} + +nsresult +nsHTMLGenericContainerContent::RemoveChildAt(PRInt32 aIndex, PRBool aNotify) +{ + nsIContent* oldKid = (nsIContent*) mChildren.ElementAt(aIndex); + if (nsnull != oldKid ) { + nsIDocument* doc = mDocument; + if (aNotify) { + if (nsnull != doc) { + doc->ContentWillBeRemoved(mContent, oldKid, aIndex); + } + } + PRBool rv = mChildren.RemoveElementAt(aIndex); + if (aNotify) { + if (nsnull != doc) { + doc->ContentHasBeenRemoved(mContent, oldKid, aIndex); + } + } + oldKid->SetDocument(nsnull); + oldKid->SetParent(nsnull); + NS_RELEASE(oldKid); + } + + return NS_OK; +} diff --git a/mozilla/layout/html/content/src/nsGenericHTMLElement.h b/mozilla/layout/html/content/src/nsGenericHTMLElement.h new file mode 100644 index 00000000000..cc65be72ebb --- /dev/null +++ b/mozilla/layout/html/content/src/nsGenericHTMLElement.h @@ -0,0 +1,814 @@ +/* -*- 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. + */ +#ifndef nsHTMLGenericContent_h___ +#define nsHTMLGenericContent_h___ + +#include "nsIDOMHTMLElement.h" +#include "nsIContent.h" +#include "nsHTMLValue.h" +#include "nsVoidArray.h" + +extern const nsIID kIDOMNodeIID; +extern const nsIID kIDOMElementIID; +extern const nsIID kIDOMHTMLElementIID; +extern const nsIID kIDOMEventReceiverIID; +extern const nsIID kIScriptObjectOwnerIID; +extern const nsIID kISupportsIID; +extern const nsIID kIContentIID; +extern const nsIID kIHTMLContentIID; + +class nsIDOMAttribute; +class nsIDOMEventListener; +class nsIDOMNodeList; +class nsIEventListenerManager; +class nsIFrame; +class nsIHTMLAttributes; +class nsIHTMLContent; +class nsIStyleContext; +class nsIStyleRule; +class nsISupportsArray; + +enum nsSetAttrNotify { + eSetAttrNotify_None = 0, + eSetAttrNotify_Render = 1, + eSetAttrNotify_Reflow = 2, + eSetAttrNotify_Restart = 3 +}; + +struct nsHTMLGenericContent { + nsHTMLGenericContent(); + ~nsHTMLGenericContent(); + + void Init(nsIHTMLContent* aOuterContentObject, nsIAtom* aTag); + + // Implementation for nsIDOMNode + nsresult GetNodeName(nsString& aNodeName); + nsresult GetNodeValue(nsString& aNodeValue); + nsresult SetNodeValue(const nsString& aNodeValue); + nsresult GetNodeType(PRInt32* aNodeType); + nsresult GetParentNode(nsIDOMNode** aParentNode); + nsresult GetAttributes(nsIDOMNamedNodeMap** aAttributes); + nsresult GetPreviousSibling(nsIDOMNode** aPreviousSibling); + nsresult GetNextSibling(nsIDOMNode** aNextSibling); + + // Implementation for nsIDOMElement + nsresult GetTagName(nsString& aTagName); + nsresult GetDOMAttribute(const nsString& aName, nsString& aReturn); + nsresult SetDOMAttribute(const nsString& aName, const nsString& aValue); + nsresult RemoveAttribute(const nsString& aName); + nsresult GetAttributeNode(const nsString& aName, + nsIDOMAttribute** aReturn); + nsresult SetAttributeNode(nsIDOMAttribute* aNewAttr); + nsresult RemoveAttributeNode(nsIDOMAttribute* aOldAttr); + nsresult GetElementsByTagName(const nsString& aTagname, + nsIDOMNodeList** aReturn); + nsresult Normalize(); + + // Implementation for nsIDOMHTMLElement + nsresult GetId(nsString& aId); + nsresult SetId(const nsString& aId); + nsresult GetTitle(nsString& aTitle); + nsresult SetTitle(const nsString& aTitle); + nsresult GetLang(nsString& aLang); + nsresult SetLang(const nsString& aLang); + nsresult GetDir(nsString& aDir); + nsresult SetDir(const nsString& aDir); + nsresult GetClassName(nsString& aClassName); + nsresult SetClassName(const nsString& aClassName); + + // nsIDOMEventReceiver interface + nsresult AddEventListener(nsIDOMEventListener *aListener, const nsIID& aIID); + nsresult RemoveEventListener(nsIDOMEventListener* aListener, + const nsIID& aIID); + nsresult GetListenerManager(nsIEventListenerManager** aInstancePtrResult); + nsresult GetNewListenerManager(nsIEventListenerManager** aInstancePtrResult); + + // nsIScriptObjectOwner interface + nsresult GetScriptObject(nsIScriptContext* aContext, void** aScriptObject); + nsresult ResetScriptObject(); + + // Implementation for nsIContent + nsresult GetDocument(nsIDocument*& aResult) const; + nsresult SetDocument(nsIDocument* aDocument); + nsresult GetParent(nsIContent*& aResult) const; + nsresult SetParent(nsIContent* aParent); + nsresult IsSynthetic(PRBool& aResult); + nsresult GetTag(nsIAtom*& aResult) const; + nsresult SetAttribute(const nsString& aName, const nsString& aValue, + PRBool aNotify); + nsresult GetAttribute(const nsString& aName, nsString& aResult) const; + nsIContentDelegate* GetDelegate(nsIPresContext* aCX); + nsresult List(FILE* out, PRInt32 aIndent) const; + nsresult HandleDOMEvent(nsIPresContext& aPresContext, + nsEvent* aEvent, + nsIDOMEvent** aDOMEvent, + PRUint32 aFlags, + nsEventStatus& aEventStatus); + + // Implementation for nsIHTMLContent + nsresult Compact(); + nsresult SetAttribute(nsIAtom* aAttribute, const nsString& aValue, + PRBool aNotify); + nsresult SetAttribute(nsIAtom* aAttribute, const nsHTMLValue& aValue, + PRBool aNotify); + nsresult UnsetAttribute(nsIAtom* aAttribute); + nsresult GetAttribute(nsIAtom *aAttribute, nsString &aResult) const; + nsresult GetAttribute(nsIAtom* aAttribute, nsHTMLValue& aValue) const; + nsresult GetAllAttributeNames(nsISupportsArray* aArray, + PRInt32& aCount) const; + nsresult GetAttributeCount(PRInt32& aResult) const; + nsresult SetID(nsIAtom* aID); + nsresult GetID(nsIAtom*& aResult) const; + nsresult SetClass(nsIAtom* aClass); + nsresult GetClass(nsIAtom*& aResult) const; + nsresult GetStyleRule(nsIStyleRule*& aResult); + nsresult MapAttributesInto(nsIStyleContext* aStyleContext, + nsIPresContext* aPresContext); + nsresult ToHTMLString(nsString& aResult) const; + nsresult ToHTML(FILE* out) const; + nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); + + //---------------------------------------- + + nsresult SetAttr(nsIAtom* aAttribute, const nsString& aValue, + nsSetAttrNotify aNotify); + + nsresult SetAttr(nsIAtom* aAttribute, const nsHTMLValue& aValue, + nsSetAttrNotify aNotify); + + nsresult AddScriptEventListener(nsIAtom* aAttribute, + nsHTMLValue& aValue, + REFNSIID aIID); + + nsresult AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const; + + void ListAttributes(FILE* out) const; + + void TriggerLink(nsIPresContext& aPresContext, + const nsString& aBase, + const nsString& aURLSpec, + const nsString& aTargetSpec, + PRBool aClick); + + //---------------------------------------- + + // Attribute parsing utilities + + struct EnumTable { + const char* tag; + PRInt32 value; + }; + + static PRBool ParseEnumValue(const nsString& aValue, + EnumTable* aTable, + nsHTMLValue& aResult); + + static PRBool EnumValueToString(const nsHTMLValue& aValue, + EnumTable* aTable, + nsString& aResult); + + static PRBool ParseValueOrPercent(const nsString& aString, + nsHTMLValue& aResult, + nsHTMLUnit aValueUnit); + + static void ParseValueOrPercentOrProportional(const nsString& aString, + nsHTMLValue& aResult, + nsHTMLUnit aValueUnit); + + static PRBool ValueOrPercentToString(const nsHTMLValue& aValue, + nsString& aResult); + + static PRBool ParseValue(const nsString& aString, PRInt32 aMin, + nsHTMLValue& aResult, nsHTMLUnit aValueUnit); + + static PRBool ParseValue(const nsString& aString, PRInt32 aMin, PRInt32 aMax, + nsHTMLValue& aResult, nsHTMLUnit aValueUnit); + + static PRBool ParseColor(const nsString& aString, nsHTMLValue& aResult); + + static PRBool ColorToString(const nsHTMLValue& aValue, + nsString& aResult); + + static PRBool ParseAlignValue(const nsString& aString, nsHTMLValue& aResult); + + static PRBool AlignValueToString(const nsHTMLValue& aValue, + nsString& aResult); + + static PRBool ParseImageAttribute(nsIAtom* aAttribute, + const nsString& aString, + nsHTMLValue& aResult); + + static PRBool ImageAttributeToString(nsIAtom* aAttribute, + const nsHTMLValue& aValue, + nsString& aResult); + + void MapImageAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext); + + void MapImageAlignAttributeInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext); + + void MapImageBorderAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext, + nscolor aBorderColors[4]); + + // Up pointer to the real content object that we are + // supporting. Sometimes there is work that we just can't do + // ourselves, so this is needed to ask the real object to do the + // work. + nsIHTMLContent* mContent; + + nsIDocument* mDocument; + nsIContent* mParent; + nsIHTMLAttributes* mAttributes; + nsIAtom* mTag; + void* mScriptObject; + nsIEventListenerManager* mListenerManager; +}; + +//---------------------------------------------------------------------- + +struct nsHTMLGenericLeafContent : public nsHTMLGenericContent { + nsHTMLGenericLeafContent(); + ~nsHTMLGenericLeafContent(); + + nsresult CopyInnerTo(nsIHTMLContent* aSrcContent, + nsHTMLGenericLeafContent* aDest); + + // Remainder of nsIDOMHTMLElement (and nsIDOMNode) + nsresult Equals(nsIDOMNode* aNode, PRBool aDeep, PRBool* aReturn); + nsresult GetChildNodes(nsIDOMNodeList** aChildNodes) { + *aChildNodes = nsnull; + return NS_OK; + } + nsresult GetHasChildNodes(PRBool* aHasChildNodes) { + *aHasChildNodes = PR_FALSE; + return NS_OK; + } + nsresult GetFirstChild(nsIDOMNode** aFirstChild) { + *aFirstChild = nsnull; + return NS_OK; + } + nsresult GetLastChild(nsIDOMNode** aLastChild) { + *aLastChild = nsnull; + return NS_OK; + } + nsresult InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, + nsIDOMNode** aReturn) { + return NS_ERROR_FAILURE; + } + nsresult ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, + nsIDOMNode** aReturn) { + return NS_ERROR_FAILURE; + } + nsresult RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) { + return NS_ERROR_FAILURE; + } + nsresult AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn) { + return NS_ERROR_FAILURE; + } + + // Remainder of nsIHTMLContent (and nsIContent) + nsresult SizeOf(nsISizeOfHandler* aHandler) const; + nsresult BeginConvertToXIF(nsXIFConverter& aConverter) const; + nsresult ConvertContentToXIF(nsXIFConverter& aConverter) const; + nsresult FinishConvertToXIF(nsXIFConverter& aConverter) const; + nsresult Compact() { + return NS_OK; + } + nsresult CanContainChildren(PRBool& aResult) const { + aResult = PR_FALSE; + return NS_OK; + } + nsresult ChildCount(PRInt32& aResult) const { + aResult = 0; + return NS_OK; + } + nsresult ChildAt(PRInt32 aIndex, nsIContent*& aResult) const { + aResult = nsnull; + return NS_OK; + } + nsresult IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const { + aResult = -1; + return NS_OK; + } + nsresult InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) { + return NS_OK; + } + nsresult ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) { + return NS_OK; + } + nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify) { + return NS_OK; + } + nsresult RemoveChildAt(PRInt32 aIndex, PRBool aNotify) { + return NS_OK; + } +}; + +//---------------------------------------------------------------------- + +struct nsHTMLGenericContainerContent : public nsHTMLGenericContent { + nsHTMLGenericContainerContent(); + ~nsHTMLGenericContainerContent(); + + nsresult CopyInnerTo(nsIHTMLContent* aSrcContent, + nsHTMLGenericContainerContent* aDest); + + // Remainder of nsIDOMHTMLElement (and nsIDOMNode) + nsresult Equals(nsIDOMNode* aNode, PRBool aDeep, PRBool* aReturn); + nsresult GetChildNodes(nsIDOMNodeList** aChildNodes); + nsresult GetHasChildNodes(PRBool* aHasChildNodes); + nsresult GetFirstChild(nsIDOMNode** aFirstChild); + nsresult GetLastChild(nsIDOMNode** aLastChild); + nsresult InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, + nsIDOMNode** aReturn); + nsresult ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, + nsIDOMNode** aReturn); + nsresult RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn); + nsresult AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn); + + // Remainder of nsIHTMLContent (and nsIContent) + nsresult SizeOf(nsISizeOfHandler* aHandler) const; + nsresult BeginConvertToXIF(nsXIFConverter& aConverter) const; + nsresult ConvertContentToXIF(nsXIFConverter& aConverter) const; + nsresult FinishConvertToXIF(nsXIFConverter& aConverter) const; + nsresult Compact(); + nsresult CanContainChildren(PRBool& aResult) const; + nsresult ChildCount(PRInt32& aResult) const; + nsresult ChildAt(PRInt32 aIndex, nsIContent*& aResult) const; + nsresult IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const; + nsresult InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify); + nsresult ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify); + nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify); + nsresult RemoveChildAt(PRInt32 aIndex, PRBool aNotify); + + nsVoidArray mChildren; +}; + +//---------------------------------------------------------------------- + +/** + * Mostly implement the nsIDOMNode API by forwarding the methods to a + * generic content object (either nsHTMLGenericLeafContent or + * nsHTMLGenericContainerContent) + * + * Note that classes using this macro will need to implement: + * NS_IMETHOD CloneNode(nsIDOMNode** aReturn); + */ +#define NS_IMPL_IDOMNODE_USING_GENERIC(_g) \ + NS_IMETHOD GetNodeName(nsString& aNodeName) { \ + return _g.GetNodeName(aNodeName); \ + } \ + NS_IMETHOD GetNodeValue(nsString& aNodeValue) { \ + return _g.GetNodeValue(aNodeValue); \ + } \ + NS_IMETHOD SetNodeValue(const nsString& aNodeValue) { \ + return _g.SetNodeValue(aNodeValue); \ + } \ + NS_IMETHOD GetNodeType(PRInt32* aNodeType) { \ + return _g.GetNodeType(aNodeType); \ + } \ + NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode) { \ + return _g.GetParentNode(aParentNode); \ + } \ + NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes) { \ + return _g.GetChildNodes(aChildNodes); \ + } \ + NS_IMETHOD GetHasChildNodes(PRBool* aHasChildNodes) { \ + return _g.GetHasChildNodes(aHasChildNodes); \ + } \ + NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild) { \ + return _g.GetFirstChild(aFirstChild); \ + } \ + NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild) { \ + return _g.GetLastChild(aLastChild); \ + } \ + NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling) { \ + return _g.GetPreviousSibling(aPreviousSibling); \ + } \ + NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling) { \ + return _g.GetNextSibling(aNextSibling); \ + } \ + NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes) { \ + return _g.GetAttributes(aAttributes); \ + } \ + NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, \ + nsIDOMNode** aReturn) { \ + return _g.InsertBefore(aNewChild, aRefChild, aReturn); \ + } \ + NS_IMETHOD AppendChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) { \ + return _g.AppendChild(aOldChild, aReturn); \ + } \ + NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, \ + nsIDOMNode** aReturn) { \ + return _g.ReplaceChild(aNewChild, aOldChild, aReturn); \ + } \ + NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) { \ + return _g.RemoveChild(aOldChild, aReturn); \ + } \ + NS_IMETHOD Equals(nsIDOMNode* aNode, PRBool aDeep, PRBool* aReturn) { \ + return _g.Equals(aNode, aDeep, aReturn); \ + } \ + NS_IMETHOD CloneNode(nsIDOMNode** aReturn); + +/** + * Implement the nsIDOMElement API by forwarding the methods to a + * generic content object (either nsHTMLGenericLeafContent or + * nsHTMLGenericContainerContent) + */ +#define NS_IMPL_IDOMELEMENT_USING_GENERIC(_g) \ + NS_IMETHOD GetTagName(nsString& aTagName) { \ + return _g.GetTagName(aTagName); \ + } \ + NS_IMETHOD GetDOMAttribute(const nsString& aName, nsString& aReturn) { \ + return _g.GetDOMAttribute(aName, aReturn); \ + } \ + NS_IMETHOD SetDOMAttribute(const nsString& aName, const nsString& aValue) { \ + return _g.SetDOMAttribute(aName, aValue); \ + } \ + NS_IMETHOD RemoveAttribute(const nsString& aName) { \ + return _g.RemoveAttribute(aName); \ + } \ + NS_IMETHOD GetAttributeNode(const nsString& aName, \ + nsIDOMAttribute** aReturn) { \ + return _g.GetAttributeNode(aName, aReturn); \ + } \ + NS_IMETHOD SetAttributeNode(nsIDOMAttribute* aNewAttr) { \ + return _g.SetAttributeNode(aNewAttr); \ + } \ + NS_IMETHOD RemoveAttributeNode(nsIDOMAttribute* aOldAttr) { \ + return _g.RemoveAttributeNode(aOldAttr); \ + } \ + NS_IMETHOD GetElementsByTagName(const nsString& aTagname, \ + nsIDOMNodeList** aReturn) { \ + return _g.GetElementsByTagName(aTagname, aReturn); \ + } \ + NS_IMETHOD Normalize() { \ + return _g.Normalize(); \ + } + +/** + * Implement the nsIDOMHTMLElement API by forwarding the methods to a + * generic content object (either nsHTMLGenericLeafContent or + * nsHTMLGenericContainerContent) + */ +#define NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(_g) \ + NS_IMETHOD GetId(nsString& aId) { \ + return _g.GetId(aId); \ + } \ + NS_IMETHOD SetId(const nsString& aId) { \ + return _g.SetId(aId); \ + } \ + NS_IMETHOD GetTitle(nsString& aTitle) { \ + return _g.GetTitle(aTitle); \ + } \ + NS_IMETHOD SetTitle(const nsString& aTitle) { \ + return _g.SetTitle(aTitle); \ + } \ + NS_IMETHOD GetLang(nsString& aLang) { \ + return _g.GetLang(aLang); \ + } \ + NS_IMETHOD SetLang(const nsString& aLang) { \ + return _g.SetLang(aLang); \ + } \ + NS_IMETHOD GetDir(nsString& aDir) { \ + return _g.GetDir(aDir); \ + } \ + NS_IMETHOD SetDir(const nsString& aDir) { \ + return _g.SetDir(aDir); \ + } \ + NS_IMETHOD GetClassName(nsString& aClassName) { \ + return _g.GetClassName(aClassName); \ + } \ + NS_IMETHOD SetClassName(const nsString& aClassName) { \ + return _g.SetClassName(aClassName); \ + } + +/** + * Implement the nsIDOMEventReceiver API by forwarding the methods to a + * generic content object (either nsHTMLGenericLeafContent or + * nsHTMLGenericContainerContent) + */ +#define NS_IMPL_IDOMEVENTRECEIVER_USING_GENERIC(_g) \ + NS_IMETHOD AddEventListener(nsIDOMEventListener *aListener, \ + const nsIID& aIID) { \ + return _g.AddEventListener(aListener, aIID); \ + } \ + NS_IMETHOD RemoveEventListener(nsIDOMEventListener *aListener, \ + const nsIID& aIID) { \ + return _g.RemoveEventListener(aListener, aIID); \ + } \ + NS_IMETHOD GetListenerManager(nsIEventListenerManager** aResult) { \ + return _g.GetListenerManager(aResult); \ + } \ + NS_IMETHOD GetNewListenerManager(nsIEventListenerManager** aResult) { \ + return _g.GetNewListenerManager(aResult); \ + } + +/** + * Implement the nsIScriptObjectOwner API by forwarding the methods to a + * generic content object (either nsHTMLGenericLeafContent or + * nsHTMLGenericContainerContent) + */ +#define NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(_g) \ + NS_IMETHOD GetScriptObject(nsIScriptContext* aContext, \ + void** aScriptObject) { \ + return _g.GetScriptObject(aContext, aScriptObject); \ + } \ + NS_IMETHOD ResetScriptObject() { \ + return _g.ResetScriptObject(); \ + } + +#define NS_IMPL_ICONTENT_USING_GENERIC(_g) \ + NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \ + return _g.GetDocument(aResult); \ + } \ + NS_IMETHOD SetDocument(nsIDocument* aDocument) { \ + return _g.SetDocument(aDocument); \ + } \ + NS_IMETHOD GetParent(nsIContent*& aResult) const { \ + return _g.GetParent(aResult); \ + } \ + NS_IMETHOD SetParent(nsIContent* aParent) { \ + return _g.SetParent(aParent); \ + } \ + NS_IMETHOD CanContainChildren(PRBool& aResult) const { \ + return _g.CanContainChildren(aResult); \ + } \ + NS_IMETHOD ChildCount(PRInt32& aResult) const { \ + return _g.ChildCount(aResult); \ + } \ + NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const { \ + return _g.ChildAt(aIndex, aResult); \ + } \ + NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const { \ + return _g.IndexOf(aPossibleChild, aResult); \ + } \ + NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, \ + PRBool aNotify) { \ + return _g.InsertChildAt(aKid, aIndex, aNotify); \ + } \ + NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, \ + PRBool aNotify) { \ + return _g.ReplaceChildAt(aKid, aIndex, aNotify); \ + } \ + NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify) { \ + return _g.AppendChildTo(aKid, aNotify); \ + } \ + NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) { \ + return _g.RemoveChildAt(aIndex, aNotify); \ + } \ + NS_IMETHOD IsSynthetic(PRBool& aResult) { \ + return _g.IsSynthetic(aResult); \ + } \ + NS_IMETHOD GetTag(nsIAtom*& aResult) const { \ + return _g.GetTag(aResult); \ + } \ + NS_IMETHOD SetAttribute(const nsString& aName, const nsString& aValue, \ + PRBool aNotify) { \ + return _g.SetAttribute(aName, aValue, aNotify); \ + } \ + NS_IMETHOD GetAttribute(const nsString& aName, \ + nsString& aResult) const { \ + return _g.GetAttribute(aName, aResult); \ + } \ + virtual nsIContentDelegate* GetDelegate(nsIPresContext* aCX) { \ + return _g.GetDelegate(aCX); \ + } \ + NS_IMETHOD List(FILE* out, PRInt32 aIndent) const { \ + return _g.List(out, aIndent); \ + } \ + NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const { \ + return _g.BeginConvertToXIF(aConverter); \ + } \ + NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const { \ + return _g.ConvertContentToXIF(aConverter); \ + } \ + NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const { \ + return _g.FinishConvertToXIF(aConverter); \ + } \ + NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const { \ + return _g.SizeOf(aHandler); \ + } \ + NS_IMETHOD HandleDOMEvent(nsIPresContext& aPresContext, \ + nsEvent* aEvent, \ + nsIDOMEvent** aDOMEvent, \ + PRUint32 aFlags, \ + nsEventStatus& aEventStatus); + +#define NS_IMPL_IHTMLCONTENT_USING_GENERIC(_g) \ + NS_IMETHOD Compact() { \ + return _g.Compact(); \ + } \ + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue, \ + PRBool aNotify) { \ + return _g.SetAttribute(aAttribute, aValue, aNotify); \ + } \ + NS_IMETHOD SetAttribute(nsIAtom* aAttribute, \ + const nsHTMLValue& aValue, PRBool aNotify) { \ + return _g.SetAttribute(aAttribute, aValue, aNotify); \ + } \ + NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute) { \ + return _g.UnsetAttribute(aAttribute); \ + } \ + NS_IMETHOD GetAttribute(nsIAtom *aAttribute, \ + nsString &aResult) const { \ + return _g.GetAttribute(aAttribute, aResult); \ + } \ + NS_IMETHOD GetAttribute(nsIAtom* aAttribute, \ + nsHTMLValue& aValue) const { \ + return _g.GetAttribute(aAttribute, aValue); \ + } \ + NS_IMETHOD GetAllAttributeNames(nsISupportsArray* aArray, \ + PRInt32& aResult) const { \ + return _g.GetAllAttributeNames(aArray, aResult); \ + } \ + NS_IMETHOD GetAttributeCount(PRInt32& aResult) const { \ + return _g.GetAttributeCount(aResult); \ + } \ + NS_IMETHOD SetID(nsIAtom* aID) { \ + return _g.SetID(aID); \ + } \ + NS_IMETHOD GetID(nsIAtom*& aResult) const { \ + return _g.GetID(aResult); \ + } \ + NS_IMETHOD SetClass(nsIAtom* aClass) { \ + return _g.SetClass(aClass); \ + } \ + NS_IMETHOD GetClass(nsIAtom*& aResult) const { \ + return _g.GetClass(aResult); \ + } \ + NS_IMETHOD GetStyleRule(nsIStyleRule*& aResult) { \ + return _g.GetStyleRule(aResult); \ + } \ + NS_IMETHOD ToHTMLString(nsString& aResult) const { \ + return _g.ToHTMLString(aResult); \ + } \ + NS_IMETHOD ToHTML(FILE* out) const { \ + return _g.ToHTML(out); \ + } \ + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, \ + nsIFrame* aParentFrame, \ + nsIStyleContext* aStyleContext, \ + nsIFrame*& aResult) { \ + return _g.CreateFrame(aPresContext, aParentFrame, aStyleContext, \ + aResult); \ + } \ + NS_IMETHOD StringToAttribute(nsIAtom* aAttribute, \ + const nsString& aValue, \ + nsHTMLValue& aResult); \ + NS_IMETHOD AttributeToString(nsIAtom* aAttribute, \ + nsHTMLValue& aValue, \ + nsString& aResult) const; \ + NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, \ + nsIPresContext* aPresContext); + +/** + * This macro implements the portion of query interface that is + * generic to all html content objects. + */ +#define NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(_id, _iptr, _this) \ + if (_id.Equals(kISupportsIID)) { \ + nsIHTMLContent* tmp = _this; \ + nsISupports* tmp2 = tmp; \ + *_iptr = (void*) tmp2; \ + AddRef(); \ + return NS_OK; \ + } \ + if (_id.Equals(kIDOMNodeIID)) { \ + nsIDOMNode* tmp = _this; \ + *_iptr = (void*) tmp; \ + AddRef(); \ + return NS_OK; \ + } \ + if (_id.Equals(kIDOMElementIID)) { \ + nsIDOMElement* tmp = _this; \ + *_iptr = (void*) tmp; \ + AddRef(); \ + return NS_OK; \ + } \ + if (_id.Equals(kIDOMHTMLElementIID)) { \ + nsIDOMHTMLElement* tmp = _this; \ + *_iptr = (void*) tmp; \ + AddRef(); \ + return NS_OK; \ + } \ + if (_id.Equals(kIDOMEventReceiverIID)) { \ + nsIDOMEventReceiver* tmp = _this; \ + *_iptr = (void*) tmp; \ + AddRef(); \ + return NS_OK; \ + } \ + if (_id.Equals(kIScriptObjectOwnerIID)) { \ + nsIScriptObjectOwner* tmp = _this; \ + *_iptr = (void*) tmp; \ + AddRef(); \ + return NS_OK; \ + } \ + if (_id.Equals(kIContentIID)) { \ + nsIContent* tmp = _this; \ + *_iptr = (void*) tmp; \ + AddRef(); \ + return NS_OK; \ + } \ + if (_id.Equals(kIHTMLContentIID)) { \ + nsIHTMLContent* tmp = _this; \ + *_iptr = (void*) tmp; \ + AddRef(); \ + return NS_OK; \ + } + +/** + * A macro to implement the getter and setter for a given string + * valued content property. The method uses the generic SetAttr and + * GetAttribute methods. + */ +#define NS_IMPL_STRING_ATTR(_class, _method, _atom, _notify) \ + NS_IMETHODIMP \ + _class::Get##_method(nsString& aValue) \ + { \ + mInner.GetAttribute(nsHTMLAtoms::_atom, aValue); \ + return NS_OK; \ + } \ + NS_IMETHODIMP \ + _class::Set##_method(const nsString& aValue) \ + { \ + return mInner.SetAttr(nsHTMLAtoms::_atom, aValue, _notify); \ + } + +/** + * A macro to implement the getter and setter for a given boolean + * valued content property. The method uses the generic SetAttr and + * GetAttribute methods. + */ +#define NS_IMPL_BOOL_ATTR(_class, _method, _atom, _notify) \ + NS_IMETHODIMP \ + _class::Get##_method(PRBool* aValue) \ + { \ + nsHTMLValue val; \ + nsresult rv = mInner.GetAttribute(nsHTMLAtoms::_atom, val); \ + *aValue = NS_CONTENT_ATTR_NOT_THERE != rv; \ + return NS_OK; \ + } \ + NS_IMETHODIMP \ + _class::Set##_method(PRBool aValue) \ + { \ + nsAutoString empty; \ + if (aValue) { \ + return mInner.SetAttr(nsHTMLAtoms::_atom, empty, _notify); \ + } \ + else { \ + mInner.UnsetAttribute(nsHTMLAtoms::_atom); \ + return NS_OK; \ + } \ + } + +/** + * A macro to implement the getter and setter for a given integer + * valued content property. The method uses the generic SetAttr and + * GetAttribute methods. + */ +#define NS_IMPL_INT_ATTR(_class, _method, _atom, _notify) \ + NS_IMETHODIMP \ + _class::Get##_method(PRInt32* aValue) \ + { \ + nsHTMLValue value; \ + *aValue = -1; \ + if (NS_CONTENT_ATTR_HAS_VALUE == \ + mInner.GetAttribute(nsHTMLAtoms::_atom, value)) { \ + if (value.GetUnit() == eHTMLUnit_Integer) { \ + *aValue = value.GetIntValue(); \ + } \ + } \ + return NS_OK; \ + } \ + NS_IMETHODIMP \ + _class::Set##_method(PRInt32 aValue) \ + { \ + nsHTMLValue value(aValue, eHTMLUnit_Integer); \ + return mInner.SetAttr(nsHTMLAtoms::_atom, value, _notify); \ + } + +#endif /* nsHTMLLeafContent_h___ */ diff --git a/mozilla/layout/html/content/src/nsHTMLAnchorElement.cpp b/mozilla/layout/html/content/src/nsHTMLAnchorElement.cpp new file mode 100644 index 00000000000..05e7072a7f2 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLAnchorElement.cpp @@ -0,0 +1,295 @@ +/* -*- 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 "nsIDOMHTMLAnchorElement.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(kIDOMHTMLAnchorElementIID, NS_IDOMHTMLANCHORELEMENT_IID); + +class nsHTMLAnchorElement : public nsIDOMHTMLAnchorElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLAnchorElement(nsIAtom* aTag); + ~nsHTMLAnchorElement(); + + // 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) + + // nsIDOMHTMLAnchorElement + NS_IMETHOD GetAccessKey(nsString& aAccessKey); + NS_IMETHOD SetAccessKey(const nsString& aAccessKey); + NS_IMETHOD GetCharset(nsString& aCharset); + NS_IMETHOD SetCharset(const nsString& aCharset); + NS_IMETHOD GetCoords(nsString& aCoords); + NS_IMETHOD SetCoords(const nsString& aCoords); + NS_IMETHOD GetHref(nsString& aHref); + NS_IMETHOD SetHref(const nsString& aHref); + NS_IMETHOD GetHreflang(nsString& aHreflang); + NS_IMETHOD SetHreflang(const nsString& aHreflang); + NS_IMETHOD GetName(nsString& aName); + NS_IMETHOD SetName(const nsString& aName); + NS_IMETHOD GetRel(nsString& aRel); + NS_IMETHOD SetRel(const nsString& aRel); + NS_IMETHOD GetRev(nsString& aRev); + NS_IMETHOD SetRev(const nsString& aRev); + NS_IMETHOD GetShape(nsString& aShape); + NS_IMETHOD SetShape(const nsString& aShape); + NS_IMETHOD GetTabIndex(PRInt32* aTabIndex); + NS_IMETHOD SetTabIndex(PRInt32 aTabIndex); + NS_IMETHOD GetTarget(nsString& aTarget); + NS_IMETHOD SetTarget(const nsString& aTarget); + NS_IMETHOD GetType(nsString& aType); + NS_IMETHOD SetType(const nsString& aType); + NS_IMETHOD Blur(); + NS_IMETHOD Focus(); + + // 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_NewHTMLAnchorElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLAnchorElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLAnchorElement::nsHTMLAnchorElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLAnchorElement::~nsHTMLAnchorElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLAnchorElement) + +NS_IMPL_RELEASE(nsHTMLAnchorElement) + +nsresult +nsHTMLAnchorElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLAnchorElementIID)) { + nsIDOMHTMLAnchorElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLAnchorElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLAnchorElement* it = new nsHTMLAnchorElement(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(nsHTMLAnchorElement, AccessKey, accesskey, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Charset, charset, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Coords, coords, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Href, href, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Hreflang, hreflang, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Name, name, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Rel, rel, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Rev, rev, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Shape, shape, eSetAttrNotify_None) +NS_IMPL_INT_ATTR(nsHTMLAnchorElement, TabIndex, tabindex, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Target, target, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Type, type, eSetAttrNotify_None) + +NS_IMETHODIMP +nsHTMLAnchorElement::Blur() +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLAnchorElement::Focus() +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLAnchorElement::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 +nsHTMLAnchorElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLAnchorElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLAnchorElement::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/nsHTMLAppletElement.cpp b/mozilla/layout/html/content/src/nsHTMLAppletElement.cpp new file mode 100644 index 00000000000..e4f369d17a0 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLAppletElement.cpp @@ -0,0 +1,211 @@ +/* -*- 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 "nsIDOMHTMLAppletElement.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(kIDOMHTMLAppletElementIID, NS_IDOMHTMLAPPLETELEMENT_IID); + +class nsHTMLAppletElement : public nsIDOMHTMLAppletElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLAppletElement(nsIAtom* aTag); + ~nsHTMLAppletElement(); + + // 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) + + // nsIDOMHTMLAppletElement + NS_IMETHOD GetAlign(nsString& aAlign); + NS_IMETHOD SetAlign(const nsString& aAlign); + NS_IMETHOD GetAlt(nsString& aAlt); + NS_IMETHOD SetAlt(const nsString& aAlt); + NS_IMETHOD GetArchive(nsString& aArchive); + NS_IMETHOD SetArchive(const nsString& aArchive); + NS_IMETHOD GetCode(nsString& aCode); + NS_IMETHOD SetCode(const nsString& aCode); + NS_IMETHOD GetCodeBase(nsString& aCodeBase); + NS_IMETHOD SetCodeBase(const nsString& aCodeBase); + NS_IMETHOD GetHeight(nsString& aHeight); + NS_IMETHOD SetHeight(const nsString& aHeight); + NS_IMETHOD GetHspace(nsString& aHspace); + NS_IMETHOD SetHspace(const nsString& aHspace); + NS_IMETHOD GetName(nsString& aName); + NS_IMETHOD SetName(const nsString& aName); + NS_IMETHOD GetObject(nsString& aObject); + NS_IMETHOD SetObject(const nsString& aObject); + 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_NewHTMLAppletElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLAppletElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLAppletElement::nsHTMLAppletElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLAppletElement::~nsHTMLAppletElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLAppletElement) + +NS_IMPL_RELEASE(nsHTMLAppletElement) + +nsresult +nsHTMLAppletElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLAppletElementIID)) { + nsIDOMHTMLAppletElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLAppletElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLAppletElement* it = new nsHTMLAppletElement(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(nsHTMLAppletElement, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Alt, alt, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Archive, archive, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Code, code, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLAppletElement, CodeBase, codebase, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Height, height, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Hspace, hspace, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Name, name, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Object, object, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Vspace, vspace, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Width, width, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLAppletElement::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 +nsHTMLAppletElement::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 +nsHTMLAppletElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + mInner.MapImageAlignAttributeInto(aContext, aPresContext); + mInner.MapImageAttributesInto(aContext, aPresContext); + mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull); + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLAppletElement::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/nsHTMLAreaElement.cpp b/mozilla/layout/html/content/src/nsHTMLAreaElement.cpp new file mode 100644 index 00000000000..19cfa3b1f76 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLAreaElement.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 "nsIDOMHTMLAreaElement.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(kIDOMHTMLAreaElementIID, NS_IDOMHTMLAREAELEMENT_IID); + +class nsHTMLAreaElement : public nsIDOMHTMLAreaElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLAreaElement(nsIAtom* aTag); + ~nsHTMLAreaElement(); + + // 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) + + // nsIDOMHTMLAreaElement + NS_IMETHOD GetAccessKey(nsString& aAccessKey); + NS_IMETHOD SetAccessKey(const nsString& aAccessKey); + NS_IMETHOD GetAlt(nsString& aAlt); + NS_IMETHOD SetAlt(const nsString& aAlt); + NS_IMETHOD GetCoords(nsString& aCoords); + NS_IMETHOD SetCoords(const nsString& aCoords); + NS_IMETHOD GetHref(nsString& aHref); + NS_IMETHOD SetHref(const nsString& aHref); + NS_IMETHOD GetNoHref(PRBool* aNoHref); + NS_IMETHOD SetNoHref(PRBool aNoHref); + NS_IMETHOD GetShape(nsString& aShape); + NS_IMETHOD SetShape(const nsString& aShape); + NS_IMETHOD GetTabIndex(PRInt32* aTabIndex); + NS_IMETHOD SetTabIndex(PRInt32 aTabIndex); + NS_IMETHOD GetTarget(nsString& aTarget); + NS_IMETHOD SetTarget(const nsString& aTarget); + + // 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_NewHTMLAreaElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLAreaElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLAreaElement::nsHTMLAreaElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLAreaElement::~nsHTMLAreaElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLAreaElement) + +NS_IMPL_RELEASE(nsHTMLAreaElement) + +nsresult +nsHTMLAreaElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLAreaElementIID)) { + nsIDOMHTMLAreaElement* tmp = this; + *aInstancePtr = (void*) tmp; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLAreaElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLAreaElement* it = new nsHTMLAreaElement(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(nsHTMLAreaElement, AccessKey, accesskey, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAreaElement, Alt, alt, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAreaElement, Coords, coords, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAreaElement, Href, href, eSetAttrNotify_None) +NS_IMPL_BOOL_ATTR(nsHTMLAreaElement, NoHref, nohref, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAreaElement, Shape, shape, eSetAttrNotify_None) +NS_IMPL_INT_ATTR(nsHTMLAreaElement, TabIndex, tabindex, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLAreaElement, Target, target, eSetAttrNotify_None) + +NS_IMETHODIMP +nsHTMLAreaElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLAreaElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLAreaElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLAreaElement::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/nsHTMLBRElement.cpp b/mozilla/layout/html/content/src/nsHTMLBRElement.cpp new file mode 100644 index 00000000000..ecb0c1ec88c --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLBRElement.cpp @@ -0,0 +1,187 @@ +/* -*- 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 "nsIDOMHTMLBRElement.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(kIDOMHTMLBRElementIID, NS_IDOMHTMLBRELEMENT_IID); + +class nsHTMLBRElement : public nsIDOMHTMLBRElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLBRElement(nsIAtom* aTag); + ~nsHTMLBRElement(); + + // 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) + + // nsIDOMHTMLBRElement + NS_IMETHOD GetClear(nsString& aClear); + NS_IMETHOD SetClear(const nsString& aClear); + + // 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_NewHTMLBRElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLBRElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLBRElement::nsHTMLBRElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLBRElement::~nsHTMLBRElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLBRElement) + +NS_IMPL_RELEASE(nsHTMLBRElement) + +nsresult +nsHTMLBRElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLBRElementIID)) { + nsIDOMHTMLBRElement* tmp = this; + *aInstancePtr = (void*) tmp; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLBRElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLBRElement* it = new nsHTMLBRElement(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(nsHTMLBRElement, Clear, clear, eSetAttrNotify_Reflow) + +static nsHTMLGenericContent::EnumTable kClearTable[] = { + { "left", NS_STYLE_CLEAR_LEFT }, + { "right", NS_STYLE_CLEAR_RIGHT }, + { "all", NS_STYLE_CLEAR_LEFT_AND_RIGHT }, + { "both", NS_STYLE_CLEAR_LEFT_AND_RIGHT }, + { 0 } +}; + +NS_IMETHODIMP +nsHTMLBRElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + if (aAttribute == nsHTMLAtoms::clear) { + if (nsHTMLGenericContent::ParseEnumValue(aValue, kClearTable, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } + } + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLBRElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + if (aAttribute == nsHTMLAtoms::clear) { + if (eHTMLUnit_Enumerated == aValue.GetUnit()) { + nsHTMLGenericContent::EnumValueToString(aValue, kClearTable, aResult); + return NS_CONTENT_ATTR_HAS_VALUE; + } + } + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLBRElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + if (nsnull != mInner.mAttributes) { + nsStyleDisplay* display = (nsStyleDisplay*) + aContext->GetMutableStyleData(eStyleStruct_Display); + nsHTMLValue value; + GetAttribute(nsHTMLAtoms::clear, value); + if (value.GetUnit() == eHTMLUnit_Enumerated) { + display->mBreakType = value.GetIntValue(); + } + } + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLBRElement::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/nsHTMLBaseElement.cpp b/mozilla/layout/html/content/src/nsHTMLBaseElement.cpp new file mode 100644 index 00000000000..f3f53eadb9d --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLBaseElement.cpp @@ -0,0 +1,162 @@ +/* -*- 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 "nsIDOMHTMLBaseElement.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(kIDOMHTMLBaseElementIID, NS_IDOMHTMLBASEELEMENT_IID); + +class nsHTMLBaseElement : public nsIDOMHTMLBaseElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLBaseElement(nsIAtom* aTag); + ~nsHTMLBaseElement(); + + // 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) + + // nsIDOMHTMLBaseElement + NS_IMETHOD GetHref(nsString& aHref); + NS_IMETHOD SetHref(const nsString& aHref); + NS_IMETHOD GetTarget(nsString& aTarget); + NS_IMETHOD SetTarget(const nsString& aTarget); + + // 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_NewHTMLBaseElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLBaseElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLBaseElement::nsHTMLBaseElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLBaseElement::~nsHTMLBaseElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLBaseElement) + +NS_IMPL_RELEASE(nsHTMLBaseElement) + +nsresult +nsHTMLBaseElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLBaseElementIID)) { + nsIDOMHTMLBaseElement* tmp = this; + *aInstancePtr = (void*) tmp; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLBaseElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLBaseElement* it = new nsHTMLBaseElement(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(nsHTMLBaseElement, Href, href, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLBaseElement, Target, target, eSetAttrNotify_None) + +NS_IMETHODIMP +nsHTMLBaseElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLBaseElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLBaseElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLBaseElement::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/nsHTMLBaseFontElement.cpp b/mozilla/layout/html/content/src/nsHTMLBaseFontElement.cpp new file mode 100644 index 00000000000..40726de9282 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLBaseFontElement.cpp @@ -0,0 +1,168 @@ +/* -*- 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 "nsIDOMHTMLBaseFontElement.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(kIDOMHTMLBaseFontElementIID, NS_IDOMHTMLBASEFONTELEMENT_IID); + +class nsHTMLBaseFontElement : public nsIDOMHTMLBaseFontElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLBaseFontElement(nsIAtom* aTag); + ~nsHTMLBaseFontElement(); + + // 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) + + // nsIDOMHTMLBaseElement + NS_IMETHOD GetColor(nsString& aColor); + NS_IMETHOD SetColor(const nsString& aColor); + NS_IMETHOD GetFace(nsString& aFace); + NS_IMETHOD SetFace(const nsString& aFace); + NS_IMETHOD GetSize(nsString& aSize); + NS_IMETHOD SetSize(const nsString& aSize); + + // 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_NewHTMLBaseFontElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLBaseFontElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLBaseFontElement::nsHTMLBaseFontElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLBaseFontElement::~nsHTMLBaseFontElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLBaseFontElement) + +NS_IMPL_RELEASE(nsHTMLBaseFontElement) + +nsresult +nsHTMLBaseFontElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLBaseFontElementIID)) { + nsIDOMHTMLBaseFontElement* tmp = this; + *aInstancePtr = (void*) tmp; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLBaseFontElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLBaseFontElement* it = new nsHTMLBaseFontElement(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(nsHTMLBaseFontElement, Color, color, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLBaseFontElement, Face, face, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLBaseFontElement, Size, size, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLBaseFontElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLBaseFontElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLBaseFontElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me? + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLBaseFontElement::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/nsHTMLBodyElement.cpp b/mozilla/layout/html/content/src/nsHTMLBodyElement.cpp new file mode 100644 index 00000000000..688d348e1df --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLBodyElement.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 "nsIDOMHTMLBodyElement.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(kIDOMHTMLBodyElementIID, NS_IDOMHTMLBODYELEMENT_IID); + +class nsHTMLBodyElement : public nsIDOMHTMLBodyElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLBodyElement(nsIAtom* aTag); + ~nsHTMLBodyElement(); + + // 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) + + // nsIDOMHTMLBodyElement + NS_IMETHOD GetALink(nsString& aALink); + NS_IMETHOD SetALink(const nsString& aALink); + NS_IMETHOD GetBackground(nsString& aBackground); + NS_IMETHOD SetBackground(const nsString& aBackground); + NS_IMETHOD GetBgColor(nsString& aBgColor); + NS_IMETHOD SetBgColor(const nsString& aBgColor); + NS_IMETHOD GetLink(nsString& aLink); + NS_IMETHOD SetLink(const nsString& aLink); + NS_IMETHOD GetText(nsString& aText); + NS_IMETHOD SetText(const nsString& aText); + NS_IMETHOD GetVLink(nsString& aVLink); + NS_IMETHOD SetVLink(const nsString& aVLink); + + // 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_NewHTMLBodyElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLBodyElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLBodyElement::nsHTMLBodyElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLBodyElement::~nsHTMLBodyElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLBodyElement) + +NS_IMPL_RELEASE(nsHTMLBodyElement) + +nsresult +nsHTMLBodyElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLBodyElementIID)) { + nsIDOMHTMLBodyElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLBodyElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLBodyElement* it = new nsHTMLBodyElement(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(nsHTMLBodyElement, ALink, alink, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLBodyElement, Background, background, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLBodyElement, BgColor, bgcolor, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLBodyElement, Link, link, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLBodyElement, Text, text, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLBodyElement, VLink, vlink, eSetAttrNotify_Render) + +NS_IMETHODIMP +nsHTMLBodyElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLBodyElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLBodyElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLBodyElement::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/nsHTMLDListElement.cpp b/mozilla/layout/html/content/src/nsHTMLDListElement.cpp new file mode 100644 index 00000000000..66c536cdcbc --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLDListElement.cpp @@ -0,0 +1,162 @@ +/* -*- 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 "nsIDOMHTMLDListElement.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(kIDOMHTMLDListElementIID, NS_IDOMHTMLDLISTELEMENT_IID); + +class nsHTMLDListElement : public nsIDOMHTMLDListElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLDListElement(nsIAtom* aTag); + ~nsHTMLDListElement(); + + // 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) + + // nsIDOMHTMLDListElement + NS_IMETHOD GetCompact(PRBool* aCompact); + NS_IMETHOD SetCompact(PRBool aCompact); + + // 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_NewHTMLDListElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLDListElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLDListElement::nsHTMLDListElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLDListElement::~nsHTMLDListElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLDListElement) + +NS_IMPL_RELEASE(nsHTMLDListElement) + +nsresult +nsHTMLDListElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLDListElementIID)) { + nsIDOMHTMLDListElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLDListElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLDListElement* it = new nsHTMLDListElement(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(nsHTMLDListElement, Compact, compact, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLDListElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLDListElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLDListElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLDListElement::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/nsHTMLDelElement.cpp b/mozilla/layout/html/content/src/nsHTMLDelElement.cpp new file mode 100644 index 00000000000..4db504ac163 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLDelElement.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 "nsIDOMHTMLDelElement.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(kIDOMHTMLDelElementIID, NS_IDOMHTMLDELELEMENT_IID); + +class nsHTMLDelElement : public nsIDOMHTMLDelElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLDelElement(nsIAtom* aTag); + ~nsHTMLDelElement(); + + // 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) + + // nsIDOMHTMLDelElement + NS_IMETHOD GetCite(nsString& aCite); + NS_IMETHOD SetCite(const nsString& aCite); + NS_IMETHOD GetDateTime(nsString& aDateTime); + NS_IMETHOD SetDateTime(const nsString& aDateTime); + + // 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_NewHTMLDelElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLDelElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLDelElement::nsHTMLDelElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLDelElement::~nsHTMLDelElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLDelElement) + +NS_IMPL_RELEASE(nsHTMLDelElement) + +nsresult +nsHTMLDelElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLDelElementIID)) { + nsIDOMHTMLDelElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLDelElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLDelElement* it = new nsHTMLDelElement(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(nsHTMLDelElement, Cite, cite, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLDelElement, DateTime, datetime, eSetAttrNotify_None) + +NS_IMETHODIMP +nsHTMLDelElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLDelElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLDelElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLDelElement::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/nsHTMLDirectoryElement.cpp b/mozilla/layout/html/content/src/nsHTMLDirectoryElement.cpp new file mode 100644 index 00000000000..aea1a95b0a9 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLDirectoryElement.cpp @@ -0,0 +1,162 @@ +/* -*- 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 "nsIDOMHTMLDirectoryElement.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(kIDOMHTMLDirectoryElementIID, NS_IDOMHTMLDIRECTORYELEMENT_IID); + +class nsHTMLDirectoryElement : public nsIDOMHTMLDirectoryElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLDirectoryElement(nsIAtom* aTag); + ~nsHTMLDirectoryElement(); + + // 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) + + // nsIDOMHTMLDirectoryElement + NS_IMETHOD GetCompact(PRBool* aCompact); + NS_IMETHOD SetCompact(PRBool aCompact); + + // 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_NewHTMLDirectoryElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLDirectoryElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLDirectoryElement::nsHTMLDirectoryElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLDirectoryElement::~nsHTMLDirectoryElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLDirectoryElement) + +NS_IMPL_RELEASE(nsHTMLDirectoryElement) + +nsresult +nsHTMLDirectoryElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLDirectoryElementIID)) { + nsIDOMHTMLDirectoryElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLDirectoryElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLDirectoryElement* it = new nsHTMLDirectoryElement(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(nsHTMLDirectoryElement, Compact, compact, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLDirectoryElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLDirectoryElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLDirectoryElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLDirectoryElement::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/nsHTMLDivElement.cpp b/mozilla/layout/html/content/src/nsHTMLDivElement.cpp new file mode 100644 index 00000000000..28bee113049 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLDivElement.cpp @@ -0,0 +1,173 @@ +/* -*- 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 "nsIDOMHTMLDivElement.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" + +// XXX missing nav attributes + +static NS_DEFINE_IID(kIDOMHTMLDivElementIID, NS_IDOMHTMLDIVELEMENT_IID); + +class nsHTMLDivElement : public nsIDOMHTMLDivElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLDivElement(nsIAtom* aTag); + ~nsHTMLDivElement(); + + // 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) + + // nsIDOMHTMLDivElement + 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_NewHTMLDivElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLDivElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLDivElement::nsHTMLDivElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLDivElement::~nsHTMLDivElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLDivElement) + +NS_IMPL_RELEASE(nsHTMLDivElement) + +nsresult +nsHTMLDivElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLDivElementIID)) { + nsIDOMHTMLDivElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLDivElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLDivElement* it = new nsHTMLDivElement(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(nsHTMLDivElement, Align, align, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLDivElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + if (aAttribute == nsHTMLAtoms::align) { + if (nsHTMLGenericContent::ParseAlignValue(aValue, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } + } + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLDivElement::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; + } + } + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLDivElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLDivElement::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/nsHTMLEmbed.cpp b/mozilla/layout/html/content/src/nsHTMLEmbed.cpp deleted file mode 100644 index 7960832e31a..00000000000 --- a/mozilla/layout/html/content/src/nsHTMLEmbed.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- 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 "nsHTMLParts.h" -#include "nsObjectContent.h" -#include "nsHTMLIIDs.h" - -#define nsHTMLEmbedSuper nsObjectContent - -class nsHTMLEmbed : public nsHTMLEmbedSuper { -public: - nsHTMLEmbed(nsIAtom* aTag); - -protected: - virtual ~nsHTMLEmbed(); -}; - -nsHTMLEmbed::nsHTMLEmbed(nsIAtom* aTag) - : nsHTMLEmbedSuper(aTag) -{ -} - -nsHTMLEmbed::~nsHTMLEmbed() -{ -} - -nsresult -NS_NewHTMLEmbed(nsIHTMLContent** aInstancePtrResult, - nsIAtom* aTag) -{ - NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); - if (nsnull == aInstancePtrResult) { - return NS_ERROR_NULL_POINTER; - } - nsIHTMLContent* it = new nsHTMLEmbed(aTag); - if (nsnull == it) { - return NS_ERROR_OUT_OF_MEMORY; - } - return it->QueryInterface(kIHTMLContentIID, (void **) aInstancePtrResult); -} diff --git a/mozilla/layout/html/content/src/nsHTMLEmbedElement.cpp b/mozilla/layout/html/content/src/nsHTMLEmbedElement.cpp new file mode 100644 index 00000000000..660906d04a2 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLEmbedElement.cpp @@ -0,0 +1,181 @@ +/* -*- 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 "nsIDOMHTMLElement.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" + +// XXX define nsIDOMHTMLEmbedElement; add in nav attrs + +//static NS_DEFINE_IID(kIDOMHTMLEmbedElementIID, NS_IDOMHTMLEmbedELEMENT_IID); + +class nsHTMLEmbedElement : public nsIDOMHTMLElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLEmbedElement(nsIAtom* aTag); + ~nsHTMLEmbedElement(); + + // 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) + + // nsIDOMHTMLEmbedElement + + // 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_NewHTMLEmbedElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLEmbedElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLEmbedElement::nsHTMLEmbedElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLEmbedElement::~nsHTMLEmbedElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLEmbedElement) + +NS_IMPL_RELEASE(nsHTMLEmbedElement) + +nsresult +nsHTMLEmbedElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) +#if XXX + if (aIID.Equals(kIDOMHTMLEmbedElementIID)) { + nsIDOMHTMLEmbedElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } +#endif + return NS_NOINTERFACE; +} + +nsresult +nsHTMLEmbedElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLEmbedElement* it = new nsHTMLEmbedElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMETHODIMP +nsHTMLEmbedElement::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 +nsHTMLEmbedElement::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 +nsHTMLEmbedElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + mInner.MapImageAlignAttributeInto(aContext, aPresContext); + mInner.MapImageAttributesInto(aContext, aPresContext); + mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull); + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLEmbedElement::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/nsHTMLFont.cpp b/mozilla/layout/html/content/src/nsHTMLFontElement.cpp similarity index 77% rename from mozilla/layout/html/content/src/nsHTMLFont.cpp rename to mozilla/layout/html/content/src/nsHTMLFontElement.cpp index 3a0f6fb17d2..3daf247b8b2 100644 --- a/mozilla/layout/html/content/src/nsHTMLFont.cpp +++ b/mozilla/layout/html/content/src/nsHTMLFontElement.cpp @@ -20,7 +20,7 @@ #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" @@ -29,14 +29,14 @@ static NS_DEFINE_IID(kIDOMHTMLFontElementIID, NS_IDOMHTMLFONTELEMENT_IID); -class nsHTMLFont : public nsIDOMHTMLFontElement, +class nsHTMLFontElement : public nsIDOMHTMLFontElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLFont(nsIAtom* aTag); - ~nsHTMLFont(); + nsHTMLFontElement(nsIAtom* aTag); + ~nsHTMLFontElement(); // nsISupports NS_DECL_ISUPPORTS @@ -75,35 +75,35 @@ protected: }; nsresult -NS_NewHTMLFont(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLFontElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLFont(aTag); + nsIHTMLContent* it = new nsHTMLFontElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLFont::nsHTMLFont(nsIAtom* aTag) +nsHTMLFontElement::nsHTMLFontElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLFont::~nsHTMLFont() +nsHTMLFontElement::~nsHTMLFontElement() { } -NS_IMPL_ADDREF(nsHTMLFont) +NS_IMPL_ADDREF(nsHTMLFontElement) -NS_IMPL_RELEASE(nsHTMLFont) +NS_IMPL_RELEASE(nsHTMLFontElement) nsresult -nsHTMLFont::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLFontElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) if (aIID.Equals(kIDOMHTMLFontElementIID)) { @@ -116,9 +116,9 @@ nsHTMLFont::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLFont::CloneNode(nsIDOMNode** aReturn) +nsHTMLFontElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLFont* it = new nsHTMLFont(mInner.mTag); + nsHTMLFontElement* it = new nsHTMLFontElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -126,12 +126,12 @@ nsHTMLFont::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_STRING_ATTR(nsHTMLFont, Color, face, eSetAttrNotify_Render) -NS_IMPL_STRING_ATTR(nsHTMLFont, Face, face, eSetAttrNotify_Reflow) -NS_IMPL_STRING_ATTR(nsHTMLFont, Size, size, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLFontElement, Color, face, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLFontElement, Face, face, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLFontElement, Size, size, eSetAttrNotify_Reflow) NS_IMETHODIMP -nsHTMLFont::StringToAttribute(nsIAtom* aAttribute, +nsHTMLFontElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -140,7 +140,7 @@ nsHTMLFont::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLFont::AttributeToString(nsIAtom* aAttribute, +nsHTMLFontElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -149,7 +149,7 @@ nsHTMLFont::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLFont::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLFontElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { // XXX write me @@ -157,7 +157,7 @@ nsHTMLFont::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLFont::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLFontElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/layout/html/content/src/nsHTMLFormElement.cpp b/mozilla/layout/html/content/src/nsHTMLFormElement.cpp new file mode 100644 index 00000000000..c0e070be8e2 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLFormElement.cpp @@ -0,0 +1,206 @@ +/* -*- 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 "nsIDOMHTMLFormElement.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(kIDOMHTMLFormElementIID, NS_IDOMHTMLFORMELEMENT_IID); + +class nsHTMLFormElement : public nsIDOMHTMLFormElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLFormElement(nsIAtom* aTag); + ~nsHTMLFormElement(); + + // 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) + + // nsIDOMHTMLFormElement + NS_IMETHOD GetElements(nsIDOMHTMLCollection** aElements); + NS_IMETHOD GetName(nsString& aName); + NS_IMETHOD GetAcceptCharset(nsString& aAcceptCharset); + NS_IMETHOD SetAcceptCharset(const nsString& aAcceptCharset); + NS_IMETHOD GetAction(nsString& aAction); + NS_IMETHOD SetAction(const nsString& aAction); + NS_IMETHOD GetEnctype(nsString& aEnctype); + NS_IMETHOD SetEnctype(const nsString& aEnctype); + NS_IMETHOD GetMethod(nsString& aMethod); + NS_IMETHOD SetMethod(const nsString& aMethod); + NS_IMETHOD GetTarget(nsString& aTarget); + NS_IMETHOD SetTarget(const nsString& aTarget); + NS_IMETHOD Reset(); + NS_IMETHOD Submit(); + + // 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_NewHTMLFormElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLFormElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLFormElement::nsHTMLFormElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLFormElement::~nsHTMLFormElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLFormElement) + +NS_IMPL_RELEASE(nsHTMLFormElement) + +nsresult +nsHTMLFormElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLFormElementIID)) { + nsIDOMHTMLFormElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLFormElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLFormElement* it = new nsHTMLFormElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMETHODIMP +nsHTMLFormElement::GetElements(nsIDOMHTMLCollection** aResult) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLFormElement::GetName(nsString& aValue) +{ + return mInner.GetAttribute(nsHTMLAtoms::name, aValue); +} + +NS_IMPL_STRING_ATTR(nsHTMLFormElement, AcceptCharset, acceptcharset, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLFormElement, Action, action, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLFormElement, Enctype, enctype, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLFormElement, Method, method, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLFormElement, Target, target, eSetAttrNotify_None) + +NS_IMETHODIMP +nsHTMLFormElement::Reset() +{ + // XXX + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLFormElement::Submit() +{ + // XXX + return NS_OK; +} + + +NS_IMETHODIMP +nsHTMLFormElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLFormElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLFormElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLFormElement::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/nsHTMLHRElement.cpp b/mozilla/layout/html/content/src/nsHTMLHRElement.cpp new file mode 100644 index 00000000000..6c6c4f8fcbe --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLHRElement.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 "nsIDOMHTMLHRElement.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(kIDOMHTMLHRElementIID, NS_IDOMHTMLHRELEMENT_IID); + +class nsHTMLHRElement : public nsIDOMHTMLHRElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLHRElement(nsIAtom* aTag); + ~nsHTMLHRElement(); + + // 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) + + // nsIDOMHTMLHRElement + NS_IMETHOD GetAlign(nsString& aAlign); + NS_IMETHOD SetAlign(const nsString& aAlign); + NS_IMETHOD GetNoShade(PRBool* aNoShade); + NS_IMETHOD SetNoShade(PRBool aNoShade); + NS_IMETHOD GetSize(nsString& aSize); + NS_IMETHOD SetSize(const nsString& aSize); + 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: + nsHTMLGenericLeafContent mInner; +}; + +nsresult +NS_NewHTMLHRElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLHRElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLHRElement::nsHTMLHRElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLHRElement::~nsHTMLHRElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLHRElement) + +NS_IMPL_RELEASE(nsHTMLHRElement) + +nsresult +nsHTMLHRElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLHRElementIID)) { + nsIDOMHTMLHRElement* tmp = this; + *aInstancePtr = (void*) tmp; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLHRElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLHRElement* it = new nsHTMLHRElement(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(nsHTMLHRElement, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_BOOL_ATTR(nsHTMLHRElement, NoShade, noshade, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLHRElement, Size, size, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLHRElement, Width, width, eSetAttrNotify_Reflow) + +static nsHTMLGenericContent::EnumTable kAlignTable[] = { + { "left", NS_STYLE_TEXT_ALIGN_LEFT }, + { "right", NS_STYLE_TEXT_ALIGN_RIGHT }, + { "center", NS_STYLE_TEXT_ALIGN_CENTER }, + { 0 } +}; + +NS_IMETHODIMP +nsHTMLHRElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + if (aAttribute == nsHTMLAtoms::width) { + nsHTMLGenericContent::ParseValueOrPercent(aValue, aResult, + eHTMLUnit_Pixel); + return NS_CONTENT_ATTR_HAS_VALUE; + } + else if (aAttribute == nsHTMLAtoms::size) { + nsHTMLGenericContent::ParseValue(aValue, 1, 100, aResult, eHTMLUnit_Pixel); + return NS_CONTENT_ATTR_HAS_VALUE; + } + else if (aAttribute == nsHTMLAtoms::noshade) { + aResult.SetEmptyValue(); + return NS_CONTENT_ATTR_HAS_VALUE; + } + else if (aAttribute == nsHTMLAtoms::align) { + if (nsHTMLGenericContent::ParseEnumValue(aValue, kAlignTable, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } + } + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLHRElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + if (aAttribute == nsHTMLAtoms::align) { + if (eHTMLUnit_Enumerated == aValue.GetUnit()) { + nsHTMLGenericContent::EnumValueToString(aValue, kAlignTable, aResult); + return NS_CONTENT_ATTR_HAS_VALUE; + } + } + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLHRElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + if (nsnull != mInner.mAttributes) { + nsHTMLValue value; + // align: enum + GetAttribute(nsHTMLAtoms::align, value); + if (value.GetUnit() == eHTMLUnit_Enumerated) { + nsStyleText* text = (nsStyleText*) + aContext->GetMutableStyleData(eStyleStruct_Text); + text->mTextAlign = value.GetIntValue(); + } + + // width: pixel, percent + float p2t = aPresContext->GetPixelsToTwips(); + nsStylePosition* pos = (nsStylePosition*) + aContext->GetMutableStyleData(eStyleStruct_Position); + GetAttribute(nsHTMLAtoms::width, value); + if (value.GetUnit() == eHTMLUnit_Pixel) { + nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t); + pos->mWidth.SetCoordValue(twips); + } + else if (value.GetUnit() == eHTMLUnit_Percent) { + pos->mWidth.SetPercentValue(value.GetPercentValue()); + } + } + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLHRElement::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/nsHTMLHead.cpp b/mozilla/layout/html/content/src/nsHTMLHead.cpp deleted file mode 100644 index 7735d18138d..00000000000 --- a/mozilla/layout/html/content/src/nsHTMLHead.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- 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 "NPL"); you may not use this file except in - * compliance with the NPL. You may obtain a copy of the NPL at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the NPL is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL - * for the specific language governing rights and limitations under the - * NPL. - * - * The Initial Developer of this code under the NPL is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. - */ -#include "nsHTMLParts.h" -#include "nsHTMLContainer.h" -#include "nsFrame.h" -#include "nsHTMLIIDs.h" - -class nsHTMLHead : public nsHTMLContainer { -public: - nsHTMLHead(nsIAtom* aTag); - - NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); - -protected: - virtual ~nsHTMLHead(); -}; - -nsHTMLHead::nsHTMLHead(nsIAtom* aTag) - : nsHTMLContainer(aTag) -{ -} - -nsHTMLHead::~nsHTMLHead() -{ -} - -NS_IMETHODIMP -nsHTMLHead::CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult) -{ - nsIFrame* frame; - nsFrame::NewFrame(&frame, this, aParentFrame); - if (nsnull == frame) { - return NS_ERROR_OUT_OF_MEMORY; - } - frame->SetStyleContext(aPresContext, aStyleContext); - aResult = frame; - return NS_OK; -} - -nsresult -NS_NewHTMLHead(nsIHTMLContent** aInstancePtrResult, - nsIAtom* aTag) -{ - NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); - if (nsnull == aInstancePtrResult) { - return NS_ERROR_NULL_POINTER; - } - nsIHTMLContent* it = new nsHTMLHead(aTag); - if (nsnull == it) { - return NS_ERROR_OUT_OF_MEMORY; - } - return it->QueryInterface(kIHTMLContentIID, (void **) aInstancePtrResult); -} diff --git a/mozilla/layout/html/content/src/nsHTMLHeadElement.cpp b/mozilla/layout/html/content/src/nsHTMLHeadElement.cpp new file mode 100644 index 00000000000..1e8ab45bd27 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLHeadElement.cpp @@ -0,0 +1,159 @@ +/* -*- 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 "nsIDOMHTMLHeadElement.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(kIDOMHTMLHeadElementIID, NS_IDOMHTMLHEADELEMENT_IID); + +class nsHTMLHeadElement : public nsIDOMHTMLHeadElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLHeadElement(nsIAtom* aTag); + ~nsHTMLHeadElement(); + + // 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) + + // nsIDOMHTMLHeadElement + NS_IMETHOD GetProfile(nsString& aProfile); + NS_IMETHOD SetProfile(const nsString& aProfile); + + // 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_NewHTMLHeadElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLHeadElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLHeadElement::nsHTMLHeadElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLHeadElement::~nsHTMLHeadElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLHeadElement) + +NS_IMPL_RELEASE(nsHTMLHeadElement) + +nsresult +nsHTMLHeadElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLHeadElementIID)) { + nsIDOMHTMLHeadElement* tmp = this; + *aInstancePtr = (void*) tmp; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLHeadElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLHeadElement* it = new nsHTMLHeadElement(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(nsHTMLHeadElement, Profile, profile, eSetAttrNotify_None) + +NS_IMETHODIMP +nsHTMLHeadElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLHeadElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLHeadElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLHeadElement::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/nsHTMLHeadingElement.cpp b/mozilla/layout/html/content/src/nsHTMLHeadingElement.cpp new file mode 100644 index 00000000000..cb6ef14aff0 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLHeadingElement.cpp @@ -0,0 +1,162 @@ +/* -*- 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 "nsIDOMHTMLHeadingElement.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(kIDOMHTMLHeadingElementIID, NS_IDOMHTMLHEADINGELEMENT_IID); + +class nsHTMLHeadingElement : public nsIDOMHTMLHeadingElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLHeadingElement(nsIAtom* aTag); + ~nsHTMLHeadingElement(); + + // 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) + + // nsIDOMHTMLHeadingElement + 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_NewHTMLHeadingElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLHeadingElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLHeadingElement::nsHTMLHeadingElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLHeadingElement::~nsHTMLHeadingElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLHeadingElement) + +NS_IMPL_RELEASE(nsHTMLHeadingElement) + +nsresult +nsHTMLHeadingElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLHeadingElementIID)) { + nsIDOMHTMLHeadingElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLHeadingElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLHeadingElement* it = new nsHTMLHeadingElement(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(nsHTMLHeadingElement, Align, align, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLHeadingElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLHeadingElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLHeadingElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLHeadingElement::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/nsHTMLBase.cpp b/mozilla/layout/html/content/src/nsHTMLHtmlElement.cpp similarity index 71% rename from mozilla/layout/html/content/src/nsHTMLBase.cpp rename to mozilla/layout/html/content/src/nsHTMLHtmlElement.cpp index da3b42bfb0d..6ed7c41f22d 100644 --- a/mozilla/layout/html/content/src/nsHTMLBase.cpp +++ b/mozilla/layout/html/content/src/nsHTMLHtmlElement.cpp @@ -16,27 +16,27 @@ * Corporation. Portions created by Netscape are Copyright (C) 1998 * Netscape Communications Corporation. All Rights Reserved. */ -#include "nsIDOMHTMLBaseElement.h" +#include "nsIDOMHTMLHtmlElement.h" #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" -static NS_DEFINE_IID(kIDOMHTMLBaseElementIID, NS_IDOMHTMLBASEELEMENT_IID); +static NS_DEFINE_IID(kIDOMHTMLHtmlElementIID, NS_IDOMHTMLHTMLELEMENT_IID); -class nsHTMLBase : public nsIDOMHTMLBaseElement, +class nsHTMLHtmlElement : public nsIDOMHTMLHtmlElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLBase(nsIAtom* aTag); - ~nsHTMLBase(); + nsHTMLHtmlElement(nsIAtom* aTag); + ~nsHTMLHtmlElement(); // nsISupports NS_DECL_ISUPPORTS @@ -50,11 +50,9 @@ public: // nsIDOMHTMLElement NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner) - // nsIDOMHTMLBaseElement - NS_IMETHOD GetHref(nsString& aHref); - NS_IMETHOD SetHref(const nsString& aHref); - NS_IMETHOD GetTarget(nsString& aTarget); - NS_IMETHOD SetTarget(const nsString& aTarget); + // nsIDOMHTMLHtmlElement + NS_IMETHOD GetVersion(nsString& aVersion); + NS_IMETHOD SetVersion(const nsString& aVersion); // nsIScriptObjectOwner NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner) @@ -69,54 +67,54 @@ public: NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner) protected: - nsHTMLGenericLeafContent mInner; + nsHTMLGenericContainerContent mInner; }; nsresult -NS_NewHTMLBase(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLHtmlElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLBase(aTag); + nsIHTMLContent* it = new nsHTMLHtmlElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLBase::nsHTMLBase(nsIAtom* aTag) +nsHTMLHtmlElement::nsHTMLHtmlElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLBase::~nsHTMLBase() +nsHTMLHtmlElement::~nsHTMLHtmlElement() { } -NS_IMPL_ADDREF(nsHTMLBase) +NS_IMPL_ADDREF(nsHTMLHtmlElement) -NS_IMPL_RELEASE(nsHTMLBase) +NS_IMPL_RELEASE(nsHTMLHtmlElement) nsresult -nsHTMLBase::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLHtmlElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) - if (aIID.Equals(kIDOMHTMLBaseElementIID)) { - nsIDOMHTMLBaseElement* tmp = this; + if (aIID.Equals(kIDOMHTMLHtmlElementIID)) { + nsIDOMHTMLHtmlElement* tmp = this; *aInstancePtr = (void*) tmp; - AddRef(); + mRefCnt++; return NS_OK; } return NS_NOINTERFACE; } nsresult -nsHTMLBase::CloneNode(nsIDOMNode** aReturn) +nsHTMLHtmlElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLBase* it = new nsHTMLBase(mInner.mTag); + nsHTMLHtmlElement* it = new nsHTMLHtmlElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -124,11 +122,10 @@ nsHTMLBase::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_STRING_ATTR(nsHTMLBase, Href, href, eSetAttrNotify_None) -NS_IMPL_STRING_ATTR(nsHTMLBase, Target, target, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLHtmlElement, Version, version, eSetAttrNotify_None) NS_IMETHODIMP -nsHTMLBase::StringToAttribute(nsIAtom* aAttribute, +nsHTMLHtmlElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -136,7 +133,7 @@ nsHTMLBase::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLBase::AttributeToString(nsIAtom* aAttribute, +nsHTMLHtmlElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -144,14 +141,14 @@ nsHTMLBase::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLBase::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLHtmlElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { return NS_OK; } NS_IMETHODIMP -nsHTMLBase::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLHtmlElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/layout/html/content/src/nsHTMLInputElement.cpp b/mozilla/layout/html/content/src/nsHTMLInputElement.cpp new file mode 100644 index 00000000000..bfbdcebec5e --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLInputElement.cpp @@ -0,0 +1,257 @@ +/* -*- 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 "nsIDOMHTMLInputElement.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" + +// XXX align=left, hspace, vspace, border? other nav4 attrs + +static NS_DEFINE_IID(kIDOMHTMLInputElementIID, NS_IDOMHTMLINPUTELEMENT_IID); + +class nsHTMLInputElement : public nsIDOMHTMLInputElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLInputElement(nsIAtom* aTag); + ~nsHTMLInputElement(); + + // 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) + + // nsIDOMHTMLInputElement + NS_IMETHOD GetDefaultValue(nsString& aDefaultValue); + NS_IMETHOD SetDefaultValue(const nsString& aDefaultValue); + NS_IMETHOD GetDefaultChecked(PRBool* aDefaultChecked); + NS_IMETHOD SetDefaultChecked(PRBool aDefaultChecked); + NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm); + NS_IMETHOD GetAccept(nsString& aAccept); + NS_IMETHOD SetAccept(const nsString& aAccept); + NS_IMETHOD GetAccessKey(nsString& aAccessKey); + NS_IMETHOD SetAccessKey(const nsString& aAccessKey); + NS_IMETHOD GetAlign(nsString& aAlign); + NS_IMETHOD SetAlign(const nsString& aAlign); + NS_IMETHOD GetAlt(nsString& aAlt); + NS_IMETHOD SetAlt(const nsString& aAlt); + NS_IMETHOD GetChecked(PRBool* aChecked); + NS_IMETHOD SetChecked(PRBool aChecked); + NS_IMETHOD GetDisabled(PRBool* aDisabled); + NS_IMETHOD SetDisabled(PRBool aDisabled); + NS_IMETHOD GetMaxLength(PRInt32* aMaxLength); + NS_IMETHOD SetMaxLength(PRInt32 aMaxLength); + NS_IMETHOD GetName(nsString& aName); + NS_IMETHOD SetName(const nsString& aName); + NS_IMETHOD GetReadOnly(PRBool* aReadOnly); + NS_IMETHOD SetReadOnly(PRBool aReadOnly); + NS_IMETHOD GetSize(nsString& aSize); + NS_IMETHOD SetSize(const nsString& aSize); + NS_IMETHOD GetSrc(nsString& aSrc); + NS_IMETHOD SetSrc(const nsString& aSrc); + NS_IMETHOD GetTabIndex(PRInt32* aTabIndex); + NS_IMETHOD SetTabIndex(PRInt32 aTabIndex); + NS_IMETHOD GetType(nsString& aType); + NS_IMETHOD GetUseMap(nsString& aUseMap); + NS_IMETHOD SetUseMap(const nsString& aUseMap); + NS_IMETHOD GetValue(nsString& aValue); + NS_IMETHOD SetValue(const nsString& aValue); + NS_IMETHOD Blur(); + NS_IMETHOD Focus(); + NS_IMETHOD Select(); + NS_IMETHOD Click(); + + // 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_NewHTMLInputElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLInputElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLInputElement::nsHTMLInputElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLInputElement::~nsHTMLInputElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLInputElement) + +NS_IMPL_RELEASE(nsHTMLInputElement) + +nsresult +nsHTMLInputElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLInputElementIID)) { + nsIDOMHTMLInputElement* tmp = this; + *aInstancePtr = (void*) tmp; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLInputElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLInputElement* it = new nsHTMLInputElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMETHODIMP +nsHTMLInputElement::GetForm(nsIDOMHTMLFormElement** aForm) +{ + *aForm = nsnull;/* XXX */ + return NS_OK; +} + +NS_IMPL_STRING_ATTR(nsHTMLInputElement, DefaultValue, defaultvalue, eSetAttrNotify_None) +NS_IMPL_BOOL_ATTR(nsHTMLInputElement, DefaultChecked, defaultchecked, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLInputElement, Accept, accept, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLInputElement, AccessKey, accesskey, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLInputElement, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLInputElement, Alt, alt, eSetAttrNotify_None) +NS_IMPL_BOOL_ATTR(nsHTMLInputElement, Checked, checked, eSetAttrNotify_Render) +NS_IMPL_BOOL_ATTR(nsHTMLInputElement, Disabled, disabled, eSetAttrNotify_Render) +NS_IMPL_INT_ATTR(nsHTMLInputElement, MaxLength, maxlength, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLInputElement, Name, name, eSetAttrNotify_Restart) +NS_IMPL_BOOL_ATTR(nsHTMLInputElement, ReadOnly, readonly, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLInputElement, Size, size, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLInputElement, Src, src, eSetAttrNotify_Render) +NS_IMPL_INT_ATTR(nsHTMLInputElement, TabIndex, tabindex, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLInputElement, UseMap, usemap, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLInputElement, Value, value, eSetAttrNotify_Render) + +NS_IMETHODIMP +nsHTMLInputElement::GetType(nsString& aValue) +{ + mInner.GetAttribute(nsHTMLAtoms::type, aValue); + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLInputElement::Blur() +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLInputElement::Focus() +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLInputElement::Select() +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLInputElement::Click() +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLInputElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX align + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLInputElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX align + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLInputElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX align + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLInputElement::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/nsHTMLInsElement.cpp b/mozilla/layout/html/content/src/nsHTMLInsElement.cpp new file mode 100644 index 00000000000..bdd8b1fb01a --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLInsElement.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 "nsIDOMHTMLInsElement.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(kIDOMHTMLInsElementIID, NS_IDOMHTMLINSELEMENT_IID); + +class nsHTMLInsElement : public nsIDOMHTMLInsElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLInsElement(nsIAtom* aTag); + ~nsHTMLInsElement(); + + // 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) + + // nsIDOMHTMLInsElement + NS_IMETHOD GetCite(nsString& aCite); + NS_IMETHOD SetCite(const nsString& aCite); + NS_IMETHOD GetDateTime(nsString& aDateTime); + NS_IMETHOD SetDateTime(const nsString& aDateTime); + + // 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_NewHTMLInsElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLInsElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLInsElement::nsHTMLInsElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLInsElement::~nsHTMLInsElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLInsElement) + +NS_IMPL_RELEASE(nsHTMLInsElement) + +nsresult +nsHTMLInsElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLInsElementIID)) { + nsIDOMHTMLInsElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLInsElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLInsElement* it = new nsHTMLInsElement(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(nsHTMLInsElement, Cite, cite, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLInsElement, DateTime, datetime, eSetAttrNotify_None) + +NS_IMETHODIMP +nsHTMLInsElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLInsElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLInsElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLInsElement::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/nsHTMLLIElement.cpp b/mozilla/layout/html/content/src/nsHTMLLIElement.cpp new file mode 100644 index 00000000000..80e2d2ebabd --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLLIElement.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 "nsIDOMHTMLLIElement.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(kIDOMHTMLLIElementIID, NS_IDOMHTMLLIELEMENT_IID); + +class nsHTMLLIElement : public nsIDOMHTMLLIElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLLIElement(nsIAtom* aTag); + ~nsHTMLLIElement(); + + // 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) + + // nsIDOMHTMLLIElement + NS_IMETHOD GetType(nsString& aType); + NS_IMETHOD SetType(const nsString& aType); + NS_IMETHOD GetValue(PRInt32* aValue); + NS_IMETHOD SetValue(PRInt32 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_NewHTMLLIElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLLIElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLLIElement::nsHTMLLIElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLLIElement::~nsHTMLLIElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLLIElement) + +NS_IMPL_RELEASE(nsHTMLLIElement) + +nsresult +nsHTMLLIElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLLIElementIID)) { + nsIDOMHTMLLIElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLLIElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLLIElement* it = new nsHTMLLIElement(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(nsHTMLLIElement, Type, type, eSetAttrNotify_Reflow) +NS_IMPL_INT_ATTR(nsHTMLLIElement, Value, value, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLLIElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLLIElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLLIElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLLIElement::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/nsHTMLLayer.cpp b/mozilla/layout/html/content/src/nsHTMLLayerElement.cpp similarity index 52% rename from mozilla/layout/html/content/src/nsHTMLLayer.cpp rename to mozilla/layout/html/content/src/nsHTMLLayerElement.cpp index d06649a327d..642809f348f 100644 --- a/mozilla/layout/html/content/src/nsHTMLLayer.cpp +++ b/mozilla/layout/html/content/src/nsHTMLLayerElement.cpp @@ -1,74 +1,143 @@ /* -*- 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 "NPL"); you may not use this file except in - * compliance with the NPL. You may obtain a copy of the NPL at + * 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 NPL is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL - * for the specific language governing rights and limitations under the - * 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 Initial Developer of this code under the NPL is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. + * 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 "nsHTMLParts.h" -#include "nsHTMLContainer.h" -#include "nsHTMLIIDs.h" +#include "nsIDOMHTMLElement.h" +#include "nsIScriptObjectOwner.h" +#include "nsIDOMEventReceiver.h" +#include "nsIHTMLContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" -#include "nsIStyleRule.h" +#include "nsHTMLIIDs.h" #include "nsIStyleContext.h" #include "nsStyleConsts.h" -#include "nsBodyFrame.h" #include "nsIPresContext.h" -#include -#if !defined(_I32_MIN) -#define _I32_MIN (-2147483647 - 1) -#endif +static NS_DEFINE_IID(kIDOMHTMLLayerElementIID, NS_IDOMHTMLELEMENT_IID); -static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID); - -class LayerPart : public nsHTMLContainer { +class nsHTMLLayerElement : public nsIDOMHTMLElement,/* XXX need layer api */ + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ public: - LayerPart(nsIAtom* aTag); + nsHTMLLayerElement(nsIAtom* aTag); + ~nsHTMLLayerElement(); - NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); + // nsISupports + NS_DECL_ISUPPORTS - NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aString, - PRBool aNotify); + // nsIDOMNode + NS_IMPL_IDOMNODE_USING_GENERIC(mInner) - NS_IMETHOD MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext); + // nsIDOMElement + NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner) - NS_IMETHOD AttributeToString(nsIAtom* aAttribute, - nsHTMLValue& aValue, - nsString& aResult) const; + // nsIDOMHTMLElement + NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner) + + // nsIDOMHTMLLayerElement + NS_IMETHOD GetCite(nsString& aCite); + NS_IMETHOD SetCite(const nsString& aCite); + + // 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_NewHTMLLayerElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLLayerElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} -LayerPart::LayerPart(nsIAtom* aTag) - : nsHTMLContainer(aTag) +nsHTMLLayerElement::nsHTMLLayerElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLLayerElement::~nsHTMLLayerElement() { } -static nsHTMLTagContent::EnumTable kVisibilityTable[] = { +NS_IMPL_ADDREF(nsHTMLLayerElement) + +NS_IMPL_RELEASE(nsHTMLLayerElement) + +nsresult +nsHTMLLayerElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) +#if XXX + if (aIID.Equals(kIDOMHTMLLayerElementIID)) { + nsIDOMHTMLLayerElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } +#endif + return NS_NOINTERFACE; +} + +nsresult +nsHTMLLayerElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLLayerElement* it = new nsHTMLLayerElement(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(nsHTMLLayerElement, Cite, cite, eSetAttrNotify_None) + +static nsHTMLGenericContent::EnumTable kVisibilityTable[] = { {"hide", NS_STYLE_VISIBILITY_HIDDEN}, {"visible", NS_STYLE_VISIBILITY_VISIBLE}, {0} }; NS_IMETHODIMP -LayerPart::SetAttribute(nsIAtom* aAttribute, const nsString& aString, - PRBool aNotify) +nsHTMLLayerElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) { +#if 0 // XXX CLIP nsHTMLValue val; if (aAttribute == nsHTMLAtoms::src) { @@ -114,15 +183,31 @@ LayerPart::SetAttribute(nsIAtom* aAttribute, const nsString& aString, } // ABOVE, BELOW, OnMouseOver, OnMouseOut, OnFocus, OnBlur, OnLoad - return nsHTMLTagContent::SetAttribute(aAttribute, aString, aNotify); +#endif + return NS_CONTENT_ATTR_NOT_THERE; } NS_IMETHODIMP -LayerPart::MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext) +nsHTMLLayerElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + if (aAttribute == nsHTMLAtoms::visibility) { + if (eHTMLUnit_Enumerated == aValue.GetUnit()) { + nsHTMLGenericContent::EnumValueToString(aValue, kVisibilityTable, aResult); + return NS_CONTENT_ATTR_HAS_VALUE; + } + } + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLLayerElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) { // Note: ua.css specifies that the 'position' is absolute - if (nsnull != mAttributes) { + if (nsnull != mInner.mAttributes) { nsHTMLValue value; float p2t = aPresContext->GetPixelsToTwips(); nsStylePosition* position = (nsStylePosition*) @@ -178,65 +263,18 @@ LayerPart::MapAttributesInto(nsIStyleContext* aContext, } // Background and bgcolor - MapBackgroundAttributesInto(aContext, aPresContext); +//XXX MapBackgroundAttributesInto(aContext, aPresContext); } return NS_OK; } NS_IMETHODIMP -LayerPart::AttributeToString(nsIAtom* aAttribute, - nsHTMLValue& aValue, - nsString& aResult) const +nsHTMLLayerElement::HandleDOMEvent(nsIPresContext& aPresContext, + nsEvent* aEvent, + nsIDOMEvent** aDOMEvent, + PRUint32 aFlags, + nsEventStatus& aEventStatus) { - if (aAttribute == nsHTMLAtoms::visibility) { - if (eHTMLUnit_Enumerated == aValue.GetUnit()) { - EnumValueToString(aValue, kVisibilityTable, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; - } - } - return NS_CONTENT_ATTR_NOT_THERE; -} - -NS_IMETHODIMP -LayerPart::CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult) -{ - nsIFrame* frame = nsnull; - nsresult rv; - - // The type of frame depends on whether there is a SRC attribute - nsAutoString url; -#if 0 - if (GetAttribute("SRC", url) == eContentAttr_HasValue) { - rv = new nsHTMLFrameOuterFrame(this, aParentFrame); - } - else { - rv = nsBodyFrame::NewFrame(&frame, this, aParentFrame); - } -#else - rv = nsBodyFrame::NewFrame(&frame, this, aParentFrame); -#endif - if (NS_OK != rv) { - return rv; - } - frame->SetStyleContext(aPresContext, aStyleContext); - aResult = frame; - return NS_OK; -} - -nsresult -NS_NewHTMLLayer(nsIHTMLContent** aInstancePtrResult, - nsIAtom* aTag) -{ - NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); - if (nsnull == aInstancePtrResult) { - return NS_ERROR_NULL_POINTER; - } - nsIHTMLContent* body = new LayerPart(aTag); - if (nsnull == body) { - return NS_ERROR_OUT_OF_MEMORY; - } - return body->QueryInterface(kIHTMLContentIID, (void **) aInstancePtrResult); + return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent, + aFlags, aEventStatus); } diff --git a/mozilla/layout/html/content/src/nsHTMLLinkElement.cpp b/mozilla/layout/html/content/src/nsHTMLLinkElement.cpp new file mode 100644 index 00000000000..3dfd93f064e --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLLinkElement.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 "nsIDOMHTMLLinkElement.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(kIDOMHTMLLinkElementIID, NS_IDOMHTMLLINKELEMENT_IID); + +class nsHTMLLinkElement : public nsIDOMHTMLLinkElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLLinkElement(nsIAtom* aTag); + ~nsHTMLLinkElement(); + + // 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) + + // nsIDOMHTMLLinkElement + NS_IMETHOD GetDisabled(PRBool* aDisabled); + NS_IMETHOD SetDisabled(PRBool aDisabled); + NS_IMETHOD GetCharset(nsString& aCharset); + NS_IMETHOD SetCharset(const nsString& aCharset); + NS_IMETHOD GetHref(nsString& aHref); + NS_IMETHOD SetHref(const nsString& aHref); + NS_IMETHOD GetHreflang(nsString& aHreflang); + NS_IMETHOD SetHreflang(const nsString& aHreflang); + NS_IMETHOD GetMedia(nsString& aMedia); + NS_IMETHOD SetMedia(const nsString& aMedia); + NS_IMETHOD GetRel(nsString& aRel); + NS_IMETHOD SetRel(const nsString& aRel); + NS_IMETHOD GetRev(nsString& aRev); + NS_IMETHOD SetRev(const nsString& aRev); + NS_IMETHOD GetTarget(nsString& aTarget); + NS_IMETHOD SetTarget(const nsString& aTarget); + NS_IMETHOD GetType(nsString& aType); + NS_IMETHOD SetType(const nsString& aType); + + // 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_NewHTMLLinkElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLLinkElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLLinkElement::nsHTMLLinkElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLLinkElement::~nsHTMLLinkElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLLinkElement) + +NS_IMPL_RELEASE(nsHTMLLinkElement) + +nsresult +nsHTMLLinkElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLLinkElementIID)) { + nsIDOMHTMLLinkElement* tmp = this; + *aInstancePtr = (void*) tmp; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLLinkElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLLinkElement* it = new nsHTMLLinkElement(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(nsHTMLLinkElement, Disabled, disabled, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLLinkElement, Charset, charset, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLLinkElement, Href, href, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLLinkElement, Hreflang, hreflang, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLLinkElement, Media, media, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLLinkElement, Rel, rel, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLLinkElement, Rev, rev, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLLinkElement, Target, target, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLLinkElement, Type, type, eSetAttrNotify_Restart) + +NS_IMETHODIMP +nsHTMLLinkElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLLinkElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLLinkElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLLinkElement::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/nsHTMLMapElement.cpp b/mozilla/layout/html/content/src/nsHTMLMapElement.cpp new file mode 100644 index 00000000000..5668db1c1b0 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLMapElement.cpp @@ -0,0 +1,178 @@ +/* -*- 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 "nsIDOMHTMLMapElement.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(kIDOMHTMLMapElementIID, NS_IDOMHTMLMAPELEMENT_IID); + +class nsHTMLMapElement : public nsIDOMHTMLMapElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLMapElement(nsIAtom* aTag); + ~nsHTMLMapElement(); + + // 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) + + // nsIDOMHTMLMapElement + NS_IMETHOD GetAreas(nsIDOMHTMLCollection** aAreas); + NS_IMETHOD SetAreas(nsIDOMHTMLCollection* aAreas); + NS_IMETHOD GetName(nsString& aName); + NS_IMETHOD SetName(const nsString& aName); + + // 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_NewHTMLMapElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLMapElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLMapElement::nsHTMLMapElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLMapElement::~nsHTMLMapElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLMapElement) + +NS_IMPL_RELEASE(nsHTMLMapElement) + +nsresult +nsHTMLMapElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLMapElementIID)) { + nsIDOMHTMLMapElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLMapElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLMapElement* it = new nsHTMLMapElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMETHODIMP +nsHTMLMapElement::GetAreas(nsIDOMHTMLCollection** aAreas) +{ + *aAreas = nsnull; + return NS_ERROR_OUT_OF_MEMORY;/* XXX */ +} + +NS_IMETHODIMP +nsHTMLMapElement::SetAreas(nsIDOMHTMLCollection* aAreas) +{ + // XXX write me + return NS_OK; +} + +NS_IMPL_STRING_ATTR(nsHTMLMapElement, Name, name, eSetAttrNotify_Restart) + +NS_IMETHODIMP +nsHTMLMapElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLMapElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLMapElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLMapElement::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/nsHTMLMenuElement.cpp b/mozilla/layout/html/content/src/nsHTMLMenuElement.cpp new file mode 100644 index 00000000000..1880cb63c50 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLMenuElement.cpp @@ -0,0 +1,162 @@ +/* -*- 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 "nsIDOMHTMLMenuElement.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(kIDOMHTMLMenuElementIID, NS_IDOMHTMLMENUELEMENT_IID); + +class nsHTMLMenuElement : public nsIDOMHTMLMenuElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLMenuElement(nsIAtom* aTag); + ~nsHTMLMenuElement(); + + // 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) + + // nsIDOMHTMLMenuElement + NS_IMETHOD GetCompact(PRBool* aCompact); + NS_IMETHOD SetCompact(PRBool aCompact); + + // 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_NewHTMLMenuElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLMenuElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLMenuElement::nsHTMLMenuElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLMenuElement::~nsHTMLMenuElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLMenuElement) + +NS_IMPL_RELEASE(nsHTMLMenuElement) + +nsresult +nsHTMLMenuElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLMenuElementIID)) { + nsIDOMHTMLMenuElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLMenuElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLMenuElement* it = new nsHTMLMenuElement(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(nsHTMLMenuElement, Compact, compact, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLMenuElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLMenuElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLMenuElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLMenuElement::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/nsHTMLMeta.cpp b/mozilla/layout/html/content/src/nsHTMLMeta.cpp deleted file mode 100644 index 3333954d733..00000000000 --- a/mozilla/layout/html/content/src/nsHTMLMeta.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- 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 "NPL"); you may not use this file except in - * compliance with the NPL. You may obtain a copy of the NPL at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the NPL is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL - * for the specific language governing rights and limitations under the - * NPL. - * - * The Initial Developer of this code under the NPL is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. - */ -#include "nsHTMLParts.h" -#include "nsHTMLContainer.h" -#include "nsFrame.h" -#include "nsHTMLIIDs.h" - -#define nsHTMLMetaSuper nsHTMLTagContent - -class nsHTMLMeta : public nsHTMLMetaSuper { -public: - nsHTMLMeta(nsIAtom* aTag); - - NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); - -protected: - virtual ~nsHTMLMeta(); -}; - -nsHTMLMeta::nsHTMLMeta(nsIAtom* aTag) - : nsHTMLMetaSuper(aTag) -{ -} - -nsHTMLMeta::~nsHTMLMeta() -{ -} - -NS_IMETHODIMP -nsHTMLMeta::CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult) -{ - nsIFrame* frame; - nsFrame::NewFrame(&frame, this, aParentFrame); - if (nsnull == frame) { - return NS_ERROR_OUT_OF_MEMORY; - } - frame->SetStyleContext(aPresContext, aStyleContext); - aResult = frame; - return NS_OK; -} - -nsresult -NS_NewHTMLMeta(nsIHTMLContent** aInstancePtrResult, - nsIAtom* aTag) -{ - NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); - if (nsnull == aInstancePtrResult) { - return NS_ERROR_NULL_POINTER; - } - nsIHTMLContent* it = new nsHTMLMeta(aTag); - if (nsnull == it) { - return NS_ERROR_OUT_OF_MEMORY; - } - return it->QueryInterface(kIHTMLContentIID, (void **) aInstancePtrResult); -} diff --git a/mozilla/layout/html/content/src/nsHTMLMetaElement.cpp b/mozilla/layout/html/content/src/nsHTMLMetaElement.cpp new file mode 100644 index 00000000000..21c93653bdb --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLMetaElement.cpp @@ -0,0 +1,168 @@ +/* -*- 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 "nsIDOMHTMLMetaElement.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(kIDOMHTMLMetaElementIID, NS_IDOMHTMLMETAELEMENT_IID); + +class nsHTMLMetaElement : public nsIDOMHTMLMetaElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLMetaElement(nsIAtom* aTag); + ~nsHTMLMetaElement(); + + // 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) + + // nsIDOMHTMLMetaElement + NS_IMETHOD GetContent(nsString& aContent); + NS_IMETHOD SetContent(const nsString& aContent); + NS_IMETHOD GetHttpEquiv(nsString& aHttpEquiv); + NS_IMETHOD SetHttpEquiv(const nsString& aHttpEquiv); + NS_IMETHOD GetName(nsString& aName); + NS_IMETHOD SetName(const nsString& aName); + NS_IMETHOD GetScheme(nsString& aScheme); + NS_IMETHOD SetScheme(const nsString& aScheme); + + // 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_NewHTMLMetaElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLMetaElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLMetaElement::nsHTMLMetaElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLMetaElement::~nsHTMLMetaElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLMetaElement) + +NS_IMPL_RELEASE(nsHTMLMetaElement) + +nsresult +nsHTMLMetaElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLMetaElementIID)) { + nsIDOMHTMLMetaElement* tmp = this; + *aInstancePtr = (void*) tmp; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLMetaElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLMetaElement* it = new nsHTMLMetaElement(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(nsHTMLMetaElement, Content, content, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLMetaElement, HttpEquiv, httpEquiv, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLMetaElement, Name, name, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLMetaElement, Scheme, scheme, eSetAttrNotify_None) + +NS_IMETHODIMP +nsHTMLMetaElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLMetaElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLMetaElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLMetaElement::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/nsHTMLModElement.cpp b/mozilla/layout/html/content/src/nsHTMLModElement.cpp new file mode 100644 index 00000000000..31f684098ba --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLModElement.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 "nsIDOMHTMLModElement.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(kIDOMHTMLModElementIID, NS_IDOMHTMLMODELEMENT_IID); + +class nsHTMLModElement : public nsIDOMHTMLModElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLModElement(nsIAtom* aTag); + ~nsHTMLModElement(); + + // 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) + + // nsIDOMHTMLModElement + NS_IMETHOD GetCite(nsString& aCite); + NS_IMETHOD SetCite(const nsString& aCite); + NS_IMETHOD GetDateTime(nsString& aDateTime); + NS_IMETHOD SetDateTime(const nsString& aDateTime); + + // 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_NewHTMLModElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLModElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLModElement::nsHTMLModElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLModElement::~nsHTMLModElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLModElement) + +NS_IMPL_RELEASE(nsHTMLModElement) + +nsresult +nsHTMLModElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLModElementIID)) { + nsIDOMHTMLModElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLModElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLModElement* it = new nsHTMLModElement(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(nsHTMLModElement, Cite, cite, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLModElement, DateTime, datetime, eSetAttrNotify_None) + +NS_IMETHODIMP +nsHTMLModElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLModElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLModElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLModElement::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/nsHTMLOListElement.cpp b/mozilla/layout/html/content/src/nsHTMLOListElement.cpp new file mode 100644 index 00000000000..206ab62f18c --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLOListElement.cpp @@ -0,0 +1,168 @@ +/* -*- 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 "nsIDOMHTMLOListElement.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(kIDOMHTMLOListElementIID, NS_IDOMHTMLOLISTELEMENT_IID); + +class nsHTMLOListElement : public nsIDOMHTMLOListElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLOListElement(nsIAtom* aTag); + ~nsHTMLOListElement(); + + // 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) + + // nsIDOMHTMLOListElement + NS_IMETHOD GetCompact(PRBool* aCompact); + NS_IMETHOD SetCompact(PRBool aCompact); + NS_IMETHOD GetStart(PRInt32* aStart); + NS_IMETHOD SetStart(PRInt32 aStart); + NS_IMETHOD GetType(nsString& aType); + NS_IMETHOD SetType(const nsString& aType); + + // 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_NewHTMLOListElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLOListElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLOListElement::nsHTMLOListElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLOListElement::~nsHTMLOListElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLOListElement) + +NS_IMPL_RELEASE(nsHTMLOListElement) + +nsresult +nsHTMLOListElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLOListElementIID)) { + nsIDOMHTMLOListElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLOListElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLOListElement* it = new nsHTMLOListElement(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(nsHTMLOListElement, Compact, compact, eSetAttrNotify_Reflow) +NS_IMPL_INT_ATTR(nsHTMLOListElement, Start, compact, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLOListElement, Type, compact, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLOListElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLOListElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLOListElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLOListElement::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/nsHTMLObject.cpp b/mozilla/layout/html/content/src/nsHTMLObject.cpp deleted file mode 100644 index 6fd54202df7..00000000000 --- a/mozilla/layout/html/content/src/nsHTMLObject.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- 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 "nsHTMLParts.h" -#include "nsObjectContent.h" -#include "nsHTMLIIDs.h" - -#define nsHTMLObjectSuper nsObjectContent - -class nsHTMLObject : public nsHTMLObjectSuper { -public: - nsHTMLObject(nsIAtom* aTag); - -protected: - virtual ~nsHTMLObject(); -}; - -nsHTMLObject::nsHTMLObject(nsIAtom* aTag) - : nsHTMLObjectSuper(aTag) -{ -} - -nsHTMLObject::~nsHTMLObject() -{ -} - -nsresult -NS_NewHTMLObject(nsIHTMLContent** aInstancePtrResult, - nsIAtom* aTag) -{ - NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); - if (nsnull == aInstancePtrResult) { - return NS_ERROR_NULL_POINTER; - } - nsIHTMLContent* it = new nsHTMLObject(aTag); - if (nsnull == it) { - return NS_ERROR_OUT_OF_MEMORY; - } - return it->QueryInterface(kIHTMLContentIID, (void **) aInstancePtrResult); -} diff --git a/mozilla/layout/html/content/src/nsHTMLObjectElement.cpp b/mozilla/layout/html/content/src/nsHTMLObjectElement.cpp new file mode 100644 index 00000000000..8837ceed6d1 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLObjectElement.cpp @@ -0,0 +1,244 @@ +/* -*- 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 "nsIDOMHTMLObjectElement.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(kIDOMHTMLObjectElementIID, NS_IDOMHTMLOBJECTELEMENT_IID); + +class nsHTMLObjectElement : public nsIDOMHTMLObjectElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLObjectElement(nsIAtom* aTag); + ~nsHTMLObjectElement(); + + // 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) + + // nsIDOMHTMLObjectElement + NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm); + NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm); + NS_IMETHOD GetCode(nsString& aCode); + NS_IMETHOD SetCode(const nsString& aCode); + NS_IMETHOD GetAlign(nsString& aAlign); + NS_IMETHOD SetAlign(const nsString& aAlign); + NS_IMETHOD GetArchive(nsString& aArchive); + NS_IMETHOD SetArchive(const nsString& aArchive); + NS_IMETHOD GetBorder(nsString& aBorder); + NS_IMETHOD SetBorder(const nsString& aBorder); + NS_IMETHOD GetCodeBase(nsString& aCodeBase); + NS_IMETHOD SetCodeBase(const nsString& aCodeBase); + NS_IMETHOD GetCodeType(nsString& aCodeType); + NS_IMETHOD SetCodeType(const nsString& aCodeType); + NS_IMETHOD GetData(nsString& aData); + NS_IMETHOD SetData(const nsString& aData); + NS_IMETHOD GetDeclare(PRBool* aDeclare); + NS_IMETHOD SetDeclare(PRBool aDeclare); + NS_IMETHOD GetHeight(nsString& aHeight); + NS_IMETHOD SetHeight(const nsString& aHeight); + NS_IMETHOD GetHspace(nsString& aHspace); + NS_IMETHOD SetHspace(const nsString& aHspace); + NS_IMETHOD GetName(nsString& aName); + NS_IMETHOD SetName(const nsString& aName); + NS_IMETHOD GetStandby(nsString& aStandby); + NS_IMETHOD SetStandby(const nsString& aStandby); + NS_IMETHOD GetTabIndex(PRInt32* aTabIndex); + NS_IMETHOD SetTabIndex(PRInt32 aTabIndex); + NS_IMETHOD GetType(nsString& aType); + NS_IMETHOD SetType(const nsString& aType); + 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_NewHTMLObjectElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLObjectElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLObjectElement::nsHTMLObjectElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLObjectElement::~nsHTMLObjectElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLObjectElement) + +NS_IMPL_RELEASE(nsHTMLObjectElement) + +nsresult +nsHTMLObjectElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLObjectElementIID)) { + nsIDOMHTMLObjectElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLObjectElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLObjectElement* it = new nsHTMLObjectElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMETHODIMP +nsHTMLObjectElement::GetForm(nsIDOMHTMLFormElement** aForm) +{ + *aForm = nsnull;/* XXX */ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLObjectElement::SetForm(nsIDOMHTMLFormElement* aForm) +{ + return NS_OK; +} + +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Code, code, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Archive, archive, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Border, border, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, CodeBase, codebase, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, CodeType, codetype, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Data, data, eSetAttrNotify_None) +NS_IMPL_BOOL_ATTR(nsHTMLObjectElement, Declare, declare, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Height, height, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Hspace, hspace, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Name, name, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Standby, standby, eSetAttrNotify_None) +NS_IMPL_INT_ATTR(nsHTMLObjectElement, TabIndex, tabindex, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Type, type, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, UseMap, usemap, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Vspace, vspace, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Width, width, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLObjectElement::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 +nsHTMLObjectElement::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 +nsHTMLObjectElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + mInner.MapImageAlignAttributeInto(aContext, aPresContext); + mInner.MapImageAttributesInto(aContext, aPresContext); + mInner.MapImageBorderAttributesInto(aContext, aPresContext, nsnull); + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLObjectElement::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/nsHTMLOptionElement.cpp b/mozilla/layout/html/content/src/nsHTMLOptionElement.cpp new file mode 100644 index 00000000000..cab9b6a3655 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLOptionElement.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 "nsIDOMHTMLOptionElement.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(kIDOMHTMLOptionElementIID, NS_IDOMHTMLOPTIONELEMENT_IID); + +class nsHTMLOptionElement : public nsIDOMHTMLOptionElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLOptionElement(nsIAtom* aTag); + ~nsHTMLOptionElement(); + + // 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) + + // nsIDOMHTMLOptionElement + NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm); + NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm); + NS_IMETHOD GetDefaultSelected(PRBool* aDefaultSelected); + NS_IMETHOD SetDefaultSelected(PRBool aDefaultSelected); + NS_IMETHOD GetText(nsString& aText); + NS_IMETHOD SetText(const nsString& aText); + NS_IMETHOD GetIndex(PRInt32* aIndex); + NS_IMETHOD SetIndex(PRInt32 aIndex); + NS_IMETHOD GetDisabled(PRBool* aDisabled); + NS_IMETHOD SetDisabled(PRBool aDisabled); + NS_IMETHOD GetLabel(nsString& aLabel); + NS_IMETHOD SetLabel(const nsString& aLabel); + NS_IMETHOD GetSelected(PRBool* aSelected); + NS_IMETHOD SetSelected(PRBool aSelected); + 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_NewHTMLOptionElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLOptionElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLOptionElement::nsHTMLOptionElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLOptionElement::~nsHTMLOptionElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLOptionElement) + +NS_IMPL_RELEASE(nsHTMLOptionElement) + +nsresult +nsHTMLOptionElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLOptionElementIID)) { + nsIDOMHTMLOptionElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLOptionElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLOptionElement* it = new nsHTMLOptionElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMETHODIMP +nsHTMLOptionElement::GetForm(nsIDOMHTMLFormElement** aForm) +{ + *aForm = nsnull;/* XXX */ + return NS_OK; +} + +NS_IMPL_BOOL_ATTR(nsHTMLOptionElement, DefaultSelected, defaultselected, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLOptionElement, Text, text, eSetAttrNotify_Render) +NS_IMPL_INT_ATTR(nsHTMLOptionElement, Index, index, eSetAttrNotify_None) +NS_IMPL_BOOL_ATTR(nsHTMLOptionElement, Disabled, disabled, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLOptionElement, Label, label, eSetAttrNotify_Render) +NS_IMPL_BOOL_ATTR(nsHTMLOptionElement, Selected, selected, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLOptionElement, Value, value, eSetAttrNotify_Render) + +NS_IMETHODIMP +nsHTMLOptionElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLOptionElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLOptionElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLOptionElement::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/nsHTMLParagraphElement.cpp b/mozilla/layout/html/content/src/nsHTMLParagraphElement.cpp new file mode 100644 index 00000000000..fa3bffa68d9 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLParagraphElement.cpp @@ -0,0 +1,173 @@ +/* -*- 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 "nsIDOMHTMLParagraphElement.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" + +// XXX missing nav attributes + +static NS_DEFINE_IID(kIDOMHTMLParagraphElementIID, NS_IDOMHTMLPARAGRAPHELEMENT_IID); + +class nsHTMLParagraphElement : public nsIDOMHTMLParagraphElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLParagraphElement(nsIAtom* aTag); + ~nsHTMLParagraphElement(); + + // 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) + + // nsIDOMHTMLParagraphElement + 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_NewHTMLParagraphElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLParagraphElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLParagraphElement::nsHTMLParagraphElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLParagraphElement::~nsHTMLParagraphElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLParagraphElement) + +NS_IMPL_RELEASE(nsHTMLParagraphElement) + +nsresult +nsHTMLParagraphElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLParagraphElementIID)) { + nsIDOMHTMLParagraphElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLParagraphElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLParagraphElement* it = new nsHTMLParagraphElement(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(nsHTMLParagraphElement, Align, align, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLParagraphElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + if (aAttribute == nsHTMLAtoms::align) { + if (nsHTMLGenericContent::ParseAlignValue(aValue, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } + } + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLParagraphElement::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; + } + } + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLParagraphElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLParagraphElement::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/nsHTMLParamElement.cpp b/mozilla/layout/html/content/src/nsHTMLParamElement.cpp new file mode 100644 index 00000000000..1efbffa79e6 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLParamElement.cpp @@ -0,0 +1,171 @@ +/* -*- 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 "nsIDOMHTMLParamElement.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(kIDOMHTMLParamElementIID, NS_IDOMHTMLPARAMELEMENT_IID); + +class nsHTMLParamElement : public nsIDOMHTMLParamElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLParamElement(nsIAtom* aTag); + ~nsHTMLParamElement(); + + // 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) + + // nsIDOMHTMLParamElement + NS_IMETHOD GetName(nsString& aName); + NS_IMETHOD SetName(const nsString& aName); + NS_IMETHOD GetType(nsString& aType); + NS_IMETHOD SetType(const nsString& aType); + NS_IMETHOD GetValue(nsString& aValue); + NS_IMETHOD SetValue(const nsString& aValue); + NS_IMETHOD GetValueType(nsString& aValueType); + NS_IMETHOD SetValueType(const nsString& aValueType); + + // 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_NewHTMLParamElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLParamElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLParamElement::nsHTMLParamElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLParamElement::~nsHTMLParamElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLParamElement) + +NS_IMPL_RELEASE(nsHTMLParamElement) + +nsresult +nsHTMLParamElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLParamElementIID)) { + nsIDOMHTMLParamElement* tmp = this; + *aInstancePtr = (void*) tmp; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLParamElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLParamElement* it = new nsHTMLParamElement(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(nsHTMLParamElement, Name, name, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLParamElement, Type, type, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLParamElement, Value, value, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLParamElement, ValueType, valuetype, eSetAttrNotify_Restart) + +NS_IMETHODIMP +nsHTMLParamElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLParamElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLParamElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLParamElement::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/nsHTMLPreElement.cpp b/mozilla/layout/html/content/src/nsHTMLPreElement.cpp new file mode 100644 index 00000000000..507574ec6aa --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLPreElement.cpp @@ -0,0 +1,173 @@ +/* -*- 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 "nsIDOMHTMLPreElement.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" + +// XXX missing nav attributes + +static NS_DEFINE_IID(kIDOMHTMLPreElementIID, NS_IDOMHTMLPREELEMENT_IID); + +class nsHTMLPreElement : public nsIDOMHTMLPreElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLPreElement(nsIAtom* aTag); + ~nsHTMLPreElement(); + + // 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) + + // nsIDOMHTMLPreElement + NS_IMETHOD GetWidth(PRInt32* aWidth); + NS_IMETHOD SetWidth(PRInt32 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_NewHTMLPreElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLPreElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLPreElement::nsHTMLPreElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLPreElement::~nsHTMLPreElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLPreElement) + +NS_IMPL_RELEASE(nsHTMLPreElement) + +nsresult +nsHTMLPreElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLPreElementIID)) { + nsIDOMHTMLPreElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLPreElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLPreElement* it = new nsHTMLPreElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMPL_INT_ATTR(nsHTMLPreElement, Width, width, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLPreElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + if (aAttribute == nsHTMLAtoms::align) { + if (nsHTMLGenericContent::ParseAlignValue(aValue, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } + } + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLPreElement::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; + } + } + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLPreElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLPreElement::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/nsHTMLDList.cpp b/mozilla/layout/html/content/src/nsHTMLQuoteElement.cpp similarity index 72% rename from mozilla/layout/html/content/src/nsHTMLDList.cpp rename to mozilla/layout/html/content/src/nsHTMLQuoteElement.cpp index c828c8a8a82..f0b4522dd57 100644 --- a/mozilla/layout/html/content/src/nsHTMLDList.cpp +++ b/mozilla/layout/html/content/src/nsHTMLQuoteElement.cpp @@ -16,27 +16,27 @@ * Corporation. Portions created by Netscape are Copyright (C) 1998 * Netscape Communications Corporation. All Rights Reserved. */ -#include "nsIDOMHTMLDListElement.h" +#include "nsIDOMHTMLQuoteElement.h" #include "nsIScriptObjectOwner.h" #include "nsIDOMEventReceiver.h" #include "nsIHTMLContent.h" -#include "nsHTMLGenericContent.h" +#include "nsGenericHTMLElement.h" #include "nsHTMLAtoms.h" #include "nsHTMLIIDs.h" #include "nsIStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" -static NS_DEFINE_IID(kIDOMHTMLDListElementIID, NS_IDOMHTMLDLISTELEMENT_IID); +static NS_DEFINE_IID(kIDOMHTMLQuoteElementIID, NS_IDOMHTMLQUOTEELEMENT_IID); -class nsHTMLDList : public nsIDOMHTMLDListElement, +class nsHTMLQuoteElement : public nsIDOMHTMLQuoteElement, public nsIScriptObjectOwner, public nsIDOMEventReceiver, public nsIHTMLContent { public: - nsHTMLDList(nsIAtom* aTag); - ~nsHTMLDList(); + nsHTMLQuoteElement(nsIAtom* aTag); + ~nsHTMLQuoteElement(); // nsISupports NS_DECL_ISUPPORTS @@ -50,9 +50,9 @@ public: // nsIDOMHTMLElement NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner) - // nsIDOMHTMLDListElement - NS_IMETHOD GetCompact(PRBool* aCompact); - NS_IMETHOD SetCompact(PRBool aCompact); + // nsIDOMHTMLQuoteElement + NS_IMETHOD GetCite(nsString& aCite); + NS_IMETHOD SetCite(const nsString& aCite); // nsIScriptObjectOwner NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner) @@ -71,39 +71,39 @@ protected: }; nsresult -NS_NewHTMLDList(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +NS_NewHTMLQuoteElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - nsIHTMLContent* it = new nsHTMLDList(aTag); + nsIHTMLContent* it = new nsHTMLQuoteElement(aTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); } -nsHTMLDList::nsHTMLDList(nsIAtom* aTag) +nsHTMLQuoteElement::nsHTMLQuoteElement(nsIAtom* aTag) { NS_INIT_REFCNT(); mInner.Init(this, aTag); } -nsHTMLDList::~nsHTMLDList() +nsHTMLQuoteElement::~nsHTMLQuoteElement() { } -NS_IMPL_ADDREF(nsHTMLDList) +NS_IMPL_ADDREF(nsHTMLQuoteElement) -NS_IMPL_RELEASE(nsHTMLDList) +NS_IMPL_RELEASE(nsHTMLQuoteElement) nsresult -nsHTMLDList::QueryInterface(REFNSIID aIID, void** aInstancePtr) +nsHTMLQuoteElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) - if (aIID.Equals(kIDOMHTMLDListElementIID)) { - nsIDOMHTMLDListElement* tmp = this; + if (aIID.Equals(kIDOMHTMLQuoteElementIID)) { + nsIDOMHTMLQuoteElement* tmp = this; *aInstancePtr = (void*) tmp; mRefCnt++; return NS_OK; @@ -112,9 +112,9 @@ nsHTMLDList::QueryInterface(REFNSIID aIID, void** aInstancePtr) } nsresult -nsHTMLDList::CloneNode(nsIDOMNode** aReturn) +nsHTMLQuoteElement::CloneNode(nsIDOMNode** aReturn) { - nsHTMLDList* it = new nsHTMLDList(mInner.mTag); + nsHTMLQuoteElement* it = new nsHTMLQuoteElement(mInner.mTag); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } @@ -122,10 +122,10 @@ nsHTMLDList::CloneNode(nsIDOMNode** aReturn) return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); } -NS_IMPL_BOOL_ATTR(nsHTMLDList, Compact, compact, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLQuoteElement, Cite, cite, eSetAttrNotify_None) NS_IMETHODIMP -nsHTMLDList::StringToAttribute(nsIAtom* aAttribute, +nsHTMLQuoteElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { @@ -134,7 +134,7 @@ nsHTMLDList::StringToAttribute(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLDList::AttributeToString(nsIAtom* aAttribute, +nsHTMLQuoteElement::AttributeToString(nsIAtom* aAttribute, nsHTMLValue& aValue, nsString& aResult) const { @@ -143,7 +143,7 @@ nsHTMLDList::AttributeToString(nsIAtom* aAttribute, } NS_IMETHODIMP -nsHTMLDList::MapAttributesInto(nsIStyleContext* aContext, +nsHTMLQuoteElement::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { // XXX write me @@ -151,7 +151,7 @@ nsHTMLDList::MapAttributesInto(nsIStyleContext* aContext, } NS_IMETHODIMP -nsHTMLDList::HandleDOMEvent(nsIPresContext& aPresContext, +nsHTMLQuoteElement::HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, diff --git a/mozilla/layout/html/content/src/nsHTMLScriptElement.cpp b/mozilla/layout/html/content/src/nsHTMLScriptElement.cpp new file mode 100644 index 00000000000..504436522b0 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLScriptElement.cpp @@ -0,0 +1,223 @@ +/* -*- 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 "nsIDOMHTMLScriptElement.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(kIDOMHTMLScriptElementIID, NS_IDOMHTMLSCRIPTELEMENT_IID); + +class nsHTMLScriptElement : public nsIDOMHTMLScriptElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLScriptElement(nsIAtom* aTag); + ~nsHTMLScriptElement(); + + // 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) + + // nsIDOMHTMLScriptElement + NS_IMETHOD GetText(nsString& aText); + NS_IMETHOD SetText(const nsString& aText); + NS_IMETHOD GetHtmlFor(nsString& aHtmlFor); + NS_IMETHOD SetHtmlFor(const nsString& aHtmlFor); + NS_IMETHOD GetEvent(nsString& aEvent); + NS_IMETHOD SetEvent(const nsString& aEvent); + NS_IMETHOD GetCharset(nsString& aCharset); + NS_IMETHOD SetCharset(const nsString& aCharset); + NS_IMETHOD GetDefer(PRBool* aDefer); + NS_IMETHOD SetDefer(PRBool aDefer); + NS_IMETHOD GetSrc(nsString& aSrc); + NS_IMETHOD SetSrc(const nsString& aSrc); + NS_IMETHOD GetType(nsString& aType); + NS_IMETHOD SetType(const nsString& aType); + + // 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; + nsString mText; +}; + +nsresult +NS_NewHTMLScriptElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLScriptElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLScriptElement::nsHTMLScriptElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLScriptElement::~nsHTMLScriptElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLScriptElement) + +NS_IMPL_RELEASE(nsHTMLScriptElement) + +nsresult +nsHTMLScriptElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLScriptElementIID)) { + nsIDOMHTMLScriptElement* tmp = this; + *aInstancePtr = (void*) tmp; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLScriptElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLScriptElement* it = new nsHTMLScriptElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMETHODIMP +nsHTMLScriptElement::GetText(nsString& aValue) +{ + // XXX out of memory errors + aValue = mText; + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLScriptElement::SetText(const nsString& aValue) +{ + // XXX out of memory errors + mText = aValue; + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLScriptElement::GetHtmlFor(nsString& aValue) +{ + // XXX write me +// mInner.GetAttribute(nsHTMLAtoms::charset, aValue); + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLScriptElement::SetHtmlFor(const nsString& aValue) +{ + // XXX write me +// return mInner.SetAttr(nsHTMLAtoms::charset, aValue, eSetAttrNotify_None); + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLScriptElement::GetEvent(nsString& aValue) +{ + // XXX write me +// mInner.GetAttribute(nsHTMLAtoms::charset, aValue); + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLScriptElement::SetEvent(const nsString& aValue) +{ + // XXX write me +// return mInner.SetAttr(nsHTMLAtoms::charset, aValue, eSetAttrNotify_None); + return NS_OK; +} + +NS_IMPL_STRING_ATTR(nsHTMLScriptElement, Charset, charset, eSetAttrNotify_None) +NS_IMPL_BOOL_ATTR(nsHTMLScriptElement, Defer, defer, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLScriptElement, Src, src, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLScriptElement, Type, type, eSetAttrNotify_Restart) + +NS_IMETHODIMP +nsHTMLScriptElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLScriptElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLScriptElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLScriptElement::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/nsHTMLSelectElement.cpp b/mozilla/layout/html/content/src/nsHTMLSelectElement.cpp new file mode 100644 index 00000000000..b5c4e777b41 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLSelectElement.cpp @@ -0,0 +1,234 @@ +/* -*- 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 "nsIDOMHTMLSelectElement.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(kIDOMHTMLSelectElementIID, NS_IDOMHTMLSELECTELEMENT_IID); + +class nsHTMLSelectElement : public nsIDOMHTMLSelectElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLSelectElement(nsIAtom* aTag); + ~nsHTMLSelectElement(); + + // 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) + + // nsIDOMHTMLSelectElement + NS_IMETHOD GetType(nsString& aType); + NS_IMETHOD SetType(const nsString& aType); + NS_IMETHOD GetSelectedIndex(PRInt32* aSelectedIndex); + NS_IMETHOD SetSelectedIndex(PRInt32 aSelectedIndex); + NS_IMETHOD GetValue(nsString& aValue); + NS_IMETHOD SetValue(const nsString& aValue); + NS_IMETHOD GetLength(PRInt32* aLength); + NS_IMETHOD SetLength(PRInt32 aLength); + NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm); + NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm); + NS_IMETHOD GetOptions(nsIDOMHTMLCollection** aOptions); + NS_IMETHOD SetOptions(nsIDOMHTMLCollection* aOptions); + NS_IMETHOD GetDisabled(PRBool* aDisabled); + NS_IMETHOD SetDisabled(PRBool aDisabled); + NS_IMETHOD GetMultiple(PRBool* aMultiple); + NS_IMETHOD SetMultiple(PRBool aMultiple); + NS_IMETHOD GetName(nsString& aName); + NS_IMETHOD SetName(const nsString& aName); + NS_IMETHOD GetSize(PRInt32* aSize); + NS_IMETHOD SetSize(PRInt32 aSize); + NS_IMETHOD GetTabIndex(PRInt32* aTabIndex); + NS_IMETHOD SetTabIndex(PRInt32 aTabIndex); + NS_IMETHOD Add(nsIDOMHTMLElement* aElement, nsIDOMHTMLElement* aBefore); + NS_IMETHOD Remove(PRInt32 aIndex); + NS_IMETHOD Blur(); + NS_IMETHOD Focus(); + + // 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_NewHTMLSelectElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLSelectElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLSelectElement::nsHTMLSelectElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLSelectElement::~nsHTMLSelectElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLSelectElement) + +NS_IMPL_RELEASE(nsHTMLSelectElement) + +nsresult +nsHTMLSelectElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLSelectElementIID)) { + nsIDOMHTMLSelectElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLSelectElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLSelectElement* it = new nsHTMLSelectElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMETHODIMP +nsHTMLSelectElement::GetForm(nsIDOMHTMLFormElement** aForm) +{ + *aForm = nsnull;/* XXX */ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLSelectElement::SetForm(nsIDOMHTMLFormElement* aForm) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLSelectElement::GetOptions(nsIDOMHTMLCollection** aValue) +{ + *aValue = nsnull;/* XXX */ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLSelectElement::SetOptions(nsIDOMHTMLCollection* aValue) +{ + return NS_OK; +} + +NS_IMPL_STRING_ATTR(nsHTMLSelectElement, Type, type, eSetAttrNotify_Restart) +NS_IMPL_INT_ATTR(nsHTMLSelectElement, SelectedIndex, selectedindex, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLSelectElement, Value, value, eSetAttrNotify_Render) +NS_IMPL_INT_ATTR(nsHTMLSelectElement, Length, length, eSetAttrNotify_Restart) +NS_IMPL_BOOL_ATTR(nsHTMLSelectElement, Disabled, disabled, eSetAttrNotify_Render) +NS_IMPL_INT_ATTR(nsHTMLSelectElement, Multiple, multiple, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLSelectElement, Name, name, eSetAttrNotify_Restart) +NS_IMPL_INT_ATTR(nsHTMLSelectElement, Size, size, eSetAttrNotify_Render) +NS_IMPL_INT_ATTR(nsHTMLSelectElement, TabIndex, tabindex, eSetAttrNotify_Render) + +NS_IMETHODIMP +nsHTMLSelectElement::Blur() +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLSelectElement::Focus() +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLSelectElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLSelectElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLSelectElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLSelectElement::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/nsHTMLStyleElement.cpp b/mozilla/layout/html/content/src/nsHTMLStyleElement.cpp new file mode 100644 index 00000000000..db961cf8f80 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLStyleElement.cpp @@ -0,0 +1,167 @@ +/* -*- 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 "nsIDOMHTMLStyleElement.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" + +// XXX no SRC attribute + +static NS_DEFINE_IID(kIDOMHTMLStyleElementIID, NS_IDOMHTMLSTYLEELEMENT_IID); + +class nsHTMLStyleElement : public nsIDOMHTMLStyleElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLStyleElement(nsIAtom* aTag); + ~nsHTMLStyleElement(); + + // 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) + + // nsIDOMHTMLStyleElement + NS_IMETHOD GetDisabled(PRBool* aDisabled); + NS_IMETHOD SetDisabled(PRBool aDisabled); + NS_IMETHOD GetMedia(nsString& aMedia); + NS_IMETHOD SetMedia(const nsString& aMedia); + NS_IMETHOD GetType(nsString& aType); + NS_IMETHOD SetType(const nsString& aType); + + // 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_NewHTMLStyleElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLStyleElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLStyleElement::nsHTMLStyleElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLStyleElement::~nsHTMLStyleElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLStyleElement) + +NS_IMPL_RELEASE(nsHTMLStyleElement) + +nsresult +nsHTMLStyleElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLStyleElementIID)) { + nsIDOMHTMLStyleElement* tmp = this; + *aInstancePtr = (void*) tmp; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLStyleElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLStyleElement* it = new nsHTMLStyleElement(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(nsHTMLStyleElement, Disabled, disabled, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLStyleElement, Media, media, eSetAttrNotify_Restart) +NS_IMPL_STRING_ATTR(nsHTMLStyleElement, Type, type, eSetAttrNotify_Restart) + +NS_IMETHODIMP +nsHTMLStyleElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLStyleElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLStyleElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLStyleElement::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/nsHTMLTableCaptionElement.cpp b/mozilla/layout/html/content/src/nsHTMLTableCaptionElement.cpp new file mode 100644 index 00000000000..35178ad56d9 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLTableCaptionElement.cpp @@ -0,0 +1,162 @@ +/* -*- 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 "nsIDOMHTMLTableCaptionElement.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(kIDOMHTMLTableCaptionElementIID, NS_IDOMHTMLTABLECAPTIONELEMENT_IID); + +class nsHTMLTableCaptionElement : public nsIDOMHTMLTableCaptionElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLTableCaptionElement(nsIAtom* aTag); + ~nsHTMLTableCaptionElement(); + + // 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) + + // nsIDOMHTMLTableCaptionElement + 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_NewHTMLTableCaptionElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLTableCaptionElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLTableCaptionElement::nsHTMLTableCaptionElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLTableCaptionElement::~nsHTMLTableCaptionElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLTableCaptionElement) + +NS_IMPL_RELEASE(nsHTMLTableCaptionElement) + +nsresult +nsHTMLTableCaptionElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLTableCaptionElementIID)) { + nsIDOMHTMLTableCaptionElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLTableCaptionElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLTableCaptionElement* it = new nsHTMLTableCaptionElement(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(nsHTMLTableCaptionElement, Align, align, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLTableCaptionElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLTableCaptionElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLTableCaptionElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTableCaptionElement::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/nsHTMLTableCellElement.cpp b/mozilla/layout/html/content/src/nsHTMLTableCellElement.cpp new file mode 100644 index 00000000000..29cb75d57de --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLTableCellElement.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 "nsIDOMHTMLTableCellElement.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(kIDOMHTMLTableCellElementIID, NS_IDOMHTMLTABLECELLELEMENT_IID); + +class nsHTMLTableCellElement : public nsIDOMHTMLTableCellElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLTableCellElement(nsIAtom* aTag); + ~nsHTMLTableCellElement(); + + // 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) + + // nsIDOMHTMLTableCellElement + NS_IMETHOD GetCellIndex(PRInt32* aCellIndex); + NS_IMETHOD SetCellIndex(PRInt32 aCellIndex); + NS_IMETHOD GetAbbr(nsString& aAbbr); + NS_IMETHOD SetAbbr(const nsString& aAbbr); + NS_IMETHOD GetAlign(nsString& aAlign); + NS_IMETHOD SetAlign(const nsString& aAlign); + NS_IMETHOD GetAxis(nsString& aAxis); + NS_IMETHOD SetAxis(const nsString& aAxis); + NS_IMETHOD GetBgColor(nsString& aBgColor); + NS_IMETHOD SetBgColor(const nsString& aBgColor); + NS_IMETHOD GetCh(nsString& aCh); + NS_IMETHOD SetCh(const nsString& aCh); + NS_IMETHOD GetChOff(nsString& aChOff); + NS_IMETHOD SetChOff(const nsString& aChOff); + NS_IMETHOD GetColSpan(PRInt32* aColSpan); + NS_IMETHOD SetColSpan(PRInt32 aColSpan); + NS_IMETHOD GetHeaders(nsString& aHeaders); + NS_IMETHOD SetHeaders(const nsString& aHeaders); + NS_IMETHOD GetHeight(nsString& aHeight); + NS_IMETHOD SetHeight(const nsString& aHeight); + NS_IMETHOD GetNoWrap(PRBool* aNoWrap); + NS_IMETHOD SetNoWrap(PRBool aNoWrap); + NS_IMETHOD GetRowSpan(PRInt32* aRowSpan); + NS_IMETHOD SetRowSpan(PRInt32 aRowSpan); + NS_IMETHOD GetScope(nsString& aScope); + NS_IMETHOD SetScope(const nsString& aScope); + NS_IMETHOD GetVAlign(nsString& aVAlign); + NS_IMETHOD SetVAlign(const nsString& aVAlign); + 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_NewHTMLTableCellElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLTableCellElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLTableCellElement::nsHTMLTableCellElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLTableCellElement::~nsHTMLTableCellElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLTableCellElement) + +NS_IMPL_RELEASE(nsHTMLTableCellElement) + +nsresult +nsHTMLTableCellElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLTableCellElementIID)) { + nsIDOMHTMLTableCellElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLTableCellElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLTableCellElement* it = new nsHTMLTableCellElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMETHODIMP +nsHTMLTableCellElement::GetCellIndex(PRInt32* aCellIndex) +{ + *aCellIndex = 0;/* XXX */ + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTableCellElement::SetCellIndex(PRInt32 aCellIndex) +{ + // XXX write me + return NS_OK; +} + +NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Abbr, abbr, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Axis, axis, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, BgColor, bgcolor, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Ch, ch, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, ChOff, choff, eSetAttrNotify_Reflow) +NS_IMPL_INT_ATTR(nsHTMLTableCellElement, ColSpan, colspan, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Headers, headers, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Height, height, eSetAttrNotify_Reflow) +NS_IMPL_BOOL_ATTR(nsHTMLTableCellElement, NoWrap, nowrap, eSetAttrNotify_Reflow) +NS_IMPL_INT_ATTR(nsHTMLTableCellElement, RowSpan, rowspan, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Scope, scope, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, VAlign, valign, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Width, width, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLTableCellElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLTableCellElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLTableCellElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTableCellElement::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/nsHTMLTableColElement.cpp b/mozilla/layout/html/content/src/nsHTMLTableColElement.cpp new file mode 100644 index 00000000000..7dc7a63480c --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLTableColElement.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 "nsIDOMHTMLTableColElement.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(kIDOMHTMLTableColElementIID, NS_IDOMHTMLTABLECOLELEMENT_IID); + +class nsHTMLTableColElement : public nsIDOMHTMLTableColElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLTableColElement(nsIAtom* aTag); + ~nsHTMLTableColElement(); + + // 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) + + // nsIDOMHTMLTableColElement + NS_IMETHOD GetAlign(nsString& aAlign); + NS_IMETHOD SetAlign(const nsString& aAlign); + NS_IMETHOD GetCh(nsString& aCh); + NS_IMETHOD SetCh(const nsString& aCh); + NS_IMETHOD GetChOff(nsString& aChOff); + NS_IMETHOD SetChOff(const nsString& aChOff); + NS_IMETHOD GetSpan(PRInt32* aSpan); + NS_IMETHOD SetSpan(PRInt32 aSpan); + NS_IMETHOD GetVAlign(nsString& aVAlign); + NS_IMETHOD SetVAlign(const nsString& aVAlign); + 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_NewHTMLTableColElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLTableColElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLTableColElement::nsHTMLTableColElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLTableColElement::~nsHTMLTableColElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLTableColElement) + +NS_IMPL_RELEASE(nsHTMLTableColElement) + +nsresult +nsHTMLTableColElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLTableColElementIID)) { + nsIDOMHTMLTableColElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLTableColElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLTableColElement* it = new nsHTMLTableColElement(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(nsHTMLTableColElement, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableColElement, Ch, ch, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableColElement, ChOff, choff, eSetAttrNotify_Reflow) +NS_IMPL_INT_ATTR(nsHTMLTableColElement, Span, span, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableColElement, VAlign, valign, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableColElement, Width, width, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLTableColElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLTableColElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLTableColElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTableColElement::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/nsHTMLTableElement.cpp b/mozilla/layout/html/content/src/nsHTMLTableElement.cpp new file mode 100644 index 00000000000..be711b1cfb0 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLTableElement.cpp @@ -0,0 +1,321 @@ +/* -*- 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 "nsIDOMHTMLTableElement.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(kIDOMHTMLTableElementIID, NS_IDOMHTMLTABLEELEMENT_IID); + +class nsHTMLTableElement : public nsIDOMHTMLTableElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLTableElement(nsIAtom* aTag); + ~nsHTMLTableElement(); + + // 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) + + // nsIDOMHTMLTableElement + NS_IMETHOD GetCaption(nsIDOMHTMLTableCaptionElement** aCaption); + NS_IMETHOD SetCaption(nsIDOMHTMLTableCaptionElement* aCaption); + NS_IMETHOD GetTHead(nsIDOMHTMLTableSectionElement** aTHead); + NS_IMETHOD SetTHead(nsIDOMHTMLTableSectionElement* aTHead); + NS_IMETHOD GetTFoot(nsIDOMHTMLTableSectionElement** aTFoot); + NS_IMETHOD SetTFoot(nsIDOMHTMLTableSectionElement* aTFoot); + NS_IMETHOD GetRows(nsIDOMHTMLCollection** aRows); + NS_IMETHOD SetRows(nsIDOMHTMLCollection* aRows); + NS_IMETHOD GetTBodies(nsIDOMHTMLCollection** aTBodies); + NS_IMETHOD SetTBodies(nsIDOMHTMLCollection* aTBodies); + NS_IMETHOD GetAlign(nsString& aAlign); + NS_IMETHOD SetAlign(const nsString& aAlign); + NS_IMETHOD GetBgColor(nsString& aBgColor); + NS_IMETHOD SetBgColor(const nsString& aBgColor); + NS_IMETHOD GetBorder(nsString& aBorder); + NS_IMETHOD SetBorder(const nsString& aBorder); + NS_IMETHOD GetCellPadding(nsString& aCellPadding); + NS_IMETHOD SetCellPadding(const nsString& aCellPadding); + NS_IMETHOD GetCellSpacing(nsString& aCellSpacing); + NS_IMETHOD SetCellSpacing(const nsString& aCellSpacing); + NS_IMETHOD GetFrame(nsString& aFrame); + NS_IMETHOD SetFrame(const nsString& aFrame); + NS_IMETHOD GetRules(nsString& aRules); + NS_IMETHOD SetRules(const nsString& aRules); + NS_IMETHOD GetSummary(nsString& aSummary); + NS_IMETHOD SetSummary(const nsString& aSummary); + NS_IMETHOD GetWidth(nsString& aWidth); + NS_IMETHOD SetWidth(const nsString& aWidth); + NS_IMETHOD CreateTHead(nsIDOMHTMLElement** aReturn); + NS_IMETHOD DeleteTHead(); + NS_IMETHOD CreateTFoot(nsIDOMHTMLElement** aReturn); + NS_IMETHOD DeleteTFoot(); + NS_IMETHOD CreateCaption(nsIDOMHTMLElement** aReturn); + NS_IMETHOD DeleteCaption(); + NS_IMETHOD InsertRow(PRInt32 aIndex, nsIDOMHTMLElement** aReturn); + NS_IMETHOD DeleteRow(PRInt32 aIndex); + + // 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_NewHTMLTableElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLTableElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLTableElement::nsHTMLTableElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLTableElement::~nsHTMLTableElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLTableElement) + +NS_IMPL_RELEASE(nsHTMLTableElement) + +nsresult +nsHTMLTableElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLTableElementIID)) { + nsIDOMHTMLTableElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLTableElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLTableElement* it = new nsHTMLTableElement(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(nsHTMLTableElement, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableElement, BgColor, bgcolor, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLTableElement, Border, border, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableElement, CellPadding, cellpadding, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableElement, CellSpacing, cellspacing, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableElement, Frame, frame, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLTableElement, Rules, rules, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLTableElement, Summary, summary, eSetAttrNotify_None) +NS_IMPL_STRING_ATTR(nsHTMLTableElement, Width, width, eSetAttrNotify_None) + +NS_IMETHODIMP +nsHTMLTableElement::GetCaption(nsIDOMHTMLTableCaptionElement** aValue) +{ + *aValue = nsnull; + return NS_OK; // XXX write me +} + +NS_IMETHODIMP +nsHTMLTableElement::SetCaption(nsIDOMHTMLTableCaptionElement* aValue) +{ + return NS_OK; // XXX write me +} + +NS_IMETHODIMP +nsHTMLTableElement::GetTHead(nsIDOMHTMLTableSectionElement** aValue) +{ + *aValue = nsnull; + return NS_OK; // XXX write me +} + +NS_IMETHODIMP +nsHTMLTableElement::SetTHead(nsIDOMHTMLTableSectionElement* aValue) +{ + return NS_OK; // XXX write me +} + +NS_IMETHODIMP +nsHTMLTableElement::GetTFoot(nsIDOMHTMLTableSectionElement** aValue) +{ + *aValue = nsnull; + return NS_OK; // XXX write me +} + +NS_IMETHODIMP +nsHTMLTableElement::SetTFoot(nsIDOMHTMLTableSectionElement* aValue) +{ + return NS_OK; // XXX write me +} + +NS_IMETHODIMP +nsHTMLTableElement::GetRows(nsIDOMHTMLCollection** aValue) +{ + *aValue = nsnull; + return NS_OK; // XXX write me +} + +NS_IMETHODIMP +nsHTMLTableElement::SetRows(nsIDOMHTMLCollection* aValue) +{ + return NS_OK; // XXX write me +} + +NS_IMETHODIMP +nsHTMLTableElement::GetTBodies(nsIDOMHTMLCollection** aValue) +{ + *aValue = nsnull; + return NS_OK; // XXX write me +} + +NS_IMETHODIMP +nsHTMLTableElement::SetTBodies(nsIDOMHTMLCollection* aValue) +{ + return NS_OK; // XXX write me +} + +NS_IMETHODIMP +nsHTMLTableElement::CreateTHead(nsIDOMHTMLElement** aValue) +{ + *aValue = nsnull; + return NS_OK; // XXX write me +} + +NS_IMETHODIMP +nsHTMLTableElement::DeleteTHead() +{ + return NS_OK; // XXX write me +} + +NS_IMETHODIMP +nsHTMLTableElement::CreateTFoot(nsIDOMHTMLElement** aValue) +{ + *aValue = nsnull; + return NS_OK; // XXX write me +} + +NS_IMETHODIMP +nsHTMLTableElement::DeleteTFoot() +{ + return NS_OK; // XXX write me +} + +NS_IMETHODIMP +nsHTMLTableElement::CreateCaption(nsIDOMHTMLElement** aValue) +{ + *aValue = nsnull; + return NS_OK; // XXX write me +} + +NS_IMETHODIMP +nsHTMLTableElement::DeleteCaption() +{ + return NS_OK; // XXX write me +} + +NS_IMETHODIMP +nsHTMLTableElement::InsertRow(PRInt32 aIndex, nsIDOMHTMLElement** aValue) +{ + *aValue = nsnull; + return NS_OK; // XXX write me +} + +NS_IMETHODIMP +nsHTMLTableElement::DeleteRow(PRInt32 aValue) +{ + return NS_OK; // XXX write me +} + +NS_IMETHODIMP +nsHTMLTableElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLTableElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLTableElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTableElement::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/nsHTMLTableRowElement.cpp b/mozilla/layout/html/content/src/nsHTMLTableRowElement.cpp new file mode 100644 index 00000000000..6188c52f93c --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLTableRowElement.cpp @@ -0,0 +1,242 @@ +/* -*- 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 "nsIDOMHTMLTableRowElement.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(kIDOMHTMLTableRowElementIID, NS_IDOMHTMLTABLEROWELEMENT_IID); + +class nsHTMLTableRowElement : public nsIDOMHTMLTableRowElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLTableRowElement(nsIAtom* aTag); + ~nsHTMLTableRowElement(); + + // 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) + + // nsIDOMHTMLTableRowElement + NS_IMETHOD GetRowIndex(PRInt32* aRowIndex); + NS_IMETHOD SetRowIndex(PRInt32 aRowIndex); + NS_IMETHOD GetSectionRowIndex(PRInt32* aSectionRowIndex); + NS_IMETHOD SetSectionRowIndex(PRInt32 aSectionRowIndex); + NS_IMETHOD GetCells(nsIDOMHTMLCollection** aCells); + NS_IMETHOD SetCells(nsIDOMHTMLCollection* aCells); + NS_IMETHOD GetAlign(nsString& aAlign); + NS_IMETHOD SetAlign(const nsString& aAlign); + NS_IMETHOD GetBgColor(nsString& aBgColor); + NS_IMETHOD SetBgColor(const nsString& aBgColor); + NS_IMETHOD GetCh(nsString& aCh); + NS_IMETHOD SetCh(const nsString& aCh); + NS_IMETHOD GetChOff(nsString& aChOff); + NS_IMETHOD SetChOff(const nsString& aChOff); + NS_IMETHOD GetVAlign(nsString& aVAlign); + NS_IMETHOD SetVAlign(const nsString& aVAlign); + NS_IMETHOD InsertCell(PRInt32 aIndex, nsIDOMHTMLElement** aReturn); + NS_IMETHOD DeleteCell(PRInt32 aIndex); + + // 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_NewHTMLTableRowElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLTableRowElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLTableRowElement::nsHTMLTableRowElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLTableRowElement::~nsHTMLTableRowElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLTableRowElement) + +NS_IMPL_RELEASE(nsHTMLTableRowElement) + +nsresult +nsHTMLTableRowElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLTableRowElementIID)) { + nsIDOMHTMLTableRowElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLTableRowElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLTableRowElement* it = new nsHTMLTableRowElement(mInner.mTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + mInner.CopyInnerTo(this, &it->mInner); + return it->QueryInterface(kIDOMNodeIID, (void**) aReturn); +} + +NS_IMETHODIMP +nsHTMLTableRowElement::GetRowIndex(PRInt32* aValue) +{ + *aValue = 0; + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTableRowElement::SetRowIndex(PRInt32 aValue) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTableRowElement::GetSectionRowIndex(PRInt32* aValue) +{ + *aValue = 0; + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTableRowElement::SetSectionRowIndex(PRInt32 aValue) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTableRowElement::GetCells(nsIDOMHTMLCollection** aValue) +{ + *aValue = 0; + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTableRowElement::SetCells(nsIDOMHTMLCollection* aValue) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTableRowElement::InsertCell(PRInt32 aIndex, nsIDOMHTMLElement** aValue) +{ + *aValue = 0; + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTableRowElement::DeleteCell(PRInt32 aValue) +{ + // XXX write me + return NS_OK; +} + +NS_IMPL_STRING_ATTR(nsHTMLTableRowElement, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableRowElement, BgColor, bgcolor, eSetAttrNotify_Render) +NS_IMPL_STRING_ATTR(nsHTMLTableRowElement, Ch, ch, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableRowElement, ChOff, choff, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableRowElement, VAlign, valign, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLTableRowElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLTableRowElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLTableRowElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTableRowElement::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/nsHTMLTableSectionElement.cpp b/mozilla/layout/html/content/src/nsHTMLTableSectionElement.cpp new file mode 100644 index 00000000000..aa0ec1cced0 --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLTableSectionElement.cpp @@ -0,0 +1,199 @@ +/* -*- 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 "nsIDOMHTMLTableSectionElement.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(kIDOMHTMLTableSectionElementIID, NS_IDOMHTMLTABLESECTIONELEMENT_IID); + +class nsHTMLTableSectionElement : public nsIDOMHTMLTableSectionElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLTableSectionElement(nsIAtom* aTag); + ~nsHTMLTableSectionElement(); + + // 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) + + // nsIDOMHTMLTableSectionElement + NS_IMETHOD GetAlign(nsString& aAlign); + NS_IMETHOD SetAlign(const nsString& aAlign); + NS_IMETHOD GetVAlign(nsString& aVAlign); + NS_IMETHOD SetVAlign(const nsString& aVAlign); + NS_IMETHOD GetRows(nsIDOMHTMLCollection** aRows); + NS_IMETHOD SetRows(nsIDOMHTMLCollection* aRows); + NS_IMETHOD InsertRow(PRInt32 aIndex, nsIDOMHTMLElement** aReturn); + NS_IMETHOD DeleteRow(PRInt32 aIndex); + + // 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_NewHTMLTableSectionElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLTableSectionElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLTableSectionElement::nsHTMLTableSectionElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLTableSectionElement::~nsHTMLTableSectionElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLTableSectionElement) + +NS_IMPL_RELEASE(nsHTMLTableSectionElement) + +nsresult +nsHTMLTableSectionElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLTableSectionElementIID)) { + nsIDOMHTMLTableSectionElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLTableSectionElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLTableSectionElement* it = new nsHTMLTableSectionElement(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(nsHTMLTableSectionElement, Align, align, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLTableSectionElement, VAlign, valign, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLTableSectionElement::GetRows(nsIDOMHTMLCollection** aValue) +{ + *aValue = 0; + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTableSectionElement::SetRows(nsIDOMHTMLCollection* aValue) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTableSectionElement::InsertRow(PRInt32 aIndex, nsIDOMHTMLElement** aValue) +{ + *aValue = 0; + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTableSectionElement::DeleteRow(PRInt32 aIndex) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTableSectionElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLTableSectionElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLTableSectionElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTableSectionElement::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/nsHTMLTitleElement.cpp b/mozilla/layout/html/content/src/nsHTMLTitleElement.cpp new file mode 100644 index 00000000000..49b24c1c3dd --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLTitleElement.cpp @@ -0,0 +1,152 @@ +/* -*- 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 "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ +#include "nsHTMLParts.h" +#include "nsHTMLContainer.h" +#include "nsFrame.h" +#include "nsHTMLIIDs.h" +#include "nsXIFConverter.h" + +#define nsHTMLTitleElementSuper nsHTMLTagContent + +class nsHTMLTitleElement : public nsHTMLTitleElementSuper { +public: + nsHTMLTitleElement(nsIAtom* aTag, const nsString& aTitle); + + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); + + NS_IMETHOD List(FILE* out, PRInt32 aIndent) const; + + + NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const; + NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const; + NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const; + +protected: + virtual ~nsHTMLTitleElement(); + nsString mTitle; +}; + +nsresult +NS_NewHTMLTitle(nsIHTMLContent** aInstancePtrResult, + nsIAtom* aTag, const nsString& aTitle) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLTitleElement(aTag, aTitle); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void **) aInstancePtrResult); +} + +nsHTMLTitleElement::nsHTMLTitleElement(nsIAtom* aTag, const nsString& aTitle) + : nsHTMLTitleElementSuper(aTag), mTitle(aTitle) +{ +} + +nsHTMLTitleElement::~nsHTMLTitleElement() +{ +} + +NS_IMETHODIMP +nsHTMLTitleElement::CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) +{ + nsIFrame* frame; + nsFrame::NewFrame(&frame, this, aParentFrame); + if (nsnull == frame) { + return NS_ERROR_OUT_OF_MEMORY; + } + frame->SetStyleContext(aPresContext, aStyleContext); + aResult = frame; + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTitleElement::List(FILE* out, PRInt32 aIndent) const +{ + NS_PRECONDITION(nsnull != mDocument, "bad content"); + + PRInt32 index; + for (index = aIndent; --index >= 0; ) fputs(" ", out); + + nsIAtom* tag; + GetTag(tag); + if (tag != nsnull) { + nsAutoString buf; + tag->ToString(buf); + fputs(buf, out); + NS_RELEASE(tag); + } + + ListAttributes(out); + + fprintf(out, " RefCount=%d<", mRefCnt); + fputs(mTitle, out); + fputs(">\n", out); + return NS_OK; +} + +/** + * Translate the content object into the (XIF) XML Interchange Format + * XIF is an intermediate form of the content model, the buffer + * will then be parsed into any number of formats including HTML, TXT, etc. + * These methods must be called in the following order: + + BeginConvertToXIF + ConvertContentToXIF + EndConvertToXIF + */ + +NS_IMETHODIMP +nsHTMLTitleElement::BeginConvertToXIF(nsXIFConverter& aConverter) const +{ + if (nsnull != mTag) + { + nsAutoString name; + mTag->ToString(name); + aConverter.BeginContainer(name); + } + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTitleElement::ConvertContentToXIF(nsXIFConverter& aConverter) const +{ + aConverter.AddContent(mTitle); + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLTitleElement::FinishConvertToXIF(nsXIFConverter& aConverter) const +{ + if (nsnull != mTag) + { + nsAutoString name; + mTag->ToString(name); + aConverter.EndContainer(name); + } + return NS_OK; +} diff --git a/mozilla/layout/html/content/src/nsHTMLUListElement.cpp b/mozilla/layout/html/content/src/nsHTMLUListElement.cpp new file mode 100644 index 00000000000..fb7fbaba07a --- /dev/null +++ b/mozilla/layout/html/content/src/nsHTMLUListElement.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 "nsIDOMHTMLUListElement.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(kIDOMHTMLUListElementIID, NS_IDOMHTMLULISTELEMENT_IID); + +class nsHTMLUListElement : public nsIDOMHTMLUListElement, + public nsIScriptObjectOwner, + public nsIDOMEventReceiver, + public nsIHTMLContent +{ +public: + nsHTMLUListElement(nsIAtom* aTag); + ~nsHTMLUListElement(); + + // 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) + + // nsIDOMHTMLUListElement + NS_IMETHOD GetCompact(PRBool* aCompact); + NS_IMETHOD SetCompact(PRBool aCompact); + NS_IMETHOD GetType(nsString& aType); + NS_IMETHOD SetType(const nsString& aType); + + // 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_NewHTMLUListElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsIHTMLContent* it = new nsHTMLUListElement(aTag); + if (nsnull == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult); +} + +nsHTMLUListElement::nsHTMLUListElement(nsIAtom* aTag) +{ + NS_INIT_REFCNT(); + mInner.Init(this, aTag); +} + +nsHTMLUListElement::~nsHTMLUListElement() +{ +} + +NS_IMPL_ADDREF(nsHTMLUListElement) + +NS_IMPL_RELEASE(nsHTMLUListElement) + +nsresult +nsHTMLUListElement::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this) + if (aIID.Equals(kIDOMHTMLUListElementIID)) { + nsIDOMHTMLUListElement* tmp = this; + *aInstancePtr = (void*) tmp; + mRefCnt++; + return NS_OK; + } + return NS_NOINTERFACE; +} + +nsresult +nsHTMLUListElement::CloneNode(nsIDOMNode** aReturn) +{ + nsHTMLUListElement* it = new nsHTMLUListElement(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(nsHTMLUListElement, Compact, compact, eSetAttrNotify_Reflow) +NS_IMPL_STRING_ATTR(nsHTMLUListElement, Type, compact, eSetAttrNotify_Reflow) + +NS_IMETHODIMP +nsHTMLUListElement::StringToAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + // XXX write me + return NS_CONTENT_ATTR_NOT_THERE; +} + +NS_IMETHODIMP +nsHTMLUListElement::AttributeToString(nsIAtom* aAttribute, + nsHTMLValue& aValue, + nsString& aResult) const +{ + // XXX write me + return mInner.AttributeToString(aAttribute, aValue, aResult); +} + +NS_IMETHODIMP +nsHTMLUListElement::MapAttributesInto(nsIStyleContext* aContext, + nsIPresContext* aPresContext) +{ + // XXX write me + return NS_OK; +} + +NS_IMETHODIMP +nsHTMLUListElement::HandleDOMEvent(nsIPresContext& aPresContext, + nsEvent* aEvent, + nsIDOMEvent** aDOMEvent, + PRUint32 aFlags, + nsEventStatus& aEventStatus) +{ + return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent, + aFlags, aEventStatus); +}