blob: ef2ae2f05f630f142a03f20cda0b907d2066b6ff [file] [log] [blame]
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "core/frame/DeprecatedScheduleStyleRecalcDuringLayout.h"
#include "platform/wtf/Assertions.h"
namespace blink {
DeprecatedScheduleStyleRecalcDuringLayout::
DeprecatedScheduleStyleRecalcDuringLayout(DocumentLifecycle& lifecycle)
: lifecycle_(lifecycle),
deprecated_transition_(DocumentLifecycle::kInPerformLayout,
DocumentLifecycle::kVisualUpdatePending),
was_in_perform_layout_(lifecycle.GetState() ==
DocumentLifecycle::kInPerformLayout) {}
DeprecatedScheduleStyleRecalcDuringLayout::
~DeprecatedScheduleStyleRecalcDuringLayout() {
// This block of code is intended to restore the state machine to the
// proper state. The style recalc will still have been schedule, however.
if (was_in_perform_layout_ &&
lifecycle_.GetState() != DocumentLifecycle::kInPerformLayout) {
DCHECK_EQ(lifecycle_.GetState(), DocumentLifecycle::kVisualUpdatePending);
lifecycle_.AdvanceTo(DocumentLifecycle::kInPerformLayout);
}
}
} // namespace blink