[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 08:37:20 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit c4ab5b00f42db7cc582fc185ab636cf8479848bf
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Apr 27 17:38:07 2004 +0000
Reviewed by Ken.
- fixed <rdar://problem/3623694>: "top level <option> and <optgroup> labels look identical in pop-up menus; should not"
* khtml/rendering/render_form.cpp: (RenderSelect::updateFromElement):
Call appendGroupLabel instead of appendItem for group labels.
* kwq/KWQComboBox.h: Added appendGroupLabel, private setControlSize, labelFont, setTitle, _labelFont,
and make _items a QValueList<KWQListBoxItem> instead of QStringList.
* kwq/KWQComboBox.mm:
(QComboBox::QComboBox): Initializes _labelFont to nil.
(QComboBox::~QComboBox): Release _labelFont.
(QComboBox::setTitle): Added helper function. Uses an attributed string for group labels, and also sets
the action to NULL so they are disabled.
(QComboBox::appendItem): Added isLabel boolean parameter, make KWQListBoxItem, call setTitle.
(QComboBox::sizeHint): Changed to handle group labels with a separate renderer to measure bolded text.
(QComboBox::setCurrentItem): Changed to use setTitle helper.
(QComboBox::setFont): Release _labelFont if control size changed.
(QComboBox::labelFont): Compute label font lazily.
(QComboBox::populateMenu): Changed to use setTitle helper.
* kwq/KWQListBox.h: Removed excess includes, fixed comment.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6494 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 3856f23..c46fac4 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,28 @@
+2004-04-27 Darin Adler <darin at apple.com>
+
+ Reviewed by Ken.
+
+ - fixed <rdar://problem/3623694>: "top level <option> and <optgroup> labels look identical in pop-up menus; should not"
+
+ * khtml/rendering/render_form.cpp: (RenderSelect::updateFromElement):
+ Call appendGroupLabel instead of appendItem for group labels.
+
+ * kwq/KWQComboBox.h: Added appendGroupLabel, private setControlSize, labelFont, setTitle, _labelFont,
+ and make _items a QValueList<KWQListBoxItem> instead of QStringList.
+ * kwq/KWQComboBox.mm:
+ (QComboBox::QComboBox): Initializes _labelFont to nil.
+ (QComboBox::~QComboBox): Release _labelFont.
+ (QComboBox::setTitle): Added helper function. Uses an attributed string for group labels, and also sets
+ the action to NULL so they are disabled.
+ (QComboBox::appendItem): Added isLabel boolean parameter, make KWQListBoxItem, call setTitle.
+ (QComboBox::sizeHint): Changed to handle group labels with a separate renderer to measure bolded text.
+ (QComboBox::setCurrentItem): Changed to use setTitle helper.
+ (QComboBox::setFont): Release _labelFont if control size changed.
+ (QComboBox::labelFont): Compute label font lazily.
+ (QComboBox::populateMenu): Changed to use setTitle helper.
+
+ * kwq/KWQListBox.h: Removed excess includes, fixed comment.
+
2004-04-26 Darin Adler <darin at apple.com>
Reviewed by Maciej.
diff --git a/WebCore/khtml/rendering/render_form.cpp b/WebCore/khtml/rendering/render_form.cpp
index 16b9e02..300777e 100644
--- a/WebCore/khtml/rendering/render_form.cpp
+++ b/WebCore/khtml/rendering/render_form.cpp
@@ -1158,7 +1158,7 @@ void RenderSelect::updateFromElement()
if (m_useListBox)
static_cast<KListBox*>(m_widget)->appendGroupLabel(label);
else
- static_cast<KComboBox*>(m_widget)->appendItem(label);
+ static_cast<KComboBox*>(m_widget)->appendGroupLabel(label);
#else
if(m_useListBox) {
QListBoxText *item = new QListBoxText(label);
diff --git a/WebCore/kwq/KWQComboBox.h b/WebCore/kwq/KWQComboBox.h
index b3712b4..085e124 100644
--- a/WebCore/kwq/KWQComboBox.h
+++ b/WebCore/kwq/KWQComboBox.h
@@ -26,15 +26,13 @@
#ifndef QCOMBOBOX_H_
#define QCOMBOBOX_H_
-#include "KWQWidget.h"
-#include "KWQStringList.h"
-
-class QListBox;
+#include "KWQListBox.h"
#ifdef __OBJC__
@class KWQComboBoxAdapter;
#else
class KWQComboBoxAdapter;
+class NSMenuItem;
#endif
class QComboBox : public QWidget {
@@ -43,7 +41,8 @@ public:
~QComboBox();
void clear();
- void appendItem(const QString &text);
+ void appendItem(const QString &text) { appendItem(text, false); }
+ void appendGroupLabel(const QString &text) { appendItem(text, true); }
int currentItem() const { return _currentItem; }
void setCurrentItem(int);
@@ -67,17 +66,22 @@ public:
void populateMenu();
private:
+ void appendItem(const QString &, bool isLabel);
const int *dimensions() const;
+ NSFont *labelFont() const;
+ void setTitle(NSMenuItem *, const KWQListBoxItem &);
mutable int _width;
mutable bool _widthGood;
mutable int _currentItem;
- // A vector<QString> or QValueVector<QString> may be more efficient for large menus.
- QStringList _items;
+ // A vector<KWQListBoxItem> or QValueVector<KWQListBoxItem> may be more efficient for large menus.
+ QValueList<KWQListBoxItem> _items;
mutable bool _menuPopulated;
+ mutable NSFont *_labelFont;
+
KWQSignal _activated;
};
diff --git a/WebCore/kwq/KWQComboBox.mm b/WebCore/kwq/KWQComboBox.mm
index ccc1886..4204e06 100644
--- a/WebCore/kwq/KWQComboBox.mm
+++ b/WebCore/kwq/KWQComboBox.mm
@@ -69,6 +69,7 @@ QComboBox::QComboBox()
: _widthGood(false)
, _currentItem(0)
, _menuPopulated(true)
+ , _labelFont(nil)
, _activated(this, SIGNAL(activated(int)))
{
KWQ_BLOCK_EXCEPTIONS;
@@ -96,15 +97,29 @@ QComboBox::~QComboBox()
KWQPopUpButton *button = (KWQPopUpButton *)getView();
[button setTarget:nil];
+ [_labelFont release];
KWQ_UNBLOCK_EXCEPTIONS;
}
-void QComboBox::appendItem(const QString &text)
+void QComboBox::setTitle(NSMenuItem *menuItem, const KWQListBoxItem &title)
{
- KWQ_BLOCK_EXCEPTIONS;
+ if (title.isGroupLabel) {
+ NSDictionary *attributes = [[NSDictionary alloc] initWithObjectsAndKeys:labelFont(), NSFontAttributeName, nil];
+ NSAttributedString *string = [[NSAttributedString alloc] initWithString:title.string.getNSString() attributes:attributes];
+ [menuItem setAttributedTitle:string];
+ [string release];
+ [attributes release];
+ [menuItem setAction:NULL /*@selector(fakeSelectorForDisabledItem)*/];
+ } else {
+ [menuItem setTitle:title.string.getNSString()];
+ }
+}
- _items.append(text);
+void QComboBox::appendItem(const QString &text, bool isLabel)
+{
+ const KWQListBoxItem listItem(text, isLabel);
+ _items.append(listItem);
if (_menuPopulated) {
KWQPopUpButton *button = (KWQPopUpButton *)getView();
if (![[button cell] isHighlighted]) {
@@ -112,13 +127,14 @@ void QComboBox::appendItem(const QString &text)
} else {
// We must add the item with no title and then set the title because
// addItemWithTitle does not allow duplicate titles.
+ KWQ_BLOCK_EXCEPTIONS;
[button addItemWithTitle:@""];
- [[button lastItem] setTitle:text.getNSString()];
+ NSMenuItem *menuItem = [button lastItem];
+ setTitle(menuItem, listItem);
+ KWQ_UNBLOCK_EXCEPTIONS;
}
}
_widthGood = false;
-
- KWQ_UNBLOCK_EXCEPTIONS;
}
QSize QComboBox::sizeHint() const
@@ -129,23 +145,37 @@ QSize QComboBox::sizeHint() const
if (!_widthGood) {
float width = 0;
- QValueListConstIterator<QString> i = const_cast<const QStringList &>(_items).begin();
- QValueListConstIterator<QString> e = const_cast<const QStringList &>(_items).end();
+ QValueListConstIterator<KWQListBoxItem> i = const_cast<const QValueList<KWQListBoxItem> &>(_items).begin();
+ QValueListConstIterator<KWQListBoxItem> e = const_cast<const QValueList<KWQListBoxItem> &>(_items).end();
if (i != e) {
- id <WebCoreTextRenderer> renderer = [[WebCoreTextRendererFactory sharedFactory]
- rendererWithFont:[button font] usingPrinterFont:![NSGraphicsContext currentContextDrawingToScreen]];
+ id <WebCoreTextRenderer> itemRenderer = [[WebCoreTextRendererFactory sharedFactory]
+ rendererWithFont:[button font]
+ usingPrinterFont:![NSGraphicsContext currentContextDrawingToScreen]];
+ id <WebCoreTextRenderer> labelRenderer = nil;
WebCoreTextStyle style;
WebCoreInitializeEmptyTextStyle(&style);
style.applyRunRounding = NO;
style.applyWordRounding = NO;
do {
- const QString &s = *i;
+ const QString &s = (*i).string;
+ bool isLabel = (*i).isGroupLabel;
++i;
WebCoreTextRun run;
int length = s.length();
WebCoreInitializeTextRun(&run, reinterpret_cast<const UniChar *>(s.unicode()), length, 0, length);
+ id <WebCoreTextRenderer> renderer;
+ if (isLabel) {
+ if (labelRenderer == nil) {
+ labelRenderer = [[WebCoreTextRendererFactory sharedFactory]
+ rendererWithFont:labelFont()
+ usingPrinterFont:![NSGraphicsContext currentContextDrawingToScreen]];
+ }
+ renderer = labelRenderer;
+ } else {
+ renderer = itemRenderer;
+ }
float textWidth = [renderer floatWidthForRun:&run style:&style widths:0];
width = kMax(width, textWidth);
} while (i != e);
@@ -206,7 +236,8 @@ void QComboBox::setCurrentItem(int index)
} else {
[button removeAllItems];
[button addItemWithTitle:@""];
- [[button itemAtIndex:0] setTitle:_items[index].getNSString()];
+ NSMenuItem *menuItem = [button itemAtIndex:0];
+ setTitle(menuItem, _items[index]);
}
KWQ_UNBLOCK_EXCEPTIONS;
@@ -244,12 +275,23 @@ void QComboBox::setFont(const QFont &f)
if (size != [[button cell] controlSize]) {
[[button cell] setControlSize:size];
[button setFont:[NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:size]]];
+ [_labelFont release];
+ _labelFont = nil;
_widthGood = false;
}
KWQ_UNBLOCK_EXCEPTIONS;
}
+NSFont *QComboBox::labelFont() const
+{
+ if (_labelFont == nil) {
+ NSControl * const button = static_cast<NSControl *>(getView());
+ _labelFont = [[NSFont boldSystemFontOfSize:[[button font] pointSize]] retain];
+ }
+ return _labelFont;
+}
+
const int *QComboBox::dimensions() const
{
// We empirically determined these dimensions.
@@ -304,13 +346,14 @@ void QComboBox::populateMenu()
KWQPopUpButton *button = getView();
[button removeAllItems];
- QValueListConstIterator<QString> i = const_cast<const QStringList &>(_items).begin();
- QValueListConstIterator<QString> e = const_cast<const QStringList &>(_items).end();
+ QValueListConstIterator<KWQListBoxItem> i = const_cast<const QValueList<KWQListBoxItem> &>(_items).begin();
+ QValueListConstIterator<KWQListBoxItem> e = const_cast<const QValueList<KWQListBoxItem> &>(_items).end();
for (; i != e; ++i) {
// We must add the item with no title and then set the title because
// addItemWithTitle does not allow duplicate titles.
[button addItemWithTitle:@""];
- [[button lastItem] setTitle:(*i).getNSString()];
+ NSMenuItem *menuItem = [button lastItem];
+ setTitle(menuItem, *i);
}
[button selectItemAtIndex:_currentItem];
diff --git a/WebCore/kwq/KWQListBox.h b/WebCore/kwq/KWQListBox.h
index 0901074..be7f315 100644
--- a/WebCore/kwq/KWQListBox.h
+++ b/WebCore/kwq/KWQListBox.h
@@ -27,9 +27,6 @@
#define KWQLISTBOX_H_
#include "KWQScrollView.h"
-#include "KWQSignal.h"
-#include "KWQString.h"
-#include "KWQValueList.h"
struct KWQListBoxItem
{
@@ -77,7 +74,7 @@ public:
private:
void appendItem(const QString &, bool isLabel);
- // A vector<QString> or QValueVector<QString> might be more efficient for large lists.
+ // A vector<KWQListBoxItem> or QValueVector<KWQListBoxItem> might be more efficient for large lists.
QValueList<KWQListBoxItem> _items;
bool _changingSelection;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list