- Revision
- 220594
- Author
- an...@apple.com
- Date
- 2017-08-11 09:22:44 -0700 (Fri, 11 Aug 2017)
Log Message
Remove RenderQuote collection from RenderView
https://bugs.webkit.org/show_bug.cgi?id=175479
Reviewed by Andreas Kling.
We can do it well enough without maintaining this pointer structure.
Global updating doesn't work well with future direction for first-letter and similar anyway.
We need to update quote immediately when updating its style.
* rendering/RenderQuote.cpp:
(WebCore::RenderQuote::insertedIntoTree):
(WebCore::RenderQuote::willBeRemovedFromTree):
Just tell the view that there are renderers to update.
(WebCore::RenderQuote::styleDidChange):
(WebCore::RenderQuote::isOpen const):
(WebCore::RenderQuote::updateRenderer):
(WebCore::RenderQuote::updateRenderers): Deleted.
Update single renderer only. RenderTreeUpdater provides the previous renderer to compute the depth.
* rendering/RenderQuote.h:
* rendering/RenderView.cpp:
(WebCore::RenderView::registerQuote): Deleted.
(WebCore::RenderView::unregisterQuote): Deleted.
(WebCore::RenderView::updateSpecialRenderers): Deleted.
Remove the quote list.
* rendering/RenderView.h:
* style/RenderTreeUpdater.cpp:
(WebCore::RenderTreeUpdater::commit):
Ensure that all quotes are updated.
(WebCore::RenderTreeUpdater::updateBeforeOrAfterPseudoElement):
(WebCore::RenderTreeUpdater::updateQuotesUpTo):
Traverse render tree to find quotes to update starting from the previous updated quote.
* style/RenderTreeUpdater.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (220593 => 220594)
--- trunk/Source/WebCore/ChangeLog 2017-08-11 15:48:36 UTC (rev 220593)
+++ trunk/Source/WebCore/ChangeLog 2017-08-11 16:22:44 UTC (rev 220594)
@@ -1,3 +1,49 @@
+2017-08-11 Antti Koivisto <an...@apple.com>
+
+ Remove RenderQuote collection from RenderView
+ https://bugs.webkit.org/show_bug.cgi?id=175479
+
+ Reviewed by Andreas Kling.
+
+ We can do it well enough without maintaining this pointer structure.
+
+ Global updating doesn't work well with future direction for first-letter and similar anyway.
+ We need to update quote immediately when updating its style.
+
+ * rendering/RenderQuote.cpp:
+ (WebCore::RenderQuote::insertedIntoTree):
+ (WebCore::RenderQuote::willBeRemovedFromTree):
+
+ Just tell the view that there are renderers to update.
+
+ (WebCore::RenderQuote::styleDidChange):
+ (WebCore::RenderQuote::isOpen const):
+ (WebCore::RenderQuote::updateRenderer):
+ (WebCore::RenderQuote::updateRenderers): Deleted.
+
+ Update single renderer only. RenderTreeUpdater provides the previous renderer to compute the depth.
+
+ * rendering/RenderQuote.h:
+ * rendering/RenderView.cpp:
+ (WebCore::RenderView::registerQuote): Deleted.
+ (WebCore::RenderView::unregisterQuote): Deleted.
+ (WebCore::RenderView::updateSpecialRenderers): Deleted.
+
+ Remove the quote list.
+
+ * rendering/RenderView.h:
+ * style/RenderTreeUpdater.cpp:
+ (WebCore::RenderTreeUpdater::commit):
+
+ Ensure that all quotes are updated.
+
+ (WebCore::RenderTreeUpdater::updateBeforeOrAfterPseudoElement):
+ (WebCore::RenderTreeUpdater::updateQuotesUpTo):
+
+ Traverse render tree to find quotes to update starting from the previous updated quote.
+
+ * style/RenderTreeUpdater.h:
+
2017-08-11 Adrian Perez de Castro <ape...@igalia.com>
[CMake] Many warning about missing “override” keywords in ANGLE with Clang
Modified: trunk/Source/WebCore/rendering/RenderQuote.cpp (220593 => 220594)
--- trunk/Source/WebCore/rendering/RenderQuote.cpp 2017-08-11 15:48:36 UTC (rev 220593)
+++ trunk/Source/WebCore/rendering/RenderQuote.cpp 2017-08-11 16:22:44 UTC (rev 220594)
@@ -47,12 +47,12 @@
void RenderQuote::insertedIntoTree()
{
RenderInline::insertedIntoTree();
- view().registerQuote(*this);
+ view().setHasQuotesNeedingUpdate(true);
}
void RenderQuote::willBeRemovedFromTree()
{
- view().unregisterQuote(*this);
+ view().setHasQuotesNeedingUpdate(true);
RenderInline::willBeRemovedFromTree();
}
@@ -61,7 +61,7 @@
RenderInline::styleDidChange(diff, oldStyle);
if (diff >= StyleDifferenceLayout) {
m_needsTextUpdate = true;
- view().setHasSpecialRendererNeedingUpdate();
+ view().setHasQuotesNeedingUpdate(true);
}
}
@@ -388,25 +388,44 @@
return emptyString();
}
-void RenderQuote::updateRenderers(const RenderView& view)
+bool RenderQuote::isOpen() const
{
- int depth = -1;
- for (auto* quote : view.quotes()) {
- bool isOpen = quote->m_type == OPEN_QUOTE || quote->m_type == NO_OPEN_QUOTE;
- if (!isOpen)
- --depth;
- else if (depth < 0)
- depth = 0;
+ switch (m_type) {
+ case OPEN_QUOTE:
+ case NO_OPEN_QUOTE:
+ return true;
+ case CLOSE_QUOTE:
+ case NO_CLOSE_QUOTE:
+ return false;
+ }
+ ASSERT_NOT_REACHED();
+ return false;
+}
- if (quote->m_depth != depth || quote->m_needsTextUpdate) {
- quote->m_depth = depth;
- quote->m_needsTextUpdate = false;
- quote->updateTextRenderer();
- }
+void RenderQuote::updateRenderer(RenderQuote* previousQuote)
+{
+ ASSERT_WITH_SECURITY_IMPLICATION(document().inRenderTreeUpdate());
+ ASSERT_WITH_SECURITY_IMPLICATION(!view().renderTreeIsBeingMutatedInternally());
+ ASSERT_WITH_SECURITY_IMPLICATION(!view().layoutState());
- if (isOpen)
+ int depth = -1;
+ if (previousQuote) {
+ depth = previousQuote->m_depth;
+ if (previousQuote->isOpen())
++depth;
}
+
+ if (!isOpen())
+ --depth;
+ else if (depth < 0)
+ depth = 0;
+
+ if (m_depth == depth && !m_needsTextUpdate)
+ return;
+
+ m_depth = depth;
+ m_needsTextUpdate = false;
+ updateTextRenderer();
}
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/RenderQuote.h (220593 => 220594)
--- trunk/Source/WebCore/rendering/RenderQuote.h 2017-08-11 15:48:36 UTC (rev 220593)
+++ trunk/Source/WebCore/rendering/RenderQuote.h 2017-08-11 16:22:44 UTC (rev 220594)
@@ -31,11 +31,12 @@
RenderQuote(Document&, RenderStyle&&, QuoteType);
virtual ~RenderQuote();
- static void updateRenderers(const RenderView&);
+ void updateRenderer(RenderQuote* previousQuote);
private:
const char* renderName() const override { return "RenderQuote"; }
bool isQuote() const override { return true; }
+ bool isOpen() const;
void styleDidChange(StyleDifference, const RenderStyle*) override;
void insertedIntoTree() override;
void willBeRemovedFromTree() override;
Modified: trunk/Source/WebCore/rendering/RenderView.cpp (220593 => 220594)
--- trunk/Source/WebCore/rendering/RenderView.cpp 2017-08-11 15:48:36 UTC (rev 220593)
+++ trunk/Source/WebCore/rendering/RenderView.cpp 2017-08-11 16:22:44 UTC (rev 220594)
@@ -1524,48 +1524,6 @@
return 0;
}
-void RenderView::registerQuote(RenderQuote& quote)
-{
- ASSERT(!m_quotes.contains("e));
-
- setHasSpecialRendererNeedingUpdate();
-
- if (m_quotes.isEmpty()) {
- m_quotes.add("e);
- return;
- }
- auto quoteRenderers = descendantsOfType<RenderQuote>(*this);
- auto it = quoteRenderers.at(quote);
- if (++it == quoteRenderers.end()) {
- m_quotes.add("e);
- return;
- }
- auto& nextQuote = *it;
- ASSERT(m_quotes.contains(&nextQuote));
- m_quotes.insertBefore(&nextQuote, "e);
-}
-
-void RenderView::unregisterQuote(RenderQuote& quote)
-{
- ASSERT(m_quotes.contains("e));
-
- setHasSpecialRendererNeedingUpdate();
-
- m_quotes.remove("e);
-}
-
-void RenderView::updateSpecialRenderers()
-{
- ASSERT_WITH_SECURITY_IMPLICATION(document().inRenderTreeUpdate());
- ASSERT_WITH_SECURITY_IMPLICATION(!renderTreeIsBeingMutatedInternally());
-
- if (!m_hasSpecialRendererNeedingUpdate)
- return;
- m_hasSpecialRendererNeedingUpdate = false;
-
- RenderQuote::updateRenderers(*this);
-}
-
#if ENABLE(CSS_SCROLL_SNAP)
void RenderView::registerBoxWithScrollSnapPositions(const RenderBox& box)
{
Modified: trunk/Source/WebCore/rendering/RenderView.h (220593 => 220594)
--- trunk/Source/WebCore/rendering/RenderView.h 2017-08-11 15:48:36 UTC (rev 220593)
+++ trunk/Source/WebCore/rendering/RenderView.h 2017-08-11 16:22:44 UTC (rev 220594)
@@ -196,13 +196,9 @@
IntSize viewportSizeForCSSViewportUnits() const;
- void registerQuote(RenderQuote&);
- void unregisterQuote(RenderQuote&);
- const ListHashSet<RenderQuote*>& quotes() const { return m_quotes; }
+ bool hasQuotesNeedingUpdate() const { return m_hasQuotesNeedingUpdate; }
+ void setHasQuotesNeedingUpdate(bool b) { m_hasQuotesNeedingUpdate = b; }
- void setHasSpecialRendererNeedingUpdate() { m_hasSpecialRendererNeedingUpdate = true; }
- void updateSpecialRenderers();
-
// FIXME: see class RenderTreeInternalMutation below.
bool renderTreeIsBeingMutatedInternally() const { return !!m_renderTreeInternalMutationCounter; }
@@ -209,7 +205,7 @@
// FIXME: This is a work around because the current implementation of counters
// requires walking the entire tree repeatedly and most pages don't actually use either
// feature so we shouldn't take the performance hit when not needed. Long term we should
- // rewrite the counter and quotes code.
+ // rewrite the counter code.
void addRenderCounter() { m_renderCounterCount++; }
void removeRenderCounter() { ASSERT(m_renderCounterCount > 0); m_renderCounterCount--; }
bool hasRenderCounters() { return m_renderCounterCount; }
@@ -376,8 +372,7 @@
std::unique_ptr<RenderLayerCompositor> m_compositor;
std::unique_ptr<FlowThreadController> m_flowThreadController;
- ListHashSet<RenderQuote*> m_quotes;
- bool m_hasSpecialRendererNeedingUpdate { false };
+ bool m_hasQuotesNeedingUpdate { false };
unsigned m_renderCounterCount { 0 };
unsigned m_renderTreeInternalMutationCounter { 0 };
Modified: trunk/Source/WebCore/style/RenderTreeUpdater.cpp (220593 => 220594)
--- trunk/Source/WebCore/style/RenderTreeUpdater.cpp 2017-08-11 15:48:36 UTC (rev 220593)
+++ trunk/Source/WebCore/style/RenderTreeUpdater.cpp 2017-08-11 16:22:44 UTC (rev 220594)
@@ -37,8 +37,10 @@
#include "InspectorInstrumentation.h"
#include "NodeRenderStyle.h"
#include "PseudoElement.h"
+#include "RenderDescendantIterator.h"
#include "RenderFullScreen.h"
#include "RenderNamedFlowThread.h"
+#include "RenderQuote.h"
#include "StyleResolver.h"
#include "StyleTreeResolver.h"
#include <wtf/SystemTracing.h>
@@ -124,7 +126,11 @@
for (auto* root : findRenderingRoots(*m_styleUpdate))
updateRenderTree(*root);
- m_document.renderView()->updateSpecialRenderers();
+ if (m_document.renderView()->hasQuotesNeedingUpdate()) {
+ updateQuotesUpTo(nullptr);
+ m_previousUpdatedQuote = nullptr;
+ m_document.renderView()->setHasQuotesNeedingUpdate(false);
+ }
m_styleUpdate = nullptr;
}
@@ -542,10 +548,19 @@
updateElementRenderer(*pseudoElement, elementUpdate);
+ auto* pseudoRenderer = pseudoElement->renderer();
+ if (!pseudoRenderer)
+ return;
+
if (elementUpdate.change == Style::Detach)
pseudoElement->didAttachRenderers();
else
pseudoElement->didRecalcStyle(elementUpdate.change);
+
+ if (m_document.renderView()->hasQuotesNeedingUpdate()) {
+ for (auto& child : descendantsOfType<RenderQuote>(*pseudoRenderer))
+ updateQuotesUpTo(&child);
+ }
}
void RenderTreeUpdater::tearDownRenderers(Element& root, TeardownType teardownType)
@@ -603,6 +618,22 @@
text.setRenderer(nullptr);
}
+void RenderTreeUpdater::updateQuotesUpTo(RenderQuote* lastQuote)
+{
+ auto quoteRenderers = descendantsOfType<RenderQuote>(*m_document.renderView());
+ auto it = m_previousUpdatedQuote ? ++quoteRenderers.at(*m_previousUpdatedQuote) : quoteRenderers.begin();
+ auto end = quoteRenderers.end();
+ for (; it != end; ++it) {
+ auto& quote = *it;
+ // Quote character depends on quote depth so we chain the updates.
+ quote.updateRenderer(m_previousUpdatedQuote);
+ m_previousUpdatedQuote = "e;
+ if ("e == lastQuote)
+ return;
+ }
+ ASSERT(!lastQuote);
+}
+
#if PLATFORM(IOS)
static EVisibility elementImplicitVisibility(const Element& element)
{
Modified: trunk/Source/WebCore/style/RenderTreeUpdater.h (220593 => 220594)
--- trunk/Source/WebCore/style/RenderTreeUpdater.h 2017-08-11 15:48:36 UTC (rev 220593)
+++ trunk/Source/WebCore/style/RenderTreeUpdater.h 2017-08-11 16:22:44 UTC (rev 220594)
@@ -37,6 +37,7 @@
class Document;
class Element;
class Node;
+class RenderQuote;
class RenderStyle;
class Text;
@@ -73,6 +74,8 @@
void popParent();
void popParentsToDepth(unsigned depth);
+ void updateQuotesUpTo(RenderQuote*);
+
Document& m_document;
std::unique_ptr<const Style::Update> m_styleUpdate;
@@ -79,6 +82,7 @@
Vector<Parent> m_parentStack;
HashSet<Text*> m_invalidatedWhitespaceOnlyTextSiblings;
+ RenderQuote* m_previousUpdatedQuote { nullptr };
};
} // namespace WebCore