Bug 1348236 - coding style fixes for nsAutoScrollTimer and its uses in nsSelection. r=heycam

MozReview-Commit-ID: GlfYK7NpTWX

--HG--
extra : rebase_source : 16e94c14269f8684b6eb3dfb4a2f408ec3763230
This commit is contained in:
Jeremy Chen 2017-03-19 00:40:30 +08:00
parent db670f1744
commit 7a35c86351

View File

@ -265,13 +265,13 @@ public:
mContent = nsIPresShell::GetCapturingContent();
if (!mTimer)
{
if (!mTimer) {
nsresult result;
mTimer = do_CreateInstance("@mozilla.org/timer;1", &result);
if (NS_FAILED(result))
if (NS_FAILED(result)) {
return result;
}
}
return mTimer->InitWithCallback(this, mDelay, nsITimer::TYPE_ONE_SHOT);
@ -279,8 +279,7 @@ public:
nsresult Stop()
{
if (mTimer)
{
if (mTimer) {
mTimer->Cancel();
mTimer = nullptr;
}
@ -308,15 +307,17 @@ public:
{
AutoWeakFrame frame =
mContent ? mPresContext->GetPrimaryFrameFor(mContent) : nullptr;
if (!frame)
if (!frame) {
return NS_OK;
}
mContent = nullptr;
nsPoint pt = mPoint -
frame->GetOffsetTo(mPresContext->PresShell()->FrameManager()->GetRootFrame());
mFrameSelection->HandleDrag(frame, pt);
if (!frame.IsAlive())
if (!frame.IsAlive()) {
return NS_OK;
}
NS_ASSERTION(frame->PresContext() == mPresContext, "document mismatch?");
mSelection->DoAutoScroll(frame, pt);
@ -327,9 +328,9 @@ public:
protected:
virtual ~nsAutoScrollTimer()
{
if (mTimer) {
mTimer->Cancel();
}
if (mTimer) {
mTimer->Cancel();
}
}
private:
@ -1724,8 +1725,9 @@ nsFrameSelection::StartAutoScrollTimer(nsIFrame *aFrame,
uint32_t aDelay)
{
int8_t index = GetIndexFromSelectionType(SelectionType::eNormal);
if (!mDomSelections[index])
if (!mDomSelections[index]) {
return NS_ERROR_NULL_POINTER;
}
return mDomSelections[index]->StartAutoScrollTimer(aFrame, aPoint, aDelay);
}
@ -1734,8 +1736,9 @@ void
nsFrameSelection::StopAutoScrollTimer()
{
int8_t index = GetIndexFromSelectionType(SelectionType::eNormal);
if (!mDomSelections[index])
if (!mDomSelections[index]) {
return;
}
mDomSelections[index]->StopAutoScrollTimer();
}
@ -4825,23 +4828,25 @@ Selection::StartAutoScrollTimer(nsIFrame* aFrame, nsPoint& aPoint,
NS_PRECONDITION(aFrame, "Need a frame");
nsresult result;
if (!mFrameSelection)
if (!mFrameSelection) {
return NS_OK;//nothing to do
}
if (!mAutoScrollTimer)
{
if (!mAutoScrollTimer) {
mAutoScrollTimer = new nsAutoScrollTimer();
result = mAutoScrollTimer->Init(mFrameSelection, this);
if (NS_FAILED(result))
if (NS_FAILED(result)) {
return result;
}
}
result = mAutoScrollTimer->SetDelay(aDelay);
if (NS_FAILED(result))
if (NS_FAILED(result)) {
return result;
}
return DoAutoScroll(aFrame, aPoint);
}
@ -4852,7 +4857,7 @@ Selection::StopAutoScrollTimer()
if (mAutoScrollTimer) {
return mAutoScrollTimer->Stop();
}
return NS_OK;
return NS_OK;
}
nsresult
@ -4860,8 +4865,9 @@ Selection::DoAutoScroll(nsIFrame* aFrame, nsPoint& aPoint)
{
NS_PRECONDITION(aFrame, "Need a frame");
if (mAutoScrollTimer)
if (mAutoScrollTimer) {
(void)mAutoScrollTimer->Stop();
}
nsPresContext* presContext = aFrame->PresContext();
nsCOMPtr<nsIPresShell> shell = presContext->PresShell();