Tidy up the ie backend a little, make sure all com objects are correctly released.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68223 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -122,11 +122,7 @@ bool wxWebViewIE::Create(wxWindow* parent,
|
|||||||
|
|
||||||
void wxWebViewIE::LoadUrl(const wxString& url)
|
void wxWebViewIE::LoadUrl(const wxString& url)
|
||||||
{
|
{
|
||||||
wxVariant out = m_ie.CallMethod("Navigate", (BSTR) url.wc_str(),
|
m_ie.CallMethod("Navigate", (BSTR) url.wc_str(), NULL, NULL, NULL, NULL);
|
||||||
NULL, NULL, NULL, NULL);
|
|
||||||
|
|
||||||
// FIXME: why is out value null??
|
|
||||||
//(HRESULT)(out.GetLong()) == S_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWebViewIE::SetPage(const wxString& html, const wxString&)
|
void wxWebViewIE::SetPage(const wxString& html, const wxString&)
|
||||||
@@ -170,22 +166,20 @@ wxString wxWebViewIE::GetPageSource()
|
|||||||
IHTMLDocument2* document = GetDocument();
|
IHTMLDocument2* document = GetDocument();
|
||||||
IHTMLElement *bodyTag = NULL;
|
IHTMLElement *bodyTag = NULL;
|
||||||
IHTMLElement *htmlTag = NULL;
|
IHTMLElement *htmlTag = NULL;
|
||||||
document->get_body(&bodyTag);
|
BSTR bstr;
|
||||||
wxASSERT(bodyTag != NULL);
|
HRESULT hr = document->get_body(&bodyTag);
|
||||||
|
if(SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
hr = bodyTag->get_parentElement(&htmlTag);
|
||||||
|
if(SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
htmlTag->get_outerHTML(&bstr);
|
||||||
|
htmlTag->Release();
|
||||||
|
}
|
||||||
|
bodyTag->Release();
|
||||||
|
}
|
||||||
|
|
||||||
document->Release();
|
document->Release();
|
||||||
bodyTag->get_parentElement(&htmlTag);
|
|
||||||
wxASSERT(htmlTag != NULL);
|
|
||||||
|
|
||||||
BSTR bstr;
|
|
||||||
htmlTag->get_outerHTML(&bstr);
|
|
||||||
|
|
||||||
bodyTag->Release();
|
|
||||||
htmlTag->Release();
|
|
||||||
|
|
||||||
//wxMessageBox(wxString(bstr));
|
|
||||||
|
|
||||||
// TODO: check encoding
|
|
||||||
return wxString(bstr);
|
return wxString(bstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,7 +265,6 @@ int wxWebViewIE::GetIETextZoom()
|
|||||||
wxASSERT (result == S_OK);
|
wxASSERT (result == S_OK);
|
||||||
|
|
||||||
int zoom = V_I4(&zoomVariant);
|
int zoom = V_I4(&zoomVariant);
|
||||||
// wxMessageBox(wxString::Format("Zoom : %i", zoom));
|
|
||||||
VariantClear (&zoomVariant);
|
VariantClear (&zoomVariant);
|
||||||
|
|
||||||
return zoom;
|
return zoom;
|
||||||
@@ -410,10 +403,7 @@ void wxWebViewIE::GoForward()
|
|||||||
|
|
||||||
void wxWebViewIE::Stop()
|
void wxWebViewIE::Stop()
|
||||||
{
|
{
|
||||||
wxVariant out = m_ie.CallMethod("Stop");
|
m_ie.CallMethod("Stop");
|
||||||
|
|
||||||
// FIXME: why is out value null??
|
|
||||||
//return (HRESULT)(out.GetLong()) == S_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWebViewIE::ClearHistory()
|
void wxWebViewIE::ClearHistory()
|
||||||
@@ -491,9 +481,10 @@ wxString wxWebViewIE::GetCurrentURL()
|
|||||||
wxString wxWebViewIE::GetCurrentTitle()
|
wxString wxWebViewIE::GetCurrentTitle()
|
||||||
{
|
{
|
||||||
IHTMLDocument2* document = GetDocument();
|
IHTMLDocument2* document = GetDocument();
|
||||||
|
|
||||||
BSTR title;
|
BSTR title;
|
||||||
|
|
||||||
document->get_nameProp(&title);
|
document->get_nameProp(&title);
|
||||||
|
document->Release();
|
||||||
return wxString(title);
|
return wxString(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -552,6 +543,8 @@ void wxWebViewIE::SetEditable(bool enable)
|
|||||||
document->put_designMode(SysAllocString(L"On"));
|
document->put_designMode(SysAllocString(L"On"));
|
||||||
else
|
else
|
||||||
document->put_designMode(SysAllocString(L"Off"));
|
document->put_designMode(SysAllocString(L"Off"));
|
||||||
|
|
||||||
|
document->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWebViewIE::IsEditable()
|
bool wxWebViewIE::IsEditable()
|
||||||
@@ -563,6 +556,8 @@ bool wxWebViewIE::IsEditable()
|
|||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
document->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWebViewIE::SelectAll()
|
void wxWebViewIE::SelectAll()
|
||||||
@@ -574,9 +569,14 @@ bool wxWebViewIE::HasSelection()
|
|||||||
{
|
{
|
||||||
IHTMLDocument2* document = GetDocument();
|
IHTMLDocument2* document = GetDocument();
|
||||||
IHTMLSelectionObject* selection;
|
IHTMLSelectionObject* selection;
|
||||||
document->get_selection(&selection);
|
|
||||||
BSTR type;
|
BSTR type;
|
||||||
selection->get_type(&type);
|
HRESULT hr = document->get_selection(&selection);
|
||||||
|
if(SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
selection->get_type(&type);
|
||||||
|
selection->Release();
|
||||||
|
}
|
||||||
|
document->Release();
|
||||||
return wxString(type) != "None";
|
return wxString(type) != "None";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -617,9 +617,10 @@ wxString wxWebViewIE::GetSelectedText()
|
|||||||
bool wxWebViewIE::CanExecCommand(wxString command)
|
bool wxWebViewIE::CanExecCommand(wxString command)
|
||||||
{
|
{
|
||||||
IHTMLDocument2* document = GetDocument();
|
IHTMLDocument2* document = GetDocument();
|
||||||
|
|
||||||
VARIANT_BOOL enabled;
|
VARIANT_BOOL enabled;
|
||||||
|
|
||||||
document->queryCommandEnabled(SysAllocString(command.wc_str()), &enabled);
|
document->queryCommandEnabled(SysAllocString(command.wc_str()), &enabled);
|
||||||
|
document->Release();
|
||||||
|
|
||||||
return (enabled == VARIANT_TRUE);
|
return (enabled == VARIANT_TRUE);
|
||||||
}
|
}
|
||||||
@@ -628,6 +629,7 @@ void wxWebViewIE::ExecCommand(wxString command)
|
|||||||
{
|
{
|
||||||
IHTMLDocument2* document = GetDocument();
|
IHTMLDocument2* document = GetDocument();
|
||||||
document->execCommand(SysAllocString(command.wc_str()), VARIANT_FALSE, VARIANT(), NULL);
|
document->execCommand(SysAllocString(command.wc_str()), VARIANT_FALSE, VARIANT(), NULL);
|
||||||
|
document->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
IHTMLDocument2* wxWebViewIE::GetDocument()
|
IHTMLDocument2* wxWebViewIE::GetDocument()
|
||||||
|
Reference in New Issue
Block a user