Diff
Modified: trunk/Source/WebCore/ChangeLog (230965 => 230966)
--- trunk/Source/WebCore/ChangeLog 2018-04-24 19:19:47 UTC (rev 230965)
+++ trunk/Source/WebCore/ChangeLog 2018-04-24 19:48:53 UTC (rev 230966)
@@ -1,3 +1,126 @@
+2018-04-24 Antti Koivisto <an...@apple.com>
+
+ Rename LayoutCtx.h/cpp to LayoutContext.h/cpp
+ https://bugs.webkit.org/show_bug.cgi?id=184922
+
+ Reviewed by Zalan Bujtas.
+
+ To achieve this the existing LayoutContext class is renamed to FrameViewLayoutContext.
+
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * layout/LayoutContext.cpp: Copied from Source/WebCore/layout/LayoutCtx.cpp.
+ * layout/LayoutContext.h: Copied from Source/WebCore/layout/LayoutCtx.h.
+ * layout/LayoutCtx.cpp: Removed.
+ * layout/LayoutCtx.h: Removed.
+ * page/FrameView.cpp:
+ (WebCore::FrameView::shouldDeferScrollUpdateAfterContentSizeChange):
+ (WebCore::FrameView::updateLayoutViewport):
+ (WebCore::FrameView::updateLayerPositionsAfterScrolling):
+ (WebCore::FrameView::updateCompositingLayersAfterScrolling):
+ (WebCore::FrameView::availableContentSizeChanged):
+ * page/FrameView.h:
+ * page/FrameViewLayoutContext.cpp: Copied from Source/WebCore/page/LayoutContext.cpp.
+ (WebCore::LayoutScope::LayoutScope):
+ (WebCore::FrameViewLayoutContext::FrameViewLayoutContext):
+ (WebCore::FrameViewLayoutContext::~FrameViewLayoutContext):
+ (WebCore::FrameViewLayoutContext::layout):
+ (WebCore::FrameViewLayoutContext::runOrScheduleAsynchronousTasks):
+ (WebCore::FrameViewLayoutContext::runAsynchronousTasks):
+ (WebCore::FrameViewLayoutContext::flushAsynchronousTasks):
+ (WebCore::FrameViewLayoutContext::reset):
+ (WebCore::FrameViewLayoutContext::needsLayout const):
+ (WebCore::FrameViewLayoutContext::setNeedsLayout):
+ (WebCore::FrameViewLayoutContext::enableSetNeedsLayout):
+ (WebCore::FrameViewLayoutContext::disableSetNeedsLayout):
+ (WebCore::FrameViewLayoutContext::scheduleLayout):
+ (WebCore::FrameViewLayoutContext::unscheduleLayout):
+ (WebCore::FrameViewLayoutContext::scheduleSubtreeLayout):
+ (WebCore::FrameViewLayoutContext::layoutTimerFired):
+ (WebCore::FrameViewLayoutContext::convertSubtreeLayoutToFullLayout):
+ (WebCore::FrameViewLayoutContext::setSubtreeLayoutRoot):
+ (WebCore::FrameViewLayoutContext::canPerformLayout const):
+ (WebCore::FrameViewLayoutContext::applyTextSizingIfNeeded):
+ (WebCore::FrameViewLayoutContext::updateStyleForLayout):
+ (WebCore::FrameViewLayoutContext::handleLayoutWithFrameFlatteningIfNeeded):
+ (WebCore::FrameViewLayoutContext::startLayoutAtMainFrameViewIfNeeded):
+ (WebCore::FrameViewLayoutContext::layoutDelta const):
+ (WebCore::FrameViewLayoutContext::addLayoutDelta):
+ (WebCore::FrameViewLayoutContext::layoutDeltaMatches):
+ (WebCore::FrameViewLayoutContext::layoutState const):
+ (WebCore::FrameViewLayoutContext::pushLayoutState):
+ (WebCore::FrameViewLayoutContext::pushLayoutStateForPaginationIfNeeded):
+ (WebCore::FrameViewLayoutContext::popLayoutState):
+ (WebCore::FrameViewLayoutContext::checkLayoutState):
+ (WebCore::FrameViewLayoutContext::frame const):
+ (WebCore::FrameViewLayoutContext::view const):
+ (WebCore::FrameViewLayoutContext::renderView const):
+ (WebCore::FrameViewLayoutContext::document const):
+ (WebCore::LayoutContext::LayoutContext): Deleted.
+ (WebCore::LayoutContext::~LayoutContext): Deleted.
+ (WebCore::LayoutContext::layout): Deleted.
+ (WebCore::LayoutContext::runOrScheduleAsynchronousTasks): Deleted.
+ (WebCore::LayoutContext::runAsynchronousTasks): Deleted.
+ (WebCore::LayoutContext::flushAsynchronousTasks): Deleted.
+ (WebCore::LayoutContext::reset): Deleted.
+ (WebCore::LayoutContext::needsLayout const): Deleted.
+ (WebCore::LayoutContext::setNeedsLayout): Deleted.
+ (WebCore::LayoutContext::enableSetNeedsLayout): Deleted.
+ (WebCore::LayoutContext::disableSetNeedsLayout): Deleted.
+ (WebCore::LayoutContext::scheduleLayout): Deleted.
+ (WebCore::LayoutContext::unscheduleLayout): Deleted.
+ (WebCore::LayoutContext::scheduleSubtreeLayout): Deleted.
+ (WebCore::LayoutContext::layoutTimerFired): Deleted.
+ (WebCore::LayoutContext::convertSubtreeLayoutToFullLayout): Deleted.
+ (WebCore::LayoutContext::setSubtreeLayoutRoot): Deleted.
+ (WebCore::LayoutContext::canPerformLayout const): Deleted.
+ (WebCore::LayoutContext::applyTextSizingIfNeeded): Deleted.
+ (WebCore::LayoutContext::updateStyleForLayout): Deleted.
+ (WebCore::LayoutContext::handleLayoutWithFrameFlatteningIfNeeded): Deleted.
+ (WebCore::LayoutContext::startLayoutAtMainFrameViewIfNeeded): Deleted.
+ (WebCore::LayoutContext::layoutDelta const): Deleted.
+ (WebCore::LayoutContext::addLayoutDelta): Deleted.
+ (WebCore::LayoutContext::layoutDeltaMatches): Deleted.
+ (WebCore::LayoutContext::layoutState const): Deleted.
+ (WebCore::LayoutContext::pushLayoutState): Deleted.
+ (WebCore::LayoutContext::pushLayoutStateForPaginationIfNeeded): Deleted.
+ (WebCore::LayoutContext::popLayoutState): Deleted.
+ (WebCore::LayoutContext::checkLayoutState): Deleted.
+ (WebCore::LayoutContext::frame const): Deleted.
+ (WebCore::LayoutContext::view const): Deleted.
+ (WebCore::LayoutContext::renderView const): Deleted.
+ (WebCore::LayoutContext::document const): Deleted.
+ * page/FrameViewLayoutContext.h: Copied from Source/WebCore/page/LayoutContext.h.
+ (WebCore::LayoutContext::startDisallowingLayout): Deleted.
+ (WebCore::LayoutContext::endDisallowingLayout): Deleted.
+ (WebCore::LayoutContext::layoutPhase const): Deleted.
+ (WebCore::LayoutContext::isLayoutNested const): Deleted.
+ (WebCore::LayoutContext::isLayoutPending const): Deleted.
+ (WebCore::LayoutContext::isInLayout const): Deleted.
+ (WebCore::LayoutContext::isInRenderTreeLayout const): Deleted.
+ (WebCore::LayoutContext::inPaintableState const): Deleted.
+ (WebCore::LayoutContext::layoutCount const): Deleted.
+ (WebCore::LayoutContext::subtreeLayoutRoot const): Deleted.
+ (WebCore::LayoutContext::clearSubtreeLayoutRoot): Deleted.
+ (WebCore::LayoutContext::resetFirstLayoutFlag): Deleted.
+ (WebCore::LayoutContext::didFirstLayout const): Deleted.
+ (WebCore::LayoutContext::setNeedsFullRepaint): Deleted.
+ (WebCore::LayoutContext::needsFullRepaint const): Deleted.
+ (WebCore::LayoutContext::isPaintOffsetCacheEnabled const): Deleted.
+ (WebCore::LayoutContext::layoutDisallowed const): Deleted.
+ (WebCore::LayoutContext::isLayoutSchedulingEnabled const): Deleted.
+ (WebCore::LayoutContext::inAsynchronousTasks const): Deleted.
+ (WebCore::LayoutContext::disablePaintOffsetCache): Deleted.
+ (WebCore::LayoutContext::enablePaintOffsetCache): Deleted.
+ * page/LayoutContext.cpp: Removed.
+ * page/LayoutContext.h: Removed.
+ * rendering/LayoutState.cpp:
+ (WebCore::LayoutState::LayoutState):
+ (WebCore::LayoutState::computePaginationInformation):
+ (WebCore::LayoutState::establishLineGrid):
+ (WebCore::LayoutStateDisabler::LayoutStateDisabler):
+ * rendering/LayoutState.h:
+
2018-04-24 Mark Lam <mark....@apple.com>
Need to acquire the VM lock before calling toNumber on a JSValue.
Modified: trunk/Source/WebCore/Sources.txt (230965 => 230966)
--- trunk/Source/WebCore/Sources.txt 2018-04-24 19:19:47 UTC (rev 230965)
+++ trunk/Source/WebCore/Sources.txt 2018-04-24 19:48:53 UTC (rev 230966)
@@ -1217,7 +1217,7 @@
layout/FloatingState.cpp
layout/FormattingContext.cpp
layout/FormattingState.cpp
-layout/LayoutCtx.cpp
+layout/LayoutContext.cpp
layout/blockformatting/BlockFormattingContext.cpp
layout/blockformatting/BlockFormattingState.cpp
layout/blockformatting/BlockMarginCollapse.cpp
@@ -1361,10 +1361,10 @@
page/FrameSnapshotting.cpp
page/FrameTree.cpp
page/FrameView.cpp
+page/FrameViewLayoutContext.cpp
page/History.cpp
page/IntersectionObserver.cpp
page/IntersectionObserverEntry.cpp
-page/LayoutContext.cpp
page/Location.cpp
page/MemoryRelease.cpp
page/MouseEventWithHitTestResults.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (230965 => 230966)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-04-24 19:19:47 UTC (rev 230965)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-04-24 19:48:53 UTC (rev 230966)
@@ -391,7 +391,7 @@
10FB084B14E15C7E00A3DB98 /* PublicURLManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 10FB084A14E15C7E00A3DB98 /* PublicURLManager.h */; };
112B34D51E60B98300BB310A /* SimpleLineLayoutPagination.h in Headers */ = {isa = PBXBuildFile; fileRef = 112B34D41E60B98300BB310A /* SimpleLineLayoutPagination.h */; };
113409DA203E038000C66915 /* RenderTreeBuilderContinuation.h in Headers */ = {isa = PBXBuildFile; fileRef = 113409D8203E038000C66915 /* RenderTreeBuilderContinuation.h */; };
- 113D0B521F9FDD2B00F611BB /* LayoutContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 113D0B501F9FDD2B00F611BB /* LayoutContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 113D0B521F9FDD2B00F611BB /* FrameViewLayoutContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 113D0B501F9FDD2B00F611BB /* FrameViewLayoutContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
115CFA6A208AF7D0001E6991 /* FormattingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 115CFA68208AF7D0001E6991 /* FormattingContext.h */; };
115CFA6E208AFAB7001E6991 /* BlockFormattingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 115CFA6C208AFAB6001E6991 /* BlockFormattingContext.h */; };
115CFA76208AFE30001E6991 /* FormattingState.h in Headers */ = {isa = PBXBuildFile; fileRef = 115CFA74208AFE30001E6991 /* FormattingState.h */; };
@@ -1955,8 +1955,8 @@
6ED8C37A183BFF8C009E53BD /* BoxShape.h in Headers */ = {isa = PBXBuildFile; fileRef = 6ED8C378183BFF8C009E53BD /* BoxShape.h */; settings = {ATTRIBUTES = (Private, ); }; };
6EE8A77310F803F3005A4A24 /* JSWebGLContextAttributes.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EE8A77110F803F3005A4A24 /* JSWebGLContextAttributes.h */; };
6F222B761AB52D8A0094651A /* WebGLVertexArrayObjectBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6F222B751AB52D8A0094651A /* WebGLVertexArrayObjectBase.cpp */; };
- 6F7CA3C6208C2957002F29AB /* LayoutCtx.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F7CA3C4208C2956002F29AB /* LayoutCtx.h */; };
- 6F7CA3C7208C2957002F29AB /* LayoutCtx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6F7CA3C5208C2956002F29AB /* LayoutCtx.cpp */; };
+ 6F7CA3C6208C2957002F29AB /* LayoutContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F7CA3C4208C2956002F29AB /* LayoutContext.h */; };
+ 6F7CA3C7208C2957002F29AB /* LayoutContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6F7CA3C5208C2956002F29AB /* LayoutContext.cpp */; };
6F7CA3CA208C2B2E002F29AB /* InlineFormattingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F7CA3C8208C2B2E002F29AB /* InlineFormattingContext.h */; };
6F7CA3CB208C2B2E002F29AB /* InlineFormattingContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6F7CA3C9208C2B2E002F29AB /* InlineFormattingContext.cpp */; };
6F995A151A70756200A735F4 /* WebGLSync.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6F995A131A70756200A735F4 /* WebGLSync.cpp */; };
@@ -5723,8 +5723,8 @@
112B34D41E60B98300BB310A /* SimpleLineLayoutPagination.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayoutPagination.h; sourceTree = "<group>"; };
113409D7203E038000C66915 /* RenderTreeBuilderContinuation.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTreeBuilderContinuation.cpp; sourceTree = "<group>"; };
113409D8203E038000C66915 /* RenderTreeBuilderContinuation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderTreeBuilderContinuation.h; sourceTree = "<group>"; };
- 113D0B4F1F9FDD2B00F611BB /* LayoutContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutContext.cpp; sourceTree = "<group>"; };
- 113D0B501F9FDD2B00F611BB /* LayoutContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutContext.h; sourceTree = "<group>"; };
+ 113D0B4F1F9FDD2B00F611BB /* FrameViewLayoutContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FrameViewLayoutContext.cpp; sourceTree = "<group>"; };
+ 113D0B501F9FDD2B00F611BB /* FrameViewLayoutContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FrameViewLayoutContext.h; sourceTree = "<group>"; };
115CFA68208AF7D0001E6991 /* FormattingContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FormattingContext.h; sourceTree = "<group>"; };
115CFA69208AF7D0001E6991 /* FormattingContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FormattingContext.cpp; sourceTree = "<group>"; };
115CFA6C208AFAB6001E6991 /* BlockFormattingContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BlockFormattingContext.h; sourceTree = "<group>"; };
@@ -8862,8 +8862,8 @@
6EE8A77110F803F3005A4A24 /* JSWebGLContextAttributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLContextAttributes.h; sourceTree = "<group>"; };
6F222B741AB52D640094651A /* WebGLVertexArrayObjectBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGLVertexArrayObjectBase.h; sourceTree = "<group>"; };
6F222B751AB52D8A0094651A /* WebGLVertexArrayObjectBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebGLVertexArrayObjectBase.cpp; sourceTree = "<group>"; };
- 6F7CA3C4208C2956002F29AB /* LayoutCtx.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutCtx.h; sourceTree = "<group>"; };
- 6F7CA3C5208C2956002F29AB /* LayoutCtx.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutCtx.cpp; sourceTree = "<group>"; };
+ 6F7CA3C4208C2956002F29AB /* LayoutContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutContext.h; sourceTree = "<group>"; };
+ 6F7CA3C5208C2956002F29AB /* LayoutContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutContext.cpp; sourceTree = "<group>"; };
6F7CA3C8208C2B2E002F29AB /* InlineFormattingContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InlineFormattingContext.h; sourceTree = "<group>"; };
6F7CA3C9208C2B2E002F29AB /* InlineFormattingContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InlineFormattingContext.cpp; sourceTree = "<group>"; };
6F995A091A7070E600A735F4 /* WebGLQuery.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebGLQuery.idl; sourceTree = "<group>"; };
@@ -15648,8 +15648,8 @@
115CFA68208AF7D0001E6991 /* FormattingContext.h */,
115CFA75208AFE30001E6991 /* FormattingState.cpp */,
115CFA74208AFE30001E6991 /* FormattingState.h */,
- 6F7CA3C5208C2956002F29AB /* LayoutCtx.cpp */,
- 6F7CA3C4208C2956002F29AB /* LayoutCtx.h */,
+ 6F7CA3C5208C2956002F29AB /* LayoutContext.cpp */,
+ 6F7CA3C4208C2956002F29AB /* LayoutContext.h */,
);
path = layout;
sourceTree = "<group>";
@@ -19203,6 +19203,8 @@
65A21483097A3F5300B9050A /* FrameTree.h */,
65CBFEF70974F607001DAC25 /* FrameView.cpp */,
65CBFEF80974F607001DAC25 /* FrameView.h */,
+ 113D0B4F1F9FDD2B00F611BB /* FrameViewLayoutContext.cpp */,
+ 113D0B501F9FDD2B00F611BB /* FrameViewLayoutContext.h */,
574D42791D594FF6002CF50E /* GlobalCrypto.idl */,
46B95191207D632D00A7D2DD /* GlobalFrameIdentifier.h */,
7C9892451F5A07650091DC70 /* GlobalPerformance.idl */,
@@ -19219,8 +19221,6 @@
0F4710D91DB6FE22002DCEC3 /* IntersectionObserverEntry.h */,
0F4710DA1DB6FE22002DCEC3 /* IntersectionObserverEntry.idl */,
E4916FF6195DF6A0005AB349 /* LayerFlushThrottleState.h */,
- 113D0B4F1F9FDD2B00F611BB /* LayoutContext.cpp */,
- 113D0B501F9FDD2B00F611BB /* LayoutContext.h */,
931D72F515FE695300C4C07E /* LayoutMilestones.h */,
BCE1C41A0D982980003B02F2 /* Location.cpp */,
BCE1C4190D982980003B02F2 /* Location.h */,
@@ -29107,8 +29107,8 @@
1199FA4B208E37B6002358CC /* LayoutBlockContainer.h in Headers */,
115CFA97208B952B001E6991 /* LayoutBox.h in Headers */,
1199FA46208E35A3002358CC /* LayoutContainer.h in Headers */,
- 113D0B521F9FDD2B00F611BB /* LayoutContext.h in Headers */,
- 6F7CA3C6208C2957002F29AB /* LayoutCtx.h in Headers */,
+ 113D0B521F9FDD2B00F611BB /* FrameViewLayoutContext.h in Headers */,
+ 6F7CA3C6208C2957002F29AB /* LayoutContext.h in Headers */,
1199FA53208E38D3002358CC /* LayoutInlineBox.h in Headers */,
1199FA4F208E3899002358CC /* LayoutInlineContainer.h in Headers */,
931D72F615FE695300C4C07E /* LayoutMilestones.h in Headers */,
@@ -31309,7 +31309,7 @@
6F7CA3CB208C2B2E002F29AB /* InlineFormattingContext.cpp in Sources */,
538EC93E1F99BF5A004D22A8 /* JSQuickTimePluginReplacement.cpp in Sources */,
935C477009AC4D7300A6AAB4 /* KeyEventMac.mm in Sources */,
- 6F7CA3C7208C2957002F29AB /* LayoutCtx.cpp in Sources */,
+ 6F7CA3C7208C2957002F29AB /* LayoutContext.cpp in Sources */,
CDA98E0B1603CD6000FEA3B1 /* LegacyCDM.cpp in Sources */,
CDE8B5EC1A69777300B4B66A /* LegacyCDMPrivateClearKey.cpp in Sources */,
CDCA98EB18B2C8EB00C12FF9 /* LegacyCDMPrivateMediaPlayer.cpp in Sources */,
Copied: trunk/Source/WebCore/layout/LayoutContext.cpp (from rev 230965, trunk/Source/WebCore/layout/LayoutCtx.cpp) (0 => 230966)
--- trunk/Source/WebCore/layout/LayoutContext.cpp (rev 0)
+++ trunk/Source/WebCore/layout/LayoutContext.cpp 2018-04-24 19:48:53 UTC (rev 230966)
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "LayoutContext.h"
Copied: trunk/Source/WebCore/layout/LayoutContext.h (from rev 230965, trunk/Source/WebCore/layout/LayoutCtx.h) (0 => 230966)
--- trunk/Source/WebCore/layout/LayoutContext.h (rev 0)
+++ trunk/Source/WebCore/layout/LayoutContext.h 2018-04-24 19:48:53 UTC (rev 230966)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include <wtf/IsoMalloc.h>
+
+namespace WebCore {
+
+namespace Display {
+class Box;
+}
+
+namespace Layout {
+
+class Box;
+class Container;
+class FormattingContext;
+class FormattingState;
+class StyleDiff;
+
+// LayoutContext is the entry point for layout. It takes a (formatting root)container which acts as the root of the layout context.
+// LayoutContext::layout() generates the display tree for the root container's subtree (it does not run layout on the root though).
+// Note, while the root container is suppposed to be the entry point for the initial layout, it does not necessarily need to be the entry point of any
+// subsequent layouts (subtree layout).
+// LayoutContext also holds the formatting states. They cache formatting context specific data to enable performant incremental layouts.
+class LayoutContext {
+ WTF_MAKE_ISO_ALLOCATED(LayoutContext);
+public:
+ LayoutContext(const Container& rootContainer);
+
+ void layout();
+
+ Container& rootContainer() const;
+ FormattingContext& formattingContext(const Container& formattingRoot) const;
+ FormattingState& establishedFormattingState(const Container& formattingRoot);
+ FormattingState& formattingState(const Box&);
+
+ void addDisplayBox(const Box&, Display::Box&);
+ Display::Box* displayBox(const Box&) const;
+
+ void markNeedsLayout(const Box&, StyleDiff);
+ bool needsLayout(const Box&) const;
+};
+
+}
+}
+#endif
Deleted: trunk/Source/WebCore/layout/LayoutCtx.cpp (230965 => 230966)
--- trunk/Source/WebCore/layout/LayoutCtx.cpp 2018-04-24 19:19:47 UTC (rev 230965)
+++ trunk/Source/WebCore/layout/LayoutCtx.cpp 2018-04-24 19:48:53 UTC (rev 230966)
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "LayoutCtx.h"
Deleted: trunk/Source/WebCore/layout/LayoutCtx.h (230965 => 230966)
--- trunk/Source/WebCore/layout/LayoutCtx.h 2018-04-24 19:19:47 UTC (rev 230965)
+++ trunk/Source/WebCore/layout/LayoutCtx.h 2018-04-24 19:48:53 UTC (rev 230966)
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-
-#include <wtf/IsoMalloc.h>
-
-namespace WebCore {
-
-namespace Display {
-class Box;
-}
-
-namespace Layout {
-
-class Box;
-class Container;
-class FormattingContext;
-class FormattingState;
-class StyleDiff;
-
-// LayoutContext is the entry point for layout. It takes a (formatting root)container which acts as the root of the layout context.
-// LayoutContext::layout() generates the display tree for the root container's subtree (it does not run layout on the root though).
-// Note, while the root container is suppposed to be the entry point for the initial layout, it does not necessarily need to be the entry point of any
-// subsequent layouts (subtree layout).
-// LayoutContext also holds the formatting states. They cache formatting context specific data to enable performant incremental layouts.
-class LayoutContext {
- WTF_MAKE_ISO_ALLOCATED(LayoutContext);
-public:
- LayoutContext(const Container& rootContainer);
-
- void layout();
-
- Container& rootContainer() const;
- FormattingContext& formattingContext(const Container& formattingRoot) const;
- FormattingState& establishedFormattingState(const Container& formattingRoot);
- FormattingState& formattingState(const Box&);
-
- void addDisplayBox(const Box&, Display::Box&);
- Display::Box* displayBox(const Box&) const;
-
- void markNeedsLayout(const Box&, StyleDiff);
- bool needsLayout(const Box&) const;
-};
-
-}
-}
-#endif
Modified: trunk/Source/WebCore/page/FrameView.cpp (230965 => 230966)
--- trunk/Source/WebCore/page/FrameView.cpp 2018-04-24 19:19:47 UTC (rev 230965)
+++ trunk/Source/WebCore/page/FrameView.cpp 2018-04-24 19:48:53 UTC (rev 230966)
@@ -1309,7 +1309,7 @@
bool FrameView::shouldDeferScrollUpdateAfterContentSizeChange()
{
- return (layoutContext().layoutPhase() < LayoutContext::LayoutPhase::InPostLayout) && (layoutContext().layoutPhase() != LayoutContext::LayoutPhase::OutsideLayout);
+ return (layoutContext().layoutPhase() < FrameViewLayoutContext::LayoutPhase::InPostLayout) && (layoutContext().layoutPhase() != FrameViewLayoutContext::LayoutPhase::OutsideLayout);
}
RenderBox* FrameView::embeddedContentBox() const
@@ -1677,7 +1677,7 @@
// Don't update the layout viewport if we're in the middle of adjusting scrollbars. We'll get another call
// as a post-layout task.
- if (layoutContext().layoutPhase() == LayoutContext::LayoutPhase::InViewSizeAdjust)
+ if (layoutContext().layoutPhase() == FrameViewLayoutContext::LayoutPhase::InViewSizeAdjust)
return;
LayoutRect layoutViewport = layoutViewportRect();
@@ -2470,7 +2470,7 @@
void FrameView::updateLayerPositionsAfterScrolling()
{
// If we're scrolling as a result of updating the view size after layout, we'll update widgets and layer positions soon anyway.
- if (layoutContext().layoutPhase() == LayoutContext::LayoutPhase::InViewSizeAdjust)
+ if (layoutContext().layoutPhase() == FrameViewLayoutContext::LayoutPhase::InViewSizeAdjust)
return;
if (!layoutContext().isLayoutNested() && hasViewportConstrainedObjects()) {
@@ -2510,7 +2510,7 @@
void FrameView::updateCompositingLayersAfterScrolling()
{
- ASSERT(layoutContext().layoutPhase() >= LayoutContext::LayoutPhase::InPostLayout || layoutContext().layoutPhase() == LayoutContext::LayoutPhase::OutsideLayout);
+ ASSERT(layoutContext().layoutPhase() >= FrameViewLayoutContext::LayoutPhase::InPostLayout || layoutContext().layoutPhase() == FrameViewLayoutContext::LayoutPhase::OutsideLayout);
if (!shouldUpdateCompositingLayersAfterScrolling())
return;
@@ -2618,7 +2618,7 @@
// FIXME: Merge this logic with m_setNeedsLayoutWasDeferred and find a more appropriate
// way of handling potential recursive layouts when the viewport is resized to accomodate
// the content but the content always overflows the viewport. See webkit.org/b/165781.
- if (!(layoutContext().layoutPhase() == LayoutContext::LayoutPhase::InViewSizeAdjust && useFixedLayout()))
+ if (!(layoutContext().layoutPhase() == FrameViewLayoutContext::LayoutPhase::InViewSizeAdjust && useFixedLayout()))
document->updateViewportUnitsOnResize();
}
Modified: trunk/Source/WebCore/page/FrameView.h (230965 => 230966)
--- trunk/Source/WebCore/page/FrameView.h 2018-04-24 19:19:47 UTC (rev 230965)
+++ trunk/Source/WebCore/page/FrameView.h 2018-04-24 19:48:53 UTC (rev 230966)
@@ -27,7 +27,7 @@
#include "AdjustViewSizeOrNot.h"
#include "Color.h"
#include "ContainerNode.h"
-#include "LayoutContext.h"
+#include "FrameViewLayoutContext.h"
#include "LayoutMilestones.h"
#include "LayoutRect.h"
#include "Pagination.h"
@@ -73,7 +73,7 @@
public:
friend class RenderView;
friend class Internals;
- friend class LayoutContext;
+ friend class FrameViewLayoutContext;
WEBCORE_EXPORT static Ref<FrameView> create(Frame&);
static Ref<FrameView> create(Frame&, const IntSize& initialSize);
@@ -109,8 +109,8 @@
void setContentsSize(const IntSize&) final;
void updateContentsSize() final;
- const LayoutContext& layoutContext() const { return m_layoutContext; }
- LayoutContext& layoutContext() { return m_layoutContext; }
+ const FrameViewLayoutContext& layoutContext() const { return m_layoutContext; }
+ FrameViewLayoutContext& layoutContext() { return m_layoutContext; }
WEBCORE_EXPORT bool didFirstLayout() const;
void queuePostLayoutCallback(WTF::Function<void ()>&&);
@@ -912,7 +912,7 @@
IntRect* m_cachedWindowClipRect { nullptr };
Vector<WTF::Function<void ()>> m_postLayoutCallbackQueue;
- LayoutContext m_layoutContext;
+ FrameViewLayoutContext m_layoutContext;
};
inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count)
Copied: trunk/Source/WebCore/page/FrameViewLayoutContext.cpp (from rev 230965, trunk/Source/WebCore/page/LayoutContext.cpp) (0 => 230966)
--- trunk/Source/WebCore/page/FrameViewLayoutContext.cpp (rev 0)
+++ trunk/Source/WebCore/page/FrameViewLayoutContext.cpp 2018-04-24 19:48:53 UTC (rev 230966)
@@ -0,0 +1,631 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "FrameViewLayoutContext.h"
+
+#include "CSSAnimationController.h"
+#include "DebugPageOverlays.h"
+#include "Document.h"
+#include "FrameView.h"
+#include "InspectorInstrumentation.h"
+#include "LayoutDisallowedScope.h"
+#include "LayoutState.h"
+#include "Logging.h"
+#include "RenderElement.h"
+#include "RenderView.h"
+#include "ScriptDisallowedScope.h"
+#include "Settings.h"
+
+#include <wtf/SetForScope.h>
+#include <wtf/SystemTracing.h>
+#include <wtf/text/TextStream.h>
+
+namespace WebCore {
+
+static bool isObjectAncestorContainerOf(RenderElement& ancestor, RenderElement& descendant)
+{
+ for (auto* renderer = &descendant; renderer; renderer = renderer->container()) {
+ if (renderer == &ancestor)
+ return true;
+ }
+ return false;
+}
+
+#ifndef NDEBUG
+class RenderTreeNeedsLayoutChecker {
+public :
+ RenderTreeNeedsLayoutChecker(const RenderElement& layoutRoot)
+ : m_layoutRoot(layoutRoot)
+ {
+ }
+
+ ~RenderTreeNeedsLayoutChecker()
+ {
+ auto reportNeedsLayoutError = [] (const RenderObject& renderer) {
+ WTFReportError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, "post-layout: dirty renderer(s)");
+ renderer.showRenderTreeForThis();
+ ASSERT_NOT_REACHED();
+ };
+
+ if (m_layoutRoot.needsLayout()) {
+ reportNeedsLayoutError(m_layoutRoot);
+ return;
+ }
+
+ for (auto* descendant = m_layoutRoot.firstChild(); descendant; descendant = descendant->nextInPreOrder(&m_layoutRoot)) {
+ if (!descendant->needsLayout())
+ continue;
+
+ reportNeedsLayoutError(*descendant);
+ return;
+ }
+ }
+
+private:
+ const RenderElement& m_layoutRoot;
+};
+#endif
+
+class LayoutScope {
+public:
+ LayoutScope(FrameViewLayoutContext& layoutContext)
+ : m_view(layoutContext.view())
+ , m_nestedState(layoutContext.m_layoutNestedState, layoutContext.m_layoutNestedState == FrameViewLayoutContext::LayoutNestedState::NotInLayout ? FrameViewLayoutContext::LayoutNestedState::NotNested : FrameViewLayoutContext::LayoutNestedState::Nested)
+ , m_schedulingIsEnabled(layoutContext.m_layoutSchedulingIsEnabled, false)
+ , m_inProgrammaticScroll(layoutContext.view().inProgrammaticScroll())
+ {
+ m_view.setInProgrammaticScroll(true);
+ }
+
+ ~LayoutScope()
+ {
+ m_view.setInProgrammaticScroll(m_inProgrammaticScroll);
+ }
+
+private:
+ FrameView& m_view;
+ SetForScope<FrameViewLayoutContext::LayoutNestedState> m_nestedState;
+ SetForScope<bool> m_schedulingIsEnabled;
+ bool m_inProgrammaticScroll { false };
+};
+
+FrameViewLayoutContext::FrameViewLayoutContext(FrameView& frameView)
+ : m_frameView(frameView)
+ , m_layoutTimer(*this, &FrameViewLayoutContext::layoutTimerFired)
+ , m_asynchronousTasksTimer(*this, &FrameViewLayoutContext::runAsynchronousTasks)
+{
+}
+
+FrameViewLayoutContext::~FrameViewLayoutContext()
+{
+}
+
+void FrameViewLayoutContext::layout()
+{
+ LOG_WITH_STREAM(Layout, stream << "FrameView " << &view() << " FrameViewLayoutContext::layout() with size " << view().layoutSize());
+
+ RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!frame().document()->inRenderTreeUpdate() || ScriptDisallowedScope::LayoutAssertionDisableScope::shouldDisable());
+ ASSERT(LayoutDisallowedScope::isLayoutAllowed());
+ ASSERT(!view().isPainting());
+ ASSERT(frame().view() == &view());
+ ASSERT(frame().document());
+ ASSERT(frame().document()->pageCacheState() == Document::NotInPageCache);
+ if (!canPerformLayout()) {
+ LOG(Layout, " is not allowed, bailing");
+ return;
+ }
+
+ Ref<FrameView> protectView(view());
+ LayoutScope layoutScope(*this);
+ TraceScope tracingScope(LayoutStart, LayoutEnd);
+ InspectorInstrumentationCookie inspectorLayoutScope(InspectorInstrumentation::willLayout(view().frame()));
+ AnimationUpdateBlock animationUpdateBlock(&view().frame().animation());
+ WeakPtr<RenderElement> layoutRoot;
+
+ m_layoutTimer.stop();
+ m_delayedLayout = false;
+ m_setNeedsLayoutWasDeferred = false;
+
+#if !LOG_DISABLED
+ if (m_firstLayout && !frame().ownerElement())
+ LOG(Layout, "FrameView %p elapsed time before first layout: %.3fs", this, document()->timeSinceDocumentCreation().value());
+#endif
+#if PLATFORM(IOS)
+ if (view().updateFixedPositionLayoutRect() && subtreeLayoutRoot())
+ convertSubtreeLayoutToFullLayout();
+#endif
+ if (handleLayoutWithFrameFlatteningIfNeeded())
+ return;
+
+ {
+ SetForScope<LayoutPhase> layoutPhase(m_layoutPhase, LayoutPhase::InPreLayout);
+
+ // If this is a new top-level layout and there are any remaining tasks from the previous layout, finish them now.
+ if (!isLayoutNested() && m_asynchronousTasksTimer.isActive() && !view().isInChildFrameWithFrameFlattening())
+ runAsynchronousTasks();
+
+ updateStyleForLayout();
+ if (view().hasOneRef())
+ return;
+
+ view().autoSizeIfEnabled();
+ if (!renderView())
+ return;
+
+ layoutRoot = makeWeakPtr(subtreeLayoutRoot() ? subtreeLayoutRoot() : renderView());
+ m_needsFullRepaint = is<RenderView>(layoutRoot.get()) && (m_firstLayout || renderView()->printing());
+ view().willDoLayout(layoutRoot);
+ m_firstLayout = false;
+ }
+ {
+ SetForScope<LayoutPhase> layoutPhase(m_layoutPhase, LayoutPhase::InRenderTreeLayout);
+ ScriptDisallowedScope::InMainThread scriptDisallowedScope;
+ SubtreeLayoutStateMaintainer subtreeLayoutStateMaintainer(subtreeLayoutRoot());
+ RenderView::RepaintRegionAccumulator repaintRegionAccumulator(renderView());
+#ifndef NDEBUG
+ RenderTreeNeedsLayoutChecker checker(*layoutRoot);
+#endif
+ layoutRoot->layout();
+ ++m_layoutCount;
+#if ENABLE(TEXT_AUTOSIZING)
+ applyTextSizingIfNeeded(*layoutRoot.get());
+#endif
+ clearSubtreeLayoutRoot();
+ }
+ {
+ SetForScope<LayoutPhase> layoutPhase(m_layoutPhase, LayoutPhase::InViewSizeAdjust);
+ if (is<RenderView>(layoutRoot.get()) && !renderView()->printing()) {
+ // This is to protect m_needsFullRepaint's value when layout() is getting re-entered through adjustViewSize().
+ SetForScope<bool> needsFullRepaint(m_needsFullRepaint);
+ view().adjustViewSize();
+ // FIXME: Firing media query callbacks synchronously on nested frames could produced a detached FrameView here by
+ // navigating away from the current document (see webkit.org/b/173329).
+ if (view().hasOneRef())
+ return;
+ }
+ }
+ {
+ SetForScope<LayoutPhase> layoutPhase(m_layoutPhase, LayoutPhase::InPostLayout);
+ if (m_needsFullRepaint)
+ renderView()->repaintRootContents();
+ ASSERT(!layoutRoot->needsLayout());
+ view().didLayout(layoutRoot);
+ runOrScheduleAsynchronousTasks();
+ }
+ InspectorInstrumentation::didLayout(inspectorLayoutScope, *layoutRoot);
+ DebugPageOverlays::didLayout(view().frame());
+}
+
+void FrameViewLayoutContext::runOrScheduleAsynchronousTasks()
+{
+ if (m_asynchronousTasksTimer.isActive())
+ return;
+
+ if (view().isInChildFrameWithFrameFlattening()) {
+ // While flattening frames, we defer post layout tasks to avoid getting stuck in a cycle,
+ // except updateWidgetPositions() which is required to kick off subframe layout in certain cases.
+ if (!m_inAsynchronousTasks)
+ view().updateWidgetPositions();
+ m_asynchronousTasksTimer.startOneShot(0_s);
+ return;
+ }
+
+ // If we are already in performPostLayoutTasks(), defer post layout tasks until after we return
+ // to avoid re-entrancy.
+ if (m_inAsynchronousTasks) {
+ m_asynchronousTasksTimer.startOneShot(0_s);
+ return;
+ }
+
+ runAsynchronousTasks();
+ if (needsLayout()) {
+ // If runAsynchronousTasks() made us layout again, let's defer the tasks until after we return.
+ m_asynchronousTasksTimer.startOneShot(0_s);
+ layout();
+ }
+}
+
+void FrameViewLayoutContext::runAsynchronousTasks()
+{
+ m_asynchronousTasksTimer.stop();
+ if (m_inAsynchronousTasks)
+ return;
+ SetForScope<bool> inAsynchronousTasks(m_inAsynchronousTasks, true);
+ view().performPostLayoutTasks();
+}
+
+void FrameViewLayoutContext::flushAsynchronousTasks()
+{
+ if (!m_asynchronousTasksTimer.isActive())
+ return;
+ runAsynchronousTasks();
+}
+
+void FrameViewLayoutContext::reset()
+{
+ m_layoutPhase = LayoutPhase::OutsideLayout;
+ clearSubtreeLayoutRoot();
+ m_layoutCount = 0;
+ m_layoutSchedulingIsEnabled = true;
+ m_delayedLayout = false;
+ m_layoutTimer.stop();
+ m_firstLayout = true;
+ m_asynchronousTasksTimer.stop();
+ m_needsFullRepaint = true;
+}
+
+bool FrameViewLayoutContext::needsLayout() const
+{
+ // This can return true in cases where the document does not have a body yet.
+ // Document::shouldScheduleLayout takes care of preventing us from scheduling
+ // layout in that case.
+ auto* renderView = this->renderView();
+ return isLayoutPending()
+ || (renderView && renderView->needsLayout())
+ || subtreeLayoutRoot()
+ || (m_disableSetNeedsLayoutCount && m_setNeedsLayoutWasDeferred);
+}
+
+void FrameViewLayoutContext::setNeedsLayout()
+{
+ if (m_disableSetNeedsLayoutCount) {
+ m_setNeedsLayoutWasDeferred = true;
+ return;
+ }
+
+ if (auto* renderView = this->renderView()) {
+ ASSERT(!renderView->inHitTesting());
+ renderView->setNeedsLayout();
+ }
+}
+
+void FrameViewLayoutContext::enableSetNeedsLayout()
+{
+ ASSERT(m_disableSetNeedsLayoutCount);
+ if (!--m_disableSetNeedsLayoutCount)
+ m_setNeedsLayoutWasDeferred = false; // FIXME: Find a way to make the deferred layout actually happen.
+}
+
+void FrameViewLayoutContext::disableSetNeedsLayout()
+{
+ ++m_disableSetNeedsLayoutCount;
+}
+
+void FrameViewLayoutContext::scheduleLayout()
+{
+ // FIXME: We should assert the page is not in the page cache, but that is causing
+ // too many false assertions. See <rdar://problem/7218118>.
+ ASSERT(frame().view() == &view());
+
+ if (subtreeLayoutRoot())
+ convertSubtreeLayoutToFullLayout();
+ if (!isLayoutSchedulingEnabled())
+ return;
+ if (!needsLayout())
+ return;
+ if (!frame().document()->shouldScheduleLayout())
+ return;
+ InspectorInstrumentation::didInvalidateLayout(frame());
+ // When frame flattening is enabled, the contents of the frame could affect the layout of the parent frames.
+ // Also invalidate parent frame starting from the owner element of this frame.
+ if (frame().ownerRenderer() && view().isInChildFrameWithFrameFlattening())
+ frame().ownerRenderer()->setNeedsLayout(MarkContainingBlockChain);
+
+ Seconds delay = frame().document()->minimumLayoutDelay();
+ if (m_layoutTimer.isActive() && m_delayedLayout && !delay)
+ unscheduleLayout();
+
+ if (m_layoutTimer.isActive())
+ return;
+
+ m_delayedLayout = delay.value();
+
+#if !LOG_DISABLED
+ if (!frame().document()->ownerElement())
+ LOG(Layout, "FrameView %p scheduling layout for %.3fs", this, delay.value());
+#endif
+
+ m_layoutTimer.startOneShot(delay);
+}
+
+void FrameViewLayoutContext::unscheduleLayout()
+{
+ if (m_asynchronousTasksTimer.isActive())
+ m_asynchronousTasksTimer.stop();
+
+ if (!m_layoutTimer.isActive())
+ return;
+
+#if !LOG_DISABLED
+ if (!frame().document()->ownerElement())
+ LOG(Layout, "FrameView %p layout timer unscheduled at %.3fs", this, frame().document()->timeSinceDocumentCreation().value());
+#endif
+
+ m_layoutTimer.stop();
+ m_delayedLayout = false;
+}
+
+void FrameViewLayoutContext::scheduleSubtreeLayout(RenderElement& layoutRoot)
+{
+ ASSERT(renderView());
+ auto& renderView = *this->renderView();
+
+ // Try to catch unnecessary work during render tree teardown.
+ ASSERT(!renderView.renderTreeBeingDestroyed());
+ ASSERT(frame().view() == &view());
+
+ if (renderView.needsLayout() && !subtreeLayoutRoot()) {
+ layoutRoot.markContainingBlocksForLayout(ScheduleRelayout::No);
+ return;
+ }
+
+ if (!isLayoutPending() && isLayoutSchedulingEnabled()) {
+ Seconds delay = renderView.document().minimumLayoutDelay();
+ ASSERT(!layoutRoot.container() || is<RenderView>(layoutRoot.container()) || !layoutRoot.container()->needsLayout());
+ setSubtreeLayoutRoot(layoutRoot);
+ InspectorInstrumentation::didInvalidateLayout(frame());
+ m_delayedLayout = delay.value();
+ m_layoutTimer.startOneShot(delay);
+ return;
+ }
+
+ auto* subtreeLayoutRoot = this->subtreeLayoutRoot();
+ if (subtreeLayoutRoot == &layoutRoot)
+ return;
+
+ if (!subtreeLayoutRoot) {
+ // We already have a pending (full) layout. Just mark the subtree for layout.
+ layoutRoot.markContainingBlocksForLayout(ScheduleRelayout::No);
+ InspectorInstrumentation::didInvalidateLayout(frame());
+ return;
+ }
+
+ if (isObjectAncestorContainerOf(*subtreeLayoutRoot, layoutRoot)) {
+ // Keep the current root.
+ layoutRoot.markContainingBlocksForLayout(ScheduleRelayout::No, subtreeLayoutRoot);
+ ASSERT(!subtreeLayoutRoot->container() || is<RenderView>(subtreeLayoutRoot->container()) || !subtreeLayoutRoot->container()->needsLayout());
+ return;
+ }
+
+ if (isObjectAncestorContainerOf(layoutRoot, *subtreeLayoutRoot)) {
+ // Re-root at newRelayoutRoot.
+ subtreeLayoutRoot->markContainingBlocksForLayout(ScheduleRelayout::No, &layoutRoot);
+ setSubtreeLayoutRoot(layoutRoot);
+ ASSERT(!layoutRoot.container() || is<RenderView>(layoutRoot.container()) || !layoutRoot.container()->needsLayout());
+ InspectorInstrumentation::didInvalidateLayout(frame());
+ return;
+ }
+ // Two disjoint subtrees need layout. Mark both of them and issue a full layout instead.
+ convertSubtreeLayoutToFullLayout();
+ layoutRoot.markContainingBlocksForLayout(ScheduleRelayout::No);
+ InspectorInstrumentation::didInvalidateLayout(frame());
+}
+
+void FrameViewLayoutContext::layoutTimerFired()
+{
+#if !LOG_DISABLED
+ if (!frame().document()->ownerElement())
+ LOG(Layout, "FrameView %p layout timer fired at %.3fs", this, frame().document()->timeSinceDocumentCreation().value());
+#endif
+ layout();
+}
+
+void FrameViewLayoutContext::convertSubtreeLayoutToFullLayout()
+{
+ ASSERT(subtreeLayoutRoot());
+ subtreeLayoutRoot()->markContainingBlocksForLayout(ScheduleRelayout::No);
+ clearSubtreeLayoutRoot();
+}
+
+void FrameViewLayoutContext::setSubtreeLayoutRoot(RenderElement& layoutRoot)
+{
+ m_subtreeLayoutRoot = makeWeakPtr(layoutRoot);
+}
+
+bool FrameViewLayoutContext::canPerformLayout() const
+{
+ if (isInRenderTreeLayout())
+ return false;
+
+ if (layoutDisallowed())
+ return false;
+
+ if (view().isPainting())
+ return false;
+
+ if (!subtreeLayoutRoot() && !frame().document()->renderView())
+ return false;
+
+ return true;
+}
+
+#if ENABLE(TEXT_AUTOSIZING)
+void FrameViewLayoutContext::applyTextSizingIfNeeded(RenderElement& layoutRoot)
+{
+ auto& settings = layoutRoot.settings();
+ if (!settings.textAutosizingEnabled() || renderView()->printing())
+ return;
+ auto minimumZoomFontSize = settings.minimumZoomFontSize();
+ if (!minimumZoomFontSize)
+ return;
+ auto textAutosizingWidth = layoutRoot.page().textAutosizingWidth();
+ if (auto overrideWidth = settings.textAutosizingWindowSizeOverride().width())
+ textAutosizingWidth = overrideWidth;
+ if (!textAutosizingWidth)
+ return;
+ layoutRoot.adjustComputedFontSizesOnBlocks(minimumZoomFontSize, textAutosizingWidth);
+ if (!layoutRoot.needsLayout())
+ return;
+ LOG(TextAutosizing, "Text Autosizing: minimumZoomFontSize=%.2f textAutosizingWidth=%.2f", minimumZoomFontSize, textAutosizingWidth);
+ layoutRoot.layout();
+}
+#endif
+
+void FrameViewLayoutContext::updateStyleForLayout()
+{
+ Document& document = *frame().document();
+
+ // FIXME: This shouldn't be necessary, but see rdar://problem/36670246.
+ if (!document.styleScope().resolverIfExists())
+ document.styleScope().didChangeStyleSheetEnvironment();
+
+ // Viewport-dependent media queries may cause us to need completely different style information.
+ document.styleScope().evaluateMediaQueriesForViewportChange();
+
+ document.evaluateMediaQueryList();
+ // If there is any pagination to apply, it will affect the RenderView's style, so we should
+ // take care of that now.
+ view().applyPaginationToViewport();
+ // Always ensure our style info is up-to-date. This can happen in situations where
+ // the layout beats any sort of style recalc update that needs to occur.
+ document.updateStyleIfNeeded();
+}
+
+bool FrameViewLayoutContext::handleLayoutWithFrameFlatteningIfNeeded()
+{
+ if (!view().isInChildFrameWithFrameFlattening())
+ return false;
+
+ startLayoutAtMainFrameViewIfNeeded();
+ auto* layoutRoot = subtreeLayoutRoot() ? subtreeLayoutRoot() : frame().document()->renderView();
+ return !layoutRoot || !layoutRoot->needsLayout();
+}
+
+void FrameViewLayoutContext::startLayoutAtMainFrameViewIfNeeded()
+{
+ // When we start a layout at the child level as opposed to the topmost frame view and this child
+ // frame requires flattening, we need to re-initiate the layout at the topmost view. Layout
+ // will hit this view eventually.
+ auto* parentView = view().parentFrameView();
+ if (!parentView)
+ return;
+
+ // In the middle of parent layout, no need to restart from topmost.
+ if (parentView->layoutContext().isInLayout())
+ return;
+
+ // Parent tree is clean. Starting layout from it would have no effect.
+ if (!parentView->needsLayout())
+ return;
+
+ while (parentView->parentFrameView())
+ parentView = parentView->parentFrameView();
+
+ LOG(Layout, " frame flattening, starting from root");
+ parentView->layoutContext().layout();
+}
+
+LayoutSize FrameViewLayoutContext::layoutDelta() const
+{
+ if (auto* layoutState = this->layoutState())
+ return layoutState->layoutDelta();
+ return { };
+}
+
+void FrameViewLayoutContext::addLayoutDelta(const LayoutSize& delta)
+{
+ if (auto* layoutState = this->layoutState())
+ layoutState->addLayoutDelta(delta);
+}
+
+#if !ASSERT_DISABLED
+bool FrameViewLayoutContext::layoutDeltaMatches(const LayoutSize& delta)
+{
+ if (auto* layoutState = this->layoutState())
+ return layoutState->layoutDeltaMatches(delta);
+ return false;
+}
+#endif
+
+LayoutState* FrameViewLayoutContext::layoutState() const
+{
+ if (m_layoutStateStack.isEmpty())
+ return nullptr;
+ return m_layoutStateStack.last().get();
+}
+
+void FrameViewLayoutContext::pushLayoutState(RenderElement& root)
+{
+ ASSERT(!m_paintOffsetCacheDisableCount);
+ ASSERT(!layoutState());
+
+ m_layoutStateStack.append(std::make_unique<LayoutState>(root));
+}
+
+bool FrameViewLayoutContext::pushLayoutStateForPaginationIfNeeded(RenderBlockFlow& layoutRoot)
+{
+ if (layoutState())
+ return false;
+ m_layoutStateStack.append(std::make_unique<LayoutState>(layoutRoot, LayoutState::IsPaginated::Yes));
+ return true;
+}
+
+bool FrameViewLayoutContext::pushLayoutState(RenderBox& renderer, const LayoutSize& offset, LayoutUnit pageHeight, bool pageHeightChanged)
+{
+ // We push LayoutState even if layoutState is disabled because it stores layoutDelta too.
+ auto* layoutState = this->layoutState();
+ if (!layoutState || !needsFullRepaint() || layoutState->isPaginated() || renderer.enclosingFragmentedFlow()
+ || layoutState->lineGrid() || (renderer.style().lineGrid() != RenderStyle::initialLineGrid() && renderer.isRenderBlockFlow())) {
+ m_layoutStateStack.append(std::make_unique<LayoutState>(m_layoutStateStack, renderer, offset, pageHeight, pageHeightChanged));
+ return true;
+ }
+ return false;
+}
+
+void FrameViewLayoutContext::popLayoutState()
+{
+ m_layoutStateStack.removeLast();
+}
+
+#ifndef NDEBUG
+void FrameViewLayoutContext::checkLayoutState()
+{
+ ASSERT(layoutDeltaMatches(LayoutSize()));
+ ASSERT(!m_paintOffsetCacheDisableCount);
+}
+#endif
+
+Frame& FrameViewLayoutContext::frame() const
+{
+ return view().frame();
+}
+
+FrameView& FrameViewLayoutContext::view() const
+{
+ return m_frameView;
+}
+
+RenderView* FrameViewLayoutContext::renderView() const
+{
+ return view().renderView();
+}
+
+Document* FrameViewLayoutContext::document() const
+{
+ return frame().document();
+}
+
+} // namespace WebCore
Copied: trunk/Source/WebCore/page/FrameViewLayoutContext.h (from rev 230965, trunk/Source/WebCore/page/LayoutContext.h) (0 => 230966)
--- trunk/Source/WebCore/page/FrameViewLayoutContext.h (rev 0)
+++ trunk/Source/WebCore/page/FrameViewLayoutContext.h 2018-04-24 19:48:53 UTC (rev 230966)
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "LayoutUnit.h"
+#include "Timer.h"
+
+#include <wtf/WeakPtr.h>
+
+namespace WebCore {
+
+class Document;
+class Frame;
+class FrameView;
+class LayoutScope;
+class LayoutSize;
+class LayoutState;
+class RenderBlockFlow;
+class RenderBox;
+class RenderObject;
+class RenderElement;
+class RenderView;
+
+class FrameViewLayoutContext {
+public:
+ FrameViewLayoutContext(FrameView&);
+ ~FrameViewLayoutContext();
+
+ void layout();
+
+ void setNeedsLayout();
+ bool needsLayout() const;
+
+ void scheduleLayout();
+ void scheduleSubtreeLayout(RenderElement& layoutRoot);
+ void unscheduleLayout();
+
+ void startDisallowingLayout() { ++m_layoutDisallowedCount; }
+ void endDisallowingLayout() { ASSERT(m_layoutDisallowedCount > 0); --m_layoutDisallowedCount; }
+
+ void disableSetNeedsLayout();
+ void enableSetNeedsLayout();
+
+ enum class LayoutPhase {
+ OutsideLayout,
+ InPreLayout,
+ InRenderTreeLayout,
+ InViewSizeAdjust,
+ InPostLayout
+ };
+ LayoutPhase layoutPhase() const { return m_layoutPhase; }
+ bool isLayoutNested() const { return m_layoutNestedState == LayoutNestedState::Nested; }
+ bool isLayoutPending() const { return m_layoutTimer.isActive(); }
+ bool isInLayout() const { return layoutPhase() != LayoutPhase::OutsideLayout; }
+ bool isInRenderTreeLayout() const { return layoutPhase() == LayoutPhase::InRenderTreeLayout; }
+ bool inPaintableState() const { return layoutPhase() != LayoutPhase::InRenderTreeLayout && layoutPhase() != LayoutPhase::InViewSizeAdjust && (layoutPhase() != LayoutPhase::InPostLayout || inAsynchronousTasks()); }
+
+ unsigned layoutCount() const { return m_layoutCount; }
+
+ RenderElement* subtreeLayoutRoot() const { return m_subtreeLayoutRoot.get(); }
+ void clearSubtreeLayoutRoot() { m_subtreeLayoutRoot.clear(); }
+ void convertSubtreeLayoutToFullLayout();
+
+ void reset();
+ void resetFirstLayoutFlag() { m_firstLayout = true; }
+ bool didFirstLayout() const { return !m_firstLayout; }
+
+ void setNeedsFullRepaint() { m_needsFullRepaint = true; }
+ bool needsFullRepaint() const { return m_needsFullRepaint; }
+
+ void flushAsynchronousTasks();
+
+ LayoutState* layoutState() const;
+ // Returns true if layoutState should be used for its cached offset and clip.
+ bool isPaintOffsetCacheEnabled() const { return !m_paintOffsetCacheDisableCount && layoutState(); }
+#ifndef NDEBUG
+ void checkLayoutState();
+#endif
+ // layoutDelta is used transiently during layout to store how far an object has moved from its
+ // last layout location, in order to repaint correctly.
+ // If we're doing a full repaint m_layoutState will be 0, but in that case layoutDelta doesn't matter.
+ LayoutSize layoutDelta() const;
+ void addLayoutDelta(const LayoutSize& delta);
+#if !ASSERT_DISABLED
+ bool layoutDeltaMatches(const LayoutSize& delta);
+#endif
+ using LayoutStateStack = Vector<std::unique_ptr<LayoutState>>;
+
+private:
+ friend class LayoutScope;
+ friend class LayoutStateMaintainer;
+ friend class LayoutStateDisabler;
+ friend class SubtreeLayoutStateMaintainer;
+ friend class PaginatedLayoutStateMaintainer;
+
+ bool canPerformLayout() const;
+ bool layoutDisallowed() const { return m_layoutDisallowedCount; }
+ bool isLayoutSchedulingEnabled() const { return m_layoutSchedulingIsEnabled; }
+
+ void layoutTimerFired();
+ void runAsynchronousTasks();
+ void runOrScheduleAsynchronousTasks();
+ bool inAsynchronousTasks() const { return m_inAsynchronousTasks; }
+
+ void setSubtreeLayoutRoot(RenderElement&);
+
+#if ENABLE(TEXT_AUTOSIZING)
+ void applyTextSizingIfNeeded(RenderElement& layoutRoot);
+#endif
+ void updateStyleForLayout();
+
+ bool handleLayoutWithFrameFlatteningIfNeeded();
+ void startLayoutAtMainFrameViewIfNeeded();
+
+ // These functions may only be accessed by LayoutStateMaintainer.
+ // Subtree push/pop
+ void pushLayoutState(RenderElement&);
+ bool pushLayoutStateForPaginationIfNeeded(RenderBlockFlow&);
+ bool pushLayoutState(RenderBox& renderer, const LayoutSize& offset, LayoutUnit pageHeight = 0, bool pageHeightChanged = false);
+ void popLayoutState();
+
+ // Suspends the LayoutState optimization. Used under transforms that cannot be represented by
+ // LayoutState (common in SVG) and when manipulating the render tree during layout in ways
+ // that can trigger repaint of a non-child (e.g. when a list item moves its list marker around).
+ // Note that even when disabled, LayoutState is still used to store layoutDelta.
+ // These functions may only be accessed by LayoutStateMaintainer or LayoutStateDisabler.
+ void disablePaintOffsetCache() { m_paintOffsetCacheDisableCount++; }
+ void enablePaintOffsetCache() { ASSERT(m_paintOffsetCacheDisableCount > 0); m_paintOffsetCacheDisableCount--; }
+
+ Frame& frame() const;
+ FrameView& view() const;
+ RenderView* renderView() const;
+ Document* document() const;
+
+ FrameView& m_frameView;
+ Timer m_layoutTimer;
+ Timer m_asynchronousTasksTimer;
+
+ bool m_layoutSchedulingIsEnabled { true };
+ bool m_delayedLayout { false };
+ bool m_firstLayout { true };
+ bool m_needsFullRepaint { true };
+ bool m_inAsynchronousTasks { false };
+ bool m_setNeedsLayoutWasDeferred { false };
+ LayoutPhase m_layoutPhase { LayoutPhase::OutsideLayout };
+ enum class LayoutNestedState { NotInLayout, NotNested, Nested };
+ LayoutNestedState m_layoutNestedState { LayoutNestedState::NotInLayout };
+ unsigned m_layoutCount { 0 };
+ unsigned m_disableSetNeedsLayoutCount { 0 };
+ int m_layoutDisallowedCount { 0 };
+ WeakPtr<RenderElement> m_subtreeLayoutRoot;
+ LayoutStateStack m_layoutStateStack;
+ unsigned m_paintOffsetCacheDisableCount { 0 };
+};
+
+} // namespace WebCore
Deleted: trunk/Source/WebCore/page/LayoutContext.cpp (230965 => 230966)
--- trunk/Source/WebCore/page/LayoutContext.cpp 2018-04-24 19:19:47 UTC (rev 230965)
+++ trunk/Source/WebCore/page/LayoutContext.cpp 2018-04-24 19:48:53 UTC (rev 230966)
@@ -1,631 +0,0 @@
-/*
- * Copyright (C) 2017 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "LayoutContext.h"
-
-#include "CSSAnimationController.h"
-#include "DebugPageOverlays.h"
-#include "Document.h"
-#include "FrameView.h"
-#include "InspectorInstrumentation.h"
-#include "LayoutDisallowedScope.h"
-#include "LayoutState.h"
-#include "Logging.h"
-#include "RenderElement.h"
-#include "RenderView.h"
-#include "ScriptDisallowedScope.h"
-#include "Settings.h"
-
-#include <wtf/SetForScope.h>
-#include <wtf/SystemTracing.h>
-#include <wtf/text/TextStream.h>
-
-namespace WebCore {
-
-static bool isObjectAncestorContainerOf(RenderElement& ancestor, RenderElement& descendant)
-{
- for (auto* renderer = &descendant; renderer; renderer = renderer->container()) {
- if (renderer == &ancestor)
- return true;
- }
- return false;
-}
-
-#ifndef NDEBUG
-class RenderTreeNeedsLayoutChecker {
-public :
- RenderTreeNeedsLayoutChecker(const RenderElement& layoutRoot)
- : m_layoutRoot(layoutRoot)
- {
- }
-
- ~RenderTreeNeedsLayoutChecker()
- {
- auto reportNeedsLayoutError = [] (const RenderObject& renderer) {
- WTFReportError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, "post-layout: dirty renderer(s)");
- renderer.showRenderTreeForThis();
- ASSERT_NOT_REACHED();
- };
-
- if (m_layoutRoot.needsLayout()) {
- reportNeedsLayoutError(m_layoutRoot);
- return;
- }
-
- for (auto* descendant = m_layoutRoot.firstChild(); descendant; descendant = descendant->nextInPreOrder(&m_layoutRoot)) {
- if (!descendant->needsLayout())
- continue;
-
- reportNeedsLayoutError(*descendant);
- return;
- }
- }
-
-private:
- const RenderElement& m_layoutRoot;
-};
-#endif
-
-class LayoutScope {
-public:
- LayoutScope(LayoutContext& layoutContext)
- : m_view(layoutContext.view())
- , m_nestedState(layoutContext.m_layoutNestedState, layoutContext.m_layoutNestedState == LayoutContext::LayoutNestedState::NotInLayout ? LayoutContext::LayoutNestedState::NotNested : LayoutContext::LayoutNestedState::Nested)
- , m_schedulingIsEnabled(layoutContext.m_layoutSchedulingIsEnabled, false)
- , m_inProgrammaticScroll(layoutContext.view().inProgrammaticScroll())
- {
- m_view.setInProgrammaticScroll(true);
- }
-
- ~LayoutScope()
- {
- m_view.setInProgrammaticScroll(m_inProgrammaticScroll);
- }
-
-private:
- FrameView& m_view;
- SetForScope<LayoutContext::LayoutNestedState> m_nestedState;
- SetForScope<bool> m_schedulingIsEnabled;
- bool m_inProgrammaticScroll { false };
-};
-
-LayoutContext::LayoutContext(FrameView& frameView)
- : m_frameView(frameView)
- , m_layoutTimer(*this, &LayoutContext::layoutTimerFired)
- , m_asynchronousTasksTimer(*this, &LayoutContext::runAsynchronousTasks)
-{
-}
-
-LayoutContext::~LayoutContext()
-{
-}
-
-void LayoutContext::layout()
-{
- LOG_WITH_STREAM(Layout, stream << "FrameView " << &view() << " LayoutContext::layout() with size " << view().layoutSize());
-
- RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!frame().document()->inRenderTreeUpdate() || ScriptDisallowedScope::LayoutAssertionDisableScope::shouldDisable());
- ASSERT(LayoutDisallowedScope::isLayoutAllowed());
- ASSERT(!view().isPainting());
- ASSERT(frame().view() == &view());
- ASSERT(frame().document());
- ASSERT(frame().document()->pageCacheState() == Document::NotInPageCache);
- if (!canPerformLayout()) {
- LOG(Layout, " is not allowed, bailing");
- return;
- }
-
- Ref<FrameView> protectView(view());
- LayoutScope layoutScope(*this);
- TraceScope tracingScope(LayoutStart, LayoutEnd);
- InspectorInstrumentationCookie inspectorLayoutScope(InspectorInstrumentation::willLayout(view().frame()));
- AnimationUpdateBlock animationUpdateBlock(&view().frame().animation());
- WeakPtr<RenderElement> layoutRoot;
-
- m_layoutTimer.stop();
- m_delayedLayout = false;
- m_setNeedsLayoutWasDeferred = false;
-
-#if !LOG_DISABLED
- if (m_firstLayout && !frame().ownerElement())
- LOG(Layout, "FrameView %p elapsed time before first layout: %.3fs", this, document()->timeSinceDocumentCreation().value());
-#endif
-#if PLATFORM(IOS)
- if (view().updateFixedPositionLayoutRect() && subtreeLayoutRoot())
- convertSubtreeLayoutToFullLayout();
-#endif
- if (handleLayoutWithFrameFlatteningIfNeeded())
- return;
-
- {
- SetForScope<LayoutPhase> layoutPhase(m_layoutPhase, LayoutPhase::InPreLayout);
-
- // If this is a new top-level layout and there are any remaining tasks from the previous layout, finish them now.
- if (!isLayoutNested() && m_asynchronousTasksTimer.isActive() && !view().isInChildFrameWithFrameFlattening())
- runAsynchronousTasks();
-
- updateStyleForLayout();
- if (view().hasOneRef())
- return;
-
- view().autoSizeIfEnabled();
- if (!renderView())
- return;
-
- layoutRoot = makeWeakPtr(subtreeLayoutRoot() ? subtreeLayoutRoot() : renderView());
- m_needsFullRepaint = is<RenderView>(layoutRoot.get()) && (m_firstLayout || renderView()->printing());
- view().willDoLayout(layoutRoot);
- m_firstLayout = false;
- }
- {
- SetForScope<LayoutPhase> layoutPhase(m_layoutPhase, LayoutPhase::InRenderTreeLayout);
- ScriptDisallowedScope::InMainThread scriptDisallowedScope;
- SubtreeLayoutStateMaintainer subtreeLayoutStateMaintainer(subtreeLayoutRoot());
- RenderView::RepaintRegionAccumulator repaintRegionAccumulator(renderView());
-#ifndef NDEBUG
- RenderTreeNeedsLayoutChecker checker(*layoutRoot);
-#endif
- layoutRoot->layout();
- ++m_layoutCount;
-#if ENABLE(TEXT_AUTOSIZING)
- applyTextSizingIfNeeded(*layoutRoot.get());
-#endif
- clearSubtreeLayoutRoot();
- }
- {
- SetForScope<LayoutPhase> layoutPhase(m_layoutPhase, LayoutPhase::InViewSizeAdjust);
- if (is<RenderView>(layoutRoot.get()) && !renderView()->printing()) {
- // This is to protect m_needsFullRepaint's value when layout() is getting re-entered through adjustViewSize().
- SetForScope<bool> needsFullRepaint(m_needsFullRepaint);
- view().adjustViewSize();
- // FIXME: Firing media query callbacks synchronously on nested frames could produced a detached FrameView here by
- // navigating away from the current document (see webkit.org/b/173329).
- if (view().hasOneRef())
- return;
- }
- }
- {
- SetForScope<LayoutPhase> layoutPhase(m_layoutPhase, LayoutPhase::InPostLayout);
- if (m_needsFullRepaint)
- renderView()->repaintRootContents();
- ASSERT(!layoutRoot->needsLayout());
- view().didLayout(layoutRoot);
- runOrScheduleAsynchronousTasks();
- }
- InspectorInstrumentation::didLayout(inspectorLayoutScope, *layoutRoot);
- DebugPageOverlays::didLayout(view().frame());
-}
-
-void LayoutContext::runOrScheduleAsynchronousTasks()
-{
- if (m_asynchronousTasksTimer.isActive())
- return;
-
- if (view().isInChildFrameWithFrameFlattening()) {
- // While flattening frames, we defer post layout tasks to avoid getting stuck in a cycle,
- // except updateWidgetPositions() which is required to kick off subframe layout in certain cases.
- if (!m_inAsynchronousTasks)
- view().updateWidgetPositions();
- m_asynchronousTasksTimer.startOneShot(0_s);
- return;
- }
-
- // If we are already in performPostLayoutTasks(), defer post layout tasks until after we return
- // to avoid re-entrancy.
- if (m_inAsynchronousTasks) {
- m_asynchronousTasksTimer.startOneShot(0_s);
- return;
- }
-
- runAsynchronousTasks();
- if (needsLayout()) {
- // If runAsynchronousTasks() made us layout again, let's defer the tasks until after we return.
- m_asynchronousTasksTimer.startOneShot(0_s);
- layout();
- }
-}
-
-void LayoutContext::runAsynchronousTasks()
-{
- m_asynchronousTasksTimer.stop();
- if (m_inAsynchronousTasks)
- return;
- SetForScope<bool> inAsynchronousTasks(m_inAsynchronousTasks, true);
- view().performPostLayoutTasks();
-}
-
-void LayoutContext::flushAsynchronousTasks()
-{
- if (!m_asynchronousTasksTimer.isActive())
- return;
- runAsynchronousTasks();
-}
-
-void LayoutContext::reset()
-{
- m_layoutPhase = LayoutPhase::OutsideLayout;
- clearSubtreeLayoutRoot();
- m_layoutCount = 0;
- m_layoutSchedulingIsEnabled = true;
- m_delayedLayout = false;
- m_layoutTimer.stop();
- m_firstLayout = true;
- m_asynchronousTasksTimer.stop();
- m_needsFullRepaint = true;
-}
-
-bool LayoutContext::needsLayout() const
-{
- // This can return true in cases where the document does not have a body yet.
- // Document::shouldScheduleLayout takes care of preventing us from scheduling
- // layout in that case.
- auto* renderView = this->renderView();
- return isLayoutPending()
- || (renderView && renderView->needsLayout())
- || subtreeLayoutRoot()
- || (m_disableSetNeedsLayoutCount && m_setNeedsLayoutWasDeferred);
-}
-
-void LayoutContext::setNeedsLayout()
-{
- if (m_disableSetNeedsLayoutCount) {
- m_setNeedsLayoutWasDeferred = true;
- return;
- }
-
- if (auto* renderView = this->renderView()) {
- ASSERT(!renderView->inHitTesting());
- renderView->setNeedsLayout();
- }
-}
-
-void LayoutContext::enableSetNeedsLayout()
-{
- ASSERT(m_disableSetNeedsLayoutCount);
- if (!--m_disableSetNeedsLayoutCount)
- m_setNeedsLayoutWasDeferred = false; // FIXME: Find a way to make the deferred layout actually happen.
-}
-
-void LayoutContext::disableSetNeedsLayout()
-{
- ++m_disableSetNeedsLayoutCount;
-}
-
-void LayoutContext::scheduleLayout()
-{
- // FIXME: We should assert the page is not in the page cache, but that is causing
- // too many false assertions. See <rdar://problem/7218118>.
- ASSERT(frame().view() == &view());
-
- if (subtreeLayoutRoot())
- convertSubtreeLayoutToFullLayout();
- if (!isLayoutSchedulingEnabled())
- return;
- if (!needsLayout())
- return;
- if (!frame().document()->shouldScheduleLayout())
- return;
- InspectorInstrumentation::didInvalidateLayout(frame());
- // When frame flattening is enabled, the contents of the frame could affect the layout of the parent frames.
- // Also invalidate parent frame starting from the owner element of this frame.
- if (frame().ownerRenderer() && view().isInChildFrameWithFrameFlattening())
- frame().ownerRenderer()->setNeedsLayout(MarkContainingBlockChain);
-
- Seconds delay = frame().document()->minimumLayoutDelay();
- if (m_layoutTimer.isActive() && m_delayedLayout && !delay)
- unscheduleLayout();
-
- if (m_layoutTimer.isActive())
- return;
-
- m_delayedLayout = delay.value();
-
-#if !LOG_DISABLED
- if (!frame().document()->ownerElement())
- LOG(Layout, "FrameView %p scheduling layout for %.3fs", this, delay.value());
-#endif
-
- m_layoutTimer.startOneShot(delay);
-}
-
-void LayoutContext::unscheduleLayout()
-{
- if (m_asynchronousTasksTimer.isActive())
- m_asynchronousTasksTimer.stop();
-
- if (!m_layoutTimer.isActive())
- return;
-
-#if !LOG_DISABLED
- if (!frame().document()->ownerElement())
- LOG(Layout, "FrameView %p layout timer unscheduled at %.3fs", this, frame().document()->timeSinceDocumentCreation().value());
-#endif
-
- m_layoutTimer.stop();
- m_delayedLayout = false;
-}
-
-void LayoutContext::scheduleSubtreeLayout(RenderElement& layoutRoot)
-{
- ASSERT(renderView());
- auto& renderView = *this->renderView();
-
- // Try to catch unnecessary work during render tree teardown.
- ASSERT(!renderView.renderTreeBeingDestroyed());
- ASSERT(frame().view() == &view());
-
- if (renderView.needsLayout() && !subtreeLayoutRoot()) {
- layoutRoot.markContainingBlocksForLayout(ScheduleRelayout::No);
- return;
- }
-
- if (!isLayoutPending() && isLayoutSchedulingEnabled()) {
- Seconds delay = renderView.document().minimumLayoutDelay();
- ASSERT(!layoutRoot.container() || is<RenderView>(layoutRoot.container()) || !layoutRoot.container()->needsLayout());
- setSubtreeLayoutRoot(layoutRoot);
- InspectorInstrumentation::didInvalidateLayout(frame());
- m_delayedLayout = delay.value();
- m_layoutTimer.startOneShot(delay);
- return;
- }
-
- auto* subtreeLayoutRoot = this->subtreeLayoutRoot();
- if (subtreeLayoutRoot == &layoutRoot)
- return;
-
- if (!subtreeLayoutRoot) {
- // We already have a pending (full) layout. Just mark the subtree for layout.
- layoutRoot.markContainingBlocksForLayout(ScheduleRelayout::No);
- InspectorInstrumentation::didInvalidateLayout(frame());
- return;
- }
-
- if (isObjectAncestorContainerOf(*subtreeLayoutRoot, layoutRoot)) {
- // Keep the current root.
- layoutRoot.markContainingBlocksForLayout(ScheduleRelayout::No, subtreeLayoutRoot);
- ASSERT(!subtreeLayoutRoot->container() || is<RenderView>(subtreeLayoutRoot->container()) || !subtreeLayoutRoot->container()->needsLayout());
- return;
- }
-
- if (isObjectAncestorContainerOf(layoutRoot, *subtreeLayoutRoot)) {
- // Re-root at newRelayoutRoot.
- subtreeLayoutRoot->markContainingBlocksForLayout(ScheduleRelayout::No, &layoutRoot);
- setSubtreeLayoutRoot(layoutRoot);
- ASSERT(!layoutRoot.container() || is<RenderView>(layoutRoot.container()) || !layoutRoot.container()->needsLayout());
- InspectorInstrumentation::didInvalidateLayout(frame());
- return;
- }
- // Two disjoint subtrees need layout. Mark both of them and issue a full layout instead.
- convertSubtreeLayoutToFullLayout();
- layoutRoot.markContainingBlocksForLayout(ScheduleRelayout::No);
- InspectorInstrumentation::didInvalidateLayout(frame());
-}
-
-void LayoutContext::layoutTimerFired()
-{
-#if !LOG_DISABLED
- if (!frame().document()->ownerElement())
- LOG(Layout, "FrameView %p layout timer fired at %.3fs", this, frame().document()->timeSinceDocumentCreation().value());
-#endif
- layout();
-}
-
-void LayoutContext::convertSubtreeLayoutToFullLayout()
-{
- ASSERT(subtreeLayoutRoot());
- subtreeLayoutRoot()->markContainingBlocksForLayout(ScheduleRelayout::No);
- clearSubtreeLayoutRoot();
-}
-
-void LayoutContext::setSubtreeLayoutRoot(RenderElement& layoutRoot)
-{
- m_subtreeLayoutRoot = makeWeakPtr(layoutRoot);
-}
-
-bool LayoutContext::canPerformLayout() const
-{
- if (isInRenderTreeLayout())
- return false;
-
- if (layoutDisallowed())
- return false;
-
- if (view().isPainting())
- return false;
-
- if (!subtreeLayoutRoot() && !frame().document()->renderView())
- return false;
-
- return true;
-}
-
-#if ENABLE(TEXT_AUTOSIZING)
-void LayoutContext::applyTextSizingIfNeeded(RenderElement& layoutRoot)
-{
- auto& settings = layoutRoot.settings();
- if (!settings.textAutosizingEnabled() || renderView()->printing())
- return;
- auto minimumZoomFontSize = settings.minimumZoomFontSize();
- if (!minimumZoomFontSize)
- return;
- auto textAutosizingWidth = layoutRoot.page().textAutosizingWidth();
- if (auto overrideWidth = settings.textAutosizingWindowSizeOverride().width())
- textAutosizingWidth = overrideWidth;
- if (!textAutosizingWidth)
- return;
- layoutRoot.adjustComputedFontSizesOnBlocks(minimumZoomFontSize, textAutosizingWidth);
- if (!layoutRoot.needsLayout())
- return;
- LOG(TextAutosizing, "Text Autosizing: minimumZoomFontSize=%.2f textAutosizingWidth=%.2f", minimumZoomFontSize, textAutosizingWidth);
- layoutRoot.layout();
-}
-#endif
-
-void LayoutContext::updateStyleForLayout()
-{
- Document& document = *frame().document();
-
- // FIXME: This shouldn't be necessary, but see rdar://problem/36670246.
- if (!document.styleScope().resolverIfExists())
- document.styleScope().didChangeStyleSheetEnvironment();
-
- // Viewport-dependent media queries may cause us to need completely different style information.
- document.styleScope().evaluateMediaQueriesForViewportChange();
-
- document.evaluateMediaQueryList();
- // If there is any pagination to apply, it will affect the RenderView's style, so we should
- // take care of that now.
- view().applyPaginationToViewport();
- // Always ensure our style info is up-to-date. This can happen in situations where
- // the layout beats any sort of style recalc update that needs to occur.
- document.updateStyleIfNeeded();
-}
-
-bool LayoutContext::handleLayoutWithFrameFlatteningIfNeeded()
-{
- if (!view().isInChildFrameWithFrameFlattening())
- return false;
-
- startLayoutAtMainFrameViewIfNeeded();
- auto* layoutRoot = subtreeLayoutRoot() ? subtreeLayoutRoot() : frame().document()->renderView();
- return !layoutRoot || !layoutRoot->needsLayout();
-}
-
-void LayoutContext::startLayoutAtMainFrameViewIfNeeded()
-{
- // When we start a layout at the child level as opposed to the topmost frame view and this child
- // frame requires flattening, we need to re-initiate the layout at the topmost view. Layout
- // will hit this view eventually.
- auto* parentView = view().parentFrameView();
- if (!parentView)
- return;
-
- // In the middle of parent layout, no need to restart from topmost.
- if (parentView->layoutContext().isInLayout())
- return;
-
- // Parent tree is clean. Starting layout from it would have no effect.
- if (!parentView->needsLayout())
- return;
-
- while (parentView->parentFrameView())
- parentView = parentView->parentFrameView();
-
- LOG(Layout, " frame flattening, starting from root");
- parentView->layoutContext().layout();
-}
-
-LayoutSize LayoutContext::layoutDelta() const
-{
- if (auto* layoutState = this->layoutState())
- return layoutState->layoutDelta();
- return { };
-}
-
-void LayoutContext::addLayoutDelta(const LayoutSize& delta)
-{
- if (auto* layoutState = this->layoutState())
- layoutState->addLayoutDelta(delta);
-}
-
-#if !ASSERT_DISABLED
-bool LayoutContext::layoutDeltaMatches(const LayoutSize& delta)
-{
- if (auto* layoutState = this->layoutState())
- return layoutState->layoutDeltaMatches(delta);
- return false;
-}
-#endif
-
-LayoutState* LayoutContext::layoutState() const
-{
- if (m_layoutStateStack.isEmpty())
- return nullptr;
- return m_layoutStateStack.last().get();
-}
-
-void LayoutContext::pushLayoutState(RenderElement& root)
-{
- ASSERT(!m_paintOffsetCacheDisableCount);
- ASSERT(!layoutState());
-
- m_layoutStateStack.append(std::make_unique<LayoutState>(root));
-}
-
-bool LayoutContext::pushLayoutStateForPaginationIfNeeded(RenderBlockFlow& layoutRoot)
-{
- if (layoutState())
- return false;
- m_layoutStateStack.append(std::make_unique<LayoutState>(layoutRoot, LayoutState::IsPaginated::Yes));
- return true;
-}
-
-bool LayoutContext::pushLayoutState(RenderBox& renderer, const LayoutSize& offset, LayoutUnit pageHeight, bool pageHeightChanged)
-{
- // We push LayoutState even if layoutState is disabled because it stores layoutDelta too.
- auto* layoutState = this->layoutState();
- if (!layoutState || !needsFullRepaint() || layoutState->isPaginated() || renderer.enclosingFragmentedFlow()
- || layoutState->lineGrid() || (renderer.style().lineGrid() != RenderStyle::initialLineGrid() && renderer.isRenderBlockFlow())) {
- m_layoutStateStack.append(std::make_unique<LayoutState>(m_layoutStateStack, renderer, offset, pageHeight, pageHeightChanged));
- return true;
- }
- return false;
-}
-
-void LayoutContext::popLayoutState()
-{
- m_layoutStateStack.removeLast();
-}
-
-#ifndef NDEBUG
-void LayoutContext::checkLayoutState()
-{
- ASSERT(layoutDeltaMatches(LayoutSize()));
- ASSERT(!m_paintOffsetCacheDisableCount);
-}
-#endif
-
-Frame& LayoutContext::frame() const
-{
- return view().frame();
-}
-
-FrameView& LayoutContext::view() const
-{
- return m_frameView;
-}
-
-RenderView* LayoutContext::renderView() const
-{
- return view().renderView();
-}
-
-Document* LayoutContext::document() const
-{
- return frame().document();
-}
-
-} // namespace WebCore
Deleted: trunk/Source/WebCore/page/LayoutContext.h (230965 => 230966)
--- trunk/Source/WebCore/page/LayoutContext.h 2018-04-24 19:19:47 UTC (rev 230965)
+++ trunk/Source/WebCore/page/LayoutContext.h 2018-04-24 19:48:53 UTC (rev 230966)
@@ -1,179 +0,0 @@
-/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include "LayoutUnit.h"
-#include "Timer.h"
-
-#include <wtf/WeakPtr.h>
-
-namespace WebCore {
-
-class Document;
-class Frame;
-class FrameView;
-class LayoutScope;
-class LayoutSize;
-class LayoutState;
-class RenderBlockFlow;
-class RenderBox;
-class RenderObject;
-class RenderElement;
-class RenderView;
-
-class LayoutContext {
-public:
- LayoutContext(FrameView&);
- ~LayoutContext();
-
- void layout();
-
- void setNeedsLayout();
- bool needsLayout() const;
-
- void scheduleLayout();
- void scheduleSubtreeLayout(RenderElement& layoutRoot);
- void unscheduleLayout();
-
- void startDisallowingLayout() { ++m_layoutDisallowedCount; }
- void endDisallowingLayout() { ASSERT(m_layoutDisallowedCount > 0); --m_layoutDisallowedCount; }
-
- void disableSetNeedsLayout();
- void enableSetNeedsLayout();
-
- enum class LayoutPhase {
- OutsideLayout,
- InPreLayout,
- InRenderTreeLayout,
- InViewSizeAdjust,
- InPostLayout
- };
- LayoutPhase layoutPhase() const { return m_layoutPhase; }
- bool isLayoutNested() const { return m_layoutNestedState == LayoutNestedState::Nested; }
- bool isLayoutPending() const { return m_layoutTimer.isActive(); }
- bool isInLayout() const { return layoutPhase() != LayoutPhase::OutsideLayout; }
- bool isInRenderTreeLayout() const { return layoutPhase() == LayoutPhase::InRenderTreeLayout; }
- bool inPaintableState() const { return layoutPhase() != LayoutPhase::InRenderTreeLayout && layoutPhase() != LayoutPhase::InViewSizeAdjust && (layoutPhase() != LayoutPhase::InPostLayout || inAsynchronousTasks()); }
-
- unsigned layoutCount() const { return m_layoutCount; }
-
- RenderElement* subtreeLayoutRoot() const { return m_subtreeLayoutRoot.get(); }
- void clearSubtreeLayoutRoot() { m_subtreeLayoutRoot.clear(); }
- void convertSubtreeLayoutToFullLayout();
-
- void reset();
- void resetFirstLayoutFlag() { m_firstLayout = true; }
- bool didFirstLayout() const { return !m_firstLayout; }
-
- void setNeedsFullRepaint() { m_needsFullRepaint = true; }
- bool needsFullRepaint() const { return m_needsFullRepaint; }
-
- void flushAsynchronousTasks();
-
- LayoutState* layoutState() const;
- // Returns true if layoutState should be used for its cached offset and clip.
- bool isPaintOffsetCacheEnabled() const { return !m_paintOffsetCacheDisableCount && layoutState(); }
-#ifndef NDEBUG
- void checkLayoutState();
-#endif
- // layoutDelta is used transiently during layout to store how far an object has moved from its
- // last layout location, in order to repaint correctly.
- // If we're doing a full repaint m_layoutState will be 0, but in that case layoutDelta doesn't matter.
- LayoutSize layoutDelta() const;
- void addLayoutDelta(const LayoutSize& delta);
-#if !ASSERT_DISABLED
- bool layoutDeltaMatches(const LayoutSize& delta);
-#endif
- using LayoutStateStack = Vector<std::unique_ptr<LayoutState>>;
-
-private:
- friend class LayoutScope;
- friend class LayoutStateMaintainer;
- friend class LayoutStateDisabler;
- friend class SubtreeLayoutStateMaintainer;
- friend class PaginatedLayoutStateMaintainer;
-
- bool canPerformLayout() const;
- bool layoutDisallowed() const { return m_layoutDisallowedCount; }
- bool isLayoutSchedulingEnabled() const { return m_layoutSchedulingIsEnabled; }
-
- void layoutTimerFired();
- void runAsynchronousTasks();
- void runOrScheduleAsynchronousTasks();
- bool inAsynchronousTasks() const { return m_inAsynchronousTasks; }
-
- void setSubtreeLayoutRoot(RenderElement&);
-
-#if ENABLE(TEXT_AUTOSIZING)
- void applyTextSizingIfNeeded(RenderElement& layoutRoot);
-#endif
- void updateStyleForLayout();
-
- bool handleLayoutWithFrameFlatteningIfNeeded();
- void startLayoutAtMainFrameViewIfNeeded();
-
- // These functions may only be accessed by LayoutStateMaintainer.
- // Subtree push/pop
- void pushLayoutState(RenderElement&);
- bool pushLayoutStateForPaginationIfNeeded(RenderBlockFlow&);
- bool pushLayoutState(RenderBox& renderer, const LayoutSize& offset, LayoutUnit pageHeight = 0, bool pageHeightChanged = false);
- void popLayoutState();
-
- // Suspends the LayoutState optimization. Used under transforms that cannot be represented by
- // LayoutState (common in SVG) and when manipulating the render tree during layout in ways
- // that can trigger repaint of a non-child (e.g. when a list item moves its list marker around).
- // Note that even when disabled, LayoutState is still used to store layoutDelta.
- // These functions may only be accessed by LayoutStateMaintainer or LayoutStateDisabler.
- void disablePaintOffsetCache() { m_paintOffsetCacheDisableCount++; }
- void enablePaintOffsetCache() { ASSERT(m_paintOffsetCacheDisableCount > 0); m_paintOffsetCacheDisableCount--; }
-
- Frame& frame() const;
- FrameView& view() const;
- RenderView* renderView() const;
- Document* document() const;
-
- FrameView& m_frameView;
- Timer m_layoutTimer;
- Timer m_asynchronousTasksTimer;
-
- bool m_layoutSchedulingIsEnabled { true };
- bool m_delayedLayout { false };
- bool m_firstLayout { true };
- bool m_needsFullRepaint { true };
- bool m_inAsynchronousTasks { false };
- bool m_setNeedsLayoutWasDeferred { false };
- LayoutPhase m_layoutPhase { LayoutPhase::OutsideLayout };
- enum class LayoutNestedState { NotInLayout, NotNested, Nested };
- LayoutNestedState m_layoutNestedState { LayoutNestedState::NotInLayout };
- unsigned m_layoutCount { 0 };
- unsigned m_disableSetNeedsLayoutCount { 0 };
- int m_layoutDisallowedCount { 0 };
- WeakPtr<RenderElement> m_subtreeLayoutRoot;
- LayoutStateStack m_layoutStateStack;
- unsigned m_paintOffsetCacheDisableCount { 0 };
-};
-
-} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/LayoutState.cpp (230965 => 230966)
--- trunk/Source/WebCore/rendering/LayoutState.cpp 2018-04-24 19:19:47 UTC (rev 230965)
+++ trunk/Source/WebCore/rendering/LayoutState.cpp 2018-04-24 19:48:53 UTC (rev 230966)
@@ -64,7 +64,7 @@
}
}
-LayoutState::LayoutState(const LayoutContext::LayoutStateStack& layoutStateStack, RenderBox& renderer, const LayoutSize& offset, LayoutUnit pageLogicalHeight, bool pageLogicalHeightChanged)
+LayoutState::LayoutState(const FrameViewLayoutContext::LayoutStateStack& layoutStateStack, RenderBox& renderer, const LayoutSize& offset, LayoutUnit pageLogicalHeight, bool pageLogicalHeightChanged)
: m_clipped(false)
, m_isPaginated(false)
, m_pageLogicalHeightChanged(false)
@@ -133,7 +133,7 @@
// FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present.
}
-void LayoutState::computePaginationInformation(const LayoutContext::LayoutStateStack& layoutStateStack, RenderBox& renderer, LayoutUnit pageLogicalHeight, bool pageLogicalHeightChanged)
+void LayoutState::computePaginationInformation(const FrameViewLayoutContext::LayoutStateStack& layoutStateStack, RenderBox& renderer, LayoutUnit pageLogicalHeight, bool pageLogicalHeightChanged)
{
auto* ancestor = layoutStateStack.isEmpty() ? nullptr : layoutStateStack.last().get();
// If we establish a new page height, then cache the offset to the top of the first page.
@@ -230,7 +230,7 @@
m_lineGridPaginationOrigin = ancestor.lineGridPaginationOrigin();
}
-void LayoutState::establishLineGrid(const LayoutContext::LayoutStateStack& layoutStateStack, RenderBlockFlow& renderer)
+void LayoutState::establishLineGrid(const FrameViewLayoutContext::LayoutStateStack& layoutStateStack, RenderBlockFlow& renderer)
{
// First check to see if this grid has been established already.
if (m_lineGrid) {
@@ -291,7 +291,7 @@
m_context.enablePaintOffsetCache();
}
-LayoutStateDisabler::LayoutStateDisabler(LayoutContext& context)
+LayoutStateDisabler::LayoutStateDisabler(FrameViewLayoutContext& context)
: m_context(context)
{
m_context.disablePaintOffsetCache();
Modified: trunk/Source/WebCore/rendering/LayoutState.h (230965 => 230966)
--- trunk/Source/WebCore/rendering/LayoutState.h 2018-04-24 19:19:47 UTC (rev 230965)
+++ trunk/Source/WebCore/rendering/LayoutState.h 2018-04-24 19:48:53 UTC (rev 230966)
@@ -25,13 +25,12 @@
#pragma once
-#include "LayoutContext.h"
+#include "FrameViewLayoutContext.h"
#include "LayoutRect.h"
#include <wtf/Noncopyable.h>
namespace WebCore {
-class LayoutContext;
class RenderBlockFlow;
class RenderBox;
class RenderElement;
@@ -53,7 +52,7 @@
#endif
{
}
- LayoutState(const LayoutContext::LayoutStateStack&, RenderBox&, const LayoutSize& offset, LayoutUnit pageHeight, bool pageHeightChanged);
+ LayoutState(const FrameViewLayoutContext::LayoutStateStack&, RenderBox&, const LayoutSize& offset, LayoutUnit pageHeight, bool pageHeightChanged);
enum class IsPaginated { No, Yes };
explicit LayoutState(RenderElement&, IsPaginated = IsPaginated::No);
@@ -92,10 +91,10 @@
private:
void computeOffsets(const LayoutState& ancestor, RenderBox&, LayoutSize offset);
void computeClipRect(const LayoutState& ancestor, RenderBox&);
- // FIXME: webkit.org/b/179440 these functions should be part of the pagination code/LayoutContext.
- void computePaginationInformation(const LayoutContext::LayoutStateStack&, RenderBox&, LayoutUnit pageLogicalHeight, bool pageLogicalHeightChanged);
+ // FIXME: webkit.org/b/179440 these functions should be part of the pagination code/FrameViewLayoutContext.
+ void computePaginationInformation(const FrameViewLayoutContext::LayoutStateStack&, RenderBox&, LayoutUnit pageLogicalHeight, bool pageLogicalHeightChanged);
void propagateLineGridInfo(const LayoutState& ancestor, RenderBox&);
- void establishLineGrid(const LayoutContext::LayoutStateStack&, RenderBlockFlow&);
+ void establishLineGrid(const FrameViewLayoutContext::LayoutStateStack&, RenderBlockFlow&);
void computeLineGridPaginationOrigin(const RenderMultiColumnFlow&);
// Do not add anything apart from bitfields. See https://bugs.webkit.org/show_bug.cgi?id=100173
@@ -142,7 +141,7 @@
~LayoutStateMaintainer();
private:
- LayoutContext& m_context;
+ FrameViewLayoutContext& m_context;
bool m_paintOffsetCacheIsDisabled { false };
bool m_didPushLayoutState { false };
};
@@ -153,7 +152,7 @@
~SubtreeLayoutStateMaintainer();
private:
- LayoutContext* m_context { nullptr };
+ FrameViewLayoutContext* m_context { nullptr };
bool m_didDisablePaintOffsetCache { false };
};
@@ -160,11 +159,11 @@
class LayoutStateDisabler {
WTF_MAKE_NONCOPYABLE(LayoutStateDisabler);
public:
- LayoutStateDisabler(LayoutContext&);
+ LayoutStateDisabler(FrameViewLayoutContext&);
~LayoutStateDisabler();
private:
- LayoutContext& m_context;
+ FrameViewLayoutContext& m_context;
};
class PaginatedLayoutStateMaintainer {
@@ -173,7 +172,7 @@
~PaginatedLayoutStateMaintainer();
private:
- LayoutContext& m_context;
+ FrameViewLayoutContext& m_context;
bool m_pushed { false };
};