[haiku-webkit-commits] r412 - in webkit/trunk: WebCore/platform/graphics WebKit/haiku/API

  • From: webkit@xxxxxxxxxxxxxxx
  • To: haiku-webkit-commits@xxxxxxxxxxxxx
  • Date: Tue, 13 Apr 2010 23:11:44 +0000

Author: stippi
Date: Tue Apr 13 23:11:44 2010
New Revision: 412
URL: http://mmlr.dyndns.org/changeset/412

Log:
* Make some useful methods in BitmapImage.h public.
* In BWebSettings, when retrieving the favicon, try to retrieve the icon
  with the best size from multi-bitmap icons. Fixes ticket #12.

Modified:
   webkit/trunk/WebCore/platform/graphics/BitmapImage.h
   webkit/trunk/WebKit/haiku/API/WebSettings.cpp

Modified: webkit/trunk/WebCore/platform/graphics/BitmapImage.h
==============================================================================
--- webkit/trunk/WebCore/platform/graphics/BitmapImage.h        Tue Apr 13 
23:07:33 2010        (r411)
+++ webkit/trunk/WebCore/platform/graphics/BitmapImage.h        Tue Apr 13 
23:11:44 2010        (r412)
@@ -178,6 +178,7 @@
     virtual BBitmap* getBBitmap() const;
 #endif
 
+public:
     size_t currentFrame() const { return m_currentFrame; }
     size_t frameCount();
     NativeImagePtr frameAtIndex(size_t);
@@ -185,6 +186,7 @@
     float frameDurationAtIndex(size_t);
     bool frameHasAlphaAtIndex(size_t); 
 
+protected:
     // Decodes and caches a frame. Never accessed except internally.
     void cacheFrame(size_t index);
 

Modified: webkit/trunk/WebKit/haiku/API/WebSettings.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebSettings.cpp       Tue Apr 13 23:07:33 
2010        (r411)
+++ webkit/trunk/WebKit/haiku/API/WebSettings.cpp       Tue Apr 13 23:11:44 
2010        (r412)
@@ -29,6 +29,7 @@
 #include "WebSettings.h"
 
 #include "ApplicationCacheStorage.h"
+#include "BitmapImage.h"
 #include "DatabaseTracker.h"
 #include "IconDatabase.h"
 #include "Image.h"
@@ -364,14 +365,29 @@
                || message->FindMessenger("target", &target) != B_OK) {
                return;
        }
+       WebCore::IntSize iconSize(16, 16);
     WebCore::Image* image = 
WebCore::iconDatabase()->iconForPageURL(url.String(),
-        WebCore::IntSize(16, 16));
+        iconSize);
 
        reply.RemoveName("url");
        reply.RemoveName("icon");
     reply.AddString("url", url.String());
     if (image) {
-        const BBitmap* bitmap = image->nativeImageForCurrentFrame();
+        const BBitmap* bitmap = 0;
+       if (image->isBitmapImage()) {
+               WebCore::BitmapImage* bitmapImage = 
static_cast<WebCore::BitmapImage*>(image);
+               size_t count = bitmapImage->frameCount();
+               for (size_t i = 0; i < count; i++) {
+                       bitmap = bitmapImage->frameAtIndex(i);
+                       if (bitmap->Bounds().IntegerWidth() + 1 == 
iconSize.width()
+                               && bitmap->Bounds().IntegerHeight() + 1 == 
iconSize.height()) {
+                               break;
+                       } else
+                               bitmap = 0;
+               }
+       }
+        if (!bitmap)
+               bitmap = image->nativeImageForCurrentFrame();
         BMessage iconArchive;
         if (bitmap && bitmap->Archive(&iconArchive) == B_OK)
             reply.AddMessage("icon", &iconArchive);

Other related posts:

  • » [haiku-webkit-commits] r412 - in webkit/trunk: WebCore/platform/graphics WebKit/haiku/API - webkit