Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (220915 => 220916)
--- trunk/Source/WebCore/CMakeLists.txt 2017-08-18 13:41:58 UTC (rev 220915)
+++ trunk/Source/WebCore/CMakeLists.txt 2017-08-18 14:52:22 UTC (rev 220916)
@@ -2796,6 +2796,7 @@
style/RenderTreePosition.cpp
style/RenderTreeUpdater.cpp
style/RenderTreeUpdaterFirstLetter.cpp
+ style/RenderTreeUpdaterListItem.cpp
style/StyleChange.cpp
style/StyleFontSizeFunctions.cpp
style/StyleInvalidator.cpp
Modified: trunk/Source/WebCore/ChangeLog (220915 => 220916)
--- trunk/Source/WebCore/ChangeLog 2017-08-18 13:41:58 UTC (rev 220915)
+++ trunk/Source/WebCore/ChangeLog 2017-08-18 14:52:22 UTC (rev 220916)
@@ -1,3 +1,45 @@
+2017-08-18 Antti Koivisto <an...@apple.com>
+
+ Factor render tree mutation code from RenderListItem to RenderTreeUpdater
+ https://bugs.webkit.org/show_bug.cgi?id=175718
+
+ Reviewed by Andreas Kling.
+
+ We already stopped doing layout time mutations. We can now move the code out too.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * rendering/RenderListItem.cpp:
+ (WebCore::isHTMLListElement):
+ (WebCore::getParentOfFirstLineBox): Deleted.
+ (WebCore::firstNonMarkerChild): Deleted.
+ (WebCore::RenderListItem::updateMarkerRenderer): Deleted.
+
+ Moved to RenderTreeUpdater::ListItem.
+
+ * rendering/RenderListItem.h:
+ * rendering/RenderListMarker.cpp:
+ (WebCore::RenderListMarker::willBeDestroyed):
+ * rendering/TextAutoSizing.cpp:
+ (WebCore::TextAutoSizingValue::adjustTextNodeSizes):
+ * style/RenderTreeUpdater.cpp:
+ (WebCore::RenderTreeUpdater::pushParent):
+ (WebCore::RenderTreeUpdater::popParent):
+ (WebCore::RenderTreeUpdater::updateBeforeDescendants):
+ (WebCore::RenderTreeUpdater::updateAfterDescendants):
+
+ Factor pre/post update into functions.
+
+ (WebCore::RenderTreeUpdater::updateBeforeOrAfterPseudoElement):
+ * style/RenderTreeUpdater.h:
+ * style/RenderTreeUpdaterListItem.cpp: Added.
+
+ Mutation functions move here.
+
+ (WebCore::getParentOfFirstLineBox):
+ (WebCore::firstNonMarkerChild):
+ (WebCore::RenderTreeUpdater::ListItem::updateMarker):
+ * style/RenderTreeUpdaterListItem.h: Added.
+
2017-08-18 Ms2ger <ms2...@gmail.com>
[GTK] Show controls if a video element isn't allowed to play inline.
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (220915 => 220916)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-08-18 13:41:58 UTC (rev 220915)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-08-18 14:52:22 UTC (rev 220916)
@@ -6792,6 +6792,9 @@
E48284081F44594C00863AC3 /* RenderTreeUpdaterFirstLetter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E48284061F44594B00863AC3 /* RenderTreeUpdaterFirstLetter.cpp */; };
E48944A2180B57D800F165D8 /* SimpleLineLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E48944A0180B57D800F165D8 /* SimpleLineLayout.cpp */; };
E48944A3180B57D800F165D8 /* SimpleLineLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = E48944A1180B57D800F165D8 /* SimpleLineLayout.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ E48E332C1F47037C00BAB0EF /* RenderTreeUpdaterFirstLetter.h in Headers */ = {isa = PBXBuildFile; fileRef = E48284091F44595600863AC3 /* RenderTreeUpdaterFirstLetter.h */; };
+ E48E332D1F47038000BAB0EF /* RenderTreeUpdaterListItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E48E332A1F46C98000BAB0EF /* RenderTreeUpdaterListItem.cpp */; };
+ E48E332E1F47038000BAB0EF /* RenderTreeUpdaterListItem.h in Headers */ = {isa = PBXBuildFile; fileRef = E48E33281F46C97F00BAB0EF /* RenderTreeUpdaterListItem.h */; };
E4916FF7195DF6A0005AB349 /* LayerFlushThrottleState.h in Headers */ = {isa = PBXBuildFile; fileRef = E4916FF6195DF6A0005AB349 /* LayerFlushThrottleState.h */; settings = {ATTRIBUTES = (Private, ); }; };
E4946EAE156E64DD00D3297F /* StyleRuleImport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4946EAC156E64DD00D3297F /* StyleRuleImport.cpp */; };
E4946EAF156E64DD00D3297F /* StyleRuleImport.h in Headers */ = {isa = PBXBuildFile; fileRef = E4946EAD156E64DD00D3297F /* StyleRuleImport.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -15405,6 +15408,8 @@
E48284091F44595600863AC3 /* RenderTreeUpdaterFirstLetter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderTreeUpdaterFirstLetter.h; sourceTree = "<group>"; };
E48944A0180B57D800F165D8 /* SimpleLineLayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleLineLayout.cpp; sourceTree = "<group>"; };
E48944A1180B57D800F165D8 /* SimpleLineLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayout.h; sourceTree = "<group>"; };
+ E48E33281F46C97F00BAB0EF /* RenderTreeUpdaterListItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTreeUpdaterListItem.h; sourceTree = "<group>"; };
+ E48E332A1F46C98000BAB0EF /* RenderTreeUpdaterListItem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTreeUpdaterListItem.cpp; sourceTree = "<group>"; };
E4916FF6195DF6A0005AB349 /* LayerFlushThrottleState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayerFlushThrottleState.h; sourceTree = "<group>"; };
E4946EAC156E64DD00D3297F /* StyleRuleImport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleRuleImport.cpp; sourceTree = "<group>"; };
E4946EAD156E64DD00D3297F /* StyleRuleImport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleRuleImport.h; sourceTree = "<group>"; };
@@ -24917,6 +24922,8 @@
E46180281C8A06CD0026C02C /* RenderTreeUpdater.h */,
E48284061F44594B00863AC3 /* RenderTreeUpdaterFirstLetter.cpp */,
E48284091F44595600863AC3 /* RenderTreeUpdaterFirstLetter.h */,
+ E48E332A1F46C98000BAB0EF /* RenderTreeUpdaterListItem.cpp */,
+ E48E33281F46C97F00BAB0EF /* RenderTreeUpdaterListItem.h */,
E401E0A51C3C0CF700F34D10 /* StyleChange.cpp */,
E401E0A31C3C0B8300F34D10 /* StyleChange.h */,
E4D58EB617B4ED8900CBDCA8 /* StyleFontSizeFunctions.cpp */,
@@ -27807,6 +27814,7 @@
1AE96A8D1D1A0DDD00B86768 /* JSApplePayPaymentMethodSelectedEvent.h in Headers */,
7C65231A1E00DBB500677F22 /* JSApplePayPaymentPass.h in Headers */,
7C6579F21E00856600E3A27A /* JSApplePayPaymentRequest.h in Headers */,
+ E48E332C1F47037C00BAB0EF /* RenderTreeUpdaterFirstLetter.h in Headers */,
1AE96A8F1D1A0DDD00B86768 /* JSApplePaySession.h in Headers */,
1AE96A911D1A0DDD00B86768 /* JSApplePayShippingContactSelectedEvent.h in Headers */,
7C6579F41E00856600E3A27A /* JSApplePayShippingMethod.h in Headers */,
@@ -29807,6 +29815,7 @@
BC22747B0E8366E200E7F975 /* SVGRenderStyleDefs.h in Headers */,
436708F212D9CA4B00044234 /* SVGRenderSupport.h in Headers */,
436708F412D9CA4B00044234 /* SVGRenderTreeAsText.h in Headers */,
+ E48E332E1F47038000BAB0EF /* RenderTreeUpdaterListItem.h in Headers */,
436708F612D9CA4B00044234 /* SVGResources.h in Headers */,
436708F812D9CA4B00044234 /* SVGResourcesCache.h in Headers */,
436708FA12D9CA4B00044234 /* SVGResourcesCycleSolver.h in Headers */,
@@ -31936,6 +31945,7 @@
E172AF8F1811BC3700FBADB9 /* JSDOMPromiseDeferred.cpp in Sources */,
0FF3B9281EE3B6DE00B84144 /* JSDOMQuad.cpp in Sources */,
0F94A3961EF1B10500FBAFFB /* JSDOMQuadCustom.cpp in Sources */,
+ E48E332D1F47038000BAB0EF /* RenderTreeUpdaterListItem.cpp in Sources */,
0FF3B92A1EE3B6DE00B84144 /* JSDOMQuadInit.cpp in Sources */,
0F4710BB1DB56BE8002DCEC3 /* JSDOMRect.cpp in Sources */,
0F4710BD1DB56BE8002DCEC3 /* JSDOMRectInit.cpp in Sources */,
Modified: trunk/Source/WebCore/rendering/RenderListItem.cpp (220915 => 220916)
--- trunk/Source/WebCore/rendering/RenderListItem.cpp 2017-08-18 13:41:58 UTC (rev 220915)
+++ trunk/Source/WebCore/rendering/RenderListItem.cpp 2017-08-18 14:52:22 UTC (rev 220916)
@@ -34,9 +34,6 @@
#include "RenderChildIterator.h"
#include "RenderInline.h"
#include "RenderListMarker.h"
-#include "RenderMultiColumnFlowThread.h"
-#include "RenderRuby.h"
-#include "RenderTable.h"
#include "RenderView.h"
#include "StyleInheritedData.h"
#if !ASSERT_DISABLED
@@ -110,7 +107,7 @@
updateListMarkerNumbers();
}
-static inline bool isHTMLListElement(const Node& node)
+bool isHTMLListElement(const Node& node)
{
return is<HTMLUListElement>(node) || is<HTMLOListElement>(node);
}
@@ -226,35 +223,6 @@
m_isValueUpToDate = true;
}
-static RenderBlock* getParentOfFirstLineBox(RenderBlock& current, RenderObject& marker)
-{
- bool inQuirksMode = current.document().inQuirksMode();
- for (auto& child : childrenOfType<RenderObject>(current)) {
- if (&child == &marker)
- continue;
-
- if (child.isInline() && (!is<RenderInline>(child) || current.generatesLineBoxesForInlineChild(&child)))
- return ¤t;
-
- if (child.isFloating() || child.isOutOfFlowPositioned())
- continue;
-
- if (!is<RenderBlock>(child) || is<RenderTable>(child) || is<RenderRubyAsBlock>(child))
- break;
-
- if (is<RenderBox>(child) && downcast<RenderBox>(child).isWritingModeRoot())
- break;
-
- if (is<RenderListItem>(current) && inQuirksMode && child.node() && isHTMLListElement(*child.node()))
- break;
-
- if (RenderBlock* lineBox = getParentOfFirstLineBox(downcast<RenderBlock>(child), marker))
- return lineBox;
- }
-
- return nullptr;
-}
-
void RenderListItem::updateValue()
{
if (!m_hasExplicitValue) {
@@ -264,58 +232,6 @@
}
}
-static RenderObject* firstNonMarkerChild(RenderBlock& parent)
-{
- RenderObject* child = parent.firstChild();
- while (is<RenderListMarker>(child))
- child = child->nextSibling();
- return child;
-}
-
-void RenderListItem::updateMarkerRenderer()
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!view().layoutState());
-
- if (style().listStyleType() == NoneListStyle && (!style().listStyleImage() || style().listStyleImage()->errorOccurred())) {
- if (m_marker) {
- m_marker->destroy();
- ASSERT(!m_marker);
- }
- return;
- }
-
- auto newStyle = computeMarkerStyle();
- if (m_marker)
- m_marker->setStyle(WTFMove(newStyle));
- else {
- m_marker = createRenderer<RenderListMarker>(*this, WTFMove(newStyle)).leakPtr();
- m_marker->initializeStyle();
- }
-
- RenderElement* currentParent = m_marker->parent();
- RenderBlock* newParent = getParentOfFirstLineBox(*this, *m_marker);
- if (!newParent) {
- // If the marker is currently contained inside an anonymous box,
- // then we are the only item in that anonymous box (since no line box
- // parent was found). It's ok to just leave the marker where it is
- // in this case.
- if (currentParent && currentParent->isAnonymousBlock())
- return;
- if (multiColumnFlowThread())
- newParent = multiColumnFlowThread();
- else
- newParent = this;
- }
-
- if (newParent != currentParent) {
- m_marker->removeFromParent();
- newParent->addChild(m_marker, firstNonMarkerChild(*newParent));
- // If current parent is an anonymous block that has lost all its children, destroy it.
- if (currentParent && currentParent->isAnonymousBlock() && !currentParent->firstChild() && !downcast<RenderBlock>(*currentParent).continuation())
- currentParent->destroy();
- }
-}
-
void RenderListItem::layout()
{
StackStats::LayoutCheckPoint layoutCheckPoint;
Modified: trunk/Source/WebCore/rendering/RenderListItem.h (220915 => 220916)
--- trunk/Source/WebCore/rendering/RenderListItem.h 2017-08-18 13:41:58 UTC (rev 220915)
+++ trunk/Source/WebCore/rendering/RenderListItem.h 2017-08-18 14:52:22 UTC (rev 220916)
@@ -54,9 +54,10 @@
static void updateItemValuesForOrderedList(const HTMLOListElement&);
static unsigned itemCountForOrderedList(const HTMLOListElement&);
- void didDestroyListMarker() { m_marker = nullptr; }
+ RenderStyle computeMarkerStyle() const;
- void updateMarkerRenderer();
+ RenderListMarker* markerRenderer() { return m_marker; }
+ void setMarkerRenderer(RenderListMarker* marker) { m_marker = marker; }
#if !ASSERT_DISABLED
bool inLayout() const { return m_inLayout; }
@@ -85,7 +86,6 @@
void updateValueNow() const;
void explicitValueChanged();
- RenderStyle computeMarkerStyle() const;
int m_explicitValue;
RenderListMarker* m_marker;
@@ -98,6 +98,8 @@
bool m_notInList : 1;
};
+bool isHTMLListElement(const Node&);
+
} // namespace WebCore
SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderListItem, isListItem())
Modified: trunk/Source/WebCore/rendering/RenderListMarker.cpp (220915 => 220916)
--- trunk/Source/WebCore/rendering/RenderListMarker.cpp 2017-08-18 13:41:58 UTC (rev 220915)
+++ trunk/Source/WebCore/rendering/RenderListMarker.cpp 2017-08-18 14:52:22 UTC (rev 220916)
@@ -1133,7 +1133,7 @@
void RenderListMarker::willBeDestroyed()
{
- m_listItem.didDestroyListMarker();
+ m_listItem.setMarkerRenderer(nullptr);
if (m_image)
m_image->removeClient(this);
Modified: trunk/Source/WebCore/rendering/TextAutoSizing.cpp (220915 => 220916)
--- trunk/Source/WebCore/rendering/TextAutoSizing.cpp 2017-08-18 13:41:58 UTC (rev 220915)
+++ trunk/Source/WebCore/rendering/TextAutoSizing.cpp 2017-08-18 14:52:22 UTC (rev 220916)
@@ -33,11 +33,11 @@
#include "FontCascade.h"
#include "Logging.h"
#include "RenderBlock.h"
-#include "RenderListItem.h"
#include "RenderListMarker.h"
#include "RenderText.h"
#include "RenderTextFragment.h"
#include "RenderTreeUpdaterFirstLetter.h"
+#include "RenderTreeUpdaterListItem.h"
#include "StyleResolver.h"
namespace WebCore {
@@ -159,7 +159,7 @@
parentRenderer->setStyle(WTFMove(newParentStyle));
if (is<RenderListItem>(*parentRenderer))
- downcast<RenderListItem>(*parentRenderer).updateMarkerRenderer();
+ RenderTreeUpdater::ListItem::updateMarker(downcast<RenderListItem>(*parentRenderer));
}
for (auto& node : m_autoSizedNodes) {
Modified: trunk/Source/WebCore/style/RenderTreeUpdater.cpp (220915 => 220916)
--- trunk/Source/WebCore/style/RenderTreeUpdater.cpp 2017-08-18 13:41:58 UTC (rev 220915)
+++ trunk/Source/WebCore/style/RenderTreeUpdater.cpp 2017-08-18 14:52:22 UTC (rev 220916)
@@ -43,6 +43,7 @@
#include "RenderNamedFlowThread.h"
#include "RenderQuote.h"
#include "RenderTreeUpdaterFirstLetter.h"
+#include "RenderTreeUpdaterListItem.h"
#include "StyleResolver.h"
#include "StyleTreeResolver.h"
#include <wtf/SystemTracing.h>
@@ -224,26 +225,15 @@
{
m_parentStack.append(Parent(element, changeType));
- updateBeforeOrAfterPseudoElement(element, BEFORE);
+ updateBeforeDescendants(element);
}
void RenderTreeUpdater::popParent()
{
auto& parent = m_parentStack.last();
+ if (parent.element)
+ updateAfterDescendants(*parent.element, parent.styleChange);
- if (parent.element) {
- updateBeforeOrAfterPseudoElement(*parent.element, AFTER);
-
- if (auto* renderer = parent.element->renderer()) {
- if (is<RenderBlock>(*renderer))
- FirstLetter::update(downcast<RenderBlock>(*renderer));
- if (is<RenderListItem>(*renderer))
- downcast<RenderListItem>(*renderer).updateMarkerRenderer();
-
- if (parent.element->hasCustomStyleResolveCallbacks() && parent.styleChange == Style::Detach)
- parent.element->didAttachRenderers();
- }
- }
m_parentStack.removeLast();
}
@@ -255,6 +245,29 @@
popParent();
}
+void RenderTreeUpdater::updateBeforeDescendants(Element& element)
+{
+ updateBeforeOrAfterPseudoElement(element, BEFORE);
+}
+
+void RenderTreeUpdater::updateAfterDescendants(Element& element, Style::Change styleChange)
+{
+ updateBeforeOrAfterPseudoElement(element, AFTER);
+
+ auto* renderer = element.renderer();
+ if (!renderer)
+ return;
+
+ // These functions do render tree mutations that require descendant renderers.
+ if (is<RenderBlock>(*renderer))
+ FirstLetter::update(downcast<RenderBlock>(*renderer));
+ if (is<RenderListItem>(*renderer))
+ ListItem::updateMarker(downcast<RenderListItem>(*renderer));
+
+ if (element.hasCustomStyleResolveCallbacks() && styleChange == Style::Detach)
+ element.didAttachRenderers();
+}
+
static bool pseudoStyleCacheIsInvalid(RenderElement* renderer, RenderStyle* newStyle)
{
const RenderStyle& currentStyle = renderer->style();
@@ -571,7 +584,7 @@
updateQuotesUpTo(&child);
}
if (is<RenderListItem>(*pseudoRenderer))
- downcast<RenderListItem>(*pseudoRenderer).updateMarkerRenderer();
+ ListItem::updateMarker(downcast<RenderListItem>(*pseudoRenderer));
}
void RenderTreeUpdater::tearDownRenderers(Element& root, TeardownType teardownType)
Modified: trunk/Source/WebCore/style/RenderTreeUpdater.h (220915 => 220916)
--- trunk/Source/WebCore/style/RenderTreeUpdater.h 2017-08-18 13:41:58 UTC (rev 220915)
+++ trunk/Source/WebCore/style/RenderTreeUpdater.h 2017-08-18 14:52:22 UTC (rev 220916)
@@ -52,6 +52,7 @@
static void tearDownRenderer(Text&);
class FirstLetter;
+ class ListItem;
private:
void updateRenderTree(ContainerNode& root);
@@ -59,6 +60,8 @@
void updateElementRenderer(Element&, const Style::ElementUpdate&);
void createRenderer(Element&, RenderStyle&&);
void invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(Node&);
+ void updateBeforeDescendants(Element&);
+ void updateAfterDescendants(Element&, Style::Change);
void updateBeforeOrAfterPseudoElement(Element&, PseudoId);
struct Parent {
Added: trunk/Source/WebCore/style/RenderTreeUpdaterListItem.cpp (0 => 220916)
--- trunk/Source/WebCore/style/RenderTreeUpdaterListItem.cpp (rev 0)
+++ trunk/Source/WebCore/style/RenderTreeUpdaterListItem.cpp 2017-08-18 14:52:22 UTC (rev 220916)
@@ -0,0 +1,120 @@
+/**
+ * Copyright (C) 1999 Lars Knoll (kn...@kde.org)
+ * (C) 1999 Antti Koivisto (koivi...@kde.org)
+ * Copyright (C) 2003-2006, 2010, 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2006 Andrew Wellington (pro...@wiretapped.net)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "RenderTreeUpdaterListItem.h"
+
+#include "RenderChildIterator.h"
+#include "RenderListMarker.h"
+#include "RenderMultiColumnFlowThread.h"
+#include "RenderRuby.h"
+#include "RenderTable.h"
+
+namespace WebCore {
+
+static RenderBlock* getParentOfFirstLineBox(RenderBlock& current, RenderObject& marker)
+{
+ bool inQuirksMode = current.document().inQuirksMode();
+ for (auto& child : childrenOfType<RenderObject>(current)) {
+ if (&child == &marker)
+ continue;
+
+ if (child.isInline() && (!is<RenderInline>(child) || current.generatesLineBoxesForInlineChild(&child)))
+ return ¤t;
+
+ if (child.isFloating() || child.isOutOfFlowPositioned())
+ continue;
+
+ if (!is<RenderBlock>(child) || is<RenderTable>(child) || is<RenderRubyAsBlock>(child))
+ break;
+
+ if (is<RenderBox>(child) && downcast<RenderBox>(child).isWritingModeRoot())
+ break;
+
+ if (is<RenderListItem>(current) && inQuirksMode && child.node() && isHTMLListElement(*child.node()))
+ break;
+
+ if (RenderBlock* lineBox = getParentOfFirstLineBox(downcast<RenderBlock>(child), marker))
+ return lineBox;
+ }
+
+ return nullptr;
+}
+
+static RenderObject* firstNonMarkerChild(RenderBlock& parent)
+{
+ RenderObject* child = parent.firstChild();
+ while (is<RenderListMarker>(child))
+ child = child->nextSibling();
+ return child;
+}
+
+void RenderTreeUpdater::ListItem::updateMarker(RenderListItem& listItemRenderer)
+{
+ ASSERT_WITH_SECURITY_IMPLICATION(!listItemRenderer.view().layoutState());
+
+ auto& style = listItemRenderer.style();
+
+ if (style.listStyleType() == NoneListStyle && (!style.listStyleImage() || style.listStyleImage()->errorOccurred())) {
+ if (listItemRenderer.markerRenderer()) {
+ listItemRenderer.markerRenderer()->destroy();
+ ASSERT(!listItemRenderer.markerRenderer());
+ }
+ return;
+ }
+
+ auto newStyle = listItemRenderer.computeMarkerStyle();
+ auto* markerRenderer = listItemRenderer.markerRenderer();
+ if (markerRenderer)
+ markerRenderer->setStyle(WTFMove(newStyle));
+ else {
+ markerRenderer = WebCore::createRenderer<RenderListMarker>(listItemRenderer, WTFMove(newStyle)).leakPtr();
+ markerRenderer->initializeStyle();
+ listItemRenderer.setMarkerRenderer(markerRenderer);
+ }
+
+ RenderElement* currentParent = markerRenderer->parent();
+ RenderBlock* newParent = getParentOfFirstLineBox(listItemRenderer, *markerRenderer);
+ if (!newParent) {
+ // If the marker is currently contained inside an anonymous box,
+ // then we are the only item in that anonymous box (since no line box
+ // parent was found). It's ok to just leave the marker where it is
+ // in this case.
+ if (currentParent && currentParent->isAnonymousBlock())
+ return;
+ if (auto* multiColumnFlowThread = listItemRenderer.multiColumnFlowThread())
+ newParent = multiColumnFlowThread;
+ else
+ newParent = &listItemRenderer;
+ }
+
+ if (newParent != currentParent) {
+ markerRenderer->removeFromParent();
+ newParent->addChild(markerRenderer, firstNonMarkerChild(*newParent));
+ // If current parent is an anonymous block that has lost all its children, destroy it.
+ if (currentParent && currentParent->isAnonymousBlock() && !currentParent->firstChild() && !downcast<RenderBlock>(*currentParent).continuation())
+ currentParent->destroy();
+ }
+}
+
+}
Added: trunk/Source/WebCore/style/RenderTreeUpdaterListItem.h (0 => 220916)
--- trunk/Source/WebCore/style/RenderTreeUpdaterListItem.h (rev 0)
+++ trunk/Source/WebCore/style/RenderTreeUpdaterListItem.h 2017-08-18 14:52:22 UTC (rev 220916)
@@ -0,0 +1,38 @@
+/*
+ * 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. 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
+
+#include "RenderListItem.h"
+#include "RenderTreeUpdater.h"
+
+namespace WebCore {
+
+class RenderTreeUpdater::ListItem {
+public:
+ static void updateMarker(RenderListItem&);
+};
+
+}