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.

git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@465 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
stippi
2012-07-03 15:43:41 +02:00
committed by Alexandre Deckner
parent 50c66f3857
commit 65cc5e49ee
3 changed files with 103 additions and 7 deletions
+10 -2
View File
@@ -1174,8 +1174,14 @@ BrowserWindow::_TabChanged(int32 index)
// 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 @@ BrowserWindow::_SetPageIcon(BWebView* view, const BBitmap* icon)
// the TabManager for display in the respective tab.
userData->SetPageIcon(icon);
fTabManager->SetTabIcon(view, userData->PageIcon());
if (view == CurrentWebView())
fURLInputGroup->SetPageIcon(icon);
}
+89 -5
View File
@@ -128,7 +128,7 @@ private:
// #pragma mark - URLTextView
static const float kHorizontalTextRectInset = 3.0;
static const float kHorizontalTextRectInset = 4.0;
class URLInputGroup::URLTextView : public BTextView {
@@ -505,9 +505,14 @@ public:
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 @@ private:
};
// #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 @@ URLInputGroup::URLInputGroup(BMessage* goMessage)
{
GroupLayout()->SetInsets(2, 2, 2, 2);
fIconView = new PageIconView();
GroupLayout()->AddView(fIconView, 0.0f);
fTextView = new URLTextView(this);
AddChild(fTextView);
@@ -537,7 +615,7 @@ URLInputGroup::URLInputGroup(BMessage* goMessage)
// 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 @@ URLInputGroup::GoButton() const
}
void
URLInputGroup::SetPageIcon(const BBitmap* icon)
{
fIconView->SetIcon(icon);
}
+4
View File
@@ -27,9 +27,13 @@ public:
BButton* GoButton() const;
void SetPageIcon(const BBitmap* icon);
private:
class PageIconView;
class URLTextView;
PageIconView* fIconView;
URLTextView* fTextView;
BButton* fGoButton;
bool fWindowActive;