[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
darin
darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:53:23 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 01481afe3bbfd41f5494a160144488575600ab8c
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Oct 23 23:17:33 2002 +0000
WebFoundation:
* English.lproj/StringsNotToBeLocalized.txt:
WebCore:
- finished up the job of moving the file button to WebKit
I did this mainly for localization reasons.
* kwq/KWQFileButton.h: Remove filename(), add filenameChanged(),
make KWQFileButton be a QWidget subclass, not a QPushButton one.
Remove clicked() and paint() virtual functions, _filename, _icon,
and _label data members.
* kwq/KWQFileButton.mm:
(KWQFileButton::KWQFileButton): Just make a WebCoreFileButton.
(KWQFileButton::~KWQFileButton): Less to do here now.
(KWQFileButton::setFilename): Call the button to do the work.
(KWQFileButton::sizeHint): Ditto.
(KWQFileButton::frameGeometry): Ditto.
(KWQFileButton::setFrameGeometry): Ditto.
(KWQFileButton::baselinePosition): Ditto.
(KWQFileButton::filenameChanged): Added. Sends message.
(-[KWQFileButtonAdapter initWithKWQFileButton:]): Observe the "filename
changed notification".
(-[KWQFileButtonAdapter dealloc]): Stop observing.
(-[KWQFileButtonAdapter filenameChanged:]): Send a signal when the notification
comes in, so KHTML finds out.
* kwq/KWQSlot.mm:
(KWQSlot::KWQSlot): Remove handling for RenderFileButton slotReturnPressed.
(KWQSlot::call): Ditto.
* kwq/WebCoreViewFactory.h: Remove bestSize. Add setVisualFrame, visualFrame, and
bestVisualFrameSize.
* kwq/KWQInputDialog.mm: Tweaked includes. Long-term we want to use "", not <>.
* kwq/KWQKConfigBase.mm: Ditto.
* kwq/KWQKHTMLPartImpl.mm: Ditto.
WebKit:
- finished up the job of moving the file button here from WebCore.
I did this mainly for localization reasons.
* WebCoreSupport.subproj/WebFileButton.m:
(-[WebFileButton initWithFrame:]): Set up button control size, font, bezel style,
target, and action. Also add it as a subview.
(-[WebFileButton drawRect:]): Center icon in the "visual frame" part of the view,
not the entire bounds.
(-[WebFileButton setFilename:]): Don't show any icon when the filename is empty.
(-[WebFileButton bestVisualFrameSize]): Implemented this.
(-[WebFileButton visualFrame]): Ditto.
(-[WebFileButton setVisualFrame:]): Ditto.
(-[WebFileButton baseline]): Ditto.
(-[WebFileButton beginSheet]): Added. Shared between button presses and other clicks.
(-[WebFileButton chooseButtonPressed:]): Call beginSheet.
(-[WebFileButton mouseDown:]): Ditto.
(-[WebFileButton openPanelDidEnd:returnCode:contextInfo:]): Send the notification,
WebCoreFileButtonFilenameChanged, when the filename is changed.
* WebView.subproj/WebController.m: (-[WebController policyDelegate]):
Add a FIXME about the leak I found here.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2440 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index 731e15e..b21619e 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,39 @@
+2002-10-23 Darin Adler <darin at apple.com>
+
+ - finished up the job of moving the file button to WebKit
+
+ I did this mainly for localization reasons.
+
+ * kwq/KWQFileButton.h: Remove filename(), add filenameChanged(),
+ make KWQFileButton be a QWidget subclass, not a QPushButton one.
+ Remove clicked() and paint() virtual functions, _filename, _icon,
+ and _label data members.
+ * kwq/KWQFileButton.mm:
+ (KWQFileButton::KWQFileButton): Just make a WebCoreFileButton.
+ (KWQFileButton::~KWQFileButton): Less to do here now.
+ (KWQFileButton::setFilename): Call the button to do the work.
+ (KWQFileButton::sizeHint): Ditto.
+ (KWQFileButton::frameGeometry): Ditto.
+ (KWQFileButton::setFrameGeometry): Ditto.
+ (KWQFileButton::baselinePosition): Ditto.
+ (KWQFileButton::filenameChanged): Added. Sends message.
+ (-[KWQFileButtonAdapter initWithKWQFileButton:]): Observe the "filename
+ changed notification".
+ (-[KWQFileButtonAdapter dealloc]): Stop observing.
+ (-[KWQFileButtonAdapter filenameChanged:]): Send a signal when the notification
+ comes in, so KHTML finds out.
+
+ * kwq/KWQSlot.mm:
+ (KWQSlot::KWQSlot): Remove handling for RenderFileButton slotReturnPressed.
+ (KWQSlot::call): Ditto.
+
+ * kwq/WebCoreViewFactory.h: Remove bestSize. Add setVisualFrame, visualFrame, and
+ bestVisualFrameSize.
+
+ * kwq/KWQInputDialog.mm: Tweaked includes. Long-term we want to use "", not <>.
+ * kwq/KWQKConfigBase.mm: Ditto.
+ * kwq/KWQKHTMLPartImpl.mm: Ditto.
+
2002-10-23 Chris Blumenberg <cblu at apple.com>
Call the arguments for plug-ins "attributes" everywhere.
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 731e15e..b21619e 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,39 @@
+2002-10-23 Darin Adler <darin at apple.com>
+
+ - finished up the job of moving the file button to WebKit
+
+ I did this mainly for localization reasons.
+
+ * kwq/KWQFileButton.h: Remove filename(), add filenameChanged(),
+ make KWQFileButton be a QWidget subclass, not a QPushButton one.
+ Remove clicked() and paint() virtual functions, _filename, _icon,
+ and _label data members.
+ * kwq/KWQFileButton.mm:
+ (KWQFileButton::KWQFileButton): Just make a WebCoreFileButton.
+ (KWQFileButton::~KWQFileButton): Less to do here now.
+ (KWQFileButton::setFilename): Call the button to do the work.
+ (KWQFileButton::sizeHint): Ditto.
+ (KWQFileButton::frameGeometry): Ditto.
+ (KWQFileButton::setFrameGeometry): Ditto.
+ (KWQFileButton::baselinePosition): Ditto.
+ (KWQFileButton::filenameChanged): Added. Sends message.
+ (-[KWQFileButtonAdapter initWithKWQFileButton:]): Observe the "filename
+ changed notification".
+ (-[KWQFileButtonAdapter dealloc]): Stop observing.
+ (-[KWQFileButtonAdapter filenameChanged:]): Send a signal when the notification
+ comes in, so KHTML finds out.
+
+ * kwq/KWQSlot.mm:
+ (KWQSlot::KWQSlot): Remove handling for RenderFileButton slotReturnPressed.
+ (KWQSlot::call): Ditto.
+
+ * kwq/WebCoreViewFactory.h: Remove bestSize. Add setVisualFrame, visualFrame, and
+ bestVisualFrameSize.
+
+ * kwq/KWQInputDialog.mm: Tweaked includes. Long-term we want to use "", not <>.
+ * kwq/KWQKConfigBase.mm: Ditto.
+ * kwq/KWQKHTMLPartImpl.mm: Ditto.
+
2002-10-23 Chris Blumenberg <cblu at apple.com>
Call the arguments for plug-ins "attributes" everywhere.
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 731e15e..b21619e 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,39 @@
+2002-10-23 Darin Adler <darin at apple.com>
+
+ - finished up the job of moving the file button to WebKit
+
+ I did this mainly for localization reasons.
+
+ * kwq/KWQFileButton.h: Remove filename(), add filenameChanged(),
+ make KWQFileButton be a QWidget subclass, not a QPushButton one.
+ Remove clicked() and paint() virtual functions, _filename, _icon,
+ and _label data members.
+ * kwq/KWQFileButton.mm:
+ (KWQFileButton::KWQFileButton): Just make a WebCoreFileButton.
+ (KWQFileButton::~KWQFileButton): Less to do here now.
+ (KWQFileButton::setFilename): Call the button to do the work.
+ (KWQFileButton::sizeHint): Ditto.
+ (KWQFileButton::frameGeometry): Ditto.
+ (KWQFileButton::setFrameGeometry): Ditto.
+ (KWQFileButton::baselinePosition): Ditto.
+ (KWQFileButton::filenameChanged): Added. Sends message.
+ (-[KWQFileButtonAdapter initWithKWQFileButton:]): Observe the "filename
+ changed notification".
+ (-[KWQFileButtonAdapter dealloc]): Stop observing.
+ (-[KWQFileButtonAdapter filenameChanged:]): Send a signal when the notification
+ comes in, so KHTML finds out.
+
+ * kwq/KWQSlot.mm:
+ (KWQSlot::KWQSlot): Remove handling for RenderFileButton slotReturnPressed.
+ (KWQSlot::call): Ditto.
+
+ * kwq/WebCoreViewFactory.h: Remove bestSize. Add setVisualFrame, visualFrame, and
+ bestVisualFrameSize.
+
+ * kwq/KWQInputDialog.mm: Tweaked includes. Long-term we want to use "", not <>.
+ * kwq/KWQKConfigBase.mm: Ditto.
+ * kwq/KWQKHTMLPartImpl.mm: Ditto.
+
2002-10-23 Chris Blumenberg <cblu at apple.com>
Call the arguments for plug-ins "attributes" everywhere.
diff --git a/WebCore/kwq/KWQFileButton.h b/WebCore/kwq/KWQFileButton.h
index 90f5551..6b91041 100644
--- a/WebCore/kwq/KWQFileButton.h
+++ b/WebCore/kwq/KWQFileButton.h
@@ -26,40 +26,31 @@
#ifndef KWQFILEBUTTON_H
#define KWQFILEBUTTON_H
-#include <qpushbutton.h>
+#include <qwidget.h>
#ifdef __OBJC__
@class KWQFileButtonAdapter;
- at class NSImage;
- at class NSString;
#else
class KWQFileButtonAdapter;
-class NSImage;
-class NSString;
#endif
-class KWQFileButton : public QPushButton {
+class KWQFileButton : public QWidget {
public:
KWQFileButton();
~KWQFileButton();
void setFilename(const QString &);
- QString filename() const { return _filename; }
QSize sizeHint() const;
QRect frameGeometry() const;
void setFrameGeometry(const QRect &);
int baselinePosition() const;
+
+ void filenameChanged();
private:
- virtual void clicked();
- virtual void paint(QPainter *, const QRect &);
-
KWQSignal _textChanged;
- QString _filename;
KWQFileButtonAdapter *_adapter;
- NSImage *_icon;
- NSString *_label;
};
#endif
diff --git a/WebCore/kwq/KWQFileButton.mm b/WebCore/kwq/KWQFileButton.mm
index 631a5b6..8d6d4fd 100644
--- a/WebCore/kwq/KWQFileButton.mm
+++ b/WebCore/kwq/KWQFileButton.mm
@@ -25,20 +25,7 @@
#import "KWQFileButton.h"
-// FIXME: These need to be localized.
-#define BUTTON_LABEL ("Choose File")
-#define NO_FILE_SELECTED (@"no file selected")
-
-#define AFTER_BUTTON_SPACING 4
-#define ICON_HEIGHT 16
-#define ICON_WIDTH 16
-#define ICON_FILENAME_SPACING 2
-// FIXME: Is it OK to hard-code the width of the filename part of this control?
-#define FILENAME_WIDTH 200
-
-#define ADDITIONAL_WIDTH (AFTER_BUTTON_SPACING + ICON_WIDTH + ICON_FILENAME_SPACING + FILENAME_WIDTH)
-
-// FIXME: Clicks on the text should pull up the sheet too.
+#import "WebCoreViewFactory.h"
@interface KWQFileButtonAdapter : NSObject
{
@@ -46,16 +33,13 @@
}
- initWithKWQFileButton:(KWQFileButton *)button;
-- (void)openPanelDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
@end
KWQFileButton::KWQFileButton()
- : QPushButton(BUTTON_LABEL, 0)
+ : QWidget([[WebCoreViewFactory sharedFactory] fileButton])
, _textChanged(this, SIGNAL(textChanged(const QString &)))
, _adapter([[KWQFileButtonAdapter alloc] initWithKWQFileButton:this])
- , _icon(nil)
- , _label([NO_FILE_SELECTED retain])
{
}
@@ -63,105 +47,37 @@ KWQFileButton::~KWQFileButton()
{
_adapter->button = 0;
[_adapter release];
- [_icon release];
- [_label release];
}
void KWQFileButton::setFilename(const QString &f)
{
- if (_filename == f) {
- return;
- }
- _filename = f;
- _textChanged.call(_filename);
-
- // Get the label.
- [_label release];
- if (_filename.isEmpty()) {
- _label = [NO_FILE_SELECTED retain];
- } else {
- _label = [[[NSFileManager defaultManager] displayNameAtPath:_filename.getNSString()] copy];
- }
-
- // Get the icon.
- [_icon release];
- _icon = [[[NSWorkspace sharedWorkspace] iconForFile:_filename.getNSString()] retain];
-
- // Dirty the part of the view past the button, including the icon and text.
- QRect r = QPushButton::frameGeometry();
- r.setX(r.x() + r.width() + AFTER_BUTTON_SPACING);
- r.setWidth(ADDITIONAL_WIDTH - AFTER_BUTTON_SPACING);
- [[getView() superview] setNeedsDisplayInRect:frameGeometry()];
-}
-
-void KWQFileButton::clicked()
-{
- NSOpenPanel *sheet = [NSOpenPanel openPanel];
-
- [sheet setPrompt:@"Choose"];
-
- [_adapter retain];
-
- [sheet beginSheetForDirectory:@"~" file:@"" types:nil
- modalForWindow:[getView() window] modalDelegate:_adapter
- didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:)
- contextInfo:nil];
-
- QPushButton::clicked();
+ [(NSView <WebCoreFileButton> *)getView() setFilename:f.getNSString()];
}
QSize KWQFileButton::sizeHint() const
{
- QSize s = QPushButton::sizeHint();
- s.setWidth(s.width() + ADDITIONAL_WIDTH);
- return s;
+ return QSize([(NSView <WebCoreFileButton> *)getView() bestVisualFrameSize]);
}
QRect KWQFileButton::frameGeometry() const
{
- QRect r = QPushButton::frameGeometry();
- r.setWidth(r.width() + ADDITIONAL_WIDTH);
- return r;
+ return QRect([(NSView <WebCoreFileButton> *)getView() visualFrame]);
}
void KWQFileButton::setFrameGeometry(const QRect &rect)
{
- QRect r = rect;
- r.setWidth(r.width() - ADDITIONAL_WIDTH);
- QPushButton::setFrameGeometry(r);
+ [(NSView <WebCoreFileButton> *)getView() setVisualFrame:rect];
}
int KWQFileButton::baselinePosition() const
{
- return QPushButton::baselinePosition();
+ float baseline = [(NSView <WebCoreFileButton> *)getView() baseline];
+ return (int)(NSMaxX([getView() frame]) - baseline);
}
-void KWQFileButton::paint(QPainter *p, const QRect &r)
+void KWQFileButton::filenameChanged()
{
- if (p->paintingDisabled()) {
- return;
- }
-
- QPushButton::paint(p, r);
-
- [NSGraphicsContext saveGraphicsState];
- NSRectClip(NSIntersectionRect(frameGeometry(), r));
-
- int left = x() + width() - ADDITIONAL_WIDTH + AFTER_BUTTON_SPACING;
-
- if (_icon) {
- [_icon drawInRect:NSMakeRect(left, y() + (height() - ICON_HEIGHT) / 2, ICON_WIDTH, ICON_HEIGHT)
- fromRect:NSMakeRect(0, 0, [_icon size].width, [_icon size].height)
- operation:NSCompositeSourceOver fraction:1.0];
- left += ICON_WIDTH + ICON_FILENAME_SPACING;
- }
-
- // FIXME: Ellipsize the text to fit in the space available.
- NSFont *font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
- NSDictionary *attributes = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
- [_label drawAtPoint:NSMakePoint(left, y() + baselinePosition() - [font ascender]) withAttributes:attributes];
-
- [NSGraphicsContext restoreGraphicsState];
+ _textChanged.call(QString::fromNSString([(NSView <WebCoreFileButton> *)getView() filename]));
}
@implementation KWQFileButtonAdapter
@@ -170,15 +86,20 @@ void KWQFileButton::paint(QPainter *p, const QRect &r)
{
[super init];
button = b;
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(filenameChanged:)
+ name:WebCoreFileButtonFilenameChanged object:b->getView()];
return self;
}
-- (void)openPanelDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
+- (void)dealloc
+{
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+ [super dealloc];
+}
+
+- (void)filenameChanged:(NSNotification *)notification
{
- if (button && returnCode == NSOKButton && [[sheet filenames] count] == 1) {
- button->setFilename(QString::fromNSString([[sheet filenames] objectAtIndex:0]));
- }
- [self release];
+ button->filenameChanged();
}
@end
diff --git a/WebCore/kwq/KWQInputDialog.mm b/WebCore/kwq/KWQInputDialog.mm
index e2cccd1..3dc7c79 100644
--- a/WebCore/kwq/KWQInputDialog.mm
+++ b/WebCore/kwq/KWQInputDialog.mm
@@ -25,7 +25,7 @@
#import <qinputdialog.h>
-#import <WebCoreViewFactory.h>
+#import "WebCoreViewFactory.h"
QString QInputDialog::getText(const QString &, const QString &prompt, QLineEdit::EchoMode, const QString &defaultValue, bool *ok)
{
diff --git a/WebCore/kwq/KWQKConfigBase.mm b/WebCore/kwq/KWQKConfigBase.mm
index 34f784d..bfe6395 100644
--- a/WebCore/kwq/KWQKConfigBase.mm
+++ b/WebCore/kwq/KWQKConfigBase.mm
@@ -25,11 +25,11 @@
#import <kconfig.h>
-#import <KWQLogging.h>
+#import "KWQLogging.h"
#import <qcolor.h>
#import <qstringlist.h>
-#import <WebCoreSettings.h>
-#import <WebCoreViewFactory.h>
+#import "WebCoreSettings.h"
+#import "WebCoreViewFactory.h"
class KWQKConfigImpl
{
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index 2f0fd90..5c407b0 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -34,7 +34,6 @@
#import <khtmlview.h>
#import <WebCoreBridge.h>
-#import <WebCoreViewFactory.h>
#import <KWQLogging.h>
diff --git a/WebCore/kwq/KWQKHTMLPartImpl.mm b/WebCore/kwq/KWQKHTMLPartImpl.mm
index 2f0fd90..5c407b0 100644
--- a/WebCore/kwq/KWQKHTMLPartImpl.mm
+++ b/WebCore/kwq/KWQKHTMLPartImpl.mm
@@ -34,7 +34,6 @@
#import <khtmlview.h>
#import <WebCoreBridge.h>
-#import <WebCoreViewFactory.h>
#import <KWQLogging.h>
diff --git a/WebCore/kwq/KWQSlot.mm b/WebCore/kwq/KWQSlot.mm
index 52eb9e9..2d1c607 100644
--- a/WebCore/kwq/KWQSlot.mm
+++ b/WebCore/kwq/KWQSlot.mm
@@ -96,7 +96,7 @@ KWQSlot::KWQSlot(QObject *object, const char *member) : m_object(0)
ASSERT(dynamic_cast<KHTMLPart *>(object));
m_function = slotRedirect;
} else if (KWQNamesMatch(member, SLOT(slotReturnPressed()))) {
- ASSERT(dynamic_cast<RenderLineEdit *>(object) || dynamic_cast<RenderFileButton *>(object));
+ ASSERT(dynamic_cast<RenderLineEdit *>(object));
m_function = slotReturnPressed;
} else if (KWQNamesMatch(member, SLOT(slotSelected(int)))) {
ASSERT(dynamic_cast<RenderSelect *>(object));
@@ -143,21 +143,10 @@ void KWQSlot::call() const
CASE(slotParentCompleted, KHTMLPart, slotParentCompleted)
CASE(slotParentDestroyed, WindowQObject, parentDestroyed)
CASE(slotRedirect, KHTMLPart, slotRedirect)
+ CASE(slotReturnPressed, RenderLineEdit, slotReturnPressed)
CASE(slotSelectionChanged, RenderSelect, slotSelectionChanged)
CASE(slotTextChanged, RenderTextArea, slotTextChanged)
CASE(slotWidgetDestructed, RenderWidget, slotWidgetDestructed)
-
- case slotReturnPressed: {
- RenderLineEdit *edit = dynamic_cast<RenderLineEdit *>(m_object.pointer());
- if (edit) {
- edit->slotReturnPressed();
- }
- RenderFileButton *button = dynamic_cast<RenderFileButton *>(m_object.pointer());
- if (button) {
- button->slotReturnPressed();
- }
- return;
- }
}
#undef CASE
diff --git a/WebCore/kwq/WebCoreViewFactory.h b/WebCore/kwq/WebCoreViewFactory.h
index c93216d..dfe155c 100644
--- a/WebCore/kwq/WebCoreViewFactory.h
+++ b/WebCore/kwq/WebCoreViewFactory.h
@@ -62,8 +62,10 @@
@protocol WebCoreFileButton <NSObject>
- (void)setFilename:(NSString *)filename;
- (NSString *)filename;
-- (NSSize)bestSize;
- (float)baseline;
+- (void)setVisualFrame:(NSRect)rect;
+- (NSRect)visualFrame;
+- (NSSize)bestVisualFrameSize;
@end
extern NSString *WebCoreFileButtonFilenameChanged;
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 1475da9..4df4355 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,28 @@
+2002-10-23 Darin Adler <darin at apple.com>
+
+ - finished up the job of moving the file button here from WebCore.
+
+ I did this mainly for localization reasons.
+
+ * WebCoreSupport.subproj/WebFileButton.m:
+ (-[WebFileButton initWithFrame:]): Set up button control size, font, bezel style,
+ target, and action. Also add it as a subview.
+ (-[WebFileButton drawRect:]): Center icon in the "visual frame" part of the view,
+ not the entire bounds.
+ (-[WebFileButton setFilename:]): Don't show any icon when the filename is empty.
+ (-[WebFileButton bestVisualFrameSize]): Implemented this.
+ (-[WebFileButton visualFrame]): Ditto.
+ (-[WebFileButton setVisualFrame:]): Ditto.
+ (-[WebFileButton baseline]): Ditto.
+ (-[WebFileButton beginSheet]): Added. Shared between button presses and other clicks.
+ (-[WebFileButton chooseButtonPressed:]): Call beginSheet.
+ (-[WebFileButton mouseDown:]): Ditto.
+ (-[WebFileButton openPanelDidEnd:returnCode:contextInfo:]): Send the notification,
+ WebCoreFileButtonFilenameChanged, when the filename is changed.
+
+ * WebView.subproj/WebController.m: (-[WebController policyDelegate]):
+ Add a FIXME about the leak I found here.
+
2002-10-23 Chris Blumenberg <cblu at apple.com>
Call the arguments for plug-ins "attributes" everywhere.
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index 1475da9..4df4355 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,3 +1,28 @@
+2002-10-23 Darin Adler <darin at apple.com>
+
+ - finished up the job of moving the file button here from WebCore.
+
+ I did this mainly for localization reasons.
+
+ * WebCoreSupport.subproj/WebFileButton.m:
+ (-[WebFileButton initWithFrame:]): Set up button control size, font, bezel style,
+ target, and action. Also add it as a subview.
+ (-[WebFileButton drawRect:]): Center icon in the "visual frame" part of the view,
+ not the entire bounds.
+ (-[WebFileButton setFilename:]): Don't show any icon when the filename is empty.
+ (-[WebFileButton bestVisualFrameSize]): Implemented this.
+ (-[WebFileButton visualFrame]): Ditto.
+ (-[WebFileButton setVisualFrame:]): Ditto.
+ (-[WebFileButton baseline]): Ditto.
+ (-[WebFileButton beginSheet]): Added. Shared between button presses and other clicks.
+ (-[WebFileButton chooseButtonPressed:]): Call beginSheet.
+ (-[WebFileButton mouseDown:]): Ditto.
+ (-[WebFileButton openPanelDidEnd:returnCode:contextInfo:]): Send the notification,
+ WebCoreFileButtonFilenameChanged, when the filename is changed.
+
+ * WebView.subproj/WebController.m: (-[WebController policyDelegate]):
+ Add a FIXME about the leak I found here.
+
2002-10-23 Chris Blumenberg <cblu at apple.com>
Call the arguments for plug-ins "attributes" everywhere.
diff --git a/WebKit/WebCoreSupport.subproj/WebFileButton.m b/WebKit/WebCoreSupport.subproj/WebFileButton.m
index 6fb4cff..3a176db 100644
--- a/WebKit/WebCoreSupport.subproj/WebFileButton.m
+++ b/WebKit/WebCoreSupport.subproj/WebFileButton.m
@@ -8,10 +8,9 @@
#import "WebFileButton.h"
+#import <WebFoundation/WebAssertions.h>
#import <WebFoundation/WebLocalizableStrings.h>
-
#import <WebCore/WebCoreViewFactory.h>
-
#import <WebKit/WebStringTruncator.h>
#define NO_FILE_SELECTED
@@ -20,7 +19,7 @@
#define ICON_HEIGHT 16
#define ICON_WIDTH 16
#define ICON_FILENAME_SPACING 2
-// FIXME: Is it OK to hard-code the width of the filename part of this control?
+// FIXME: Is it OK to hard-code the width of the filename part?
#define FILENAME_WIDTH 200
#define ADDITIONAL_WIDTH (AFTER_BUTTON_SPACING + ICON_WIDTH + ICON_FILENAME_SPACING + FILENAME_WIDTH)
@@ -40,7 +39,6 @@
- (void)positionButton
{
[_button sizeToFit];
- // FIXME: Need to take margins into account.
[_button setFrameOrigin:NSMakePoint(0, 0)];
}
@@ -49,7 +47,16 @@
self = [super initWithFrame:frame];
if (self) {
_button = [[NSButton alloc] init];
+
[_button setTitle:UI_STRING("Choose File", "title for file button used in HTML forms")];
+ [[_button cell] setControlSize:NSSmallControlSize];
+ [_button setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
+ [_button setBezelStyle:NSRoundedBezelStyle];
+ [_button setTarget:self];
+ [_button setAction:@selector(chooseButtonPressed:)];
+
+ [self addSubview:_button];
+
[self positionButton];
[self setFilename:nil];
}
@@ -65,11 +72,6 @@
[super dealloc];
}
-- (NSFont *)font
-{
- return [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
-}
-
- (void)drawRect:(NSRect)rect
{
NSRect bounds = [self bounds];
@@ -80,15 +82,17 @@
float left = bounds.size.width - ADDITIONAL_WIDTH + AFTER_BUTTON_SPACING;
if (_icon) {
- [_icon drawInRect:NSMakeRect(left, (bounds.size.height - ICON_HEIGHT) / 2, ICON_WIDTH, ICON_HEIGHT)
+ float bottom = (bounds.size.height - BUTTON_BOTTOM_MARGIN - BUTTON_TOP_MARGIN - ICON_HEIGHT) / 2
+ + BUTTON_BOTTOM_MARGIN;
+ [_icon drawInRect:NSMakeRect(left, bottom, ICON_WIDTH, ICON_HEIGHT)
fromRect:NSMakeRect(0, 0, [_icon size].width, [_icon size].height)
operation:NSCompositeSourceOver fraction:1.0];
left += ICON_WIDTH + ICON_FILENAME_SPACING;
}
- NSFont *font = [self font];
+ NSFont *font = [_button font];
NSDictionary *attributes = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
- [_label drawAtPoint:NSMakePoint(left, [self baseline] - [font ascender]) withAttributes:attributes];
+ [_label drawAtPoint:NSMakePoint(left, [self baseline]) withAttributes:attributes];
[NSGraphicsContext restoreGraphicsState];
}
@@ -105,11 +109,15 @@
} else {
_label = [[WebStringTruncator centerTruncateString:
[[NSFileManager defaultManager] displayNameAtPath:_filename]
- toWidth:FILENAME_WIDTH withFont:[self font]] copy];
+ toWidth:FILENAME_WIDTH withFont:[_button font]] copy];
}
[_icon release];
- _icon = [[[NSWorkspace sharedWorkspace] iconForFile:_filename] retain];
+ if (![_filename length]) {
+ _icon = nil;
+ } else {
+ _icon = [[[NSWorkspace sharedWorkspace] iconForFile:_filename] retain];
+ }
[self setNeedsDisplay:YES];
}
@@ -126,19 +134,48 @@
[super setFrameSize:size];
}
-- (NSSize)bestSize
+- (NSSize)bestVisualFrameSize
+{
+ NSSize size = [[_button cell] cellSize];
+ size.height -= BUTTON_TOP_MARGIN + BUTTON_BOTTOM_MARGIN;
+ size.width -= BUTTON_LEFT_MARGIN + BUTTON_RIGHT_MARGIN;
+ size.width += ADDITIONAL_WIDTH;
+ return size;
+}
+
+- (NSRect)visualFrame
{
- // FIXME: Not yet implemented
- return [self frame].size;
+ ASSERT([self superview] == nil || [[self superview] isFlipped]);
+ NSRect frame = [self frame];
+ frame.origin.x += BUTTON_LEFT_MARGIN;
+ frame.size.width -= BUTTON_LEFT_MARGIN;
+ frame.origin.y += BUTTON_BOTTOM_MARGIN;
+ frame.size.height -= BUTTON_TOP_MARGIN + BUTTON_BOTTOM_MARGIN;
+ return frame;
+}
+
+- (void)setVisualFrame:(NSRect)frame
+{
+ ASSERT([self superview] == nil || [[self superview] isFlipped]);
+ frame.origin.x -= BUTTON_LEFT_MARGIN;
+ frame.size.width += BUTTON_LEFT_MARGIN;
+ frame.origin.y -= BUTTON_BOTTOM_MARGIN;
+ frame.size.height += BUTTON_TOP_MARGIN + BUTTON_BOTTOM_MARGIN;
+ [self setFrame:frame];
}
- (float)baseline
{
- // FIXME: Not yet implemented
- return 0;
+ // Button text is centered vertically, with a fudge factor to account for the shadow.
+ ASSERT(_button);
+ NSFont *buttonFont = [_button font];
+ float ascender = [buttonFont ascender];
+ float descender = [buttonFont descender];
+ return ([[_button cell] cellSize].height - (ascender - descender)) / 2.0
+ + BUTTON_VERTICAL_FUDGE_FACTOR + descender;
}
-- (void)chooseButtonPressed:(id)sender
+- (void)beginSheet
{
[self retain];
@@ -150,10 +187,21 @@
contextInfo:nil];
}
+- (void)chooseButtonPressed:(id)sender
+{
+ [self beginSheet];
+}
+
+- (void)mouseDown:(NSEvent *)event
+{
+ [self beginSheet];
+}
+
- (void)openPanelDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
{
if (returnCode == NSOKButton && [[sheet filenames] count] == 1) {
[self setFilename:[[sheet filenames] objectAtIndex:0]];
+ [[NSNotificationCenter defaultCenter] postNotificationName:WebCoreFileButtonFilenameChanged object:self];
}
[self release];
}
diff --git a/WebKit/WebView.subproj/WebController.m b/WebKit/WebView.subproj/WebController.m
index 9774d5d..6ea71f9 100644
--- a/WebKit/WebView.subproj/WebController.m
+++ b/WebKit/WebView.subproj/WebController.m
@@ -126,6 +126,7 @@ NSString *WebElementFrameKey = @"WebElementFrame";
- (id<WebControllerPolicyDelegate>)policyDelegate
{
+ // FIXME: This leaks!
if (!_private->policyDelegate)
_private->policyDelegate = [[WebDefaultPolicyDelegate alloc] initWithWebController: self];
return _private->policyDelegate;
diff --git a/WebKit/WebView.subproj/WebView.m b/WebKit/WebView.subproj/WebView.m
index 9774d5d..6ea71f9 100644
--- a/WebKit/WebView.subproj/WebView.m
+++ b/WebKit/WebView.subproj/WebView.m
@@ -126,6 +126,7 @@ NSString *WebElementFrameKey = @"WebElementFrame";
- (id<WebControllerPolicyDelegate>)policyDelegate
{
+ // FIXME: This leaks!
if (!_private->policyDelegate)
_private->policyDelegate = [[WebDefaultPolicyDelegate alloc] initWithWebController: self];
return _private->policyDelegate;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list