/* static */ bool WheelTransaction::WillHandleDefaultAction(WidgetWheelEvent* aWheelEvent, nsWeakFrame& aTargetWeakFrame) { nsIFrame* lastTargetFrame = GetTargetFrame(); if (!lastTargetFrame) { BeginTransaction(aTargetWeakFrame.GetFrame(), aWheelEvent); } else if (lastTargetFrame != aTargetWeakFrame.GetFrame()) { EndTransaction(); BeginTransaction(aTargetWeakFrame.GetFrame(), aWheelEvent); } else { UpdateTransaction(aWheelEvent); } // When the wheel event will not be handled with any frames, // UpdateTransaction() fires MozMouseScrollFailed event which is for // automated testing. In the event handler, the target frame might be // destroyed. Then, the caller shouldn't try to handle the default action. if (!aTargetWeakFrame.IsAlive()) { EndTransaction(); return false; } return true; }
/* static */ bool WheelTransaction::UpdateTransaction(WidgetWheelEvent* aEvent) { nsIFrame* scrollToFrame = GetTargetFrame(); nsIScrollableFrame* scrollableFrame = scrollToFrame->GetScrollTargetFrame(); if (scrollableFrame) { scrollToFrame = do_QueryFrame(scrollableFrame); } if (!WheelHandlingUtils::CanScrollOn(scrollToFrame, aEvent->deltaX, aEvent->deltaY)) { OnFailToScrollTarget(); // We should not modify the transaction state when the view will not be // scrolled actually. return false; } SetTimeout(); if (sScrollSeriesCounter != 0 && OutOfTime(sTime, kScrollSeriesTimeout)) { sScrollSeriesCounter = 0; } sScrollSeriesCounter++; // We should use current time instead of WidgetEvent.time. // 1. Some events doesn't have the correct creation time. // 2. If the computer runs slowly by other processes eating the CPU resource, // the event creation time doesn't keep real time. sTime = PR_IntervalToMilliseconds(PR_IntervalNow()); sMouseMoved = 0; return true; }
// not the fastest of routines, but I only call it occasionally... // LPCSTR CSequence::GetDisplayNameForTree(CModel* pModel, bool bIncludeAnimEnum, bool bIncludeFrameDetails, bool bViewFrameDetails_Additional, CDC* pDC) { if (pModel->IsGhoul2()) { // bIncludeAnimEnum = false; // :-) } #define ACCOUNTFORWIDTH(width) \ iWidthSoFar+=width; \ while (1) \ { \ size = pDC->GetOutputTextExtent(string); \ if (size.cx>=iWidthSoFar) \ break; \ string+=" "; \ } static CString string; int iWidthSoFar=0; CSize size; string.Empty(); if (bIncludeFrameDetails) { CString temp; temp.Format("( Frames: Target %4d, Count %4d%sLoop %4d, Speed %4d )",GetTargetFrame(),GetFrameCount(),GetGenLoopFrame()?"+1, ":", ",GetLoopFrame(),GetFrameSpeed()); string += temp; ACCOUNTFORWIDTH(400); } string += GetName(); ACCOUNTFORWIDTH(250); if (bIncludeAnimEnum && strlen(GetEnum())) //ValidEnum()) { CString _enum; if (ValidEnum()) { _enum.Format("( %s",GetEnum()); } else { _enum.Format("( (BAD: %s)",GetEnum()); } string += _enum; for (int i=0; i<MAX_ADDITIONAL_SEQUENCES; i++) { if (AdditionalSeqs[i]->AdditionalSequenceIsValid()) { string += ", "; // spaces seem pretty small in default font string += AdditionalSeqs[i]->GetEnum(); if (bViewFrameDetails_Additional) { CString temp; temp.Format("(T:%d C:%d L:%d S:%d)", AdditionalSeqs[i]->GetTargetFrame(), AdditionalSeqs[i]->GetFrameCount(), AdditionalSeqs[i]->GetLoopFrame(), AdditionalSeqs[i]->GetFrameSpeed() ); string += temp; } } else { // either empty string, or a bad enum... (because of anims.h being edited) // if (strlen(AdditionalSeqs[i]->GetEnum())) { string += ", "; string += va("(BAD: %s)",AdditionalSeqs[i]->GetEnum()); } } } string += " )"; ACCOUNTFORWIDTH(200); // this is flawed now because of additional-seqs, so keep this string as the last one } return string; }