Implement put_innerHTML and some other simple methods. Fix property page to display proper content type for document. b=171769 r=chak@netscape.com sr=rpotts@netscape.com a=a=rjesup@wgate.com

git-svn-id: svn://10.0.0.236/trunk@132231 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
locka%iol.ie 2002-10-18 11:39:57 +00:00
parent 74c1029647
commit 6a64bf064c
9 changed files with 137 additions and 38 deletions

View File

@ -41,9 +41,10 @@
#include "IEHtmlElementCollection.h"
#include "IEHtmlElement.h"
#include "MozillaBrowser.h"
#include "nsIDOMHTMLDocument.h"
#include "nsIDOMNSHTMLDocument.h"
#include <stack>
#include "MozillaBrowser.h"
CIEHtmlDocument::CIEHtmlDocument() :
mControl(NULL)
@ -342,8 +343,29 @@ HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_frames(IHTMLFramesCollection2 __R
HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_embeds(IHTMLElementCollection __RPC_FAR *__RPC_FAR *p)
{
// Validate parameters
if (p == NULL)
{
return E_INVALIDARG;
}
*p = NULL;
return E_NOTIMPL;
nsCOMPtr<nsIDOMNSHTMLDocument> htmlDoc = do_QueryInterface(mDOMDocument);
if (!htmlDoc)
return E_FAIL;
nsCOMPtr<nsIDOMHTMLCollection> nodeList;
htmlDoc->GetEmbeds(getter_AddRefs(nodeList));
// Get all elements
CIEHtmlElementCollectionInstance *pCollection = NULL;
CIEHtmlElementCollection::CreateFromDOMHTMLCollection(this, nodeList, (CIEHtmlElementCollection **) &pCollection);
if (pCollection)
{
pCollection->QueryInterface(IID_IHTMLElementCollection, (void **) p);
}
return S_OK;
}
@ -353,64 +375,89 @@ HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_plugins(IHTMLElementCollection __
return E_NOTIMPL;
}
#define IMPL_SET_COLOR(name, v) \
CComVariant vStr; \
if (FAILED(::VariantChangeType(&vStr, &v, 0, VT_BSTR))) \
return E_INVALIDARG; \
if (!mDOMDocument) \
return E_UNEXPECTED; \
nsCOMPtr<nsIDOMNSHTMLDocument> htmlDoc = do_QueryInterface(mDOMDocument); \
if (!htmlDoc) \
return E_FAIL; \
USES_CONVERSION; \
nsAutoString val(OLE2W(vStr.bstrVal)); \
htmlDoc->Set ## name(val); \
return S_OK;
#define IMPL_GET_COLOR(name, v) \
if (p == NULL) return E_INVALIDARG; \
if (!mDOMDocument) return E_UNEXPECTED; \
nsCOMPtr<nsIDOMNSHTMLDocument> htmlDoc = do_QueryInterface(mDOMDocument); \
if (!htmlDoc) return E_FAIL; \
USES_CONVERSION; \
nsAutoString val; \
htmlDoc->Get ## name(val); \
p->vt = VT_BSTR; \
p->bstrVal = ::SysAllocString(W2COLE(val.get())); \
return S_OK;
HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_alinkColor(VARIANT v)
{
return E_NOTIMPL;
IMPL_SET_COLOR(AlinkColor, v);
}
HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_alinkColor(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
IMPL_GET_COLOR(AlinkColor, p);
}
HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_bgColor(VARIANT v)
{
return E_NOTIMPL;
IMPL_SET_COLOR(BgColor, v);
}
HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_bgColor(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
IMPL_GET_COLOR(BgColor, p);
}
HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_fgColor(VARIANT v)
{
return E_NOTIMPL;
IMPL_SET_COLOR(FgColor, v);
}
HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_fgColor(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
IMPL_GET_COLOR(FgColor, p);
}
HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_linkColor(VARIANT v)
{
return E_NOTIMPL;
IMPL_SET_COLOR(LinkColor, v);
}
HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_linkColor(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
IMPL_GET_COLOR(LinkColor, p);
}
HRESULT STDMETHODCALLTYPE CIEHtmlDocument::put_vlinkColor(VARIANT v)
{
return E_NOTIMPL;
IMPL_SET_COLOR(VlinkColor, v);
}
HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_vlinkColor(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
IMPL_GET_COLOR(VlinkColor, p);
}
@ -430,8 +477,25 @@ HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_location(IHTMLLocation __RPC_FAR
HRESULT STDMETHODCALLTYPE CIEHtmlDocument::get_lastModified(BSTR __RPC_FAR *p)
{
if (p == NULL)
{
return E_INVALIDARG;
}
*p = NULL;
return E_NOTIMPL;
if (!mDOMDocument)
{
return E_UNEXPECTED;
}
nsCOMPtr<nsIDOMNSHTMLDocument> htmlDoc = do_QueryInterface(mDOMDocument);
if (!htmlDoc)
{
return E_FAIL;
}
USES_CONVERSION;
nsAutoString val;
htmlDoc->GetLastModified(val);
*p = ::SysAllocString(W2COLE(val.get()));
return S_OK;
}

View File

@ -508,7 +508,16 @@ HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_offsetParent(IHTMLElement __RPC_FA
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_innerHTML(BSTR v)
{
return E_NOTIMPL;
nsCOMPtr<nsIDOMNSHTMLElement> elementHTML = do_QueryInterface(mDOMNode);
if (!elementHTML)
{
return E_UNEXPECTED;
}
USES_CONVERSION;
nsAutoString innerHTML(OLE2W(v));
elementHTML->SetInnerHTML(innerHTML);
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_innerHTML(BSTR __RPC_FAR *p)

View File

@ -60,8 +60,6 @@ REQUIRES = \
CPPSRCS = \
StdAfx.cpp \
ControlSite.cpp \
ControlSiteIPFrame.cpp \
ItemContainer.cpp \
PropertyBag.cpp \
MozillaControl.cpp \

View File

@ -68,6 +68,7 @@
#include "nsIDOMWindowInternal.h"
#include "nsIDOMHTMLAnchorElement.h"
#include "nsIDOMNSDocument.h"
#include "nsEmbedAPI.h"
@ -320,7 +321,7 @@ void CMozillaBrowser::ShowContextMenu(PRUint32 aContextFlags, nsIDOMEvent *aEven
//
// ShowURIPropertyDlg
//
void CMozillaBrowser::ShowURIPropertyDlg(const nsString &aURI)
void CMozillaBrowser::ShowURIPropertyDlg(const nsAString &aURI, const nsAString &aContentType)
{
CPropertyDlg dlg;
CPPageDlg linkDlg;
@ -328,10 +329,8 @@ void CMozillaBrowser::ShowURIPropertyDlg(const nsString &aURI)
if (aURI.Length() > 0)
{
USES_CONVERSION;
linkDlg.mProtocol = "Hypertext Transfer Protocol"; // TODO
linkDlg.mType = "HTML Document"; // TODO
linkDlg.mURL.AssignWithConversion(aURI);
linkDlg.mType = aContentType;
linkDlg.mURL = aURI;
}
dlg.DoModal();
@ -834,8 +833,14 @@ LRESULT CMozillaBrowser::OnDocumentProperties(WORD wNotifyCode, WORD wID, HWND h
{
htmlDoc->GetURL(uri);
}
nsAutoString contentType;
nsCOMPtr<nsIDOMNSDocument> doc = do_QueryInterface(ownerDoc);
if (doc)
{
doc->GetContentType(contentType);
}
ShowURIPropertyDlg(uri);
ShowURIPropertyDlg(uri, contentType);
return 0;
}
@ -930,14 +935,16 @@ LRESULT CMozillaBrowser::OnLinkCopyShortcut(WORD wNotifyCode, WORD wID, HWND hWn
LRESULT CMozillaBrowser::OnLinkProperties(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
nsAutoString uri;
nsAutoString type;
nsCOMPtr<nsIDOMHTMLAnchorElement> anchorElement = do_QueryInterface(mContextNode);
if (anchorElement)
{
anchorElement->GetHref(uri);
anchorElement->GetType(type); // How many anchors implement this I wonder
}
ShowURIPropertyDlg(uri);
ShowURIPropertyDlg(uri, type);
return 0;
}
@ -1281,14 +1288,14 @@ HRESULT CMozillaBrowser::OnEditorCommand(DWORD nCmdID)
PRBool bAll = PR_TRUE;
// Set or remove
pHtmlEditor->GetInlineProperty(pInlineProperty, nsString(), nsString(), &bFirst, &bAny, &bAll);
pHtmlEditor->GetInlineProperty(pInlineProperty, nsAutoString(), nsAutoString(), &bFirst, &bAny, &bAll);
if (bAny)
{
pHtmlEditor->RemoveInlineProperty(pInlineProperty, nsString());
pHtmlEditor->RemoveInlineProperty(pInlineProperty, nsAutoString());
}
else
{
pHtmlEditor->SetInlineProperty(pInlineProperty, nsString(), nsString());
pHtmlEditor->SetInlineProperty(pInlineProperty, nsAutoString(), nsAutoString());
}
}

View File

@ -417,7 +417,7 @@ protected:
// User interface methods
virtual int MessageBox(LPCTSTR lpszText, LPCTSTR lpszCaption = _T(""), UINT nType = MB_OK);
virtual void ShowContextMenu(PRUint32 aContextFlags, nsIDOMEvent *aEvent, nsIDOMNode *aNode);
virtual void ShowURIPropertyDlg(const nsString &aURI);
virtual void ShowURIPropertyDlg(const nsAString &aURI, const nsAString &aContentType);
virtual void NextDlgControl();
virtual void PrevDlgControl();

View File

@ -325,9 +325,8 @@ FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Address: (URL)",IDC_STATIC,0,68,27,20
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,0,32,185,1
LTEXT "Type:",IDC_STATIC,0,53,19,8
LTEXT "type",IDC_TYPE,35,53,149,8
LTEXT "Protocol:",IDC_STATIC,0,38,28,8
LTEXT "Type:",IDC_STATIC,0,38,19,8
LTEXT "protocol",IDC_PROTOCOL,35,38,149,8
EDITTEXT IDC_ADDRESS,35,68,149,61,ES_MULTILINE | ES_AUTOVSCROLL |
ES_READONLY

View File

@ -42,6 +42,9 @@
#include "PropertyDlg.h"
#include "resource.h"
#include "nsIMIMEInfo.h"
#include "nsIMIMEService.h"
CPropertyDlg::CPropertyDlg() :
mPPage(NULL)
{
@ -96,8 +99,30 @@ LRESULT CPropertyDlg::OnClose(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bH
LRESULT CPPageDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
SetDlgItemText(IDC_PROTOCOL, mProtocol.get());
SetDlgItemText(IDC_TYPE, mType.get());
SetDlgItemText(IDC_ADDRESS, mURL.get());
nsAutoString desc;
if (!mType.IsEmpty())
{
nsresult rv;
nsCOMPtr<nsIMIMEService> mimeService;
mimeService = do_GetService("@mozilla.org/mime;1", &rv);
NS_ENSURE_TRUE(mimeService, NS_ERROR_FAILURE);
nsCOMPtr<nsIMIMEInfo> mimeInfo;
nsCAutoString contentType;
contentType.AssignWithConversion(mType);
mimeService->GetFromMIMEType(contentType.get(), getter_AddRefs(mimeInfo));
if (mimeInfo)
{
nsXPIDLString description;
mimeInfo->GetDescription(getter_Copies(description));
desc = description;
}
}
USES_CONVERSION;
SetDlgItemText(IDC_PROTOCOL, W2T(desc.get()));
SetDlgItemText(IDC_TYPE, W2T(mType.get()));
SetDlgItemText(IDC_ADDRESS, W2T(mURL.get()));
return 1;
}

View File

@ -45,9 +45,8 @@ class CPPageDlg : public CDialogImpl<CPPageDlg>
public:
enum { IDD = IDD_PPAGE_LINK };
nsCString mProtocol;
nsCString mType;
nsCString mURL;
nsString mType;
nsString mURL;
BEGIN_MSG_MAP(CPPageLinkDlg)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)

View File

@ -160,8 +160,6 @@ typedef long int32;
#include "PropertyList.h"
#include "PropertyBag.h"
#include "ItemContainer.h"
#include "ControlSite.h"
#include "ControlSiteIPFrame.h"
#include "IEHtmlDocument.h"
#include "CPMozillaControl.h"