OLD | NEW |
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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 | 392 |
393 String RenderMenuList::itemText(unsigned listIndex) const | 393 String RenderMenuList::itemText(unsigned listIndex) const |
394 { | 394 { |
395 HTMLSelectElement* select = selectElement(); | 395 HTMLSelectElement* select = selectElement(); |
396 const Vector<HTMLElement*>& listItems = select->listItems(); | 396 const Vector<HTMLElement*>& listItems = select->listItems(); |
397 if (listIndex >= listItems.size()) | 397 if (listIndex >= listItems.size()) |
398 return String(); | 398 return String(); |
399 | 399 |
400 String itemString; | 400 String itemString; |
401 Element* element = listItems[listIndex]; | 401 Element* element = listItems[listIndex]; |
402 if (element->hasTagName(optgroupTag)) | 402 if (isHTMLOptGroupElement(element)) |
403 itemString = static_cast<const HTMLOptGroupElement*>(element)->groupLabe
lText(); | 403 itemString = toHTMLOptGroupElement(element)->groupLabelText(); |
404 else if (element->hasTagName(optionTag)) | 404 else if (element->hasTagName(optionTag)) |
405 itemString = toHTMLOptionElement(element)->textIndentedToRespectGroupLab
el(); | 405 itemString = toHTMLOptionElement(element)->textIndentedToRespectGroupLab
el(); |
406 | 406 |
407 applyTextTransform(style(), itemString, ' '); | 407 applyTextTransform(style(), itemString, ' '); |
408 return itemString; | 408 return itemString; |
409 } | 409 } |
410 | 410 |
411 String RenderMenuList::itemLabel(unsigned) const | 411 String RenderMenuList::itemLabel(unsigned) const |
412 { | 412 { |
413 return String(); | 413 return String(); |
(...skipping 25 matching lines...) Expand all Loading... |
439 { | 439 { |
440 const Vector<HTMLElement*>& listItems = selectElement()->listItems(); | 440 const Vector<HTMLElement*>& listItems = selectElement()->listItems(); |
441 if (listIndex >= listItems.size()) | 441 if (listIndex >= listItems.size()) |
442 return false; | 442 return false; |
443 HTMLElement* element = listItems[listIndex]; | 443 HTMLElement* element = listItems[listIndex]; |
444 if (!element->hasTagName(optionTag)) | 444 if (!element->hasTagName(optionTag)) |
445 return false; | 445 return false; |
446 | 446 |
447 bool groupEnabled = true; | 447 bool groupEnabled = true; |
448 if (Element* parentElement = element->parentElement()) { | 448 if (Element* parentElement = element->parentElement()) { |
449 if (parentElement->hasTagName(optgroupTag)) | 449 if (isHTMLOptGroupElement(parentElement)) |
450 groupEnabled = !parentElement->isDisabledFormControl(); | 450 groupEnabled = !parentElement->isDisabledFormControl(); |
451 } | 451 } |
452 if (!groupEnabled) | 452 if (!groupEnabled) |
453 return false; | 453 return false; |
454 | 454 |
455 return !element->isDisabledFormControl(); | 455 return !element->isDisabledFormControl(); |
456 } | 456 } |
457 | 457 |
458 PopupMenuStyle RenderMenuList::itemStyle(unsigned listIndex) const | 458 PopupMenuStyle RenderMenuList::itemStyle(unsigned listIndex) const |
459 { | 459 { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 | 583 |
584 bool RenderMenuList::itemIsSeparator(unsigned listIndex) const | 584 bool RenderMenuList::itemIsSeparator(unsigned listIndex) const |
585 { | 585 { |
586 const Vector<HTMLElement*>& listItems = selectElement()->listItems(); | 586 const Vector<HTMLElement*>& listItems = selectElement()->listItems(); |
587 return listIndex < listItems.size() && listItems[listIndex]->hasTagName(hrTa
g); | 587 return listIndex < listItems.size() && listItems[listIndex]->hasTagName(hrTa
g); |
588 } | 588 } |
589 | 589 |
590 bool RenderMenuList::itemIsLabel(unsigned listIndex) const | 590 bool RenderMenuList::itemIsLabel(unsigned listIndex) const |
591 { | 591 { |
592 const Vector<HTMLElement*>& listItems = selectElement()->listItems(); | 592 const Vector<HTMLElement*>& listItems = selectElement()->listItems(); |
593 return listIndex < listItems.size() && listItems[listIndex]->hasTagName(optg
roupTag); | 593 return listIndex < listItems.size() && isHTMLOptGroupElement(listItems[listI
ndex]); |
594 } | 594 } |
595 | 595 |
596 bool RenderMenuList::itemIsSelected(unsigned listIndex) const | 596 bool RenderMenuList::itemIsSelected(unsigned listIndex) const |
597 { | 597 { |
598 const Vector<HTMLElement*>& listItems = selectElement()->listItems(); | 598 const Vector<HTMLElement*>& listItems = selectElement()->listItems(); |
599 if (listIndex >= listItems.size()) | 599 if (listIndex >= listItems.size()) |
600 return false; | 600 return false; |
601 HTMLElement* element = listItems[listIndex]; | 601 HTMLElement* element = listItems[listIndex]; |
602 return element->hasTagName(optionTag) && toHTMLOptionElement(element)->selec
ted(); | 602 return element->hasTagName(optionTag) && toHTMLOptionElement(element)->selec
ted(); |
603 } | 603 } |
604 | 604 |
605 void RenderMenuList::setTextFromItem(unsigned listIndex) | 605 void RenderMenuList::setTextFromItem(unsigned listIndex) |
606 { | 606 { |
607 setTextFromOption(selectElement()->listToOptionIndex(listIndex)); | 607 setTextFromOption(selectElement()->listToOptionIndex(listIndex)); |
608 } | 608 } |
609 | 609 |
610 FontSelector* RenderMenuList::fontSelector() const | 610 FontSelector* RenderMenuList::fontSelector() const |
611 { | 611 { |
612 return document()->styleResolver()->fontSelector(); | 612 return document()->styleResolver()->fontSelector(); |
613 } | 613 } |
614 | 614 |
615 } | 615 } |
OLD | NEW |