1/* 2 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20#ifndef EventRetargeter_h 21#define EventRetargeter_h 22 23#include "wtf/HashMap.h" 24#include "wtf/RefPtr.h" 25#include "wtf/Vector.h" 26 27namespace WebCore { 28 29class EventPath; 30class EventTarget; 31class FocusEvent; 32class MouseEvent; 33class Node; 34class TouchEvent; 35class TouchList; 36class TreeScope; 37 38class EventRetargeter { 39public: 40 static void adjustForMouseEvent(Node*, MouseEvent&); 41 static void adjustForFocusEvent(Node*, FocusEvent&); 42 typedef Vector<RefPtr<TouchList> > EventPathTouchLists; 43 static void adjustForTouchEvent(Node*, TouchEvent&); 44 45private: 46 typedef Vector<RefPtr<EventTarget> > AdjustedTargets; 47 typedef HashMap<TreeScope*, EventTarget*> RelatedTargetMap; 48 enum EventWithRelatedTargetDispatchBehavior { 49 StopAtBoundaryIfNeeded, 50 DoesNotStopAtBoundary 51 }; 52 static void adjustForRelatedTarget(const Node*, EventTarget* relatedTarget, EventPath&); 53 static void calculateAdjustedNodes(const Node*, const Node* relatedNode, EventWithRelatedTargetDispatchBehavior, EventPath&, AdjustedTargets&); 54 static void buildRelatedNodeMap(const Node*, RelatedTargetMap&); 55 static EventTarget* findRelatedNode(TreeScope*, RelatedTargetMap&); 56 static void adjustTouchList(const Node*, const TouchList*, const EventPath&, EventPathTouchLists&); 57#ifndef NDEBUG 58 static void checkReachability(Node*, TouchList*); 59#endif 60}; 61 62} 63 64#endif // EventRetargeter_h 65