Chromium Code Reviews| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 , m_typeAhead(this) | 67 , m_typeAhead(this) |
| 68 , m_size(0) | 68 , m_size(0) |
| 69 , m_lastOnChangeIndex(-1) | 69 , m_lastOnChangeIndex(-1) |
| 70 , m_activeSelectionAnchorIndex(-1) | 70 , m_activeSelectionAnchorIndex(-1) |
| 71 , m_activeSelectionEndIndex(-1) | 71 , m_activeSelectionEndIndex(-1) |
| 72 , m_isProcessingUserDrivenChange(false) | 72 , m_isProcessingUserDrivenChange(false) |
| 73 , m_multiple(false) | 73 , m_multiple(false) |
| 74 , m_activeSelectionState(false) | 74 , m_activeSelectionState(false) |
| 75 , m_shouldRecalcListItems(false) | 75 , m_shouldRecalcListItems(false) |
| 76 , m_suggestedIndex(-1) | 76 , m_suggestedIndex(-1) |
| 77 , m_optionChildChangedTimer(this, &HTMLSelectElement::timerFired) | |
| 77 { | 78 { |
| 78 ScriptWrappable::init(this); | 79 ScriptWrappable::init(this); |
| 79 } | 80 } |
| 80 | 81 |
| 81 PassRefPtr<HTMLSelectElement> HTMLSelectElement::create(Document& document) | 82 PassRefPtr<HTMLSelectElement> HTMLSelectElement::create(Document& document) |
| 82 { | 83 { |
| 83 return adoptRef(new HTMLSelectElement(document, 0)); | 84 return adoptRef(new HTMLSelectElement(document, 0)); |
| 84 } | 85 } |
| 85 | 86 |
| 86 PassRefPtr<HTMLSelectElement> HTMLSelectElement::create(Document& document, HTML FormElement* form) | 87 PassRefPtr<HTMLSelectElement> HTMLSelectElement::create(Document& document, HTML FormElement* form) |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 501 // Otherwise, it returns |listIndex|. | 502 // Otherwise, it returns |listIndex|. |
| 502 // Valid means that it is enabled and an option element. | 503 // Valid means that it is enabled and an option element. |
| 503 int HTMLSelectElement::nextValidIndex(int listIndex, SkipDirection direction, in t skip) const | 504 int HTMLSelectElement::nextValidIndex(int listIndex, SkipDirection direction, in t skip) const |
| 504 { | 505 { |
| 505 ASSERT(direction == -1 || direction == 1); | 506 ASSERT(direction == -1 || direction == 1); |
| 506 const Vector<HTMLElement*>& listItems = this->listItems(); | 507 const Vector<HTMLElement*>& listItems = this->listItems(); |
| 507 int lastGoodIndex = listIndex; | 508 int lastGoodIndex = listIndex; |
| 508 int size = listItems.size(); | 509 int size = listItems.size(); |
| 509 for (listIndex += direction; listIndex >= 0 && listIndex < size; listIndex + = direction) { | 510 for (listIndex += direction; listIndex >= 0 && listIndex < size; listIndex + = direction) { |
| 510 --skip; | 511 --skip; |
| 511 if (!listItems[listIndex]->isDisabledFormControl() && isHTMLOptionElemen t(*listItems[listIndex])) { | 512 HTMLElement* element = listItems[listIndex]; |
| 512 lastGoodIndex = listIndex; | 513 if (!isHTMLOptionElement(*element) || toHTMLOptionElement(element)->isDi sabledFormControl() || !toHTMLOptionElement(element)->isDisplayNone()) |
| 513 if (skip <= 0) | 514 continue; |
| 514 break; | 515 lastGoodIndex = listIndex; |
| 515 } | 516 if (skip <= 0) |
| 517 break; | |
| 516 } | 518 } |
| 517 return lastGoodIndex; | 519 return lastGoodIndex; |
| 518 } | 520 } |
| 519 | 521 |
| 520 int HTMLSelectElement::nextSelectableListIndex(int startIndex) const | 522 int HTMLSelectElement::nextSelectableListIndex(int startIndex) const |
| 521 { | 523 { |
| 522 return nextValidIndex(startIndex, SkipForwards, 1); | 524 return nextValidIndex(startIndex, SkipForwards, 1); |
| 523 } | 525 } |
| 524 | 526 |
| 525 int HTMLSelectElement::previousSelectableListIndex(int startIndex) const | 527 int HTMLSelectElement::previousSelectableListIndex(int startIndex) const |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 618 { | 620 { |
| 619 ASSERT(renderer() && (renderer()->isListBox() || m_multiple)); | 621 ASSERT(renderer() && (renderer()->isListBox() || m_multiple)); |
| 620 ASSERT(!listItems().size() || m_activeSelectionAnchorIndex >= 0); | 622 ASSERT(!listItems().size() || m_activeSelectionAnchorIndex >= 0); |
| 621 | 623 |
| 622 unsigned start = min(m_activeSelectionAnchorIndex, m_activeSelectionEndIndex ); | 624 unsigned start = min(m_activeSelectionAnchorIndex, m_activeSelectionEndIndex ); |
| 623 unsigned end = max(m_activeSelectionAnchorIndex, m_activeSelectionEndIndex); | 625 unsigned end = max(m_activeSelectionAnchorIndex, m_activeSelectionEndIndex); |
| 624 | 626 |
| 625 const Vector<HTMLElement*>& items = listItems(); | 627 const Vector<HTMLElement*>& items = listItems(); |
| 626 for (unsigned i = 0; i < items.size(); ++i) { | 628 for (unsigned i = 0; i < items.size(); ++i) { |
| 627 HTMLElement* element = items[i]; | 629 HTMLElement* element = items[i]; |
| 628 if (!isHTMLOptionElement(*element) || toHTMLOptionElement(element)->isDi sabledFormControl()) | 630 if (!isHTMLOptionElement(*element) || toHTMLOptionElement(element)->isDi sabledFormControl() || !toHTMLOptionElement(element)->isDisplayNone()) |
| 629 continue; | 631 continue; |
| 630 | 632 |
| 631 if (i >= start && i <= end) | 633 if (i >= start && i <= end) |
| 632 toHTMLOptionElement(element)->setSelectedState(m_activeSelectionStat e); | 634 toHTMLOptionElement(element)->setSelectedState(m_activeSelectionStat e); |
| 633 else if (deselectOtherOptions || i >= m_cachedStateForActiveSelection.si ze()) | 635 else if (deselectOtherOptions || i >= m_cachedStateForActiveSelection.si ze()) |
| 634 toHTMLOptionElement(element)->setSelectedState(false); | 636 toHTMLOptionElement(element)->setSelectedState(false); |
| 635 else | 637 else |
| 636 toHTMLOptionElement(element)->setSelectedState(m_cachedStateForActiv eSelection[i]); | 638 toHTMLOptionElement(element)->setSelectedState(m_cachedStateForActiv eSelection[i]); |
| 637 } | 639 } |
| 638 | 640 |
| (...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1617 bool HTMLSelectElement::isInteractiveContent() const | 1619 bool HTMLSelectElement::isInteractiveContent() const |
| 1618 { | 1620 { |
| 1619 return true; | 1621 return true; |
| 1620 } | 1622 } |
| 1621 | 1623 |
| 1622 bool HTMLSelectElement::supportsAutofocus() const | 1624 bool HTMLSelectElement::supportsAutofocus() const |
| 1623 { | 1625 { |
| 1624 return true; | 1626 return true; |
| 1625 } | 1627 } |
| 1626 | 1628 |
| 1629 void HTMLSelectElement::updateListOnRenderer() | |
| 1630 { | |
| 1631 if (m_optionChildChangedTimer.isActive()) | |
| 1632 return; | |
| 1633 ASSERT(!m_optionChildChangedTimer.isActive()); | |
| 1634 m_optionChildChangedTimer.startOneShot(0, FROM_HERE); | |
|
esprehn
2014/03/20 17:09:25
This is not correct, you can't use a timer.
spartha
2014/03/21 21:37:36
Just curious, when is it recommended to use a time
| |
| 1635 } | |
| 1636 | |
| 1637 void HTMLSelectElement::timerFired(Timer<HTMLSelectElement>* ) | |
| 1638 { | |
| 1639 setOptionsChangedOnRenderer(); | |
| 1640 // Update the renderer with the new list. | |
| 1641 if (RenderObject* renderer = this->renderer()) | |
| 1642 renderer->updateFromElement(); | |
| 1643 } | |
| 1644 | |
| 1627 } // namespace | 1645 } // namespace |
| OLD | NEW |