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/RenderMenuList.cpp

Issue 19510005: [oilpan] Completely move HTMLFormControlElement's hierarchy to the managed heap Base URL: svn://svn.chromium.org/blink/branches/oilpan
Patch Set: Created 7 years, 5 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
« no previous file with comments | « Source/core/rendering/RenderMenuList.h ('k') | Source/core/rendering/RenderSearchField.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of the select element renderer in WebCore. 2 * This file is part of the select element renderer in WebCore.
3 * 3 *
4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
6 * 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 6 * 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 innerStyle->setDirection(direction); 124 innerStyle->setDirection(direction);
125 } else if (m_optionStyle && document()->page()->chrome()->selectItemAlignmen tFollowsMenuWritingDirection()) { 125 } else if (m_optionStyle && document()->page()->chrome()->selectItemAlignmen tFollowsMenuWritingDirection()) {
126 if ((m_optionStyle->direction() != innerStyle->direction() || m_optionSt yle->unicodeBidi() != innerStyle->unicodeBidi())) 126 if ((m_optionStyle->direction() != innerStyle->direction() || m_optionSt yle->unicodeBidi() != innerStyle->unicodeBidi()))
127 m_innerBlock->setNeedsLayoutAndPrefWidthsRecalc(); 127 m_innerBlock->setNeedsLayoutAndPrefWidthsRecalc();
128 innerStyle->setTextAlign(style()->isLeftToRightDirection() ? LEFT : RIGH T); 128 innerStyle->setTextAlign(style()->isLeftToRightDirection() ? LEFT : RIGH T);
129 innerStyle->setDirection(m_optionStyle->direction()); 129 innerStyle->setDirection(m_optionStyle->direction());
130 innerStyle->setUnicodeBidi(m_optionStyle->unicodeBidi()); 130 innerStyle->setUnicodeBidi(m_optionStyle->unicodeBidi());
131 } 131 }
132 } 132 }
133 133
134 inline HTMLSelectElement* RenderMenuList::selectElement() const 134 inline Result<HTMLSelectElement> RenderMenuList::selectElement() const
135 { 135 {
136 return toHTMLSelectElement(node()); 136 return toHTMLSelectElement(node());
137 } 137 }
138 138
139 void RenderMenuList::addChild(RenderObject* newChild, RenderObject* beforeChild) 139 void RenderMenuList::addChild(RenderObject* newChild, RenderObject* beforeChild)
140 { 140 {
141 createInnerBlock(); 141 createInnerBlock();
142 m_innerBlock->addChild(newChild, beforeChild); 142 m_innerBlock->addChild(newChild, beforeChild);
143 ASSERT(m_innerBlock == firstChild()); 143 ASSERT(m_innerBlock == firstChild());
144 144
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 212 }
213 213
214 if (m_popupIsVisible) 214 if (m_popupIsVisible)
215 m_popup->updateFromElement(); 215 m_popup->updateFromElement();
216 else 216 else
217 setTextFromOption(selectElement()->selectedIndex()); 217 setTextFromOption(selectElement()->selectedIndex());
218 } 218 }
219 219
220 void RenderMenuList::setTextFromOption(int optionIndex) 220 void RenderMenuList::setTextFromOption(int optionIndex)
221 { 221 {
222 HTMLSelectElement* select = selectElement(); 222 Handle<HTMLSelectElement> select = selectElement();
223 const Vector<HTMLElement*>& listItems = select->listItems(); 223 const Vector<HTMLElement*>& listItems = select->listItems();
224 int size = listItems.size(); 224 int size = listItems.size();
225 225
226 int i = select->optionToListIndex(optionIndex); 226 int i = select->optionToListIndex(optionIndex);
227 String text = emptyString(); 227 String text = emptyString();
228 if (i >= 0 && i < size) { 228 if (i >= 0 && i < size) {
229 Element* element = listItems[i]; 229 Element* element = listItems[i];
230 if (element->hasTagName(optionTag)) { 230 if (element->hasTagName(optionTag)) {
231 text = toHTMLOptionElement(element)->textIndentedToRespectGroupLabel (); 231 text = toHTMLOptionElement(element)->textIndentedToRespectGroupLabel ();
232 m_optionStyle = element->renderStyle(); 232 m_optionStyle = element->renderStyle();
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 createInnerBlock(); 332 createInnerBlock();
333 if (!m_popup) 333 if (!m_popup)
334 m_popup = document()->page()->chrome()->createPopupMenu(this); 334 m_popup = document()->page()->chrome()->createPopupMenu(this);
335 m_popupIsVisible = true; 335 m_popupIsVisible = true;
336 336
337 // Compute the top left taking transforms into account, but use 337 // Compute the top left taking transforms into account, but use
338 // the actual width of the element to size the popup. 338 // the actual width of the element to size the popup.
339 FloatPoint absTopLeft = localToAbsolute(FloatPoint(), UseTransforms); 339 FloatPoint absTopLeft = localToAbsolute(FloatPoint(), UseTransforms);
340 IntRect absBounds = absoluteBoundingBoxRectIgnoringTransforms(); 340 IntRect absBounds = absoluteBoundingBoxRectIgnoringTransforms();
341 absBounds.setLocation(roundedIntPoint(absTopLeft)); 341 absBounds.setLocation(roundedIntPoint(absTopLeft));
342 HTMLSelectElement* select = selectElement(); 342 Handle<HTMLSelectElement> select = selectElement();
343 m_popup->show(absBounds, document()->view(), select->optionToListIndex(selec t->selectedIndex())); 343 m_popup->show(absBounds, document()->view(), select->optionToListIndex(selec t->selectedIndex()));
344 } 344 }
345 345
346 void RenderMenuList::hidePopup() 346 void RenderMenuList::hidePopup()
347 { 347 {
348 if (m_popup) 348 if (m_popup)
349 m_popup->hide(); 349 m_popup->hide();
350 } 350 }
351 351
352 void RenderMenuList::valueChanged(unsigned listIndex, bool fireOnChange) 352 void RenderMenuList::valueChanged(unsigned listIndex, bool fireOnChange)
353 { 353 {
354 // Check to ensure a page navigation has not occurred while 354 // Check to ensure a page navigation has not occurred while
355 // the popup was up. 355 // the popup was up.
356 Document* doc = toElement(node())->document(); 356 Document* doc = toElement(node())->document();
357 if (!doc || doc != doc->frame()->document()) 357 if (!doc || doc != doc->frame()->document())
358 return; 358 return;
359 359
360 HTMLSelectElement* select = selectElement(); 360 Handle<HTMLSelectElement> select = selectElement();
361 select->optionSelectedByUser(select->listToOptionIndex(listIndex), fireOnCha nge); 361 select->optionSelectedByUser(select->listToOptionIndex(listIndex), fireOnCha nge);
362 } 362 }
363 363
364 void RenderMenuList::listBoxSelectItem(int listIndex, bool allowMultiplySelectio ns, bool shift, bool fireOnChangeNow) 364 void RenderMenuList::listBoxSelectItem(int listIndex, bool allowMultiplySelectio ns, bool shift, bool fireOnChangeNow)
365 { 365 {
366 selectElement()->listBoxSelectItem(listIndex, allowMultiplySelections, shift , fireOnChangeNow); 366 selectElement()->listBoxSelectItem(listIndex, allowMultiplySelections, shift , fireOnChangeNow);
367 } 367 }
368 368
369 bool RenderMenuList::multiple() const 369 bool RenderMenuList::multiple() const
370 { 370 {
371 return selectElement()->multiple(); 371 return selectElement()->multiple();
372 } 372 }
373 373
374 void RenderMenuList::didSetSelectedIndex(int listIndex) 374 void RenderMenuList::didSetSelectedIndex(int listIndex)
375 { 375 {
376 didUpdateActiveOption(selectElement()->listToOptionIndex(listIndex)); 376 didUpdateActiveOption(selectElement()->listToOptionIndex(listIndex));
377 } 377 }
378 378
379 void RenderMenuList::didUpdateActiveOption(int optionIndex) 379 void RenderMenuList::didUpdateActiveOption(int optionIndex)
380 { 380 {
381 if (!AXObjectCache::accessibilityEnabled() || !document()->existingAXObjectC ache()) 381 if (!AXObjectCache::accessibilityEnabled() || !document()->existingAXObjectC ache())
382 return; 382 return;
383 383
384 if (m_lastActiveIndex == optionIndex) 384 if (m_lastActiveIndex == optionIndex)
385 return; 385 return;
386 m_lastActiveIndex = optionIndex; 386 m_lastActiveIndex = optionIndex;
387 387
388 HTMLSelectElement* select = selectElement(); 388 Handle<HTMLSelectElement> select = selectElement();
389 int listIndex = select->optionToListIndex(optionIndex); 389 int listIndex = select->optionToListIndex(optionIndex);
390 if (listIndex < 0 || listIndex >= static_cast<int>(select->listItems().size( ))) 390 if (listIndex < 0 || listIndex >= static_cast<int>(select->listItems().size( )))
391 return; 391 return;
392 392
393 ASSERT(select->listItems()[listIndex]); 393 ASSERT(select->listItems()[listIndex]);
394 394
395 if (AccessibilityMenuList* menuList = static_cast<AccessibilityMenuList*>(do cument()->axObjectCache()->get(this))) 395 if (AccessibilityMenuList* menuList = static_cast<AccessibilityMenuList*>(do cument()->axObjectCache()->get(this)))
396 menuList->didUpdateActiveOption(optionIndex); 396 menuList->didUpdateActiveOption(optionIndex);
397 } 397 }
398 398
399 String RenderMenuList::itemText(unsigned listIndex) const 399 String RenderMenuList::itemText(unsigned listIndex) const
400 { 400 {
401 HTMLSelectElement* select = selectElement(); 401 Handle<HTMLSelectElement> select = selectElement();
402 const Vector<HTMLElement*>& listItems = select->listItems(); 402 const Vector<HTMLElement*>& listItems = select->listItems();
403 if (listIndex >= listItems.size()) 403 if (listIndex >= listItems.size())
404 return String(); 404 return String();
405 405
406 String itemString; 406 String itemString;
407 Element* element = listItems[listIndex]; 407 Element* element = listItems[listIndex];
408 if (element->hasTagName(optgroupTag)) 408 if (element->hasTagName(optgroupTag))
409 itemString = static_cast<const HTMLOptGroupElement*>(element)->groupLabe lText(); 409 itemString = static_cast<const HTMLOptGroupElement*>(element)->groupLabe lText();
410 else if (element->hasTagName(optionTag)) 410 else if (element->hasTagName(optionTag))
411 itemString = toHTMLOptionElement(element)->textIndentedToRespectGroupLab el(); 411 itemString = toHTMLOptionElement(element)->textIndentedToRespectGroupLab el();
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 return paddingRight() + m_innerBlock->paddingRight(); 571 return paddingRight() + m_innerBlock->paddingRight();
572 } 572 }
573 573
574 int RenderMenuList::listSize() const 574 int RenderMenuList::listSize() const
575 { 575 {
576 return selectElement()->listItems().size(); 576 return selectElement()->listItems().size();
577 } 577 }
578 578
579 int RenderMenuList::selectedIndex() const 579 int RenderMenuList::selectedIndex() const
580 { 580 {
581 HTMLSelectElement* select = selectElement(); 581 Handle<HTMLSelectElement> select = selectElement();
582 return select->optionToListIndex(select->selectedIndex()); 582 return select->optionToListIndex(select->selectedIndex());
583 } 583 }
584 584
585 void RenderMenuList::popupDidHide() 585 void RenderMenuList::popupDidHide()
586 { 586 {
587 m_popupIsVisible = false; 587 m_popupIsVisible = false;
588 } 588 }
589 589
590 bool RenderMenuList::itemIsSeparator(unsigned listIndex) const 590 bool RenderMenuList::itemIsSeparator(unsigned listIndex) const
591 { 591 {
(...skipping 20 matching lines...) Expand all
612 { 612 {
613 setTextFromOption(selectElement()->listToOptionIndex(listIndex)); 613 setTextFromOption(selectElement()->listToOptionIndex(listIndex));
614 } 614 }
615 615
616 Result<FontSelector> RenderMenuList::fontSelector() const 616 Result<FontSelector> RenderMenuList::fontSelector() const
617 { 617 {
618 return document()->styleResolver()->fontSelector(); 618 return document()->styleResolver()->fontSelector();
619 } 619 }
620 620
621 } 621 }
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderMenuList.h ('k') | Source/core/rendering/RenderSearchField.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698