Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: third_party/WebKit/WebCore/html/HTMLSelectElement.cpp

Issue 21184: WebKit merge 40722:40785 (part 1) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 menuList->showPopup(); 704 menuList->showPopup();
705 } 705 }
706 evt->setDefaultHandled(); 706 evt->setDefaultHandled();
707 } 707 }
708 } 708 }
709 709
710 void HTMLSelectElement::listBoxDefaultEventHandler(Event* evt) 710 void HTMLSelectElement::listBoxDefaultEventHandler(Event* evt)
711 { 711 {
712 if (evt->type() == eventNames().mousedownEvent && evt->isMouseEvent() && sta tic_cast<MouseEvent*>(evt)->button() == LeftButton) { 712 if (evt->type() == eventNames().mousedownEvent && evt->isMouseEvent() && sta tic_cast<MouseEvent*>(evt)->button() == LeftButton) {
713 focus(); 713 focus();
714 714
715 MouseEvent* mEvt = static_cast<MouseEvent*>(evt); 715 // Convert to coords relative to the list box if needed.
716 int listIndex = static_cast<RenderListBox*>(renderer())->listIndexAtOffs et(mEvt->offsetX(), mEvt->offsetY()); 716 MouseEvent* mouseEvent = static_cast<MouseEvent*>(evt);
717 int offsetX = mouseEvent->offsetX();
718 int offsetY = mouseEvent->offsetY();
719 Node* target = evt->target()->toNode();
720 if (target != this) {
721 FloatPoint absPos = renderer()->absoluteToLocal(FloatPoint(offsetX, offsetY), false, true);
722 offsetX = absPos.x();
723 offsetY = absPos.y();
724 }
725 int listIndex = static_cast<RenderListBox*>(renderer())->listIndexAtOffs et(offsetX, offsetY);
717 if (listIndex >= 0) { 726 if (listIndex >= 0) {
718 // Save the selection so it can be compared to the new selection whe n we call onChange during mouseup, or after autoscroll finishes. 727 // Save the selection so it can be compared to the new selection whe n we call onChange during mouseup, or after autoscroll finishes.
719 saveLastSelection(); 728 saveLastSelection();
720 729
721 m_activeSelectionState = true; 730 m_activeSelectionState = true;
722 731
723 bool multiSelectKeyPressed = false; 732 bool multiSelectKeyPressed = false;
724 #if PLATFORM(MAC) 733 #if PLATFORM(MAC)
725 multiSelectKeyPressed = mEvt->metaKey(); 734 multiSelectKeyPressed = mouseEvent->metaKey();
726 #else 735 #else
727 multiSelectKeyPressed = mEvt->ctrlKey(); 736 multiSelectKeyPressed = mouseEvent->ctrlKey();
728 #endif 737 #endif
729 738
730 bool shiftSelect = multiple() && mEvt->shiftKey(); 739 bool shiftSelect = multiple() && mouseEvent->shiftKey();
731 bool multiSelect = multiple() && multiSelectKeyPressed && !mEvt->shi ftKey(); 740 bool multiSelect = multiple() && multiSelectKeyPressed && !mouseEven t->shiftKey();
732 741
733 HTMLElement* clickedElement = listItems()[listIndex]; 742 HTMLElement* clickedElement = listItems()[listIndex];
734 HTMLOptionElement* option = 0; 743 HTMLOptionElement* option = 0;
735 if (clickedElement->hasLocalName(optionTag)) { 744 if (clickedElement->hasLocalName(optionTag)) {
736 option = static_cast<HTMLOptionElement*>(clickedElement); 745 option = static_cast<HTMLOptionElement*>(clickedElement);
737 746
738 // Keep track of whether an active selection (like during drag s election), should select or deselect 747 // Keep track of whether an active selection (like during drag s election), should select or deselect
739 if (option->selected() && multiSelectKeyPressed) 748 if (option->selected() && multiSelectKeyPressed)
740 m_activeSelectionState = false; 749 m_activeSelectionState = false;
741 750
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 { 1126 {
1118 Vector<HTMLElement*> items = m_listItems; 1127 Vector<HTMLElement*> items = m_listItems;
1119 recalcListItems(false); 1128 recalcListItems(false);
1120 ASSERT(items == m_listItems); 1129 ASSERT(items == m_listItems);
1121 } 1130 }
1122 1131
1123 #endif 1132 #endif
1124 1133
1125 } // namespace 1134 } // namespace
1126 1135
OLDNEW
« no previous file with comments | « third_party/WebKit/WebCore/html/HTMLParser.cpp ('k') | third_party/WebKit/WebCore/inspector/InspectorController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698