Skip to content

Commit

Permalink
Unreviewed, reverting 264051@main.
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=259381

Caused a release assertion failure in RenderBlock::endAndCommitUpdateScrollInfoAfterLayoutTransaction

Reverted changeset:

"Deploy LayoutDisallowedScope in LayoutPhase::InRenderTreeLayout"
https://bugs.webkit.org/show_bug.cgi?id=256661
https://commits.webkit.org/264051@main

Canonical link: https://commits.webkit.org/266193@main
  • Loading branch information
webkit-commit-queue authored and rniwa committed Jul 21, 2023
1 parent 8c1fe1c commit f703c1c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 34 deletions.
3 changes: 1 addition & 2 deletions Source/WebCore/page/LocalFrameViewLayoutContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void LocalFrameViewLayoutContext::layout()
void LocalFrameViewLayoutContext::performLayout()
{
RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!frame().document()->inRenderTreeUpdate());
RELEASE_ASSERT(LayoutDisallowedScope::isLayoutAllowed());
ASSERT(LayoutDisallowedScope::isLayoutAllowed());
ASSERT(!view().isPainting());
ASSERT(frame().view() == &view());
ASSERT(frame().document());
Expand Down Expand Up @@ -246,7 +246,6 @@ void LocalFrameViewLayoutContext::performLayout()
{
SetForScope layoutPhase(m_layoutPhase, LayoutPhase::InRenderTreeLayout);
ScriptDisallowedScope::InMainThread scriptDisallowedScope;
LayoutDisallowedScope layoutDisallowedScope(LayoutDisallowedScope::Reason::ReentrancyAvoidance);
SubtreeLayoutStateMaintainer subtreeLayoutStateMaintainer(subtreeLayoutRoot());
RenderView::RepaintRegionAccumulator repaintRegionAccumulator(renderView());
#ifndef NDEBUG
Expand Down
6 changes: 5 additions & 1 deletion Source/WebCore/rendering/LayoutDisallowedScope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@

namespace WebCore {

unsigned LayoutDisallowedScope::s_currentScopeCount = 0;
#if ASSERT_ENABLED

LayoutDisallowedScope* LayoutDisallowedScope::s_currentAssertion = nullptr;

#endif

}
45 changes: 18 additions & 27 deletions Source/WebCore/rendering/LayoutDisallowedScope.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,33 @@

#pragma once

#include "RuntimeApplicationChecks.h"
#include <wtf/Compiler.h>

namespace WebCore {

class LayoutDisallowedScope {
public:
enum class Reason : bool { PerformanceOptimization, ReentrancyAvoidance };

LayoutDisallowedScope(Reason) { ++s_currentScopeCount; }
~LayoutDisallowedScope() { --s_currentScopeCount; }
enum class Reason { PerformanceOptimization, ReentrancyAvoidance };

static bool isLayoutAllowed() { return LIKELY(!s_currentScopeCount) || UNLIKELY(!isInWebProcess()); }
#if !ASSERT_ENABLED
LayoutDisallowedScope(Reason) { }
static bool isLayoutAllowed() { return true; }
#else // ASSERT_ENABLED
LayoutDisallowedScope(Reason)
: m_previousAssertion(s_currentAssertion)
{
s_currentAssertion = this;
}

class AllowedScope {
public:
AllowedScope();
~AllowedScope();
~LayoutDisallowedScope()
{
s_currentAssertion = m_previousAssertion;
}

private:
unsigned m_originalCount;
};
static bool isLayoutAllowed() { return !s_currentAssertion; }

private:
static unsigned s_currentScopeCount;
LayoutDisallowedScope* m_previousAssertion;
static LayoutDisallowedScope* s_currentAssertion;
#endif // ASSERT_ENABLED
};

ALWAYS_INLINE LayoutDisallowedScope::AllowedScope::AllowedScope()
: m_originalCount { s_currentScopeCount }
{
s_currentScopeCount = 0;
}

ALWAYS_INLINE LayoutDisallowedScope::AllowedScope::~AllowedScope()
{
s_currentScopeCount = m_originalCount;
}

}
4 changes: 0 additions & 4 deletions Source/WebCore/svg/graphics/SVGImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include "ImageObserver.h"
#include "IntRect.h"
#include "JSDOMWindowBase.h"
#include "LayoutDisallowedScope.h"
#include "LegacyRenderSVGRoot.h"
#include "LocalDOMWindow.h"
#include "LocalFrame.h"
Expand Down Expand Up @@ -191,8 +190,6 @@ ImageDrawResult SVGImage::drawForContainer(GraphicsContext& context, const Float
if (!m_page)
return ImageDrawResult::DidNothing;

LayoutDisallowedScope::AllowedScope layoutAllowedScope; // Allow layout in the SVG document for this image.

ImageObserver* observer = imageObserver();
ASSERT(observer);

Expand Down Expand Up @@ -315,7 +312,6 @@ ImageDrawResult SVGImage::draw(GraphicsContext& context, const FloatRect& dstRec

{
ScriptDisallowedScope::DisableAssertionsInScope disabledScope;
LayoutDisallowedScope::AllowedScope layoutAllowedScope;
if (view->needsLayout())
view->layoutContext().layout();
}
Expand Down

0 comments on commit f703c1c

Please sign in to comment.