| 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 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1139 | 1139 |
| 1140 m_activeSelectionState = true; | 1140 m_activeSelectionState = true; |
| 1141 | 1141 |
| 1142 bool shiftSelect = m_multiple && shift; | 1142 bool shiftSelect = m_multiple && shift; |
| 1143 bool multiSelect = m_multiple && multi && !shift; | 1143 bool multiSelect = m_multiple && multi && !shift; |
| 1144 | 1144 |
| 1145 HTMLElement* clickedElement = listItems()[listIndex]; | 1145 HTMLElement* clickedElement = listItems()[listIndex]; |
| 1146 if (clickedElement->hasTagName(optionTag)) { | 1146 if (clickedElement->hasTagName(optionTag)) { |
| 1147 // Keep track of whether an active selection (like during drag | 1147 // Keep track of whether an active selection (like during drag |
| 1148 // selection), should select or deselect. | 1148 // selection), should select or deselect. |
| 1149 if (toHTMLOptionElement(clickedElement)->selected() && multi) | 1149 if (toHTMLOptionElement(clickedElement)->selected() && multiSelect) |
| 1150 m_activeSelectionState = false; | 1150 m_activeSelectionState = false; |
| 1151 if (!m_activeSelectionState) | 1151 if (!m_activeSelectionState) |
| 1152 toHTMLOptionElement(clickedElement)->setSelectedState(false); | 1152 toHTMLOptionElement(clickedElement)->setSelectedState(false); |
| 1153 } | 1153 } |
| 1154 | 1154 |
| 1155 // If we're not in any special multiple selection mode, then deselect all | 1155 // If we're not in any special multiple selection mode, then deselect all |
| 1156 // other items, excluding the clicked option. If no option was clicked, then | 1156 // other items, excluding the clicked option. If no option was clicked, then |
| 1157 // this will deselect all items in the list. | 1157 // this will deselect all items in the list. |
| 1158 if (!shiftSelect && !multiSelect) | 1158 if (!shiftSelect && !multiSelect) |
| 1159 deselectItemsWithoutValidation(clickedElement); | 1159 deselectItemsWithoutValidation(clickedElement); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 MouseEvent* mouseEvent = static_cast<MouseEvent*>(event); | 1207 MouseEvent* mouseEvent = static_cast<MouseEvent*>(event); |
| 1208 if (mouseEvent->button() != LeftButton || !mouseEvent->buttonDown()) | 1208 if (mouseEvent->button() != LeftButton || !mouseEvent->buttonDown()) |
| 1209 return; | 1209 return; |
| 1210 | 1210 |
| 1211 IntPoint localOffset = roundedIntPoint(renderer()->absoluteToLocal(mouse
Event->absoluteLocation(), false, true)); | 1211 IntPoint localOffset = roundedIntPoint(renderer()->absoluteToLocal(mouse
Event->absoluteLocation(), false, true)); |
| 1212 int listIndex = toRenderListBox(renderer())->listIndexAtOffset(toSize(lo
calOffset)); | 1212 int listIndex = toRenderListBox(renderer())->listIndexAtOffset(toSize(lo
calOffset)); |
| 1213 if (listIndex >= 0) { | 1213 if (listIndex >= 0) { |
| 1214 if (m_multiple) { | 1214 if (m_multiple) { |
| 1215 setActiveSelectionEndIndex(listIndex); | 1215 setActiveSelectionEndIndex(listIndex); |
| 1216 updateListBoxSelection(false); | 1216 updateListBoxSelection(false); |
| 1217 } else | 1217 } else { |
| 1218 updateSelectedState(listIndex, false, false); | 1218 setActiveSelectionAnchorIndex(listIndex); |
| 1219 setActiveSelectionEndIndex(listIndex); |
| 1220 updateListBoxSelection(true); |
| 1221 } |
| 1219 event->setDefaultHandled(); | 1222 event->setDefaultHandled(); |
| 1220 } | 1223 } |
| 1221 } else if (event->type() == eventNames().mouseupEvent && event->isMouseEvent
() && static_cast<MouseEvent*>(event)->button() == LeftButton && document()->fra
me()->eventHandler()->autoscrollRenderer() != renderer()) { | 1224 } else if (event->type() == eventNames().mouseupEvent && event->isMouseEvent
() && static_cast<MouseEvent*>(event)->button() == LeftButton && document()->fra
me()->eventHandler()->autoscrollRenderer() != renderer()) { |
| 1222 // This makes sure we fire dispatchFormControlChangeEvent for a single | 1225 // This makes sure we fire dispatchFormControlChangeEvent for a single |
| 1223 // click. For drag selection, onChange will fire when the autoscroll | 1226 // click. For drag selection, onChange will fire when the autoscroll |
| 1224 // timer stops. | 1227 // timer stops. |
| 1225 listBoxOnChange(); | 1228 listBoxOnChange(); |
| 1226 } else if (event->type() == eventNames().keydownEvent) { | 1229 } else if (event->type() == eventNames().keydownEvent) { |
| 1227 if (!event->isKeyboardEvent()) | 1230 if (!event->isKeyboardEvent()) |
| 1228 return; | 1231 return; |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1494 | 1497 |
| 1495 const HTMLSelectElement* toHTMLSelectElement(const Node* node) | 1498 const HTMLSelectElement* toHTMLSelectElement(const Node* node) |
| 1496 { | 1499 { |
| 1497 ASSERT(!node || node->hasTagName(selectTag)); | 1500 ASSERT(!node || node->hasTagName(selectTag)); |
| 1498 return static_cast<const HTMLSelectElement*>(node); | 1501 return static_cast<const HTMLSelectElement*>(node); |
| 1499 } | 1502 } |
| 1500 | 1503 |
| 1501 #endif | 1504 #endif |
| 1502 | 1505 |
| 1503 } // namespace | 1506 } // namespace |
| OLD | NEW |