void EventDispatcher::ensureEventAncestors(Event* event) { if (m_ancestorsInitialized) return; m_ancestorsInitialized = true; bool inDocument = m_node->inDocument(); bool isSVGElement = m_node->isSVGElement(); Vector<EventTarget*, 32> targetStack; for (AncestorChainWalker walker(m_node.get()); walker.get(); walker.parent()) { Node* node = walker.get(); if (targetStack.isEmpty()) targetStack.append(eventTargetRespectingTargetRules(node)); else if (walker.crossingInsertionPoint()) targetStack.append(targetStack.last()); m_ancestors.append(EventContext(node, eventTargetRespectingTargetRules(node), targetStack.last())); if (!inDocument) return; if (!node->isShadowRoot()) continue; if (determineDispatchBehavior(event, toShadowRoot(node), targetStack.last()) == StayInsideShadowDOM) return; if (!isSVGElement) { ASSERT(!targetStack.isEmpty()); targetStack.removeLast(); } } }
void EventDispatcher::ensureEventAncestors(Event* event) { if (m_ancestorsInitialized) return; m_ancestorsInitialized = true; bool inDocument = m_node->inDocument(); bool isSVGElement = m_node->isSVGElement(); Vector<EventTarget*> targetStack; Node* last = 0; for (ComposedShadowTreeParentWalker walker(m_node.get()); walker.get(); walker.parentIncludingInsertionPointAndShadowRoot()) { Node* node = walker.get(); if (targetStack.isEmpty()) targetStack.append(eventTargetRespectingSVGTargetRules(node)); else if (isInsertionPoint(node) && toInsertionPoint(node)->contains(last)) targetStack.append(targetStack.last()); m_ancestors.append(EventContext(node, eventTargetRespectingSVGTargetRules(node), targetStack.last())); if (!inDocument) return; last = node; if (!node->isShadowRoot()) continue; if (determineDispatchBehavior(event, toShadowRoot(node), targetStack.last()) == StayInsideShadowDOM) return; if (!isSVGElement) { ASSERT(!targetStack.isEmpty()); targetStack.removeLast(); } } }
void EventDispatcher::getEventAncestors(EventTarget* originalTarget, EventDispatchBehavior behavior) { if (!m_node->inDocument()) return; if (ancestorsInitialized()) return; EventTarget* target = originalTarget; Node* ancestor = m_node.get(); bool shouldSkipNextAncestor = false; while (true) { if (ancestor->isShadowRoot()) { if (behavior == StayInsideShadowDOM) return; ancestor = ancestor->shadowHost(); if (!shouldSkipNextAncestor) target = ancestor; } else ancestor = ancestor->parentNodeGuaranteedHostFree(); if (!ancestor) return; #if ENABLE(SVG) // Skip SVGShadowTreeRootElement. shouldSkipNextAncestor = ancestor->isSVGElement() && ancestor->isShadowRoot(); if (shouldSkipNextAncestor) continue; #endif // FIXME: Unroll the extra loop inside eventTargetRespectingSVGTargetRules into this loop. m_ancestors.append(EventContext(ancestor, eventTargetRespectingSVGTargetRules(ancestor), target)); } }
DInputEventQueue* DInputManager::registerWindow( DRenderWindow* wind, bool isExclusive ) { EventContextMap::iterator i = mEventContextMap.find(wind); if (i != mEventContextMap.end()) { return i->second.eventQueue; } // create a new OIS::InputManager OIS::ParamList pl; std::ostringstream wnd; wnd << (size_t)wind->getWindowHandle(); pl.insert(std::make_pair(mPlatform, wnd.str())); if (!isExclusive) { // 非独占模式下鼠标可移出窗口之外 pl.insert(std::make_pair(std::string("w32_mouse"), "DISCL_FOREGROUND")); pl.insert(std::make_pair(std::string("w32_mouse"), "DISCL_NONEXCLUSIVE")); } // since no NULL will be returned, we do not check. // (OIS will throw exception) OIS::InputManager* mgr = OIS::InputManager::createInputSystem(pl); mgr->enableAddOnFactory(OIS::InputManager::AddOn_All); // since the ois's mouse event depend on its window size, so we must act // when the window size changed. wind->signalResized.connect( DBind(&DInputManager::onWindowResized, this, _1)); DInputEventQueue* queue = new DInputEventQueue(); DInputReceiver* receiver = new DInputReceiver(mgr, queue); receiver->setWindowSize(wind->getWidth(), wind->getHeight()); mEventContextMap.insert(std::make_pair(wind, EventContext(mgr, receiver, queue))); return queue; }
QTSS_Error OpenFile(QTSS_OpenFile_Params* inParams) { OSFileSource* theFileSource = NEW OSFileSource(inParams->inPath); UInt64 theLength = theFileSource->GetLength(); // // OSFileSource returns mod date as a time_t. // This is the same as a QTSS_TimeVal, except the latter is in msec QTSS_TimeVal theModDate = (QTSS_TimeVal)theFileSource->GetModDate(); theModDate *= 1000; // // Check to see if the file actually exists if (theLength == 0) { delete theFileSource; return QTSS_FileNotFound; } // // Add this new file source object to the file object QTSS_Error theErr = QTSS_SetValue(inParams->inFileObject, sOSFileSourceAttr, 0, &theFileSource, sizeof(theFileSource)); if (theErr != QTSS_NoErr) { delete theFileSource; return QTSS_RequestFailed; } // // If caller wants async I/O, at this point we should set up the EventContext if (inParams->inFlags & qtssOpenFileAsync) { EventContext* theEventContext = NEW EventContext(EventContext::kInvalidFileDesc, Socket::GetEventThread()); theEventContext->InitNonBlocking(theFileSource->GetFD()); theErr = QTSS_SetValue(inParams->inFileObject, sEventContextAttr, 0, &theEventContext, sizeof(theEventContext)); if (theErr != QTSS_NoErr) { delete theFileSource; delete theEventContext; return QTSS_RequestFailed; } } // // Set up the other attribute values in the file object (void)QTSS_SetValue(inParams->inFileObject, qtssFlObjLength, 0, &theLength, sizeof(theLength)); (void)QTSS_SetValue(inParams->inFileObject, qtssFlObjModDate, 0, &theModDate, sizeof(theModDate)); return QTSS_NoErr; }
void EventDispatcher::ensureEventAncestors(Event* event) { if (!m_node->inDocument()) return; if (m_ancestorsInitialized) return; m_ancestorsInitialized = true; Node* ancestor = m_node.get(); EventTarget* target = eventTargetRespectingSVGTargetRules(ancestor); bool shouldSkipNextAncestor = false; while (true) { bool isSVGShadowRoot = ancestor->isSVGShadowRoot(); if (isSVGShadowRoot || ancestor->isShadowRoot()) { if (determineDispatchBehavior(event, ancestor) == StayInsideShadowDOM) return; #if ENABLE(SVG) ancestor = isSVGShadowRoot ? ancestor->svgShadowHost() : ancestor->shadowHost(); #else ancestor = ancestor->shadowHost(); #endif if (!shouldSkipNextAncestor) target = ancestor; } else ancestor = ancestor->parentNodeGuaranteedHostFree(); if (!ancestor) return; #if ENABLE(SVG) // Skip SVGShadowTreeRootElement. shouldSkipNextAncestor = ancestor->isSVGShadowRoot(); if (shouldSkipNextAncestor) continue; #endif // FIXME: Unroll the extra loop inside eventTargetRespectingSVGTargetRules into this loop. m_ancestors.append(EventContext(ancestor, eventTargetRespectingSVGTargetRules(ancestor), target)); } }