| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 { | 77 { |
| 78 ScriptWrappable::init(this); | 78 ScriptWrappable::init(this); |
| 79 setHasCustomStyleCallbacks(); |
| 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) |
| 87 { | 88 { |
| 88 return adoptRef(new HTMLSelectElement(document, form)); | 89 return adoptRef(new HTMLSelectElement(document, form)); |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 // Otherwise, it returns |listIndex|. | 515 // Otherwise, it returns |listIndex|. |
| 515 // Valid means that it is enabled and an option element. | 516 // Valid means that it is enabled and an option element. |
| 516 int HTMLSelectElement::nextValidIndex(int listIndex, SkipDirection direction, in
t skip) const | 517 int HTMLSelectElement::nextValidIndex(int listIndex, SkipDirection direction, in
t skip) const |
| 517 { | 518 { |
| 518 ASSERT(direction == -1 || direction == 1); | 519 ASSERT(direction == -1 || direction == 1); |
| 519 const Vector<HTMLElement*>& listItems = this->listItems(); | 520 const Vector<HTMLElement*>& listItems = this->listItems(); |
| 520 int lastGoodIndex = listIndex; | 521 int lastGoodIndex = listIndex; |
| 521 int size = listItems.size(); | 522 int size = listItems.size(); |
| 522 for (listIndex += direction; listIndex >= 0 && listIndex < size; listIndex +
= direction) { | 523 for (listIndex += direction; listIndex >= 0 && listIndex < size; listIndex +
= direction) { |
| 523 --skip; | 524 --skip; |
| 524 if (!listItems[listIndex]->isDisabledFormControl() && isHTMLOptionElemen
t(*listItems[listIndex])) { | 525 HTMLElement* element = listItems[listIndex]; |
| 525 lastGoodIndex = listIndex; | 526 if (!isHTMLOptionElement(*element) || toHTMLOptionElement(element)->isDi
sabledFormControl() || toHTMLOptionElement(element)->isDisplayNone()) |
| 526 if (skip <= 0) | 527 continue; |
| 527 break; | 528 lastGoodIndex = listIndex; |
| 528 } | 529 if (skip <= 0) |
| 530 break; |
| 529 } | 531 } |
| 530 return lastGoodIndex; | 532 return lastGoodIndex; |
| 531 } | 533 } |
| 532 | 534 |
| 533 int HTMLSelectElement::nextSelectableListIndex(int startIndex) const | 535 int HTMLSelectElement::nextSelectableListIndex(int startIndex) const |
| 534 { | 536 { |
| 535 return nextValidIndex(startIndex, SkipForwards, 1); | 537 return nextValidIndex(startIndex, SkipForwards, 1); |
| 536 } | 538 } |
| 537 | 539 |
| 538 int HTMLSelectElement::previousSelectableListIndex(int startIndex) const | 540 int HTMLSelectElement::previousSelectableListIndex(int startIndex) const |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 { | 633 { |
| 632 ASSERT(renderer() && (renderer()->isListBox() || m_multiple)); | 634 ASSERT(renderer() && (renderer()->isListBox() || m_multiple)); |
| 633 ASSERT(!listItems().size() || m_activeSelectionAnchorIndex >= 0); | 635 ASSERT(!listItems().size() || m_activeSelectionAnchorIndex >= 0); |
| 634 | 636 |
| 635 unsigned start = min(m_activeSelectionAnchorIndex, m_activeSelectionEndIndex
); | 637 unsigned start = min(m_activeSelectionAnchorIndex, m_activeSelectionEndIndex
); |
| 636 unsigned end = max(m_activeSelectionAnchorIndex, m_activeSelectionEndIndex); | 638 unsigned end = max(m_activeSelectionAnchorIndex, m_activeSelectionEndIndex); |
| 637 | 639 |
| 638 const Vector<HTMLElement*>& items = listItems(); | 640 const Vector<HTMLElement*>& items = listItems(); |
| 639 for (unsigned i = 0; i < items.size(); ++i) { | 641 for (unsigned i = 0; i < items.size(); ++i) { |
| 640 HTMLElement* element = items[i]; | 642 HTMLElement* element = items[i]; |
| 641 if (!isHTMLOptionElement(*element) || toHTMLOptionElement(element)->isDi
sabledFormControl()) | 643 if (!isHTMLOptionElement(*element) || toHTMLOptionElement(element)->isDi
sabledFormControl() || toHTMLOptionElement(element)->isDisplayNone()) |
| 642 continue; | 644 continue; |
| 643 | 645 |
| 644 if (i >= start && i <= end) | 646 if (i >= start && i <= end) |
| 645 toHTMLOptionElement(element)->setSelectedState(m_activeSelectionStat
e); | 647 toHTMLOptionElement(element)->setSelectedState(m_activeSelectionStat
e); |
| 646 else if (deselectOtherOptions || i >= m_cachedStateForActiveSelection.si
ze()) | 648 else if (deselectOtherOptions || i >= m_cachedStateForActiveSelection.si
ze()) |
| 647 toHTMLOptionElement(element)->setSelectedState(false); | 649 toHTMLOptionElement(element)->setSelectedState(false); |
| 648 else | 650 else |
| 649 toHTMLOptionElement(element)->setSelectedState(m_cachedStateForActiv
eSelection[i]); | 651 toHTMLOptionElement(element)->setSelectedState(m_cachedStateForActiv
eSelection[i]); |
| 650 } | 652 } |
| 651 | 653 |
| (...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1645 bool HTMLSelectElement::isInteractiveContent() const | 1647 bool HTMLSelectElement::isInteractiveContent() const |
| 1646 { | 1648 { |
| 1647 return true; | 1649 return true; |
| 1648 } | 1650 } |
| 1649 | 1651 |
| 1650 bool HTMLSelectElement::supportsAutofocus() const | 1652 bool HTMLSelectElement::supportsAutofocus() const |
| 1651 { | 1653 { |
| 1652 return true; | 1654 return true; |
| 1653 } | 1655 } |
| 1654 | 1656 |
| 1657 void HTMLSelectElement::updateListOnRenderer() |
| 1658 { |
| 1659 setOptionsChangedOnRenderer(); |
| 1660 } |
| 1661 |
| 1662 void HTMLSelectElement::didRecalcStyle(StyleRecalcChange) |
| 1663 { |
| 1664 if (RenderObject* renderer = this->renderer()) |
| 1665 renderer->updateFromElement(); |
| 1666 } |
| 1667 |
| 1655 } // namespace | 1668 } // namespace |
| OLD | NEW |