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 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 HTMLElement* element = items[i]; | 639 HTMLElement* element = items[i]; |
640 m_cachedStateForActiveSelection.append(isHTMLOptionElement(*element) &&
toHTMLOptionElement(element)->selected()); | 640 m_cachedStateForActiveSelection.append(isHTMLOptionElement(*element) &&
toHTMLOptionElement(element)->selected()); |
641 } | 641 } |
642 } | 642 } |
643 | 643 |
644 void HTMLSelectElement::setActiveSelectionEndIndex(int index) | 644 void HTMLSelectElement::setActiveSelectionEndIndex(int index) |
645 { | 645 { |
646 if (index == m_activeSelectionEndIndex) | 646 if (index == m_activeSelectionEndIndex) |
647 return; | 647 return; |
648 m_activeSelectionEndIndex = index; | 648 m_activeSelectionEndIndex = index; |
649 setNeedsStyleRecalc(SubtreeStyleChange); | 649 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(
StyleChangeReason::Control)); |
650 } | 650 } |
651 | 651 |
652 void HTMLSelectElement::updateListBoxSelection(bool deselectOtherOptions) | 652 void HTMLSelectElement::updateListBoxSelection(bool deselectOtherOptions) |
653 { | 653 { |
654 ASSERT(renderer() && (renderer()->isListBox() || m_multiple)); | 654 ASSERT(renderer() && (renderer()->isListBox() || m_multiple)); |
655 ASSERT(!listItems().size() || m_activeSelectionAnchorIndex >= 0); | 655 ASSERT(!listItems().size() || m_activeSelectionAnchorIndex >= 0); |
656 | 656 |
657 unsigned start = std::min(m_activeSelectionAnchorIndex, m_activeSelectionEnd
Index); | 657 unsigned start = std::min(m_activeSelectionAnchorIndex, m_activeSelectionEnd
Index); |
658 unsigned end = std::max(m_activeSelectionAnchorIndex, m_activeSelectionEndIn
dex); | 658 unsigned end = std::max(m_activeSelectionAnchorIndex, m_activeSelectionEndIn
dex); |
659 | 659 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 | 763 |
764 void HTMLSelectElement::setRecalcListItems() | 764 void HTMLSelectElement::setRecalcListItems() |
765 { | 765 { |
766 // FIXME: This function does a bunch of confusing things depending on if it | 766 // FIXME: This function does a bunch of confusing things depending on if it |
767 // is in the document or not. | 767 // is in the document or not. |
768 | 768 |
769 m_shouldRecalcListItems = true; | 769 m_shouldRecalcListItems = true; |
770 // Manual selection anchor is reset when manipulating the select programmati
cally. | 770 // Manual selection anchor is reset when manipulating the select programmati
cally. |
771 m_activeSelectionAnchorIndex = -1; | 771 m_activeSelectionAnchorIndex = -1; |
772 setOptionsChangedOnRenderer(); | 772 setOptionsChangedOnRenderer(); |
773 setNeedsStyleRecalc(SubtreeStyleChange); | 773 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(
StyleChangeReason::ControlValue)); |
774 if (!inDocument()) { | 774 if (!inDocument()) { |
775 if (HTMLOptionsCollection* collection = cachedCollection<HTMLOptionsColl
ection>(SelectOptions)) | 775 if (HTMLOptionsCollection* collection = cachedCollection<HTMLOptionsColl
ection>(SelectOptions)) |
776 collection->invalidateCache(); | 776 collection->invalidateCache(); |
777 } | 777 } |
778 if (!inDocument()) | 778 if (!inDocument()) |
779 invalidateSelectedItems(); | 779 invalidateSelectedItems(); |
780 | 780 |
781 if (renderer()) { | 781 if (renderer()) { |
782 if (AXObjectCache* cache = renderer()->document().existingAXObjectCache(
)) | 782 if (AXObjectCache* cache = renderer()->document().existingAXObjectCache(
)) |
783 cache->childrenChanged(this); | 783 cache->childrenChanged(this); |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1161 toHTMLOptionElement(element)->setSelectedState(false); | 1161 toHTMLOptionElement(element)->setSelectedState(false); |
1162 | 1162 |
1163 if (!firstOption) | 1163 if (!firstOption) |
1164 firstOption = toHTMLOptionElement(element); | 1164 firstOption = toHTMLOptionElement(element); |
1165 } | 1165 } |
1166 | 1166 |
1167 if (!selectedOption && firstOption && !m_multiple && m_size <= 1) | 1167 if (!selectedOption && firstOption && !m_multiple && m_size <= 1) |
1168 firstOption->setSelectedState(true); | 1168 firstOption->setSelectedState(true); |
1169 | 1169 |
1170 setOptionsChangedOnRenderer(); | 1170 setOptionsChangedOnRenderer(); |
1171 setNeedsStyleRecalc(SubtreeStyleChange); | 1171 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(
StyleChangeReason::ControlValue)); |
1172 setNeedsValidityCheck(); | 1172 setNeedsValidityCheck(); |
1173 } | 1173 } |
1174 | 1174 |
1175 void HTMLSelectElement::handlePopupOpenKeyboardEvent(Event* event) | 1175 void HTMLSelectElement::handlePopupOpenKeyboardEvent(Event* event) |
1176 { | 1176 { |
1177 focus(); | 1177 focus(); |
1178 // Calling focus() may cause us to lose our renderer. Return true so | 1178 // Calling focus() may cause us to lose our renderer. Return true so |
1179 // that our caller doesn't process the event further, but don't set | 1179 // that our caller doesn't process the event further, but don't set |
1180 // the event as handled. | 1180 // the event as handled. |
1181 if (!renderer() || !renderer()->isMenuList() || isDisabledFormControl()) | 1181 if (!renderer() || !renderer()->isMenuList() || isDisabledFormControl()) |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1755 int focusedIndex = activeSelectionEndListIndex(); | 1755 int focusedIndex = activeSelectionEndListIndex(); |
1756 if (focusedIndex < 0) | 1756 if (focusedIndex < 0) |
1757 focusedIndex = firstSelectableListIndex(); | 1757 focusedIndex = firstSelectableListIndex(); |
1758 if (focusedIndex < 0) | 1758 if (focusedIndex < 0) |
1759 return nullptr; | 1759 return nullptr; |
1760 HTMLElement* focused = listItems()[focusedIndex]; | 1760 HTMLElement* focused = listItems()[focusedIndex]; |
1761 return isHTMLOptionElement(focused) ? toHTMLOptionElement(focused) : nullptr
; | 1761 return isHTMLOptionElement(focused) ? toHTMLOptionElement(focused) : nullptr
; |
1762 } | 1762 } |
1763 | 1763 |
1764 } // namespace | 1764 } // namespace |
OLD | NEW |