OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) | 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) |
3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) | 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) |
4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
5 * Copyright (C) 2003, 2005, 2006, 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2005, 2006, 2008 Apple Inc. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 22 matching lines...) Expand all Loading... | |
33 namespace blink { | 33 namespace blink { |
34 | 34 |
35 MouseRelatedEvent::MouseRelatedEvent() | 35 MouseRelatedEvent::MouseRelatedEvent() |
36 : m_isSimulated(false) | 36 : m_isSimulated(false) |
37 , m_hasCachedRelativePosition(false) | 37 , m_hasCachedRelativePosition(false) |
38 { | 38 { |
39 } | 39 } |
40 | 40 |
41 static LayoutSize contentsScrollOffset(AbstractView* abstractView) | 41 static LayoutSize contentsScrollOffset(AbstractView* abstractView) |
42 { | 42 { |
43 if (!abstractView) | 43 if (!abstractView || !abstractView->isLocalDOMWindow()) |
haraken
2014/11/10 08:58:20
Is it OK to return LayoutSize() for a RemoteDOMWin
dcheng
2014/11/10 09:29:43
This code is hit on the path for initMouseEvent().
| |
44 return LayoutSize(); | 44 return LayoutSize(); |
45 LocalFrame* frame = abstractView->frame(); | 45 LocalFrame* frame = toLocalDOMWindow(abstractView)->frame(); |
46 if (!frame) | 46 if (!frame) |
47 return LayoutSize(); | 47 return LayoutSize(); |
48 FrameView* frameView = frame->view(); | 48 FrameView* frameView = frame->view(); |
49 if (!frameView) | 49 if (!frameView) |
50 return LayoutSize(); | 50 return LayoutSize(); |
51 float scaleFactor = frame->pageZoomFactor(); | 51 float scaleFactor = frame->pageZoomFactor(); |
52 return LayoutSize(frameView->scrollX() / scaleFactor, frameView->scrollY() / scaleFactor); | 52 return LayoutSize(frameView->scrollX() / scaleFactor, frameView->scrollY() / scaleFactor); |
53 } | 53 } |
54 | 54 |
55 MouseRelatedEvent::MouseRelatedEvent(const AtomicString& eventType, bool canBubb le, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView> abstractView, | 55 MouseRelatedEvent::MouseRelatedEvent(const AtomicString& eventType, bool canBubb le, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView> abstractView, |
56 int detail, const IntPoint& screenLocation, const IntPoint& windowLocation, | 56 int detail, const IntPoint& screenLocation, const IntPoint& windowLocation, |
57 const IntPoint& movementDelta, | 57 const IntPoint& movementDelta, |
58 bool ctrlKey, bool altKey, bool shiftKey, b ool metaKey, bool isSimulated) | 58 bool ctrlKey, bool altKey, bool shiftKey, b ool metaKey, bool isSimulated) |
59 : UIEventWithKeyState(eventType, canBubble, cancelable, abstractView, detail , ctrlKey, altKey, shiftKey, metaKey) | 59 : UIEventWithKeyState(eventType, canBubble, cancelable, abstractView, detail , ctrlKey, altKey, shiftKey, metaKey) |
60 , m_screenLocation(screenLocation) | 60 , m_screenLocation(screenLocation) |
61 , m_movementDelta(movementDelta) | 61 , m_movementDelta(movementDelta) |
62 , m_isSimulated(isSimulated) | 62 , m_isSimulated(isSimulated) |
63 { | 63 { |
64 LayoutPoint adjustedPageLocation; | 64 LayoutPoint adjustedPageLocation; |
65 LayoutPoint scrollPosition; | 65 LayoutPoint scrollPosition; |
66 | 66 |
67 LocalFrame* frame = view() ? view()->frame() : 0; | 67 LocalFrame* frame = view() && view()->isLocalDOMWindow() ? toLocalDOMWindow( view())->frame() : 0; |
dcheng
2014/11/10 09:29:43
Note: looking at more code, I'm not sure if we can
dcheng
2014/11/10 20:41:55
Actually it turns out this is web-exposed: https:/
| |
68 if (frame && !isSimulated) { | 68 if (frame && !isSimulated) { |
69 if (FrameView* frameView = frame->view()) { | 69 if (FrameView* frameView = frame->view()) { |
70 scrollPosition = frameView->scrollPosition(); | 70 scrollPosition = frameView->scrollPosition(); |
71 adjustedPageLocation = frameView->windowToContents(windowLocation); | 71 adjustedPageLocation = frameView->windowToContents(windowLocation); |
72 float scaleFactor = 1 / frame->pageZoomFactor(); | 72 float scaleFactor = 1 / frame->pageZoomFactor(); |
73 if (scaleFactor != 1.0f) { | 73 if (scaleFactor != 1.0f) { |
74 adjustedPageLocation.scale(scaleFactor, scaleFactor); | 74 adjustedPageLocation.scale(scaleFactor, scaleFactor); |
75 scrollPosition.scale(scaleFactor, scaleFactor); | 75 scrollPosition.scale(scaleFactor, scaleFactor); |
76 } | 76 } |
77 } | 77 } |
(...skipping 25 matching lines...) Expand all Loading... | |
103 | 103 |
104 m_layerLocation = m_pageLocation; | 104 m_layerLocation = m_pageLocation; |
105 m_offsetLocation = m_pageLocation; | 105 m_offsetLocation = m_pageLocation; |
106 | 106 |
107 computePageLocation(); | 107 computePageLocation(); |
108 m_hasCachedRelativePosition = false; | 108 m_hasCachedRelativePosition = false; |
109 } | 109 } |
110 | 110 |
111 static float pageZoomFactor(const UIEvent* event) | 111 static float pageZoomFactor(const UIEvent* event) |
112 { | 112 { |
113 LocalDOMWindow* window = event->view(); | 113 if (!event->view() || !event->view()->isLocalDOMWindow()) |
haraken
2014/11/10 08:58:20
Is it OK to return 1 for a RemoteDOMWindow?
dcheng
2014/11/10 09:29:43
This is similar to my previous comment.
| |
114 if (!window) | |
115 return 1; | 114 return 1; |
116 LocalFrame* frame = window->frame(); | 115 LocalFrame* frame = toLocalDOMWindow(event->view())->frame(); |
117 if (!frame) | 116 if (!frame) |
118 return 1; | 117 return 1; |
119 return frame->pageZoomFactor(); | 118 return frame->pageZoomFactor(); |
120 } | 119 } |
121 | 120 |
122 void MouseRelatedEvent::computePageLocation() | 121 void MouseRelatedEvent::computePageLocation() |
123 { | 122 { |
124 float scaleFactor = pageZoomFactor(this); | 123 float scaleFactor = pageZoomFactor(this); |
125 setAbsoluteLocation(roundedLayoutPoint(FloatPoint(pageX() * scaleFactor, pag eY() * scaleFactor))); | 124 setAbsoluteLocation(roundedLayoutPoint(FloatPoint(pageX() * scaleFactor, pag eY() * scaleFactor))); |
126 } | 125 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
224 // See Microsoft documentation and <http://www.quirksmode.org/dom/w3c_events .html>. | 223 // See Microsoft documentation and <http://www.quirksmode.org/dom/w3c_events .html>. |
225 return m_clientLocation.y(); | 224 return m_clientLocation.y(); |
226 } | 225 } |
227 | 226 |
228 void MouseRelatedEvent::trace(Visitor* visitor) | 227 void MouseRelatedEvent::trace(Visitor* visitor) |
229 { | 228 { |
230 UIEventWithKeyState::trace(visitor); | 229 UIEventWithKeyState::trace(visitor); |
231 } | 230 } |
232 | 231 |
233 } // namespace blink | 232 } // namespace blink |
OLD | NEW |