Changeset 12514 in webkit
- Timestamp:
- Feb 1, 2006 2:36:00 PM (18 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r12513 r12514 1 2006-02-01 Darin Adler <darin@apple.com> 2 3 Reviewed by Beth. 4 5 Fix for <rdar://problem/4424126> REGRESSION(412-420+): yellow 6 highlight fails to follow cursor when mousing over star rating 7 (6232) 8 9 Event coordinates cannot be calculated until there is a target. 10 This patch restructures the code so that the coordinates are 11 initialized when the mouse event is created but are not calculated 12 until the target is set. 13 14 * khtml/xml/dom2_eventsimpl.cpp: 15 (WebCore::EventImpl::setTarget): Now calls receievdTarget() if the 16 target is not nil. 17 (WebCore::EventImpl::receivedTarget): virtual receivedTarget() 18 (WebCore::MouseRelatedEventImpl::MouseRelatedEventImpl): Call 19 initCoordinates() 20 (WebCore::MouseRelatedEventImpl::initCoordinates): Formerly called 21 computePositions(), this now only initializes the coordinates and 22 lets receivedTarget() take care of the computations. 23 (WebCore::MouseRelatedEventImpl::receivedTarget): Takes care of 24 computing the coordinates. 25 (WebCore::MouseEventImpl::initMouseEvent): Call initCoordinates() 26 * khtml/xml/dom2_eventsimpl.h: 27 (WebCore::EventImpl::target): Fix spacing. 28 (WebCore::EventImpl::currentTarget): Same. 29 (WebCore::EventImpl::setCurrentTarget): Same. 30 1 31 2006-01-31 Maciej Stachowiak <mjs@apple.com> 2 32 -
trunk/WebCore/khtml/xml/dom2_eventsimpl.cpp
r12474 r12514 123 123 } 124 124 125 void EventImpl::setTarget(NodeImpl* target) 126 { 127 m_target = target; 128 if (target) 129 receivedTarget(); 130 } 131 132 void EventImpl::receivedTarget() 133 { 134 } 135 125 136 // ----------------------------------------------------------------------------- 126 137 … … 219 230 , m_clientX(clientXArg), m_clientY(clientYArg) 220 231 { 221 computePositions(); 222 } 223 224 void MouseRelatedEventImpl::computePositions() 225 { 232 initCoordinates(); 233 } 234 235 void MouseRelatedEventImpl::initCoordinates() 236 { 237 // Set up initial values for coordinates. 238 // Correct values can't be computed until we have at target, so receivedTarget 239 // does the "real" computation. 226 240 m_pageX = m_clientX; 227 241 m_pageY = m_clientY; 228 229 242 m_layerX = m_pageX; 230 243 m_layerY = m_pageY; 231 232 244 m_offsetX = m_pageX; 233 245 m_offsetY = m_pageY; 234 235 AbstractViewImpl* av = view(); 236 if (!av) 237 return; 238 DocumentImpl* doc = av->document(); 246 } 247 248 void MouseRelatedEventImpl::receivedTarget() 249 { 250 // Compute coordinates that are based on the target. 251 m_offsetX = m_pageX; 252 m_offsetY = m_pageY; 253 m_layerX = m_pageX; 254 m_layerY = m_pageY; 255 256 // Can't do anything if the target is not in a document. 257 NodeImpl* targ = target(); 258 ASSERT(targ); 259 DocumentImpl* doc = targ->getDocument(); 239 260 if (!doc) 240 261 return; 241 FrameView* kv = doc->view(); 242 if (!kv) 243 return; 244 262 263 // Must have an updated render tree for this math to work correctly. 245 264 doc->updateRendering(); 246 265 … … 251 270 // pageX and pageY here. 252 271 253 // Compute offset position. 254 // FIXME: This won't work because setTarget wasn't called yet! 255 m_offsetX = m_pageX; 256 m_offsetY = m_pageY; 272 // Adjust offsetX/Y to be relative to the target's position. 257 273 if (!isSimulated()) { 258 if (NodeImpl *n = target()) 259 if (RenderObject *r = n->renderer()) { 260 int rx, ry; 261 if (r->absolutePosition(rx, ry)) { 262 m_offsetX -= rx; 263 m_offsetY -= ry; 264 } 274 if (RenderObject* r = targ->renderer()) { 275 int rx, ry; 276 if (r->absolutePosition(rx, ry)) { 277 m_offsetX -= rx; 278 m_offsetY -= ry; 265 279 } 280 } 266 281 } 267 282 268 // Compute layer position. 269 m_layerX = m_pageX; 270 m_layerY = m_pageY; 271 if (RenderObject* docRenderer = doc->renderer()) { 272 // FIXME: Should we use the target node instead of hit testing? 273 // If we want to, then we'll have to wait until setTarget is called. 274 RenderObject::NodeInfo hitTestResult(true, false); 275 docRenderer->layer()->hitTest(hitTestResult, m_pageX, m_pageY); 276 NodeImpl* n = hitTestResult.innerNonSharedNode(); 277 while (n && !n->renderer()) 278 n = n->parent(); 279 if (n) { 280 n->renderer()->enclosingLayer()->updateLayerPosition(); 281 for (RenderLayer* layer = n->renderer()->enclosingLayer(); layer; layer = layer->parent()) { 282 m_layerX -= layer->xPos(); 283 m_layerY -= layer->yPos(); 284 } 283 // Adjust layerX/Y to be relative to the layer. 284 // FIXME: We're pretty sure this is the wrong defintion of "layer." 285 // Our RenderLayer is a more modern concept, and layerX/Y is some 286 // other notion about groups of elements; we should test and fix this. 287 NodeImpl* n = targ; 288 while (n && !n->renderer()) 289 n = n->parent(); 290 if (n) { 291 RenderLayer* layer = n->renderer()->enclosingLayer(); 292 layer->updateLayerPosition(); 293 for (; layer; layer = layer->parent()) { 294 m_layerX -= layer->xPos(); 295 m_layerY -= layer->yPos(); 285 296 } 286 297 } … … 381 392 m_relatedTarget = relatedTargetArg; 382 393 383 computePositions();394 initCoordinates(); 384 395 } 385 396 -
trunk/WebCore/khtml/xml/dom2_eventsimpl.h
r12492 r12514 46 46 public: 47 47 EventImpl(); 48 EventImpl(const AtomicString &type, bool canBubbleArg, bool cancelableArg);48 EventImpl(const AtomicString& type, bool canBubbleArg, bool cancelableArg); 49 49 virtual ~EventImpl(); 50 50 51 51 const AtomicString &type() const { return m_type; } 52 NodeImpl *target() const { return m_target.get(); }53 void setTarget(NodeImpl *target) { m_target = target; }54 NodeImpl *currentTarget() const { return m_currentTarget; }55 void setCurrentTarget(NodeImpl *currentTarget) { m_currentTarget = currentTarget; }52 NodeImpl* target() const { return m_target.get(); } 53 void setTarget(NodeImpl*); 54 NodeImpl* currentTarget() const { return m_currentTarget; } 55 void setCurrentTarget(NodeImpl* currentTarget) { m_currentTarget = currentTarget; } 56 56 unsigned short eventPhase() const { return m_eventPhase; } 57 57 void setEventPhase(unsigned short eventPhase) { m_eventPhase = eventPhase; } … … 85 85 86 86 protected: 87 virtual void receivedTarget(); 87 88 bool dispatched() const { return m_target; } 88 89 … … 97 98 bool m_cancelBubble; 98 99 99 NodeImpl *m_currentTarget; // ref > 0 maintained externally100 NodeImpl* m_currentTarget; // ref > 0 maintained externally 100 101 unsigned short m_eventPhase; 101 102 RefPtr<NodeImpl> m_target; … … 193 194 int m_clientX; 194 195 int m_clientY; 195 void computePositions(); 196 void initCoordinates(); 197 virtual void receivedTarget(); 196 198 private: 197 199 int m_pageX;
Note: See TracChangeset
for help on using the changeset viewer.