Title: [201174] trunk/Source/WebCore
- Revision
- 201174
- Author
- [email protected]
- Date
- 2016-05-19 12:09:41 -0700 (Thu, 19 May 2016)
Log Message
Update RenderBlockFlow::adjustComputedFontSizes() to use RenderObjectTraversal
https://bugs.webkit.org/show_bug.cgi?id=157784
Reviewed by Zalan Bujtas.
Update RenderBlockFlow::adjustComputedFontSizes() to use RenderObjectTraversal
instead of having its own Renderer tree traversal API, specifically for iOS
text autosizing.
* rendering/RenderBlockFlow.cpp:
(WebCore::isVisibleRenderText):
(WebCore::resizeTextPermitted):
(WebCore::isNonBlocksOrNonFixedHeightListItems):
(WebCore::RenderBlockFlow::adjustComputedFontSizes):
* rendering/RenderIterator.h:
(WebCore::RenderObjectTraversal::nextSkippingChildren):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::traverseNext): Deleted.
(WebCore::RenderObject::enclosingBox): Deleted.
(WebCore::RenderObject::enclosingBoxModelObject): Deleted.
(WebCore::RenderObject::fixedPositionedWithNamedFlowContainingBlock): Deleted.
(WebCore::hasFixedPosInNamedFlowContainingBlock): Deleted.
(WebCore::RenderObject::firstLineBlock): Deleted.
(WebCore::objectIsRelayoutBoundary): Deleted.
* rendering/RenderObject.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (201173 => 201174)
--- trunk/Source/WebCore/ChangeLog 2016-05-19 18:50:32 UTC (rev 201173)
+++ trunk/Source/WebCore/ChangeLog 2016-05-19 19:09:41 UTC (rev 201174)
@@ -1,3 +1,31 @@
+2016-05-19 Chris Dumez <[email protected]>
+
+ Update RenderBlockFlow::adjustComputedFontSizes() to use RenderObjectTraversal
+ https://bugs.webkit.org/show_bug.cgi?id=157784
+
+ Reviewed by Zalan Bujtas.
+
+ Update RenderBlockFlow::adjustComputedFontSizes() to use RenderObjectTraversal
+ instead of having its own Renderer tree traversal API, specifically for iOS
+ text autosizing.
+
+ * rendering/RenderBlockFlow.cpp:
+ (WebCore::isVisibleRenderText):
+ (WebCore::resizeTextPermitted):
+ (WebCore::isNonBlocksOrNonFixedHeightListItems):
+ (WebCore::RenderBlockFlow::adjustComputedFontSizes):
+ * rendering/RenderIterator.h:
+ (WebCore::RenderObjectTraversal::nextSkippingChildren):
+ * rendering/RenderObject.cpp:
+ (WebCore::RenderObject::traverseNext): Deleted.
+ (WebCore::RenderObject::enclosingBox): Deleted.
+ (WebCore::RenderObject::enclosingBoxModelObject): Deleted.
+ (WebCore::RenderObject::fixedPositionedWithNamedFlowContainingBlock): Deleted.
+ (WebCore::hasFixedPosInNamedFlowContainingBlock): Deleted.
+ (WebCore::RenderObject::firstLineBlock): Deleted.
+ (WebCore::objectIsRelayoutBoundary): Deleted.
+ * rendering/RenderObject.h:
+
2016-05-19 Csaba Osztrogonác <[email protected]>
Fix the build with GCC 4.9 in CSSParser.cpp
Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (201173 => 201174)
--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2016-05-19 18:50:32 UTC (rev 201173)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2016-05-19 19:09:41 UTC (rev 201174)
@@ -3706,25 +3706,24 @@
}
#if ENABLE(IOS_TEXT_AUTOSIZING)
-inline static bool isVisibleRenderText(RenderObject* renderer)
+static inline bool isVisibleRenderText(const RenderObject& renderer)
{
- if (!is<RenderText>(*renderer))
+ if (!is<RenderText>(renderer))
return false;
- RenderText& renderText = downcast<RenderText>(*renderer);
+
+ auto& renderText = downcast<RenderText>(renderer);
return !renderText.linesBoundingBox().isEmpty() && !renderText.text()->containsOnlyWhitespace();
}
-inline static bool resizeTextPermitted(RenderObject* render)
+static inline bool resizeTextPermitted(const RenderObject& renderer)
{
// We disallow resizing for text input fields and textarea to address <rdar://problem/5792987> and <rdar://problem/8021123>
- auto renderer = render->parent();
- while (renderer) {
+ for (auto* ancestor = renderer.parent(); ancestor; ancestor = ancestor->parent()) {
// Get the first non-shadow HTMLElement and see if it's an input.
- if (is<HTMLElement>(renderer->element()) && !renderer->element()->isInShadowTree()) {
- const HTMLElement& element = downcast<HTMLElement>(*renderer->element());
+ if (is<HTMLElement>(ancestor->element()) && !ancestor->element()->isInShadowTree()) {
+ auto& element = downcast<HTMLElement>(*ancestor->element());
return !is<HTMLInputElement>(element) && !is<HTMLTextAreaElement>(element);
}
- renderer = renderer->parent();
}
return true;
}
@@ -3742,12 +3741,12 @@
return count;
}
-static bool isNonBlocksOrNonFixedHeightListItems(const RenderObject& render)
+static bool isNonBlocksOrNonFixedHeightListItems(const RenderObject& renderer)
{
- if (!render.isRenderBlock())
+ if (!renderer.isRenderBlock())
return true;
- if (render.isListItem())
- return render.style().height().type() != Fixed;
+ if (renderer.isListItem())
+ return renderer.style().height().type() != Fixed;
return false;
}
@@ -3790,29 +3789,37 @@
float actualWidth = m_widthForTextAutosizing != -1 ? static_cast<float>(m_widthForTextAutosizing) : static_cast<float>(width());
float scale = visibleWidth / actualWidth;
float minFontSize = roundf(size / scale);
-
- for (RenderObject* descendent = traverseNext(this, isNonBlocksOrNonFixedHeightListItems); descendent; descendent = descendent->traverseNext(this, isNonBlocksOrNonFixedHeightListItems)) {
- if (isVisibleRenderText(descendent) && resizeTextPermitted(descendent)) {
- auto& text = downcast<RenderText>(*descendent);
- auto& oldStyle = text.style();
- auto fontDescription = oldStyle.fontDescription();
- float specifiedSize = fontDescription.specifiedSize();
- float scaledSize = roundf(specifiedSize * scale);
- if (scaledSize > 0 && scaledSize < minFontSize) {
- // Record the width of the block and the line count the first time we resize text and use it from then on for text resizing.
- // This makes text resizing consistent even if the block's width or line count changes (which can be caused by text resizing itself 5159915).
- if (m_lineCountForTextAutosizing == NOT_SET)
- m_lineCountForTextAutosizing = lineCount;
- if (m_widthForTextAutosizing == -1)
- m_widthForTextAutosizing = actualWidth;
-
- float candidateNewSize = 0;
- float lineTextMultiplier = lineCount == ONE_LINE ? oneLineTextMultiplier(specifiedSize) : textMultiplier(specifiedSize);
- candidateNewSize = roundf(std::min(minFontSize, specifiedSize * lineTextMultiplier));
- if (candidateNewSize > specifiedSize && candidateNewSize != fontDescription.computedSize() && text.textNode() && oldStyle.textSizeAdjust().isAuto())
- document().addAutoSizingNode(*text.textNode(), candidateNewSize);
- }
+
+ for (auto* descendant = RenderObjectTraversal::firstChild(*this); descendant; ) {
+ if (!isNonBlocksOrNonFixedHeightListItems(*descendant)) {
+ descendant = RenderObjectTraversal::nextSkippingChildren(*descendant, this);
+ continue;
}
+ if (!isVisibleRenderText(*descendant) || !resizeTextPermitted(*descendant)) {
+ descendant = RenderObjectTraversal::next(*descendant, this);
+ continue;
+ }
+
+ auto& text = downcast<RenderText>(*descendant);
+ auto& oldStyle = text.style();
+ auto& fontDescription = oldStyle.fontDescription();
+ float specifiedSize = fontDescription.specifiedSize();
+ float scaledSize = roundf(specifiedSize * scale);
+ if (scaledSize > 0 && scaledSize < minFontSize) {
+ // Record the width of the block and the line count the first time we resize text and use it from then on for text resizing.
+ // This makes text resizing consistent even if the block's width or line count changes (which can be caused by text resizing itself 5159915).
+ if (m_lineCountForTextAutosizing == NOT_SET)
+ m_lineCountForTextAutosizing = lineCount;
+ if (m_widthForTextAutosizing == -1)
+ m_widthForTextAutosizing = actualWidth;
+
+ 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().addAutoSizingNode(*text.textNode(), candidateNewSize);
+ }
+
+ descendant = RenderObjectTraversal::nextSkippingChildren(text, this);
}
}
#endif // ENABLE(IOS_TEXT_AUTOSIZING)
Modified: trunk/Source/WebCore/rendering/RenderIterator.h (201173 => 201174)
--- trunk/Source/WebCore/rendering/RenderIterator.h 2016-05-19 18:50:32 UTC (rev 201173)
+++ trunk/Source/WebCore/rendering/RenderIterator.h 2016-05-19 19:09:41 UTC (rev 201174)
@@ -124,8 +124,19 @@
return nextAncestorSibling(current, stayWithin);
}
+inline RenderObject* nextSkippingChildren(RenderObject& current, const RenderObject* stayWithin)
+{
+ if (¤t == stayWithin)
+ return nullptr;
+
+ if (auto* sibling = current.nextSibling())
+ return sibling;
+
+ return nextAncestorSibling(current, stayWithin);
}
+}
+
namespace RenderTraversal {
template <typename T, typename U>
Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (201173 => 201174)
--- trunk/Source/WebCore/rendering/RenderObject.cpp 2016-05-19 18:50:32 UTC (rev 201173)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp 2016-05-19 19:09:41 UTC (rev 201174)
@@ -298,29 +298,6 @@
}
#if ENABLE(IOS_TEXT_AUTOSIZING)
-// Inspired by Node::traverseNextNode.
-RenderObject* RenderObject::traverseNext(const RenderObject* stayWithin) const
-{
- RenderObject* child = firstChildSlow();
- if (child) {
- ASSERT(!stayWithin || child->isDescendantOf(stayWithin));
- return child;
- }
- if (this == stayWithin)
- return nullptr;
- if (nextSibling()) {
- ASSERT(!stayWithin || nextSibling()->isDescendantOf(stayWithin));
- return nextSibling();
- }
- const RenderObject* n = this;
- while (n && !n->nextSibling() && (!stayWithin || n->parent() != stayWithin))
- n = n->parent();
- if (n) {
- ASSERT(!stayWithin || !n->nextSibling() || n->nextSibling()->isDescendantOf(stayWithin));
- return n->nextSibling();
- }
- return nullptr;
-}
// Non-recursive version of the DFS search.
RenderObject* RenderObject::traverseNext(const RenderObject* stayWithin, HeightTypeTraverseNextInclusionFunction inclusionFunction, int& currentDepth, int& newFixedDepth) const
@@ -370,44 +347,6 @@
return nullptr;
}
-RenderObject* RenderObject::traverseNext(const RenderObject* stayWithin, TraverseNextInclusionFunction inclusionFunction) const
-{
- for (RenderObject* child = firstChildSlow(); child; child = child->nextSibling()) {
- if (inclusionFunction(*child)) {
- ASSERT(!stayWithin || child->isDescendantOf(stayWithin));
- return child;
- }
- }
-
- if (this == stayWithin)
- return nullptr;
-
- for (RenderObject* sibling = nextSibling(); sibling; sibling = sibling->nextSibling()) {
- if (inclusionFunction(*sibling)) {
- ASSERT(!stayWithin || sibling->isDescendantOf(stayWithin));
- return sibling;
- }
- }
-
- const RenderObject* n = this;
- while (n) {
- while (n && !n->nextSibling() && (!stayWithin || n->parent() != stayWithin))
- n = n->parent();
- if (n) {
- for (RenderObject* sibling = n->nextSibling(); sibling; sibling = sibling->nextSibling()) {
- if (inclusionFunction(*sibling)) {
- ASSERT(!stayWithin || !n->nextSibling() || n->nextSibling()->isDescendantOf(stayWithin));
- return sibling;
- }
- }
- if ((!stayWithin || n->parent() != stayWithin))
- n = n->parent();
- else
- return nullptr;
- }
- }
- return nullptr;
-}
#endif // ENABLE(IOS_TEXT_AUTOSIZING)
RenderLayer* RenderObject::enclosingLayer() const
Modified: trunk/Source/WebCore/rendering/RenderObject.h (201173 => 201174)
--- trunk/Source/WebCore/rendering/RenderObject.h 2016-05-19 18:50:32 UTC (rev 201173)
+++ trunk/Source/WebCore/rendering/RenderObject.h 2016-05-19 19:09:41 UTC (rev 201174)
@@ -189,11 +189,7 @@
OverflowHeight
};
- RenderObject* traverseNext(const RenderObject* stayWithin) const;
- typedef bool (*TraverseNextInclusionFunction)(const RenderObject&);
typedef BlockContentHeightType (*HeightTypeTraverseNextInclusionFunction)(const RenderObject&);
-
- RenderObject* traverseNext(const RenderObject* stayWithin, TraverseNextInclusionFunction) const;
RenderObject* traverseNext(const RenderObject* stayWithin, HeightTypeTraverseNextInclusionFunction, int& currentDepth, int& newFixedDepth) const;
#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes