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

Side by Side Diff: Source/core/rendering/RenderListBox.cpp

Issue 275573003: Oilpan: Prepare to move select and option elements to Oilpan heap. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
3 * 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 3 * 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 inline HTMLSelectElement* RenderListBox::selectElement() const 114 inline HTMLSelectElement* RenderListBox::selectElement() const
115 { 115 {
116 return toHTMLSelectElement(node()); 116 return toHTMLSelectElement(node());
117 } 117 }
118 118
119 void RenderListBox::updateFromElement() 119 void RenderListBox::updateFromElement()
120 { 120 {
121 FontCachePurgePreventer fontCachePurgePreventer; 121 FontCachePurgePreventer fontCachePurgePreventer;
122 if (m_optionsChanged) { 122 if (m_optionsChanged) {
123 const Vector<HTMLElement*>& listItems = selectElement()->listItems(); 123 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& listItems = se lectElement()->listItems();
124 int size = static_cast<int>(listItems.size()); 124 int size = static_cast<int>(listItems.size());
125 125
126 float width = 0; 126 float width = 0;
127 m_listItemCount = 0; 127 m_listItemCount = 0;
128 for (int i = 0; i < size; ++i) { 128 for (int i = 0; i < size; ++i) {
129 const HTMLElement& element = *listItems[i]; 129 const HTMLElement& element = *listItems[i];
130 130
131 String text; 131 String text;
132 Font itemFont = style()->font(); 132 Font itemFont = style()->font();
133 if (isHTMLOptionElement(element)) { 133 if (isHTMLOptionElement(element)) {
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 366
367 // Focus the last selected item. 367 // Focus the last selected item.
368 int selectedItem = select->activeSelectionEndListIndex(); 368 int selectedItem = select->activeSelectionEndListIndex();
369 if (selectedItem >= 0) { 369 if (selectedItem >= 0) {
370 rects.append(pixelSnappedIntRect(itemBoundingBoxRectInternal(additionalO ffset, selectedItem))); 370 rects.append(pixelSnappedIntRect(itemBoundingBoxRectInternal(additionalO ffset, selectedItem)));
371 return; 371 return;
372 } 372 }
373 373
374 // No selected items, find the first non-disabled item. 374 // No selected items, find the first non-disabled item.
375 int size = numItems(); 375 int size = numItems();
376 const Vector<HTMLElement*>& listItems = select->listItems(); 376 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& listItems = select ->listItems();
377 for (int i = 0; i < size; ++i) { 377 for (int i = 0; i < size; ++i) {
378 HTMLElement* element = listItems[renderListBoxIndexToListIndex(i)]; 378 HTMLElement* element = listItems[renderListBoxIndexToListIndex(i)];
379 if (isHTMLOptionElement(*element) && !element->isDisabledFormControl()) { 379 if (isHTMLOptionElement(*element) && !element->isDisabledFormControl()) {
380 rects.append(pixelSnappedIntRect(itemBoundingBoxRectInternal(additio nalOffset, i))); 380 rects.append(pixelSnappedIntRect(itemBoundingBoxRectInternal(additio nalOffset, i)));
381 return; 381 return;
382 } 382 }
383 } 383 }
384 } 384 }
385 385
386 int RenderListBox::scrollbarLeft() const 386 int RenderListBox::scrollbarLeft() const
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 offset.setWidth(optionsSpacingHorizontal); 424 offset.setWidth(optionsSpacingHorizontal);
425 return offset; 425 return offset;
426 } 426 }
427 427
428 void RenderListBox::paintItemForeground(PaintInfo& paintInfo, const LayoutPoint& paintOffset, int listIndex) 428 void RenderListBox::paintItemForeground(PaintInfo& paintInfo, const LayoutPoint& paintOffset, int listIndex)
429 { 429 {
430 FontCachePurgePreventer fontCachePurgePreventer; 430 FontCachePurgePreventer fontCachePurgePreventer;
431 431
432 HTMLSelectElement* select = selectElement(); 432 HTMLSelectElement* select = selectElement();
433 433
434 const Vector<HTMLElement*>& listItems = select->listItems(); 434 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& listItems = select ->listItems();
435 HTMLElement* element = listItems[renderListBoxIndexToListIndex(listIndex)]; 435 HTMLElement* element = listItems[renderListBoxIndexToListIndex(listIndex)];
436 436
437 RenderStyle* itemStyle = element->renderStyle(); 437 RenderStyle* itemStyle = element->renderStyle();
438 if (!itemStyle) 438 if (!itemStyle)
439 itemStyle = style(); 439 itemStyle = style();
440 440
441 if (itemStyle->visibility() == HIDDEN) 441 if (itemStyle->visibility() == HIDDEN)
442 return; 442 return;
443 443
444 String itemText; 444 String itemText;
(...skipping 28 matching lines...) Expand all
473 } 473 }
474 474
475 // Draw the item text 475 // Draw the item text
476 TextRunPaintInfo textRunPaintInfo(textRun); 476 TextRunPaintInfo textRunPaintInfo(textRun);
477 textRunPaintInfo.bounds = r; 477 textRunPaintInfo.bounds = r;
478 paintInfo.context->drawBidiText(itemFont, textRunPaintInfo, roundedIntPoint( r.location())); 478 paintInfo.context->drawBidiText(itemFont, textRunPaintInfo, roundedIntPoint( r.location()));
479 } 479 }
480 480
481 void RenderListBox::paintItemBackground(PaintInfo& paintInfo, const LayoutPoint& paintOffset, int listIndex) 481 void RenderListBox::paintItemBackground(PaintInfo& paintInfo, const LayoutPoint& paintOffset, int listIndex)
482 { 482 {
483 const Vector<HTMLElement*>& listItems = selectElement()->listItems(); 483 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& listItems = select Element()->listItems();
484 HTMLElement* element = listItems[renderListBoxIndexToListIndex(listIndex)]; 484 HTMLElement* element = listItems[renderListBoxIndexToListIndex(listIndex)];
485 485
486 Color backColor; 486 Color backColor;
487 if (isHTMLOptionElement(*element) && ((toHTMLOptionElement(*element).selecte d() && selectElement()->suggestedIndex() < 0) || listIndex == selectElement()->s uggestedIndex())) { 487 if (isHTMLOptionElement(*element) && ((toHTMLOptionElement(*element).selecte d() && selectElement()->suggestedIndex() < 0) || listIndex == selectElement()->s uggestedIndex())) {
488 if (frame()->selection().isFocusedAndActive() && document().focusedEleme nt() == node()) 488 if (frame()->selection().isFocusedAndActive() && document().focusedEleme nt() == node())
489 backColor = RenderTheme::theme().activeListBoxSelectionBackgroundCol or(); 489 backColor = RenderTheme::theme().activeListBoxSelectionBackgroundCol or();
490 else 490 else
491 backColor = RenderTheme::theme().inactiveListBoxSelectionBackgroundC olor(); 491 backColor = RenderTheme::theme().inactiveListBoxSelectionBackgroundC olor();
492 } else { 492 } else {
493 backColor = element->renderStyle() ? resolveColor(element->renderStyle() , CSSPropertyBackgroundColor) : resolveColor(CSSPropertyBackgroundColor); 493 backColor = element->renderStyle() ? resolveColor(element->renderStyle() , CSSPropertyBackgroundColor) : resolveColor(CSSPropertyBackgroundColor);
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 if (index < 0 || index >= numItems() || index == m_indexOffset) 729 if (index < 0 || index >= numItems() || index == m_indexOffset)
730 return; 730 return;
731 731
732 scrollToOffsetWithoutAnimation(VerticalScrollbar, index); 732 scrollToOffsetWithoutAnimation(VerticalScrollbar, index);
733 } 733 }
734 734
735 bool RenderListBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re sult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulated Offset, HitTestAction hitTestAction) 735 bool RenderListBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re sult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulated Offset, HitTestAction hitTestAction)
736 { 736 {
737 if (!RenderBlockFlow::nodeAtPoint(request, result, locationInContainer, accu mulatedOffset, hitTestAction)) 737 if (!RenderBlockFlow::nodeAtPoint(request, result, locationInContainer, accu mulatedOffset, hitTestAction))
738 return false; 738 return false;
739 const Vector<HTMLElement*>& listItems = selectElement()->listItems(); 739 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& listItems = select Element()->listItems();
740 int size = numItems(); 740 int size = numItems();
741 LayoutPoint adjustedLocation = accumulatedOffset + location(); 741 LayoutPoint adjustedLocation = accumulatedOffset + location();
742 742
743 for (int i = 0; i < size; ++i) { 743 for (int i = 0; i < size; ++i) {
744 if (itemBoundingBoxRectInternal(adjustedLocation, i).contains(locationIn Container.point())) { 744 if (itemBoundingBoxRectInternal(adjustedLocation, i).contains(locationIn Container.point())) {
745 if (Element* node = listItems[renderListBoxIndexToListIndex(i)]) { 745 if (Element* node = listItems[renderListBoxIndexToListIndex(i)]) {
746 result.setInnerNode(node); 746 result.setInnerNode(node);
747 if (!result.innerNonSharedNode()) 747 if (!result.innerNonSharedNode())
748 result.setInnerNonSharedNode(node); 748 result.setInnerNonSharedNode(node);
749 result.setLocalPoint(locationInContainer.point() - toLayoutSize( adjustedLocation)); 749 result.setLocalPoint(locationInContainer.point() - toLayoutSize( adjustedLocation));
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 if (m_vBar) 968 if (m_vBar)
969 m_vBar->styleChanged(); 969 m_vBar->styleChanged();
970 970
971 // Force an update since we know the scrollbars have changed things. 971 // Force an update since we know the scrollbars have changed things.
972 if (document().hasAnnotatedRegions()) 972 if (document().hasAnnotatedRegions())
973 document().setAnnotatedRegionsDirty(true); 973 document().setAnnotatedRegionsDirty(true);
974 } 974 }
975 975
976 int RenderListBox::renderListBoxIndexToListIndex(int index) const 976 int RenderListBox::renderListBoxIndexToListIndex(int index) const
977 { 977 {
978 const Vector<HTMLElement*>& listItems = selectElement()->listItems(); 978 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& listItems = select Element()->listItems();
979 const int size = static_cast<int>(listItems.size()); 979 const int size = static_cast<int>(listItems.size());
980 980
981 if (size == numItems()) 981 if (size == numItems())
982 return index; 982 return index;
983 983
984 int listBoxIndex = 0; 984 int listBoxIndex = 0;
985 int listIndex = 0; 985 int listIndex = 0;
986 for (; listIndex < size; ++listIndex) { 986 for (; listIndex < size; ++listIndex) {
987 const HTMLElement& element = *listItems[listIndex]; 987 const HTMLElement& element = *listItems[listIndex];
988 if (isHTMLOptionElement(element) && toHTMLOptionElement(element).isDispl ayNone()) 988 if (isHTMLOptionElement(element) && toHTMLOptionElement(element).isDispl ayNone())
989 continue; 989 continue;
990 if (isHTMLOptGroupElement(element) && toHTMLOptGroupElement(element).isD isplayNone()) 990 if (isHTMLOptGroupElement(element) && toHTMLOptGroupElement(element).isD isplayNone())
991 continue; 991 continue;
992 if (index == listBoxIndex) 992 if (index == listBoxIndex)
993 break; 993 break;
994 ++listBoxIndex; 994 ++listBoxIndex;
995 } 995 }
996 return listIndex; 996 return listIndex;
997 } 997 }
998 998
999 int RenderListBox::listIndexToRenderListBoxIndex(int index) const 999 int RenderListBox::listIndexToRenderListBoxIndex(int index) const
1000 { 1000 {
1001 const Vector<HTMLElement*>& listItems = selectElement()->listItems(); 1001 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& listItems = select Element()->listItems();
1002 const int size = static_cast<int>(listItems.size()); 1002 const int size = static_cast<int>(listItems.size());
1003 1003
1004 if (size == numItems()) 1004 if (size == numItems())
1005 return index; 1005 return index;
1006 1006
1007 int listBoxIndex = 0; 1007 int listBoxIndex = 0;
1008 for (int listIndex = 0; listIndex < size; ++listIndex) { 1008 for (int listIndex = 0; listIndex < size; ++listIndex) {
1009 const HTMLElement& element = *listItems[listIndex]; 1009 const HTMLElement& element = *listItems[listIndex];
1010 if (isHTMLOptionElement(element) && toHTMLOptionElement(element).isDispl ayNone()) 1010 if (isHTMLOptionElement(element) && toHTMLOptionElement(element).isDispl ayNone())
1011 continue; 1011 continue;
(...skipping 10 matching lines...) Expand all
1022 { 1022 {
1023 return itemBoundingBoxRectInternal(point, listIndexToRenderListBoxIndex(inde x)); 1023 return itemBoundingBoxRectInternal(point, listIndexToRenderListBoxIndex(inde x));
1024 } 1024 }
1025 1025
1026 bool RenderListBox::scrollToRevealElementAtListIndex(int index) 1026 bool RenderListBox::scrollToRevealElementAtListIndex(int index)
1027 { 1027 {
1028 return scrollToRevealElementAtListIndexInternal(listIndexToRenderListBoxInde x(index)); 1028 return scrollToRevealElementAtListIndexInternal(listIndexToRenderListBoxInde x(index));
1029 } 1029 }
1030 1030
1031 } // namespace WebCore 1031 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698