| 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 17 matching lines...) Expand all Loading... |
| 28 #include "config.h" | 28 #include "config.h" |
| 29 #include "core/html/HTMLSelectElement.h" | 29 #include "core/html/HTMLSelectElement.h" |
| 30 | 30 |
| 31 #include "bindings/core/v8/ExceptionMessages.h" | 31 #include "bindings/core/v8/ExceptionMessages.h" |
| 32 #include "bindings/core/v8/ExceptionState.h" | 32 #include "bindings/core/v8/ExceptionState.h" |
| 33 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 33 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 34 #include "core/HTMLNames.h" | 34 #include "core/HTMLNames.h" |
| 35 #include "core/accessibility/AXObjectCache.h" | 35 #include "core/accessibility/AXObjectCache.h" |
| 36 #include "core/dom/Attribute.h" | 36 #include "core/dom/Attribute.h" |
| 37 #include "core/dom/ElementTraversal.h" | 37 #include "core/dom/ElementTraversal.h" |
| 38 #include "core/dom/NodeListsNodeData.h" |
| 38 #include "core/dom/NodeTraversal.h" | 39 #include "core/dom/NodeTraversal.h" |
| 39 #include "core/events/GestureEvent.h" | 40 #include "core/events/GestureEvent.h" |
| 40 #include "core/events/KeyboardEvent.h" | 41 #include "core/events/KeyboardEvent.h" |
| 41 #include "core/events/MouseEvent.h" | 42 #include "core/events/MouseEvent.h" |
| 42 #include "core/frame/FrameView.h" | 43 #include "core/frame/FrameView.h" |
| 43 #include "core/frame/LocalFrame.h" | 44 #include "core/frame/LocalFrame.h" |
| 44 #include "core/html/FormDataList.h" | 45 #include "core/html/FormDataList.h" |
| 45 #include "core/html/HTMLFormElement.h" | 46 #include "core/html/HTMLFormElement.h" |
| 46 #include "core/html/HTMLOptGroupElement.h" | 47 #include "core/html/HTMLOptGroupElement.h" |
| 47 #include "core/html/HTMLOptionElement.h" | 48 #include "core/html/HTMLOptionElement.h" |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 RenderObject* HTMLSelectElement::createRenderer(RenderStyle*) | 381 RenderObject* HTMLSelectElement::createRenderer(RenderStyle*) |
| 381 { | 382 { |
| 382 if (usesMenuList()) | 383 if (usesMenuList()) |
| 383 return new RenderMenuList(this); | 384 return new RenderMenuList(this); |
| 384 return new RenderListBox(this); | 385 return new RenderListBox(this); |
| 385 } | 386 } |
| 386 | 387 |
| 387 PassRefPtrWillBeRawPtr<HTMLCollection> HTMLSelectElement::selectedOptions() | 388 PassRefPtrWillBeRawPtr<HTMLCollection> HTMLSelectElement::selectedOptions() |
| 388 { | 389 { |
| 389 updateListItemSelectedStates(); | 390 updateListItemSelectedStates(); |
| 390 return ensureCachedHTMLCollection(SelectedOptions); | 391 return ensureCachedCollection<HTMLCollection>(SelectedOptions); |
| 391 } | 392 } |
| 392 | 393 |
| 393 PassRefPtrWillBeRawPtr<HTMLOptionsCollection> HTMLSelectElement::options() | 394 PassRefPtrWillBeRawPtr<HTMLOptionsCollection> HTMLSelectElement::options() |
| 394 { | 395 { |
| 395 return toHTMLOptionsCollection(ensureCachedHTMLCollection(SelectOptions).get
()); | 396 return ensureCachedCollection<HTMLOptionsCollection>(SelectOptions); |
| 396 } | 397 } |
| 397 | 398 |
| 398 void HTMLSelectElement::updateListItemSelectedStates() | 399 void HTMLSelectElement::updateListItemSelectedStates() |
| 399 { | 400 { |
| 400 if (!m_shouldRecalcListItems) | 401 if (!m_shouldRecalcListItems) |
| 401 return; | 402 return; |
| 402 recalcListItems(); | 403 recalcListItems(); |
| 403 setNeedsValidityCheck(); | 404 setNeedsValidityCheck(); |
| 404 } | 405 } |
| 405 | 406 |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 recalcListItems(false); | 749 recalcListItems(false); |
| 749 ASSERT(items == m_listItems); | 750 ASSERT(items == m_listItems); |
| 750 #endif | 751 #endif |
| 751 } | 752 } |
| 752 | 753 |
| 753 return m_listItems; | 754 return m_listItems; |
| 754 } | 755 } |
| 755 | 756 |
| 756 void HTMLSelectElement::invalidateSelectedItems() | 757 void HTMLSelectElement::invalidateSelectedItems() |
| 757 { | 758 { |
| 758 if (HTMLCollection* collection = cachedHTMLCollection(SelectedOptions)) | 759 if (HTMLCollection* collection = cachedCollection<HTMLCollection>(SelectedOp
tions)) |
| 759 collection->invalidateCache(); | 760 collection->invalidateCache(); |
| 760 } | 761 } |
| 761 | 762 |
| 762 void HTMLSelectElement::setRecalcListItems() | 763 void HTMLSelectElement::setRecalcListItems() |
| 763 { | 764 { |
| 764 // FIXME: This function does a bunch of confusing things depending on if it | 765 // FIXME: This function does a bunch of confusing things depending on if it |
| 765 // is in the document or not. | 766 // is in the document or not. |
| 766 | 767 |
| 767 m_shouldRecalcListItems = true; | 768 m_shouldRecalcListItems = true; |
| 768 // Manual selection anchor is reset when manipulating the select programmati
cally. | 769 // Manual selection anchor is reset when manipulating the select programmati
cally. |
| 769 m_activeSelectionAnchorIndex = -1; | 770 m_activeSelectionAnchorIndex = -1; |
| 770 setOptionsChangedOnRenderer(); | 771 setOptionsChangedOnRenderer(); |
| 771 setNeedsStyleRecalc(SubtreeStyleChange); | 772 setNeedsStyleRecalc(SubtreeStyleChange); |
| 772 if (!inDocument()) { | 773 if (!inDocument()) { |
| 773 if (HTMLCollection* collection = cachedHTMLCollection(SelectOptions)) | 774 if (HTMLOptionsCollection* collection = cachedCollection<HTMLOptionsColl
ection>(SelectOptions)) |
| 774 collection->invalidateCache(); | 775 collection->invalidateCache(); |
| 775 } | 776 } |
| 776 if (!inDocument()) | 777 if (!inDocument()) |
| 777 invalidateSelectedItems(); | 778 invalidateSelectedItems(); |
| 778 | 779 |
| 779 if (renderer()) { | 780 if (renderer()) { |
| 780 if (AXObjectCache* cache = renderer()->document().existingAXObjectCache(
)) | 781 if (AXObjectCache* cache = renderer()->document().existingAXObjectCache(
)) |
| 781 cache->childrenChanged(this); | 782 cache->childrenChanged(this); |
| 782 } | 783 } |
| 783 } | 784 } |
| (...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1735 int focusedIndex = activeSelectionEndListIndex(); | 1736 int focusedIndex = activeSelectionEndListIndex(); |
| 1736 if (focusedIndex < 0) | 1737 if (focusedIndex < 0) |
| 1737 focusedIndex = firstSelectableListIndex(); | 1738 focusedIndex = firstSelectableListIndex(); |
| 1738 if (focusedIndex < 0) | 1739 if (focusedIndex < 0) |
| 1739 return nullptr; | 1740 return nullptr; |
| 1740 HTMLElement* focused = listItems()[focusedIndex]; | 1741 HTMLElement* focused = listItems()[focusedIndex]; |
| 1741 return isHTMLOptionElement(focused) ? toHTMLOptionElement(focused) : nullptr
; | 1742 return isHTMLOptionElement(focused) ? toHTMLOptionElement(focused) : nullptr
; |
| 1742 } | 1743 } |
| 1743 | 1744 |
| 1744 } // namespace | 1745 } // namespace |
| OLD | NEW |