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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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/LayoutListBox.h" |
| 55 #include "core/layout/LayoutMenuList.h" |
55 #include "core/layout/LayoutTheme.h" | 56 #include "core/layout/LayoutTheme.h" |
56 #include "core/layout/LayoutView.h" | 57 #include "core/layout/LayoutView.h" |
57 #include "core/page/AutoscrollController.h" | 58 #include "core/page/AutoscrollController.h" |
58 #include "core/page/EventHandler.h" | 59 #include "core/page/EventHandler.h" |
59 #include "core/page/Page.h" | 60 #include "core/page/Page.h" |
60 #include "core/page/SpatialNavigation.h" | 61 #include "core/page/SpatialNavigation.h" |
61 #include "core/rendering/RenderMenuList.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; |
70 | 70 |
71 // Upper limit agreed upon with representatives of Opera and Mozilla. | 71 // Upper limit agreed upon with representatives of Opera and Mozilla. |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 setRecalcListItems(); | 351 setRecalcListItems(); |
352 } | 352 } |
353 } else if (name == multipleAttr) | 353 } else if (name == multipleAttr) |
354 parseMultipleAttribute(value); | 354 parseMultipleAttribute(value); |
355 else if (name == accesskeyAttr) { | 355 else if (name == accesskeyAttr) { |
356 // FIXME: ignore for the moment. | 356 // FIXME: ignore for the moment. |
357 // | 357 // |
358 } else if (name == disabledAttr) { | 358 } else if (name == disabledAttr) { |
359 HTMLFormControlElementWithState::parseAttribute(name, value); | 359 HTMLFormControlElementWithState::parseAttribute(name, value); |
360 if (renderer() && renderer()->isMenuList()) { | 360 if (renderer() && renderer()->isMenuList()) { |
361 if (RenderMenuList* menuList = toRenderMenuList(renderer())) { | 361 if (LayoutMenuList* menuList = toLayoutMenuList(renderer())) { |
362 if (menuList->popupIsVisible()) | 362 if (menuList->popupIsVisible()) |
363 menuList->hidePopup(); | 363 menuList->hidePopup(); |
364 } | 364 } |
365 } | 365 } |
366 | 366 |
367 } else | 367 } else |
368 HTMLFormControlElementWithState::parseAttribute(name, value); | 368 HTMLFormControlElementWithState::parseAttribute(name, value); |
369 } | 369 } |
370 | 370 |
371 bool HTMLSelectElement::shouldShowFocusRingOnMouseFocus() const | 371 bool HTMLSelectElement::shouldShowFocusRingOnMouseFocus() const |
372 { | 372 { |
373 return true; | 373 return true; |
374 } | 374 } |
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 LayoutMenuList(this); |
385 return new LayoutListBox(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() |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 return; | 730 return; |
731 scrollToIndex(activeSelectionEndListIndex()); | 731 scrollToIndex(activeSelectionEndListIndex()); |
732 if (AXObjectCache* cache = document().existingAXObjectCache()) | 732 if (AXObjectCache* cache = document().existingAXObjectCache()) |
733 cache->selectedChildrenChanged(this); | 733 cache->selectedChildrenChanged(this); |
734 } | 734 } |
735 | 735 |
736 void HTMLSelectElement::setOptionsChangedOnRenderer() | 736 void HTMLSelectElement::setOptionsChangedOnRenderer() |
737 { | 737 { |
738 if (LayoutObject* renderer = this->renderer()) { | 738 if (LayoutObject* renderer = this->renderer()) { |
739 if (usesMenuList()) | 739 if (usesMenuList()) |
740 toRenderMenuList(renderer)->setOptionsChanged(true); | 740 toLayoutMenuList(renderer)->setOptionsChanged(true); |
741 } | 741 } |
742 } | 742 } |
743 | 743 |
744 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& HTMLSelectElement::list
Items() const | 744 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& HTMLSelectElement::list
Items() const |
745 { | 745 { |
746 if (m_shouldRecalcListItems) | 746 if (m_shouldRecalcListItems) |
747 recalcListItems(); | 747 recalcListItems(); |
748 else { | 748 else { |
749 #if ENABLE(ASSERT) | 749 #if ENABLE(ASSERT) |
750 WillBeHeapVector<RawPtrWillBeMember<HTMLElement>> items = m_listItems; | 750 WillBeHeapVector<RawPtrWillBeMember<HTMLElement>> items = m_listItems; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 | 962 |
963 scrollToSelection(); | 963 scrollToSelection(); |
964 setNeedsValidityCheck(); | 964 setNeedsValidityCheck(); |
965 | 965 |
966 if (usesMenuList()) { | 966 if (usesMenuList()) { |
967 m_isProcessingUserDrivenChange = flags & UserDriven; | 967 m_isProcessingUserDrivenChange = flags & UserDriven; |
968 if (flags & DispatchInputAndChangeEvent) | 968 if (flags & DispatchInputAndChangeEvent) |
969 dispatchInputAndChangeEventForMenuList(); | 969 dispatchInputAndChangeEventForMenuList(); |
970 if (LayoutObject* renderer = this->renderer()) { | 970 if (LayoutObject* renderer = this->renderer()) { |
971 if (usesMenuList()) { | 971 if (usesMenuList()) { |
972 toRenderMenuList(renderer)->didSetSelectedIndex(listIndex); | 972 toLayoutMenuList(renderer)->didSetSelectedIndex(listIndex); |
973 } else if (renderer->isListBox()) { | 973 } else if (renderer->isListBox()) { |
974 if (AXObjectCache* cache = document().existingAXObjectCache()) | 974 if (AXObjectCache* cache = document().existingAXObjectCache()) |
975 cache->selectedChildrenChanged(this); | 975 cache->selectedChildrenChanged(this); |
976 } | 976 } |
977 } | 977 } |
978 } | 978 } |
979 | 979 |
980 notifyFormStateChanged(); | 980 notifyFormStateChanged(); |
981 } | 981 } |
982 | 982 |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 void HTMLSelectElement::handlePopupOpenKeyboardEvent(Event* event) | 1191 void HTMLSelectElement::handlePopupOpenKeyboardEvent(Event* event) |
1192 { | 1192 { |
1193 focus(); | 1193 focus(); |
1194 // Calling focus() may cause us to lose our renderer. Return true so | 1194 // Calling focus() may cause us to lose our renderer. Return true so |
1195 // that our caller doesn't process the event further, but don't set | 1195 // that our caller doesn't process the event further, but don't set |
1196 // the event as handled. | 1196 // the event as handled. |
1197 if (!renderer() || !renderer()->isMenuList() || isDisabledFormControl()) | 1197 if (!renderer() || !renderer()->isMenuList() || isDisabledFormControl()) |
1198 return; | 1198 return; |
1199 // Save the selection so it can be compared to the new selection | 1199 // Save the selection so it can be compared to the new selection |
1200 // when dispatching change events during selectOption, which | 1200 // when dispatching change events during selectOption, which |
1201 // gets called from RenderMenuList::valueChanged, which gets called | 1201 // gets called from LayoutMenuList::valueChanged, which gets called |
1202 // after the user makes a selection from the menu. | 1202 // after the user makes a selection from the menu. |
1203 saveLastSelection(); | 1203 saveLastSelection(); |
1204 if (RenderMenuList* menuList = toRenderMenuList(renderer())) | 1204 if (LayoutMenuList* menuList = toLayoutMenuList(renderer())) |
1205 menuList->showPopup(); | 1205 menuList->showPopup(); |
1206 event->setDefaultHandled(); | 1206 event->setDefaultHandled(); |
1207 return; | 1207 return; |
1208 } | 1208 } |
1209 | 1209 |
1210 bool HTMLSelectElement::shouldOpenPopupForKeyDownEvent(KeyboardEvent* keyEvent) | 1210 bool HTMLSelectElement::shouldOpenPopupForKeyDownEvent(KeyboardEvent* keyEvent) |
1211 { | 1211 { |
1212 const String& keyIdentifier = keyEvent->keyIdentifier(); | 1212 const String& keyIdentifier = keyEvent->keyIdentifier(); |
1213 LayoutTheme& layoutTheme = LayoutTheme::theme(); | 1213 LayoutTheme& layoutTheme = LayoutTheme::theme(); |
1214 | 1214 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1302 if (form()) | 1302 if (form()) |
1303 form()->submitImplicitly(event, false); | 1303 form()->submitImplicitly(event, false); |
1304 dispatchInputAndChangeEventForMenuList(); | 1304 dispatchInputAndChangeEventForMenuList(); |
1305 event->setDefaultHandled(); | 1305 event->setDefaultHandled(); |
1306 } | 1306 } |
1307 } | 1307 } |
1308 | 1308 |
1309 if (event->type() == EventTypeNames::mousedown && event->isMouseEvent() && t
oMouseEvent(event)->button() == LeftButton) { | 1309 if (event->type() == EventTypeNames::mousedown && event->isMouseEvent() && t
oMouseEvent(event)->button() == LeftButton) { |
1310 focus(); | 1310 focus(); |
1311 if (renderer() && renderer()->isMenuList() && !isDisabledFormControl())
{ | 1311 if (renderer() && renderer()->isMenuList() && !isDisabledFormControl())
{ |
1312 if (RenderMenuList* menuList = toRenderMenuList(renderer())) { | 1312 if (LayoutMenuList* menuList = toLayoutMenuList(renderer())) { |
1313 if (menuList->popupIsVisible()) | 1313 if (menuList->popupIsVisible()) |
1314 menuList->hidePopup(); | 1314 menuList->hidePopup(); |
1315 else { | 1315 else { |
1316 // Save the selection so it can be compared to the new | 1316 // Save the selection so it can be compared to the new |
1317 // selection when we call onChange during selectOption, | 1317 // selection when we call onChange during selectOption, |
1318 // which gets called from RenderMenuList::valueChanged, | 1318 // which gets called from LayoutMenuList::valueChanged, |
1319 // which gets called after the user makes a selection from | 1319 // which gets called after the user makes a selection from |
1320 // the menu. | 1320 // the menu. |
1321 saveLastSelection(); | 1321 saveLastSelection(); |
1322 menuList->showPopup(); | 1322 menuList->showPopup(); |
1323 } | 1323 } |
1324 } | 1324 } |
1325 } | 1325 } |
1326 event->setDefaultHandled(); | 1326 event->setDefaultHandled(); |
1327 } | 1327 } |
1328 | 1328 |
1329 if (event->type() == EventTypeNames::blur) { | 1329 if (event->type() == EventTypeNames::blur) { |
1330 if (RenderMenuList* menuList = toRenderMenuList(renderer())) { | 1330 if (LayoutMenuList* menuList = toLayoutMenuList(renderer())) { |
1331 if (menuList->popupIsVisible()) | 1331 if (menuList->popupIsVisible()) |
1332 menuList->hidePopup(); | 1332 menuList->hidePopup(); |
1333 } | 1333 } |
1334 } | 1334 } |
1335 } | 1335 } |
1336 | 1336 |
1337 void HTMLSelectElement::updateSelectedState(int listIndex, bool multi, bool shif
t) | 1337 void HTMLSelectElement::updateSelectedState(int listIndex, bool multi, bool shif
t) |
1338 { | 1338 { |
1339 ASSERT(listIndex >= 0); | 1339 ASSERT(listIndex >= 0); |
1340 | 1340 |
(...skipping 427 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 |