Diff
Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/ChangeLog (220696 => 220697)
--- releases/WebKitGTK/webkit-2.18/Source/WebCore/ChangeLog 2017-08-14 15:54:12 UTC (rev 220696)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/ChangeLog 2017-08-14 16:06:03 UTC (rev 220697)
@@ -1,5 +1,38 @@
2017-08-14 Antti Koivisto <[email protected]>
+ Factor text autosizing into a class
+ https://bugs.webkit.org/show_bug.cgi?id=175530
+
+ Reviewed by Andreas Kling.
+
+ Move the remaining parts out of Document.
+
+ * css/StyleBuilderCustom.h:
+ (WebCore::computeLineHeightMultiplierDueToFontSize):
+ * dom/Document.cpp:
+ (WebCore::Document::destroyRenderTree):
+ (WebCore::Document::textAutoSizing):
+ (WebCore::TextAutoSizingTraits::constructDeletedValue): Deleted.
+ (WebCore::TextAutoSizingTraits::isDeletedValue): Deleted.
+ (WebCore::Document::addAutoSizedNode): Deleted.
+ (WebCore::Document::updateAutoSizedNodes): Deleted.
+ (WebCore::Document::clearAutoSizedNodes): Deleted.
+ * dom/Document.h:
+ * rendering/RenderBlockFlow.cpp:
+ (WebCore::RenderBlockFlow::adjustComputedFontSizes):
+ * rendering/RenderElement.cpp:
+ (WebCore::RenderElement::adjustComputedFontSizesOnBlocks):
+ (WebCore::RenderElement::resetTextAutosizing):
+ * rendering/TextAutoSizing.cpp:
+ (WebCore::TextAutoSizingTraits::constructDeletedValue):
+ (WebCore::TextAutoSizingTraits::isDeletedValue):
+ (WebCore::TextAutoSizing::addTextNode):
+ (WebCore::TextAutoSizing::updateRenderTree):
+ (WebCore::TextAutoSizing::reset):
+ * rendering/TextAutoSizing.h:
+
+2017-08-14 Antti Koivisto <[email protected]>
+
[Render Tree Mutation] First letter should not mutate the render tree while in layout.
https://bugs.webkit.org/show_bug.cgi?id=163848
Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/css/StyleBuilderCustom.h (220696 => 220697)
--- releases/WebKitGTK/webkit-2.18/Source/WebCore/css/StyleBuilderCustom.h 2017-08-14 15:54:12 UTC (rev 220696)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/css/StyleBuilderCustom.h 2017-08-14 16:06:03 UTC (rev 220697)
@@ -680,7 +680,7 @@
// that the minimum font size is the only thing affecting the computed font size.
// This calculation matches the line-height computed size calculation in
- // TextAutoSizingValue::adjustTextNodeSizes().
+ // TextAutoSizing::Value::adjustTextNodeSizes().
auto scaleChange = minimumFontSize / specifiedFontSize;
return scaleChange;
}
Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/dom/Document.cpp (220696 => 220697)
--- releases/WebKitGTK/webkit-2.18/Source/WebCore/dom/Document.cpp 2017-08-14 15:54:12 UTC (rev 220696)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/dom/Document.cpp 2017-08-14 16:06:03 UTC (rev 220697)
@@ -427,20 +427,6 @@
frame->document()->domWindow()->printErrorMessage(message);
}
-#if ENABLE(TEXT_AUTOSIZING)
-
-void TextAutoSizingTraits::constructDeletedValue(TextAutoSizingKey& slot)
-{
- new (NotNull, &slot) TextAutoSizingKey(TextAutoSizingKey::Deleted);
-}
-
-bool TextAutoSizingTraits::isDeletedValue(const TextAutoSizingKey& value)
-{
- return value.isDeleted();
-}
-
-#endif
-
uint64_t Document::s_globalTreeVersion = 0;
HashSet<Document*>& Document::allDocuments()
@@ -2264,8 +2250,7 @@
Node::setRenderer(nullptr);
#if ENABLE(TEXT_AUTOSIZING)
- // Do this before the arena is cleared, which is needed to deref the RenderStyle on TextAutoSizingKey.
- m_textAutoSizedNodes.clear();
+ m_textAutoSizing = nullptr;
#endif
if (view())
@@ -5547,28 +5532,12 @@
}
#if ENABLE(TEXT_AUTOSIZING)
-
-void Document::addAutoSizedNode(Text& node, float candidateSize)
+TextAutoSizing& Document::textAutoSizing()
{
- LOG(TextAutosizing, " addAutoSizedNode %p candidateSize=%f", &node, candidateSize);
- auto addResult = m_textAutoSizedNodes.add<TextAutoSizingHashTranslator>(node.renderer()->style(), nullptr);
- if (addResult.isNewEntry)
- addResult.iterator->value = std::make_unique<TextAutoSizingValue>();
- addResult.iterator->value->addTextNode(node, candidateSize);
+ if (!m_textAutoSizing)
+ m_textAutoSizing = std::make_unique<TextAutoSizing>();
+ return *m_textAutoSizing;
}
-
-void Document::updateAutoSizedNodes()
-{
- m_textAutoSizedNodes.removeIf([](auto& keyAndValue) {
- return keyAndValue.value->adjustTextNodeSizes() == TextAutoSizingValue::StillHasNodes::No;
- });
-}
-
-void Document::clearAutoSizedNodes()
-{
- m_textAutoSizedNodes.clear();
-}
-
#endif // ENABLE(TEXT_AUTOSIZING)
void Document::initDNSPrefetch()
Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/dom/Document.h (220696 => 220697)
--- releases/WebKitGTK/webkit-2.18/Source/WebCore/dom/Document.h 2017-08-14 15:54:12 UTC (rev 220696)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/dom/Document.h 2017-08-14 16:06:03 UTC (rev 220697)
@@ -206,15 +206,7 @@
#endif
#if ENABLE(TEXT_AUTOSIZING)
-struct TextAutoSizingHash;
-class TextAutoSizingKey;
-class TextAutoSizingValue;
-
-struct TextAutoSizingTraits : WTF::GenericHashTraits<TextAutoSizingKey> {
- static const bool emptyValueIsZero = true;
- static void constructDeletedValue(TextAutoSizingKey& slot);
- static bool isDeletedValue(const TextAutoSizingKey& value);
-};
+class TextAutoSizing;
#endif
#if ENABLE(MEDIA_SESSION)
@@ -1360,6 +1352,10 @@
// Per https://html.spec.whatwg.org/multipage/obsolete.html#dom-document-releaseevents, this method does nothing.
void releaseEvents() { }
+#if ENABLE(TEXT_AUTOSIZING)
+ TextAutoSizing& textAutoSizing();
+#endif
+
protected:
enum ConstructionFlags { Synthesized = 1, NonRenderedPlaceholder = 1 << 1 };
Document(Frame*, const URL&, unsigned = DefaultDocumentClass, unsigned constructionFlags = 0);
@@ -1663,14 +1659,7 @@
Vector<Task> m_pendingTasks;
#if ENABLE(TEXT_AUTOSIZING)
-public:
- void addAutoSizedNode(Text&, float size);
- void updateAutoSizedNodes();
- void clearAutoSizedNodes();
-
-private:
- using TextAutoSizingMap = HashMap<TextAutoSizingKey, std::unique_ptr<TextAutoSizingValue>, TextAutoSizingHash, TextAutoSizingTraits>;
- TextAutoSizingMap m_textAutoSizedNodes;
+ std::unique_ptr<TextAutoSizing> m_textAutoSizing;
#endif
Timer m_visualUpdatesSuppressionTimer;
Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/RenderBlockFlow.cpp (220696 => 220697)
--- releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/RenderBlockFlow.cpp 2017-08-14 15:54:12 UTC (rev 220696)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/RenderBlockFlow.cpp 2017-08-14 16:06:03 UTC (rev 220697)
@@ -53,6 +53,7 @@
#include "Settings.h"
#include "SimpleLineLayoutFunctions.h"
#include "SimpleLineLayoutPagination.h"
+#include "TextAutoSizing.h"
#include "VerticalPositionCache.h"
#include "VisiblePosition.h"
@@ -3906,7 +3907,7 @@
float lineTextMultiplier = lineCount == ONE_LINE ? oneLineTextMultiplier(specifiedSize) : textMultiplier(specifiedSize);
float candidateNewSize = roundf(std::min(minFontSize, specifiedSize * lineTextMultiplier));
if (candidateNewSize > specifiedSize && candidateNewSize != fontDescription.computedSize() && text.textNode() && oldStyle.textSizeAdjust().isAuto())
- document().addAutoSizedNode(*text.textNode(), candidateNewSize);
+ document().textAutoSizing().addTextNode(*text.textNode(), candidateNewSize);
}
descendant = RenderObjectTraversal::nextSkippingChildren(text, this);
Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/RenderElement.cpp (220696 => 220697)
--- releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/RenderElement.cpp 2017-08-14 15:54:12 UTC (rev 220696)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/RenderElement.cpp 2017-08-14 16:06:03 UTC (rev 220697)
@@ -74,6 +74,7 @@
#include "ShadowRoot.h"
#include "StylePendingResources.h"
#include "StyleResolver.h"
+#include "TextAutoSizing.h"
#include <wtf/MathExtras.h>
#include <wtf/StackStats.h>
@@ -2314,7 +2315,7 @@
}
// Remove style from auto-sizing table that are no longer valid.
- document->updateAutoSizedNodes();
+ document->textAutoSizing().updateRenderTree();
}
void RenderElement::resetTextAutosizing()
@@ -2325,7 +2326,7 @@
LOG(TextAutosizing, "RenderElement::resetTextAutosizing()");
- document->clearAutoSizedNodes();
+ document->textAutoSizing().reset();
Vector<int> depthStack;
int currentDepth = 0;
Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/TextAutoSizing.cpp (220696 => 220697)
--- releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/TextAutoSizing.cpp 2017-08-14 15:54:12 UTC (rev 220696)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/TextAutoSizing.cpp 2017-08-14 16:06:03 UTC (rev 220697)
@@ -215,6 +215,27 @@
}
}
+void TextAutoSizing::addTextNode(Text& node, float candidateSize)
+{
+ LOG(TextAutosizing, " addAutoSizedNode %p candidateSize=%f", &node, candidateSize);
+ auto addResult = m_textNodes.add<TextAutoSizingHashTranslator>(node.renderer()->style(), nullptr);
+ if (addResult.isNewEntry)
+ addResult.iterator->value = std::make_unique<TextAutoSizingValue>();
+ addResult.iterator->value->addTextNode(node, candidateSize);
+}
+
+void TextAutoSizing::updateRenderTree()
+{
+ m_textNodes.removeIf([](auto& keyAndValue) {
+ return keyAndValue.value->adjustTextNodeSizes() == TextAutoSizingValue::StillHasNodes::No;
+ });
+}
+
+void TextAutoSizing::reset()
+{
+ m_textNodes.clear();
+}
+
} // namespace WebCore
#endif // ENABLE(TEXT_AUTOSIZING)
Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/TextAutoSizing.h (220696 => 220697)
--- releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/TextAutoSizing.h 2017-08-14 15:54:12 UTC (rev 220696)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/TextAutoSizing.h 2017-08-14 16:06:03 UTC (rev 220697)
@@ -28,6 +28,7 @@
#if ENABLE(TEXT_AUTOSIZING)
#include "RenderStyle.h"
+#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
@@ -107,6 +108,25 @@
HashSet<RefPtr<Text>> m_autoSizedNodes;
};
+struct TextAutoSizingTraits : WTF::GenericHashTraits<TextAutoSizingKey> {
+ static const bool emptyValueIsZero = true;
+ static void constructDeletedValue(TextAutoSizingKey& slot) { new (NotNull, &slot) TextAutoSizingKey(TextAutoSizingKey::Deleted); }
+ static bool isDeletedValue(const TextAutoSizingKey& value) { return value.isDeleted(); }
+};
+
+class TextAutoSizing {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ TextAutoSizing() = default;
+
+ void addTextNode(Text&, float size);
+ void updateRenderTree();
+ void reset();
+
+private:
+ HashMap<TextAutoSizingKey, std::unique_ptr<TextAutoSizingValue>, TextAutoSizingHash, TextAutoSizingTraits> m_textNodes;
+};
+
} // namespace WebCore
#endif // ENABLE(TEXT_AUTOSIZING)