Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Side by Side Diff: Source/core/html/HTMLSelectElement.cpp

Issue 342283005: Make collection caching code more consistent (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix nits Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLMapElement.cpp ('k') | Source/core/html/HTMLTableElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 RenderObject* HTMLSelectElement::createRenderer(RenderStyle*) 380 RenderObject* HTMLSelectElement::createRenderer(RenderStyle*)
380 { 381 {
381 if (usesMenuList()) 382 if (usesMenuList())
382 return new RenderMenuList(this); 383 return new RenderMenuList(this);
383 return new RenderListBox(this); 384 return new RenderListBox(this);
384 } 385 }
385 386
386 PassRefPtrWillBeRawPtr<HTMLCollection> HTMLSelectElement::selectedOptions() 387 PassRefPtrWillBeRawPtr<HTMLCollection> HTMLSelectElement::selectedOptions()
387 { 388 {
388 updateListItemSelectedStates(); 389 updateListItemSelectedStates();
389 return ensureCachedHTMLCollection(SelectedOptions); 390 return ensureCachedCollection<HTMLCollection>(SelectedOptions);
390 } 391 }
391 392
392 PassRefPtrWillBeRawPtr<HTMLOptionsCollection> HTMLSelectElement::options() 393 PassRefPtrWillBeRawPtr<HTMLOptionsCollection> HTMLSelectElement::options()
393 { 394 {
394 return toHTMLOptionsCollection(ensureCachedHTMLCollection(SelectOptions).get ()); 395 return ensureCachedCollection<HTMLOptionsCollection>(SelectOptions);
395 } 396 }
396 397
397 void HTMLSelectElement::updateListItemSelectedStates() 398 void HTMLSelectElement::updateListItemSelectedStates()
398 { 399 {
399 if (!m_shouldRecalcListItems) 400 if (!m_shouldRecalcListItems)
400 return; 401 return;
401 recalcListItems(); 402 recalcListItems();
402 setNeedsValidityCheck(); 403 setNeedsValidityCheck();
403 } 404 }
404 405
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 recalcListItems(false); 748 recalcListItems(false);
748 ASSERT(items == m_listItems); 749 ASSERT(items == m_listItems);
749 #endif 750 #endif
750 } 751 }
751 752
752 return m_listItems; 753 return m_listItems;
753 } 754 }
754 755
755 void HTMLSelectElement::invalidateSelectedItems() 756 void HTMLSelectElement::invalidateSelectedItems()
756 { 757 {
757 if (HTMLCollection* collection = cachedHTMLCollection(SelectedOptions)) 758 if (HTMLCollection* collection = cachedCollection<HTMLCollection>(SelectedOp tions))
758 collection->invalidateCache(); 759 collection->invalidateCache();
759 } 760 }
760 761
761 void HTMLSelectElement::setRecalcListItems() 762 void HTMLSelectElement::setRecalcListItems()
762 { 763 {
763 // FIXME: This function does a bunch of confusing things depending on if it 764 // FIXME: This function does a bunch of confusing things depending on if it
764 // is in the document or not. 765 // is in the document or not.
765 766
766 m_shouldRecalcListItems = true; 767 m_shouldRecalcListItems = true;
767 // Manual selection anchor is reset when manipulating the select programmati cally. 768 // Manual selection anchor is reset when manipulating the select programmati cally.
768 m_activeSelectionAnchorIndex = -1; 769 m_activeSelectionAnchorIndex = -1;
769 setOptionsChangedOnRenderer(); 770 setOptionsChangedOnRenderer();
770 setNeedsStyleRecalc(SubtreeStyleChange); 771 setNeedsStyleRecalc(SubtreeStyleChange);
771 if (!inDocument()) { 772 if (!inDocument()) {
772 if (HTMLCollection* collection = cachedHTMLCollection(SelectOptions)) 773 if (HTMLOptionsCollection* collection = cachedCollection<HTMLOptionsColl ection>(SelectOptions))
773 collection->invalidateCache(); 774 collection->invalidateCache();
774 } 775 }
775 if (!inDocument()) 776 if (!inDocument())
776 invalidateSelectedItems(); 777 invalidateSelectedItems();
777 778
778 if (renderer()) { 779 if (renderer()) {
779 if (AXObjectCache* cache = renderer()->document().existingAXObjectCache( )) 780 if (AXObjectCache* cache = renderer()->document().existingAXObjectCache( ))
780 cache->childrenChanged(this); 781 cache->childrenChanged(this);
781 } 782 }
782 } 783 }
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after
1734 int focusedIndex = activeSelectionEndListIndex(); 1735 int focusedIndex = activeSelectionEndListIndex();
1735 if (focusedIndex < 0) 1736 if (focusedIndex < 0)
1736 focusedIndex = firstSelectableListIndex(); 1737 focusedIndex = firstSelectableListIndex();
1737 if (focusedIndex < 0) 1738 if (focusedIndex < 0)
1738 return nullptr; 1739 return nullptr;
1739 HTMLElement* focused = listItems()[focusedIndex]; 1740 HTMLElement* focused = listItems()[focusedIndex];
1740 return isHTMLOptionElement(focused) ? toHTMLOptionElement(focused) : nullptr ; 1741 return isHTMLOptionElement(focused) ? toHTMLOptionElement(focused) : nullptr ;
1741 } 1742 }
1742 1743
1743 } // namespace 1744 } // namespace
OLDNEW
« no previous file with comments | « Source/core/html/HTMLMapElement.cpp ('k') | Source/core/html/HTMLTableElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698