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

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

Issue 791533004: Don't updateRenderTree in the middle of a DOM insertion. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 6 years 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/HTMLSelectElement.h ('k') | no next file » | 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 , m_size(0) 77 , m_size(0)
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 , m_scrollToSelectionLater(false)
88 { 87 {
89 } 88 }
90 89
91 PassRefPtrWillBeRawPtr<HTMLSelectElement> HTMLSelectElement::create(Document& do cument) 90 PassRefPtrWillBeRawPtr<HTMLSelectElement> HTMLSelectElement::create(Document& do cument)
92 { 91 {
93 RefPtrWillBeRawPtr<HTMLSelectElement> select = adoptRefWillBeNoop(new HTMLSe lectElement(document, 0)); 92 RefPtrWillBeRawPtr<HTMLSelectElement> select = adoptRefWillBeNoop(new HTMLSe lectElement(document, 0));
94 select->ensureUserAgentShadowRoot(); 93 select->ensureUserAgentShadowRoot();
95 return select.release(); 94 return select.release();
96 } 95 }
97 96
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 setNeedsValidityCheck(); 411 setNeedsValidityCheck();
413 } 412 }
414 413
415 void HTMLSelectElement::childrenChanged(const ChildrenChange& change) 414 void HTMLSelectElement::childrenChanged(const ChildrenChange& change)
416 { 415 {
417 setRecalcListItems(); 416 setRecalcListItems();
418 setNeedsValidityCheck(); 417 setNeedsValidityCheck();
419 m_lastOnChangeSelection.clear(); 418 m_lastOnChangeSelection.clear();
420 419
421 HTMLFormControlElementWithState::childrenChanged(change); 420 HTMLFormControlElementWithState::childrenChanged(change);
422
423 if (m_scrollToSelectionLater) {
424 m_scrollToSelectionLater = false;
425 scrollToSelection();
426 }
427 } 421 }
428 422
429 void HTMLSelectElement::optionElementChildrenChanged() 423 void HTMLSelectElement::optionElementChildrenChanged()
430 { 424 {
431 setRecalcListItems(); 425 setRecalcListItems();
432 setNeedsValidityCheck(); 426 setNeedsValidityCheck();
433 427
434 if (renderer()) { 428 if (renderer()) {
435 if (AXObjectCache* cache = renderer()->document().existingAXObjectCache( )) 429 if (AXObjectCache* cache = renderer()->document().existingAXObjectCache( ))
436 cache->childrenChanged(this); 430 cache->childrenChanged(this);
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 else if (!usesMenuList() || multiple()) 915 else if (!usesMenuList() || multiple())
922 selectOption(-1); 916 selectOption(-1);
923 else 917 else
924 selectOption(nextSelectableListIndex(-1)); 918 selectOption(nextSelectableListIndex(-1));
925 } 919 }
926 920
927 void HTMLSelectElement::optionInserted(const HTMLOptionElement& option, bool opt ionIsSelected) 921 void HTMLSelectElement::optionInserted(const HTMLOptionElement& option, bool opt ionIsSelected)
928 { 922 {
929 ASSERT(option.ownerSelectElement() == this); 923 ASSERT(option.ownerSelectElement() == this);
930 if (optionIsSelected) 924 if (optionIsSelected)
931 selectOption(option.index(), DelayScrollToSelection); 925 selectOption(option.index());
932 } 926 }
933 927
934 void HTMLSelectElement::optionRemoved(const HTMLOptionElement& option) 928 void HTMLSelectElement::optionRemoved(const HTMLOptionElement& option)
935 { 929 {
936 if (m_activeSelectionAnchorIndex < 0 && m_activeSelectionEndIndex < 0) 930 if (m_activeSelectionAnchorIndex < 0 && m_activeSelectionEndIndex < 0)
937 return; 931 return;
938 int listIndex = optionToListIndex(option.index()); 932 int listIndex = optionToListIndex(option.index());
939 if (listIndex <= m_activeSelectionAnchorIndex) 933 if (listIndex <= m_activeSelectionAnchorIndex)
940 m_activeSelectionAnchorIndex--; 934 m_activeSelectionAnchorIndex--;
941 if (listIndex <= m_activeSelectionEndIndex) 935 if (listIndex <= m_activeSelectionEndIndex)
(...skipping 24 matching lines...) Expand all
966 } 960 }
967 } 961 }
968 962
969 if (shouldDeselect) 963 if (shouldDeselect)
970 deselectItemsWithoutValidation(element); 964 deselectItemsWithoutValidation(element);
971 965
972 // For the menu list case, this is what makes the selected element appear. 966 // For the menu list case, this is what makes the selected element appear.
973 if (RenderObject* renderer = this->renderer()) 967 if (RenderObject* renderer = this->renderer())
974 renderer->updateFromElement(); 968 renderer->updateFromElement();
975 969
976 if (flags & DelayScrollToSelection) 970 scrollToSelection();
977 m_scrollToSelectionLater = true;
978 else
979 scrollToSelection();
980
981 setNeedsValidityCheck(); 971 setNeedsValidityCheck();
982 972
983 if (usesMenuList()) { 973 if (usesMenuList()) {
984 m_isProcessingUserDrivenChange = flags & UserDriven; 974 m_isProcessingUserDrivenChange = flags & UserDriven;
985 if (flags & DispatchInputAndChangeEvent) 975 if (flags & DispatchInputAndChangeEvent)
986 dispatchInputAndChangeEventForMenuList(); 976 dispatchInputAndChangeEventForMenuList();
987 if (RenderObject* renderer = this->renderer()) { 977 if (RenderObject* renderer = this->renderer()) {
988 if (usesMenuList()) { 978 if (usesMenuList()) {
989 toRenderMenuList(renderer)->didSetSelectedIndex(listIndex); 979 toRenderMenuList(renderer)->didSetSelectedIndex(listIndex);
990 } else if (renderer->isListBox()) { 980 } else if (renderer->isListBox()) {
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
1785 int focusedIndex = activeSelectionEndListIndex(); 1775 int focusedIndex = activeSelectionEndListIndex();
1786 if (focusedIndex < 0) 1776 if (focusedIndex < 0)
1787 focusedIndex = firstSelectableListIndex(); 1777 focusedIndex = firstSelectableListIndex();
1788 if (focusedIndex < 0) 1778 if (focusedIndex < 0)
1789 return nullptr; 1779 return nullptr;
1790 HTMLElement* focused = listItems()[focusedIndex]; 1780 HTMLElement* focused = listItems()[focusedIndex];
1791 return isHTMLOptionElement(focused) ? toHTMLOptionElement(focused) : nullptr ; 1781 return isHTMLOptionElement(focused) ? toHTMLOptionElement(focused) : nullptr ;
1792 } 1782 }
1793 1783
1794 } // namespace 1784 } // namespace
OLDNEW
« no previous file with comments | « Source/core/html/HTMLSelectElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698