| OLD | NEW |
| 1 // Copyright (c) 2008, Google Inc. | 1 // Copyright (c) 2008, Google Inc. |
| 2 // All rights reserved. | 2 // 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 15 matching lines...) Expand all Loading... |
| 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 | 29 |
| 30 #include "config.h" | 30 #include "config.h" |
| 31 | 31 |
| 32 #pragma warning(push, 0) | 32 #pragma warning(push, 0) |
| 33 #include "PopupMenu.h" | 33 #include "PopupMenu.h" |
| 34 | 34 |
| 35 #include "CharacterNames.h" | 35 #include "CharacterNames.h" |
| 36 #include "ChromeClientWin.h" | 36 #include "ChromeClientChromium.h" |
| 37 #include "Document.h" | 37 #include "Document.h" |
| 38 #include "Font.h" | 38 #include "Font.h" |
| 39 #include "Frame.h" | 39 #include "Frame.h" |
| 40 #include "FontSelector.h" | 40 #include "FontSelector.h" |
| 41 #include "FramelessScrollView.h" | 41 #include "FramelessScrollView.h" |
| 42 #include "GraphicsContext.h" | 42 #include "GraphicsContext.h" |
| 43 #include "IntRect.h" | 43 #include "IntRect.h" |
| 44 #include "Page.h" | 44 #include "Page.h" |
| 45 #include "PlatformKeyboardEvent.h" | 45 #include "PlatformKeyboardEvent.h" |
| 46 #include "PlatformMouseEvent.h" | 46 #include "PlatformMouseEvent.h" |
| 47 #include "PlatformScreen.h" | 47 #include "PlatformScreen.h" |
| 48 #include "PlatformScrollbar.h" | 48 #include "PlatformScrollbar.h" |
| 49 #include "PlatformWheelEvent.h" | 49 #include "PlatformWheelEvent.h" |
| 50 #include "SystemTime.h" | 50 #include "SystemTime.h" |
| 51 #include "RenderBlock.h" | 51 #include "RenderBlock.h" |
| 52 #include "RenderTheme.h" | 52 #include "RenderTheme.h" |
| 53 #include "Widget.h" | 53 #include "Widget.h" |
| 54 #include "WidgetClientWin.h" | 54 #include "WidgetClientChromium.h" |
| 55 #pragma warning(pop) | 55 #pragma warning(pop) |
| 56 | 56 |
| 57 //#define LOG_ENABLE | |
| 58 #include "LogWin.h" | |
| 59 | |
| 60 using namespace WTF; | 57 using namespace WTF; |
| 61 using namespace Unicode; | 58 using namespace Unicode; |
| 62 | 59 |
| 63 using std::min; | 60 using std::min; |
| 64 using std::max; | 61 using std::max; |
| 65 | 62 |
| 66 namespace WebCore { | 63 namespace WebCore { |
| 67 | 64 |
| 68 typedef unsigned long long TimeStamp; | 65 typedef unsigned long long TimeStamp; |
| 69 | 66 |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 | 348 |
| 352 void PopupContainer::showPopup(FrameView* view) | 349 void PopupContainer::showPopup(FrameView* view) |
| 353 { | 350 { |
| 354 // Pre-layout, our size matches the <select> dropdown control. | 351 // Pre-layout, our size matches the <select> dropdown control. |
| 355 int selectHeight = frameGeometry().height(); | 352 int selectHeight = frameGeometry().height(); |
| 356 | 353 |
| 357 // Lay everything out to figure out our preferred size, then tell the view's | 354 // Lay everything out to figure out our preferred size, then tell the view's |
| 358 // WidgetClient about it. It should assign us a client. | 355 // WidgetClient about it. It should assign us a client. |
| 359 layout(); | 356 layout(); |
| 360 | 357 |
| 361 WidgetClientWin* widgetClient = | 358 WidgetClientChromium* widgetClient = static_cast<WidgetClientChromium*>( |
| 362 static_cast<WidgetClientWin*>(view->client()); | 359 view->client()); |
| 363 ChromeClientWin* chromeClient = | 360 ChromeClientChromium* chromeClient = static_cast<ChromeClientChromium*>( |
| 364 static_cast<ChromeClientWin*>(view->frame()->page()->chrome()->client())
; | 361 view->frame()->page()->chrome()->client()); |
| 365 if (widgetClient && chromeClient) { | 362 if (widgetClient && chromeClient) { |
| 366 // If the popup would extend past the bottom of the screen, open upwards | 363 // If the popup would extend past the bottom of the screen, open upwards |
| 367 // instead. | 364 // instead. |
| 368 FloatRect screen = screenRect(view); | 365 FloatRect screen = screenRect(view); |
| 369 IntRect widgetRect = chromeClient->windowToScreen(frameGeometry()); | 366 IntRect widgetRect = chromeClient->windowToScreen(frameGeometry()); |
| 370 if (widgetRect.bottom() > static_cast<int>(screen.bottom())) | 367 if (widgetRect.bottom() > static_cast<int>(screen.bottom())) |
| 371 widgetRect.move(0, -(widgetRect.height() + selectHeight)); | 368 widgetRect.move(0, -(widgetRect.height() + selectHeight)); |
| 372 | 369 |
| 373 widgetClient->popupOpened(this, widgetRect); | 370 widgetClient->popupOpened(this, widgetRect); |
| 374 } | 371 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 386 } | 383 } |
| 387 | 384 |
| 388 void PopupContainer::hidePopup() | 385 void PopupContainer::hidePopup() |
| 389 { | 386 { |
| 390 invalidate(); | 387 invalidate(); |
| 391 | 388 |
| 392 m_listBox->disconnectClient(); | 389 m_listBox->disconnectClient(); |
| 393 removeChild(m_listBox.get()); | 390 removeChild(m_listBox.get()); |
| 394 | 391 |
| 395 if (client()) | 392 if (client()) |
| 396 static_cast<WidgetClientWin*>(client())->popupClosed(this); | 393 static_cast<WidgetClientChromium*>(client())->popupClosed(this); |
| 397 } | 394 } |
| 398 | 395 |
| 399 void PopupContainer::layout() | 396 void PopupContainer::layout() |
| 400 { | 397 { |
| 401 m_listBox->layout(); | 398 m_listBox->layout(); |
| 402 | 399 |
| 403 // Place the listbox within our border. | 400 // Place the listbox within our border. |
| 404 m_listBox->move(kBorderSize, kBorderSize); | 401 m_listBox->move(kBorderSize, kBorderSize); |
| 405 | 402 |
| 406 // Size ourselves to contain listbox + border. | 403 // Size ourselves to contain listbox + border. |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 | 659 |
| 663 void PopupListBox::paint(GraphicsContext* gc, const IntRect& rect) | 660 void PopupListBox::paint(GraphicsContext* gc, const IntRect& rect) |
| 664 { | 661 { |
| 665 // adjust coords for scrolled frame | 662 // adjust coords for scrolled frame |
| 666 IntRect r = intersection(rect, frameGeometry()); | 663 IntRect r = intersection(rect, frameGeometry()); |
| 667 int tx = x() - contentsX(); | 664 int tx = x() - contentsX(); |
| 668 int ty = y() - contentsY(); | 665 int ty = y() - contentsY(); |
| 669 | 666 |
| 670 r.move(-tx, -ty); | 667 r.move(-tx, -ty); |
| 671 | 668 |
| 672 LOG(("PopupListBox::paint [%d,%d] [r: %d,%d,%d,%d]", tx, ty, | |
| 673 r.x(), r.y(), r.width(), r.height())); | |
| 674 | |
| 675 // set clip rect to match revised damage rect | 669 // set clip rect to match revised damage rect |
| 676 gc->save(); | 670 gc->save(); |
| 677 gc->translate(static_cast<float>(tx), static_cast<float>(ty)); | 671 gc->translate(static_cast<float>(tx), static_cast<float>(ty)); |
| 678 gc->clip(r); | 672 gc->clip(r); |
| 679 | 673 |
| 680 // TODO(mpcomplete): Can we optimize scrolling to not require repainting the | 674 // TODO(mpcomplete): Can we optimize scrolling to not require repainting the |
| 681 // entire window? Should we? | 675 // entire window? Should we? |
| 682 for (int i = 0; i < numItems(); ++i) | 676 for (int i = 0; i < numItems(); ++i) |
| 683 paintRow(gc, r, i); | 677 paintRow(gc, r, i); |
| 684 | 678 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 } | 713 } |
| 720 | 714 |
| 721 // If we have a transparent background, make sure it has a color to blend | 715 // If we have a transparent background, make sure it has a color to blend |
| 722 // against. | 716 // against. |
| 723 if (backColor.hasAlpha()) | 717 if (backColor.hasAlpha()) |
| 724 gc->fillRect(rowRect, Color::white); | 718 gc->fillRect(rowRect, Color::white); |
| 725 | 719 |
| 726 gc->fillRect(rowRect, backColor); | 720 gc->fillRect(rowRect, backColor); |
| 727 gc->setFillColor(textColor); | 721 gc->setFillColor(textColor); |
| 728 | 722 |
| 729 LOG(("paintRow %d, [%d, %d, %d, %d] %x on %x", rowIndex, | |
| 730 rowRect.x(), rowRect.y(), rowRect.width(), rowRect.height(), | |
| 731 textColor.rgb(), backColor.rgb())); | |
| 732 | |
| 733 Font itemFont = getRowFont(rowIndex); | 723 Font itemFont = getRowFont(rowIndex); |
| 734 gc->setFont(itemFont); | 724 gc->setFont(itemFont); |
| 735 | 725 |
| 736 // Bunch of shit to deal with RTL text... | 726 // Bunch of shit to deal with RTL text... |
| 737 String itemText = m_popupClient->itemText(rowIndex); | 727 String itemText = m_popupClient->itemText(rowIndex); |
| 738 unsigned length = itemText.length(); | 728 unsigned length = itemText.length(); |
| 739 const UChar* str = itemText.characters(); | 729 const UChar* str = itemText.characters(); |
| 740 | 730 |
| 741 TextRun textRun(str, length, false, 0, 0, style->direction() == RTL, style->
unicodeBidi() == Override); | 731 TextRun textRun(str, length, false, 0, 0, style->direction() == RTL, style->
unicodeBidi() == Override); |
| 742 | 732 |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1106 // FIXME | 1096 // FIXME |
| 1107 } | 1097 } |
| 1108 | 1098 |
| 1109 WebCore::IntRect PopupMenu::windowClipRect() const | 1099 WebCore::IntRect PopupMenu::windowClipRect() const |
| 1110 { | 1100 { |
| 1111 // FIXME | 1101 // FIXME |
| 1112 return WebCore::IntRect(); | 1102 return WebCore::IntRect(); |
| 1113 } | 1103 } |
| 1114 | 1104 |
| 1115 } // namespace WebCore | 1105 } // namespace WebCore |
| OLD | NEW |