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

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

Issue 1181183004: Recalc list items for <select> before updating style for the select. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Call recalcListItems directly. Created 5 years, 6 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
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 , m_lastOnChangeIndex(-1) 78 , m_lastOnChangeIndex(-1)
79 , m_activeSelectionAnchorIndex(-1) 79 , m_activeSelectionAnchorIndex(-1)
80 , m_activeSelectionEndIndex(-1) 80 , m_activeSelectionEndIndex(-1)
81 , m_isProcessingUserDrivenChange(false) 81 , m_isProcessingUserDrivenChange(false)
82 , m_multiple(false) 82 , m_multiple(false)
83 , m_activeSelectionState(false) 83 , m_activeSelectionState(false)
84 , m_shouldRecalcListItems(false) 84 , m_shouldRecalcListItems(false)
85 , m_suggestedIndex(-1) 85 , m_suggestedIndex(-1)
86 , m_isAutofilledByPreview(false) 86 , m_isAutofilledByPreview(false)
87 { 87 {
88 setHasCustomStyleCallbacks();
88 } 89 }
89 90
90 PassRefPtrWillBeRawPtr<HTMLSelectElement> HTMLSelectElement::create(Document& do cument) 91 PassRefPtrWillBeRawPtr<HTMLSelectElement> HTMLSelectElement::create(Document& do cument)
91 { 92 {
92 RefPtrWillBeRawPtr<HTMLSelectElement> select = adoptRefWillBeNoop(new HTMLSe lectElement(document, 0)); 93 RefPtrWillBeRawPtr<HTMLSelectElement> select = adoptRefWillBeNoop(new HTMLSe lectElement(document, 0));
93 select->ensureUserAgentShadowRoot(); 94 select->ensureUserAgentShadowRoot();
94 return select.release(); 95 return select.release();
95 } 96 }
96 97
97 PassRefPtrWillBeRawPtr<HTMLSelectElement> HTMLSelectElement::create(Document& do cument, HTMLFormElement* form) 98 PassRefPtrWillBeRawPtr<HTMLSelectElement> HTMLSelectElement::create(Document& do cument, HTMLFormElement* form)
(...skipping 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after
1744 } 1745 }
1745 1746
1746 DEFINE_TRACE(HTMLSelectElement) 1747 DEFINE_TRACE(HTMLSelectElement)
1747 { 1748 {
1748 #if ENABLE(OILPAN) 1749 #if ENABLE(OILPAN)
1749 visitor->trace(m_listItems); 1750 visitor->trace(m_listItems);
1750 #endif 1751 #endif
1751 HTMLFormControlElementWithState::trace(visitor); 1752 HTMLFormControlElementWithState::trace(visitor);
1752 } 1753 }
1753 1754
1755 void HTMLSelectElement::willRecalcStyle(StyleRecalcChange change)
1756 {
1757 // TODO(esprehn): recalcListItems will update the selected states of list
ojan 2015/06/19 01:05:02 It's not clear what the TODO here is.
1758 // items so we need to do it first so we match the correct style <option>'s.
1759 if (m_shouldRecalcListItems)
1760 recalcListItems();
1761 }
1762
1754 void HTMLSelectElement::didAddUserAgentShadowRoot(ShadowRoot& root) 1763 void HTMLSelectElement::didAddUserAgentShadowRoot(ShadowRoot& root)
1755 { 1764 {
1756 RefPtrWillBeRawPtr<HTMLContentElement> content = HTMLContentElement::create( document()); 1765 RefPtrWillBeRawPtr<HTMLContentElement> content = HTMLContentElement::create( document());
1757 content->setAttribute(selectAttr, "option,optgroup,hr"); 1766 content->setAttribute(selectAttr, "option,optgroup,hr");
1758 root.appendChild(content); 1767 root.appendChild(content);
1759 } 1768 }
1760 1769
1761 HTMLOptionElement* HTMLSelectElement::spatialNavigationFocusedOption() 1770 HTMLOptionElement* HTMLSelectElement::spatialNavigationFocusedOption()
1762 { 1771 {
1763 if (!isSpatialNavigationEnabled(document().frame())) 1772 if (!isSpatialNavigationEnabled(document().frame()))
1764 return nullptr; 1773 return nullptr;
1765 int focusedIndex = activeSelectionEndListIndex(); 1774 int focusedIndex = activeSelectionEndListIndex();
1766 if (focusedIndex < 0) 1775 if (focusedIndex < 0)
1767 focusedIndex = firstSelectableListIndex(); 1776 focusedIndex = firstSelectableListIndex();
1768 if (focusedIndex < 0) 1777 if (focusedIndex < 0)
1769 return nullptr; 1778 return nullptr;
1770 HTMLElement* focused = listItems()[focusedIndex]; 1779 HTMLElement* focused = listItems()[focusedIndex];
1771 return isHTMLOptionElement(focused) ? toHTMLOptionElement(focused) : nullptr ; 1780 return isHTMLOptionElement(focused) ? toHTMLOptionElement(focused) : nullptr ;
1772 } 1781 }
1773 1782
1774 } // namespace 1783 } // namespace
OLDNEW
« Source/core/dom/Element.cpp ('K') | « Source/core/html/HTMLSelectElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698