parser/html/nsHtml5AutoPauseUpdate.h
author Boris Zbarsky <bzbarsky@mit.edu>
Tue, 29 May 2018 22:58:49 -0400
changeset 477120 e46b5b3027713125c2e472c3d1d9dc0ba8a3387a
parent 442884 3660e2cf9fdbb05e7890f70e9a35572a0d714694
child 508163 6f3709b3878117466168c40affa7bca0b60cf75b
permissions -rw-r--r--
Bug 1455676 part 14. Remove most use of nsIDOMNode in dom/. r=qdot

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 sw=2 et tw=78: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef nsHtml5AutoPauseUpdate_h
#define nsHtml5AutoPauseUpdate_h

class MOZ_RAII nsHtml5AutoPauseUpdate final
{
private:
  RefPtr<nsHtml5DocumentBuilder> mBuilder;

public:
  explicit nsHtml5AutoPauseUpdate(nsHtml5DocumentBuilder* aBuilder)
    : mBuilder(aBuilder)
  {
    mBuilder->EndDocUpdate();
  }
  ~nsHtml5AutoPauseUpdate()
  {
    // Something may have terminated the parser during the update pause.
    if (!mBuilder->IsComplete()) {
      mBuilder->BeginDocUpdate();
    }
  }
};

#endif // nsHtml5AutoPauseUpdate_h