[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:58:15 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit e7dcb12cc21fb4786fbe2fec11f1265635f99b6e
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Nov 9 01:33:21 2002 +0000

    	- fixed 3090452 -- REGRESSION: orbitz Box extends way over margins
    
            * kwq/KWQComboBox.h: Added _width and _widthGood.
            * kwq/KWQComboBox.mm:
            (QComboBox::QComboBox): Set _widthGood to false.
            (QComboBox::insertItem): Set _widthGood to false.
            (QComboBox::sizeHint): Compute the width by measuring the text ourselves.
    	Turns out the cell isn't helpful for that.
            (QComboBox::clear): Set _widthGood to false.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2606 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index 9f66c59..84bdd3e 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,15 @@
+2002-11-08  Darin Adler  <darin at apple.com>
+
+	- fixed 3090452 -- REGRESSION: orbitz Box extends way over margins
+
+        * kwq/KWQComboBox.h: Added _width and _widthGood.
+        * kwq/KWQComboBox.mm:
+        (QComboBox::QComboBox): Set _widthGood to false.
+        (QComboBox::insertItem): Set _widthGood to false.
+        (QComboBox::sizeHint): Compute the width by measuring the text ourselves.
+	Turns out the cell isn't helpful for that.
+        (QComboBox::clear): Set _widthGood to false.
+
 2002-11-08  Richard Williamson   <rjw at apple.com>
 
         Cleanup of fix to 3083281.  Never call stopAnimating from
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 9f66c59..84bdd3e 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,15 @@
+2002-11-08  Darin Adler  <darin at apple.com>
+
+	- fixed 3090452 -- REGRESSION: orbitz Box extends way over margins
+
+        * kwq/KWQComboBox.h: Added _width and _widthGood.
+        * kwq/KWQComboBox.mm:
+        (QComboBox::QComboBox): Set _widthGood to false.
+        (QComboBox::insertItem): Set _widthGood to false.
+        (QComboBox::sizeHint): Compute the width by measuring the text ourselves.
+	Turns out the cell isn't helpful for that.
+        (QComboBox::clear): Set _widthGood to false.
+
 2002-11-08  Richard Williamson   <rjw at apple.com>
 
         Cleanup of fix to 3083281.  Never call stopAnimating from
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 9f66c59..84bdd3e 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,15 @@
+2002-11-08  Darin Adler  <darin at apple.com>
+
+	- fixed 3090452 -- REGRESSION: orbitz Box extends way over margins
+
+        * kwq/KWQComboBox.h: Added _width and _widthGood.
+        * kwq/KWQComboBox.mm:
+        (QComboBox::QComboBox): Set _widthGood to false.
+        (QComboBox::insertItem): Set _widthGood to false.
+        (QComboBox::sizeHint): Compute the width by measuring the text ourselves.
+	Turns out the cell isn't helpful for that.
+        (QComboBox::clear): Set _widthGood to false.
+
 2002-11-08  Richard Williamson   <rjw at apple.com>
 
         Cleanup of fix to 3083281.  Never call stopAnimating from
diff --git a/WebCore/kwq/KWQComboBox.h b/WebCore/kwq/KWQComboBox.h
index 2305d50..a7e2e56 100644
--- a/WebCore/kwq/KWQComboBox.h
+++ b/WebCore/kwq/KWQComboBox.h
@@ -56,11 +56,14 @@ public:
 
     bool eventFilter(QObject *object, QEvent *event) { return false; }
 
-    void activated() { m_activated.call(currentItem()); }
+    void activated() { _activated.call(currentItem()); }
 
 private:
-    KWQSignal m_activated;
-    KWQComboBoxAdapter *m_adapter;
+    KWQComboBoxAdapter *_adapter;
+    mutable float _width;
+    mutable bool _widthGood;
+
+    KWQSignal _activated;
 };
 
 #endif
diff --git a/WebCore/kwq/KWQComboBox.mm b/WebCore/kwq/KWQComboBox.mm
index 13a3d04..7e331fa 100644
--- a/WebCore/kwq/KWQComboBox.mm
+++ b/WebCore/kwq/KWQComboBox.mm
@@ -40,6 +40,12 @@
 // This is the 2-pixel CELLOFFSET for bordered cells from NSCell.
 #define VERTICAL_FUDGE_FACTOR 2
 
+// When we discovered we needed to measure text widths ourselves, I empirically
+// determined these widths. I don't know what exactly they correspond to in the
+// NSPopUpButtonCell code.
+#define WIDTH_NOT_INCLUDING_TEXT 30
+#define MINIMUM_WIDTH 36
+
 @interface KWQComboBoxAdapter : NSObject
 {
     QComboBox *box;
@@ -56,8 +62,9 @@
 @end
 
 QComboBox::QComboBox()
-    : m_activated(this, SIGNAL(activated(int)))
-    , m_adapter([[KWQComboBoxAdapter alloc] initWithQComboBox:this])
+    : _adapter([[KWQComboBoxAdapter alloc] initWithQComboBox:this])
+    , _widthGood(false)
+    , _activated(this, SIGNAL(activated(int)))
 {
     NSPopUpButton *button = [[NSPopUpButton alloc] init];
     
@@ -65,7 +72,7 @@ QComboBox::QComboBox()
     [button setCell:cell];
     [cell release];
 
-    [button setTarget:m_adapter];
+    [button setTarget:_adapter];
     [button setAction:@selector(action:)];
 
     [[button cell] setControlSize:NSSmallControlSize];
@@ -80,7 +87,7 @@ QComboBox::~QComboBox()
 {
     NSPopUpButton *button = (NSPopUpButton *)getView();
     [button setTarget:nil];
-    [m_adapter release];
+    [_adapter release];
 }
 
 void QComboBox::insertItem(const QString &text, int index)
@@ -98,12 +105,33 @@ void QComboBox::insertItem(const QString &text, int index)
     // because addItemWithTitle will not allow multiple items with the
     // same title. But this way, we can have such duplicate items.
     [[button itemAtIndex:index] setTitle:text.getNSString()];
+    _widthGood = false;
 }
 
 QSize QComboBox::sizeHint() const 
 {
     NSPopUpButton *button = (NSPopUpButton *)getView();
-    return QSize((int)[[button cell] cellSize].width - (LEFT_MARGIN + RIGHT_MARGIN),
+    
+    float width;
+    if (_widthGood) {
+        width = _width;
+    } else {
+        width = 0;
+        NSDictionary *attributes = [NSDictionary dictionaryWithObject:[button font] forKey:NSFontAttributeName];
+        NSEnumerator *e = [[button itemTitles] objectEnumerator];
+        NSString *text;
+        while ((text = [e nextObject])) {
+            NSSize size = [text sizeWithAttributes:attributes];
+            width = MAX(width, size.width);
+        }
+        _width = ceil(width);
+        if (_width < MINIMUM_WIDTH - WIDTH_NOT_INCLUDING_TEXT) {
+            _width = MINIMUM_WIDTH - WIDTH_NOT_INCLUDING_TEXT;
+        }
+        _widthGood = true;
+    }
+    
+    return QSize((int)_width + WIDTH_NOT_INCLUDING_TEXT,
         (int)[[button cell] cellSize].height - (TOP_MARGIN + BOTTOM_MARGIN));
 }
 
@@ -134,6 +162,7 @@ void QComboBox::clear()
 {
     NSPopUpButton *button = (NSPopUpButton *)getView();
     [button removeAllItems];
+    _widthGood = false;
 }
 
 void QComboBox::setCurrentItem(int index)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list