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

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

Issue 2115783002: Merge "Improve performance of HTMLSelectElement::setActiveSelectionAnchor()." to M52. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 5 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
« no previous file with comments | « third_party/WebKit/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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 // FIXME: This is horribly factored. 372 // FIXME: This is horribly factored.
373 if (Attribute* sizeAttribute = ensureUniqueElementData().attributes( ).find(sizeAttr)) 373 if (Attribute* sizeAttribute = ensureUniqueElementData().attributes( ).find(sizeAttr))
374 sizeAttribute->setValue(attrSize); 374 sizeAttribute->setValue(attrSize);
375 } 375 }
376 m_size = std::max(size, 0u); 376 m_size = std::max(size, 0u);
377 setNeedsValidityCheck(); 377 setNeedsValidityCheck();
378 if (m_size != oldSize) { 378 if (m_size != oldSize) {
379 if (inActiveDocument()) 379 if (inActiveDocument())
380 lazyReattachIfAttached(); 380 lazyReattachIfAttached();
381 resetToDefaultSelection(); 381 resetToDefaultSelection();
382 if (!usesMenuList())
383 saveListboxActiveSelection();
382 } 384 }
383 } else if (name == multipleAttr) { 385 } else if (name == multipleAttr) {
384 parseMultipleAttribute(value); 386 parseMultipleAttribute(value);
385 } else if (name == accesskeyAttr) { 387 } else if (name == accesskeyAttr) {
386 // FIXME: ignore for the moment. 388 // FIXME: ignore for the moment.
387 // 389 //
388 } else if (name == disabledAttr) { 390 } else if (name == disabledAttr) {
389 HTMLFormControlElementWithState::parseAttribute(name, oldValue, value); 391 HTMLFormControlElementWithState::parseAttribute(name, oldValue, value);
390 if (popupIsVisible()) 392 if (popupIsVisible())
391 hidePopup(); 393 hidePopup();
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 } 638 }
637 639
638 m_lastOnChangeSelection.clear(); 640 m_lastOnChangeSelection.clear();
639 for (auto& element : listItems()) 641 for (auto& element : listItems())
640 m_lastOnChangeSelection.append(isHTMLOptionElement(*element) && toHTMLOp tionElement(element)->selected()); 642 m_lastOnChangeSelection.append(isHTMLOptionElement(*element) && toHTMLOp tionElement(element)->selected());
641 } 643 }
642 644
643 void HTMLSelectElement::setActiveSelectionAnchor(HTMLOptionElement* option) 645 void HTMLSelectElement::setActiveSelectionAnchor(HTMLOptionElement* option)
644 { 646 {
645 m_activeSelectionAnchor = option; 647 m_activeSelectionAnchor = option;
648 if (!usesMenuList())
649 saveListboxActiveSelection();
650 }
646 651
652 void HTMLSelectElement::saveListboxActiveSelection()
653 {
647 // Cache the selection state so we can restore the old selection as the new 654 // Cache the selection state so we can restore the old selection as the new
648 // selection pivots around this anchor index. 655 // selection pivots around this anchor index.
649 // Example: 656 // Example:
650 // 1. Press the mouse button on the second OPTION 657 // 1. Press the mouse button on the second OPTION
651 // m_activeSelectionAnchorIndex = 1 658 // m_activeSelectionAnchorIndex = 1
652 // 2. Drag the mouse pointer onto the fifth OPTION 659 // 2. Drag the mouse pointer onto the fifth OPTION
653 // m_activeSelectionEndIndex = 4, options at 1-4 indices are selected. 660 // m_activeSelectionEndIndex = 4, options at 1-4 indices are selected.
654 // 3. Drag the mouse pointer onto the fourth OPTION 661 // 3. Drag the mouse pointer onto the fourth OPTION
655 // m_activeSelectionEndIndex = 3, options at 1-3 indices are selected. 662 // m_activeSelectionEndIndex = 3, options at 1-3 indices are selected.
656 // updateListBoxSelection needs to clear selection of the fifth OPTION. 663 // updateListBoxSelection needs to clear selection of the fifth OPTION.
(...skipping 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after
2083 } 2090 }
2084 2091
2085 void HTMLSelectElement::didMutateSubtree() 2092 void HTMLSelectElement::didMutateSubtree()
2086 { 2093 {
2087 DCHECK(popupIsVisible()); 2094 DCHECK(popupIsVisible());
2088 DCHECK(m_popup); 2095 DCHECK(m_popup);
2089 m_popup->updateFromElement(PopupMenu::ByDOMChange); 2096 m_popup->updateFromElement(PopupMenu::ByDOMChange);
2090 } 2097 }
2091 2098
2092 } // namespace blink 2099 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLSelectElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698