ostream &operator<<(ostream &stream, const VendorProduct &vendor_product) { ostream_state_saver state(stream); stream << "vendor ID:" << setfill('0') << hex << setw(4) << vendor_product.getVendorId() << ", product ID:" << setw(4) << vendor_product.getProductId(); return stream; }
void check_running () { if (state () != async_state::running) throw async_not_running_error (); }
nsresult nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent) { NS_ENSURE_TRUE(mOuter, NS_OK); nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(aMouseEvent)); PRUint16 button = 0; mouseEvent->GetButton(&button); // only if left button if (button != 0) return NS_OK; if (mOuter->GetContent()-> AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled, nsGkAtoms::_true, eCaseMatters)) return NS_OK; mParentBox = mOuter->GetParentBox(); if (!mParentBox) return NS_OK; // get our index nsPresContext* outerPresContext = mOuter->PresContext(); const nsFrameList& siblingList(mParentBox->GetChildList(nsnull)); PRInt32 childIndex = siblingList.IndexOf(mOuter); // if it's 0 (or not found) then stop right here. // It might be not found if we're not in the parent's primary frame list. if (childIndex <= 0) return NS_OK; PRInt32 childCount = siblingList.GetLength(); // if it's the last index then we need to allow for resizeafter="grow" if (childIndex == childCount - 1 && GetResizeAfter() != Grow) return NS_OK; nsCOMPtr<nsIRenderingContext> rc = outerPresContext->PresShell()->GetReferenceRenderingContext(); NS_ENSURE_TRUE(rc, NS_ERROR_FAILURE); nsBoxLayoutState state(outerPresContext, rc); mCurrentPos = 0; mPressed = PR_TRUE; mDidDrag = PR_FALSE; EnsureOrient(); PRBool isHorizontal = !mOuter->IsHorizontal(); ResizeType resizeBefore = GetResizeBefore(); ResizeType resizeAfter = GetResizeAfter(); delete[] mChildInfosBefore; delete[] mChildInfosAfter; mChildInfosBefore = new nsSplitterInfo[childCount]; mChildInfosAfter = new nsSplitterInfo[childCount]; // create info 2 lists. One of the children before us and one after. PRInt32 count = 0; mChildInfosBeforeCount = 0; mChildInfosAfterCount = 0; nsIBox* childBox = mParentBox->GetChildBox(); while (nsnull != childBox) { nsIContent* content = childBox->GetContent(); nsIDocument* doc = content->GetOwnerDoc(); nsIAtom* atom; if (doc) { PRInt32 dummy; atom = doc->BindingManager()->ResolveTag(content, &dummy); } else { atom = content->Tag(); } // skip over any splitters if (atom != nsGkAtoms::splitter) { nsSize prefSize = childBox->GetPrefSize(state); nsSize minSize = childBox->GetMinSize(state); nsSize maxSize = nsBox::BoundsCheckMinMax(minSize, childBox->GetMaxSize(state)); prefSize = nsBox::BoundsCheck(minSize, prefSize, maxSize); mOuter->AddMargin(childBox, minSize); mOuter->AddMargin(childBox, prefSize); mOuter->AddMargin(childBox, maxSize); nscoord flex = childBox->GetFlex(state); nsMargin margin(0,0,0,0); childBox->GetMargin(margin); nsRect r(childBox->GetRect()); r.Inflate(margin); // We need to check for hidden attribute too, since treecols with // the hidden="true" attribute are not really hidden, just collapsed if (!content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::fixed, nsGkAtoms::_true, eCaseMatters) && !content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::hidden, nsGkAtoms::_true, eCaseMatters)) { if (count < childIndex && (resizeBefore != Flex || flex > 0)) { mChildInfosBefore[mChildInfosBeforeCount].childElem = content; mChildInfosBefore[mChildInfosBeforeCount].min = isHorizontal ? minSize.width : minSize.height; mChildInfosBefore[mChildInfosBeforeCount].max = isHorizontal ? maxSize.width : maxSize.height; mChildInfosBefore[mChildInfosBeforeCount].current = isHorizontal ? r.width : r.height; mChildInfosBefore[mChildInfosBeforeCount].flex = flex; mChildInfosBefore[mChildInfosBeforeCount].index = count; mChildInfosBefore[mChildInfosBeforeCount].changed = mChildInfosBefore[mChildInfosBeforeCount].current; mChildInfosBeforeCount++; } else if (count > childIndex && (resizeAfter != Flex || flex > 0)) { mChildInfosAfter[mChildInfosAfterCount].childElem = content; mChildInfosAfter[mChildInfosAfterCount].min = isHorizontal ? minSize.width : minSize.height; mChildInfosAfter[mChildInfosAfterCount].max = isHorizontal ? maxSize.width : maxSize.height; mChildInfosAfter[mChildInfosAfterCount].current = isHorizontal ? r.width : r.height; mChildInfosAfter[mChildInfosAfterCount].flex = flex; mChildInfosAfter[mChildInfosAfterCount].index = count; mChildInfosAfter[mChildInfosAfterCount].changed = mChildInfosAfter[mChildInfosAfterCount].current; mChildInfosAfterCount++; } } } childBox = childBox->GetNextBox(); count++; } if (!mParentBox->IsNormalDirection()) { // The before array is really the after array, and the order needs to be reversed. // First reverse both arrays. Reverse(mChildInfosBefore, mChildInfosBeforeCount); Reverse(mChildInfosAfter, mChildInfosAfterCount); // Now swap the two arrays. nscoord newAfterCount = mChildInfosBeforeCount; mChildInfosBeforeCount = mChildInfosAfterCount; mChildInfosAfterCount = newAfterCount; nsSplitterInfo* temp = mChildInfosAfter; mChildInfosAfter = mChildInfosBefore; mChildInfosBefore = temp; } // if resizebefore is not Farthest, reverse the list because the first child // in the list is the farthest, and we want the first child to be the closest. if (resizeBefore != Farthest) Reverse(mChildInfosBefore, mChildInfosBeforeCount); // if the resizeafter is the Farthest we must reverse the list because the first child in the list // is the closest we want the first child to be the Farthest. if (resizeAfter == Farthest) Reverse(mChildInfosAfter, mChildInfosAfterCount); // grow only applys to the children after. If grow is set then no space should be taken out of any children after // us. To do this we just set the size of that list to be 0. if (resizeAfter == Grow) mChildInfosAfterCount = 0; PRInt32 c; nsPoint pt = nsLayoutUtils::GetDOMEventCoordinatesRelativeTo(mouseEvent, mParentBox); if (isHorizontal) { c = pt.x; mSplitterPos = mOuter->mRect.x; } else { c = pt.y; mSplitterPos = mOuter->mRect.y; } mDragStart = c; //printf("Pressed mDragStart=%d\n",mDragStart); nsIPresShell::SetCapturingContent(mOuter->GetContent(), CAPTURE_IGNOREALLOWED); return NS_OK; }
Icon SystemTray::stateIcon() const { return stateIcon(state()); }
void soft_start () { if (state () == async_state::idle) start (); }
RenderInfo::~RenderInfo() { state(0); }
void TraceBuilder::useState(Block* block) { assert(m_snapshots[block]); std::unique_ptr<State> state(m_snapshots[block]); m_snapshots[block] = nullptr; useState(std::move(state)); }
// Call me once a frame! void GPGMultiplayer::Update() { pthread_mutex_lock(&state_mutex_); // unlocked in two places below if (!next_states_.empty()) { // Transition at most one state per frame. MultiplayerState next_state = next_states_.front(); next_states_.pop(); pthread_mutex_unlock(&state_mutex_); SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "GPGMultiplayer: Exiting state %d to enter state %d", state(), next_state); TransitionState(state(), next_state); } else { pthread_mutex_unlock(&state_mutex_); } // Now update based on what state we are in. switch (state()) { case kDiscovering: { pthread_mutex_lock(&instance_mutex_); bool has_discovered_instance = !discovered_instances_.empty(); pthread_mutex_unlock(&instance_mutex_); if (has_discovered_instance) { QueueNextState(kDiscoveringPromptedUser); } break; } case kDiscoveringPromptedUser: { DialogResponse response = GetConnectionDialogResponse(); if (response == kDialogNo) { // we decided not to connect to the first discovered instance. pthread_mutex_lock(&instance_mutex_); discovered_instances_.pop_front(); pthread_mutex_unlock(&instance_mutex_); QueueNextState(kDiscovering); } else if (response == kDialogYes) { // We decided to try to connect to the first discovered instance. pthread_mutex_lock(&instance_mutex_); auto instance = discovered_instances_.front(); discovered_instances_.pop_front(); pthread_mutex_unlock(&instance_mutex_); SendConnectionRequest(instance); QueueNextState(kDiscoveringWaitingForHost); } // Otherwise we haven't gotten a response yet. break; } case kConnectedWithDisconnections: { pthread_mutex_lock(&instance_mutex_); bool has_disconnected_instance = !disconnected_instances_.empty(); bool has_pending_instance = !pending_instances_.empty(); pthread_mutex_unlock(&instance_mutex_); if (!has_disconnected_instance) { SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "GPGMultiplayer: No disconnected instances."); QueueNextState(kConnected); } else if (has_pending_instance) { // Check if the pending instance is one of the disconnected ones. // If so, and we still have room, connect him. // Otherwise, reject. pthread_mutex_lock(&instance_mutex_); auto i = disconnected_instances_.find(pending_instances_.front()); bool is_reconnection = (i != disconnected_instances_.end()); pthread_mutex_unlock(&instance_mutex_); if (!is_reconnection) { // Not a disconnected instance. Reject. RejectConnectionRequest(pending_instances_.front()); } else if (max_connected_players_allowed() >= 0 && GetNumConnectedPlayers() >= max_connected_players_allowed()) { // Too many players to allow us back. Reject. But we might be // allowed back again in the future. RejectConnectionRequest(pending_instances_.front()); } else { // A valid reconnecting instance. Allow. AcceptConnectionRequest(pending_instances_.front()); } } break; } case kAdvertising: { pthread_mutex_lock(&instance_mutex_); bool has_pending_instance = !pending_instances_.empty(); pthread_mutex_unlock(&instance_mutex_); if (has_pending_instance) { if (max_connected_players_allowed() >= 0 && GetNumConnectedPlayers() >= max_connected_players_allowed()) { // Already have a full game, auto-reject any additional players. RejectConnectionRequest(pending_instances_.front()); } else { // Prompt the user to allow the connection. QueueNextState(kAdvertisingPromptedUser); } } break; } case kAdvertisingPromptedUser: { // check if we allowed connection int response = GetConnectionDialogResponse(); if (response == 0) { // Reject removes the instance_id from pending pthread_mutex_lock(&instance_mutex_); auto instance = pending_instances_.front(); pthread_mutex_unlock(&instance_mutex_); RejectConnectionRequest(instance); QueueNextState(kAdvertising); } else if (response == 1) { // Accept removes the instance_id from pending and adds it to connected pthread_mutex_lock(&instance_mutex_); auto instance = pending_instances_.front(); pthread_mutex_unlock(&instance_mutex_); AcceptConnectionRequest(instance); QueueNextState(kAdvertising); } // Otherwise we haven't gotten a response yet. break; } default: { // no default behavior break; } } }
bool run() { bool changed = false; AbstractState state(m_graph); InsertionSet<NodeIndex> insertionSet; for (BlockIndex blockIndex = 0; blockIndex < m_graph.m_blocks.size(); ++blockIndex) { BasicBlock* block = m_graph.m_blocks[blockIndex].get(); if (!block) continue; if (!block->cfaFoundConstants) continue; state.beginBasicBlock(block); for (unsigned indexInBlock = 0; indexInBlock < block->size(); ++indexInBlock) { if (!state.isValid()) break; state.execute(indexInBlock); NodeIndex nodeIndex = block->at(indexInBlock); Node& node = m_graph[nodeIndex]; if (!node.shouldGenerate() || m_graph.clobbersWorld(node) || node.hasConstant()) continue; JSValue value = state.forNode(nodeIndex).value(); if (!value) continue; Node phantom(Phantom, node.codeOrigin); if (node.op() == GetLocal) { ASSERT(m_graph[node.child1()].op() == Phi); ASSERT(!m_graph[node.child1()].hasResult()); ASSERT(block->variablesAtHead.operand(node.local()) == nodeIndex); ASSERT(block->isInPhis(node.child1().index())); block->variablesAtHead.operand(node.local()) = node.child1().index(); NodeIndex tailNodeIndex = block->variablesAtTail.operand(node.local()); if (tailNodeIndex == nodeIndex) block->variablesAtTail.operand(node.local()) = node.child1().index(); else { ASSERT(m_graph[tailNodeIndex].op() == Flush || m_graph[tailNodeIndex].op() == SetLocal); } } phantom.children = node.children; phantom.ref(); m_graph.convertToConstant(nodeIndex, value); NodeIndex phantomNodeIndex = m_graph.size(); m_graph.append(phantom); insertionSet.append(indexInBlock, phantomNodeIndex); changed = true; } insertionSet.execute(*block); state.reset(); } return changed; }
void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) { #ifdef QT_DEBUG_DRAW qDebug() << "QPaintEngineEx::stroke()" << pen; #endif Q_D(QPaintEngineEx); if (path.isEmpty()) return; if (!d->strokeHandler) { d->strokeHandler = new StrokeHandler(path.elementCount()+4); d->stroker.setMoveToHook(qpaintengineex_moveTo); d->stroker.setLineToHook(qpaintengineex_lineTo); d->stroker.setCubicToHook(qpaintengineex_cubicTo); } if (!qpen_fast_equals(pen, d->strokerPen)) { d->strokerPen = pen; d->stroker.setJoinStyle(pen.joinStyle()); d->stroker.setCapStyle(pen.capStyle()); d->stroker.setMiterLimit(pen.miterLimit()); qreal penWidth = pen.widthF(); if (penWidth == 0) d->stroker.setStrokeWidth(1); else d->stroker.setStrokeWidth(penWidth); Qt::PenStyle style = pen.style(); if (style == Qt::SolidLine) { d->activeStroker = &d->stroker; } else if (style == Qt::NoPen) { d->activeStroker = 0; } else { d->dasher.setDashPattern(pen.dashPattern()); d->dasher.setDashOffset(pen.dashOffset()); d->activeStroker = &d->dasher; } } if (!d->activeStroker) { return; } if (pen.style() > Qt::SolidLine) { if (qt_pen_is_cosmetic(pen, state()->renderHints)){ d->activeStroker->setClipRect(d->exDeviceRect); } else { QRectF clipRect = state()->matrix.inverted().mapRect(QRectF(d->exDeviceRect)); d->activeStroker->setClipRect(clipRect); } } const QPainterPath::ElementType *types = path.elements(); const qreal *points = path.points(); int pointCount = path.elementCount(); const qreal *lastPoint = points + (pointCount<<1); d->strokeHandler->types.reset(); d->strokeHandler->pts.reset(); // Some engines might decide to optimize for the non-shape hint later on... uint flags = QVectorPath::WindingFill; if (path.elementCount() > 2) flags |= QVectorPath::NonConvexShapeMask; if (d->stroker.capStyle() == Qt::RoundCap || d->stroker.joinStyle() == Qt::RoundJoin) flags |= QVectorPath::CurvedShapeMask; // ### Perspective Xforms are currently not supported... if (!qt_pen_is_cosmetic(pen, state()->renderHints)) { // We include cosmetic pens in this case to avoid having to // change the current transform. Normal transformed, // non-cosmetic pens will be transformed as part of fill // later, so they are also covered here.. d->activeStroker->setCurveThresholdFromTransform(state()->matrix); d->activeStroker->begin(d->strokeHandler); if (types) { while (points < lastPoint) { switch (*types) { case QPainterPath::MoveToElement: d->activeStroker->moveTo(points[0], points[1]); points += 2; ++types; break; case QPainterPath::LineToElement: d->activeStroker->lineTo(points[0], points[1]); points += 2; ++types; break; case QPainterPath::CurveToElement: d->activeStroker->cubicTo(points[0], points[1], points[2], points[3], points[4], points[5]); points += 6; types += 3; flags |= QVectorPath::CurvedShapeMask; break; default: break; } } if (path.hasImplicitClose()) d->activeStroker->lineTo(path.points()[0], path.points()[1]); } else { d->activeStroker->moveTo(points[0], points[1]); points += 2; while (points < lastPoint) { d->activeStroker->lineTo(points[0], points[1]); points += 2; } if (path.hasImplicitClose()) d->activeStroker->lineTo(path.points()[0], path.points()[1]); } d->activeStroker->end(); if (!d->strokeHandler->types.size()) // an empty path... return; QVectorPath strokePath(d->strokeHandler->pts.data(), d->strokeHandler->types.size(), d->strokeHandler->types.data(), flags); fill(strokePath, pen.brush()); } else { // For cosmetic pens we need a bit of trickery... We to process xform the input points if (state()->matrix.type() >= QTransform::TxProject) { QPainterPath painterPath = state()->matrix.map(path.convertToPainterPath()); d->activeStroker->strokePath(painterPath, d->strokeHandler, QTransform()); } else { d->activeStroker->setCurveThresholdFromTransform(QTransform()); d->activeStroker->begin(d->strokeHandler); if (types) { while (points < lastPoint) { switch (*types) { case QPainterPath::MoveToElement: { QPointF pt = (*(QPointF *) points) * state()->matrix; d->activeStroker->moveTo(pt.x(), pt.y()); points += 2; ++types; break; } case QPainterPath::LineToElement: { QPointF pt = (*(QPointF *) points) * state()->matrix; d->activeStroker->lineTo(pt.x(), pt.y()); points += 2; ++types; break; } case QPainterPath::CurveToElement: { QPointF c1 = ((QPointF *) points)[0] * state()->matrix; QPointF c2 = ((QPointF *) points)[1] * state()->matrix; QPointF e = ((QPointF *) points)[2] * state()->matrix; d->activeStroker->cubicTo(c1.x(), c1.y(), c2.x(), c2.y(), e.x(), e.y()); points += 6; types += 3; flags |= QVectorPath::CurvedShapeMask; break; } default: break; } } if (path.hasImplicitClose()) { QPointF pt = * ((QPointF *) path.points()) * state()->matrix; d->activeStroker->lineTo(pt.x(), pt.y()); } } else { QPointF p = ((QPointF *)points)[0] * state()->matrix; d->activeStroker->moveTo(p.x(), p.y()); points += 2; while (points < lastPoint) { QPointF p = ((QPointF *)points)[0] * state()->matrix; d->activeStroker->lineTo(p.x(), p.y()); points += 2; } if (path.hasImplicitClose()) d->activeStroker->lineTo(p.x(), p.y()); } d->activeStroker->end(); } QVectorPath strokePath(d->strokeHandler->pts.data(), d->strokeHandler->types.size(), d->strokeHandler->types.data(), flags); QTransform xform = state()->matrix; state()->matrix = QTransform(); transformChanged(); QBrush brush = pen.brush(); if (qbrush_style(brush) != Qt::SolidPattern) brush.setTransform(brush.transform() * xform); fill(strokePath, brush); state()->matrix = xform; transformChanged(); } }
static void dump_ex (typename basic_state_machine<CharT>::iterator &iter_, ostream &stream_) { const std::size_t states_ = iter_->states; for (std::size_t i_ = 0; i_ < states_; ++i_) { state (stream_); stream_ << i_ << std::endl; if (iter_->end_state) { end_state (stream_); stream_ << iter_->id; unique_id (stream_); stream_ << iter_->unique_id; dfa (stream_); stream_ << iter_->goto_dfa; stream_ << std::endl; } if (iter_->bol_index != npos) { bol (stream_); stream_ << iter_->bol_index << std::endl; } if (iter_->eol_index != npos) { eol (stream_); stream_ << iter_->eol_index << std::endl; } const std::size_t transitions_ = iter_->transitions; if (transitions_ == 0) { ++iter_; } for (std::size_t t_ = 0; t_ < transitions_; ++t_) { std::size_t goto_state_ = iter_->goto_state; if (iter_->token.any ()) { any (stream_); } else { open_bracket (stream_); if (iter_->token._negated) { negated (stream_); } string charset_; CharT c_ = 0; escape_control_chars (iter_->token._charset, charset_); c_ = *charset_.c_str (); if (!iter_->token._negated && (c_ == '^' || c_ == ']')) { stream_ << '\\'; } stream_ << charset_; close_bracket (stream_); } stream_ << goto_state_ << std::endl; ++iter_; } stream_ << std::endl; } }
void AbstractImageGrabber::stop() { if (state() != AbstractGrabber::StoppedState) { setStopRequest(true); } }
void AbstractImageGrabber::resume() { if (state() == AbstractGrabber::SuspendedState) startGrabbing(); }
void AbstractImageGrabber::suspend() { if (state() == AbstractGrabber::ActiveState) { setPauseRequest(true); } }
void Engine_State::show(void) { std::cout << "ON " << m_on << " ; " << "IDLE " << m_idle << " ; " << "STATE "<< state() << std::endl; }
void RemotePlainGdbAdapter::handleRemoteSetupFailed(const QString &reason) { QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state()); m_engine->handleAdapterStartFailed(reason); }
int DFA::recognize(const String &str, int startPos, int &length) { ASSERT(startPos <= str.length()); // keep track of the length of the longest token found, and // the final state it's associated with int maxLengthFound = 0; int bestFinalState = -1; int bestFinalCode = -1; setState(startState_); int i = startPos; while (i < str.length()) { char c = str.charAt(i); // if this is not a legal character for a token, no match. if (!isValid(c)) break; int newState = getTransitionState(state(), c); // if there's no transition on this symbol from the state, no match. if (newState < 0) break; setState(newState); i++; #if AUGMENT // if the current state has a <token id> transition, // then we've reached a final state; choose the // first such number in the list, since we want the productions // that were listed first to have higher priority. int token = findTokenID(); if (token >= 0) { maxLengthFound = i - startPos; bestFinalCode = token; bestFinalState = newState; } #endif // With the augmented <token id>s, we will never // actually get to the (distinct) final state; so this is not // necessary. We'll leave it in for compatibility with HW #1. // if this is a final state, update the longest token length. if (isFinalState(newState)) { maxLengthFound = i - startPos; bestFinalState = newState; #if !AUGMENT bestFinalCode = getState(newState).finalCode(); #endif } } // don't know why this is here. setState(bestFinalState); length = maxLengthFound; return bestFinalCode; }
void RemotePlainGdbAdapter::startAdapter() { QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state()); showMessage(QLatin1String("TRYING TO START ADAPTER")); m_engine->requestRemoteSetup(); }
NS_IMETHODIMP nsLeafBoxFrame::Reflow(nsPresContext* aPresContext, nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus) { // This is mostly a copy of nsBoxFrame::Reflow(). // We aren't able to share an implementation because of the frame // class hierarchy. If you make changes here, please keep // nsBoxFrame::Reflow in sync. DO_GLOBAL_REFLOW_COUNT("nsLeafBoxFrame"); DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus); NS_ASSERTION(aReflowState.ComputedWidth() >=0 && aReflowState.ComputedHeight() >= 0, "Computed Size < 0"); #ifdef DO_NOISY_REFLOW printf("\n-------------Starting LeafBoxFrame Reflow ----------------------------\n"); printf("%p ** nsLBF::Reflow %d R: ", this, myCounter++); switch (aReflowState.reason) { case eReflowReason_Initial: printf("Ini");break; case eReflowReason_Incremental: printf("Inc");break; case eReflowReason_Resize: printf("Rsz");break; case eReflowReason_StyleChange: printf("Sty");break; case eReflowReason_Dirty: printf("Drt "); break; default:printf("<unknown>%d", aReflowState.reason);break; } printSize("AW", aReflowState.availableWidth); printSize("AH", aReflowState.availableHeight); printSize("CW", aReflowState.ComputedWidth()); printSize("CH", aReflowState.ComputedHeight()); printf(" *\n"); #endif aStatus = NS_FRAME_COMPLETE; // create the layout state nsBoxLayoutState state(aPresContext, aReflowState.rendContext); nsSize computedSize(aReflowState.ComputedWidth(),aReflowState.ComputedHeight()); nsMargin m; m = aReflowState.mComputedBorderPadding; //GetBorderAndPadding(m); // this happens sometimes. So lets handle it gracefully. if (aReflowState.ComputedHeight() == 0) { nsSize minSize = GetMinSize(state); computedSize.height = minSize.height - m.top - m.bottom; } nsSize prefSize(0,0); // if we are told to layout intrinic then get our preferred size. if (computedSize.width == NS_INTRINSICSIZE || computedSize.height == NS_INTRINSICSIZE) { prefSize = GetPrefSize(state); nsSize minSize = GetMinSize(state); nsSize maxSize = GetMaxSize(state); prefSize = BoundsCheck(minSize, prefSize, maxSize); } // get our desiredSize if (aReflowState.ComputedWidth() == NS_INTRINSICSIZE) { computedSize.width = prefSize.width; } else { computedSize.width += m.left + m.right; } if (aReflowState.ComputedHeight() == NS_INTRINSICSIZE) { computedSize.height = prefSize.height; } else { computedSize.height += m.top + m.bottom; } // handle reflow state min and max sizes // XXXbz the width handling here seems to be wrong, since // mComputedMin/MaxWidth is a content-box size, whole // computedSize.width is a border-box size... if (computedSize.width > aReflowState.mComputedMaxWidth) computedSize.width = aReflowState.mComputedMaxWidth; if (computedSize.width < aReflowState.mComputedMinWidth) computedSize.width = aReflowState.mComputedMinWidth; // Now adjust computedSize.height for our min and max computed // height. The only problem is that those are content-box sizes, // while computedSize.height is a border-box size. So subtract off // m.TopBottom() before adjusting, then readd it. computedSize.height = std::max(0, computedSize.height - m.TopBottom()); computedSize.height = NS_CSS_MINMAX(computedSize.height, aReflowState.mComputedMinHeight, aReflowState.mComputedMaxHeight); computedSize.height += m.TopBottom(); nsRect r(mRect.x, mRect.y, computedSize.width, computedSize.height); SetBounds(state, r); // layout our children Layout(state); // ok our child could have gotten bigger. So lets get its bounds aDesiredSize.width = mRect.width; aDesiredSize.height = mRect.height; aDesiredSize.ascent = GetBoxAscent(state); // the overflow rect is set in SetBounds() above aDesiredSize.mOverflowAreas = GetOverflowAreas(); #ifdef DO_NOISY_REFLOW { printf("%p ** nsLBF(done) W:%d H:%d ", this, aDesiredSize.width, aDesiredSize.height); if (maxElementWidth) { printf("MW:%d\n", *maxElementWidth); } else { printf("MW:?\n"); } } #endif return NS_OK; }
void DownloadJob::onDownloadProgress( qint64 rcvd, qint64 total ) { if ( m_reply == 0 ) return; if ( rcvd >= m_fileSize && m_fileSize > 0 ) { m_finished = true; } if ( state() == Paused ) return; m_rcvdSize = rcvd; m_fileSize = total; qint64 now = QDateTime::currentDateTime().toMSecsSinceEpoch(); if ( ( now - 50 > m_rcvdStamp ) || ( rcvd == total ) ) { m_rcvdStamp = now; if ( ( m_rcvdSize - 16384 > m_rcvdEmit ) || ( rcvd == total ) ) { m_rcvdEmit = m_rcvdSize; emit progress( progressPercentage() ); } } if ( !m_file ) return; if ( !m_file->isOpen() ) { if ( m_tryResuming && checkForResumedFile() ) return; if ( !m_file->open( QIODevice::WriteOnly ) ) { tLog() << Q_FUNC_INFO << "Failed opening file:" << m_file->fileName(); setState( Failed ); return; } } QByteArray data = m_reply->readAll(); if ( data.isEmpty() ) return; if ( m_file->write( data ) < 0 ) { tLog() << Q_FUNC_INFO << "Failed writing to file:" << data.length(); onDownloadError( QNetworkReply::UnknownContentError ); return; } if ( m_rcvdSize >= m_fileSize && m_fileSize > 0 ) { onDownloadFinished(); } else if ( m_reply->isFinished() && m_reply->bytesAvailable() == 0 ) { if ( ( m_fileSize > 0 && m_rcvdSize < m_fileSize ) || m_rcvdSize == 0 ) { onDownloadError( QNetworkReply::UnknownContentError ); return; } } }
int get_link (int v) { if (t[v].link != -1) return t[v].link; if (t[v].par == -1) return 0; int to = get_link (t[v].par); return t[v].link = split (go (state(to,t[to].len()), t[v].l + (t[v].par==0), t[v].r)); }
/*! \reimp */ QAccessible::Relation QAccessibleWidget::relationTo(int child, const QAccessibleInterface *other, int otherChild) const { Relation relation = Unrelated; if (d->asking == this) // recursive call return relation; QObject *o = other ? other->object() : 0; if (!o) return relation; QWidget *focus = widget()->focusWidget(); if (object() == focus && isAncestor(o, focus)) relation |= FocusChild; QACConnectionObject *connectionObject = (QACConnectionObject*)object(); for (int sig = 0; sig < d->primarySignals.count(); ++sig) { if (connectionObject->isSender(o, d->primarySignals.at(sig).toAscii())) { relation |= Controller; break; } } // test for passive relationships. // d->asking protects from endless recursion. d->asking = this; int inverse = other->relationTo(otherChild, this, child); d->asking = 0; if (inverse & Controller) relation |= Controlled; if (inverse & Label) relation |= Labelled; if(o == object()) { if (child && !otherChild) return relation | Child; if (!child && otherChild) return relation | Ancestor; if (!child && !otherChild) return relation | Self; } QObject *parent = object()->parent(); if (o == parent) return relation | Child; if (o->parent() == parent) { relation |= Sibling; QAccessibleInterface *sibIface = QAccessible::queryAccessibleInterface(o); Q_ASSERT(sibIface); QRect wg = rect(0); QRect sg = sibIface->rect(0); if (wg.intersects(sg)) { QAccessibleInterface *pIface = 0; sibIface->navigate(Ancestor, 1, &pIface); if (pIface && !((sibIface->state(0) | state(0)) & Invisible)) { int wi = pIface->indexOfChild(this); int si = pIface->indexOfChild(sibIface); if (wi > si) relation |= QAccessible::Covers; else relation |= QAccessible::Covered; } delete pIface; } else { QPoint wc = wg.center(); QPoint sc = sg.center(); if (wc.x() < sc.x()) relation |= QAccessible::Left; else if(wc.x() > sc.x()) relation |= QAccessible::Right; if (wc.y() < sc.y()) relation |= QAccessible::Up; else if (wc.y() > sc.y()) relation |= QAccessible::Down; } delete sibIface; return relation; } if (isAncestor(o, object())) return relation | Descendent; if (isAncestor(object(), o)) return relation | Ancestor; return relation; }
void params(DWORD This, DWORD OutClass, char* name, DWORD index, char* handle_string) { { locvar::guard _tmp_guard_((0x10000 | (int)CC_GUIID_YDWETimerStartMultiple), name, handle_string); DWORD nItemCount, i; DWORD nItemClass; char NewName[260]; nItemCount = *(DWORD*)(This+0xC); for (i = 0; i < nItemCount; i++) { nItemClass = ((DWORD*)(*(DWORD*)(This+0x10)))[i]; if (*(DWORD*)(nItemClass+0x13C) != 0) { if ((index) == -1 || (*(DWORD*)(nItemClass+0x154) == index)) { switch (*(DWORD*)(nItemClass+0x138)) { case CC_GUIID_YDWESetAnyTypeLocalVariable: { BLZSStrPrintf(NewName, 260, "%sFunc%03d", name, i+1); locvar::set(nItemClass, OutClass, NewName); break; } case CC_GUIID_YDWETimerStartMultiple: case CC_GUIID_YDWERegisterTriggerMultiple: ShowError(OutClass, "WESTRING_ERROR_YDTRIGGER_ILLEGAL_PARAMETER"); break; default: { CC_PutAction(nItemClass, OutClass, name, i, 0); } break; } } } } } for each (auto it in register_var[name]) { auto uiit = trigger_data_ui.find(it.first); if (uiit == trigger_data_ui.end()) { locvar::do_set(OutClass, it.second.c_str(), it.first.c_str() , state(CC_GUIID_YDWETimerStartMultiple, name, handle_string) , [&]() { locvar::do_get(OutClass, it.second.c_str(), it.first.c_str(), global); } ); } else { locvar::do_set(OutClass, it.second.c_str(), it.first.c_str() , state(CC_GUIID_YDWETimerStartMultiple, name, handle_string) , [&]() { PUT_CONST(it.first.c_str(), 0); PUT_CONST("()", 0); } ); } }
/*! * Destroys the QxtDiscoverableService. * * TIf registered, the service will be unregistered. */ QxtDiscoverableService::~QxtDiscoverableService() { if(state() == Registered || state() == Resolved) releaseService(); }
void soft_stop () { if (state () == async_state::running) stop (); }
/*! * Sets the list of subtypes for this service. * * \sa serviceSubTypes * \sa addServiceSubType * \sa removeServiceSubType * \sa hasServiceSubType */ void QxtDiscoverableService::setServiceSubTypes(const QStringList& subtypes) { if(state() != Unknown) qWarning() << "QxtDiscoverableService: Setting service subtypes while not in Unknown state has no effect"; qxt_d().serviceSubTypes = subtypes; }
void check_idle () { if (state () != async_state::idle) throw async_not_idle_error (); }
/*! * Removes a subtype from the service. * * \sa serviceSubTypes * \sa setServiceSubTypes * \sa addServiceSubType * \sa hasServiceSubType */ void QxtDiscoverableService::removeServiceSubType(const QString& subtype) { if(state() != Unknown) qWarning() << "QxtDiscoverableService: Setting service subtypes while not in Unknown state has no effect"; qxt_d().serviceSubTypes.removeAll(subtype); }
// @param reconf true if this is a reconfiguration and not an initial load of the configuration. // @return true if ok; throws if config really bad; false if config doesn't include self bool ReplSetImpl::initFromConfig(ReplSetConfig& c, bool reconf) { // NOTE: haveNewConfig() writes the new config to disk before we get here. So // we cannot error out at this point, except fatally. Check errors earlier. lock lk(this); if (getLastErrorDefault || !c.getLastErrorDefaults.isEmpty()) { // see comment in dbcommands.cpp for getlasterrordefault getLastErrorDefault = new BSONObj(c.getLastErrorDefaults); } list<ReplSetConfig::MemberCfg*> newOnes; // additive short-cuts the new config setup. If we are just adding a // node/nodes and nothing else is changing, this is additive. If it's // not a reconfig, we're not adding anything bool additive = reconf; bool updateConfigs = false; { unsigned nfound = 0; int me = 0; for (vector<ReplSetConfig::MemberCfg>::iterator i = c.members.begin(); i != c.members.end(); i++) { ReplSetConfig::MemberCfg& m = *i; if (m.h.isSelf()) { me++; } if (reconf) { const Member *old = findById(m._id); if (old) { nfound++; verify((int) old->id() == m._id); if (!old->config().isSameIgnoringTags(m)) { additive = false; } if (!updateConfigs && old->config() != m) { updateConfigs = true; } } else { newOnes.push_back(&m); } } } if (me == 0) { // we're not in the config -- we must have been removed if (state().shunned()) { // already took note of our ejection from the set // so just sit tight and poll again return false; } _members.orphanAll(); // kill off rsHealthPoll threads (because they Know Too Much about our past) endOldHealthTasks(); // close sockets to force clients to re-evaluate this member MessagingPort::closeAllSockets(0); // take note of our ejection changeState(MemberState::RS_SHUNNED); // go into holding pattern log() << "replSet info self not present in the repl set configuration:" << rsLog; log() << c.toString() << rsLog; loadConfig(); // redo config from scratch return false; } uassert(13302, "replSet error self appears twice in the repl set configuration", me<=1); // if we found different members that the original config, reload everything if (reconf && config().members.size() != nfound) additive = false; } // If we are changing chaining rules, we don't want this to be an additive reconfig so that // the primary can step down and the sync targets change. // TODO: This can be removed once SERVER-5208 is fixed. if (reconf && config().chainingAllowed() != c.chainingAllowed()) { additive = false; } _cfg = new ReplSetConfig(c); // config() is same thing but const, so we use that when we can for clarity below dassert(&config() == _cfg); verify(config().ok()); verify(_name.empty() || _name == config()._id); _name = config()._id; verify(!_name.empty()); // this is a shortcut for simple changes if (additive) { log() << "replSet info : additive change to configuration" << rsLog; if (updateConfigs) { // we have new configs for existing members, so we need to repopulate _members // with the most recent configs _members.orphanAll(); // for logging string members = ""; // not setting _self to 0 as other threads use _self w/o locking int me = 0; for(vector<ReplSetConfig::MemberCfg>::const_iterator i = config().members.begin(); i != config().members.end(); i++) { const ReplSetConfig::MemberCfg& m = *i; Member *mi; members += (members == "" ? "" : ", ") + m.h.toString(); if (m.h.isSelf()) { verify(me++ == 0); mi = new Member(m.h, m._id, &m, true); setSelfTo(mi); } else { mi = new Member(m.h, m._id, &m, false); _members.push(mi); } } // trigger a handshake to update the syncSource of our writeconcern information syncSourceFeedback.forwardSlaveHandshake(); } // add any new members for (list<ReplSetConfig::MemberCfg*>::const_iterator i = newOnes.begin(); i != newOnes.end(); i++) { ReplSetConfig::MemberCfg *m = *i; Member *mi = new Member(m->h, m->_id, m, false); // we will indicate that new members are up() initially so that we don't relinquish // our primary state because we can't (transiently) see a majority. they should be // up as we check that new members are up before getting here on reconfig anyway. mi->get_hbinfo().health = 0.1; _members.push(mi); startHealthTaskFor(mi); } // if we aren't creating new members, we may have to update the // groups for the current ones _cfg->updateMembers(_members); return true; } // start with no members. if this is a reconfig, drop the old ones. _members.orphanAll(); endOldHealthTasks(); int oldPrimaryId = -1; { const Member *p = box.getPrimary(); if (p) oldPrimaryId = p->id(); } forgetPrimary(); // not setting _self to 0 as other threads use _self w/o locking int me = 0; // For logging string members = ""; for (vector<ReplSetConfig::MemberCfg>::const_iterator i = config().members.begin(); i != config().members.end(); i++) { const ReplSetConfig::MemberCfg& m = *i; Member *mi; members += (members == "" ? "" : ", ") + m.h.toString(); if (m.h.isSelf()) { verify(me++ == 0); mi = new Member(m.h, m._id, &m, true); if (!reconf) { log() << "replSet I am " << m.h.toString() << rsLog; } setSelfTo(mi); if ((int)mi->id() == oldPrimaryId) box.setSelfPrimary(mi); } else { mi = new Member(m.h, m._id, &m, false); _members.push(mi); if ((int)mi->id() == oldPrimaryId) box.setOtherPrimary(mi); } } if (me == 0){ log() << "replSet warning did not detect own host in full reconfig, members " << members << " config: " << c << rsLog; } else { // Do this after we've found ourselves, since _self needs // to be set before we can start the heartbeat tasks for (Member *mb = _members.head(); mb; mb=mb->next()) { startHealthTaskFor(mb); } } return true; }
Plan::CompilationPath Plan::compileInThreadImpl(LongLivedState& longLivedState) { Graph dfg(vm, *this, longLivedState); if (!parse(dfg)) { finalizer = adoptPtr(new FailedFinalizer(*this)); return FailPath; } // By this point the DFG bytecode parser will have potentially mutated various tables // in the CodeBlock. This is a good time to perform an early shrink, which is more // powerful than a late one. It's safe to do so because we haven't generated any code // that references any of the tables directly, yet. codeBlock->shrinkToFit(CodeBlock::EarlyShrink); if (validationEnabled()) validate(dfg); performCPSRethreading(dfg); performUnification(dfg); performPredictionInjection(dfg); if (validationEnabled()) validate(dfg); performBackwardsPropagation(dfg); performPredictionPropagation(dfg); performFixup(dfg); performTypeCheckHoisting(dfg); unsigned count = 1; dfg.m_fixpointState = FixpointNotConverged; for (;; ++count) { if (logCompilationChanges()) dataLogF("DFG beginning optimization fixpoint iteration #%u.\n", count); bool changed = false; if (validationEnabled()) validate(dfg); performCFA(dfg); changed |= performConstantFolding(dfg); changed |= performArgumentsSimplification(dfg); changed |= performCFGSimplification(dfg); changed |= performCSE(dfg); if (!changed) break; performCPSRethreading(dfg); } if (logCompilationChanges()) dataLogF("DFG optimization fixpoint converged in %u iterations.\n", count); dfg.m_fixpointState = FixpointConverged; performStoreElimination(dfg); // If we're doing validation, then run some analyses, to give them an opportunity // to self-validate. Now is as good a time as any to do this. if (validationEnabled()) { dfg.m_dominators.computeIfNecessary(dfg); dfg.m_naturalLoops.computeIfNecessary(dfg); } #if ENABLE(FTL_JIT) if (Options::useExperimentalFTL() && compileMode == CompileFunction && FTL::canCompile(dfg)) { performCriticalEdgeBreaking(dfg); performLoopPreHeaderCreation(dfg); performCPSRethreading(dfg); performSSAConversion(dfg); performLivenessAnalysis(dfg); performCFA(dfg); performLICM(dfg); performLivenessAnalysis(dfg); performCFA(dfg); performDCE(dfg); // We rely on this to convert dead SetLocals into the appropriate hint, and to kill dead code that won't be recognized as dead by LLVM. performLivenessAnalysis(dfg); performFlushLivenessAnalysis(dfg); performOSRAvailabilityAnalysis(dfg); dumpAndVerifyGraph(dfg, "Graph just before FTL lowering:"); // FIXME: Support OSR entry. // https://bugs.webkit.org/show_bug.cgi?id=113625 FTL::State state(dfg); FTL::lowerDFGToLLVM(state); if (Options::reportCompileTimes()) beforeFTL = currentTimeMS(); if (Options::llvmAlwaysFails()) { FTL::fail(state); return FTLPath; } FTL::compile(state); FTL::link(state); return FTLPath; } #endif // ENABLE(FTL_JIT) performCPSRethreading(dfg); performDCE(dfg); performVirtualRegisterAllocation(dfg); dumpAndVerifyGraph(dfg, "Graph after optimization:"); JITCompiler dataFlowJIT(dfg); if (compileMode == CompileFunction) { dataFlowJIT.compileFunction(); dataFlowJIT.linkFunction(); } else { ASSERT(compileMode == CompileOther); dataFlowJIT.compile(); dataFlowJIT.link(); } return DFGPath; }