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 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 HTMLElement* element = items[i]; | 640 HTMLElement* element = items[i]; |
641 m_cachedStateForActiveSelection.append(isHTMLOptionElement(*element) &&
toHTMLOptionElement(element)->selected()); | 641 m_cachedStateForActiveSelection.append(isHTMLOptionElement(*element) &&
toHTMLOptionElement(element)->selected()); |
642 } | 642 } |
643 } | 643 } |
644 | 644 |
645 void HTMLSelectElement::setActiveSelectionEndIndex(int index) | 645 void HTMLSelectElement::setActiveSelectionEndIndex(int index) |
646 { | 646 { |
647 if (index == m_activeSelectionEndIndex) | 647 if (index == m_activeSelectionEndIndex) |
648 return; | 648 return; |
649 m_activeSelectionEndIndex = index; | 649 m_activeSelectionEndIndex = index; |
650 setNeedsStyleRecalc(SubtreeStyleChange); | 650 setNeedsStyleRecalc(StyleRecalcDueToControl, SubtreeStyleChange); |
651 } | 651 } |
652 | 652 |
653 void HTMLSelectElement::updateListBoxSelection(bool deselectOtherOptions) | 653 void HTMLSelectElement::updateListBoxSelection(bool deselectOtherOptions) |
654 { | 654 { |
655 ASSERT(renderer() && (renderer()->isListBox() || m_multiple)); | 655 ASSERT(renderer() && (renderer()->isListBox() || m_multiple)); |
656 ASSERT(!listItems().size() || m_activeSelectionAnchorIndex >= 0); | 656 ASSERT(!listItems().size() || m_activeSelectionAnchorIndex >= 0); |
657 | 657 |
658 unsigned start = std::min(m_activeSelectionAnchorIndex, m_activeSelectionEnd
Index); | 658 unsigned start = std::min(m_activeSelectionAnchorIndex, m_activeSelectionEnd
Index); |
659 unsigned end = std::max(m_activeSelectionAnchorIndex, m_activeSelectionEndIn
dex); | 659 unsigned end = std::max(m_activeSelectionAnchorIndex, m_activeSelectionEndIn
dex); |
660 | 660 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 | 764 |
765 void HTMLSelectElement::setRecalcListItems() | 765 void HTMLSelectElement::setRecalcListItems() |
766 { | 766 { |
767 // FIXME: This function does a bunch of confusing things depending on if it | 767 // FIXME: This function does a bunch of confusing things depending on if it |
768 // is in the document or not. | 768 // is in the document or not. |
769 | 769 |
770 m_shouldRecalcListItems = true; | 770 m_shouldRecalcListItems = true; |
771 // Manual selection anchor is reset when manipulating the select programmati
cally. | 771 // Manual selection anchor is reset when manipulating the select programmati
cally. |
772 m_activeSelectionAnchorIndex = -1; | 772 m_activeSelectionAnchorIndex = -1; |
773 setOptionsChangedOnRenderer(); | 773 setOptionsChangedOnRenderer(); |
774 setNeedsStyleRecalc(SubtreeStyleChange); | 774 setNeedsStyleRecalc(StyleRecalcDueToControlValue, SubtreeStyleChange); |
775 if (!inDocument()) { | 775 if (!inDocument()) { |
776 if (HTMLOptionsCollection* collection = cachedCollection<HTMLOptionsColl
ection>(SelectOptions)) | 776 if (HTMLOptionsCollection* collection = cachedCollection<HTMLOptionsColl
ection>(SelectOptions)) |
777 collection->invalidateCache(); | 777 collection->invalidateCache(); |
778 } | 778 } |
779 if (!inDocument()) | 779 if (!inDocument()) |
780 invalidateSelectedItems(); | 780 invalidateSelectedItems(); |
781 | 781 |
782 if (renderer()) { | 782 if (renderer()) { |
783 if (AXObjectCache* cache = renderer()->document().existingAXObjectCache(
)) | 783 if (AXObjectCache* cache = renderer()->document().existingAXObjectCache(
)) |
784 cache->childrenChanged(this); | 784 cache->childrenChanged(this); |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 toHTMLOptionElement(element)->setSelectedState(false); | 1146 toHTMLOptionElement(element)->setSelectedState(false); |
1147 | 1147 |
1148 if (!firstOption) | 1148 if (!firstOption) |
1149 firstOption = toHTMLOptionElement(element); | 1149 firstOption = toHTMLOptionElement(element); |
1150 } | 1150 } |
1151 | 1151 |
1152 if (!selectedOption && firstOption && !m_multiple && m_size <= 1) | 1152 if (!selectedOption && firstOption && !m_multiple && m_size <= 1) |
1153 firstOption->setSelectedState(true); | 1153 firstOption->setSelectedState(true); |
1154 | 1154 |
1155 setOptionsChangedOnRenderer(); | 1155 setOptionsChangedOnRenderer(); |
1156 setNeedsStyleRecalc(SubtreeStyleChange); | 1156 setNeedsStyleRecalc(StyleRecalcDueToControlValue, SubtreeStyleChange); |
1157 setNeedsValidityCheck(); | 1157 setNeedsValidityCheck(); |
1158 } | 1158 } |
1159 | 1159 |
1160 void HTMLSelectElement::handlePopupOpenKeyboardEvent(Event* event) | 1160 void HTMLSelectElement::handlePopupOpenKeyboardEvent(Event* event) |
1161 { | 1161 { |
1162 focus(); | 1162 focus(); |
1163 // Calling focus() may cause us to lose our renderer. Return true so | 1163 // Calling focus() may cause us to lose our renderer. Return true so |
1164 // that our caller doesn't process the event further, but don't set | 1164 // that our caller doesn't process the event further, but don't set |
1165 // the event as handled. | 1165 // the event as handled. |
1166 if (!renderer() || !renderer()->isMenuList() || isDisabledFormControl()) | 1166 if (!renderer() || !renderer()->isMenuList() || isDisabledFormControl()) |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1740 int focusedIndex = activeSelectionEndListIndex(); | 1740 int focusedIndex = activeSelectionEndListIndex(); |
1741 if (focusedIndex < 0) | 1741 if (focusedIndex < 0) |
1742 focusedIndex = firstSelectableListIndex(); | 1742 focusedIndex = firstSelectableListIndex(); |
1743 if (focusedIndex < 0) | 1743 if (focusedIndex < 0) |
1744 return nullptr; | 1744 return nullptr; |
1745 HTMLElement* focused = listItems()[focusedIndex]; | 1745 HTMLElement* focused = listItems()[focusedIndex]; |
1746 return isHTMLOptionElement(focused) ? toHTMLOptionElement(focused) : nullptr
; | 1746 return isHTMLOptionElement(focused) ? toHTMLOptionElement(focused) : nullptr
; |
1747 } | 1747 } |
1748 | 1748 |
1749 } // namespace | 1749 } // namespace |
OLD | NEW |