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

Side by Side Diff: Source/core/platform/chromium/PopupListBox.cpp

Issue 14160005: Track the region where text is painted. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase with TOT Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011, Google Inc. All rights reserved. 2 * Copyright (c) 2011, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 465
466 // Prepare the directionality to draw text. 466 // Prepare the directionality to draw text.
467 TextRun textRun(itemText, 0, 0, TextRun::AllowTrailingExpansion, style.textD irection(), style.hasTextDirectionOverride()); 467 TextRun textRun(itemText, 0, 0, TextRun::AllowTrailingExpansion, style.textD irection(), style.hasTextDirectionOverride());
468 // If the text is right-to-left, make it right-aligned by adjusting its 468 // If the text is right-to-left, make it right-aligned by adjusting its
469 // beginning position. 469 // beginning position.
470 if (rightAligned) 470 if (rightAligned)
471 textX += maxWidth - itemFont.width(textRun); 471 textX += maxWidth - itemFont.width(textRun);
472 472
473 // Draw the item text. 473 // Draw the item text.
474 int textY = rowRect.y() + itemFont.fontMetrics().ascent() + (rowRect.height( ) - itemFont.fontMetrics().height()) / 2; 474 int textY = rowRect.y() + itemFont.fontMetrics().ascent() + (rowRect.height( ) - itemFont.fontMetrics().height()) / 2;
475 gc->drawBidiText(itemFont, textRun, IntPoint(textX, textY)); 475 gc->drawBidiText(itemFont, textRun, IntPoint(textX, textY), rowRect);
476 476
477 // We are using the left padding as the right padding includes room for the scroll-bar which 477 // We are using the left padding as the right padding includes room for the scroll-bar which
478 // does not show in this case. 478 // does not show in this case.
479 int rightPadding = max<int>(0, m_popupClient->clientPaddingLeft() - m_popupC lient->clientInsetLeft()); 479 int rightPadding = max<int>(0, m_popupClient->clientPaddingLeft() - m_popupC lient->clientInsetLeft());
480 int remainingWidth = rowRect.width() - rightPadding; 480 int remainingWidth = rowRect.width() - rightPadding;
481 481
482 // Draw the icon if applicable. 482 // Draw the icon if applicable.
483 RefPtr<Image> image(Image::loadPlatformResource(itemIcon.utf8().data())); 483 RefPtr<Image> image(Image::loadPlatformResource(itemIcon.utf8().data()));
484 if (image && !image->isNull()) { 484 if (image && !image->isNull()) {
485 IntRect imageRect = image->rect(); 485 IntRect imageRect = image->rect();
(...skipping 16 matching lines...) Expand all
502 itemFont.update(0); 502 itemFont.update(0);
503 } 503 }
504 504
505 TextRun labelTextRun(itemLabel, 0, 0, TextRun::AllowTrailingExpansion, style .textDirection(), style.hasTextDirectionOverride()); 505 TextRun labelTextRun(itemLabel, 0, 0, TextRun::AllowTrailingExpansion, style .textDirection(), style.hasTextDirectionOverride());
506 if (rightAligned) 506 if (rightAligned)
507 textX = max<int>(0, m_popupClient->clientPaddingLeft() - m_popupClient-> clientInsetLeft()); 507 textX = max<int>(0, m_popupClient->clientPaddingLeft() - m_popupClient-> clientInsetLeft());
508 else 508 else
509 textX = remainingWidth - itemFont.width(labelTextRun); 509 textX = remainingWidth - itemFont.width(labelTextRun);
510 510
511 gc->setFillColor(labelColor, ColorSpaceDeviceRGB); 511 gc->setFillColor(labelColor, ColorSpaceDeviceRGB);
512 gc->drawBidiText(itemFont, labelTextRun, IntPoint(textX, textY)); 512 gc->drawBidiText(itemFont, labelTextRun, IntPoint(textX, textY), rowRect);
513 } 513 }
514 514
515 Font PopupListBox::getRowFont(int rowIndex) 515 Font PopupListBox::getRowFont(int rowIndex)
516 { 516 {
517 Font itemFont = m_popupClient->itemStyle(rowIndex).font(); 517 Font itemFont = m_popupClient->itemStyle(rowIndex).font();
518 if (m_popupClient->itemIsLabel(rowIndex)) { 518 if (m_popupClient->itemIsLabel(rowIndex)) {
519 // Bold-ify labels (ie, an <optgroup> heading). 519 // Bold-ify labels (ie, an <optgroup> heading).
520 FontDescription d = itemFont.fontDescription(); 520 FontDescription d = itemFont.fontDescription();
521 d.setWeight(FontWeightBold); 521 d.setWeight(FontWeightBold);
522 Font font(d, itemFont.letterSpacing(), itemFont.wordSpacing()); 522 Font font(d, itemFont.letterSpacing(), itemFont.wordSpacing());
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 { 909 {
910 return numItems() && IntRect(0, 0, width(), height()).contains(point); 910 return numItems() && IntRect(0, 0, width(), height()).contains(point);
911 } 911 }
912 912
913 int PopupListBox::popupContentHeight() const 913 int PopupListBox::popupContentHeight() const
914 { 914 {
915 return height(); 915 return height();
916 } 916 }
917 917
918 } // namespace WebCore 918 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698