Diff
Modified: trunk/Source/WebCore/ChangeLog (231354 => 231355)
--- trunk/Source/WebCore/ChangeLog 2018-05-04 16:15:12 UTC (rev 231354)
+++ trunk/Source/WebCore/ChangeLog 2018-05-04 16:30:27 UTC (rev 231355)
@@ -1,3 +1,27 @@
+2018-05-04 Zalan Bujtas <[email protected]>
+
+ [LFC] Set the invalidation root as the result of style change.
+ https://bugs.webkit.org/show_bug.cgi?id=185301
+
+ Reviewed by Antti Koivisto.
+
+ Compute/propagate the update type on the ancestor chain and return the invalidation root
+ so that LayoutContext could use it as the entry point for the next layout frame.
+
+ * layout/LayoutContext.cpp:
+ (WebCore::Layout::LayoutContext::updateLayout):
+ (WebCore::Layout::LayoutContext::styleChanged):
+ * layout/LayoutContext.h: order is not important.
+ * layout/blockformatting/BlockInvalidation.cpp:
+ (WebCore::Layout::invalidationStopsAtFormattingContextBoundary):
+ (WebCore::Layout::computeUpdateType):
+ (WebCore::Layout::computeUpdateTypeForAncestor):
+ (WebCore::Layout::BlockInvalidation::invalidate):
+ * layout/blockformatting/BlockInvalidation.h:
+ * layout/inlineformatting/InlineInvalidation.cpp:
+ (WebCore::Layout::InlineInvalidation::invalidate):
+ * layout/inlineformatting/InlineInvalidation.h:
+
2018-05-04 Youenn Fablet <[email protected]>
PeerConnection should have its connectionState closed even if doing gathering
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (231354 => 231355)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-05-04 16:15:12 UTC (rev 231354)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-05-04 16:30:27 UTC (rev 231355)
@@ -5749,6 +5749,7 @@
115CFA89208B921A001E6991 /* BlockMarginCollapse.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BlockMarginCollapse.cpp; sourceTree = "<group>"; };
115CFA95208B952B001E6991 /* LayoutBox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutBox.h; sourceTree = "<group>"; };
115CFA96208B952B001E6991 /* LayoutBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutBox.cpp; sourceTree = "<group>"; };
+ 115F7805209CBCBD00739C13 /* Invalidation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Invalidation.h; sourceTree = "<group>"; };
119340761FE8B92300935F1E /* RenderTreeBuilderTable.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTreeBuilderTable.cpp; sourceTree = "<group>"; };
119340771FE8B92300935F1E /* RenderTreeBuilderTable.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderTreeBuilderTable.h; sourceTree = "<group>"; };
119340871FEB355D00935F1E /* RenderTreeBuilderRuby.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTreeBuilderRuby.cpp; sourceTree = "<group>"; };
@@ -15653,6 +15654,7 @@
115CFA68208AF7D0001E6991 /* FormattingContext.h */,
115CFA75208AFE30001E6991 /* FormattingState.cpp */,
115CFA74208AFE30001E6991 /* FormattingState.h */,
+ 115F7805209CBCBD00739C13 /* Invalidation.h */,
6F7CA3C5208C2956002F29AB /* LayoutContext.cpp */,
6F7CA3C4208C2956002F29AB /* LayoutContext.h */,
);
Copied: trunk/Source/WebCore/layout/Invalidation.h (from rev 231354, trunk/Source/WebCore/layout/blockformatting/BlockInvalidation.h) (0 => 231355)
--- trunk/Source/WebCore/layout/Invalidation.h (rev 0)
+++ trunk/Source/WebCore/layout/Invalidation.h 2018-05-04 16:30:27 UTC (rev 231355)
@@ -0,0 +1,41 @@
+/*
+ * 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)
+
+namespace WebCore {
+namespace Layout {
+
+class Container;
+
+struct InvalidationResult {
+ const Container* root;
+};
+
+}
+}
+#endif
Modified: trunk/Source/WebCore/layout/LayoutContext.cpp (231354 => 231355)
--- trunk/Source/WebCore/layout/LayoutContext.cpp 2018-05-04 16:15:12 UTC (rev 231354)
+++ trunk/Source/WebCore/layout/LayoutContext.cpp 2018-05-04 16:30:27 UTC (rev 231355)
@@ -35,6 +35,7 @@
#include "InlineFormattingContext.h"
#include "InlineFormattingState.h"
#include "InlineInvalidation.h"
+#include "Invalidation.h"
#include "LayoutBox.h"
#include "LayoutContainer.h"
#include <wtf/IsoMallocInlines.h>
@@ -52,8 +53,7 @@
void LayoutContext::updateLayout()
{
ASSERT(!m_formattingContextRootListForLayout.isEmpty());
- for (auto layoutRoot : m_formattingContextRootListForLayout) {
- RELEASE_ASSERT(layoutRoot.get());
+ for (auto* layoutRoot : m_formattingContextRootListForLayout) {
RELEASE_ASSERT(layoutRoot->establishesFormattingContext());
auto context = formattingContext(*layoutRoot);
auto& state = establishedFormattingState(*layoutRoot, *context);
@@ -73,12 +73,15 @@
void LayoutContext::styleChanged(const Box& layoutBox, StyleDiff styleDiff)
{
auto& formattingState = formattingStateForBox(layoutBox);
+ const Container* invalidationRoot = nullptr;
if (is<BlockFormattingState>(formattingState))
- BlockInvalidation::invalidate(layoutBox, styleDiff, *this, downcast<BlockFormattingState>(formattingState));
+ invalidationRoot = BlockInvalidation::invalidate(layoutBox, styleDiff, *this, downcast<BlockFormattingState>(formattingState)).root;
else if (is<InlineFormattingState>(formattingState))
- InlineInvalidation::invalidate(layoutBox, styleDiff, *this, downcast<InlineFormattingState>(formattingState));
+ invalidationRoot = InlineInvalidation::invalidate(layoutBox, styleDiff, *this, downcast<InlineFormattingState>(formattingState)).root;
else
ASSERT_NOT_REACHED();
+ ASSERT(invalidationRoot);
+ m_formattingContextRootListForLayout.addVoid(invalidationRoot);
}
void LayoutContext::markNeedsUpdate(const Box&, OptionSet<UpdateType>)
Modified: trunk/Source/WebCore/layout/LayoutContext.h (231354 => 231355)
--- trunk/Source/WebCore/layout/LayoutContext.h 2018-05-04 16:15:12 UTC (rev 231354)
+++ trunk/Source/WebCore/layout/LayoutContext.h 2018-05-04 16:30:27 UTC (rev 231355)
@@ -29,7 +29,7 @@
#include "FormattingContext.h"
#include "FormattingState.h"
-#include "LayoutBox.h"
+#include <wtf/HashSet.h>
#include <wtf/IsoMalloc.h>
#include <wtf/OptionSet.h>
@@ -42,6 +42,8 @@
namespace Layout {
enum class StyleDiff;
+class Box;
+class Container;
// 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).
@@ -76,7 +78,7 @@
private:
WeakPtr<Box> m_root;
- Vector<WeakPtr<Box>> m_formattingContextRootListForLayout;
+ HashSet<const Container*> m_formattingContextRootListForLayout;
HashMap<const Box*, std::unique_ptr<FormattingState>> m_formattingStates;
HashMap<const Box*, std::unique_ptr<Display::Box>> m_layoutToDisplayBox;
};
Modified: trunk/Source/WebCore/layout/blockformatting/BlockInvalidation.cpp (231354 => 231355)
--- trunk/Source/WebCore/layout/blockformatting/BlockInvalidation.cpp 2018-05-04 16:15:12 UTC (rev 231354)
+++ trunk/Source/WebCore/layout/blockformatting/BlockInvalidation.cpp 2018-05-04 16:30:27 UTC (rev 231355)
@@ -29,7 +29,9 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
#include "BlockFormattingState.h"
+#include "Invalidation.h"
#include "LayoutBox.h"
+#include "LayoutContainer.h"
#include "LayoutContext.h"
#include <wtf/IsoMallocInlines.h>
@@ -38,11 +40,37 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(BlockInvalidation);
-void BlockInvalidation::invalidate(const Box& layoutBox, StyleDiff, LayoutContext& layoutContext, BlockFormattingState&)
+static bool invalidationStopsAtFormattingContextBoundary(const Container& formattingContextRoot, const Box&, StyleDiff)
{
- layoutContext.markNeedsUpdate(layoutBox, LayoutContext::UpdateType::All);
+ ASSERT(formattingContextRoot.establishesFormattingContext());
+ return true;
}
+static LayoutContext::UpdateType computeUpdateType(const Box&, StyleDiff, BlockFormattingState&)
+{
+ return LayoutContext::UpdateType::All;
}
+
+static LayoutContext::UpdateType computeUpdateTypeForAncestor(const Container&, StyleDiff, BlockFormattingState&)
+{
+ return LayoutContext::UpdateType::All;
}
+
+InvalidationResult BlockInvalidation::invalidate(const Box& layoutBox, StyleDiff styleDiff, LayoutContext& layoutContext,
+ BlockFormattingState& formattingState)
+{
+ // Invalidate this box and the containing block chain all the way up to the formatting context root (and beyond if needed).
+ layoutContext.markNeedsUpdate(layoutBox, computeUpdateType(layoutBox, styleDiff, formattingState));
+ for (auto* containingBlock = layoutBox.containingBlock(); containingBlock; containingBlock = containingBlock->containingBlock()) {
+ if (containingBlock->establishesFormattingContext() && invalidationStopsAtFormattingContextBoundary(*containingBlock, layoutBox, styleDiff))
+ return { containingBlock };
+ layoutContext.markNeedsUpdate(*containingBlock, computeUpdateTypeForAncestor(*containingBlock, styleDiff, formattingState));
+ }
+ // Invalidation always stops at the initial containing block.
+ ASSERT_NOT_REACHED();
+ return { nullptr };
+}
+
+}
+}
#endif
Modified: trunk/Source/WebCore/layout/blockformatting/BlockInvalidation.h (231354 => 231355)
--- trunk/Source/WebCore/layout/blockformatting/BlockInvalidation.h 2018-05-04 16:15:12 UTC (rev 231354)
+++ trunk/Source/WebCore/layout/blockformatting/BlockInvalidation.h 2018-05-04 16:30:27 UTC (rev 231355)
@@ -35,6 +35,8 @@
class Box;
class BlockFormattingState;
+class Container;
+struct InvalidationResult;
class LayoutContext;
enum class StyleDiff;
@@ -42,7 +44,7 @@
class BlockInvalidation {
WTF_MAKE_ISO_ALLOCATED(BlockInvalidation);
public:
- static void invalidate(const Box&, StyleDiff, LayoutContext&, BlockFormattingState&);
+ static InvalidationResult invalidate(const Box&, StyleDiff, LayoutContext&, BlockFormattingState&);
};
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineInvalidation.cpp (231354 => 231355)
--- trunk/Source/WebCore/layout/inlineformatting/InlineInvalidation.cpp 2018-05-04 16:15:12 UTC (rev 231354)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineInvalidation.cpp 2018-05-04 16:30:27 UTC (rev 231355)
@@ -29,6 +29,7 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
#include "InlineFormattingState.h"
+#include "Invalidation.h"
#include "LayoutBox.h"
#include "LayoutContext.h"
#include <wtf/IsoMallocInlines.h>
@@ -38,9 +39,10 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(InlineInvalidation);
-void InlineInvalidation::invalidate(const Box& layoutBox, StyleDiff, LayoutContext& layoutContext, InlineFormattingState&)
+InvalidationResult InlineInvalidation::invalidate(const Box& layoutBox, StyleDiff, LayoutContext& layoutContext, InlineFormattingState&)
{
layoutContext.markNeedsUpdate(layoutBox, LayoutContext::UpdateType::All);
+ return { nullptr };
}
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineInvalidation.h (231354 => 231355)
--- trunk/Source/WebCore/layout/inlineformatting/InlineInvalidation.h 2018-05-04 16:15:12 UTC (rev 231354)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineInvalidation.h 2018-05-04 16:30:27 UTC (rev 231355)
@@ -34,7 +34,9 @@
namespace Layout {
class Box;
+class Container;
class InlineFormattingState;
+struct InvalidationResult;
class LayoutContext;
enum class StyleDiff;
@@ -42,7 +44,7 @@
class InlineInvalidation {
WTF_MAKE_ISO_ALLOCATED(InlineInvalidation);
public:
- static void invalidate(const Box&, StyleDiff, LayoutContext&, InlineFormattingState&);
+ static InvalidationResult invalidate(const Box&, StyleDiff, LayoutContext&, InlineFormattingState&);
};
}