[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:55:12 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 1526278d2ebe45618411641f168e4007ccdb5079
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Oct 28 07:54:16 2002 +0000
WebCore:
- fixed 3058845 -- <input type=file> uses hard-coded width of 200
pixels for filename
* khtml/rendering/render_form.cpp:
(RenderLineEdit::calcMinMaxWidth): Use a default of 20 "x-widths" wide, to
match Mozilla, rather than the 17 that is in KHTML by default.
(RenderFileButton::calcMinMaxWidth): Pass in a character width here, using
the same 20-character rule as above.
* kwq/KWQFileButton.h: Replace sizeHint() with sizeForCharacterWidth(int).
* kwq/KWQFileButton.mm:
(KWQFileButton::sizeForCharacterWidth): Pass character count to the WebCoreFileButton.
(KWQFileButton::baselinePosition): Fix baseline computation. It was computing some huge
negative number before and was obviously broken.
* kwq/KWQLineEdit.mm: (QLineEdit::sizeForCharacterWidth): Add an assertion.
* kwq/WebCoreViewFactory.h: Replace bestVisualFrameSize with
bestVisualFrameSizeForCharacterCount:.
WebKit:
- WebKit part of filename width fix
* WebCoreSupport.subproj/WebFileButton.m:
(-[WebFileButton drawRect:]): Compute left position by starting at
the right side of the button frame rather than by starting at the right
side of the overall bounds. Removes dependency on fixed-width filename area.
(-[WebFileButton updateLabel]): Added. Computes ellipsized filename.
(-[WebFileButton setFilename:]): Use updateLabel instead of code in line here.
(-[WebFileButton setFrameSize:]): Call updateLabel.
(-[WebFileButton bestVisualFrameSizeForCharacterCount:]): Compute a width based
on the count passed in rather than a hardcoded 200-pixel constant.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2488 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index 4e05756..6ea581e 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,22 @@
+2002-10-27 Darin Adler <darin at apple.com>
+
+ - fixed 3058845 -- <input type=file> uses hard-coded width of 200
+ pixels for filename
+
+ * khtml/rendering/render_form.cpp:
+ (RenderLineEdit::calcMinMaxWidth): Use a default of 20 "x-widths" wide, to
+ match Mozilla, rather than the 17 that is in KHTML by default.
+ (RenderFileButton::calcMinMaxWidth): Pass in a character width here, using
+ the same 20-character rule as above.
+ * kwq/KWQFileButton.h: Replace sizeHint() with sizeForCharacterWidth(int).
+ * kwq/KWQFileButton.mm:
+ (KWQFileButton::sizeForCharacterWidth): Pass character count to the WebCoreFileButton.
+ (KWQFileButton::baselinePosition): Fix baseline computation. It was computing some huge
+ negative number before and was obviously broken.
+ * kwq/KWQLineEdit.mm: (QLineEdit::sizeForCharacterWidth): Add an assertion.
+ * kwq/WebCoreViewFactory.h: Replace bestVisualFrameSize with
+ bestVisualFrameSizeForCharacterCount:.
+
2002-10-27 Don Melton <gramps at apple.com>
* khtml/ecma/kjs_navigator.cpp:
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 4e05756..6ea581e 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,22 @@
+2002-10-27 Darin Adler <darin at apple.com>
+
+ - fixed 3058845 -- <input type=file> uses hard-coded width of 200
+ pixels for filename
+
+ * khtml/rendering/render_form.cpp:
+ (RenderLineEdit::calcMinMaxWidth): Use a default of 20 "x-widths" wide, to
+ match Mozilla, rather than the 17 that is in KHTML by default.
+ (RenderFileButton::calcMinMaxWidth): Pass in a character width here, using
+ the same 20-character rule as above.
+ * kwq/KWQFileButton.h: Replace sizeHint() with sizeForCharacterWidth(int).
+ * kwq/KWQFileButton.mm:
+ (KWQFileButton::sizeForCharacterWidth): Pass character count to the WebCoreFileButton.
+ (KWQFileButton::baselinePosition): Fix baseline computation. It was computing some huge
+ negative number before and was obviously broken.
+ * kwq/KWQLineEdit.mm: (QLineEdit::sizeForCharacterWidth): Add an assertion.
+ * kwq/WebCoreViewFactory.h: Replace bestVisualFrameSize with
+ bestVisualFrameSizeForCharacterCount:.
+
2002-10-27 Don Melton <gramps at apple.com>
* khtml/ecma/kjs_navigator.cpp:
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 4e05756..6ea581e 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,22 @@
+2002-10-27 Darin Adler <darin at apple.com>
+
+ - fixed 3058845 -- <input type=file> uses hard-coded width of 200
+ pixels for filename
+
+ * khtml/rendering/render_form.cpp:
+ (RenderLineEdit::calcMinMaxWidth): Use a default of 20 "x-widths" wide, to
+ match Mozilla, rather than the 17 that is in KHTML by default.
+ (RenderFileButton::calcMinMaxWidth): Pass in a character width here, using
+ the same 20-character rule as above.
+ * kwq/KWQFileButton.h: Replace sizeHint() with sizeForCharacterWidth(int).
+ * kwq/KWQFileButton.mm:
+ (KWQFileButton::sizeForCharacterWidth): Pass character count to the WebCoreFileButton.
+ (KWQFileButton::baselinePosition): Fix baseline computation. It was computing some huge
+ negative number before and was obviously broken.
+ * kwq/KWQLineEdit.mm: (QLineEdit::sizeForCharacterWidth): Add an assertion.
+ * kwq/WebCoreViewFactory.h: Replace bestVisualFrameSize with
+ bestVisualFrameSizeForCharacterCount:.
+
2002-10-27 Don Melton <gramps at apple.com>
* khtml/ecma/kjs_navigator.cpp:
diff --git a/WebCore/khtml/rendering/render_form.cpp b/WebCore/khtml/rendering/render_form.cpp
index d79d2db..5b35875 100644
--- a/WebCore/khtml/rendering/render_form.cpp
+++ b/WebCore/khtml/rendering/render_form.cpp
@@ -506,7 +506,7 @@ void RenderLineEdit::calcMinMaxWidth()
#if APPLE_CHANGES
// Let the widget tell us how big it wants to be.
int size = element()->size();
- QSize s(widget()->sizeForCharacterWidth(size > 0 ? size : 17));
+ QSize s(widget()->sizeForCharacterWidth(size > 0 ? size : 20));
#else
const QFontMetrics &fm = style()->fontMetrics();
QSize s;
@@ -602,7 +602,8 @@ void RenderFileButton::calcMinMaxWidth()
#if APPLE_CHANGES
// Let the widget tell us how big it wants to be.
- QSize s(widget()->sizeHint());
+ int size = element()->size();
+ QSize s(static_cast<KWQFileButton *>(widget())->sizeForCharacterWidth(size > 0 ? size : 20));
#else
const QFontMetrics &fm = style()->fontMetrics();
QSize s;
diff --git a/WebCore/kwq/KWQFileButton.h b/WebCore/kwq/KWQFileButton.h
index 5b36052..4c3a31c 100644
--- a/WebCore/kwq/KWQFileButton.h
+++ b/WebCore/kwq/KWQFileButton.h
@@ -41,7 +41,7 @@ public:
void setFilename(const QString &);
- QSize sizeHint() const;
+ QSize sizeForCharacterWidth(int characters) const;
QRect frameGeometry() const;
void setFrameGeometry(const QRect &);
int baselinePosition() const;
diff --git a/WebCore/kwq/KWQFileButton.mm b/WebCore/kwq/KWQFileButton.mm
index 8d6d4fd..680d87c 100644
--- a/WebCore/kwq/KWQFileButton.mm
+++ b/WebCore/kwq/KWQFileButton.mm
@@ -25,6 +25,7 @@
#import "KWQFileButton.h"
+#import "KWQAssertions.h"
#import "WebCoreViewFactory.h"
@interface KWQFileButtonAdapter : NSObject
@@ -54,9 +55,10 @@ void KWQFileButton::setFilename(const QString &f)
[(NSView <WebCoreFileButton> *)getView() setFilename:f.getNSString()];
}
-QSize KWQFileButton::sizeHint() const
+QSize KWQFileButton::sizeForCharacterWidth(int characters) const
{
- return QSize([(NSView <WebCoreFileButton> *)getView() bestVisualFrameSize]);
+ ASSERT(characters > 0);
+ return QSize([(NSView <WebCoreFileButton> *)getView() bestVisualFrameSizeForCharacterCount:characters]);
}
QRect KWQFileButton::frameGeometry() const
@@ -71,8 +73,8 @@ void KWQFileButton::setFrameGeometry(const QRect &rect)
int KWQFileButton::baselinePosition() const
{
- float baseline = [(NSView <WebCoreFileButton> *)getView() baseline];
- return (int)(NSMaxX([getView() frame]) - baseline);
+ NSView <WebCoreFileButton> *button = (NSView <WebCoreFileButton> *)getView();
+ return (int)(NSMaxY([button frame]) - [button baseline] - [button visualFrame].origin.y);
}
void KWQFileButton::filenameChanged()
diff --git a/WebCore/kwq/KWQLineEdit.mm b/WebCore/kwq/KWQLineEdit.mm
index 8838140..7286137 100644
--- a/WebCore/kwq/KWQLineEdit.mm
+++ b/WebCore/kwq/KWQLineEdit.mm
@@ -130,6 +130,8 @@ void QLineEdit::setEdited(bool flag)
QSize QLineEdit::sizeForCharacterWidth(int numCharacters) const
{
+ ASSERT(numCharacters > 0);
+
NSMutableString *nominalWidthString = [NSMutableString stringWithCapacity:numCharacters];
for (int i = 0; i < numCharacters; ++i) {
[nominalWidthString appendString:@"x"];
diff --git a/WebCore/kwq/WebCoreViewFactory.h b/WebCore/kwq/WebCoreViewFactory.h
index 53e5912..2f44129 100644
--- a/WebCore/kwq/WebCoreViewFactory.h
+++ b/WebCore/kwq/WebCoreViewFactory.h
@@ -75,7 +75,7 @@
- (float)baseline;
- (void)setVisualFrame:(NSRect)rect;
- (NSRect)visualFrame;
-- (NSSize)bestVisualFrameSize;
+- (NSSize)bestVisualFrameSizeForCharacterCount:(int)count;
@end
extern NSString *WebCoreFileButtonFilenameChanged;
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index fcf416d..7fda612 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,5 +1,19 @@
2002-10-27 Darin Adler <darin at apple.com>
+ - WebKit part of filename width fix
+
+ * WebCoreSupport.subproj/WebFileButton.m:
+ (-[WebFileButton drawRect:]): Compute left position by starting at
+ the right side of the button frame rather than by starting at the right
+ side of the overall bounds. Removes dependency on fixed-width filename area.
+ (-[WebFileButton updateLabel]): Added. Computes ellipsized filename.
+ (-[WebFileButton setFilename:]): Use updateLabel instead of code in line here.
+ (-[WebFileButton setFrameSize:]): Call updateLabel.
+ (-[WebFileButton bestVisualFrameSizeForCharacterCount:]): Compute a width based
+ on the count passed in rather than a hardcoded 200-pixel constant.
+
+2002-10-27 Darin Adler <darin at apple.com>
+
- fixed 3037369 -- Status text not cleared after start of drag from page
* WebView.subproj/WebHTMLView.m:
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index fcf416d..7fda612 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,5 +1,19 @@
2002-10-27 Darin Adler <darin at apple.com>
+ - WebKit part of filename width fix
+
+ * WebCoreSupport.subproj/WebFileButton.m:
+ (-[WebFileButton drawRect:]): Compute left position by starting at
+ the right side of the button frame rather than by starting at the right
+ side of the overall bounds. Removes dependency on fixed-width filename area.
+ (-[WebFileButton updateLabel]): Added. Computes ellipsized filename.
+ (-[WebFileButton setFilename:]): Use updateLabel instead of code in line here.
+ (-[WebFileButton setFrameSize:]): Call updateLabel.
+ (-[WebFileButton bestVisualFrameSizeForCharacterCount:]): Compute a width based
+ on the count passed in rather than a hardcoded 200-pixel constant.
+
+2002-10-27 Darin Adler <darin at apple.com>
+
- fixed 3037369 -- Status text not cleared after start of drag from page
* WebView.subproj/WebHTMLView.m:
diff --git a/WebKit/WebCoreSupport.subproj/WebFileButton.m b/WebKit/WebCoreSupport.subproj/WebFileButton.m
index 3a176db..1943f45 100644
--- a/WebKit/WebCoreSupport.subproj/WebFileButton.m
+++ b/WebKit/WebCoreSupport.subproj/WebFileButton.m
@@ -19,10 +19,6 @@
#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?
-#define FILENAME_WIDTH 200
-
-#define ADDITIONAL_WIDTH (AFTER_BUTTON_SPACING + ICON_WIDTH + ICON_FILENAME_SPACING + FILENAME_WIDTH)
// We empirically determined that buttons have these extra pixels on all
// sides. It would be better to get this info from AppKit somehow.
@@ -79,7 +75,7 @@
[NSGraphicsContext saveGraphicsState];
NSRectClip(NSIntersectionRect(bounds, rect));
- float left = bounds.size.width - ADDITIONAL_WIDTH + AFTER_BUTTON_SPACING;
+ float left = NSMaxX([_button frame]) + AFTER_BUTTON_SPACING;
if (_icon) {
float bottom = (bounds.size.height - BUTTON_BOTTOM_MARGIN - BUTTON_TOP_MARGIN - ICON_HEIGHT) / 2
@@ -97,21 +93,34 @@
[NSGraphicsContext restoreGraphicsState];
}
+- (void)updateLabel
+{
+ [_label release];
+
+ NSString *label;
+ if ([_filename length]) {
+ label = _filename;
+ } else {
+ label = [UI_STRING("no file selected", "text to display in file button used in HTML forms when no file is selected") retain];
+ }
+
+ float left = NSMaxX([_button frame]) + AFTER_BUTTON_SPACING;
+ if (_icon) {
+ left += ICON_WIDTH + ICON_FILENAME_SPACING;
+ }
+ float labelWidth = [self bounds].size.width - left;
+
+ _label = labelWidth <= 0 ? nil : [[WebStringTruncator centerTruncateString:
+ [[NSFileManager defaultManager] displayNameAtPath:label]
+ toWidth:labelWidth withFont:[_button font]] copy];
+}
+
- (void)setFilename:(NSString *)filename
{
NSString *copy = [filename copy];
[_filename release];
_filename = copy;
- [_label release];
- if (![_filename length]) {
- _label = [UI_STRING("no file selected", "text to display in file button used in HTML forms when no file is selected") retain];
- } else {
- _label = [[WebStringTruncator centerTruncateString:
- [[NSFileManager defaultManager] displayNameAtPath:_filename]
- toWidth:FILENAME_WIDTH withFont:[_button font]] copy];
- }
-
[_icon release];
if (![_filename length]) {
_icon = nil;
@@ -119,6 +128,8 @@
_icon = [[[NSWorkspace sharedWorkspace] iconForFile:_filename] retain];
}
+ [self updateLabel];
+
[self setNeedsDisplay:YES];
}
@@ -129,17 +140,20 @@
- (void)setFrameSize:(NSSize)size
{
- // FIXME: Can we just use springs instead?
- [self positionButton];
[super setFrameSize:size];
+ // FIXME: Can we just springs and struts instead of calling positionButton?
+ [self positionButton];
+ [self updateLabel];
}
-- (NSSize)bestVisualFrameSize
+- (NSSize)bestVisualFrameSizeForCharacterCount:(int)count
{
+ ASSERT(count > 0);
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;
+ size.width += AFTER_BUTTON_SPACING + ICON_WIDTH + ICON_FILENAME_SPACING;
+ size.width += count * [[_button font] widthOfString:@"x"];
return size;
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list