| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "core/events/MouseEvent.h" | 44 #include "core/events/MouseEvent.h" |
| 45 #include "core/frame/FrameView.h" | 45 #include "core/frame/FrameView.h" |
| 46 #include "core/frame/LocalFrame.h" | 46 #include "core/frame/LocalFrame.h" |
| 47 #include "core/html/FormDataList.h" | 47 #include "core/html/FormDataList.h" |
| 48 #include "core/html/HTMLFormElement.h" | 48 #include "core/html/HTMLFormElement.h" |
| 49 #include "core/html/HTMLOptGroupElement.h" | 49 #include "core/html/HTMLOptGroupElement.h" |
| 50 #include "core/html/HTMLOptionElement.h" | 50 #include "core/html/HTMLOptionElement.h" |
| 51 #include "core/html/forms/FormController.h" | 51 #include "core/html/forms/FormController.h" |
| 52 #include "core/layout/HitTestRequest.h" | 52 #include "core/layout/HitTestRequest.h" |
| 53 #include "core/layout/HitTestResult.h" | 53 #include "core/layout/HitTestResult.h" |
| 54 #include "core/layout/LayoutListBox.h" |
| 54 #include "core/layout/LayoutTheme.h" | 55 #include "core/layout/LayoutTheme.h" |
| 55 #include "core/page/AutoscrollController.h" | 56 #include "core/page/AutoscrollController.h" |
| 56 #include "core/page/EventHandler.h" | 57 #include "core/page/EventHandler.h" |
| 57 #include "core/page/Page.h" | 58 #include "core/page/Page.h" |
| 58 #include "core/page/SpatialNavigation.h" | 59 #include "core/page/SpatialNavigation.h" |
| 59 #include "core/rendering/RenderListBox.h" | |
| 60 #include "core/rendering/RenderMenuList.h" | 60 #include "core/rendering/RenderMenuList.h" |
| 61 #include "core/rendering/RenderView.h" | 61 #include "core/rendering/RenderView.h" |
| 62 #include "platform/PlatformMouseEvent.h" | 62 #include "platform/PlatformMouseEvent.h" |
| 63 #include "platform/text/PlatformLocale.h" | 63 #include "platform/text/PlatformLocale.h" |
| 64 | 64 |
| 65 using namespace WTF::Unicode; | 65 using namespace WTF::Unicode; |
| 66 | 66 |
| 67 namespace blink { | 67 namespace blink { |
| 68 | 68 |
| 69 using namespace HTMLNames; | 69 using namespace HTMLNames; |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 | 375 |
| 376 bool HTMLSelectElement::canSelectAll() const | 376 bool HTMLSelectElement::canSelectAll() const |
| 377 { | 377 { |
| 378 return !usesMenuList(); | 378 return !usesMenuList(); |
| 379 } | 379 } |
| 380 | 380 |
| 381 LayoutObject* HTMLSelectElement::createRenderer(const LayoutStyle&) | 381 LayoutObject* HTMLSelectElement::createRenderer(const LayoutStyle&) |
| 382 { | 382 { |
| 383 if (usesMenuList()) | 383 if (usesMenuList()) |
| 384 return new RenderMenuList(this); | 384 return new RenderMenuList(this); |
| 385 return new RenderListBox(this); | 385 return new LayoutListBox(this); |
| 386 } | 386 } |
| 387 | 387 |
| 388 PassRefPtrWillBeRawPtr<HTMLCollection> HTMLSelectElement::selectedOptions() | 388 PassRefPtrWillBeRawPtr<HTMLCollection> HTMLSelectElement::selectedOptions() |
| 389 { | 389 { |
| 390 updateListItemSelectedStates(); | 390 updateListItemSelectedStates(); |
| 391 return ensureCachedCollection<HTMLCollection>(SelectedOptions); | 391 return ensureCachedCollection<HTMLCollection>(SelectedOptions); |
| 392 } | 392 } |
| 393 | 393 |
| 394 PassRefPtrWillBeRawPtr<HTMLOptionsCollection> HTMLSelectElement::options() | 394 PassRefPtrWillBeRawPtr<HTMLOptionsCollection> HTMLSelectElement::options() |
| 395 { | 395 { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 return nextValidIndex(-1, SkipForwards, INT_MAX); | 576 return nextValidIndex(-1, SkipForwards, INT_MAX); |
| 577 } | 577 } |
| 578 | 578 |
| 579 // Returns the index of the next valid item one page away from |startIndex| in d
irection |direction|. | 579 // Returns the index of the next valid item one page away from |startIndex| in d
irection |direction|. |
| 580 int HTMLSelectElement::nextSelectableListIndexPageAway(int startIndex, SkipDirec
tion direction) const | 580 int HTMLSelectElement::nextSelectableListIndexPageAway(int startIndex, SkipDirec
tion direction) const |
| 581 { | 581 { |
| 582 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems()
; | 582 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems()
; |
| 583 // Can't use m_size because renderer forces a minimum size. | 583 // Can't use m_size because renderer forces a minimum size. |
| 584 int pageSize = 0; | 584 int pageSize = 0; |
| 585 if (renderer()->isListBox()) | 585 if (renderer()->isListBox()) |
| 586 pageSize = toRenderListBox(renderer())->size() - 1; // -1 so we still sh
ow context. | 586 pageSize = toLayoutListBox(renderer())->size() - 1; // -1 so we still sh
ow context. |
| 587 | 587 |
| 588 // One page away, but not outside valid bounds. | 588 // One page away, but not outside valid bounds. |
| 589 // If there is a valid option item one page away, the index is chosen. | 589 // If there is a valid option item one page away, the index is chosen. |
| 590 // If there is no exact one page away valid option, returns startIndex or th
e most far index. | 590 // If there is no exact one page away valid option, returns startIndex or th
e most far index. |
| 591 int edgeIndex = (direction == SkipForwards) ? 0 : (items.size() - 1); | 591 int edgeIndex = (direction == SkipForwards) ? 0 : (items.size() - 1); |
| 592 int skipAmount = pageSize + ((direction == SkipForwards) ? startIndex : (edg
eIndex - startIndex)); | 592 int skipAmount = pageSize + ((direction == SkipForwards) ? startIndex : (edg
eIndex - startIndex)); |
| 593 return nextValidIndex(edgeIndex, direction, skipAmount); | 593 return nextValidIndex(edgeIndex, direction, skipAmount); |
| 594 } | 594 } |
| 595 | 595 |
| 596 void HTMLSelectElement::selectAll() | 596 void HTMLSelectElement::selectAll() |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 if (usesMenuList()) | 890 if (usesMenuList()) |
| 891 return; | 891 return; |
| 892 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems()
; | 892 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems()
; |
| 893 int listSize = static_cast<int>(items.size()); | 893 int listSize = static_cast<int>(items.size()); |
| 894 if (listIndex >= listSize) | 894 if (listIndex >= listSize) |
| 895 return; | 895 return; |
| 896 document().updateLayoutIgnorePendingStylesheets(); | 896 document().updateLayoutIgnorePendingStylesheets(); |
| 897 if (!renderer() || !renderer()->isListBox()) | 897 if (!renderer() || !renderer()->isListBox()) |
| 898 return; | 898 return; |
| 899 LayoutRect bounds = items[listIndex]->boundingBox(); | 899 LayoutRect bounds = items[listIndex]->boundingBox(); |
| 900 toRenderListBox(renderer())->scrollToRect(bounds); | 900 toLayoutListBox(renderer())->scrollToRect(bounds); |
| 901 } | 901 } |
| 902 | 902 |
| 903 void HTMLSelectElement::optionSelectionStateChanged(HTMLOptionElement* option, b
ool optionIsSelected) | 903 void HTMLSelectElement::optionSelectionStateChanged(HTMLOptionElement* option, b
ool optionIsSelected) |
| 904 { | 904 { |
| 905 ASSERT(option->ownerSelectElement() == this); | 905 ASSERT(option->ownerSelectElement() == this); |
| 906 if (optionIsSelected) | 906 if (optionIsSelected) |
| 907 selectOption(option->index()); | 907 selectOption(option->index()); |
| 908 else if (!usesMenuList() || multiple()) | 908 else if (!usesMenuList() || multiple()) |
| 909 selectOption(-1); | 909 selectOption(-1); |
| 910 else | 910 else |
| (...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1768 int focusedIndex = activeSelectionEndListIndex(); | 1768 int focusedIndex = activeSelectionEndListIndex(); |
| 1769 if (focusedIndex < 0) | 1769 if (focusedIndex < 0) |
| 1770 focusedIndex = firstSelectableListIndex(); | 1770 focusedIndex = firstSelectableListIndex(); |
| 1771 if (focusedIndex < 0) | 1771 if (focusedIndex < 0) |
| 1772 return nullptr; | 1772 return nullptr; |
| 1773 HTMLElement* focused = listItems()[focusedIndex]; | 1773 HTMLElement* focused = listItems()[focusedIndex]; |
| 1774 return isHTMLOptionElement(focused) ? toHTMLOptionElement(focused) : nullptr
; | 1774 return isHTMLOptionElement(focused) ? toHTMLOptionElement(focused) : nullptr
; |
| 1775 } | 1775 } |
| 1776 | 1776 |
| 1777 } // namespace | 1777 } // namespace |
| OLD | NEW |