WebCore:
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Apr 2006 03:47:00 +0000 (03:47 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Apr 2006 03:47:00 +0000 (03:47 +0000)
        Reviewed by Darin.

        - push WebFileButton and WebStringTruncator code down to WebCore
        http://bugzilla.opendarwin.org/show_bug.cgi?id=8552

        * WebCore.exp:
        * WebCore.xcodeproj/project.pbxproj:
        * bridge/mac/WebCoreFrameBridge.h:
        * bridge/mac/WebCoreStringTruncator.h: Added.
        * bridge/mac/WebCoreStringTruncator.mm: Added.
        (stringWidth):
        (truncateString):
        (+[WebCoreStringTruncator widthOfString:font:]):
        * bridge/mac/WebCoreViewFactory.h:
        * kwq/KWQFileButton.h:
        * kwq/KWQFileButton.mm:
        (-[WebFileChooserButton initWithWidget::]):
        (-[WebCoreFileButton positionButton]):
        (-[WebCoreFileButton initWithWidget:]):
        (-[WebCoreFileButton initWithFrame:]):
        (-[WebCoreFileButton dealloc]):
        (-[WebCoreFileButton isFlipped]):
        (-[WebCoreFileButton drawRect:]):
        (-[WebCoreFileButton updateLabel]):
        (-[WebCoreFileButton setFilename:]):
        (-[WebCoreFileButton filename]):
        (-[WebCoreFileButton setFrameSize:]):
        (-[WebCoreFileButton bestVisualFrameSizeForCharacterCount:]):
        (-[WebCoreFileButton visualFrame]):
        (-[WebCoreFileButton setVisualFrame:]):
        (-[WebCoreFileButton baseline]):
        (-[WebCoreFileButton beginSheet]):
        (-[WebCoreFileButton chooseFilename:]):
        (-[WebCoreFileButton cancel]):
        (-[WebCoreFileButton chooseButtonPressed:]):
        (-[WebCoreFileButton mouseDown:]):
        (-[WebCoreFileButton acceptsFirstResponder]):
        (-[WebCoreFileButton becomeFirstResponder]):
        (-[WebCoreFileButton nextKeyView]):
        (-[WebCoreFileButton previousKeyView]):
        (-[WebCoreFileButton nextValidKeyView]):
        (-[WebCoreFileButton previousValidKeyView]):
        (-[WebCoreFileButton performClick]):
        (-[WebFileChooserButton initWithWidget:]):
        (-[WebFileChooserButton nextValidKeyView]):
        (-[WebFileChooserButton previousValidKeyView]):
        (-[WebFileChooserButton resignFirstResponder]):
        (KWQFileButton::KWQFileButton):
        (KWQFileButton::setFilename):
        (KWQFileButton::click):
        (KWQFileButton::sizeForCharacterWidth):
        (KWQFileButton::frameGeometry):
        (KWQFileButton::setFrameGeometry):
        (KWQFileButton::baselinePosition):
        (KWQFileButton::filenameChanged):

WebKit:

        Reviewed by Darin.

        - push WebFileButton and WebStringTruncator code down to WebCore
        http://bugzilla.opendarwin.org/show_bug.cgi?id=8552

        * Misc/WebStringTruncator.m:
        (+[WebStringTruncator centerTruncateString:toWidth:]):
        (+[WebStringTruncator centerTruncateString:toWidth:withFont:]):
        (+[WebStringTruncator rightTruncateString:toWidth:withFont:]):
        (+[WebStringTruncator widthOfString:font:]):
        * WebCoreSupport/WebFileButton.h: Removed.
        * WebCoreSupport/WebFileButton.m: Removed.
        * WebCoreSupport/WebFrameBridge.h:
        * WebCoreSupport/WebFrameBridge.m:
        (-[WebFrameBridge runOpenPanelForFileButtonWithResultListener:]):
        * WebCoreSupport/WebViewFactory.m:
        (-[WebViewFactory fileButtonChooseFileLabel]):
        (-[WebViewFactory fileButtonNoFileSelectedLabel]):
        * WebKit.xcodeproj/project.pbxproj:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@14030 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
WebCore/ChangeLog
WebCore/WebCore.exp
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bridge/mac/WebCoreFrameBridge.h
WebCore/bridge/mac/WebCoreStringTruncator.h [moved from WebKit/WebCoreSupport/WebFileButton.h with 73% similarity]
WebCore/bridge/mac/WebCoreStringTruncator.mm [new file with mode: 0644]
WebCore/bridge/mac/WebCoreViewFactory.h
WebCore/kwq/KWQFileButton.h
WebCore/kwq/KWQFileButton.mm
WebKit/ChangeLog
WebKit/Misc/WebStringTruncator.m
WebKit/WebCoreSupport/WebFileButton.m [deleted file]
WebKit/WebCoreSupport/WebFrameBridge.h
WebKit/WebCoreSupport/WebFrameBridge.m
WebKit/WebCoreSupport/WebViewFactory.m
WebKit/WebKit.xcodeproj/project.pbxproj

index d517c7d836f380b6f7e43bbc7838136564009914..9c4cea64379a30753aff308cea27784d1f4e025d 100644 (file)
@@ -1,3 +1,61 @@
+2006-04-23  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Darin.
+        
+        - push WebFileButton and WebStringTruncator code down to WebCore
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=8552
+
+        * WebCore.exp:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bridge/mac/WebCoreFrameBridge.h:
+        * bridge/mac/WebCoreStringTruncator.h: Added.
+        * bridge/mac/WebCoreStringTruncator.mm: Added.
+        (stringWidth):
+        (truncateString):
+        (+[WebCoreStringTruncator widthOfString:font:]):
+        * bridge/mac/WebCoreViewFactory.h:
+        * kwq/KWQFileButton.h:
+        * kwq/KWQFileButton.mm:
+        (-[WebFileChooserButton initWithWidget::]):
+        (-[WebCoreFileButton positionButton]):
+        (-[WebCoreFileButton initWithWidget:]):
+        (-[WebCoreFileButton initWithFrame:]):
+        (-[WebCoreFileButton dealloc]):
+        (-[WebCoreFileButton isFlipped]):
+        (-[WebCoreFileButton drawRect:]):
+        (-[WebCoreFileButton updateLabel]):
+        (-[WebCoreFileButton setFilename:]):
+        (-[WebCoreFileButton filename]):
+        (-[WebCoreFileButton setFrameSize:]):
+        (-[WebCoreFileButton bestVisualFrameSizeForCharacterCount:]):
+        (-[WebCoreFileButton visualFrame]):
+        (-[WebCoreFileButton setVisualFrame:]):
+        (-[WebCoreFileButton baseline]):
+        (-[WebCoreFileButton beginSheet]):
+        (-[WebCoreFileButton chooseFilename:]):
+        (-[WebCoreFileButton cancel]):
+        (-[WebCoreFileButton chooseButtonPressed:]):
+        (-[WebCoreFileButton mouseDown:]):
+        (-[WebCoreFileButton acceptsFirstResponder]):
+        (-[WebCoreFileButton becomeFirstResponder]):
+        (-[WebCoreFileButton nextKeyView]):
+        (-[WebCoreFileButton previousKeyView]):
+        (-[WebCoreFileButton nextValidKeyView]):
+        (-[WebCoreFileButton previousValidKeyView]):
+        (-[WebCoreFileButton performClick]):
+        (-[WebFileChooserButton initWithWidget:]):
+        (-[WebFileChooserButton nextValidKeyView]):
+        (-[WebFileChooserButton previousValidKeyView]):
+        (-[WebFileChooserButton resignFirstResponder]):
+        (KWQFileButton::KWQFileButton):
+        (KWQFileButton::setFilename):
+        (KWQFileButton::click):
+        (KWQFileButton::sizeForCharacterWidth):
+        (KWQFileButton::frameGeometry):
+        (KWQFileButton::setFrameGeometry):
+        (KWQFileButton::baselinePosition):
+        (KWQFileButton::filenameChanged):
+
 2006-04-23  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Eric.
index 2b165c0dfec2214025b71b2c84c923a5fe706330..948088e02d1e82a9c010adf5e0c59b106e16ffe3 100644 (file)
 .objc_class_name_DOMUIEvent
 .objc_class_name_WebCoreCache
 .objc_class_name_WebCoreEncodings
+.objc_class_name_WebCoreFileButton
 .objc_class_name_WebCoreFrameBridge
 .objc_class_name_WebCoreFrameNamespaces
 .objc_class_name_WebCoreHistory
 .objc_class_name_WebCoreKeyGenerator
 .objc_class_name_WebCorePageBridge
 .objc_class_name_WebCoreScriptDebugger
+.objc_class_name_WebCoreStringTruncator
 .objc_class_name_WebCoreSettings
 .objc_class_name_WebCoreTextDecoder
 .objc_class_name_WebCoreTextRendererFactory
index 041030657e9e3b2ea6c5c680c5ff80e25ad04195..58ecc3e8e13249cebe712bb8490177c0722eaadb 100644 (file)
                6582A16209999D6D00BEEB6D /* ScreenMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6582A15409999D6D00BEEB6D /* ScreenMac.mm */; };
                6582A16309999D6D00BEEB6D /* SystemTimeMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6582A15509999D6D00BEEB6D /* SystemTimeMac.cpp */; };
                6582A17809999EA000BEEB6D /* QStringMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6582A17709999EA000BEEB6D /* QStringMac.mm */; };
+               65901A4409FC6039005BD752 /* WebCoreStringTruncator.h in Headers */ = {isa = PBXBuildFile; fileRef = 65901A4209FC6039005BD752 /* WebCoreStringTruncator.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               65901A4509FC6039005BD752 /* WebCoreStringTruncator.mm in Sources */ = {isa = PBXBuildFile; fileRef = 65901A4309FC6039005BD752 /* WebCoreStringTruncator.mm */; };
                6593923709AE4346002C531F /* KURL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6593923509AE4346002C531F /* KURL.cpp */; };
                6593923809AE4346002C531F /* KURL.h in Headers */ = {isa = PBXBuildFile; fileRef = 6593923609AE4346002C531F /* KURL.h */; };
                6593923A09AE435C002C531F /* KURLMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6593923909AE435C002C531F /* KURLMac.mm */; };
                6582A15409999D6D00BEEB6D /* ScreenMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = ScreenMac.mm; sourceTree = "<group>"; };
                6582A15509999D6D00BEEB6D /* SystemTimeMac.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SystemTimeMac.cpp; sourceTree = "<group>"; };
                6582A17709999EA000BEEB6D /* QStringMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = QStringMac.mm; sourceTree = "<group>"; };
+               65901A4209FC6039005BD752 /* WebCoreStringTruncator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCoreStringTruncator.h; sourceTree = "<group>"; };
+               65901A4309FC6039005BD752 /* WebCoreStringTruncator.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreStringTruncator.mm; sourceTree = "<group>"; };
                6593923509AE4346002C531F /* KURL.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = KURL.cpp; sourceTree = "<group>"; };
                6593923609AE4346002C531F /* KURL.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = KURL.h; sourceTree = "<group>"; };
                6593923909AE435C002C531F /* KURLMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = KURLMac.mm; sourceTree = "<group>"; };
                65BF02350974819000C43196 /* mac */ = {
                        isa = PBXGroup;
                        children = (
+                               65901A4209FC6039005BD752 /* WebCoreStringTruncator.h */,
+                               65901A4309FC6039005BD752 /* WebCoreStringTruncator.mm */,
                                BCEA4945097F0F770094C9E4 /* BrowserExtensionMac.h */,
                                BCEA4946097F0F770094C9E4 /* BrowserExtensionMac.mm */,
                                65BF023B0974819000C43196 /* FrameMac.h */,
                                14115B7309F84CD600CA4FC1 /* JSNodeFilter.h in Headers */,
                                14E8378E09F85D4F00B85AE4 /* JSEvent.h in Headers */,
                                93EB169709F880C00091F8FF /* WebCoreSystemInterface.h in Headers */,
+                               65901A4409FC6039005BD752 /* WebCoreStringTruncator.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                14115B7209F84CD600CA4FC1 /* JSNodeFilter.cpp in Sources */,
                                14E8378409F85D1C00B85AE4 /* JSEvent.cpp in Sources */,
                                93EB169509F880B00091F8FF /* WebCoreSystemInterface.mm in Sources */,
+                               65901A4509FC6039005BD752 /* WebCoreStringTruncator.mm in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index b44cf8dbd451e610a599a4f515f86f7bbbd85ab9..a2259bddb6a5f7983a0a7fbf33a6418bb0cd10d2 100644 (file)
@@ -66,8 +66,6 @@ typedef WebCore::RenderPart WebCoreRenderPart;
 @protocol WebCoreRenderTreeCopier;
 @protocol WebCoreResourceHandle;
 @protocol WebCoreResourceLoader;
-@protocol WebCoreFileButton;
-@protocol WebCoreFileButtonDelegate;
 
 extern NSString *WebCorePageCacheStateKey;
 
@@ -163,6 +161,11 @@ typedef enum {
     ObjectElementPlugin,
 } ObjectElementType;
 
+@protocol WebCoreOpenPanelResultListener <NSObject>
+- (void)chooseFilename:(NSString *)fileName;
+- (void)cancel;
+@end
+
 // WebCoreFrameBridge objects are used by WebCore to abstract away operations that need
 // to be implemented by library clients, for example WebKit. The objects are also
 // used in the opposite direction, for simple access to WebCore functions without dealing
@@ -535,6 +538,7 @@ typedef enum {
 - (BOOL)canRunBeforeUnloadConfirmPanel;
 - (BOOL)runBeforeUnloadConfirmPanelWithMessage:(NSString *)message;
 - (void)addMessageToConsole:(NSDictionary *)message;
+- (void)runOpenPanelForFileButtonWithResultListener:(id <WebCoreOpenPanelResultListener>)resultListener;
 
 - (id <WebCoreResourceHandle>)startLoadingResource:(id <WebCoreResourceLoader>)loader withMethod:(NSString *)method URL:(NSURL *)URL customHeaders:(NSDictionary *)customHeaders;
 - (id <WebCoreResourceHandle>)startLoadingResource:(id <WebCoreResourceLoader>)loader withMethod:(NSString *)method URL:(NSURL *)URL customHeaders:(NSDictionary *)customHeaders postData:(NSArray *)data;
@@ -607,8 +611,6 @@ typedef enum {
 - (BOOL)textField:(DOMHTMLInputElement *)element doCommandBySelector:(SEL)commandSelector;
 - (BOOL)textField:(DOMHTMLInputElement *)element shouldHandleEvent:(NSEvent *)event;
 
-- (NSView <WebCoreFileButton> *)fileButtonWithDelegate:(id <WebCoreFileButtonDelegate>)delegate;
-
 - (void)setHasBorder:(BOOL)hasBorder;
 
 - (WebCoreKeyboardUIMode)keyboardUIMode;
@@ -677,18 +679,3 @@ typedef enum {
 - (NSObject *)nodeWithName:(NSString *)name position:(NSPoint)p rect:(NSRect)rect view:(NSView *)view children:(NSArray *)children;
 @end
 
-@protocol WebCoreFileButton <NSObject>
-- (void)setFilename:(NSString *)filename;
-- (void)performClick;
-- (NSString *)filename;
-- (float)baseline;
-- (void)setVisualFrame:(NSRect)rect;
-- (NSRect)visualFrame;
-- (NSSize)bestVisualFrameSizeForCharacterCount:(int)count;
-@end
-
-@protocol WebCoreFileButtonDelegate <NSObject>
-- (void)filenameChanged:(NSString *)filename;
-- (void)focusChanged:(BOOL)nowHasFocus;
-- (void)clicked;
-@end
similarity index 73%
rename from WebKit/WebCoreSupport/WebFileButton.h
rename to WebCore/bridge/mac/WebCoreStringTruncator.h
index 8c1dd2ab16013a9a11c8b7a8ba9e51030a0d9d1e..b12b6194e6500fb154e44622733f6fbdf6af0a10 100644 (file)
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#import <Cocoa/Cocoa.h>
-
-@protocol WebCoreFileButton;
-@protocol WebCoreFileButtonDelegate;
-@protocol WebOpenPanelResultListener;
-@class WebFrameBridge;
-@class WebFileChooserButton;
-
-@interface WebFileButton : NSView <WebCoreFileButton, WebOpenPanelResultListener>
-{
-    NSString *_filename;
-    WebFileChooserButton *_button;
-    NSImage *_icon;
-    NSString *_label;
-    WebFrameBridge *_bridge;
-    BOOL _inNextValidKeyView;
-    id <WebCoreFileButtonDelegate> _delegate;
-}
-- (id)initWithBridge:(WebFrameBridge *)bridge delegate:(id <WebCoreFileButtonDelegate>)delegate;
+#import <Foundation/Foundation.h>
+
+@class NSFont;
+
+@interface WebCoreStringTruncator : NSObject
+
++ (NSString *)centerTruncateString:(NSString *)string toWidth:(float)maxWidth withFont:(NSFont *)font;
+
+// Default font is [NSFont menuFontOfSize:0].
++ (NSString *)centerTruncateString:(NSString *)string toWidth:(float)maxWidth;
+
++ (NSString *)rightTruncateString:(NSString *)string toWidth:(float)maxWidth withFont:(NSFont *)font;
+
++ (float)widthOfString:(NSString *)string font:(NSFont *)font;
+
 @end
diff --git a/WebCore/bridge/mac/WebCoreStringTruncator.mm b/WebCore/bridge/mac/WebCoreStringTruncator.mm
new file mode 100644 (file)
index 0000000..e6671fc
--- /dev/null
@@ -0,0 +1,233 @@
+/*
+ * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WebCoreStringTruncator.h"
+
+#import <Cocoa/Cocoa.h>
+
+#import <kxmlcore/Assertions.h>
+#import "WebCoreTextRendererFactory.h"
+#import "WebCoreTextRenderer.h"
+
+#define STRING_BUFFER_SIZE 2048
+#define ELLIPSIS_CHARACTER 0x2026
+
+static NSFont *currentFont;
+static id<WebCoreTextRenderer> currentRenderer;
+static float currentEllipsisWidth;
+
+typedef unsigned TruncationFunction(NSString *string, unsigned length, unsigned keepCount, unichar *buffer);
+
+static unsigned centerTruncateToBuffer(NSString *string, unsigned length, unsigned keepCount, unichar *buffer)
+{
+    ASSERT(keepCount < length);
+    ASSERT(keepCount < STRING_BUFFER_SIZE);
+    
+    unsigned omitStart = (keepCount + 1) / 2;
+    unsigned omitEnd = NSMaxRange([string rangeOfComposedCharacterSequenceAtIndex:omitStart + (length - keepCount) - 1]);
+    omitStart = [string rangeOfComposedCharacterSequenceAtIndex:omitStart].location;
+    
+    NSRange beforeRange = NSMakeRange(0, omitStart);
+    NSRange afterRange = NSMakeRange(omitEnd, length - omitEnd);
+    
+    unsigned truncatedLength = beforeRange.length + 1 + afterRange.length;
+    ASSERT(truncatedLength <= length);
+
+    [string getCharacters:buffer range:beforeRange];
+    buffer[beforeRange.length] = ELLIPSIS_CHARACTER;
+    [string getCharacters:&buffer[beforeRange.length + 1] range:afterRange];
+    
+    return truncatedLength;
+}
+
+static unsigned rightTruncateToBuffer(NSString *string, unsigned length, unsigned keepCount, unichar *buffer)
+{
+    ASSERT(keepCount < length);
+    ASSERT(keepCount < STRING_BUFFER_SIZE);
+    
+    NSRange keepRange = NSMakeRange(0, [string rangeOfComposedCharacterSequenceAtIndex:keepCount].location);
+    
+    [string getCharacters:buffer range:keepRange];
+    buffer[keepRange.length] = ELLIPSIS_CHARACTER;
+    
+    return keepRange.length + 1;
+}
+
+static float stringWidth(id<WebCoreTextRenderer> renderer, const unichar *characters, unsigned length)
+{
+    WebCoreTextRun run;
+    WebCoreInitializeTextRun (&run, characters, length, 0, length);
+    WebCoreTextStyle style;
+    WebCoreInitializeEmptyTextStyle(&style);
+    style.applyRunRounding = NO;
+    style.applyWordRounding = NO;
+    return [renderer floatWidthForRun:&run style:&style];
+}
+
+static NSString *truncateString(NSString *string, float maxWidth, NSFont *font, TruncationFunction truncateToBuffer)
+{
+    unsigned length = [string length];
+    if (length == 0) {
+        return string;
+    }
+
+    unichar stringBuffer[STRING_BUFFER_SIZE];
+    unsigned keepCount;
+    unsigned truncatedLength;
+    float width;
+    unichar ellipsis;
+    unsigned keepCountForLargestKnownToFit, keepCountForSmallestKnownToNotFit;
+    float widthForLargestKnownToFit, widthForSmallestKnownToNotFit;
+    float ratio;
+    
+    ASSERT_ARG(font, font);
+    ASSERT_ARG(maxWidth, maxWidth >= 0);
+    
+    if (![currentFont isEqual:font]) {
+        [currentFont release];
+        currentFont = [font retain];
+        [currentRenderer release];
+        WebCoreFont f;
+        WebCoreInitializeFont(&f);
+        f.font = font;
+        currentRenderer = [[[WebCoreTextRendererFactory sharedFactory] rendererWithFont:f] retain];
+        ellipsis = ELLIPSIS_CHARACTER;
+        currentEllipsisWidth = stringWidth(currentRenderer, &ellipsis, 1);
+    }
+    
+    ASSERT(currentRenderer);
+
+    if (length > STRING_BUFFER_SIZE) {
+        keepCount = STRING_BUFFER_SIZE - 1; // need 1 character for the ellipsis
+        truncatedLength = centerTruncateToBuffer(string, length, keepCount, stringBuffer);
+    } else {
+        keepCount = length;
+        [string getCharacters:stringBuffer];
+        truncatedLength = length;
+    }
+
+    width = stringWidth(currentRenderer, stringBuffer, truncatedLength);
+    if (width <= maxWidth) {
+        return string;
+    }
+
+    keepCountForLargestKnownToFit = 0;
+    widthForLargestKnownToFit = currentEllipsisWidth;
+    
+    keepCountForSmallestKnownToNotFit = keepCount;
+    widthForSmallestKnownToNotFit = width;
+    
+    if (currentEllipsisWidth >= maxWidth) {
+        keepCountForLargestKnownToFit = 1;
+        keepCountForSmallestKnownToNotFit = 2;
+    }
+    
+    while (keepCountForLargestKnownToFit + 1 < keepCountForSmallestKnownToNotFit) {
+        ASSERT(widthForLargestKnownToFit <= maxWidth);
+        ASSERT(widthForSmallestKnownToNotFit > maxWidth);
+
+        ratio = (keepCountForSmallestKnownToNotFit - keepCountForLargestKnownToFit)
+            / (widthForSmallestKnownToNotFit - widthForLargestKnownToFit);
+        keepCount = static_cast<unsigned>(maxWidth * ratio);
+        
+        if (keepCount <= keepCountForLargestKnownToFit) {
+            keepCount = keepCountForLargestKnownToFit + 1;
+        } else if (keepCount >= keepCountForSmallestKnownToNotFit) {
+            keepCount = keepCountForSmallestKnownToNotFit - 1;
+        }
+        
+        ASSERT(keepCount < length);
+        ASSERT(keepCount > 0);
+        ASSERT(keepCount < keepCountForSmallestKnownToNotFit);
+        ASSERT(keepCount > keepCountForLargestKnownToFit);
+        
+        truncatedLength = truncateToBuffer(string, length, keepCount, stringBuffer);
+
+        width = stringWidth(currentRenderer, stringBuffer, truncatedLength);
+        if (width <= maxWidth) {
+            keepCountForLargestKnownToFit = keepCount;
+            widthForLargestKnownToFit = width;
+        } else {
+            keepCountForSmallestKnownToNotFit = keepCount;
+            widthForSmallestKnownToNotFit = width;
+        }
+    }
+    
+    if (keepCountForLargestKnownToFit == 0) {
+        keepCountForLargestKnownToFit = 1;
+    }
+    
+    if (keepCount != keepCountForLargestKnownToFit) {
+        keepCount = keepCountForLargestKnownToFit;
+        truncatedLength = truncateToBuffer(string, length, keepCount, stringBuffer);
+    }
+    
+    return [NSString stringWithCharacters:stringBuffer length:truncatedLength];
+}
+
+@implementation WebCoreStringTruncator
+
+static NSFont *defaultMenuFont(void)
+{
+    static NSFont *defaultMenuFont = nil;
+    if (defaultMenuFont == nil) {
+        defaultMenuFont = [[NSFont menuFontOfSize:0] retain];
+    }
+    return defaultMenuFont;
+}
+
++ (NSString *)centerTruncateString:(NSString *)string toWidth:(float)maxWidth
+{
+    return truncateString(string, maxWidth, defaultMenuFont(), centerTruncateToBuffer);
+}
+
++ (NSString *)centerTruncateString:(NSString *)string toWidth:(float)maxWidth withFont:(NSFont *)font
+{
+    return truncateString(string, maxWidth, font, centerTruncateToBuffer);
+}
+
++ (NSString *)rightTruncateString:(NSString *)string toWidth:(float)maxWidth withFont:(NSFont *)font
+{
+    return truncateString(string, maxWidth, font, rightTruncateToBuffer);
+}
+
++ (float)widthOfString:(NSString *)string font:(NSFont *)font
+{
+    unsigned length = [string length];
+    unichar *s = static_cast<unichar*>(malloc(sizeof(unichar) * length));
+    [string getCharacters:s];
+    WebCoreFont f;
+    WebCoreInitializeFont(&f);
+    f.font = font;
+    float width = stringWidth([[WebCoreTextRendererFactory sharedFactory] rendererWithFont:f], s, length);
+    free(s);
+    return width;
+}
+
+@end
index 761e79a1eb8bc82b620894badae3b3ac96ae892e..90ed121f4f42594b78123f73e697cbd4fd2a8feb 100644 (file)
@@ -40,6 +40,8 @@
 - (NSString *)resetButtonDefaultLabel;
 - (NSString *)searchableIndexIntroduction;
 - (NSString *)submitButtonDefaultLabel;
+- (NSString *)fileButtonChooseFileLabel;
+- (NSString *)fileButtonNoFileSelectedLabel;
 
 - (NSMenu *)cellMenuForSearchField;
 
index 031564a94fbdb8ce2543efd970e43a2caade394a..f7c0aebf3adcff258ce0609daaab2850217b78d6 100644 (file)
@@ -30,9 +30,9 @@
 #include "Widget.h"
 
 #ifdef __OBJC__
-@class KWQFileButtonAdapter;
+@class WebCoreFileButton;
 #else
-class KWQFileButtonAdapter;
+class WebCoreFileButton;
 #endif
 
 namespace WebCore {
@@ -42,7 +42,6 @@ namespace WebCore {
 class KWQFileButton : public Widget {
 public:
     KWQFileButton(WebCore::Frame*);
-    ~KWQFileButton();
     
     void setFilename(const DeprecatedString &);
     void click(bool sendMouseEvents);
@@ -59,7 +58,7 @@ public:
     const WebCore::String& filename() const { return m_name; }
 
 private:
-    KWQFileButtonAdapter* _adapter;
+    WebCoreFileButton* _buttonView;
     WebCore::String m_name;
 };
 
index a4ad6f5c231cbfe035be24a2f209249989ceb6b7..1ae0ef6476160d7b1b6a428c25ffb3ffb71e35a9 100644 (file)
 #import "FoundationExtras.h"
 #import "FrameMac.h"
 #import "WebCoreFrameBridge.h"
+#import "WebCoreStringTruncator.h"
+#import "WebCoreViewFactory.h"
 #import "render_form.h"
 
 using namespace WebCore;
 
-@interface KWQFileButtonAdapter : NSObject <WebCoreFileButtonDelegate>
+#define NO_FILE_SELECTED 
+
+#define AFTER_BUTTON_SPACING 4
+#define ICON_HEIGHT 16
+#define ICON_WIDTH 16
+#define ICON_FILENAME_SPACING 2
+
+// We empirically determined that buttons have these extra pixels on all
+// sides. It would be better to get this info from AppKit somehow.
+#define BUTTON_TOP_MARGIN 4
+#define BUTTON_BOTTOM_MARGIN 6
+#define BUTTON_LEFT_MARGIN 5
+#define BUTTON_RIGHT_MARGIN 5
+
+// AppKit calls this kThemePushButtonSmallTextOffset.
+#define BUTTON_VERTICAL_FUDGE_FACTOR 2
+
+@interface WebFileChooserButton : NSButton
+{
+    KWQFileButton *_widget;
+}
+- (id)initWithWidget:(KWQFileButton *)widget;
+@end
+
+@interface WebCoreFileButton : NSView <WebCoreOpenPanelResultListener>
+{
+    NSString *_filename;
+    WebFileChooserButton *_button;
+    NSImage *_icon;
+    NSString *_label;
+    BOOL _inNextValidKeyView;
+    KWQFileButton *_widget;
+}
+- (void)setFilename:(NSString *)filename;
+- (void)performClick;
+- (NSString *)filename;
+- (float)baseline;
+- (void)setVisualFrame:(NSRect)rect;
+- (NSRect)visualFrame;
+- (NSSize)bestVisualFrameSizeForCharacterCount:(int)count;
+- (id)initWithWidget:(KWQFileButton *)widget;
+@end
+
+@implementation WebCoreFileButton
+
+- (void)positionButton
 {
-@public
-    KWQFileButton *button;
+    [_button sizeToFit];
+    [_button setFrameOrigin:NSMakePoint(0, 0)];
 }
 
-- initWithKWQFileButton:(KWQFileButton *)button;
+- (id)initWithWidget:(KWQFileButton*)widget
+{
+    self = [super init];
+    if (!self)
+        return nil;
+
+    _widget = widget;
+    return self;
+}
 
-- (void)filenameChanged:(NSString *)filename;
-- (void)focusChanged:(BOOL)nowHasFocus;
-- (void)clicked;
+- (id)initWithFrame:(NSRect)frame
+{
+    self = [super initWithFrame:frame];
+    if (self) {
+        _button = [[WebFileChooserButton alloc] initWithWidget:_widget];
+        
+        [_button setTitle:[[WebCoreViewFactory sharedFactory] fileButtonChooseFileLabel]];
+        [[_button cell] setControlSize:NSSmallControlSize];
+        [_button setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
+        [_button setBezelStyle:NSRoundedBezelStyle];
+        [_button setTarget:self];
+        [_button setAction:@selector(chooseButtonPressed:)];
+        [_button setNextResponder:self];
+        
+        [self addSubview:_button];
+        
+        [self positionButton];
+        [self setFilename:nil];
+    }
+    return self;
+}
+
+- (void)dealloc
+{
+    [_filename release];
+    [_button release];
+    [_icon release];
+    [_label release];
+    [super dealloc];
+}
+
+- (BOOL)isFlipped
+{
+    return YES;
+}
+        
+- (void)drawRect:(NSRect)rect
+{
+    NSRect bounds = [self bounds];
+    
+    [NSGraphicsContext saveGraphicsState];
+    NSRectClip(NSIntersectionRect(bounds, rect));
+
+    float left = NSMaxX([_button frame]) + AFTER_BUTTON_SPACING;
+
+    if (_icon) {
+        float top = (bounds.size.height - BUTTON_BOTTOM_MARGIN - BUTTON_TOP_MARGIN - ICON_HEIGHT) / 2
+            + BUTTON_TOP_MARGIN;
+        [_icon drawInRect:NSMakeRect(left, top, 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 = [_button font];
+    NSDictionary *attributes = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
+    [_label drawAtPoint:NSMakePoint(left, [self baseline] - [[_button font] ascender]) withAttributes:attributes];
+
+    [NSGraphicsContext restoreGraphicsState];
+}
+
+- (void)updateLabel
+{
+    [_label release];
+    
+    NSString *label;
+    if ([_filename length]) {
+        label = _filename;
+    } else {
+        label = [[WebCoreViewFactory sharedFactory] fileButtonNoFileSelectedLabel];
+    }
+    
+    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 : [[WebCoreStringTruncator centerTruncateString:
+        [[NSFileManager defaultManager] displayNameAtPath:label]
+        toWidth:labelWidth withFont:[_button font]] copy];
+}
+
+- (void)setFilename:(NSString *)filename
+{
+    NSString *copy = [filename copy];
+    [_filename release];
+    _filename = copy;
+    
+    [_icon release];
+    if ([_filename length] == 0 || [_filename characterAtIndex:0] != '/') {
+        _icon = nil;
+    } else {
+        _icon = [[[NSWorkspace sharedWorkspace] iconForFile:_filename] retain];
+        // I'm not sure why this has any effect, but including this line of code seems to make
+        // the image appear right-side-up. As far as I know, the drawInRect method used above
+        // in our drawRect method should work regardless of whether the image is flipped or not.
+        [_icon setFlipped:YES];
+    }
+    
+    [self updateLabel];
+    
+    [self setNeedsDisplay:YES];
+}
+
+- (NSString *)filename
+{
+    return [[_filename copy] autorelease];
+}
+
+- (void)setFrameSize:(NSSize)size
+{
+    [super setFrameSize:size];
+    // FIXME: Can we just springs and struts instead of calling positionButton?
+    [self positionButton];
+    [self updateLabel];
+}
+
+- (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 += AFTER_BUTTON_SPACING + ICON_WIDTH + ICON_FILENAME_SPACING;
+    size.width += count * [@"x" sizeWithAttributes:[NSDictionary dictionaryWithObject:[_button font] forKey:NSFontAttributeName]].width;
+    return size;
+}
+
+- (NSRect)visualFrame
+{
+    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_TOP_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_TOP_MARGIN;
+    frame.size.height += BUTTON_TOP_MARGIN + BUTTON_BOTTOM_MARGIN;
+    [self setFrame:frame];
+}
+
+- (float)baseline
+{
+    // 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_TOP_MARGIN
+        + ([[_button cell] cellSize].height + BUTTON_TOP_MARGIN + BUTTON_BOTTOM_MARGIN - (ascender - descender)) / 2.0
+        + ascender - BUTTON_VERTICAL_FUDGE_FACTOR;
+}
+
+- (void)beginSheet
+{
+    WebCoreFrameBridge *bridge = FrameMac::bridgeForWidget(_widget);
+    [bridge retain];
+    [bridge runOpenPanelForFileButtonWithResultListener:self];
+}
+
+- (void)chooseFilename:(NSString *)filename
+{
+    // The != check here makes sure we don't consider a change from nil to nil as a change.
+    if (_filename != filename && ![_filename isEqualToString:filename]) {
+        [self setFilename:filename];
+        if (_widget)
+            _widget->filenameChanged(DeprecatedString::fromNSString(filename));
+    }
+    WebCoreFrameBridge *bridge = FrameMac::bridgeForWidget(_widget);
+    [bridge release];
+}
+
+- (void)cancel
+{
+    WebCoreFrameBridge *bridge = FrameMac::bridgeForWidget(_widget);
+    [bridge release];
+}
+
+- (void)chooseButtonPressed:(id)sender
+{
+    if (_widget)
+        _widget->sendConsumedMouseUp();
+    if (_widget && _widget->client())
+        _widget->client()->clicked(_widget);
+    [self beginSheet];
+}
+
+- (void)mouseDown:(NSEvent *)event
+{
+    [self beginSheet];
+}
+
+- (BOOL)acceptsFirstResponder
+{
+    return YES;
+}
+
+- (BOOL)becomeFirstResponder
+{
+    BOOL become = [_button acceptsFirstResponder];
+    if (become) {
+        if (_widget && _widget->client() && !FrameMac::currentEventIsMouseDownInWidget(_widget))
+            _widget->client()->scrollToVisible(_widget);
+        if (_widget && _widget->client())
+            _widget->client()->focusIn(_widget);
+        [[self window] makeFirstResponder:_button];
+    }
+    return become;
+}
+
+- (NSView *)nextKeyView
+{
+    return _inNextValidKeyView
+    ? FrameMac::nextKeyViewForWidget(_widget, KWQSelectingNext)
+    : [super nextKeyView];
+}
+
+- (NSView *)previousKeyView
+{
+    return _inNextValidKeyView
+    ? FrameMac::nextKeyViewForWidget(_widget, KWQSelectingPrevious)
+    : [super previousKeyView];
+}
+
+- (NSView *)nextValidKeyView
+{
+    _inNextValidKeyView = YES;
+    NSView *view = [super nextValidKeyView];
+    _inNextValidKeyView = NO;
+    return view;
+}
+
+- (NSView *)previousValidKeyView
+{
+    _inNextValidKeyView = YES;
+    NSView *view = [super previousValidKeyView];
+    _inNextValidKeyView = NO;
+    return view;
+}
+
+- (void)performClick
+{
+    [_button performClick:nil];
+}
 
 @end
 
-KWQFileButton::KWQFileButton(Frame *frame)
-    : _adapter(0)
+@implementation WebFileChooserButton
+
+- (id)initWithWidget:(KWQFileButton *)widget
 {
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
+    [super init];
+    _widget = widget;
+    return self;
+}
+
+- (NSView *)nextValidKeyView
+{
+    return [[self superview] nextValidKeyView];
+}
 
-    _adapter = KWQRetainNSRelease([[KWQFileButtonAdapter alloc] initWithKWQFileButton:this]);
-    setView([Mac(frame)->bridge() fileButtonWithDelegate:_adapter]);
+- (NSView *)previousValidKeyView
+{
+    return [[self superview] previousValidKeyView];
+}
 
-    END_BLOCK_OBJC_EXCEPTIONS;
+- (BOOL)resignFirstResponder
+{
+    if (_widget && _widget->client())
+        _widget->client()->focusOut(_widget);
+    return YES;
 }
 
-KWQFileButton::~KWQFileButton()
+@end
+
+
+KWQFileButton::KWQFileButton(Frame *frame)
 {
-    _adapter->button = 0;
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    CFRelease(_adapter);
+
+    _buttonView = [[WebCoreFileButton alloc] initWithWidget:this];
+    setView(_buttonView);
+
     END_BLOCK_OBJC_EXCEPTIONS;
 }
-    
+
 void KWQFileButton::setFilename(const DeprecatedString &f)
 {
-    NSView <WebCoreFileButton> *button = getView();
-
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    [button setFilename:f.getNSString()];
+    [_buttonView setFilename:f.getNSString()];
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
 void KWQFileButton::click(bool sendMouseEvents)
 {
-    NSView <WebCoreFileButton> *button = getView();
-
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    [button performClick];
+    [_buttonView performClick];
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
 IntSize KWQFileButton::sizeForCharacterWidth(int characters) const
 {
     ASSERT(characters > 0);
-    NSView <WebCoreFileButton> *button = getView();
 
     NSSize size = {0,0};
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    size = [button bestVisualFrameSizeForCharacterCount:characters];
+    size = [_buttonView bestVisualFrameSizeForCharacterCount:characters];
     return IntSize(size);
     END_BLOCK_OBJC_EXCEPTIONS;
     return IntSize(0, 0);
@@ -100,29 +420,23 @@ IntSize KWQFileButton::sizeForCharacterWidth(int characters) const
 
 IntRect KWQFileButton::frameGeometry() const
 {
-    NSView <WebCoreFileButton> *button = getView();
-
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    return enclosingIntRect([button visualFrame]);
+    return enclosingIntRect([_buttonView visualFrame]);
     END_BLOCK_OBJC_EXCEPTIONS;
     return IntRect();
 }
 
 void KWQFileButton::setFrameGeometry(const IntRect &rect)
 {
-    NSView <WebCoreFileButton> *button = getView();
-
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    [button setVisualFrame:rect];
+    [_buttonView setVisualFrame:rect];
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
 int KWQFileButton::baselinePosition(int height) const
 {
-    NSView <WebCoreFileButton> *button = getView();
-
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    return (int)([button frame].origin.y + [button baseline] - [button visualFrame].origin.y);
+    return (int)([_buttonView frame].origin.y + [_buttonView baseline] - [_buttonView visualFrame].origin.y);
     END_BLOCK_OBJC_EXCEPTIONS;
 
     return 0;
@@ -148,41 +462,3 @@ void KWQFileButton::filenameChanged(const DeprecatedString& filename)
     if (client())
         client()->valueChanged(this);
 }
-
-@implementation KWQFileButtonAdapter
-
-- initWithKWQFileButton:(KWQFileButton *)b
-{
-    [super init];
-    button = b;
-    return self;
-}
-
-- (void)filenameChanged:(NSString *)filename
-{
-    if (button)
-        button->filenameChanged(DeprecatedString::fromNSString(filename));
-}
-
-- (void)focusChanged:(BOOL)nowHasFocus
-{
-    if (nowHasFocus) {
-        if (button && button->client() && !FrameMac::currentEventIsMouseDownInWidget(button))
-            button->client()->scrollToVisible(button);
-        if (button && button->client())
-            button->client()->focusIn(button);
-    } else {
-        if (button && button->client())
-            button->client()->focusOut(button);
-    }
-}
-
--(void)clicked
-{
-    if (button)
-        button->sendConsumedMouseUp();
-    if (button && button->client())
-        button->client()->clicked(button);
-}
-
-@end
index bea02ae3b823b5266902381f8233901fe8d2af44..eb0aad8d07a02f1cbfcce504e1bb9ef566c2edf4 100644 (file)
@@ -1,3 +1,25 @@
+2006-04-23  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Darin.
+        
+        - push WebFileButton and WebStringTruncator code down to WebCore
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=8552
+
+        * Misc/WebStringTruncator.m:
+        (+[WebStringTruncator centerTruncateString:toWidth:]):
+        (+[WebStringTruncator centerTruncateString:toWidth:withFont:]):
+        (+[WebStringTruncator rightTruncateString:toWidth:withFont:]):
+        (+[WebStringTruncator widthOfString:font:]):
+        * WebCoreSupport/WebFileButton.h: Removed.
+        * WebCoreSupport/WebFileButton.m: Removed.
+        * WebCoreSupport/WebFrameBridge.h:
+        * WebCoreSupport/WebFrameBridge.m:
+        (-[WebFrameBridge runOpenPanelForFileButtonWithResultListener:]):
+        * WebCoreSupport/WebViewFactory.m:
+        (-[WebViewFactory fileButtonChooseFileLabel]):
+        (-[WebViewFactory fileButtonNoFileSelectedLabel]):
+        * WebKit.xcodeproj/project.pbxproj:
+
 2006-04-23  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Eric.
index eddd9b72f248cc1d5266e3370874c1537b3fd253..b98295929a03db3632aa359d81622278fca87443 100644 (file)
 
 #import <WebKit/WebStringTruncator.h>
 
-#import <Cocoa/Cocoa.h>
-
-#import <JavaScriptCore/Assertions.h>
+#import <WebCore/WebCoreStringTruncator.h>
 #import <WebKit/WebTextRendererFactory.h>
-#import <WebKit/WebTextRenderer.h>
-
-#define STRING_BUFFER_SIZE 2048
-#define ELLIPSIS_CHARACTER 0x2026
-
-static NSFont *currentFont;
-static WebTextRenderer *currentRenderer;
-static float currentEllipsisWidth;
-
-typedef unsigned TruncationFunction(NSString *string, unsigned length, unsigned keepCount, unichar *buffer);
-
-static unsigned centerTruncateToBuffer(NSString *string, unsigned length, unsigned keepCount, unichar *buffer)
-{
-    ASSERT(keepCount < length);
-    ASSERT(keepCount < STRING_BUFFER_SIZE);
-    
-    unsigned omitStart = (keepCount + 1) / 2;
-    unsigned omitEnd = NSMaxRange([string rangeOfComposedCharacterSequenceAtIndex:omitStart + (length - keepCount) - 1]);
-    omitStart = [string rangeOfComposedCharacterSequenceAtIndex:omitStart].location;
-    
-    NSRange beforeRange = NSMakeRange(0, omitStart);
-    NSRange afterRange = NSMakeRange(omitEnd, length - omitEnd);
-    
-    unsigned truncatedLength = beforeRange.length + 1 + afterRange.length;
-    ASSERT(truncatedLength <= length);
-
-    [string getCharacters:buffer range:beforeRange];
-    buffer[beforeRange.length] = ELLIPSIS_CHARACTER;
-    [string getCharacters:&buffer[beforeRange.length + 1] range:afterRange];
-    
-    return truncatedLength;
-}
-
-static unsigned rightTruncateToBuffer(NSString *string, unsigned length, unsigned keepCount, unichar *buffer)
-{
-    ASSERT(keepCount < length);
-    ASSERT(keepCount < STRING_BUFFER_SIZE);
-    
-    NSRange keepRange = NSMakeRange(0, [string rangeOfComposedCharacterSequenceAtIndex:keepCount].location);
-    
-    [string getCharacters:buffer range:keepRange];
-    buffer[keepRange.length] = ELLIPSIS_CHARACTER;
-    
-    return keepRange.length + 1;
-}
-
-static float stringWidth(WebTextRenderer *renderer, const unichar *characters, unsigned length)
-{
-    WebCoreTextRun run;
-    WebCoreInitializeTextRun (&run, characters, length, 0, length);
-    WebCoreTextStyle style;
-    WebCoreInitializeEmptyTextStyle(&style);
-    style.applyRunRounding = NO;
-    style.applyWordRounding = NO;
-    return [renderer floatWidthForRun:&run style:&style];
-}
-
-static NSString *truncateString(NSString *string, float maxWidth, NSFont *font, TruncationFunction truncateToBuffer)
-{
-    unsigned length = [string length];
-    if (length == 0) {
-        return string;
-    }
-
-    unichar stringBuffer[STRING_BUFFER_SIZE];
-    unsigned keepCount;
-    unsigned truncatedLength;
-    float width;
-    unichar ellipsis;
-    unsigned keepCountForLargestKnownToFit, keepCountForSmallestKnownToNotFit;
-    float widthForLargestKnownToFit, widthForSmallestKnownToNotFit;
-    float ratio;
-    
-    ASSERT_ARG(font, font);
-    ASSERT_ARG(maxWidth, maxWidth >= 0);
-    
-    if (![currentFont isEqual:font]) {
-        [currentFont release];
-        currentFont = [font retain];
-        [currentRenderer release];
-        [WebTextRendererFactory createSharedFactory];
-        WebCoreFont f;
-        WebCoreInitializeFont(&f);
-        f.font = font;
-        currentRenderer = [[[WebTextRendererFactory sharedFactory] rendererWithFont:f] retain];
-        ellipsis = ELLIPSIS_CHARACTER;
-        currentEllipsisWidth = stringWidth(currentRenderer, &ellipsis, 1);
-    }
-    
-    ASSERT(currentRenderer);
-
-    if (length > STRING_BUFFER_SIZE) {
-        keepCount = STRING_BUFFER_SIZE - 1; // need 1 character for the ellipsis
-        truncatedLength = centerTruncateToBuffer(string, length, keepCount, stringBuffer);
-    } else {
-        keepCount = length;
-        [string getCharacters:stringBuffer];
-        truncatedLength = length;
-    }
-
-    width = stringWidth(currentRenderer, stringBuffer, truncatedLength);
-    if (width <= maxWidth) {
-        return string;
-    }
-
-    keepCountForLargestKnownToFit = 0;
-    widthForLargestKnownToFit = currentEllipsisWidth;
-    
-    keepCountForSmallestKnownToNotFit = keepCount;
-    widthForSmallestKnownToNotFit = width;
-    
-    if (currentEllipsisWidth >= maxWidth) {
-        keepCountForLargestKnownToFit = 1;
-        keepCountForSmallestKnownToNotFit = 2;
-    }
-    
-    while (keepCountForLargestKnownToFit + 1 < keepCountForSmallestKnownToNotFit) {
-        ASSERT(widthForLargestKnownToFit <= maxWidth);
-        ASSERT(widthForSmallestKnownToNotFit > maxWidth);
-
-        ratio = (keepCountForSmallestKnownToNotFit - keepCountForLargestKnownToFit)
-            / (widthForSmallestKnownToNotFit - widthForLargestKnownToFit);
-        keepCount = maxWidth * ratio;
-        
-        if (keepCount <= keepCountForLargestKnownToFit) {
-            keepCount = keepCountForLargestKnownToFit + 1;
-        } else if (keepCount >= keepCountForSmallestKnownToNotFit) {
-            keepCount = keepCountForSmallestKnownToNotFit - 1;
-        }
-        
-        ASSERT(keepCount < length);
-        ASSERT(keepCount > 0);
-        ASSERT(keepCount < keepCountForSmallestKnownToNotFit);
-        ASSERT(keepCount > keepCountForLargestKnownToFit);
-        
-        truncatedLength = truncateToBuffer(string, length, keepCount, stringBuffer);
-
-        width = stringWidth(currentRenderer, stringBuffer, truncatedLength);
-        if (width <= maxWidth) {
-            keepCountForLargestKnownToFit = keepCount;
-            widthForLargestKnownToFit = width;
-        } else {
-            keepCountForSmallestKnownToNotFit = keepCount;
-            widthForSmallestKnownToNotFit = width;
-        }
-    }
-    
-    if (keepCountForLargestKnownToFit == 0) {
-        keepCountForLargestKnownToFit = 1;
-    }
-    
-    if (keepCount != keepCountForLargestKnownToFit) {
-        keepCount = keepCountForLargestKnownToFit;
-        truncatedLength = truncateToBuffer(string, length, keepCount, stringBuffer);
-    }
-    
-    return [NSString stringWithCharacters:stringBuffer length:truncatedLength];
-}
 
 @implementation WebStringTruncator
 
-static NSFont *defaultMenuFont(void)
-{
-    static NSFont *defaultMenuFont = nil;
-    if (defaultMenuFont == nil) {
-        defaultMenuFont = [[NSFont menuFontOfSize:0] retain];
-    }
-    return defaultMenuFont;
-}
-
 + (NSString *)centerTruncateString:(NSString *)string toWidth:(float)maxWidth
 {
-    return truncateString(string, maxWidth, defaultMenuFont(), centerTruncateToBuffer);
+    [WebTextRendererFactory createSharedFactory];
+    return [WebCoreStringTruncator centerTruncateString:string toWidth:maxWidth];
 }
 
 + (NSString *)centerTruncateString:(NSString *)string toWidth:(float)maxWidth withFont:(NSFont *)font
 {
-    return truncateString(string, maxWidth, font, centerTruncateToBuffer);
+    [WebTextRendererFactory createSharedFactory];
+    return [WebCoreStringTruncator centerTruncateString:string toWidth:maxWidth withFont:font];
 }
 
 + (NSString *)rightTruncateString:(NSString *)string toWidth:(float)maxWidth withFont:(NSFont *)font
 {
-    return truncateString(string, maxWidth, font, rightTruncateToBuffer);
+    [WebTextRendererFactory createSharedFactory];
+    return [WebCoreStringTruncator rightTruncateString:string toWidth:maxWidth withFont:font];
 }
 
 + (float)widthOfString:(NSString *)string font:(NSFont *)font
 {
-    unsigned length = [string length];
-    unichar *s = malloc(sizeof(unichar) * length);
-    [string getCharacters:s];
-    WebCoreFont f;
-    WebCoreInitializeFont(&f);
-    f.font = font;
-    float width = stringWidth([[WebTextRendererFactory sharedFactory] rendererWithFont:f], s, length);
-    free(s);
-    return width;
+    [WebTextRendererFactory createSharedFactory];
+    return [WebCoreStringTruncator widthOfString:string font:font];
 }
 
 @end
diff --git a/WebKit/WebCoreSupport/WebFileButton.m b/WebKit/WebCoreSupport/WebFileButton.m
deleted file mode 100644 (file)
index c96e243..0000000
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer. 
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution. 
- * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebFileButton.h"
-
-#import <JavaScriptCore/Assertions.h>
-#import <WebKit/WebLocalizableStrings.h>
-#import <WebKit/WebFrameBridge.h>
-#import <WebKit/WebStringTruncator.h>
-
-#define NO_FILE_SELECTED 
-
-#define AFTER_BUTTON_SPACING 4
-#define ICON_HEIGHT 16
-#define ICON_WIDTH 16
-#define ICON_FILENAME_SPACING 2
-
-// We empirically determined that buttons have these extra pixels on all
-// sides. It would be better to get this info from AppKit somehow.
-#define BUTTON_TOP_MARGIN 4
-#define BUTTON_BOTTOM_MARGIN 6
-#define BUTTON_LEFT_MARGIN 5
-#define BUTTON_RIGHT_MARGIN 5
-
-// AppKit calls this kThemePushButtonSmallTextOffset.
-#define BUTTON_VERTICAL_FUDGE_FACTOR 2
-
-@interface WebFileChooserButton : NSButton
-{
-    id <WebCoreFileButtonDelegate> _delegate;
-}
-- (id)initWithDelegate:(id <WebCoreFileButtonDelegate>)delegate;
-@end
-
-@implementation WebFileButton
-
-- (void)positionButton
-{
-    [_button sizeToFit];
-    [_button setFrameOrigin:NSMakePoint(0, 0)];
-}
-
-- (id)initWithBridge:(WebFrameBridge *)bridge delegate:(id <WebCoreFileButtonDelegate>)delegate
-{
-    self = [super init];
-    if (self) {
-        _bridge = bridge; // Don't retain to avoid cycle
-        _delegate = [delegate retain];
-    }
-    return self;
-}
-
-- (id)initWithFrame:(NSRect)frame
-{
-    self = [super initWithFrame:frame];
-    if (self) {
-        _button = [[WebFileChooserButton alloc] initWithDelegate:_delegate];
-        
-        [_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:)];
-        [_button setNextResponder:self];
-        
-        [self addSubview:_button];
-        
-        [self positionButton];
-        [self setFilename:nil];
-    }
-    return self;
-}
-
-- (void)dealloc
-{
-    [_filename release];
-    [_button release];
-    [_icon release];
-    [_label release];
-    [_delegate release];
-    [super dealloc];
-}
-
-- (BOOL)isFlipped
-{
-    return YES;
-}
-        
-- (void)drawRect:(NSRect)rect
-{
-    NSRect bounds = [self bounds];
-    
-    [NSGraphicsContext saveGraphicsState];
-    NSRectClip(NSIntersectionRect(bounds, rect));
-
-    float left = NSMaxX([_button frame]) + AFTER_BUTTON_SPACING;
-
-    if (_icon) {
-        float top = (bounds.size.height - BUTTON_BOTTOM_MARGIN - BUTTON_TOP_MARGIN - ICON_HEIGHT) / 2
-            + BUTTON_TOP_MARGIN;
-        [_icon drawInRect:NSMakeRect(left, top, 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 = [_button font];
-    NSDictionary *attributes = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
-    [_label drawAtPoint:NSMakePoint(left, [self baseline] - [[_button font] ascender]) withAttributes:attributes];
-
-    [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;
-    
-    [_icon release];
-    if ([_filename length] == 0 || [_filename characterAtIndex:0] != '/') {
-        _icon = nil;
-    } else {
-        _icon = [[[NSWorkspace sharedWorkspace] iconForFile:_filename] retain];
-        // I'm not sure why this has any effect, but including this line of code seems to make
-        // the image appear right-side-up. As far as I know, the drawInRect method used above
-        // in our drawRect method should work regardless of whether the image is flipped or not.
-        [_icon setFlipped:YES];
-    }
-    
-    [self updateLabel];
-    
-    [self setNeedsDisplay:YES];
-}
-
-- (NSString *)filename
-{
-    return [[_filename copy] autorelease];
-}
-
-- (void)setFrameSize:(NSSize)size
-{
-    [super setFrameSize:size];
-    // FIXME: Can we just springs and struts instead of calling positionButton?
-    [self positionButton];
-    [self updateLabel];
-}
-
-- (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 += AFTER_BUTTON_SPACING + ICON_WIDTH + ICON_FILENAME_SPACING;
-    size.width += count * [@"x" sizeWithAttributes:[NSDictionary dictionaryWithObject:[_button font] forKey:NSFontAttributeName]].width;
-    return size;
-}
-
-- (NSRect)visualFrame
-{
-    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_TOP_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_TOP_MARGIN;
-    frame.size.height += BUTTON_TOP_MARGIN + BUTTON_BOTTOM_MARGIN;
-    [self setFrame:frame];
-}
-
-- (float)baseline
-{
-    // 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_TOP_MARGIN
-        + ([[_button cell] cellSize].height + BUTTON_TOP_MARGIN + BUTTON_BOTTOM_MARGIN - (ascender - descender)) / 2.0
-        + ascender - BUTTON_VERTICAL_FUDGE_FACTOR;
-}
-
-- (void)beginSheet
-{
-    [_bridge retain];
-    [_bridge runOpenPanelForFileButtonWithResultListener:self];
-}
-
-- (void)chooseFilename:(NSString *)filename
-{
-    // The != check here makes sure we don't consider a change from nil to nil as a change.
-    if (_filename != filename && ![_filename isEqualToString:filename]) {
-        [self setFilename:filename];
-        [_delegate filenameChanged:filename];
-    }
-    [_bridge release];
-}
-
-- (void)cancel
-{
-    [_bridge release];
-}
-
-- (void)chooseButtonPressed:(id)sender
-{
-    [_delegate clicked];
-    [self beginSheet];
-}
-
-- (void)mouseDown:(NSEvent *)event
-{
-    [self beginSheet];
-}
-
-- (BOOL)acceptsFirstResponder
-{
-    return YES;
-}
-
-- (BOOL)becomeFirstResponder
-{
-    BOOL become = [_button acceptsFirstResponder];
-    if (become) {
-        [_delegate focusChanged:YES];
-        [[self window] makeFirstResponder:_button];
-    }
-    return become;
-}
-
-- (NSView *)nextKeyView
-{
-    return (_inNextValidKeyView && ![_bridge inNextKeyViewOutsideWebFrameViews])
-    ? [_bridge nextKeyView]
-    : [super nextKeyView];
-}
-
-- (NSView *)previousKeyView
-{
-    return (_inNextValidKeyView)
-    ? [_bridge previousKeyView]
-    : [super previousKeyView];
-}
-
-- (NSView *)nextValidKeyView
-{
-    _inNextValidKeyView = YES;
-    NSView *view = [super nextValidKeyView];
-    _inNextValidKeyView = NO;
-    return view;
-}
-
-- (NSView *)previousValidKeyView
-{
-    _inNextValidKeyView = YES;
-    NSView *view = [super previousValidKeyView];
-    _inNextValidKeyView = NO;
-    return view;
-}
-
-- (void)performClick
-{
-    [_button performClick:nil];
-}
-
-@end
-
-@implementation WebFileChooserButton
-
-- (id)initWithDelegate:(id <WebCoreFileButtonDelegate>)delegate
-{
-    [super init];
-    _delegate = delegate; // Don't retain to avoid cycle
-    return self;
-}
-
-- (NSView *)nextValidKeyView
-{
-    return [[self superview] nextValidKeyView];
-}
-
-- (NSView *)previousValidKeyView
-{
-    return [[self superview] previousValidKeyView];
-}
-
-- (BOOL)resignFirstResponder
-{
-    [_delegate focusChanged:NO];
-    return YES;
-}
-
-@end
index 1894bb659c83e983fa2649faf476a55c2255f18c..0067cf39e6a79432d6ee9c4d07d75bc7970cc69e 100644 (file)
@@ -53,7 +53,6 @@
 - (void)close;
 
 - (void)receivedData:(NSData *)data textEncodingName:(NSString *)textEncodingName;
-- (void)runOpenPanelForFileButtonWithResultListener:(id <WebOpenPanelResultListener>)resultListener;
 - (BOOL)inNextKeyViewOutsideWebFrameViews;
 
 - (WebFrame *)webFrame;
index a83600d48166ae656bf029bf7ea1e1338a1adac0..a2822ec58c756fe95499e734872b0cb0109e7f73 100644 (file)
@@ -35,7 +35,6 @@
 #import "WebDataSourcePrivate.h"
 #import "WebDefaultUIDelegate.h"
 #import "WebEditingDelegate.h"
-#import "WebFileButton.h"
 #import "WebFormDataStream.h"
 #import "WebFormDelegate.h"
 #import "WebFrameInternal.h"
@@ -408,18 +407,12 @@ NSString *WebPluginContainerKey =   @"WebPluginContainer";
         [wd webView:wv addMessageToConsole:message];
 }
 
-- (NSView <WebCoreFileButton> *)fileButtonWithDelegate:(id <WebCoreFileButtonDelegate>)delegate
-{
-    return [[[WebFileButton alloc] initWithBridge:self delegate:delegate] autorelease];
-}
-
-- (void)runOpenPanelForFileButtonWithResultListener:(id<WebOpenPanelResultListener>)resultListener
+- (void)runOpenPanelForFileButtonWithResultListener:(id<WebCoreOpenPanelResultListener>)resultListener
 {
     WebView *wv = [self webView];
-    [[wv _UIDelegateForwarder] webView:wv runOpenPanelForFileButtonWithResultListener:resultListener];
+    [[wv _UIDelegateForwarder] webView:wv runOpenPanelForFileButtonWithResultListener:(id<WebOpenPanelResultListener>)resultListener];
 }
 
-
 - (WebDataSource *)dataSource
 {
     ASSERT(_frame != nil);
index c1d0fe7ec6c9a04743d298e6b7b39b72c2762940..27e5e9b3fa14e2aff807edcbfbe61dc0d58f3fca 100644 (file)
     return UI_STRING("Submit", "default label for Submit buttons in forms on web pages");
 }
 
+- (NSString *)fileButtonChooseFileLabel
+{
+    return UI_STRING("Choose File", "title for file button used in HTML forms");
+}
+
+- (NSString *)fileButtonNoFileSelectedLabel
+{
+    return UI_STRING("no file selected", "text to display in file button used in HTML forms when no file is selected");
+}
+
 - (NSMenu *)cellMenuForSearchField
 {
     NSMenu* cellMenu = [[[NSMenu alloc] initWithTitle:@""] autorelease];
index 7cc4e5608b33463088bbe6c8757e0771ce50c7fc..1d393b075831a9050ed05e6134c1dbad57fe411a 100644 (file)
@@ -89,7 +89,6 @@
                939810390824BF01008DF038 /* WebPluginPackage.h in Headers */ = {isa = PBXBuildFile; fileRef = 83E4AF4B036659440000E506 /* WebPluginPackage.h */; };
                9398103A0824BF01008DF038 /* WebPluginViewFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 848DFF860365FE6A00CA2ACA /* WebPluginViewFactory.h */; settings = {ATTRIBUTES = (Public, ); }; };
                9398103C0824BF01008DF038 /* WebFrameBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = F5AFB45E02B94DC8018635CA /* WebFrameBridge.h */; };
-               9398103E0824BF01008DF038 /* WebFileButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 9311022803667CF1008635CE /* WebFileButton.h */; };
                939810400824BF01008DF038 /* WebImageRenderer.h in Headers */ = {isa = PBXBuildFile; fileRef = 9CE1F8A002A5C6F30ECA2ACD /* WebImageRenderer.h */; };
                939810410824BF01008DF038 /* WebImageRendererFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 9CE1F8A202A5C6F30ECA2ACD /* WebImageRendererFactory.h */; };
                939810420824BF01008DF038 /* WebJavaScriptTextInputPanel.h in Headers */ = {isa = PBXBuildFile; fileRef = 9345D4EA0365C5B2008635CE /* WebJavaScriptTextInputPanel.h */; settings = {ATTRIBUTES = (Private, ); }; };
                939810DC0824BF01008DF038 /* WebPluginPackage.m in Sources */ = {isa = PBXBuildFile; fileRef = 83E4AF4C036659440000E506 /* WebPluginPackage.m */; };
                939810DD0824BF01008DF038 /* npapi.m in Sources */ = {isa = PBXBuildFile; fileRef = F5F717230288493C018635CA /* npapi.m */; };
                939810DE0824BF01008DF038 /* WebFrameBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = F5AFB45F02B94DC8018635CA /* WebFrameBridge.m */; };
-               939810E00824BF01008DF038 /* WebFileButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 9311022903667CF1008635CE /* WebFileButton.m */; };
                939810E20824BF01008DF038 /* WebImageRenderer.m in Sources */ = {isa = PBXBuildFile; fileRef = 9CE1F8A102A5C6F30ECA2ACD /* WebImageRenderer.m */; };
                939810E30824BF01008DF038 /* WebImageRendererFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = 9CE1F8A302A5C6F30ECA2ACD /* WebImageRendererFactory.m */; };
                939810E40824BF01008DF038 /* WebJavaScriptTextInputPanel.m in Sources */ = {isa = PBXBuildFile; fileRef = 9345D4EB0365C5B2008635CE /* WebJavaScriptTextInputPanel.m */; };
                9305892A070868B300E79D96 /* WebDashboardRegion.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebDashboardRegion.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                930D02BB06275F640076701E /* WebViewInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebViewInternal.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                930D02BD06275F710076701E /* WebFrameInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebFrameInternal.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
-               9311022803667CF1008635CE /* WebFileButton.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebFileButton.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
-               9311022903667CF1008635CE /* WebFileButton.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebFileButton.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                93154EF103A41270008635CE /* WebPanelAuthenticationHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebPanelAuthenticationHandler.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                93154EF203A41270008635CE /* WebPanelAuthenticationHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebPanelAuthenticationHandler.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                93185DB506679F42005D5E7E /* WebHTMLViewInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebHTMLViewInternal.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                                F5AFB45E02B94DC8018635CA /* WebFrameBridge.h */,
                                F5AFB45F02B94DC8018635CA /* WebFrameBridge.m */,
                                9305892A070868B300E79D96 /* WebDashboardRegion.h */,
-                               9311022803667CF1008635CE /* WebFileButton.h */,
-                               9311022903667CF1008635CE /* WebFileButton.m */,
                                514C4C2A075E7DE500B89CAD /* WebImageDecodeItem.h */,
                                514C4C2B075E7DE500B89CAD /* WebImageDecodeItem.m */,
                                514C4C2C075E7DE500B89CAD /* WebImageDecoder.h */,
                                939810390824BF01008DF038 /* WebPluginPackage.h in Headers */,
                                9398103A0824BF01008DF038 /* WebPluginViewFactory.h in Headers */,
                                9398103C0824BF01008DF038 /* WebFrameBridge.h in Headers */,
-                               9398103E0824BF01008DF038 /* WebFileButton.h in Headers */,
                                939810400824BF01008DF038 /* WebImageRenderer.h in Headers */,
                                939810410824BF01008DF038 /* WebImageRendererFactory.h in Headers */,
                                939810420824BF01008DF038 /* WebJavaScriptTextInputPanel.h in Headers */,
                                939810DC0824BF01008DF038 /* WebPluginPackage.m in Sources */,
                                939810DD0824BF01008DF038 /* npapi.m in Sources */,
                                939810DE0824BF01008DF038 /* WebFrameBridge.m in Sources */,
-                               939810E00824BF01008DF038 /* WebFileButton.m in Sources */,
                                939810E20824BF01008DF038 /* WebImageRenderer.m in Sources */,
                                939810E30824BF01008DF038 /* WebImageRendererFactory.m in Sources */,
                                939810E40824BF01008DF038 /* WebJavaScriptTextInputPanel.m in Sources */,