[haiku-webkit-commits] r465 - webkit/trunk/WebKit/haiku/WebPositive

  • From: webkit@xxxxxxxxxxxxxxx
  • To: haiku-webkit-commits@xxxxxxxxxxxxx
  • Date: Fri, 30 Apr 2010 15:08:05 +0000

Author: stippi
Date: Fri Apr 30 15:08:05 2010
New Revision: 465
URL: http://mmlr.dyndns.org/changeset/465

Log:
The favicon is now also displayed in the URL input view. Mostly because one is
used to it, but also when only one page is open and tabs are not displayed as
per the user settings, the favicon would then not be visible.

Modified:
   webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp
   webkit/trunk/WebKit/haiku/WebPositive/URLInputGroup.cpp
   webkit/trunk/WebKit/haiku/WebPositive/URLInputGroup.h

Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp     Fri Apr 30 
14:05:35 2010        (r464)
+++ webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp     Fri Apr 30 
15:08:05 2010        (r465)
@@ -1174,8 +1174,14 @@
                // Restore the previous focus or focus the web view.
                PageUserData* userData = static_cast<PageUserData*>(
                        webView->GetUserData());
-               if (userData != NULL && userData->FocusedView() != NULL)
-                       userData->FocusedView()->MakeFocus(true);
+               BView* focusedView = NULL;
+               if (userData != NULL) {
+                       focusedView = userData->FocusedView();
+                       fURLInputGroup->SetPageIcon(userData->PageIcon());
+               }
+               
+               if (focusedView != NULL)
+                       focusedView->MakeFocus(true);
                else
                        webView->MakeFocus(true);
 
@@ -1443,6 +1449,8 @@
        // the TabManager for display in the respective tab.
        userData->SetPageIcon(icon);
        fTabManager->SetTabIcon(view, userData->PageIcon());
+       if (view == CurrentWebView())
+               fURLInputGroup->SetPageIcon(icon);
 }
 
 

Modified: webkit/trunk/WebKit/haiku/WebPositive/URLInputGroup.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/URLInputGroup.cpp     Fri Apr 30 
14:05:35 2010        (r464)
+++ webkit/trunk/WebKit/haiku/WebPositive/URLInputGroup.cpp     Fri Apr 30 
15:08:05 2010        (r465)
@@ -128,7 +128,7 @@
 // #pragma mark - URLTextView
 
 
-static const float kHorizontalTextRectInset = 3.0;
+static const float kHorizontalTextRectInset = 4.0;
 
 
 class URLInputGroup::URLTextView : public BTextView {
@@ -505,9 +505,14 @@
                        SetHighColor(0, 0, 0, 120);
                }
 
-               BPoint bitmapLocation(kFrameInset, kFrameInset);
-               if (Value() == B_CONTROL_ON)
-                       bitmapLocation += BPoint(1, 1);
+               if (fBitmap == NULL)
+                       return;
+               BRect bitmapBounds(fBitmap->Bounds());
+               BPoint bitmapLocation(
+                       floorf((bounds.left + bounds.right
+                               - (bitmapBounds.left + bitmapBounds.right)) / 2 
+ 0.5f),
+                       floorf((bounds.top + bounds.bottom
+                               - (bitmapBounds.top + bitmapBounds.bottom)) / 2 
+ 0.5f));
 
                DrawBitmap(fBitmap, bitmapLocation);
        }
@@ -517,6 +522,76 @@
 };
 
 
+// #pragma mark - IconView
+
+
+class URLInputGroup::PageIconView : public BView {
+public:
+       PageIconView()
+               :
+               BView("page icon view", B_WILL_DRAW),
+               fIcon(NULL)
+       {
+               SetDrawingMode(B_OP_OVER);
+       }
+
+       ~PageIconView()
+       {
+               delete fIcon;
+       }
+
+       virtual void Draw(BRect updateRect)
+       {
+               if (fIcon == NULL)
+                       return;
+
+               BRect bounds(Bounds());
+               BRect iconBounds(fIcon->Bounds());
+               BPoint iconPos(
+                       floorf((bounds.left + bounds.right
+                               - (iconBounds.left + iconBounds.right)) / 2 + 
0.5f),
+                       floorf((bounds.top + bounds.bottom
+                               - (iconBounds.top + iconBounds.bottom)) / 2 + 
0.5f));
+               DrawBitmap(fIcon, iconPos);
+       }
+
+       virtual BSize MinSize()
+       {
+               if (fIcon != NULL) {
+                       return BSize(fIcon->Bounds().Width() + 3,
+                               fIcon->Bounds().Height() + 3);
+               }
+               return BSize(0, 0);
+       }
+
+       virtual BSize MaxSize()
+       {
+               return BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED);
+       }
+
+       virtual BSize PreferredSize()
+       {
+               return MinSize();
+       }
+
+       void SetIcon(const BBitmap* icon)
+       {
+               if (icon == NULL && fIcon == NULL)
+                       return;
+               delete fIcon;
+               if (icon)
+                       fIcon = new BBitmap(icon);
+               else
+                       fIcon = NULL;
+               Invalidate();
+               InvalidateLayout();
+       }
+
+private:
+       BBitmap* fIcon;
+};
+
+
 // #pragma mark - URLInputGroup
 
 
@@ -527,6 +602,9 @@
 {
        GroupLayout()->SetInsets(2, 2, 2, 2);
 
+       fIconView = new PageIconView();
+       GroupLayout()->AddView(fIconView, 0.0f);
+
        fTextView = new URLTextView(this);
        AddChild(fTextView);
 
@@ -537,7 +615,7 @@
 //     fGoButton = new BitmapButton("kActionGo", NULL);
        fGoButton = new BitmapButton(kGoBitmapBits, kGoBitmapWidth,
                kGoBitmapHeight, kGoBitmapFormat, goMessage);
-       GroupLayout()->AddView(fGoButton, 0.0);
+       GroupLayout()->AddView(fGoButton, 0.0f);
 
        SetFlags(Flags() | B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE);
        SetLowColor(ViewColor());
@@ -622,3 +700,9 @@
 }
 
 
+void
+URLInputGroup::SetPageIcon(const BBitmap* icon)
+{
+       fIconView->SetIcon(icon);
+}
+

Modified: webkit/trunk/WebKit/haiku/WebPositive/URLInputGroup.h
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/URLInputGroup.h       Fri Apr 30 
14:05:35 2010        (r464)
+++ webkit/trunk/WebKit/haiku/WebPositive/URLInputGroup.h       Fri Apr 30 
15:08:05 2010        (r465)
@@ -27,9 +27,13 @@
 
                        BButton*                        GoButton() const;
 
+                       void                            SetPageIcon(const 
BBitmap* icon);
+
 private:
+                       class PageIconView;
                        class URLTextView;
 
+                       PageIconView*           fIconView;
                        URLTextView*            fTextView;
                        BButton*                        fGoButton;
                        bool                            fWindowActive;

Other related posts:

  • » [haiku-webkit-commits] r465 - webkit/trunk/WebKit/haiku/WebPositive - webkit