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

Side by Side Diff: sky/engine/core/events/MouseRelatedEvent.cpp

Issue 714013002: Remove some more zoom-related code. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: merge to ToT Created 6 years, 1 month 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
« no previous file with comments | « sky/engine/core/dom/TreeScope.cpp ('k') | sky/engine/core/frame/LocalFrame.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 bool ctrlKey, bool altKey, bool shiftKey, b ool metaKey, bool isSimulated) 44 bool ctrlKey, bool altKey, bool shiftKey, b ool metaKey, bool isSimulated)
45 : UIEventWithKeyState(eventType, canBubble, cancelable, abstractView, detail , ctrlKey, altKey, shiftKey, metaKey) 45 : UIEventWithKeyState(eventType, canBubble, cancelable, abstractView, detail , ctrlKey, altKey, shiftKey, metaKey)
46 , m_screenLocation(screenLocation) 46 , m_screenLocation(screenLocation)
47 , m_movementDelta(movementDelta) 47 , m_movementDelta(movementDelta)
48 , m_isSimulated(isSimulated) 48 , m_isSimulated(isSimulated)
49 { 49 {
50 LayoutPoint adjustedPageLocation; 50 LayoutPoint adjustedPageLocation;
51 51
52 LocalFrame* frame = view() ? view()->frame() : 0; 52 LocalFrame* frame = view() ? view()->frame() : 0;
53 if (frame && !isSimulated) { 53 if (frame && !isSimulated) {
54 if (FrameView* frameView = frame->view()) { 54 if (FrameView* frameView = frame->view())
55 adjustedPageLocation = frameView->windowToContents(windowLocation); 55 adjustedPageLocation = frameView->windowToContents(windowLocation);
56 float scaleFactor = 1 / frame->pageZoomFactor();
57 if (scaleFactor != 1.0f) {
58 adjustedPageLocation.scale(scaleFactor, scaleFactor);
59 }
60 }
61 } 56 }
62 57
63 m_clientLocation = adjustedPageLocation; 58 m_clientLocation = adjustedPageLocation;
64 m_pageLocation = adjustedPageLocation; 59 m_pageLocation = adjustedPageLocation;
65 60
66 initCoordinates(); 61 initCoordinates();
67 } 62 }
68 63
69 void MouseRelatedEvent::initCoordinates() 64 void MouseRelatedEvent::initCoordinates()
70 { 65 {
(...skipping 14 matching lines...) Expand all
85 // FIXME(sky): We don't need this anymore? 80 // FIXME(sky): We don't need this anymore?
86 m_pageLocation = clientLocation; 81 m_pageLocation = clientLocation;
87 82
88 m_layerLocation = m_pageLocation; 83 m_layerLocation = m_pageLocation;
89 m_offsetLocation = m_pageLocation; 84 m_offsetLocation = m_pageLocation;
90 85
91 computePageLocation(); 86 computePageLocation();
92 m_hasCachedRelativePosition = false; 87 m_hasCachedRelativePosition = false;
93 } 88 }
94 89
95 static float pageZoomFactor(const UIEvent* event)
96 {
97 LocalDOMWindow* window = event->view();
98 if (!window)
99 return 1;
100 LocalFrame* frame = window->frame();
101 if (!frame)
102 return 1;
103 return frame->pageZoomFactor();
104 }
105
106 void MouseRelatedEvent::computePageLocation() 90 void MouseRelatedEvent::computePageLocation()
107 { 91 {
108 float scaleFactor = pageZoomFactor(this); 92 setAbsoluteLocation(LayoutPoint(pageX(), pageY()));
109 setAbsoluteLocation(roundedLayoutPoint(FloatPoint(pageX() * scaleFactor, pag eY() * scaleFactor)));
110 } 93 }
111 94
112 void MouseRelatedEvent::receivedTarget() 95 void MouseRelatedEvent::receivedTarget()
113 { 96 {
114 m_hasCachedRelativePosition = false; 97 m_hasCachedRelativePosition = false;
115 } 98 }
116 99
117 void MouseRelatedEvent::computeRelativePosition() 100 void MouseRelatedEvent::computeRelativePosition()
118 { 101 {
119 Node* targetNode = target() ? target()->toNode() : 0; 102 Node* targetNode = target() ? target()->toNode() : 0;
120 if (!targetNode) 103 if (!targetNode)
121 return; 104 return;
122 105
123 // Compute coordinates that are based on the target. 106 // Compute coordinates that are based on the target.
124 m_layerLocation = m_pageLocation; 107 m_layerLocation = m_pageLocation;
125 m_offsetLocation = m_pageLocation; 108 m_offsetLocation = m_pageLocation;
126 109
127 // Must have an updated render tree for this math to work correctly. 110 // Must have an updated render tree for this math to work correctly.
128 targetNode->document().updateLayoutIgnorePendingStylesheets(); 111 targetNode->document().updateLayoutIgnorePendingStylesheets();
129 112
130 // Adjust offsetLocation to be relative to the target's position. 113 // Adjust offsetLocation to be relative to the target's position.
131 if (RenderObject* r = targetNode->renderer()) { 114 if (RenderObject* r = targetNode->renderer()) {
132 FloatPoint localPos = r->absoluteToLocal(absoluteLocation(), UseTransfor ms); 115 FloatPoint localPos = r->absoluteToLocal(absoluteLocation(), UseTransfor ms);
133 m_offsetLocation = roundedLayoutPoint(localPos); 116 m_offsetLocation = roundedLayoutPoint(localPos);
134 float scaleFactor = 1 / pageZoomFactor(this);
135 if (scaleFactor != 1.0f)
136 m_offsetLocation.scale(scaleFactor, scaleFactor);
137 } 117 }
138 118
139 // Adjust layerLocation to be relative to the layer. 119 // Adjust layerLocation to be relative to the layer.
140 // FIXME: event.layerX and event.layerY are poorly defined, 120 // FIXME: event.layerX and event.layerY are poorly defined,
141 // and probably don't always correspond to RenderLayer offsets. 121 // and probably don't always correspond to RenderLayer offsets.
142 // https://bugs.webkit.org/show_bug.cgi?id=21868 122 // https://bugs.webkit.org/show_bug.cgi?id=21868
143 Node* n = targetNode; 123 Node* n = targetNode;
144 while (n && !n->renderer()) 124 while (n && !n->renderer())
145 n = n->parentNode(); 125 n = n->parentNode();
146 126
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 // See Microsoft documentation and <http://www.quirksmode.org/dom/w3c_events .html>. 188 // See Microsoft documentation and <http://www.quirksmode.org/dom/w3c_events .html>.
209 return m_clientLocation.y(); 189 return m_clientLocation.y();
210 } 190 }
211 191
212 void MouseRelatedEvent::trace(Visitor* visitor) 192 void MouseRelatedEvent::trace(Visitor* visitor)
213 { 193 {
214 UIEventWithKeyState::trace(visitor); 194 UIEventWithKeyState::trace(visitor);
215 } 195 }
216 196
217 } // namespace blink 197 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/dom/TreeScope.cpp ('k') | sky/engine/core/frame/LocalFrame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698