| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
| 3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 4 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 4 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights
reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights
reserved. |
| 7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
| 8 * Copyright (C) 2010 Google Inc. All rights reserved. | 8 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 10 * | 10 * |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 dispatchFormControlChangeEvent(); | 729 dispatchFormControlChangeEvent(); |
| 730 } | 730 } |
| 731 } | 731 } |
| 732 | 732 |
| 733 void HTMLSelectElement::scrollToSelection() | 733 void HTMLSelectElement::scrollToSelection() |
| 734 { | 734 { |
| 735 if (!isFinishedParsingChildren()) | 735 if (!isFinishedParsingChildren()) |
| 736 return; | 736 return; |
| 737 if (usesMenuList()) | 737 if (usesMenuList()) |
| 738 return; | 738 return; |
| 739 scrollTo(activeSelectionEndListIndex()); | 739 scrollToIndex(activeSelectionEndListIndex()); |
| 740 if (AXObjectCache* cache = document().existingAXObjectCache()) | 740 if (AXObjectCache* cache = document().existingAXObjectCache()) |
| 741 cache->selectedChildrenChanged(this); | 741 cache->selectedChildrenChanged(this); |
| 742 } | 742 } |
| 743 | 743 |
| 744 void HTMLSelectElement::setOptionsChangedOnRenderer() | 744 void HTMLSelectElement::setOptionsChangedOnRenderer() |
| 745 { | 745 { |
| 746 if (RenderObject* renderer = this->renderer()) { | 746 if (RenderObject* renderer = this->renderer()) { |
| 747 if (usesMenuList()) | 747 if (usesMenuList()) |
| 748 toRenderMenuList(renderer)->setOptionsChanged(true); | 748 toRenderMenuList(renderer)->setOptionsChanged(true); |
| 749 } | 749 } |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 { | 880 { |
| 881 return m_suggestedIndex; | 881 return m_suggestedIndex; |
| 882 } | 882 } |
| 883 | 883 |
| 884 void HTMLSelectElement::setSuggestedIndex(int suggestedIndex) | 884 void HTMLSelectElement::setSuggestedIndex(int suggestedIndex) |
| 885 { | 885 { |
| 886 m_suggestedIndex = suggestedIndex; | 886 m_suggestedIndex = suggestedIndex; |
| 887 | 887 |
| 888 if (RenderObject* renderer = this->renderer()) { | 888 if (RenderObject* renderer = this->renderer()) { |
| 889 renderer->updateFromElement(); | 889 renderer->updateFromElement(); |
| 890 scrollTo(suggestedIndex); | 890 scrollToIndex(suggestedIndex); |
| 891 } | 891 } |
| 892 } | 892 } |
| 893 | 893 |
| 894 void HTMLSelectElement::scrollTo(int listIndex) | 894 void HTMLSelectElement::scrollToIndex(int listIndex) |
| 895 { | 895 { |
| 896 if (listIndex < 0) | 896 if (listIndex < 0) |
| 897 return; | 897 return; |
| 898 if (usesMenuList()) | 898 if (usesMenuList()) |
| 899 return; | 899 return; |
| 900 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems()
; | 900 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems()
; |
| 901 int listSize = static_cast<int>(items.size()); | 901 int listSize = static_cast<int>(items.size()); |
| 902 if (listIndex >= listSize) | 902 if (listIndex >= listSize) |
| 903 return; | 903 return; |
| 904 document().updateLayoutIgnorePendingStylesheets(); | 904 document().updateLayoutIgnorePendingStylesheets(); |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 m_activeSelectionState = true; | 1565 m_activeSelectionState = true; |
| 1566 // If the anchor is unitialized, or if we're going to deselect all | 1566 // If the anchor is unitialized, or if we're going to deselect all |
| 1567 // other options, then set the anchor index equal to the end index. | 1567 // other options, then set the anchor index equal to the end index. |
| 1568 bool deselectOthers = !m_multiple || (!toKeyboardEvent(event)->shift
Key() && selectNewItem); | 1568 bool deselectOthers = !m_multiple || (!toKeyboardEvent(event)->shift
Key() && selectNewItem); |
| 1569 if (m_activeSelectionAnchorIndex < 0 || deselectOthers) { | 1569 if (m_activeSelectionAnchorIndex < 0 || deselectOthers) { |
| 1570 if (deselectOthers) | 1570 if (deselectOthers) |
| 1571 deselectItemsWithoutValidation(); | 1571 deselectItemsWithoutValidation(); |
| 1572 setActiveSelectionAnchorIndex(m_activeSelectionEndIndex); | 1572 setActiveSelectionAnchorIndex(m_activeSelectionEndIndex); |
| 1573 } | 1573 } |
| 1574 | 1574 |
| 1575 scrollTo(endIndex); | 1575 scrollToIndex(endIndex); |
| 1576 if (selectNewItem) { | 1576 if (selectNewItem) { |
| 1577 updateListBoxSelection(deselectOthers); | 1577 updateListBoxSelection(deselectOthers); |
| 1578 listBoxOnChange(); | 1578 listBoxOnChange(); |
| 1579 } else | 1579 } else |
| 1580 scrollToSelection(); | 1580 scrollToSelection(); |
| 1581 | 1581 |
| 1582 event->setDefaultHandled(); | 1582 event->setDefaultHandled(); |
| 1583 } | 1583 } |
| 1584 } else if (event->type() == EventTypeNames::keypress) { | 1584 } else if (event->type() == EventTypeNames::keypress) { |
| 1585 if (!event->isKeyboardEvent()) | 1585 if (!event->isKeyboardEvent()) |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1774 int focusedIndex = activeSelectionEndListIndex(); | 1774 int focusedIndex = activeSelectionEndListIndex(); |
| 1775 if (focusedIndex < 0) | 1775 if (focusedIndex < 0) |
| 1776 focusedIndex = firstSelectableListIndex(); | 1776 focusedIndex = firstSelectableListIndex(); |
| 1777 if (focusedIndex < 0) | 1777 if (focusedIndex < 0) |
| 1778 return nullptr; | 1778 return nullptr; |
| 1779 HTMLElement* focused = listItems()[focusedIndex]; | 1779 HTMLElement* focused = listItems()[focusedIndex]; |
| 1780 return isHTMLOptionElement(focused) ? toHTMLOptionElement(focused) : nullptr
; | 1780 return isHTMLOptionElement(focused) ? toHTMLOptionElement(focused) : nullptr
; |
| 1781 } | 1781 } |
| 1782 | 1782 |
| 1783 } // namespace | 1783 } // namespace |
| OLD | NEW |