Commit 0d495680 authored by Seth Fowler's avatar Seth Fowler
Browse files

Bug 1285867 (Part 3e) - Use TerminalState to exit the Decode() loop. r=edwin

parent 87c5e4a5
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -164,10 +164,6 @@ Decoder::Decode(NotNull<IResumable*> aOnResume)
        // Pass the data along to the implementation.
        terminalState = DoDecode(*mIterator);

        if (terminalState == Some(TerminalState::FAILURE)) {
          PostDataError();
        }

        break;
      }

@@ -175,7 +171,12 @@ Decoder::Decode(NotNull<IResumable*> aOnResume)
        MOZ_ASSERT_UNREACHABLE("Unknown SourceBufferIterator state");
        terminalState = Some(TerminalState::FAILURE);
    }
  } while (!GetDecodeDone() && !HasError());
  } while (!GetDecodeDone() && !terminalState);

  // If decoding failed, record that fact.
  if (terminalState == Some(TerminalState::FAILURE)) {
    PostDataError();
  }

  CompleteDecode();
  return HasError() ? NS_ERROR_FAILURE : NS_OK;
+13 −6
Original line number Diff line number Diff line
@@ -262,12 +262,19 @@ nsBMPDecoder::FinishInternal()
    nsIntRect r(0, 0, mH.mWidth, AbsoluteHeight());
    PostInvalidation(r);

    if (mDoesHaveTransparency) {
      MOZ_ASSERT(mMayHaveTransparency);
      PostFrameStop(Opacity::SOME_TRANSPARENCY);
    } else {
      PostFrameStop(Opacity::FULLY_OPAQUE);
    }
    MOZ_ASSERT_IF(mDoesHaveTransparency, mMayHaveTransparency);

    // We have transparency if we either detected some in the image itself
    // (i.e., |mDoesHaveTransparency| is true) or we're in an ICO, which could
    // mean we have an AND mask that provides transparency (i.e., |mIsWithinICO|
    // is true).
    // XXX(seth): We can tell when we create the decoder if the AND mask is
    // present, so we could be more precise about this.
    const Opacity opacity = mDoesHaveTransparency || mIsWithinICO
                          ? Opacity::SOME_TRANSPARENCY
                          : Opacity::FULLY_OPAQUE;

    PostFrameStop(opacity);
    PostDecodeDone();
  }

+0 −7
Original line number Diff line number Diff line
@@ -142,13 +142,6 @@ public:
  /// bitmap has been fully decoded.)
  bool HasTransparency() const { return mDoesHaveTransparency; }

  /// Force transparency from outside. (Used by the ICO decoder.)
  void SetHasTransparency()
  {
    mMayHaveTransparency = true;
    mDoesHaveTransparency = true;
  }

  Maybe<TerminalState> DoDecode(SourceBufferIterator& aIterator) override;
  nsresult BeforeFinishInternal() override;
  nsresult FinishInternal() override;
+0 −9
Original line number Diff line number Diff line
@@ -573,15 +573,6 @@ nsICODecoder::FinishMask()
    }
  }

  // If the mask contained any transparent pixels, record that fact.
  if (mHasMaskAlpha) {
    PostHasTransparency();

    RefPtr<nsBMPDecoder> bmpDecoder =
      static_cast<nsBMPDecoder*>(mContainedDecoder.get());
    bmpDecoder->SetHasTransparency();
  }

  return Transition::To(ICOState::FINISHED_RESOURCE, 0);
}