|
a/Source/WebCore/platform/chromium/PopupListBox.cpp_sec1
|
| 44 |
#include "PopupMenuChromium.h" |
44 |
#include "PopupMenuChromium.h" |
| 45 |
#include "PopupMenuClient.h" |
45 |
#include "PopupMenuClient.h" |
| 46 |
#include "RenderTheme.h" |
46 |
#include "RenderTheme.h" |
|
|
47 |
#include "RuntimeEnabledFeatures.h" |
| 47 |
#include "ScrollbarTheme.h" |
48 |
#include "ScrollbarTheme.h" |
| 48 |
#include "StringTruncator.h" |
49 |
#include "StringTruncator.h" |
| 49 |
#include "TextRun.h" |
50 |
#include "TextRun.h" |
|
void PopupListBox::typeAheadFind(const PlatformKeyboardEvent& event)
a/Source/WebCore/platform/chromium/PopupListBox.cpp_sec2
|
| 352 |
|
353 |
|
| 353 |
void PopupListBox::paint(GraphicsContext* gc, const IntRect& rect) |
354 |
void PopupListBox::paint(GraphicsContext* gc, const IntRect& rect) |
| 354 |
{ |
355 |
{ |
|
|
356 |
int scale = m_settings.defaultDeviceScaleFactor; |
| 355 |
// adjust coords for scrolled frame |
357 |
// adjust coords for scrolled frame |
| 356 |
IntRect r = intersection(rect, frameRect()); |
358 |
IntRect r = intersection(rect, frameRect()); |
| 357 |
int tx = x() - scrollX(); |
359 |
int tx = x() - scrollX(); |
|
void PopupListBox::paint(GraphicsContext* gc, const IntRect& rect)
a/Source/WebCore/platform/chromium/PopupListBox.cpp_sec3
|
| 366 |
|
368 |
|
| 367 |
// FIXME: Can we optimize scrolling to not require repainting the entire |
369 |
// FIXME: Can we optimize scrolling to not require repainting the entire |
| 368 |
// window? Should we? |
370 |
// window? Should we? |
|
|
371 |
if (scale != 1) |
| 372 |
gc->scale(FloatSize(scale, scale)); |
| 369 |
for (int i = 0; i < numItems(); ++i) |
373 |
for (int i = 0; i < numItems(); ++i) |
| 370 |
paintRow(gc, r, i); |
374 |
paintRow(gc, r, i); |
| 371 |
|
375 |
|
|
void PopupListBox::paintRow(GraphicsContext* gc, const IntRect& rect, int rowInd
a/Source/WebCore/platform/chromium/PopupListBox.cpp_sec4
|
| 389 |
if (!rowRect.intersects(rect)) |
393 |
if (!rowRect.intersects(rect)) |
| 390 |
return; |
394 |
return; |
| 391 |
|
395 |
|
|
|
396 |
int scale = m_settings.defaultDeviceScaleFactor; |
| 397 |
// RowRect has already been scaled by the defaultDeviceScaleFactor. |
| 398 |
// To avoid scaling it twice, we have to unscale it before drawing. |
| 399 |
if (scale != 1) { |
| 400 |
// Height and y should both be evenly divisible by scale. |
| 401 |
ASSERT(!(rowRect.y() % scale)); |
| 402 |
rowRect.setY(rowRect.y() / scale); |
| 403 |
ASSERT(!(rowRect.height() % scale)); |
| 404 |
rowRect.setHeight(rowRect.height() / scale); |
| 405 |
rowRect.setWidth(ceilf(static_cast<float>(rowRect.width()) / scale)); |
| 406 |
// rowRect.x is always 0. |
| 407 |
} |
| 408 |
|
| 392 |
PopupMenuStyle style = m_popupClient->itemStyle(rowIndex); |
409 |
PopupMenuStyle style = m_popupClient->itemStyle(rowIndex); |
| 393 |
|
410 |
|
| 394 |
// Paint background |
411 |
// Paint background |
|
void PopupListBox::setOriginalIndex(int index)
a/Source/WebCore/platform/chromium/PopupListBox.cpp_sec5
|
| 613 |
|
630 |
|
| 614 |
int PopupListBox::getRowHeight(int index) |
631 |
int PopupListBox::getRowHeight(int index) |
| 615 |
{ |
632 |
{ |
| 616 |
if (index < 0) |
633 |
int scale = m_settings.defaultDeviceScaleFactor; |
| 617 |
return PopupMenuChromium::minimumRowHeight(); |
634 |
int paddingForTouch = 0; |
| 618 |
|
635 |
if (RuntimeEnabledFeatures::touchEnabled()) |
| 619 |
if (m_popupClient->itemStyle(index).isDisplayNone()) |
636 |
paddingForTouch = PopupMenuChromium::optionPaddingForTouch(); |
| 620 |
return PopupMenuChromium::minimumRowHeight(); |
637 |
if (index < 0 || m_popupClient->itemStyle(index).isDisplayNone()) |
|
|
638 |
return PopupMenuChromium::minimumRowHeight() * scale; |
| 621 |
|
639 |
|
| 622 |
// Separator row height is the same size as itself. |
640 |
// Separator row height is the same size as itself. |
| 623 |
if (m_popupClient->itemIsSeparator(index)) |
641 |
if (m_popupClient->itemIsSeparator(index)) |
| 624 |
return max(separatorHeight, PopupMenuChromium::minimumRowHeight()); |
642 |
return max(separatorHeight, (PopupMenuChromium::minimumRowHeight())) * scale; |
| 625 |
|
643 |
|
| 626 |
String icon = m_popupClient->itemIcon(index); |
644 |
String icon = m_popupClient->itemIcon(index); |
| 627 |
RefPtr<Image> image(Image::loadPlatformResource(icon.utf8().data())); |
645 |
RefPtr<Image> image(Image::loadPlatformResource(icon.utf8().data())); |
|
int PopupListBox::getRowHeight(int index)
a/Source/WebCore/platform/chromium/PopupListBox.cpp_sec6
|
| 631 |
|
649 |
|
| 632 |
int linePaddingHeight = m_popupClient->menuStyle().menuType() == PopupMenuStyle::AutofillPopup ? kLinePaddingHeight : 0; |
650 |
int linePaddingHeight = m_popupClient->menuStyle().menuType() == PopupMenuStyle::AutofillPopup ? kLinePaddingHeight : 0; |
| 633 |
int calculatedRowHeight = max(fontHeight, iconHeight) + linePaddingHeight * 2; |
651 |
int calculatedRowHeight = max(fontHeight, iconHeight) + linePaddingHeight * 2; |
| 634 |
return max(calculatedRowHeight, PopupMenuChromium::minimumRowHeight()); |
652 |
return (max(calculatedRowHeight, PopupMenuChromium::minimumRowHeight()) + paddingForTouch) * scale; |
| 635 |
} |
653 |
} |
| 636 |
|
654 |
|
| 637 |
IntRect PopupListBox::getRowBounds(int index) |
655 |
IntRect PopupListBox::getRowBounds(int index) |