Changeset 71244 in webkit
- Timestamp:
- Nov 3, 2010 10:02:40 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r71240 r71244 1 2010-11-03 Dimitri Glazkov <dglazkov@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 Implement shadow DOM-aware event targeting and introduce EventContext to track the context of each event dispatch. 6 https://bugs.webkit.org/show_bug.cgi?id=46015 7 8 Tuned shadow-boundary-crossing.html to better reflect its point: the event should indeed fire (it used to be swallowed), 9 but its target should be a non-shadow node. 10 11 Tweaked audio-delete-while-slider-thumb-clicked.html to actually click on 12 the scrubber thumb (it was off by 2 pixels). 13 14 * fast/events/shadow-boundary-crossing.html: Modified the test. 15 * media/audio-delete-while-slider-thumb-clicked.html : Ditto. 16 1 17 2010-11-03 Nikolas Zimmermann <nzimmermann@rim.com> 2 18 -
trunk/LayoutTests/fast/events/shadow-boundary-crossing.html
r70985 r71244 3 3 <title></title> 4 4 <script type="text/javascript"> 5 var fired = false; 5 var success; 6 var target; 6 7 7 8 function selectStart(event) 8 9 { 9 fired = true;10 success = event.target == target; 10 11 } 11 12 … … 16 17 layoutTestController.dumpAsText(); 17 18 18 vartarget = document.getElementById("target");19 target = document.getElementById("target"); 19 20 var x = target.offsetLeft + target.offsetWidth / 2; 20 21 var y = target.offsetTop + target.offsetHeight / 2; … … 24 25 eventSender.mouseUp(); 25 26 26 document.getElementById("result").innerText = fired? "FAIL" : "PASS";27 document.getElementById("result").innerText = !success ? "FAIL" : "PASS"; 27 28 } 28 29 -
trunk/LayoutTests/media/audio-delete-while-slider-thumb-clicked.html
r63684 r71244 51 51 var audio = document.getElementById('audio'); 52 52 53 var middle= audio.offsetLeft + (audio.offsetWidth / 2);54 var bottom = audio.offsetTop + audio.offsetHeight;53 var center = audio.offsetLeft + (audio.offsetWidth / 2); 54 var middle = audio.offsetTop + (audio.offsetHeight / 2); 55 55 56 var x = middle+ 16 + 16 + 8;57 var y = bottom - 8;56 var x = center + 16 + 16 + 8; 57 var y = middle; 58 58 59 59 // drag slider, leave the mouse down -
trunk/WebCore/Android.mk
r70985 r71244 133 133 dom/ErrorEvent.cpp \ 134 134 dom/Event.cpp \ 135 dom/EventContext.cpp \ 135 136 dom/EventNames.cpp \ 136 137 dom/EventTarget.cpp \ … … 193 194 dom/WebKitTransitionEvent.cpp \ 194 195 dom/WheelEvent.cpp \ 196 dom/WindowEventContext.cpp \ 195 197 dom/XMLDocumentParser.cpp \ 196 198 dom/XMLDocumentParserLibxml2.cpp \ -
trunk/WebCore/CMakeLists.txt
r71035 r71244 825 825 dom/ErrorEvent.cpp 826 826 dom/Event.cpp 827 dom/EventContext.cpp 827 828 dom/EventNames.cpp 828 829 dom/EventTarget.cpp … … 882 883 dom/WebKitTransitionEvent.cpp 883 884 dom/WheelEvent.cpp 885 dom/WindowEventContext.cpp 884 886 dom/XMLDocumentParser.cpp 885 887 dom/XMLDocumentParserLibxml2.cpp -
trunk/WebCore/ChangeLog
r71242 r71244 1 2010-11-03 Dimitri Glazkov <dglazkov@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 Implement shadow DOM-aware event targeting and introduce EventContext to track the context of each event dispatch. 6 https://bugs.webkit.org/show_bug.cgi?id=46015 7 8 This patch adds the notion of EventContext (and a very similar-acting WindowEventContext, specifically 9 for DOMWindow), an abstraction that carries information around dispatching an event for any given Node. 10 11 This abstraction is necessary to ensure that events, fired from shadow DOM nodes are properly retargeted to 12 appear as if they are coming from their host, thus never exposing the shadow DOM nodes to the world outside. 13 14 * Android.mk: Added EventContext, WindowEventContext files. 15 * CMakeLists.txt: Ditto. 16 * GNUmakefile.am: Ditto. 17 * WebCore.gypi: Ditto. 18 * WebCore.pro: Ditto. 19 * WebCore.xcodeproj/project.pbxproj: Ditto. 20 * WebCore.vcproj/WebCore.vcproj: Ditto. 21 * dom/ContainerNode.cpp: 22 (WebCore::notifyChildInserted): Changed to be shadow DOM-aware. 23 * dom/EventContext.cpp: Added. 24 * dom/EventContext.h: Added. 25 * dom/Node.cpp: 26 (WebCore::Node::markAncestorsWithChildNeedsStyleRecalc): Changed to be shadow DOM-aware. 27 (WebCore::Node::createRendererIfNeeded): Ditto. 28 (WebCore::Node::parentOrHostNode): Added new helper method. 29 (WebCore::Node::enclosingLinkEventParentOrSelf): Changed to be shadow DOM-aware. 30 (WebCore::eventTargetRespectingSVGTargetRules): Collapsed two helper methods into one. 31 (WebCore::Node::eventAncestors): Refactored to collect a vector of EventContexts. 32 (WebCore::Node::topEventContext): Added. 33 (WebCore::eventHasListeners): Changed to use EventContexts. 34 (WebCore::Node::dispatchGenericEvent): Ditto. 35 * dom/Node.h: Removed eventParentNode that's no longer needed, added parentOrHostNode decl, 36 and changed signature of eventAncestors to use EventContexts. 37 * dom/Text.cpp: 38 (WebCore::Text::createRenderer): Changed to be shadow DOM-aware. 39 * inspector/InspectorDOMAgent.cpp: 40 (WebCore::InspectorDOMAgent::getEventListenersForNode): Changed to use EventContexts. 41 * page/EventHandler.cpp: 42 (WebCore::EventHandler::updateMouseEventTargetNode): Removed code that's no longer necessary. 43 * rendering/ShadowElement.h: Made m_shadowParent a RefPtr to avoid stale references when parent 44 is deleted. 45 * svg/SVGElement.cpp: Removed eventParentNode that's no longer needed. 46 * svg/SVGElement.h: Ditto. 47 * dom/WindowEventContext.cpp: Added. 48 * dom/WindowEventContext.h: Added. 49 1 50 2010-11-02 Mikhail Naganov <mnaganov@chromium.org> 2 51 -
trunk/WebCore/GNUmakefile.am
r71227 r71244 1133 1133 WebCore/dom/ErrorEvent.h \ 1134 1134 WebCore/dom/Event.cpp \ 1135 WebCore/dom/Event.h \ 1136 WebCore/dom/EventContext.cpp \ 1137 WebCore/dom/EventContext.h \ 1135 1138 WebCore/dom/EventException.h \ 1136 WebCore/dom/Event.h \1137 1139 WebCore/dom/EventListener.h \ 1138 1140 WebCore/dom/EventNames.cpp \ … … 1262 1264 WebCore/dom/WheelEvent.cpp \ 1263 1265 WebCore/dom/WheelEvent.h \ 1266 WebCore/dom/WindowEventContext.cpp \ 1267 WebCore/dom/WindowEventContext.h \ 1264 1268 WebCore/dom/XMLDocumentParser.cpp \ 1265 1269 WebCore/dom/XMLDocumentParser.h \ -
trunk/WebCore/WebCore.gypi
r71227 r71244 1205 1205 'dom/Event.cpp', 1206 1206 'dom/Event.h', 1207 'dom/EventContext.cpp', 1208 'dom/EventContext.h', 1207 1209 'dom/EventException.h', 1208 1210 'dom/EventListener.h', … … 1340 1342 'dom/WheelEvent.cpp', 1341 1343 'dom/WheelEvent.h', 1344 'dom/WindowEventContext.cpp', 1345 'dom/WindowEventContext.h', 1342 1346 'dom/XMLDocumentParser.cpp', 1343 1347 'dom/XMLDocumentParser.h', -
trunk/WebCore/WebCore.pro
r71227 r71244 714 714 dom/ErrorEvent.cpp \ 715 715 dom/Event.cpp \ 716 dom/EventContext.cpp \ 716 717 dom/EventNames.cpp \ 717 718 dom/EventTarget.cpp \ … … 774 775 dom/WebKitTransitionEvent.cpp \ 775 776 dom/WheelEvent.cpp \ 777 dom/WindowEventContext.cpp \ 776 778 dom/XMLDocumentParser.cpp \ 777 779 dom/XMLDocumentParserQt.cpp \ -
trunk/WebCore/WebCore.vcproj/WebCore.vcproj
r71227 r71244 42253 42253 </File> 42254 42254 <File 42255 RelativePath="..\dom\EventContext.cpp" 42256 > 42257 <FileConfiguration 42258 Name="Debug|Win32" 42259 ExcludedFromBuild="true" 42260 > 42261 <Tool 42262 Name="VCCLCompilerTool" 42263 /> 42264 </FileConfiguration> 42265 <FileConfiguration 42266 Name="Release|Win32" 42267 ExcludedFromBuild="true" 42268 > 42269 <Tool 42270 Name="VCCLCompilerTool" 42271 /> 42272 </FileConfiguration> 42273 <FileConfiguration 42274 Name="Debug_Internal|Win32" 42275 ExcludedFromBuild="true" 42276 > 42277 <Tool 42278 Name="VCCLCompilerTool" 42279 /> 42280 </FileConfiguration> 42281 <FileConfiguration 42282 Name="Debug_Cairo|Win32" 42283 ExcludedFromBuild="true" 42284 > 42285 <Tool 42286 Name="VCCLCompilerTool" 42287 /> 42288 </FileConfiguration> 42289 <FileConfiguration 42290 Name="Release_Cairo|Win32" 42291 ExcludedFromBuild="true" 42292 > 42293 <Tool 42294 Name="VCCLCompilerTool" 42295 /> 42296 </FileConfiguration> 42297 <FileConfiguration 42298 Name="Debug_All|Win32" 42299 ExcludedFromBuild="true" 42300 > 42301 <Tool 42302 Name="VCCLCompilerTool" 42303 /> 42304 </FileConfiguration> 42305 </File> 42306 <File 42307 RelativePath="..\dom\EventContext.h" 42308 > 42309 </File> 42310 <File 42255 42311 RelativePath="..\dom\EventException.h" 42256 42312 > … … 45338 45394 <File 45339 45395 RelativePath="..\dom\WheelEvent.h" 45396 > 45397 </File> 45398 <File 45399 RelativePath="..\dom\WindowEventContext.cpp" 45400 > 45401 <FileConfiguration 45402 Name="Debug|Win32" 45403 ExcludedFromBuild="true" 45404 > 45405 <Tool 45406 Name="VCCLCompilerTool" 45407 /> 45408 </FileConfiguration> 45409 <FileConfiguration 45410 Name="Release|Win32" 45411 ExcludedFromBuild="true" 45412 > 45413 <Tool 45414 Name="VCCLCompilerTool" 45415 /> 45416 </FileConfiguration> 45417 <FileConfiguration 45418 Name="Debug_Internal|Win32" 45419 ExcludedFromBuild="true" 45420 > 45421 <Tool 45422 Name="VCCLCompilerTool" 45423 /> 45424 </FileConfiguration> 45425 <FileConfiguration 45426 Name="Debug_Cairo|Win32" 45427 ExcludedFromBuild="true" 45428 > 45429 <Tool 45430 Name="VCCLCompilerTool" 45431 /> 45432 </FileConfiguration> 45433 <FileConfiguration 45434 Name="Release_Cairo|Win32" 45435 ExcludedFromBuild="true" 45436 > 45437 <Tool 45438 Name="VCCLCompilerTool" 45439 /> 45440 </FileConfiguration> 45441 <FileConfiguration 45442 Name="Debug_All|Win32" 45443 ExcludedFromBuild="true" 45444 > 45445 <Tool 45446 Name="VCCLCompilerTool" 45447 /> 45448 </FileConfiguration> 45449 </File> 45450 <File 45451 RelativePath="..\dom\WindowEventContext.h" 45340 45452 > 45341 45453 </File> -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r71227 r71244 895 895 411046410FA222A600BA436A /* ScriptEventListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 4110463F0FA222A600BA436A /* ScriptEventListener.h */; }; 896 896 411046420FA222A600BA436A /* ScriptEventListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 411046400FA222A600BA436A /* ScriptEventListener.cpp */; }; 897 4123E569127B3041000FEEA7 /* WindowEventContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 4123E567127B3041000FEEA7 /* WindowEventContext.h */; }; 898 4123E56A127B3041000FEEA7 /* WindowEventContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4123E568127B3041000FEEA7 /* WindowEventContext.cpp */; }; 897 899 4127D5370F8AAB1D00E424F5 /* ScriptState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4127D5360F8AAB1D00E424F5 /* ScriptState.cpp */; }; 900 4138D3351244054800323D33 /* EventContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 4138D3331244054800323D33 /* EventContext.h */; }; 901 4138D3361244054800323D33 /* EventContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4138D3341244054800323D33 /* EventContext.cpp */; }; 898 902 4162A450101145AE00DFF3ED /* DedicatedWorkerContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4162A44D101145AE00DFF3ED /* DedicatedWorkerContext.cpp */; }; 899 903 4162A451101145AE00DFF3ED /* DedicatedWorkerContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 4162A44E101145AE00DFF3ED /* DedicatedWorkerContext.h */; }; … … 6962 6966 4110463F0FA222A600BA436A /* ScriptEventListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptEventListener.h; sourceTree = "<group>"; }; 6963 6967 411046400FA222A600BA436A /* ScriptEventListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptEventListener.cpp; sourceTree = "<group>"; }; 6968 4123E567127B3041000FEEA7 /* WindowEventContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WindowEventContext.h; sourceTree = "<group>"; }; 6969 4123E568127B3041000FEEA7 /* WindowEventContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WindowEventContext.cpp; sourceTree = "<group>"; }; 6964 6970 4127D5360F8AAB1D00E424F5 /* ScriptState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptState.cpp; sourceTree = "<group>"; }; 6971 4138D3331244054800323D33 /* EventContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventContext.h; sourceTree = "<group>"; }; 6972 4138D3341244054800323D33 /* EventContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventContext.cpp; sourceTree = "<group>"; }; 6965 6973 4162A44D101145AE00DFF3ED /* DedicatedWorkerContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DedicatedWorkerContext.cpp; path = workers/DedicatedWorkerContext.cpp; sourceTree = "<group>"; }; 6966 6974 4162A44E101145AE00DFF3ED /* DedicatedWorkerContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DedicatedWorkerContext.h; path = workers/DedicatedWorkerContext.h; sourceTree = "<group>"; }; … … 18173 18181 85031B2C0A44EFC700F992E0 /* Event.h */, 18174 18182 14E836D209F8512000B85AE4 /* Event.idl */, 18183 4138D3341244054800323D33 /* EventContext.cpp */, 18184 4138D3331244054800323D33 /* EventContext.h */, 18175 18185 BC60D9090D2A17CE00B9918F /* EventException.h */, 18176 18186 BC60D90A0D2A17CE00B9918F /* EventException.idl */, … … 18333 18343 85031B3B0A44EFC700F992E0 /* WheelEvent.h */, 18334 18344 93EEC1F709C2877700C515D1 /* WheelEvent.idl */, 18345 4123E568127B3041000FEEA7 /* WindowEventContext.cpp */, 18346 4123E567127B3041000FEEA7 /* WindowEventContext.h */, 18335 18347 F523D30902DE4476018635CA /* XMLDocumentParser.cpp */, 18336 18348 F523D30A02DE4476018635CA /* XMLDocumentParser.h */, … … 19496 19508 2ECF7AE210162B5800427DE7 /* ErrorEvent.h in Headers */, 19497 19509 85031B420A44EFC700F992E0 /* Event.h in Headers */, 19510 4138D3351244054800323D33 /* EventContext.h in Headers */, 19498 19511 BC60D90C0D2A17CE00B9918F /* EventException.h in Headers */, 19499 19512 93C09A530B064DB3005ABD4D /* EventHandler.h in Headers */, … … 21160 21173 9380F47409A11AB4001FDB34 /* Widget.h in Headers */, 21161 21174 939B02EF0EA2DBC400C54570 /* WidthIterator.h in Headers */, 21175 4123E569127B3041000FEEA7 /* WindowEventContext.h in Headers */, 21162 21176 BC8243E90D0CFD7500460C8F /* WindowFeatures.h in Headers */, 21163 21177 E1E1BF00115FF6FB006F52CA /* WindowsKeyboardCodes.h in Headers */, … … 22129 22143 2ECF7AE110162B5800427DE7 /* ErrorEvent.cpp in Sources */, 22130 22144 85031B410A44EFC700F992E0 /* Event.cpp in Sources */, 22145 4138D3361244054800323D33 /* EventContext.cpp in Sources */, 22131 22146 93C09A810B064F00005ABD4D /* EventHandler.cpp in Sources */, 22132 22147 93C09A7F0B064EEF005ABD4D /* EventHandlerMac.mm in Sources */, … … 23728 23743 9380F47809A11ACC001FDB34 /* WidgetMac.mm in Sources */, 23729 23744 939B02EE0EA2DBC400C54570 /* WidthIterator.cpp in Sources */, 23745 4123E56A127B3041000FEEA7 /* WindowEventContext.cpp in Sources */, 23730 23746 BC8243E80D0CFD7500460C8F /* WindowFeatures.cpp in Sources */, 23731 23747 08203A9F0ED8C35300B8B61A /* WMLAccessElement.cpp in Sources */, -
trunk/WebCore/dom/ContainerNode.cpp
r70985 r71244 1006 1006 RefPtr<Document> document = child->document(); 1007 1007 1008 if (c->parentNode() && c->parentNode()->inDocument()) 1008 Node* parentOrHostNode = c->parentOrHostNode(); 1009 if (parentOrHostNode && parentOrHostNode->inDocument()) 1009 1010 c->insertedIntoDocument(); 1010 1011 else -
trunk/WebCore/dom/Node.cpp
r70985 r71244 46 46 #include "Element.h" 47 47 #include "Event.h" 48 #include "EventContext.h" 48 49 #include "EventException.h" 49 50 #include "EventHandler.h" … … 81 82 #include "WebKitTransitionEvent.h" 82 83 #include "WheelEvent.h" 84 #include "WindowEventContext.h" 83 85 #include "XMLNames.h" 84 86 #include "htmlediting.h" … … 735 737 inline void Node::markAncestorsWithChildNeedsStyleRecalc() 736 738 { 737 for (ContainerNode* p = parent Node(); p && !p->childNeedsStyleRecalc(); p = p->parentNode())739 for (ContainerNode* p = parentOrHostNode(); p && !p->childNeedsStyleRecalc(); p = p->parentOrHostNode()) 738 740 p->setChildNeedsStyleRecalc(); 739 741 740 742 if (document()->childNeedsStyleRecalc()) 741 743 document()->scheduleStyleRecalc(); … … 1322 1324 ASSERT(!renderer()); 1323 1325 1324 ContainerNode* parent = parent Node();1326 ContainerNode* parent = parentOrHostNode(); 1325 1327 ASSERT(parent); 1326 1328 … … 2240 2242 } 2241 2243 2242 ContainerNode* Node::eventParentNode()2243 {2244 return parentNode();2245 }2246 2247 2244 Node* Node::enclosingLinkEventParentOrSelf() 2248 2245 { 2249 for (Node* node = this; node; node = node-> eventParentNode()) {2246 for (Node* node = this; node; node = node->parentOrHostNode()) { 2250 2247 // For imagemaps, the enclosing link node is the associated area element not the image itself. 2251 2248 // So we don't let images be the enclosingLinkNode, even though isLink sometimes returns true … … 2485 2482 } 2486 2483 2484 static inline EventTarget* eventTargetRespectingSVGTargetRules(Node* referenceNode) 2485 { 2486 ASSERT(referenceNode); 2487 2487 2488 #if ENABLE(SVG) 2488 static inline SVGElementInstance* eventTargetAsSVGElementInstance(Node* referenceNode)2489 {2490 ASSERT(referenceNode);2491 2489 if (!referenceNode->isSVGElement()) 2492 return 0;2490 return referenceNode; 2493 2491 2494 2492 // Spec: The event handling for the non-exposed tree works as if the referenced element had been textually included … … 2504 2502 return instance; 2505 2503 } 2506 2507 return 0;2508 }2509 2504 #endif 2510 2505 2511 static inline EventTarget* eventTargetRespectingSVGTargetRules(Node* referenceNode) 2512 { 2513 ASSERT(referenceNode); 2506 return referenceNode; 2507 } 2508 2509 void Node::getEventAncestors(Vector<EventContext>& ancestors, EventTarget* originalTarget) 2510 { 2511 if (!inDocument()) 2512 return; 2513 2514 EventTarget* target = originalTarget; 2515 Node* ancestor = this; 2516 bool shouldSkipNextAncestor = false; 2517 while (true) { 2518 if (ancestor->isShadowNode()) { 2519 ancestor = ancestor->shadowParentNode(); 2520 if (!shouldSkipNextAncestor) 2521 target = ancestor; 2522 } else 2523 ancestor = ancestor->parentNode(); 2524 2525 if (!ancestor) 2526 return; 2514 2527 2515 2528 #if ENABLE(SVG) 2516 if (SVGElementInstance* instance = eventTargetAsSVGElementInstance(referenceNode)) {2517 ASSERT(instance->shadowTreeElement() == referenceNode);2518 return instance;2519 }2529 // Skip SVGShadowTreeRootElement. 2530 shouldSkipNextAncestor = ancestor->isSVGElement() && ancestor->isShadowNode(); 2531 if (shouldSkipNextAncestor) 2532 continue; 2520 2533 #endif 2521 2522 return referenceNode; 2523 } 2524 2525 void Node::eventAncestors(Vector<RefPtr<ContainerNode> > &ancestors) 2526 { 2527 if (inDocument()) { 2528 for (ContainerNode* ancestor = eventParentNode(); ancestor; ancestor = ancestor->eventParentNode()) { 2529 #if ENABLE(SVG) 2530 // Skip <use> shadow tree elements. 2531 if (ancestor->isSVGElement() && ancestor->isShadowNode()) 2532 continue; 2533 #endif 2534 ancestors.append(ancestor); 2535 } 2534 // FIXME: Unroll the extra loop inside eventTargetRespectingSVGTargetRules into this loop. 2535 ancestors.append(EventContext(ancestor, eventTargetRespectingSVGTargetRules(ancestor), target)); 2536 2536 2537 } 2537 2538 } … … 2546 2547 RefPtr<FrameView> view = document()->view(); 2547 2548 return dispatchGenericEvent(event.release()); 2549 } 2550 2551 static const EventContext* topEventContext(const Vector<EventContext>& ancestors) 2552 { 2553 return ancestors.isEmpty() ? 0 : &(ancestors.last()); 2548 2554 } 2549 2555 … … 2560 2566 // Be sure to ref all of nodes since event handlers could result in the last reference going away. 2561 2567 RefPtr<Node> thisNode(this); 2562 Vector<RefPtr<ContainerNode> > ancestors; 2563 eventAncestors(ancestors); 2564 2565 // Set up a pointer to indicate whether / where to dispatch window events. 2566 // We don't dispatch load events to the window. That quirk was originally 2567 // added because Mozilla doesn't propagate load events to the window object. 2568 DOMWindow* targetForWindowEvents = 0; 2569 if (event->type() != eventNames().loadEvent) { 2570 Node* topLevelContainer = ancestors.isEmpty() ? this : ancestors.last().get(); 2571 if (topLevelContainer->isDocumentNode()) 2572 targetForWindowEvents = static_cast<Document*>(topLevelContainer)->domWindow(); 2573 } 2574 2575 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDispatchEvent(document(), *event, targetForWindowEvents, this, ancestors); 2568 RefPtr<EventTarget> originalTarget = event->target(); 2569 Vector<EventContext> ancestors; 2570 getEventAncestors(ancestors, originalTarget.get()); 2571 2572 WindowEventContext windowContext(event.get(), this, topEventContext(ancestors)); 2573 2574 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDispatchEvent(document(), *event, windowContext.window(), this, ancestors); 2576 2575 2577 2576 // Give the target node a chance to do some work before DOM event handlers get a crack. … … 2583 2582 event->setEventPhase(Event::CAPTURING_PHASE); 2584 2583 2585 if (targetForWindowEvents) { 2586 event->setCurrentTarget(targetForWindowEvents); 2587 targetForWindowEvents->fireEventListeners(event.get()); 2584 if (windowContext.handleLocalEvents(event.get()) && event->propagationStopped()) 2585 goto doneDispatching; 2586 2587 for (size_t i = ancestors.size(); i; --i) { 2588 ancestors[i - 1].handleLocalEvents(event.get()); 2588 2589 if (event->propagationStopped()) 2589 2590 goto doneDispatching; 2590 2591 } 2591 for (size_t i = ancestors.size(); i; --i) {2592 ContainerNode* ancestor = ancestors[i - 1].get();2593 event->setCurrentTarget(eventTargetRespectingSVGTargetRules(ancestor));2594 ancestor->handleLocalEvents(event.get());2595 if (event->propagationStopped())2596 goto doneDispatching;2597 }2598 2592 2599 2593 event->setEventPhase(Event::AT_TARGET); 2600 2594 event->setTarget(originalTarget.get()); 2601 2595 event->setCurrentTarget(eventTargetRespectingSVGTargetRules(this)); 2602 2596 handleLocalEvents(event.get()); … … 2610 2604 size_t size = ancestors.size(); 2611 2605 for (size_t i = 0; i < size; ++i) { 2612 ContainerNode* ancestor = ancestors[i].get(); 2613 event->setCurrentTarget(eventTargetRespectingSVGTargetRules(ancestor)); 2614 ancestor->handleLocalEvents(event.get()); 2606 ancestors[i].handleLocalEvents(event.get()); 2615 2607 if (event->propagationStopped() || event->cancelBubble()) 2616 2608 goto doneDispatching; 2617 2609 } 2618 if (targetForWindowEvents) { 2619 event->setCurrentTarget(targetForWindowEvents); 2620 targetForWindowEvents->fireEventListeners(event.get()); 2621 if (event->propagationStopped() || event->cancelBubble()) 2622 goto doneDispatching; 2623 } 2610 windowContext.handleLocalEvents(event.get()); 2624 2611 } 2625 2612 2626 2613 doneDispatching: 2614 event->setTarget(originalTarget.get()); 2627 2615 event->setCurrentTarget(0); 2628 2616 event->setEventPhase(0); … … 2645 2633 size_t size = ancestors.size(); 2646 2634 for (size_t i = 0; i < size; ++i) { 2647 ContainerNode* ancestor = ancestors[i].get(); 2648 ancestor->defaultEventHandler(event.get()); 2635 ancestors[i].node()->defaultEventHandler(event.get()); 2649 2636 ASSERT(!event->defaultPrevented()); 2650 2637 if (event->defaultHandled()) -
trunk/WebCore/dom/Node.h
r70985 r71244 50 50 class Element; 51 51 class Event; 52 class EventContext; 52 53 class EventListener; 53 54 class FloatPoint; … … 205 206 Node* shadowTreeRootNode(); 206 207 bool isInShadowTree(); 207 208 // The node's parent for the purpose of event capture and bubbling. 209 virtual ContainerNode* eventParentNode(); 208 // Node's parent or shadow tree host. 209 ContainerNode* parentOrHostNode(); 210 210 211 211 // Returns the enclosing event parent node (or self) that, when clicked, would trigger a navigation. … … 213 213 214 214 // Node ancestors when concerned about event flow. 215 // FIXME: Should be named getEventAncestors. 216 void eventAncestors(Vector<RefPtr<ContainerNode> > &ancestors); 215 void getEventAncestors(Vector<EventContext>& ancestors, EventTarget*); 217 216 218 217 bool isBlockFlow() const; … … 694 693 } 695 694 695 inline ContainerNode* Node::parentOrHostNode() 696 { 697 if (ContainerNode* parent = parentNode()) 698 return parent; 699 return shadowParentNode(); 700 } 701 696 702 } //namespace 697 703 -
trunk/WebCore/dom/Text.cpp
r70985 r71244 240 240 RenderObject* Text::createRenderer(RenderArena* arena, RenderStyle*) 241 241 { 242 Node* parentOrHost = parentOrHostNode(); 242 243 #if ENABLE(SVG) 243 if (parent Node()->isSVGElement()244 if (parentOrHost->isSVGElement() 244 245 #if ENABLE(SVG_FOREIGN_OBJECT) 245 && !parent Node()->hasTagName(SVGNames::foreignObjectTag)246 && !parentOrHost->hasTagName(SVGNames::foreignObjectTag) 246 247 #endif 247 248 ) -
trunk/WebCore/inspector/InspectorDOMAgent.cpp
r70985 r71244 52 52 #include "DocumentType.h" 53 53 #include "Event.h" 54 #include "EventContext.h" 54 55 #include "EventListener.h" 55 56 #include "EventNames.h" … … 608 609 609 610 // The Node's Event Ancestors (not including self) 610 Vector< RefPtr<ContainerNode>> ancestors;611 node-> eventAncestors(ancestors);611 Vector<EventContext> ancestors; 612 node->getEventAncestors(ancestors, node); 612 613 613 614 // Nodes and their Listeners for the concerned event types (order is top to bottom) 614 615 Vector<EventListenerInfo> eventInformation; 615 616 for (size_t i = ancestors.size(); i; --i) { 616 ContainerNode* ancestor = ancestors[i - 1].get();617 Node* ancestor = ancestors[i - 1].node(); 617 618 for (size_t j = 0; j < eventTypesLength; ++j) { 618 619 AtomicString& type = eventTypes[j]; -
trunk/WebCore/inspector/InspectorInstrumentation.cpp
r70985 r71244 36 36 #include "DOMWindow.h" 37 37 #include "Event.h" 38 #include "EventContext.h" 38 39 #include "InspectorController.h" 39 40 #include "InspectorDOMAgent.h" … … 54 55 int InspectorInstrumentation::s_frontendCounter = 0; 55 56 56 static bool eventHasListeners(const AtomicString& eventType, DOMWindow* window, Node* node, const Vector< RefPtr<ContainerNode>>& ancestors)57 static bool eventHasListeners(const AtomicString& eventType, DOMWindow* window, Node* node, const Vector<EventContext>& ancestors) 57 58 { 58 59 if (window && window->hasEventListeners(eventType)) … … 63 64 64 65 for (size_t i = 0; i < ancestors.size(); i++) { 65 ContainerNode* ancestor = ancestors[i].get();66 Node* ancestor = ancestors[i].node(); 66 67 if (ancestor->hasEventListeners(eventType)) 67 68 return true; … … 139 140 domAgent->characterDataModified(characterData); 140 141 } 141 142 142 143 143 void InspectorInstrumentation::willSendXMLHttpRequestImpl(InspectorController* inspectorController, const String& url) … … 214 214 } 215 215 216 InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventImpl(InspectorController* inspectorController, const Event& event, DOMWindow* window, Node* node, const Vector< RefPtr<ContainerNode>>& ancestors)216 InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventImpl(InspectorController* inspectorController, const Event& event, DOMWindow* window, Node* node, const Vector<EventContext>& ancestors) 217 217 { 218 218 pauseOnNativeEventIfNeeded(inspectorController, listenerEventCategoryType, event.type(), false); -
trunk/WebCore/inspector/InspectorInstrumentation.h
r70985 r71244 41 41 class CharacterData; 42 42 class Element; 43 class EventContext; 43 44 class InspectorController; 44 45 class InspectorTimelineAgent; … … 74 75 static InspectorInstrumentationCookie willChangeXHRReadyState(ScriptExecutionContext*, XMLHttpRequest* request); 75 76 static void didChangeXHRReadyState(const InspectorInstrumentationCookie&); 76 static InspectorInstrumentationCookie willDispatchEvent(Document*, const Event& event, DOMWindow* window, Node* node, const Vector< RefPtr<ContainerNode>>& ancestors);77 static InspectorInstrumentationCookie willDispatchEvent(Document*, const Event& event, DOMWindow* window, Node* node, const Vector<EventContext>& ancestors); 77 78 static void didDispatchEvent(const InspectorInstrumentationCookie&); 78 79 static InspectorInstrumentationCookie willDispatchEventOnWindow(Frame*, const Event& event, DOMWindow* window); … … 131 132 static InspectorInstrumentationCookie willChangeXHRReadyStateImpl(InspectorController*, XMLHttpRequest* request); 132 133 static void didChangeXHRReadyStateImpl(const InspectorInstrumentationCookie&); 133 static InspectorInstrumentationCookie willDispatchEventImpl(InspectorController*, const Event& event, DOMWindow* window, Node* node, const Vector< RefPtr<ContainerNode>>& ancestors);134 static InspectorInstrumentationCookie willDispatchEventImpl(InspectorController*, const Event& event, DOMWindow* window, Node* node, const Vector<EventContext>& ancestors); 134 135 static void didDispatchEventImpl(const InspectorInstrumentationCookie&); 135 136 static InspectorInstrumentationCookie willDispatchEventOnWindowImpl(InspectorController*, const Event& event, DOMWindow* window); … … 226 227 } 227 228 228 229 229 inline void InspectorInstrumentation::willSendXMLHttpRequest(ScriptExecutionContext* context, const String& url) 230 230 { … … 294 294 } 295 295 296 inline InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEvent(Document* document, const Event& event, DOMWindow* window, Node* node, const Vector< RefPtr<ContainerNode>>& ancestors)296 inline InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEvent(Document* document, const Event& event, DOMWindow* window, Node* node, const Vector<EventContext>& ancestors) 297 297 { 298 298 #if ENABLE(INSPECTOR) -
trunk/WebCore/page/EventHandler.cpp
r70985 r71244 1767 1767 if (result && result->isTextNode()) 1768 1768 result = result->parentNode(); 1769 if (result)1770 result = result->shadowAncestorNode();1771 1769 } 1772 1770 m_nodeUnderMouse = result; -
trunk/WebCore/rendering/ShadowElement.h
r65852 r71244 44 44 } 45 45 46 HTMLElement* shadowParent() const { return m_shadowParent ; }46 HTMLElement* shadowParent() const { return m_shadowParent.get(); } 47 47 48 48 private: 49 49 virtual bool isShadowNode() const { return true; } 50 virtual ContainerNode* shadowParentNode() { return m_shadowParent ; }50 virtual ContainerNode* shadowParentNode() { return m_shadowParent.get(); } 51 51 52 HTMLElement*m_shadowParent;52 RefPtr<HTMLElement> m_shadowParent; 53 53 }; 54 54 -
trunk/WebCore/svg/SVGElement.cpp
r70985 r71244 348 348 } 349 349 350 ContainerNode* SVGElement::eventParentNode()351 {352 if (ContainerNode* shadowParent = shadowParentNode())353 return shadowParent;354 return StyledElement::eventParentNode();355 }356 357 350 } 358 351 -
trunk/WebCore/svg/SVGElement.h
r70985 r71244 100 100 virtual bool isSupported(StringImpl* feature, StringImpl* version) const; 101 101 102 virtual ContainerNode* eventParentNode();103 104 102 virtual bool needsPendingResourceHandling() const { return true; } 105 103 virtual void buildPendingResource() { }
Note: See TracChangeset
for help on using the changeset viewer.