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

Side by Side Diff: Source/web/PopupListBox.cpp

Issue 603193005: Move the Widget hierarchy to the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add ~Scrollbar assert Created 6 years, 2 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
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 , m_lastCharTime(0) 80 , m_lastCharTime(0)
81 , m_maxWindowWidth(std::numeric_limits<int>::max()) 81 , m_maxWindowWidth(std::numeric_limits<int>::max())
82 , m_container(container) 82 , m_container(container)
83 { 83 {
84 } 84 }
85 85
86 PopupListBox::~PopupListBox() 86 PopupListBox::~PopupListBox()
87 { 87 {
88 clear(); 88 clear();
89 89
90 // Oilpan: the scrollbars of the ScrollView are self-sufficient,
91 // capable of detaching themselves from their animator on
92 // finalization.
93 #if !ENABLE(OILPAN)
90 setHasVerticalScrollbar(false); 94 setHasVerticalScrollbar(false);
95 #endif
96 }
97
98 void PopupListBox::trace(Visitor* visitor)
99 {
100 visitor->trace(m_capturingScrollbar);
101 visitor->trace(m_lastScrollbarUnderMouse);
102 visitor->trace(m_focusedElement);
103 visitor->trace(m_container);
104 visitor->trace(m_verticalScrollbar);
105 Widget::trace(visitor);
91 } 106 }
92 107
93 bool PopupListBox::handleMouseDownEvent(const PlatformMouseEvent& event) 108 bool PopupListBox::handleMouseDownEvent(const PlatformMouseEvent& event)
94 { 109 {
95 Scrollbar* scrollbar = scrollbarAtWindowPoint(event.position()); 110 Scrollbar* scrollbar = scrollbarAtWindowPoint(event.position());
96 if (scrollbar) { 111 if (scrollbar) {
97 m_capturingScrollbar = scrollbar; 112 m_capturingScrollbar = scrollbar;
98 m_capturingScrollbar->mouseDown(event); 113 m_capturingScrollbar->mouseDown(event);
99 return true; 114 return true;
100 } 115 }
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 Font font(d); 510 Font font(d);
496 font.update(nullptr); 511 font.update(nullptr);
497 return font; 512 return font;
498 } 513 }
499 514
500 return itemFont; 515 return itemFont;
501 } 516 }
502 517
503 void PopupListBox::abandon() 518 void PopupListBox::abandon()
504 { 519 {
505 RefPtr<PopupListBox> keepAlive(this); 520 RefPtrWillBeRawPtr<PopupListBox> protect(this);
506 521
507 m_selectedIndex = m_originalIndex; 522 m_selectedIndex = m_originalIndex;
508 523
509 hidePopup(); 524 hidePopup();
510 525
511 if (m_acceptedIndexOnAbandon >= 0) { 526 if (m_acceptedIndexOnAbandon >= 0) {
512 if (m_popupClient) 527 if (m_popupClient)
513 m_popupClient->valueChanged(m_acceptedIndexOnAbandon); 528 m_popupClient->valueChanged(m_acceptedIndexOnAbandon);
514 m_acceptedIndexOnAbandon = -1; 529 m_acceptedIndexOnAbandon = -1;
515 } 530 }
(...skipping 27 matching lines...) Expand all
543 558
544 if (index < 0) { 559 if (index < 0) {
545 if (m_popupClient) { 560 if (m_popupClient) {
546 // Enter pressed with no selection, just close the popup. 561 // Enter pressed with no selection, just close the popup.
547 hidePopup(); 562 hidePopup();
548 } 563 }
549 return false; 564 return false;
550 } 565 }
551 566
552 if (isSelectableItem(index)) { 567 if (isSelectableItem(index)) {
553 RefPtr<PopupListBox> keepAlive(this); 568 RefPtrWillBeRawPtr<PopupListBox> protect(this);
554 569
555 // Hide ourselves first since valueChanged may have numerous side-effect s. 570 // Hide ourselves first since valueChanged may have numerous side-effect s.
556 hidePopup(); 571 hidePopup();
557 572
558 // Tell the <select> PopupMenuClient what index was selected. 573 // Tell the <select> PopupMenuClient what index was selected.
559 m_popupClient->valueChanged(index); 574 m_popupClient->valueChanged(index);
560 575
561 return true; 576 return true;
562 } 577 }
563 578
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 setContentsSize(IntSize(contentWidth, getRowBounds(numItems() - 1).maxY())); 843 setContentsSize(IntSize(contentWidth, getRowBounds(numItems() - 1).maxY()));
829 844
830 if (hostWindow()) 845 if (hostWindow())
831 scrollToRevealSelection(); 846 scrollToRevealSelection();
832 847
833 invalidate(); 848 invalidate();
834 } 849 }
835 850
836 void PopupListBox::clear() 851 void PopupListBox::clear()
837 { 852 {
838 for (Vector<PopupItem*>::iterator it = m_items.begin(); it != m_items.end(); ++it) 853 deleteAllValues(m_items);
haraken 2014/09/29 14:16:36 It would be better to use Vector<OwnPtr<PopupItem>
839 delete *it;
840 m_items.clear(); 854 m_items.clear();
841 } 855 }
842 856
843 bool PopupListBox::isPointInBounds(const IntPoint& point) 857 bool PopupListBox::isPointInBounds(const IntPoint& point)
844 { 858 {
845 return numItems() && IntRect(0, 0, width(), height()).contains(point); 859 return numItems() && IntRect(0, 0, width(), height()).contains(point);
846 } 860 }
847 861
848 int PopupListBox::popupContentHeight() const 862 int PopupListBox::popupContentHeight() const
849 { 863 {
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 maximumOffset.clampNegativeToZero(); 1055 maximumOffset.clampNegativeToZero();
1042 return maximumOffset; 1056 return maximumOffset;
1043 } 1057 }
1044 1058
1045 IntPoint PopupListBox::minimumScrollPosition() const 1059 IntPoint PopupListBox::minimumScrollPosition() const
1046 { 1060 {
1047 return IntPoint(-scrollOrigin().x(), -scrollOrigin().y()); 1061 return IntPoint(-scrollOrigin().x(), -scrollOrigin().y());
1048 } 1062 }
1049 1063
1050 } // namespace blink 1064 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698