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

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: fixed build on win and mac Created 7 years, 7 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 TextRunPaintInfo textRunPaintInfo(textRun);
476 textRunPaintInfo.bounds = rowRect;
477 gc->drawBidiText(itemFont, textRunPaintInfo, IntPoint(textX, textY));
476 478
477 // We are using the left padding as the right padding includes room for the scroll-bar which 479 // We are using the left padding as the right padding includes room for the scroll-bar which
478 // does not show in this case. 480 // does not show in this case.
479 int rightPadding = max<int>(0, m_popupClient->clientPaddingLeft() - m_popupC lient->clientInsetLeft()); 481 int rightPadding = max<int>(0, m_popupClient->clientPaddingLeft() - m_popupC lient->clientInsetLeft());
480 int remainingWidth = rowRect.width() - rightPadding; 482 int remainingWidth = rowRect.width() - rightPadding;
481 483
482 // Draw the icon if applicable. 484 // Draw the icon if applicable.
483 RefPtr<Image> image(Image::loadPlatformResource(itemIcon.utf8().data())); 485 RefPtr<Image> image(Image::loadPlatformResource(itemIcon.utf8().data()));
484 if (image && !image->isNull()) { 486 if (image && !image->isNull()) {
485 IntRect imageRect = image->rect(); 487 IntRect imageRect = image->rect();
(...skipping 14 matching lines...) Expand all
500 d.setComputedSize(d.computedSize() * 0.9); 502 d.setComputedSize(d.computedSize() * 0.9);
501 itemFont = Font(d, itemFont.letterSpacing(), itemFont.wordSpacing()); 503 itemFont = Font(d, itemFont.letterSpacing(), itemFont.wordSpacing());
502 itemFont.update(0); 504 itemFont.update(0);
503 } 505 }
504 506
505 TextRun labelTextRun(itemLabel, 0, 0, TextRun::AllowTrailingExpansion, style .textDirection(), style.hasTextDirectionOverride()); 507 TextRun labelTextRun(itemLabel, 0, 0, TextRun::AllowTrailingExpansion, style .textDirection(), style.hasTextDirectionOverride());
506 if (rightAligned) 508 if (rightAligned)
507 textX = max<int>(0, m_popupClient->clientPaddingLeft() - m_popupClient-> clientInsetLeft()); 509 textX = max<int>(0, m_popupClient->clientPaddingLeft() - m_popupClient-> clientInsetLeft());
508 else 510 else
509 textX = remainingWidth - itemFont.width(labelTextRun); 511 textX = remainingWidth - itemFont.width(labelTextRun);
512 TextRunPaintInfo labelTextRunPaintInfo(labelTextRun);
513 labelTextRunPaintInfo.bounds = rowRect;
510 514
511 gc->setFillColor(labelColor, ColorSpaceDeviceRGB); 515 gc->setFillColor(labelColor, ColorSpaceDeviceRGB);
512 gc->drawBidiText(itemFont, labelTextRun, IntPoint(textX, textY)); 516 gc->drawBidiText(itemFont, labelTextRunPaintInfo, IntPoint(textX, textY));
513 } 517 }
514 518
515 Font PopupListBox::getRowFont(int rowIndex) 519 Font PopupListBox::getRowFont(int rowIndex)
516 { 520 {
517 Font itemFont = m_popupClient->itemStyle(rowIndex).font(); 521 Font itemFont = m_popupClient->itemStyle(rowIndex).font();
518 if (m_popupClient->itemIsLabel(rowIndex)) { 522 if (m_popupClient->itemIsLabel(rowIndex)) {
519 // Bold-ify labels (ie, an <optgroup> heading). 523 // Bold-ify labels (ie, an <optgroup> heading).
520 FontDescription d = itemFont.fontDescription(); 524 FontDescription d = itemFont.fontDescription();
521 d.setWeight(FontWeightBold); 525 d.setWeight(FontWeightBold);
522 Font font(d, itemFont.letterSpacing(), itemFont.wordSpacing()); 526 Font font(d, itemFont.letterSpacing(), itemFont.wordSpacing());
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 { 913 {
910 return numItems() && IntRect(0, 0, width(), height()).contains(point); 914 return numItems() && IntRect(0, 0, width(), height()).contains(point);
911 } 915 }
912 916
913 int PopupListBox::popupContentHeight() const 917 int PopupListBox::popupContentHeight() const
914 { 918 {
915 return height(); 919 return height();
916 } 920 }
917 921
918 } // namespace WebCore 922 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/canvas/CanvasRenderingContext2D.cpp ('k') | Source/core/platform/graphics/Font.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698