Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1791)

Unified Diff: Source/web/PopupMenuImpl.cpp

Issue 1164873004: New SELECT Popup: Correctly count the number of items for styling. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/web/PopupMenuImpl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/PopupMenuImpl.cpp
diff --git a/Source/web/PopupMenuImpl.cpp b/Source/web/PopupMenuImpl.cpp
index e0cb84fe7b37c148acc50fc71b8f0255c91a3d1e..1304a6fa0fe9f6b5686f6340cfd0f111af32288f 100644
--- a/Source/web/PopupMenuImpl.cpp
+++ b/Source/web/PopupMenuImpl.cpp
@@ -15,6 +15,7 @@
#include "core/html/HTMLHRElement.h"
#include "core/html/HTMLOptGroupElement.h"
#include "core/html/HTMLOptionElement.h"
+#include "core/html/HTMLSelectElement.h"
#include "core/html/parser/HTMLParserIdioms.h"
#include "core/layout/LayoutTheme.h"
#include "core/page/PagePopup.h"
@@ -27,11 +28,6 @@
namespace blink {
-// We don't make child style information if the popup will have a lot of items
-// because of a performance problem.
-// TODO(tkent): This is a workaround. We should do a performance optimization.
-static const unsigned styledChildrenLimit = 100;
-
class PopupMenuCSSFontSelector : public CSSFontSelector {
public:
static PassRefPtrWillBeRawPtr<PopupMenuCSSFontSelector> create(Document* document, CSSFontSelector* ownerFontSelector)
@@ -88,6 +84,19 @@ IntSize PopupMenuImpl::contentSize()
return IntSize();
}
+// We don't make child style information if the popup will have a lot of items
+// because of a performance problem.
+// TODO(tkent): This is a workaround. We should do a performance optimization.
+bool PopupMenuImpl::hasTooManyItemsForStyling()
+{
+ // 300 is enough for world-wide countries.
+ const unsigned styledChildrenLimit = 300;
+
+ if (!isHTMLSelectElement(ownerElement()))
+ return false;
+ return toHTMLSelectElement(ownerElement()).listItems().size() > styledChildrenLimit;
+}
+
void PopupMenuImpl::writeDocument(SharedBuffer* data)
{
IntRect anchorRectInScreen = m_chromeClient->viewportToScreen(m_client->elementRectRelativeToViewport());
@@ -99,7 +108,7 @@ void PopupMenuImpl::writeDocument(SharedBuffer* data)
"window.dialogArguments = {\n", data);
addProperty("selectedIndex", m_client->selectedIndex(), data);
PagePopupClient::addString("children: [\n", data);
- bool enableExtraStyling = ownerElement().countChildren() < styledChildrenLimit;
+ bool enableExtraStyling = !hasTooManyItemsForStyling();
for (HTMLElement& child : Traversal<HTMLElement>::childrenOf(ownerElement())) {
if (isHTMLOptionElement(child))
addOption(toHTMLOptionElement(child), enableExtraStyling, data);
@@ -379,7 +388,7 @@ void PopupMenuImpl::update()
PagePopupClient::addString("window.updateData = {\n", data.get());
PagePopupClient::addString("type: \"update\",\n", data.get());
PagePopupClient::addString("children: [", data.get());
- bool enableExtraStyling = ownerElement().countChildren() < styledChildrenLimit;
+ bool enableExtraStyling = !hasTooManyItemsForStyling();
for (HTMLElement& child : Traversal<HTMLElement>::childrenOf(ownerElement())) {
if (isHTMLOptionElement(child))
addOption(toHTMLOptionElement(child), enableExtraStyling, data.get());
« no previous file with comments | « Source/web/PopupMenuImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698