[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
jhawkins at chromium.org
jhawkins at chromium.org
Wed Dec 22 11:31:14 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 03b5093f38e59c51f90b11911de4b70acb6f91ac
Author: jhawkins at chromium.org <jhawkins at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Jul 27 23:02:00 2010 +0000
2010-07-27 James Hawkins <jhawkins at chromium.org>
Reviewed by Darin Fisher.
[Chromium] Add the ability to show right-aligned icons in the AutoFill popup.
https://bugs.webkit.org/show_bug.cgi?id=43076
* public/WebView.h:
* src/AutoFillPopupMenuClient.cpp:
(WebKit::AutoFillPopupMenuClient::getIcon):
(WebKit::AutoFillPopupMenuClient::removeSuggestionAtIndex):
(WebKit::AutoFillPopupMenuClient::itemIcon):
(WebKit::AutoFillPopupMenuClient::initialize):
(WebKit::AutoFillPopupMenuClient::setSuggestions):
* src/AutoFillPopupMenuClient.h:
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::applyAutoFillSuggestions):
(WebKit::WebViewImpl::applyAutocompleteSuggestions):
* src/WebViewImpl.h:
2010-07-27 James Hawkins <jhawkins at chromium.org>
Reviewed by Darin Fisher.
Add itemIcon() method to the PopupMenuClient, used by Chrome AutoFill
to display right-aligned credit card icons in the suggestions popup.
https://bugs.webkit.org/show_bug.cgi?id=43076
No new tests as this is only used by the Chromium WebKit API.
* platform/PopupMenuClient.h:
* platform/chromium/PopupMenuChromium.cpp:
(WebCore::PopupListBox::paintRow):
* rendering/RenderMenuList.cpp:
(WebCore::RenderMenuList::itemIcon):
* rendering/RenderMenuList.h:
* rendering/RenderTextControlSingleLine.cpp:
(WebCore::RenderTextControlSingleLine::itemIcon):
* rendering/RenderTextControlSingleLine.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64173 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index b33e1fa..5a503bc 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,23 @@
+2010-07-27 James Hawkins <jhawkins at chromium.org>
+
+ Reviewed by Darin Fisher.
+
+ Add itemIcon() method to the PopupMenuClient, used by Chrome AutoFill
+ to display right-aligned credit card icons in the suggestions popup.
+ https://bugs.webkit.org/show_bug.cgi?id=43076
+
+ No new tests as this is only used by the Chromium WebKit API.
+
+ * platform/PopupMenuClient.h:
+ * platform/chromium/PopupMenuChromium.cpp:
+ (WebCore::PopupListBox::paintRow):
+ * rendering/RenderMenuList.cpp:
+ (WebCore::RenderMenuList::itemIcon):
+ * rendering/RenderMenuList.h:
+ * rendering/RenderTextControlSingleLine.cpp:
+ (WebCore::RenderTextControlSingleLine::itemIcon):
+ * rendering/RenderTextControlSingleLine.h:
+
2010-07-27 Andreas Kling <andreas.kling at nokia.com>
Reviewed by Kenneth Rohde Christiansen.
diff --git a/WebCore/platform/PopupMenuClient.h b/WebCore/platform/PopupMenuClient.h
index a1396e8..976f28c 100644
--- a/WebCore/platform/PopupMenuClient.h
+++ b/WebCore/platform/PopupMenuClient.h
@@ -43,6 +43,7 @@ public:
virtual String itemText(unsigned listIndex) const = 0;
virtual String itemLabel(unsigned listIndex) const = 0;
+ virtual String itemIcon(unsigned listIndex) const = 0;
virtual String itemToolTip(unsigned listIndex) const = 0;
virtual String itemAccessibilityText(unsigned listIndex) const = 0;
virtual bool itemIsEnabled(unsigned listIndex) const = 0;
diff --git a/WebCore/platform/chromium/PopupMenuChromium.cpp b/WebCore/platform/chromium/PopupMenuChromium.cpp
index 4701a75..2618362 100644
--- a/WebCore/platform/chromium/PopupMenuChromium.cpp
+++ b/WebCore/platform/chromium/PopupMenuChromium.cpp
@@ -71,6 +71,7 @@ static const int kMaxVisibleRows = 20;
static const int kMaxHeight = 500;
static const int kBorderSize = 1;
static const int kTextToLabelPadding = 10;
+static const int kLabelToIconPadding = 5;
static const TimeStamp kTypeAheadTimeoutMs = 1000;
// The settings used for the drop down menu.
@@ -959,18 +960,30 @@ void PopupListBox::paintRow(GraphicsContext* gc, const IntRect& rect, int rowInd
int textY = rowRect.y() + itemFont.ascent() + (rowRect.height() - itemFont.height()) / 2;
gc->drawBidiText(itemFont, textRun, IntPoint(textX, textY));
+ // We are using the left padding as the right padding includes room for the scroll-bar which
+ // does not show in this case.
+ int rightPadding = max(0, m_popupClient->clientPaddingLeft() - m_popupClient->clientInsetLeft());
+ int remainingWidth = rowRect.width() - rightPadding;
+
+ // Draw the icon if applicable.
+ String itemIcon = m_popupClient->itemIcon(rowIndex);
+ RefPtr<Image> image(Image::loadPlatformResource(itemIcon.utf8().data()));
+ if (image && !image->isNull()) {
+ IntRect imageRect = image->rect();
+ remainingWidth -= (imageRect.width() + kLabelToIconPadding);
+ imageRect.setX(rowRect.width() - rightPadding - imageRect.width());
+ imageRect.setY(rowRect.y() + (rowRect.height() - imageRect.height()) / 2);
+ gc->drawImage(image.get(), DeviceColorSpace, imageRect);
+ }
+
// Draw the the label if applicable.
if (itemLabel.isEmpty())
return;
TextRun labelTextRun(itemLabel.characters(), itemLabel.length(), false, 0, 0, rtl);
if (rightAligned)
textX = max(0, m_popupClient->clientPaddingLeft() - m_popupClient->clientInsetLeft());
- else {
- // We are using the left padding as the right padding includes room for the scroll-bar which
- // does not show in this case.
- int rightPadding = max(0, m_popupClient->clientPaddingLeft() - m_popupClient->clientInsetLeft());
- textX = rowRect.width() - rightPadding - itemFont.width(labelTextRun);
- }
+ else
+ textX = remainingWidth - itemFont.width(labelTextRun);
gc->setFillColor(labelColor, DeviceColorSpace);
gc->drawBidiText(itemFont, labelTextRun, IntPoint(textX, textY));
diff --git a/WebCore/rendering/RenderMenuList.cpp b/WebCore/rendering/RenderMenuList.cpp
index 177921c..ff16e7e 100644
--- a/WebCore/rendering/RenderMenuList.cpp
+++ b/WebCore/rendering/RenderMenuList.cpp
@@ -354,6 +354,11 @@ String RenderMenuList::itemLabel(unsigned) const
return String();
}
+String RenderMenuList::itemIcon(unsigned) const
+{
+ return String();
+}
+
String RenderMenuList::itemAccessibilityText(unsigned listIndex) const
{
// Allow the accessible name be changed if necessary.
diff --git a/WebCore/rendering/RenderMenuList.h b/WebCore/rendering/RenderMenuList.h
index d72e1a9..aef8d4f 100644
--- a/WebCore/rendering/RenderMenuList.h
+++ b/WebCore/rendering/RenderMenuList.h
@@ -83,6 +83,7 @@ private:
// PopupMenuClient methods
virtual String itemText(unsigned listIndex) const;
virtual String itemLabel(unsigned listIndex) const;
+ virtual String itemIcon(unsigned listIndex) const;
virtual String itemToolTip(unsigned listIndex) const;
virtual String itemAccessibilityText(unsigned listIndex) const;
virtual bool itemIsEnabled(unsigned listIndex) const;
diff --git a/WebCore/rendering/RenderTextControlSingleLine.cpp b/WebCore/rendering/RenderTextControlSingleLine.cpp
index d0ab107..f40fbf0 100644
--- a/WebCore/rendering/RenderTextControlSingleLine.cpp
+++ b/WebCore/rendering/RenderTextControlSingleLine.cpp
@@ -916,6 +916,11 @@ String RenderTextControlSingleLine::itemLabel(unsigned) const
return String();
}
+String RenderTextControlSingleLine::itemIcon(unsigned) const
+{
+ return String();
+}
+
bool RenderTextControlSingleLine::itemIsEnabled(unsigned listIndex) const
{
if (!listIndex || itemIsSeparator(listIndex))
diff --git a/WebCore/rendering/RenderTextControlSingleLine.h b/WebCore/rendering/RenderTextControlSingleLine.h
index 92ecadd..8c7e844 100644
--- a/WebCore/rendering/RenderTextControlSingleLine.h
+++ b/WebCore/rendering/RenderTextControlSingleLine.h
@@ -117,6 +117,7 @@ private:
virtual void selectionCleared() {}
virtual String itemText(unsigned listIndex) const;
virtual String itemLabel(unsigned listIndex) const;
+ virtual String itemIcon(unsigned listIndex) const;
virtual String itemToolTip(unsigned) const { return String(); }
virtual String itemAccessibilityText(unsigned) const { return String(); }
virtual bool itemIsEnabled(unsigned listIndex) const;
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index e6b2b9c..0adcc7e 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,23 @@
+2010-07-27 James Hawkins <jhawkins at chromium.org>
+
+ Reviewed by Darin Fisher.
+
+ [Chromium] Add the ability to show right-aligned icons in the AutoFill popup.
+ https://bugs.webkit.org/show_bug.cgi?id=43076
+
+ * public/WebView.h:
+ * src/AutoFillPopupMenuClient.cpp:
+ (WebKit::AutoFillPopupMenuClient::getIcon):
+ (WebKit::AutoFillPopupMenuClient::removeSuggestionAtIndex):
+ (WebKit::AutoFillPopupMenuClient::itemIcon):
+ (WebKit::AutoFillPopupMenuClient::initialize):
+ (WebKit::AutoFillPopupMenuClient::setSuggestions):
+ * src/AutoFillPopupMenuClient.h:
+ * src/WebViewImpl.cpp:
+ (WebKit::WebViewImpl::applyAutoFillSuggestions):
+ (WebKit::WebViewImpl::applyAutocompleteSuggestions):
+ * src/WebViewImpl.h:
+
2010-07-27 Brett Wilson <brettw at chromium.org>
Reviewed by Darin Fisher.
diff --git a/WebKit/chromium/public/WebView.h b/WebKit/chromium/public/WebView.h
index 26d7269..1b94da2 100644
--- a/WebKit/chromium/public/WebView.h
+++ b/WebKit/chromium/public/WebView.h
@@ -253,6 +253,7 @@ public:
const WebNode&,
const WebVector<WebString>& names,
const WebVector<WebString>& labels,
+ const WebVector<int>& uniqueIDs,
int separatorIndex) = 0;
// Notifies the WebView that AutoFill suggestions are available for a node.
@@ -262,6 +263,7 @@ public:
const WebNode&,
const WebVector<WebString>& names,
const WebVector<WebString>& labels,
+ const WebVector<WebString>& icons,
const WebVector<int>& uniqueIDs,
int separatorIndex) = 0;
diff --git a/WebKit/chromium/src/AutoFillPopupMenuClient.cpp b/WebKit/chromium/src/AutoFillPopupMenuClient.cpp
index 6b74f60..b14840c 100644
--- a/WebKit/chromium/src/AutoFillPopupMenuClient.cpp
+++ b/WebKit/chromium/src/AutoFillPopupMenuClient.cpp
@@ -84,6 +84,16 @@ WebString AutoFillPopupMenuClient::getLabel(unsigned listIndex) const
return m_labels[index];
}
+WebString AutoFillPopupMenuClient::getIcon(unsigned listIndex) const
+{
+ int index = convertListIndexToInternalIndex(listIndex);
+ if (index == -1)
+ return WebString();
+
+ ASSERT(index >= 0 && static_cast<size_t>(index) < m_icons.size());
+ return m_icons[index];
+}
+
void AutoFillPopupMenuClient::removeSuggestionAtIndex(unsigned listIndex)
{
if (!canRemoveSuggestionAtIndex(listIndex))
@@ -95,6 +105,8 @@ void AutoFillPopupMenuClient::removeSuggestionAtIndex(unsigned listIndex)
m_names.remove(index);
m_labels.remove(index);
+ m_icons.remove(index);
+ m_uniqueIDs.remove(index);
// Shift the separator index if necessary.
if (m_separatorIndex != -1)
@@ -177,6 +189,11 @@ String AutoFillPopupMenuClient::itemLabel(unsigned listIndex) const
return getLabel(listIndex);
}
+String AutoFillPopupMenuClient::itemIcon(unsigned listIndex) const
+{
+ return getIcon(listIndex);
+}
+
PopupMenuStyle AutoFillPopupMenuClient::itemStyle(unsigned listIndex) const
{
return *m_style;
@@ -249,10 +266,12 @@ void AutoFillPopupMenuClient::initialize(
HTMLInputElement* textField,
const WebVector<WebString>& names,
const WebVector<WebString>& labels,
+ const WebVector<WebString>& icons,
const WebVector<int>& uniqueIDs,
int separatorIndex)
{
ASSERT(names.size() == labels.size());
+ ASSERT(names.size() == icons.size());
ASSERT(names.size() == uniqueIDs.size());
ASSERT(separatorIndex < static_cast<int>(names.size()));
@@ -261,7 +280,7 @@ void AutoFillPopupMenuClient::initialize(
// The suggestions must be set before initializing the
// AutoFillPopupMenuClient.
- setSuggestions(names, labels, uniqueIDs, separatorIndex);
+ setSuggestions(names, labels, icons, uniqueIDs, separatorIndex);
FontDescription fontDescription;
RenderTheme::defaultTheme()->systemFont(CSSValueWebkitControl,
@@ -280,19 +299,23 @@ void AutoFillPopupMenuClient::initialize(
void AutoFillPopupMenuClient::setSuggestions(const WebVector<WebString>& names,
const WebVector<WebString>& labels,
+ const WebVector<WebString>& icons,
const WebVector<int>& uniqueIDs,
int separatorIndex)
{
ASSERT(names.size() == labels.size());
+ ASSERT(names.size() == icons.size());
ASSERT(names.size() == uniqueIDs.size());
ASSERT(separatorIndex < static_cast<int>(names.size()));
m_names.clear();
m_labels.clear();
+ m_icons.clear();
m_uniqueIDs.clear();
for (size_t i = 0; i < names.size(); ++i) {
m_names.append(names[i]);
m_labels.append(labels[i]);
+ m_icons.append(icons[i]);
m_uniqueIDs.append(uniqueIDs[i]);
}
diff --git a/WebKit/chromium/src/AutoFillPopupMenuClient.h b/WebKit/chromium/src/AutoFillPopupMenuClient.h
index 289c8d0..223cf16 100644
--- a/WebKit/chromium/src/AutoFillPopupMenuClient.h
+++ b/WebKit/chromium/src/AutoFillPopupMenuClient.h
@@ -60,6 +60,9 @@ public:
// Returns the label at |listIndex|.
virtual WebString getLabel(unsigned listIndex) const;
+ // Returns the icon at |listIndex|.
+ virtual WebString getIcon(unsigned listIndex) const;
+
// Removes the suggestion at |listIndex| from the list of suggestions.
virtual void removeSuggestionAtIndex(unsigned listIndex);
@@ -72,6 +75,7 @@ public:
virtual void selectionCleared();
virtual WebCore::String itemText(unsigned listIndex) const;
virtual WebCore::String itemLabel(unsigned listIndex) const;
+ virtual WebCore::String itemIcon(unsigned listIndex) const;
virtual WebCore::String itemToolTip(unsigned lastIndex) const { return WebCore::String(); }
virtual WebCore::String itemAccessibilityText(unsigned lastIndex) const { return WebCore::String(); }
virtual bool itemIsEnabled(unsigned listIndex) const { return true; }
@@ -100,11 +104,13 @@ public:
void initialize(WebCore::HTMLInputElement*,
const WebVector<WebString>& names,
const WebVector<WebString>& labels,
+ const WebVector<WebString>& icons,
const WebVector<int>& uniqueIDs,
int separatorIndex);
void setSuggestions(const WebVector<WebString>& names,
const WebVector<WebString>& labels,
+ const WebVector<WebString>& icons,
const WebVector<int>& uniqueIDs,
int separatorIndex);
@@ -124,9 +130,10 @@ private:
int getSelectedIndex() const { return m_selectedIndex; }
void setSelectedIndex(int index) { m_selectedIndex = index; }
- // The names and labels that make up the text of the menu items.
+ // The names, labels and icons that make up the contents of the menu items.
Vector<WebCore::String> m_names;
Vector<WebCore::String> m_labels;
+ Vector<WebCore::String> m_icons;
Vector<int> m_uniqueIDs;
// The index of the separator. -1 if there is no separator.
diff --git a/WebKit/chromium/src/WebViewImpl.cpp b/WebKit/chromium/src/WebViewImpl.cpp
index d8e69d4..0b5282b 100644
--- a/WebKit/chromium/src/WebViewImpl.cpp
+++ b/WebKit/chromium/src/WebViewImpl.cpp
@@ -1737,16 +1737,18 @@ void WebViewImpl::applyAutoFillSuggestions(
const WebNode& node,
const WebVector<WebString>& names,
const WebVector<WebString>& labels,
+ const WebVector<int>& uniqueIDs,
int separatorIndex)
{
- WebVector<int> uniqueIDs(names.size());
- applyAutoFillSuggestions(node, names, labels, uniqueIDs, separatorIndex);
+ WebVector<WebString> icons(names.size());
+ applyAutoFillSuggestions(node, names, labels, icons, uniqueIDs, separatorIndex);
}
void WebViewImpl::applyAutoFillSuggestions(
const WebNode& node,
const WebVector<WebString>& names,
const WebVector<WebString>& labels,
+ const WebVector<WebString>& icons,
const WebVector<int>& uniqueIDs,
int separatorIndex)
{
@@ -1777,7 +1779,7 @@ void WebViewImpl::applyAutoFillSuggestions(
m_autoFillPopupClient.set(new AutoFillPopupMenuClient);
m_autoFillPopupClient->initialize(
- inputElem, names, labels, uniqueIDs, separatorIndex);
+ inputElem, names, labels, icons, uniqueIDs, separatorIndex);
if (!m_autoFillPopup.get()) {
m_autoFillPopup = PopupContainer::create(m_autoFillPopupClient.get(),
@@ -1787,7 +1789,7 @@ void WebViewImpl::applyAutoFillSuggestions(
if (m_autoFillPopupShowing) {
m_autoFillPopupClient->setSuggestions(
- names, labels, uniqueIDs, separatorIndex);
+ names, labels, icons, uniqueIDs, separatorIndex);
refreshAutoFillPopup();
} else {
m_autoFillPopup->show(focusedNode->getRect(),
@@ -1809,12 +1811,13 @@ void WebViewImpl::applyAutocompleteSuggestions(
{
WebVector<WebString> names(suggestions.size());
WebVector<WebString> labels(suggestions.size());
+ WebVector<WebString> icons(suggestions.size());
WebVector<int> uniqueIDs(suggestions.size());
for (size_t i = 0; i < suggestions.size(); ++i)
names[i] = suggestions[i];
- applyAutoFillSuggestions(node, names, labels, uniqueIDs, -1);
+ applyAutoFillSuggestions(node, names, labels, icons, uniqueIDs, -1);
if (m_autoFillPopupClient)
m_autoFillPopupClient->setAutocompleteMode(true);
}
diff --git a/WebKit/chromium/src/WebViewImpl.h b/WebKit/chromium/src/WebViewImpl.h
index d0fda92..530fbf5 100644
--- a/WebKit/chromium/src/WebViewImpl.h
+++ b/WebKit/chromium/src/WebViewImpl.h
@@ -171,11 +171,13 @@ public:
const WebNode&,
const WebVector<WebString>& names,
const WebVector<WebString>& labels,
+ const WebVector<int>& uniqueIDs,
int separatorIndex);
virtual void applyAutoFillSuggestions(
const WebNode&,
const WebVector<WebString>& names,
const WebVector<WebString>& labels,
+ const WebVector<WebString>& icons,
const WebVector<int>& uniqueIDs,
int separatorIndex);
// DEPRECATED: replacing with applyAutoFillSuggestions.
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list