[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:50:56 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit a30591079305e1c9a0528febf87a6a4fcfe7d390
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Oct 17 23:04:30 2002 +0000
- fixed 3052547 -- <select> doesn't size properly (size > 1)
* khtml/rendering/render_form.cpp:
(RenderLineEdit::slotReturnPressed): #if !APPLE_CHANGES around some unused
code in here.
(RenderSelect::updateFromElement): Fix bug where it was using Multi here, but
Extended elsewhere for the selection mode.
(RenderSelect::layout): Change code so that QListBox handles the sizing.
* kwq/KWQListBox.h: Removed a lot of unused stuff, made other things use inlines.
* kwq/KWQListBox.mm: Rewrote most of the file contents. Made a new
QListBox::sizeForNumberOfLines method. We will have to port this to NSTableView
rather than NSBrowser.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2361 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index b2477b4..b4d27bd 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,5 +1,21 @@
2002-10-17 Darin Adler <darin at apple.com>
+ - fixed 3052547 -- <select> doesn't size properly (size > 1)
+
+ * khtml/rendering/render_form.cpp:
+ (RenderLineEdit::slotReturnPressed): #if !APPLE_CHANGES around some unused
+ code in here.
+ (RenderSelect::updateFromElement): Fix bug where it was using Multi here, but
+ Extended elsewhere for the selection mode.
+ (RenderSelect::layout): Change code so that QListBox handles the sizing.
+
+ * kwq/KWQListBox.h: Removed a lot of unused stuff, made other things use inlines.
+ * kwq/KWQListBox.mm: Rewrote most of the file contents. Made a new
+ QListBox::sizeForNumberOfLines method. We will have to port this to NSTableView
+ rather than NSBrowser.
+
+2002-10-17 Darin Adler <darin at apple.com>
+
- fixed 3078245 -- REGRESSION: lightgrey displays as black, used
to display as white, should display light gray
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index b2477b4..b4d27bd 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,5 +1,21 @@
2002-10-17 Darin Adler <darin at apple.com>
+ - fixed 3052547 -- <select> doesn't size properly (size > 1)
+
+ * khtml/rendering/render_form.cpp:
+ (RenderLineEdit::slotReturnPressed): #if !APPLE_CHANGES around some unused
+ code in here.
+ (RenderSelect::updateFromElement): Fix bug where it was using Multi here, but
+ Extended elsewhere for the selection mode.
+ (RenderSelect::layout): Change code so that QListBox handles the sizing.
+
+ * kwq/KWQListBox.h: Removed a lot of unused stuff, made other things use inlines.
+ * kwq/KWQListBox.mm: Rewrote most of the file contents. Made a new
+ QListBox::sizeForNumberOfLines method. We will have to port this to NSTableView
+ rather than NSBrowser.
+
+2002-10-17 Darin Adler <darin at apple.com>
+
- fixed 3078245 -- REGRESSION: lightgrey displays as black, used
to display as white, should display light gray
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index b2477b4..b4d27bd 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,5 +1,21 @@
2002-10-17 Darin Adler <darin at apple.com>
+ - fixed 3052547 -- <select> doesn't size properly (size > 1)
+
+ * khtml/rendering/render_form.cpp:
+ (RenderLineEdit::slotReturnPressed): #if !APPLE_CHANGES around some unused
+ code in here.
+ (RenderSelect::updateFromElement): Fix bug where it was using Multi here, but
+ Extended elsewhere for the selection mode.
+ (RenderSelect::layout): Change code so that QListBox handles the sizing.
+
+ * kwq/KWQListBox.h: Removed a lot of unused stuff, made other things use inlines.
+ * kwq/KWQListBox.mm: Rewrote most of the file contents. Made a new
+ QListBox::sizeForNumberOfLines method. We will have to port this to NSTableView
+ rather than NSBrowser.
+
+2002-10-17 Darin Adler <darin at apple.com>
+
- fixed 3078245 -- REGRESSION: lightgrey displays as black, used
to display as white, should display light gray
diff --git a/WebCore/khtml/rendering/render_form.cpp b/WebCore/khtml/rendering/render_form.cpp
index 08af55f..62a9c2d 100644
--- a/WebCore/khtml/rendering/render_form.cpp
+++ b/WebCore/khtml/rendering/render_form.cpp
@@ -464,10 +464,12 @@ RenderLineEdit::RenderLineEdit(HTMLInputElementImpl *element)
void RenderLineEdit::slotReturnPressed()
{
+#if !APPLE_CHANGES
// don't submit the form when return was pressed in a completion-popup
KCompletionBox *box = widget()->completionBox(false);
if ( box && box->isVisible() && box->currentItem() != -1 )
return;
+#endif
// Emit onChange if necessary
// Works but might not be enough, dirk said he had another solution at
@@ -776,7 +778,7 @@ void RenderSelect::updateFromElement()
}
if (m_useListBox && oldMultiple != m_multiple) {
- static_cast<KListBox*>(m_widget)->setSelectionMode(m_multiple ? QListBox::Multi : QListBox::Single);
+ static_cast<KListBox*>(m_widget)->setSelectionMode(m_multiple ? QListBox::Extended : QListBox::Single);
}
m_selectionChanged = true;
m_optionsChanged = true;
@@ -897,6 +899,7 @@ void RenderSelect::layout( )
if(m_useListBox) {
KListBox* w = static_cast<KListBox*>(m_widget);
+#if !APPLE_CHANGES
QListBoxItem* p = w->firstItem();
int width = 0;
int height = 0;
@@ -905,6 +908,7 @@ void RenderSelect::layout( )
height = QMAX(height, p->height(p->listBox()));
p = p->next();
}
+#endif
int size = m_size;
// check if multiple and size was not given or invalid
@@ -916,18 +920,17 @@ void RenderSelect::layout( )
size = QMIN(static_cast<KListBox*>(m_widget)->count(), 10);
#if APPLE_CHANGES
- width += w->scrollBarWidth();
- height = size*height;
- // NSBrowser has problems drawing scrollbar correctly when its size is too small.
- if (height < 60)
- height = 60;
+ // Let the widget tell us how big it wants to be.
+ QSize s(w->sizeForNumberOfLines(size));
+ setIntrinsicWidth( s.width() );
+ setIntrinsicHeight( s.height() );
#else
width += 2*w->frameWidth() + w->verticalScrollBar()->sizeHint().width();
height = size*height + 2*w->frameWidth();
-#endif
setIntrinsicWidth( width );
setIntrinsicHeight( height );
+#endif
}
else {
QSize s(m_widget->sizeHint());
diff --git a/WebCore/kwq/KWQListBox.h b/WebCore/kwq/KWQListBox.h
index e4af947..7185822 100644
--- a/WebCore/kwq/KWQListBox.h
+++ b/WebCore/kwq/KWQListBox.h
@@ -31,68 +31,61 @@
#include <KWQSignal.h>
class QListBoxItem;
-class QListBoxText;
class QListBox : public QScrollView {
friend class QListBoxItem;
public:
- enum SelectionMode { Single, Multi, Extended, NoSelection };
+ enum SelectionMode { Single, Extended };
QListBox(QWidget *parent);
~QListBox();
- int scrollBarWidth() const;
+ QSize sizeForNumberOfLines(int numLines) const;
uint count() const;
void clear();
virtual void setSelectionMode(SelectionMode);
- QListBoxItem *firstItem() const;
- int currentItem() const;
- void insertItem(const QString &, int index=-1);
- void insertItem(const QListBoxItem *, int index=-1);
+
+ QListBoxItem *firstItem() const { return _head; }
+
void beginBatchInsert();
+ void insertItem(const QString &, unsigned index);
+ void insertItem(QListBoxItem *, unsigned index);
void endBatchInsert();
void setSelected(int, bool);
- bool isSelected(int);
+ bool isSelected(int) const;
- void clicked() { m_clicked.call(); }
- void selectionChanged() { m_selectionChanged.call(); }
+ void clicked() { _clicked.call(); }
+ void selectionChanged() { _selectionChanged.call(); }
private:
- QListBoxItem *head;
- bool m_insertingItems;
+ QListBoxItem *_head;
+ bool _insertingItems;
- KWQSignal m_clicked;
- KWQSignal m_selectionChanged;
+ KWQSignal _clicked;
+ KWQSignal _selectionChanged;
};
class QListBoxItem {
friend class QListBox;
-friend class QListBoxText;
public:
- QListBoxItem();
- virtual ~QListBoxItem();
+ QListBoxItem(const QString &text);
- void setSelectable(bool);
- QListBox *listBox() const;
- virtual int width(const QListBox *) const;
- virtual int height(const QListBox *) const;
- QListBoxItem *next() const;
- QListBoxItem *prev() const;
-
- QString text;
- QListBoxItem *previousItem, *nextItem;
- QListBox *box;
+ void setSelectable(bool) { }
+ QListBoxItem *next() const { return _next; }
+ QString text() const { return _text; }
private:
+ QString _text;
+ QListBoxItem *_next;
+
QListBoxItem(const QListBoxItem &);
QListBoxItem &operator=(const QListBoxItem &);
};
class QListBoxText : public QListBoxItem {
public:
- QListBoxText(const QString &text=QString::null);
- ~QListBoxText();
+ QListBoxText(const QString &text = QString::null) : QListBoxItem(text) { }
};
#endif
diff --git a/WebCore/kwq/KWQListBox.mm b/WebCore/kwq/KWQListBox.mm
index b0425dc..b5b82ee 100644
--- a/WebCore/kwq/KWQListBox.mm
+++ b/WebCore/kwq/KWQListBox.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2001, 2002 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
@@ -25,29 +25,33 @@
#import <KWQListBox.h>
-#import <KWQView.h>
+#import <KWQAssertions.h>
+
+// FIXME: We have to switch to NSTableView instead of NSBrowser.
+
+#define BORDER_TOTAL_WIDTH 3
+#define BORDER_TOTAL_HEIGHT 2
+
+ at interface NSBrowser (KWQNSBrowserSecrets)
+- (void)_setScrollerSize:(NSControlSize)scrollerSize;
+ at end
@interface KWQBrowserDelegate : NSObject
{
QListBox *box;
}
-
+- initWithListBox:(QListBox *)b;
@end
@implementation KWQBrowserDelegate
-- initWithListBox: (QListBox *)b
+- initWithListBox:(QListBox *)b
{
[super init];
box = b;
return self;
}
-// ==========================================================
-// Browser Delegate Methods.
-// ==========================================================
-
-// Use lazy initialization, since we don't want to touch the file system too much.
- (int)browser:(NSBrowser *)sender numberOfRowsInColumn:(int)column
{
return box->count();
@@ -55,173 +59,113 @@
- (void)browser:(NSBrowser *)sender willDisplayCell:(id)cell atRow:(int)row column:(int)column
{
- QListBoxItem *item = box->firstItem();
int count = 0;
-
- while (item != 0){
- if (count == row){
- if (item->text.isEmpty())
- [cell setEnabled: NO];
- else
- [cell setEnabled: YES];
- [cell setLeaf: YES];
- [cell setStringValue: item->text.getNSString()];
- return;
+ for (QListBoxItem *item = box->firstItem(); item; item = item->next()) {
+ if (count == row) {
+ [cell setEnabled:!item->text().isEmpty()];
+ [cell setLeaf:YES];
+ [cell setStringValue:item->text().getNSString()];
+ break;
}
- item = item->nextItem;
count++;
}
}
-// ==========================================================
-// Browser Target / Action Methods.
-// ==========================================================
-
- (IBAction)browserSingleClick:(id)browser
{
box->selectionChanged();
box->clicked();
}
-- (IBAction)browserDoubleClick:(id)browser
-{
-}
-
@end
QListBox::QListBox(QWidget *parent)
- : QScrollView(parent), m_insertingItems(false)
- , m_clicked(this, SIGNAL(clicked(QListBoxItem *)))
- , m_selectionChanged(this, SIGNAL(selectionChanged()))
+ : QScrollView(parent), _head(0), _insertingItems(false)
+ , _clicked(this, SIGNAL(clicked(QListBoxItem *)))
+ , _selectionChanged(this, SIGNAL(selectionChanged()))
{
- NSBrowser *browser = [[NSBrowser alloc] initWithFrame: NSMakeRect (0,0,1,1)];
- KWQBrowserDelegate *delegate = [[KWQBrowserDelegate alloc] initWithListBox: this];
+ NSBrowser *browser = [[NSBrowser alloc] init];
+ KWQBrowserDelegate *delegate = [[KWQBrowserDelegate alloc] initWithListBox:this];
- head = 0L;
-
- // FIXME: Need to configure browser's scroll view to use a scroller that
- // has no up/down buttons. Typically the browser is very small and won't
+ // FIXME: Need to configure browser's scroll view to use a scroller that
+ // has no up/down buttons. Typically the browser is very small and won't
// have enough space to draw the up/down buttons and the scroll knob.
- [browser setTitled: NO];
- [browser setDelegate: delegate];
- [browser setTarget: delegate];
- [browser setAction: @selector(browserSingleClick:)];
+ [browser setTitled:NO];
+ [browser setDelegate:delegate];
+ [browser setTarget:delegate];
+ [browser setAction:@selector(browserSingleClick:)];
[browser addColumn];
+ [browser setMaxVisibleColumns:1];
+ [browser _setScrollerSize:NSSmallControlSize];
- setView (browser);
+ setView(browser);
[browser release];
}
-
QListBox::~QListBox()
{
NSBrowser *browser = (NSBrowser *)getView();
KWQBrowserDelegate *delegate = [browser delegate];
- [browser setDelegate: nil];
+ [browser setDelegate:nil];
[delegate release];
}
-
uint QListBox::count() const
{
- QListBoxItem *item = (QListBoxItem *)head;
int count = 0;
-
- while (item != 0){
- item = item->nextItem;
+ for (QListBoxItem *item = _head; item; item = item->next()) {
count++;
}
return count;
}
-
-int QListBox::scrollBarWidth() const
-{
- return (int)[NSScroller scrollerWidth];
-}
-
-
void QListBox::clear()
{
- NSBrowser *browser = (NSBrowser *)getView();
-
- // Do we need to delete previous head?
- head = 0;
+ QListBoxItem *next;
+ for (QListBoxItem *item = _head; item; item = next) {
+ next = item->next();
+ delete item;
+ }
+ _head = 0;
+ NSBrowser *browser = (NSBrowser *)getView();
[browser loadColumnZero];
}
-
void QListBox::setSelectionMode(SelectionMode mode)
{
NSBrowser *browser = (NSBrowser *)getView();
-
- if (mode == QListBox::Extended){
- [browser setAllowsMultipleSelection: YES];
- }
- else {
- [browser setAllowsMultipleSelection: NO];
- }
-}
-
-
-QListBoxItem *QListBox::firstItem() const
-{
- return head;
-}
-
-
-int QListBox::currentItem() const
-{
- NSBrowser *browser = (NSBrowser *)getView();
- return [browser selectedRowInColumn:0];
+ [browser setAllowsMultipleSelection:mode != Single];
}
-
-void QListBox::insertItem(const QString &t, int index)
+void QListBox::insertItem(const QString &text, unsigned index)
{
- insertItem( new QListBoxText(t), index );
+ insertItem(new QListBoxItem(text), index);
}
-
-void QListBox::insertItem(const QListBoxItem *newItem, int _index)
+void QListBox::insertItem(QListBoxItem *item, unsigned index)
{
- if ( !newItem )
- return;
+ if (!item)
+ return;
- if ( _index < 0 || _index >= (int)count())
- _index = count();
+ if (index > count())
+ index = count();
- int index = _index;
- QListBoxItem *item = (QListBoxItem *)newItem;
-
- item->box = this;
- if ( !head || index == 0 ) {
- item->nextItem = head;
- item->previousItem = 0;
- head = item;
- if ( item->nextItem )
- item->nextItem->previousItem = item;
+ if (!_head || index == 0) {
+ item->_next = _head;
+ _head = item;
} else {
- QListBoxItem * i = head;
- while ( i->nextItem && index > 1 ) {
- i = i->nextItem;
+ QListBoxItem *i = _head;
+ while (i->_next && index > 1) {
+ i = i->_next;
index--;
}
- if ( i->nextItem ) {
- item->nextItem = i->nextItem;
- item->previousItem = i;
- item->nextItem->previousItem = item;
- item->previousItem->nextItem = item;
- } else {
- i->nextItem = item;
- item->previousItem = i;
- item->nextItem = 0;
- }
+ item->_next = i->_next;
+ i->_next = item;
}
- if (!m_insertingItems) {
+ if (!_insertingItems) {
NSBrowser *browser = (NSBrowser *)getView();
[browser loadColumnZero];
[browser tile];
@@ -230,12 +174,14 @@ void QListBox::insertItem(const QListBoxItem *newItem, int _index)
void QListBox::beginBatchInsert()
{
- m_insertingItems = true;
+ ASSERT(!_insertingItems);
+ _insertingItems = true;
}
void QListBox::endBatchInsert()
{
- m_insertingItems = false;
+ ASSERT(_insertingItems);
+ _insertingItems = false;
NSBrowser *browser = (NSBrowser *)getView();
[browser loadColumnZero];
[browser tile];
@@ -243,85 +189,42 @@ void QListBox::endBatchInsert()
void QListBox::setSelected(int index, bool selectIt)
{
+ ASSERT(!_insertingItems);
if (selectIt) {
NSBrowser *browser = (NSBrowser *)getView();
- [browser selectRow: index inColumn: 0];
+ [browser selectRow:index inColumn:0];
+ } else {
+ // FIXME: What can we do here?
}
}
-
-bool QListBox::isSelected(int index)
+bool QListBox::isSelected(int index) const
{
+ ASSERT(!_insertingItems);
NSBrowser *browser = (NSBrowser *)getView();
- return [[browser loadedCellAtRow: index column:0] state] == NSOnState;
+ return [[browser loadedCellAtRow:index column:0] state] != NSOffState;
}
-
-// class QListBoxItem ==========================================================
-
-QListBoxItem::QListBoxItem()
-{
-}
-
-QListBoxItem::~QListBoxItem()
-{
-}
-
-
-void QListBoxItem::setSelectable(bool flag)
+QSize QListBox::sizeForNumberOfLines(int lines) const
{
- // Not implemented, RenderSelect calls this when an item element is ""
- // We handle that case directly in our browser delegate.
-}
-
-
-QListBox *QListBoxItem::listBox() const
-{
- return box;
-}
-
-
-int QListBoxItem::width(const QListBox *) const
-{
- // Is this right?
- NSBrowser *browser = (NSBrowser *)box->getView();
- NSSize cellSize = [[browser loadedCellAtRow: 0 column: 0] cellSizeForBounds: NSMakeRect (0,0,10000,10000)];
- NSSize frameSize = [NSScrollView frameSizeForContentSize:cellSize hasHorizontalScroller:NO hasVerticalScroller:YES borderType:NSLineBorder];
- return (int)frameSize.width;
-}
-
-
-int QListBoxItem::height(const QListBox *) const
-{
- // Is this right?
- NSBrowser *browser = (NSBrowser *)box->getView();
- NSSize size = [[browser loadedCellAtRow: 0 column: 0] cellSizeForBounds: NSMakeRect (0,0,10000,10000)];
- return (int)size.height;
-}
-
-
-QListBoxItem *QListBoxItem::next() const
-{
- return nextItem;
-}
-
-
-QListBoxItem *QListBoxItem::prev() const
-{
- return previousItem;
-}
-
-
-
-// class QListBoxText ==========================================================
-
-QListBoxText::QListBoxText(const QString &t)
-{
- text = t;
+ NSBrowser *browser = (NSBrowser *)getView();
+ int rows = [[browser delegate] browser:browser numberOfRowsInColumn:0];
+ float rowHeight = 0;
+ float width = 0;
+ for (int row = 0; row < rows; row++) {
+ NSBrowserCell *cell = [browser loadedCellAtRow:row column:0];
+ NSSize size = [cell cellSize];
+ NSLog(@"string is %@, width is %f", [cell stringValue], size.width);
+ width = MAX(width, size.width);
+ rowHeight = MAX(rowHeight, size.height);
+ }
+ // FIXME: Add scroll bar width.
+ return QSize((int)ceil(width + BORDER_TOTAL_WIDTH
+ + [NSScroller scrollerWidthForControlSize:NSSmallControlSize]),
+ (int)ceil(rowHeight * lines + BORDER_TOTAL_HEIGHT));
}
-
-QListBoxText::~QListBoxText()
+QListBoxItem::QListBoxItem(const QString &text)
+ : _text(text), _next(0)
{
}
-
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list