Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(855)

Unified Diff: third_party/WebKit/Source/core/frame/FrameView.cpp

Issue 2259983003: Add a choice not to crash when unexpected dirty layout is encountered (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add todos Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/frame/FrameView.cpp
diff --git a/third_party/WebKit/Source/core/frame/FrameView.cpp b/third_party/WebKit/Source/core/frame/FrameView.cpp
index 9d93a5fb2b42126d2194a639970391c26ef15663..4540fb1dbad6fbd565bbdc172167e82988b3e6fa 100644
--- a/third_party/WebKit/Source/core/frame/FrameView.cpp
+++ b/third_party/WebKit/Source/core/frame/FrameView.cpp
@@ -121,6 +121,20 @@
#include "wtf/StdLibExtras.h"
#include <memory>
+// Change the the following line to "#if 0" to disable crash on unexpected
+// dirty layout (crbug.com/590856) when dcheck is off.
+#if 1
+#define CHECK_FOR_DIRTY_LAYOUT CHECK
+#else
+#define CHECK_FOR_DIRTY_LAYOUT(arg) \
+do { \
+ if (!(arg)) { \
+ NOTREACHED(); \
+ return false; \
+ } \
+} while (false)
+#endif
+
namespace blink {
using namespace HTMLNames;
@@ -1845,16 +1859,15 @@ void FrameView::layoutOrthogonalWritingModeRoots()
}
}
-void FrameView::checkLayoutInvalidationIsAllowed() const
+bool FrameView::checkLayoutInvalidationIsAllowed() const
{
if (m_allowsLayoutInvalidationAfterLayoutClean)
- return;
-
- if (!m_frame->document())
- return;
+ return true;
// If we are updating all lifecycle phases beyond LayoutClean, we don't expect dirty layout after LayoutClean.
- CHECK(lifecycle().state() < DocumentLifecycle::LayoutClean);
+ CHECK_FOR_DIRTY_LAYOUT(lifecycle().state() < DocumentLifecycle::LayoutClean);
+
+ return true;
}
void FrameView::scheduleRelayout()
@@ -1863,9 +1876,9 @@ void FrameView::scheduleRelayout()
if (!m_layoutSchedulingEnabled)
return;
-
- checkLayoutInvalidationIsAllowed();
-
+ // TODO(crbug.com/590856): It's still broken when we choose not to crash when the check fails.
+ if (!checkLayoutInvalidationIsAllowed())
+ return;
if (!needsLayout())
return;
if (!m_frame->document()->shouldScheduleLayout())
@@ -1886,7 +1899,9 @@ void FrameView::scheduleRelayoutOfSubtree(LayoutObject* relayoutRoot)
{
DCHECK(m_frame->view() == this);
- checkLayoutInvalidationIsAllowed();
+ // TODO(crbug.com/590856): It's still broken when we choose not to crash when the check fails.
+ if (!checkLayoutInvalidationIsAllowed())
+ return;
// FIXME: Should this call shouldScheduleLayout instead?
if (!m_frame->document()->isActive())
@@ -1938,20 +1953,23 @@ bool FrameView::needsLayout() const
|| isSubtreeLayout();
}
-NOINLINE void FrameView::checkDoesNotNeedLayout() const
+NOINLINE bool FrameView::checkDoesNotNeedLayout() const
{
- CHECK(!layoutPending());
- CHECK(layoutViewItem().isNull() || !layoutViewItem().needsLayout());
- CHECK(!isSubtreeLayout());
+ CHECK_FOR_DIRTY_LAYOUT(!layoutPending());
+ CHECK_FOR_DIRTY_LAYOUT(layoutViewItem().isNull() || !layoutViewItem().needsLayout());
+ CHECK_FOR_DIRTY_LAYOUT(!isSubtreeLayout());
+ return true;
}
void FrameView::setNeedsLayout()
{
- checkLayoutInvalidationIsAllowed();
-
LayoutViewItem layoutViewItem = this->layoutViewItem();
- if (!layoutViewItem.isNull())
- layoutViewItem.setNeedsLayout(LayoutInvalidationReason::Unknown);
+ if (layoutViewItem.isNull())
+ return;
+ // TODO(crbug.com/590856): It's still broken if we choose not to crash when the check fails.
+ if (!checkLayoutInvalidationIsAllowed())
+ return;
+ layoutViewItem.setNeedsLayout(LayoutInvalidationReason::Unknown);
}
bool FrameView::isTransparent() const
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameView.h ('k') | third_party/WebKit/Source/core/paint/FramePainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698