Mozilla 31 update

import/tags/kmeleon75b1
boisso 8 years ago
parent c28552d1dc
commit c52f599f26
  1. 12
      k-meleon/AutoComplete.h
  2. 15
      k-meleon/BrowserGlue.cpp
  3. 28
      k-meleon/BrowserImpl.cpp
  4. 14
      k-meleon/BrowserView.h
  5. 10
      k-meleon/BrowserViewUtils.cpp
  6. 116
      k-meleon/BrowserWindow.cpp
  7. 4
      k-meleon/BrowserWindow.h
  8. 4
      k-meleon/Components.cpp
  9. 4
      k-meleon/CookiePromptService.cpp
  10. 11
      k-meleon/Cookies.h
  11. 7
      k-meleon/CookiesViewerDlg.cpp
  12. 385
      k-meleon/FavIconList.cpp
  13. 4
      k-meleon/GenKeyPairDialogs.cpp
  14. 4
      k-meleon/JSBridge/JSBridge.vcxproj
  15. 4
      k-meleon/JSBridge/genidl.cmd
  16. 2
      k-meleon/JSBridge/jsplugin.cpp
  17. 2
      k-meleon/JSBridge/nsGenericFactory.cpp
  18. 10
      k-meleon/KMeleon.vcxproj
  19. 2
      k-meleon/KMeleonConst.h
  20. 19
      k-meleon/KmAbout.cpp
  21. 84
      k-meleon/KmAppInfo.cpp
  22. 32
      k-meleon/KmFileLocProvider.cpp
  23. 2
      k-meleon/KmFileLocProvider.h
  24. 8
      k-meleon/MfcEmbed.h
  25. 68
      k-meleon/MozUtils.cpp
  26. 12
      k-meleon/MozUtils.h
  27. 26
      k-meleon/NSSDialogs.cpp
  28. 13
      k-meleon/Permissions.h
  29. 52
      k-meleon/Plugins.cpp
  30. 27
      k-meleon/Preferences.cpp
  31. 2
      k-meleon/PrintProgressDialog.h
  32. 6
      k-meleon/PrintSetupDialog.cpp
  33. 8
      k-meleon/PromptService.cpp
  34. 4
      k-meleon/ReBarEx.cpp
  35. 4
      k-meleon/ReBarEx.h
  36. 26
      k-meleon/SaveAsHandler.cpp
  37. 4
      k-meleon/SaveAsHandler.h
  38. 8
      k-meleon/StdAfx.cpp
  39. 15
      k-meleon/StdAfx.h
  40. 8
      k-meleon/TooltipsProvider.cpp
  41. 1444
      k-meleon/UnknownContentTypeHandler.cpp
  42. 25
      k-meleon/UnknownContentTypeHandler.h
  43. 1
      k-meleon/fullscreen/fullscreen.h
  44. 4
      k-meleon/fullscreen/fullscreen.vcxproj
  45. 2
      k-meleon/fullscreen/mozilla.cpp
  46. 1
      k-meleon/kmeleon_plugin.h
  47. 4
      k-meleon/login/genidl.cmd
  48. 4
      k-meleon/login/login.vcxproj
  49. 4
      k-meleon/login/mozilla.cpp
  50. 13
      k-meleon/login/mozilla.h
  51. 2
      k-meleon/login/stdafx.h
  52. 2
      k-meleon/privacy/privacy.cpp
  53. 4
      k-meleon/privacy/privacy.vcxproj

@ -71,10 +71,10 @@ protected:
AutoCompleteResult* m_ACIt;
AutoCompleteCallback m_Callback;
void* m_data;
static nsEmbedString previousSearch;
static nsString previousSearch;
};
NS_IMPL_ISUPPORTS1(CACListener, nsIAutoCompleteObserver)
NS_IMPL_ISUPPORTS(CACListener, nsIAutoCompleteObserver)
NS_IMETHODIMP CACListener::OnUpdateSearchResult(nsIAutoCompleteSearch *search, nsIAutoCompleteResult *result)
{
@ -99,8 +99,8 @@ NS_IMETHODIMP CACListener::OnSearchResult(nsIAutoCompleteSearch *search, nsIAuto
for (PRUint32 i = 0; i<gACCountResults; i++)
{
nsEmbedString nsStr;
nsEmbedCString nsCStr;
nsString nsStr;
nsCString nsCStr;
result->GetValueAt(i, nsStr);
NS_UTF16ToCString(nsStr,NS_CSTRING_ENCODING_NATIVE_FILESYSTEM,nsCStr);
@ -122,7 +122,7 @@ NS_IMETHODIMP CACListener::OnSearchResult(nsIAutoCompleteSearch *search, nsIAuto
return NS_OK;
}
nsEmbedString CACListener::previousSearch;
nsString CACListener::previousSearch;
void CACListener::AutoCompleteStop()
{
@ -140,7 +140,7 @@ void CACListener::AutoComplete(const CString& aSearchString, AutoCompleteCallbac
nsCOMPtr<nsIAutoCompleteSearch> autoComplete = do_GetService("@mozilla.org/autocomplete/search;1?name=history", &rv);
NS_ENSURE_TRUE(autoComplete, );
nsEmbedString searchString = CStringToNSString(aSearchString);
nsString searchString = CStringToNSString(aSearchString);
if (!searchString.Equals(previousSearch)) {
previousSearch = searchString;
nsCOMPtr<nsIAutoCompleteObserver> listener = new CACListener(callback, data);

@ -76,7 +76,6 @@ void CBrowserGlue::UpdateBusyState(BOOL aBusy)
else {
SetFavIcon(nullptr);
mPendingLocation = _T("");
/*
nsCOMPtr<nsIDOMEventTarget> eventTarget;
nsCOMPtr<nsIWebBrowser> br = mpBrowserView->GetBrowserWrapper()->GetWebBrowser();
@ -108,7 +107,7 @@ void CBrowserGlue::UpdateCurrentURI(nsIURI *aLocation)
}
}
nsEmbedCString uriString;
nsCString uriString;
nsCOMPtr<nsIURI> exposable;
nsCOMPtr<nsIURIFixup> fixup(do_GetService("@mozilla.org/docshell/urifixup;1"));
if (fixup && NS_SUCCEEDED(fixup->CreateExposableURI(aLocation, getter_AddRefs(exposable))) && exposable)
@ -150,14 +149,14 @@ void CBrowserGlue::UpdateCurrentURI(nsIURI *aLocation)
if ( allowMRU ) {
if (theApp.preferences.MRUbehavior == 0){
nsEmbedCString password;
nsCString password;
aLocation->GetUsername(password);
aLocation->SetUserPass(password);
aLocation->GetSpec(uriString);
theApp.m_MRUList->AddURL(NSUTF8StringToCString(uriString));
}
else if (theApp.preferences.MRUbehavior == 1){
nsEmbedCString nsScheme, nsHost;
nsCString nsScheme, nsHost;
aLocation->GetScheme(nsScheme);
aLocation->GetHost(nsHost);
nsHost.Insert("://",0);
@ -354,7 +353,7 @@ void CBrowserGlue::SetFavIcon(nsIURI* favUri)
if (theApp.preferences.GetBool("browser.chrome.favicons", PR_TRUE))
{
nsCOMPtr<nsIURI> currentURI;
nsEmbedCString nsUri;
nsCString nsUri;
mpBrowserView->GetBrowserWrapper()->GetCurrentURI(getter_AddRefs(currentURI));
if (!currentURI) return;
@ -496,7 +495,7 @@ bool CBrowserGlue::performXULCommand(LPCWSTR id, LPCTSTR siteUri)
mpBrowserView->GetBrowserWrapper()->GetCurrentURI(getter_AddRefs(uri));
PRInt32 port;
nsEmbedCString host;
nsCString host;
uri->GetHost(host);
uri->GetPort(&port);
if (port == -1) port = 443;
@ -555,7 +554,7 @@ bool CBrowserGlue::performXULCommand(LPCWSTR id, LPCTSTR siteUri)
nsresult rv;
PRInt32 port;
nsEmbedCString host;
nsCString host;
uri->GetHost(host);
uri->GetPort(&port);
if (port == -1) port = 443;
@ -619,7 +618,7 @@ BOOL CBrowserGlue::AllowFlash()
mpBrowserView->GetBrowserWrapper()->GetCurrentURI(getter_AddRefs(uri));
NS_ENSURE_TRUE(uri, FALSE);
nsEmbedCString nshost;
nsCString nshost;
uri->GetHost(nshost);
CString host = NSCStringToCString(nshost);

@ -80,6 +80,8 @@
#include "nsIDOMEventTarget.h"
#include "nsPIWindowRoot.h"
#include "nsIDOMEventTarget.h"
#include "nsIDOMLocation.h"
#include "nsPIDOMWindow.h"
#include "nsIScriptSecurityManager.h"
@ -166,7 +168,7 @@ NS_IMETHODIMP CBrowserImpl::Observe(nsISupports *aSubject, const char *aTopic, c
NS_IMETHODIMP CBrowserImpl::OnHistoryNewEntry(nsIURI *aNewURI)
{
nsEmbedCString str;
nsCString str;
aNewURI->GetSpec(str);
CString cStr = str.get();
m_pBrowserFrameGlue->UpdateMRU(str.get());
@ -451,6 +453,8 @@ NS_IMETHODIMP CBrowserImpl::SetDimensions(PRUint32 aFlags, PRInt32 x, PRInt32 y,
wp.rcNormalPosition.top = y;
}
if (!mChromeLoaded && (mChromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME))
wp.showCmd = SW_HIDE;
frame->SetWindowPlacement(&wp);
return NS_OK;
}
@ -527,7 +531,7 @@ NS_IMETHODIMP CBrowserImpl::GetTitle(PRUnichar** aTitle)
CString title;
m_pBrowserFrameGlue->GetBrowserTitle(title);
nsEmbedString nsTitle;
nsString nsTitle;
*aTitle = NS_StringCloneData(CStringToNSString(title));
return NS_OK;
@ -689,7 +693,7 @@ NS_IMETHODIMP CBrowserImpl::HandleEvent(nsIDOMEvent *aEvent)
NS_ENSURE_TRUE(m_pBrowserFrameGlue, NS_OK);
nsresult rv;
nsEmbedString type;
nsString type;
aEvent->GetType(type);
if (type.Equals(NS_LITERAL_STRING("mousedown")))
@ -718,7 +722,7 @@ NS_IMETHODIMP CBrowserImpl::HandleEvent(nsIDOMEvent *aEvent)
nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(aEvent));
NS_ENSURE_TRUE(mouseEvent, NS_ERROR_FAILURE);
uint16_t button;
int16_t button;
mouseEvent->GetButton(&button);
nsCOMPtr<nsIDOMNode> targetNode = do_QueryInterface(eventTarget);
@ -734,7 +738,7 @@ NS_IMETHODIMP CBrowserImpl::HandleEvent(nsIDOMEvent *aEvent)
if (urlStr.Left(6).Compare(_T("about:")) == 0) {
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(eventTarget, &rv);
if (element) {
nsEmbedString str;
nsString str;
rv = element->GetAttribute(NS_LITERAL_STRING("id"), str);
if (str.Length() > 0) {
urlStr = GetUriForDocument(domDocument);
@ -851,7 +855,7 @@ NS_IMETHODIMP CBrowserImpl::HandleEvent(nsIDOMEvent *aEvent)
nsCOMPtr<nsIDOMElement> elem = do_QueryInterface(target);
NS_ENSURE_TRUE (elem, NS_ERROR_FAILURE);
nsEmbedString value;
nsString value;
rv = elem->GetTagName(value);
rv = elem->GetAttribute(NS_LITERAL_STRING("rel"), value);
@ -887,15 +891,15 @@ NS_IMETHODIMP CBrowserImpl::HandleEvent(nsIDOMEvent *aEvent)
/* disallow subframes to set favicon */
if (domWinAsISupports != topDomWinAsISupports) return NS_OK;
nsEmbedString spec;
nsString spec;
rv = domDoc->GetDocumentURI (spec);
NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
nsCOMPtr<nsIURI> docUri;
NewURI (getter_AddRefs (docUri), spec);
nsEmbedCString favicon;
nsEmbedCString cvalue;
nsCString favicon;
nsCString cvalue;
NS_UTF16ToCString(value, NS_CSTRING_ENCODING_UTF8, cvalue);
rv = docUri->Resolve (cvalue, favicon);
NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
@ -917,7 +921,7 @@ NS_IMETHODIMP CBrowserImpl::HandleEvent(nsIDOMEvent *aEvent)
//if (NS_FAILED (rv)) return NS_OK;
/* Hide password part */
nsEmbedCString password;
nsCString password;
favUri->GetUsername(password);
favUri->SetUserPass(password);
@ -948,7 +952,7 @@ NS_IMETHODIMP CBrowserImpl::HandleEvent(nsIDOMEvent *aEvent)
popupEvent->GetPopupWindowURI(getter_AddRefs(uri));
NS_ENSURE_TRUE (uri, NS_ERROR_FAILURE);
nsEmbedCString host;
nsCString host;
rv = uri->GetHost(host);
NS_ENSURE_SUCCESS (rv, rv);
NS_ENSURE_TRUE (host.Length(), NS_OK);
@ -978,7 +982,7 @@ NS_IMETHODIMP CBrowserImpl::HandleEvent(nsIDOMEvent *aEvent)
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(eventTarget, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsEmbedString str;
nsString str;
rv = element->GetAttribute(NS_LITERAL_STRING("id"), str);
NS_ENSURE_SUCCESS(rv, rv);

@ -170,14 +170,14 @@ public:
// nsIDOMWindow *FindDOMWindow(nsIDOMWindow *window, nsIDOMDocument *document);
/* void SetCtxMenuLinkUrl(nsEmbedString& strLinkUrl);
nsEmbedString mCtxMenuLinkUrl;
/* void SetCtxMenuLinkUrl(nsString& strLinkUrl);
nsString mCtxMenuLinkUrl;
void SetCtxMenuImageSrc(nsEmbedString& strImgSrc);
nsEmbedString mCtxMenuImgSrc;
void SetCtxMenuImageSrc(nsString& strImgSrc);
nsString mCtxMenuImgSrc;
void SetCurrentFrameURL(nsEmbedString& strcCurrentFrameURL);
nsEmbedString mCtxMenuCurrentFrameURL;*/
void SetCurrentFrameURL(nsString& strcCurrentFrameURL);
nsString mCtxMenuCurrentFrameURL;*/
void Activate(BOOL bActive);
@ -213,7 +213,7 @@ protected:
CBrowserWrapper* m_pWindow;
nsEmbedString m_lastHighlightWord;
nsString m_lastHighlightWord;
// BOOL m_refreshBackButton;
// BOOL m_refreshForwardButton;
BOOL m_InPrintPreview;

@ -71,7 +71,7 @@ void OpenFileExternal(const char* uri, LPCTSTR file, nsresult status, void* para
CreateProcess(0,command,0,0,0,0,0,0,&si,&pi); // launch external viewer
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
delete command;
delete [] command;
}
free(viewer);
// Have to show an error message
@ -309,8 +309,8 @@ LRESULT CBrowserView::RefreshToolBarItem(WPARAM ItemID, LPARAM unused)
void CBrowserView::OpenURL(const char* pUrl, nsIURI *refURI, BOOL allowFixup)
{
nsEmbedString str;
NS_CStringToUTF16(nsEmbedCString(pUrl), NS_CSTRING_ENCODING_ASCII, str);
nsString str;
NS_CStringToUTF16(nsCString(pUrl), NS_CSTRING_ENCODING_ASCII, str);
OpenURL(str.get(), refURI, allowFixup);
}*/
@ -361,8 +361,8 @@ void CBrowserView::OpenURL(LPCTSTR url, BOOL sendRef, BOOL allowFixup)
/*
CBrowserFrame* CBrowserView::OpenURLInNewWindow(const char* pUrl, BOOL bBackground, nsIURI *refURI, BOOL allowFixup)
{
nsEmbedString str;
NS_CStringToUTF16(nsEmbedCString(pUrl), NS_CSTRING_ENCODING_UTF8, str);
nsString str;
NS_CStringToUTF16(nsCString(pUrl), NS_CSTRING_ENCODING_UTF8, str);
return OpenURLInNewWindow(str.get(), bBackground, refURI, allowFixup);
}*/

@ -80,6 +80,7 @@
//#include "nsIDOMDocumentRange.h"
#include "nsIDOMDocumentFragment.h"
#include "nsIDOMWindowCollection.h"
#include "nsPIDOMWindow.h"
#include "nsIFocusManager.h"
#include "nsIScriptContext.h"
@ -453,7 +454,7 @@ CString CBrowserWrapper::GetURI(BOOL unescape)
return _T("");
// Get the uri string associated with the nsIURI object
nsEmbedCString uriString;
nsCString uriString;
rv = currentURI->GetSpec(uriString);
NS_ENSURE_SUCCESS(rv, _T(""));
@ -491,17 +492,16 @@ BOOL CBrowserWrapper::GetCharset(char* aCharset)
{
// If no forced charset look for the document charset
char *charset;
DocShell->GetCharset(&charset);
if (!charset)
nsCString charset;
DocShell->GetCharset(charset);
if (charset.IsEmpty())
{
// If no document charset use default
result = mdv->GetDefaultCharacterSet(mCharset);
result = mdv->GetHintCharacterSet(mCharset);
}
else
{
mCharset = charset;
nsMemory::Free (charset);
}
}
@ -549,7 +549,7 @@ BOOL CBrowserWrapper::ScrollBy(int32_t dx, int32_t dy)
}
NS_ENSURE_TRUE(dom, FALSE);
return NS_SUCCEEDED(dom->ScrollBy (dx, dy));
return dom->ScrollBy (dx, dy);
}
already_AddRefed<nsIMarkupDocumentViewer> CBrowserWrapper::GetMarkupViewer()
@ -680,7 +680,7 @@ BOOL CBrowserWrapper::CloneSHistory(CBrowserWrapper* newWebBrowser)
nsCOMPtr<nsISHistoryInternal> newSHInternal(do_QueryInterface(newSH));
NS_ENSURE_TRUE(newSHInternal, FALSE);
nsCOMPtr<nsIHistoryEntry> she;
nsCOMPtr<nsISHEntry> she;
for (int i=0;i<count;i++)
{
@ -729,12 +729,12 @@ BOOL CBrowserWrapper::GetSHistoryInfoAt(PRInt32 index, CString& title, CString&
mWebNav->GetSessionHistory(getter_AddRefs(sHistory));
NS_ENSURE_TRUE(sHistory, FALSE);
nsCOMPtr<nsIHistoryEntry> he;
nsCOMPtr<nsISHEntry> he;
sHistory->GetEntryAtIndex(index, PR_FALSE, getter_AddRefs(he));
if (!he) return false;
nsresult rv;
nsEmbedCString nsUrl;
nsCString nsUrl;
PRUnichar* nsTitle;
rv = he->GetTitle(&nsTitle);
@ -945,56 +945,10 @@ BOOL CBrowserWrapper::InjectCSS(const wchar_t* userStyleSheet)
BOOL CBrowserWrapper::InjectJS(const wchar_t* userScript, CString& result, bool bTopWindow)
{
/*nsresult rv;
// No more running JS from C++
nsresult rv;
nsCOMPtr<nsIDOMDocument> document;
if (!bTopWindow)
{
if (mLastMouseActionNode)
rv = mLastMouseActionNode->GetOwnerDocument(getter_AddRefs(document));
else
{
nsCOMPtr<nsIDOMWindow> dom;
rv = mWebBrowserFocus->GetFocusedWindow(getter_AddRefs(dom));
if (dom) rv = dom->GetDocument(getter_AddRefs(document));
}
}
if (!document)
{
nsCOMPtr<nsIDOMWindow> dom;
rv = mWebBrowser->GetContentDOMWindow(getter_AddRefs(dom));
NS_ENSURE_SUCCESS(rv, FALSE);
rv = dom->GetDocument(getter_AddRefs(document));
}
NS_ENSURE_SUCCESS(rv, FALSE);*/
PRBool jsEnabled = PR_TRUE;
jsEnabled = theApp.preferences.GetBool("javascript.enabled", jsEnabled);
theApp.preferences.SetBool("javascript.enabled", true);
nsCOMPtr<nsIScriptGlobalObject> sgo = do_GetInterface(mWebBrowser);
nsCOMPtr<nsIScriptContext> ctx = sgo->GetContext();
JSContext* cx = ctx->GetNativeContext();
//mozilla::AutoPushJSContext cx(ctx->GetNativeContext());
JS::Rooted<JSObject*> global(cx, sgo->GetGlobalJSObject());
JS::Rooted<JS::Value> retval(cx, JS::UndefinedValue());
JS::CompileOptions options(cx);
//options.setFileAndLine("kmeleon",0).setVersion(JSVERSION_DEFAULT);
nsCOMPtr<nsIScriptObjectPrincipal> sgoPrincipal = do_QueryInterface(sgo);
ctx->EvaluateString(nsEmbedString(userScript), global,
options, false, nullptr/*retval.address()*/);
//result = NSStringToCString(nsString(JS_GetStringCharsZ(ctx->GetNativeContext(), retval.toString())));
theApp.preferences.SetBool("javascript.enabled", jsEnabled);
return TRUE;
return LoadURL(CString(_T("javascript:")) + userScript);
}
BOOL CBrowserWrapper::_GetSelection(nsIDOMWindow* dom, nsAString &aSelText)
@ -1032,7 +986,7 @@ BOOL CBrowserWrapper::_GetSelection(nsIDOMWindow* dom, nsAString &aSelText)
return ret;
}
BOOL CBrowserWrapper::GetSelectionInsideForm(nsIDOMElement *element, nsEmbedString &aSelText)
BOOL CBrowserWrapper::GetSelectionInsideForm(nsIDOMElement *element, nsString &aSelText)
{
nsCOMPtr<nsIDOMHTMLInputElement> domnsinput = do_QueryInterface(element);
if (domnsinput)
@ -1049,7 +1003,7 @@ BOOL CBrowserWrapper::GetSelectionInsideForm(nsIDOMElement *element, nsEmbedStri
nsCOMPtr<nsIDOMHTMLInputElement> dominput = do_QueryInterface(element);
if (!dominput) return FALSE;
nsEmbedString value;
nsString value;
dominput->GetValue(value);
value.Cut(end,-1);
if (start>value.Length())
@ -1073,7 +1027,7 @@ BOOL CBrowserWrapper::GetSelectionInsideForm(nsIDOMElement *element, nsEmbedStri
nsCOMPtr<nsIDOMHTMLTextAreaElement> tainput = do_QueryInterface(element);
if (!tansinput) return FALSE;
nsEmbedString value;
nsString value;
tainput->GetValue(value);
value.Cut(end,-1);
if (start>value.Length())
@ -1086,7 +1040,7 @@ BOOL CBrowserWrapper::GetSelectionInsideForm(nsIDOMElement *element, nsEmbedStri
return FALSE;
}
BOOL CBrowserWrapper::GetUSelection(nsEmbedString& aSelText)
BOOL CBrowserWrapper::GetUSelection(nsString& aSelText)
{
nsCOMPtr<nsIDOMWindow> dom(do_GetInterface(mWebBrowser));
NS_ENSURE_TRUE(dom, FALSE);
@ -1110,7 +1064,7 @@ BOOL CBrowserWrapper::GetUSelection(nsEmbedString& aSelText)
BOOL CBrowserWrapper::GetSelection(CString& aSelText)
{
nsEmbedString selText;
nsString selText;
if (!GetUSelection(selText))
return FALSE;
@ -1174,7 +1128,7 @@ BOOL CBrowserWrapper::GetSecurityInfo(CString &sign)
rv = docShell->GetSecurityUI (getter_AddRefs (securityInfo));
NS_ENSURE_SUCCESS(rv, FALSE);
/*nsEmbedString tooltip;
/*nsString tooltip;
rv = securityInfo->GetTooltipText (tooltip);
NS_ENSURE_SUCCESS(rv, FALSE);
@ -1248,9 +1202,9 @@ bool CBrowserWrapper::CheckNode(nsIDOMElement* elem)
{
if (elem)
{
nsEmbedString className;
elem->GetAttribute(nsEmbedString(kClass), className);
if (className.Equals(nsEmbedString(kHighlighClassName)))
nsString className;
elem->GetAttribute(nsString(kClass), className);
if (className.Equals(nsString(kHighlighClassName)))
return PR_TRUE;
}
return PR_FALSE;
@ -1396,11 +1350,11 @@ BOOL CBrowserWrapper::_Highlight(nsIDOMWindow* dom, const PRUnichar* backcolor,
}
nsCOMPtr<nsIDOMElement> baseElement;
rv = document->CreateElement(nsEmbedString(kSpan), getter_AddRefs(baseElement));
rv = document->CreateElement(nsString(kSpan), getter_AddRefs(baseElement));
NS_ENSURE_SUCCESS(rv, FALSE);
baseElement->SetAttribute(nsEmbedString(kStyle), nsEmbedString(kDefaultHighlightStyle));
baseElement->SetAttribute(nsEmbedString(kClass), nsEmbedString(kHighlighClassName));
baseElement->SetAttribute(nsString(kStyle), nsString(kDefaultHighlightStyle));
baseElement->SetAttribute(nsString(kClass), nsString(kHighlighClassName));
while (1)
{
@ -1522,7 +1476,7 @@ already_AddRefed<nsISupports> CBrowserWrapper::GetPageDescriptor(BOOL focus)
BOOL CBrowserWrapper::CanSave()
{
nsEmbedCString contentType;
nsCString contentType;
nsCOMPtr<nsIDOMDocument> document;
nsCOMPtr<nsIDOMWindow> dom;
@ -1531,7 +1485,7 @@ BOOL CBrowserWrapper::CanSave()
rv = dom->GetDocument(getter_AddRefs(document));
nsEmbedString type;
nsString type;
rv = document->GetContentType(type);
NS_UTF16ToCString(type, NS_CSTRING_ENCODING_ASCII, contentType);
@ -1576,7 +1530,7 @@ BOOL CBrowserWrapper::SaveDocument(BOOL frame, LPCTSTR filename)
document->GetLocation(getter_AddRefs(location));
NS_ENSURE_TRUE(location, FALSE);
nsEmbedString nsURL;
nsString nsURL;
location->GetHref(nsURL);
nsresult rv = NewURI(getter_AddRefs(nsURI), nsURL);
NS_ENSURE_SUCCESS(rv, FALSE);
@ -1595,9 +1549,9 @@ BOOL CBrowserWrapper::SaveURL(LPCTSTR url, LPCTSTR filename)
nsCOMPtr<nsIURI> nsURI;
#ifdef _UNICODE
nsresult rv = NewURI(getter_AddRefs(nsURI), nsEmbedString((WCHAR*)url));
nsresult rv = NewURI(getter_AddRefs(nsURI), nsString((WCHAR*)url));
#else
nsresult rv = NewURI(getter_AddRefs(nsURI), nsEmbedCString((char*)url));
nsresult rv = NewURI(getter_AddRefs(nsURI), nsCString((char*)url));
#endif
NS_ENSURE_SUCCESS(rv, FALSE);
@ -1616,12 +1570,12 @@ BOOL CBrowserWrapper::_Save(nsIURI* aURI,
// NEED better error handling
nsresult rv;
nsEmbedCString contentType;
nsCString contentType;
BOOL isHTML = FALSE;
if (aDocument)
{
nsEmbedString type;
nsString type;
rv = aDocument->GetContentType(type);
NS_UTF16ToCString(type, NS_CSTRING_ENCODING_ASCII, contentType);
@ -1711,7 +1665,7 @@ BOOL CBrowserWrapper::InputHasFocus(bool typeAhead)
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(domDoc));
if (!htmlDoc) return FALSE;
nsEmbedString designMode;
nsString designMode;
htmlDoc->GetDesignMode(designMode);
if (designMode.Equals(NS_LITERAL_STRING("on")))
return TRUE;
@ -1765,7 +1719,7 @@ BOOL CBrowserWrapper::IsInputOrObject(nsIDOMElement* element)
nsString attr;
element->GetAttribute(NS_LITERAL_STRING("contenteditable"), attr);
if (attr.Compare(NS_LITERAL_STRING("true")) == 0)
if (wcscmp(attr.get(), L"true") == 0)
return TRUE;
return FALSE;
@ -2030,7 +1984,7 @@ void CBrowserWrapper::SetWrapAround(BOOL wrap)
wchar_t* CBrowserWrapper::GetSearchString()
{
NS_ENSURE_TRUE(mFinder, NULL);
nsEmbedString stringBuf;
nsString stringBuf;
mFinder->GetSearchString(getter_Copies(stringBuf));
return wcsdup(stringBuf.get());
}

@ -314,9 +314,9 @@ public:
BOOL GetSHistoryState(int& index, int& count);
BOOL GetSHistoryInfoAt(PRInt32 index, CString& title, CString& url);
BOOL GetSelectionInsideForm(nsIDOMElement *element, nsEmbedString &aSelText);
BOOL GetSelectionInsideForm(nsIDOMElement *element, nsString &aSelText);
BOOL GetSelection(CString&);
BOOL GetUSelection(nsEmbedString&);
BOOL GetUSelection(nsString&);
BOOL InjectCSS(const wchar_t* userStyleSheet);
BOOL InjectJS(const wchar_t* userJS, CString& result, bool bTopWindow = true);
BOOL GetSecurityInfo(CString &sign);

@ -56,6 +56,7 @@ static const mozilla::Module::ContractIDEntry kBrowserContracts[] = {
{NS_PROMPTSERVICE_CONTRACTID, &kNS_PROMPTSERVICE_CID},
{"@mozilla.org/prompter;1", &kNS_PROMPTSERVICE_CID},
{NS_HELPERAPPLAUNCHERDLG_CONTRACTID, &kNS_UNKNOWNCONTENTTYPEHANDLER_CID},
{"@mozilla.org/uriloader/content-handler;1?type=application/k-skin", &kNS_UNKNOWNCONTENTTYPEHANDLER_CID},
{NS_COOKIEPROMPTSERVICE_CONTRACTID, &kNS_COOKIEPROMPTSERVICE_CID},
{NS_CERTIFICATEDIALOGS_CONTRACTID, &kNS_NSSDIALOGS_CID},
{NS_GENERATINGKEYPAIRINFODIALOGS_CONTRACTID, &kNS_NSSKEYPAIRDIALOGS_CID},
@ -63,6 +64,9 @@ static const mozilla::Module::ContractIDEntry kBrowserContracts[] = {
{"@mozilla.org/xre/app-info;1", &kNS_KMAPPINFO_CID},
{"@mozilla.org/toolkit/app-startup;1", &kNS_KMAPPINFO_CID},
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "home", &kNS_KMABOUT_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "permissions", &kNS_KMABOUT_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "preferences", &kNS_KMABOUT_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "downloads", &kNS_KMABOUT_CID },
{ NULL }
};

@ -28,7 +28,7 @@
extern CWnd* CWndForDOMWindow(nsIDOMWindow *aWindow);
NS_IMPL_ISUPPORTS1(CCookiePromptService, nsICookiePromptService)
NS_IMPL_ISUPPORTS(CCookiePromptService, nsICookiePromptService)
CCookiePromptService::CCookiePromptService(){
}
@ -42,7 +42,7 @@ NS_IMETHODIMP CCookiePromptService::CookieDialog(nsIDOMWindow *parent, nsICookie
CString q;
static BOOL accept = TRUE;
CString host = NSUTF8StringToCString(nsEmbedCString(hostname));
CString host = NSUTF8StringToCString(nsCString(hostname));
if (changingCookie)
q.Format(IDS_COOKIE_MODIFY, host);

@ -18,15 +18,14 @@
*/
#include "nsICookie.h"
#include "nsEmbedString.h"
#include "resource.h"
class CCookie {
public:
nsEmbedCString m_host;
nsEmbedCString m_name;
nsEmbedCString m_path;
nsCString m_host;
nsCString m_name;
nsCString m_path;
CString m_csHost;
CString m_csName;
CString m_csValue;
@ -44,12 +43,12 @@ public:
cookie->GetName(m_name);
m_csName = A2CT(m_name.get());
nsEmbedCString str;
nsCString str;
cookie->GetValue(str);
m_csValue = A2CT(str.get());
cookie->GetHost(m_host);
nsEmbedString _str;
nsString _str;
NS_CStringToUTF16(m_host, NS_CSTRING_ENCODING_UTF8, _str);
m_csHost = W2CT(_str.get());

@ -97,10 +97,13 @@ BOOL CCookiesViewerDlg::OnInitDialog()
enumCookie->HasMoreElements(&ret);
while (ret)
{
nsCOMPtr<nsICookie> nsCookie;
rv = enumCookie->GetNext(getter_AddRefs(nsCookie));
nsCOMPtr<nsISupports> nsSupport;
rv = enumCookie->GetNext(getter_AddRefs(nsSupport));
if (NS_FAILED(rv)) break;
nsCOMPtr<nsICookie> nsCookie = do_QueryInterface(nsSupport);
NS_ENSURE_TRUE(nsCookie, FALSE);
CCookie* cookie = new CCookie(nsCookie);
POSITION p = m_CookiesList.AddHead(cookie);

@ -26,48 +26,18 @@ Bug: Changing skin need to delete the iconcache.
#include "stdafx.h"
#ifdef INTERNAL_SITEICONS
#include "FavIconList.h"
#include "UnknownContentTypeHandler.h"
#include "nscWebBrowserPersist.h"
#include "imgILoader.h"
#include "imgIContainer.h"
#include "mfcembed.h"
#include "kmeleon_plugin.h"
#include "MozUtils.h"
#include "KmImage.h"
//#define PNG_SUPPORT
#ifdef PNG_SUPPORT
#define PNGDIB_NO_D2P
#define PNGDIB_S
#include "../pngdib-3.0.1/pngdib.h"
#ifdef _DEBUG
#pragma comment(lib,"../pngdib-3.0.1/lib/pngdib.lib")
#pragma comment(lib,"../lpng128/projects/visualc71/lib/libpng.lib")
#pragma comment(lib,"../lpng128/projects/visualc71/lib/zlib/zlib.lib")
#else
#ifdef _UNICODE
#pragma comment(lib,"../pngdib-3.0.1/lib/pngdib_u_s_md.lib")
#pragma comment(lib,"../lpng128/projects/visualc71/lib/libpng_u_md.lib")
#pragma comment(lib,"../lpng128/projects/visualc71/lib/zlib/zlib_u_md.lib")
#else
#pragma comment(lib,"../pngdib-3.0.1/lib/pngdib_s_md.lib")
#pragma comment(lib,"../lpng128/projects/visualc71/lib/libpng_md.lib")
#pragma comment(lib,"../lpng128/projects/visualc71/lib/zlib/zlib_md.lib")
#endif
#endif // _DEBUG
#endif
using namespace mozilla::gfx;
#define FAVICON_CACHE_FILE _T("IconCache.dat")
HBITMAP ResizeIcon32(HDC hDC, HBITMAP hBitmap, LONG w, LONG h)
HBITMAP ResizeIcon32(HDC hDC, HBITMAP hBitmap, int w, int h)
{
IWICImagingFactory *pImgFac;
HRESULT hr = CoCreateInstance(CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pImgFac));
@ -79,21 +49,21 @@ HBITMAP ResizeIcon32(HDC hDC, HBITMAP hBitmap, LONG w, LONG h)
BITMAPINFO bmi = {};
bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
bmi.bmiHeader.biWidth = 16;
bmi.bmiHeader.biHeight = -16;
bmi.bmiHeader.biWidth = w;
bmi.bmiHeader.biHeight = -h;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 32;
bmi.bmiHeader.biCompression = BI_RGB;
BYTE *pBits;
HBITMAP hbmp = CreateDIBSection(NULL, &bmi, DIB_RGB_COLORS, (void**)&pBits, NULL, 0);
IWICBitmapScaler* pIScaler;
hr = pImgFac->CreateBitmapScaler(&pIScaler);
hr = pIScaler->Initialize(NewBmp,16,16,WICBitmapInterpolationModeFant);
hr = pIScaler->Initialize(NewBmp,w,h,WICBitmapInterpolationModeFant);
WICRect rect = {0, 0, 16, 16};
hr = pIScaler->CopyPixels(&rect, 16 * 4, 16 * 16 * 4, pBits);
WICRect rect = {0, 0, w, h};
hr = pIScaler->CopyPixels(&rect, w * 4, w * h * 4, pBits);
if (!SUCCEEDED(hr)) return NULL;
pIScaler->Release();
@ -106,7 +76,8 @@ HBITMAP ResizeIcon32(HDC hDC, HBITMAP hBitmap, LONG w, LONG h)
HBITMAP ResizeIcon(HDC hDC, HBITMAP hBitmap, LONG w, LONG h)
{
HDC hDCs = CreateCompatibleDC(hDC);
BITMAP info;
::GetObject(hBitmap, sizeof(BITMAP), &info);
HGDIOBJ old = SelectObject(hDCs, hBitmap);
if (!old) {
DeleteDC(hDCs);
@ -114,11 +85,11 @@ HBITMAP ResizeIcon(HDC hDC, HBITMAP hBitmap, LONG w, LONG h)
}
HDC hdcScaled = CreateCompatibleDC(hDCs);
HBITMAP hbmSized = CreateCompatibleBitmap(hDCs, 16, 16);
HBITMAP hbmSized = CreateCompatibleBitmap(hDCs, w, h);
HGDIOBJ old2 = SelectObject(hdcScaled, hbmSized);
SetStretchBltMode(hdcScaled, HALFTONE);
SetStretchBltMode(hDCs, HALFTONE);
StretchBlt(hdcScaled,0,0,16,16,hDCs,0,0,w,h,SRCCOPY);
StretchBlt(hdcScaled,0,0,w,h,hDCs,0,0,info.bmWidth,info.bmHeight,SRCCOPY);
SelectObject(hdcScaled, old2);
DeleteDC(hdcScaled);
SelectObject(hDCs, old);
@ -135,7 +106,7 @@ CFavIconList::CFavIconList()
CFavIconList::~CFavIconList()
{
WriteCache();
//WriteCache();
}
BOOL CFavIconList::LoadCache()
@ -241,48 +212,6 @@ void CFavIconList::LoadDefaultIcon()
if (defaultIcon)
DestroyIcon(defaultIcon);
/*
if (theApp.FindSkinFile(szFullPath, _T("loader.bmp")))
{
HBITMAP hBitmap = (HBITMAP)LoadImage(NULL, szFullPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
if (hBitmap)
{
HDC hdcBitmap = CreateCompatibleDC(NULL);
HGDIOBJ oldBmp = SelectObject(hdcBitmap, hBitmap);
HBRUSH hBrush = CreateSolidBrush(RGB(255,0,255));
int cx, cy;
ImageList_GetIconSize(m_hImageList, &cx, &cy);
for (int i=0; i<8; i++)
{
CBitmap button;
HDC hdcButton = CreateCompatibleDC(hdcBitmap);
HBITMAP hButton = CreateCompatibleBitmap(hdcBitmap, cx, cy);
HGDIOBJ oldBmp2 = SelectObject(hdcButton, hButton);
// fill the button with the transparency
HGDIOBJ oldBrush = SelectObject(hdcButton, hBrush);
PatBlt(hdcButton, 0, 0, cx, cy, PATCOPY);
// copy the button from the full bitmap
BitBlt(hdcButton, 0, 0, cx, cy, hdcBitmap, cx*i, 0, SRCCOPY);
SelectObject(hdcButton, oldBrush);
SelectObject(hdcButton, oldBmp2);
DeleteDC(hdcButton);
CBitmap bmp;
bmp.Attach(hButton);
Add(&bmp, RGB(255,0,255));
}
SelectObject(hdcBitmap, oldBmp);
DeleteObject(hBrush);
DeleteDC(hdcBitmap);
DeleteObject(hBitmap);
}
}
*/
m_iOffset = GetImageCount();
}
@ -313,7 +242,7 @@ void CFavIconList::AddMap(const char *uri, int index, const char* pageUri)
// It's not really good to do it like that, because a site may
// have several different icons.
nsCOMPtr<nsIURI> URI;
nsEmbedCString nsUri;
nsCString nsUri;
nsUri.Assign(pageUri && pageUri[0] ? pageUri : uri);
nsresult rv = NewURI(getter_AddRefs(URI), nsUri);
if (NS_SUCCEEDED(rv)) {
@ -363,53 +292,7 @@ int CFavIconList::AddDownloadedIcon(char* uri, TCHAR* file, nsresult aStatus)
if (favicon){
index = AddIcon(uri, favicon);
DestroyIcon(favicon);
}
#ifdef PNG_SUPPORT
else
{
PNGDIB *pngdib = pngdib_p2d_init();
if (pngdib)
{
int errcode;
LPBITMAPINFOHEADER pdib;
int dib_size;
void *pdib_bits;
int bits_offs;
pngdib_p2d_set_png_filename(pngdib, file);
pngdib_p2d_set_custom_bg(pngdib, 192, 192, 192);
//pngdib_set_dibalpha32(pngdib, 1); // Can be used with Comctl32 Ver. 6 only
pngdib_p2d_set_use_file_bg(pngdib, 1);
errcode=pngdib_p2d_run(pngdib);
if(!errcode) {
pngdib_p2d_get_dib(pngdib,&pdib,&dib_size);
pngdib_p2d_get_dibbits(pngdib,&pdib_bits,&bits_offs,NULL);
HDC hDC = GetDC(NULL);
HBITMAP hBitmap = ::CreateDIBitmap(hDC,pdib,CBM_INIT,pdib_bits,(BITMAPINFO*)pdib,DIB_RGB_COLORS);
ReleaseDC(NULL,hDC);
CBitmap bitmap;
bitmap.Attach(hBitmap);
unsigned char pr,pg,pb;
int r = pngdib_p2d_get_bgcolor(pngdib, &pr, &pg, &pb);
if (r)
index = AddIcon(uri, &bitmap,RGB(pr,pg,pb));
else
index = AddIcon(uri, &bitmap, (CBitmap*)NULL);
bitmap.DeleteObject();
pngdib_p2d_free_dib(pngdib,NULL);
}
pngdib_done(pngdib);
}
}
#endif
}
}
DeleteFile(file);
return index;
@ -429,7 +312,7 @@ int CFavIconList::GetHostIcon(const TCHAR* aUrl)
const char* url;
#ifdef _UNICODE
nsEmbedCString _str;
nsCString _str;
NS_UTF16ToCString(nsDependentString(aUrl), NS_CSTRING_ENCODING_UTF8, _str);
url = _str.get();
#else
@ -437,7 +320,7 @@ int CFavIconList::GetHostIcon(const TCHAR* aUrl)
#endif
nsCOMPtr<nsIURI> URI;
nsEmbedCString nsUri;
nsCString nsUri;
nsUri.Assign(url);
nsresult rv = NewURI(getter_AddRefs(URI), nsUri);
if (NS_FAILED(rv)||!URI) return index;
@ -457,7 +340,7 @@ int CFavIconList::GetIcon(nsIURI *aURI, nsIURI* aPageURI, BOOL download)
if (!m_hImageList || !aURI) return 0;
nsEmbedCString nsUri;
nsCString nsUri;
aURI->GetSpec(nsUri);
USES_CONVERSION;
if (m_urlMap.Lookup(A2CT(nsUri.get()), index))
@ -474,7 +357,7 @@ void CFavIconList::RefreshIcon(nsIURI* aURI)
return;
int index = 0;
nsEmbedCString nsUri;
nsCString nsUri;
aURI->GetSpec(nsUri);
USES_CONVERSION;
@ -573,7 +456,7 @@ void CFavIconList::DwnCall(char* uri, TCHAR* file, nsresult status, void* param)
}
NS_IMPL_ISUPPORTS1(IconObserver, imgINotificationObserver)
NS_IMPL_ISUPPORTS(IconObserver, imgINotificationObserver)
NS_IMETHODIMP IconObserver::Notify(imgIRequest *aProxy, int32_t aType, const nsIntRect *aRect)
{
if (aType == imgINotificationObserver::LOAD_COMPLETE)
@ -619,7 +502,6 @@ struct ALPHABITMAPINFO {
}
}
};
static HBITMAP DataToBitmap(PRUint8* aImageData,
PRUint32 aWidth,
PRUint32 aHeight,
@ -688,6 +570,78 @@ static HBITMAP DataToBitmap(PRUint8* aImageData,
}
static void
ConvertBGRXToBGRA(uint8_t* aData, const IntSize &aSize, int32_t aStride)
{
uint32_t* pixel = reinterpret_cast<uint32_t*>(aData);
for (int row = 0; row < aSize.height; ++row) {
for (int column = 0; column < aSize.width; ++column) {
#ifdef IS_BIG_ENDIAN
pixel[column] |= 0x000000FF;
#else
pixel[column] |= 0xFF000000;
#endif
}
pixel += (aStride/4);
}
}
static void
CopySurfaceDataToPackedArray(uint8_t* aSrc, uint8_t* aDst, IntSize aSrcSize,
int32_t aSrcStride, int32_t aBytesPerPixel)
{
MOZ_ASSERT(aBytesPerPixel > 0,
"Negative stride for aDst not currently supported");
int packedStride = aSrcSize.width * aBytesPerPixel;
if (aSrcStride == packedStride) {
// aSrc is already packed, so we can copy with a single memcpy.
memcpy(aDst, aSrc, packedStride * aSrcSize.height);
} else {
// memcpy one row at a time.
for (int row = 0; row < aSrcSize.height; ++row) {
memcpy(aDst, aSrc, packedStride);
aSrc += aSrcStride;
aDst += packedStride;
}
}
}
static uint8_t* SurfaceToPackedBGRA(DataSourceSurface *aSurface)
{
SurfaceFormat format = aSurface->GetFormat();
if (format != SurfaceFormat::B8G8R8A8 && format != SurfaceFormat::B8G8R8X8) {
return nullptr;
}
IntSize size = aSurface->GetSize();
uint8_t* imageBuffer = new (std::nothrow) uint8_t[size.width * size.height * sizeof(uint32_t)];
if (!imageBuffer) {
return nullptr;
}
DataSourceSurface::MappedSurface map;
if (!aSurface->Map(DataSourceSurface::READ, &map)) {
delete [] imageBuffer;
return nullptr;
}
CopySurfaceDataToPackedArray(map.mData, imageBuffer, size,
map.mStride, 4 * sizeof(uint8_t));
aSurface->Unmap();
if (format == SurfaceFormat::B8G8R8X8) {
// Convert BGRX to BGRA by setting a to 255.
ConvertBGRXToBGRA(reinterpret_cast<uint8_t *>(imageBuffer), size, size.width * sizeof(uint32_t));
}
return imageBuffer;
}
uint8_t* Data32BitTo1Bit(uint8_t* aImageData,
uint32_t aWidth, uint32_t aHeight)
{
@ -720,100 +674,71 @@ uint8_t* Data32BitTo1Bit(uint8_t* aImageData,
return outData;
}
HBITMAP CreateIcon(imgIContainer *aContainer, gfxIntSize aScaledSize) {
// Get the image data
nsRefPtr<gfxASurface> surface;
aContainer->GetFrame(imgIContainer::FRAME_CURRENT,
imgIContainer::FLAG_SYNC_DECODE,
getter_AddRefs(surface));
NS_ENSURE_TRUE(surface, NULL);
nsRefPtr<gfxImageSurface> frame(surface->GetAsReadableARGB32ImageSurface());
NS_ENSURE_TRUE(frame, NULL);
int32_t width = frame->Width();
int32_t height = frame->Height();
if (!width || !height)
return NULL;
uint8_t *data;
nsRefPtr<gfxImageSurface> dest;
data = frame->Data();
/*
if ((aScaledSize.width == 0 && aScaledSize.height == 0) ||
(aScaledSize.width == width && aScaledSize.height == height)) {
// We're not scaling the image. The data is simply what's in the frame.
}
else {
NS_ENSURE_TRUE(aScaledSize.width > 0, NULL);
NS_ENSURE_TRUE(aScaledSize.height > 0, NULL);
// Draw a scaled version of the image to a temporary surface
dest = new gfxImageSurface(aScaledSize, gfxImageFormatARGB32);
if (!dest)
return NULL;
gfxContext ctx(dest);
// Set scaling
gfxFloat sw = (double) aScaledSize.width / width;
gfxFloat sh = (double) aScaledSize.height / height;
ctx.Scale(sw, sh);
// Paint a scaled image
ctx.SetOperator(gfxContext::OPERATOR_SOURCE);
ctx.SetSource(frame);
ctx.Paint();
data = dest->Data();
width = aScaledSize.width;
height = aScaledSize.height;
}*/
HBITMAP bmp = DataToBitmap(data, width, -height, 32);
return bmp;/*
uint8_t* a1data = Data32BitTo1Bit(data, width, height);
if (!a1data) {
return NS_ERROR_FAILURE;
}
HBITMAP mbmp = DataToBitmap(a1data, width, -height, 1);
free(a1data);
ICONINFO info = {0};
info.fIcon = !aIsCursor;
info.xHotspot = aHotspotX;
info.yHotspot = aHotspotY;
info.hbmMask = mbmp;
info.hbmColor = bmp;
HCURSOR icon = ::CreateIconIndirect(&info);
::DeleteObject(mbmp);
::DeleteObject(bmp);
if (!icon)
return NS_ERROR_FAILURE;
*aIcon = icon;
return NS_OK;*/
}
NS_IMETHODIMP IconObserver::CreateDIB(imgIRequest *aRequest)
{
nsresult rv;
nsCOMPtr<imgIContainer> image;
rv = aRequest->GetImage(getter_AddRefs(image));
nsCOMPtr<imgIContainer> container;
rv = aRequest->GetImage(getter_AddRefs(container));
NS_ENSURE_SUCCESS(rv, rv);
gfxIntSize s(16,16);
HBITMAP hBitmap = CreateIcon(image, s);
#ifdef _DEBUG
// There is a problem with the linking in debug
return NS_ERROR_FAILURE;
#endif
// Get the image data
mozilla::RefPtr<SourceSurface> surface;
surface = container->GetFrame(imgIContainer::FRAME_CURRENT,
imgIContainer::FLAG_SYNC_DECODE | imgIContainer::FLAG_WANT_DATA_SURFACE );
NS_ENSURE_TRUE(surface, NS_ERROR_FAILURE);
surface->GetFormat();
//surface->GetDataSurface();
mozilla::RefPtr<DataSourceSurface> dataSurface;
DataSourceSurface::MappedSurface map;
bool mappedOK;
if (surface->GetFormat() != mozilla::gfx::SurfaceFormat::B8G8R8A8) {
// Convert format to SurfaceFormat::B8G8R8A8
//dataSurface = gfxUtils::CopySurfaceToDataSourceSurfaceWithFormat(surface, SurfaceFormat::B8G8R8A8);
//NS_ENSURE_TRUE(dataSurface, NULL);
//mappedOK = dataSurface->Map(mozilla::gfx::DataSourceSurface::MapType::READ, &map);
} else {
dataSurface = surface->GetDataSurface();
NS_ENSURE_TRUE(dataSurface, NS_ERROR_FAILURE);
mappedOK = dataSurface->Map(mozilla::gfx::DataSourceSurface::READ, &map);
}
NS_ENSURE_TRUE(dataSurface && mappedOK, NS_ERROR_FAILURE);
//MOZ_ASSERT(dataSurface->GetFormat() == mozilla::gfx::SurfaceFormat::B8G8R8A8);