<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[161790] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/161790">161790</a></dd>
<dt>Author</dt> <dd>aestes@apple.com</dd>
<dt>Date</dt> <dd>2014-01-11 18:51:25 -0800 (Sat, 11 Jan 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>[iOS] Move text autosizing code from RenderBlock to RenderBlockFlow
https://bugs.webkit.org/show_bug.cgi?id=126829
Reviewed by Sam Weinig.
Some newly-upstreamed iOS text autosizing code needs to move to
RenderBlockFlow in order to build.
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::RenderBlock):
* rendering/RenderBlock.h:
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::RenderBlockFlow):
(WebCore::isVisibleRenderText):
(WebCore::resizeTextPermitted):
(WebCore::RenderBlockFlow::immediateLineCount):
(WebCore::isNonBlocksOrNonFixedHeightListItems):
(WebCore::oneLineTextMultiplier):
(WebCore::textMultiplier):
(WebCore::RenderBlockFlow::adjustComputedFontSizes):
* rendering/RenderBlockFlow.h:
(WebCore::RenderBlockFlow::resetComputedFontSize):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::adjustComputedFontSizesOnBlocks):
(WebCore::RenderObject::resetTextAutosizing):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockcpp">trunk/Source/WebCore/rendering/RenderBlock.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockh">trunk/Source/WebCore/rendering/RenderBlock.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockFlowcpp">trunk/Source/WebCore/rendering/RenderBlockFlow.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockFlowh">trunk/Source/WebCore/rendering/RenderBlockFlow.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderObjectcpp">trunk/Source/WebCore/rendering/RenderObject.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (161789 => 161790)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-01-12 02:51:19 UTC (rev 161789)
+++ trunk/Source/WebCore/ChangeLog        2014-01-12 02:51:25 UTC (rev 161790)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2014-01-11 Andy Estes <aestes@apple.com>
+
+ [iOS] Move text autosizing code from RenderBlock to RenderBlockFlow
+ https://bugs.webkit.org/show_bug.cgi?id=126829
+
+ Reviewed by Sam Weinig.
+
+ Some newly-upstreamed iOS text autosizing code needs to move to
+ RenderBlockFlow in order to build.
+
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::RenderBlock):
+ * rendering/RenderBlock.h:
+ * rendering/RenderBlockFlow.cpp:
+ (WebCore::RenderBlockFlow::RenderBlockFlow):
+ (WebCore::isVisibleRenderText):
+ (WebCore::resizeTextPermitted):
+ (WebCore::RenderBlockFlow::immediateLineCount):
+ (WebCore::isNonBlocksOrNonFixedHeightListItems):
+ (WebCore::oneLineTextMultiplier):
+ (WebCore::textMultiplier):
+ (WebCore::RenderBlockFlow::adjustComputedFontSizes):
+ * rendering/RenderBlockFlow.h:
+ (WebCore::RenderBlockFlow::resetComputedFontSize):
+ * rendering/RenderObject.cpp:
+ (WebCore::RenderObject::adjustComputedFontSizesOnBlocks):
+ (WebCore::RenderObject::resetTextAutosizing):
+
</ins><span class="cx"> 2014-01-11 Daniel Bates <dabates@apple.com>
</span><span class="cx">
</span><span class="cx"> [iOS] Fix the build
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (161789 => 161790)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlock.cpp        2014-01-12 02:51:19 UTC (rev 161789)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp        2014-01-12 02:51:25 UTC (rev 161790)
</span><span class="lines">@@ -74,10 +74,6 @@
</span><span class="cx"> #include "ShapeOutsideInfo.h"
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-#if ENABLE(IOS_TEXT_AUTOSIZING)
-#include "HTMLElement.h"
-#endif
-
</del><span class="cx"> using namespace WTF;
</span><span class="cx"> using namespace Unicode;
</span><span class="cx">
</span><span class="lines">@@ -181,10 +177,6 @@
</span><span class="cx"> , m_hasMarkupTruncation(false)
</span><span class="cx"> , m_hasBorderOrPaddingLogicalWidthChanged(false)
</span><span class="cx"> , m_lineLayoutPath(UndeterminedPath)
</span><del>-#if ENABLE(IOS_TEXT_AUTOSIZING)
- , m_widthForTextAutosizing(-1)
- , m_lineCountForTextAutosizing(NOT_SET)
-#endif
</del><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -197,10 +189,6 @@
</span><span class="cx"> , m_hasMarkupTruncation(false)
</span><span class="cx"> , m_hasBorderOrPaddingLogicalWidthChanged(false)
</span><span class="cx"> , m_lineLayoutPath(UndeterminedPath)
</span><del>-#if ENABLE(IOS_TEXT_AUTOSIZING)
- , m_widthForTextAutosizing(-1)
- , m_lineCountForTextAutosizing(NOT_SET)
-#endif
</del><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -5557,120 +5545,4 @@
</span><span class="cx">
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-#if ENABLE(IOS_TEXT_AUTOSIZING)
-inline static bool isVisibleRenderText(RenderObject* renderer)
-{
- if (!renderer->isText())
- return false;
- RenderText* renderText = toRenderText(renderer);
- return !renderText->linesBoundingBox().isEmpty() && !renderText->text()->containsOnlyWhitespace();
-}
-
-inline static bool resizeTextPermitted(RenderObject* render)
-{
- // We disallow resizing for text input fields and textarea to address <rdar://problem/5792987> and <rdar://problem/8021123>
- auto renderer = render->parent();
- while (renderer) {
- // Get the first non-shadow HTMLElement and see if it's an input.
- if (renderer->element() && renderer->element()->isHTMLElement() && !renderer->element()->isInShadowTree()) {
- const HTMLElement& element = toHTMLElement(*renderer->element());
- return !isHTMLInputElement(element) && !isHTMLTextAreaElement(element);
- }
- renderer = renderer->parent();
- }
- return true;
-}
-
-int RenderBlock::immediateLineCount()
-{
- // Copied and modified from RenderBlock::lineCount.
- // Only descend into list items.
- int count = 0;
- if (style().visibility() == VISIBLE) {
- if (childrenInline()) {
- for (RootInlineBox* box = firstRootBox(); box; box = box->nextRootBox())
- count++;
- } else {
- for (RenderObject* obj = firstChild(); obj; obj = obj->nextSibling()) {
- if (obj->isListItem())
- count += toRenderBlock(obj)->lineCount();
- }
- }
- }
- return count;
-}
-
-static bool isNonBlocksOrNonFixedHeightListItems(const RenderObject* render)
-{
- if (!render->isRenderBlock())
- return true;
- if (render->isListItem())
- return render->style().height().type() != Fixed;
- return false;
-}
-
-// For now, we auto size single lines of text the same as multiple lines.
-// We've been experimenting with low values for single lines of text.
-static inline float oneLineTextMultiplier(float specifiedSize)
-{
- return std::max((1.0f / log10f(specifiedSize) * 1.7f), 1.0f);
-}
-
-static inline float textMultiplier(float specifiedSize)
-{
- return std::max((1.0f / log10f(specifiedSize) * 1.95f), 1.0f);
-}
-
-void RenderBlock::adjustComputedFontSizes(float size, float visibleWidth)
-{
- // Don't do any work if the block is smaller than the visible area.
- if (visibleWidth >= width())
- return;
-
- unsigned lineCount;
- if (m_lineCountForTextAutosizing == NOT_SET) {
- int count = immediateLineCount();
- if (!count)
- lineCount = NO_LINE;
- else if (count == 1)
- lineCount = ONE_LINE;
- else
- lineCount = MULTI_LINE;
- } else
- lineCount = m_lineCountForTextAutosizing;
-
- ASSERT(lineCount != NOT_SET);
- if (lineCount == NO_LINE)
- return;
-
- 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)) {
- RenderText* text = toRenderText(descendent);
- RenderStyle& oldStyle = text->style();
- FontDescription 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->node() && oldStyle.textSizeAdjust().isAuto())
- document().addAutoSizingNode(text->node(), candidateNewSize);
- }
- }
- }
-}
-#endif // ENABLE(IOS_TEXT_AUTOSIZING)
-
</del><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlock.h (161789 => 161790)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlock.h        2014-01-12 02:51:19 UTC (rev 161789)
+++ trunk/Source/WebCore/rendering/RenderBlock.h        2014-01-12 02:51:25 UTC (rev 161790)
</span><span class="lines">@@ -51,12 +51,6 @@
</span><span class="cx"> enum CaretType { CursorCaret, DragCaret };
</span><span class="cx"> enum ContainingBlockState { NewContainingBlock, SameContainingBlock };
</span><span class="cx">
</span><del>-#if ENABLE(IOS_TEXT_AUTOSIZING)
-enum LineCount {
- NOT_SET = 0, NO_LINE = 1, ONE_LINE = 2, MULTI_LINE = 3
-};
-#endif
-
</del><span class="cx"> enum TextRunFlag {
</span><span class="cx"> DefaultTextRunFlags = 0,
</span><span class="cx"> RespectDirection = 1 << 0,
</span><span class="lines">@@ -354,16 +348,6 @@
</span><span class="cx"> virtual void showLineTreeAndMark(const InlineBox* = nullptr, const char* = nullptr, const InlineBox* = nullptr, const char* = nullptr, const RenderObject* = nullptr) const;
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-#if ENABLE(IOS_TEXT_AUTOSIZING)
- int immediateLineCount();
- void adjustComputedFontSizes(float size, float visibleWidth);
- void resetComputedFontSize()
- {
- m_widthForTextAutosizing = -1;
- m_lineCountForTextAutosizing = NOT_SET;
- }
-#endif
-
</del><span class="cx"> #if ENABLE(CSS_SHAPES)
</span><span class="cx"> ShapeInsideInfo& ensureShapeInsideInfo();
</span><span class="cx"> ShapeInsideInfo* shapeInsideInfo() const;
</span><span class="lines">@@ -630,11 +614,6 @@
</span><span class="cx"> unsigned m_hasBorderOrPaddingLogicalWidthChanged : 1;
</span><span class="cx"> enum LineLayoutPath { UndeterminedPath, SimpleLinesPath, LineBoxesPath, ForceLineBoxesPath };
</span><span class="cx"> unsigned m_lineLayoutPath : 2;
</span><del>-
-#if ENABLE(IOS_TEXT_AUTOSIZING)
- int m_widthForTextAutosizing;
- unsigned m_lineCountForTextAutosizing : 2;
-#endif
</del><span class="cx">
</span><span class="cx"> // RenderRubyBase objects need to be able to split and merge, moving their children around
</span><span class="cx"> // (calling moveChildTo, moveAllChildrenTo, and makeChildrenNonInline).
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockFlowcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (161789 => 161790)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp        2014-01-12 02:51:19 UTC (rev 161789)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp        2014-01-12 02:51:25 UTC (rev 161790)
</span><span class="lines">@@ -44,6 +44,10 @@
</span><span class="cx"> #include "ShapeInsideInfo.h"
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if ENABLE(IOS_TEXT_AUTOSIZING)
+#include "HTMLElement.h"
+#endif
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> bool RenderBlock::s_canPropagateFloatIntoSibling = false;
</span><span class="lines">@@ -91,12 +95,20 @@
</span><span class="cx">
</span><span class="cx"> RenderBlockFlow::RenderBlockFlow(Element& element, PassRef<RenderStyle> style)
</span><span class="cx"> : RenderBlock(element, std::move(style), RenderBlockFlowFlag)
</span><ins>+#if ENABLE(IOS_TEXT_AUTOSIZING)
+ , m_widthForTextAutosizing(-1)
+ , m_lineCountForTextAutosizing(NOT_SET)
+#endif
</ins><span class="cx"> {
</span><span class="cx"> setChildrenInline(true);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> RenderBlockFlow::RenderBlockFlow(Document& document, PassRef<RenderStyle> style)
</span><span class="cx"> : RenderBlock(document, std::move(style), RenderBlockFlowFlag)
</span><ins>+#if ENABLE(IOS_TEXT_AUTOSIZING)
+ , m_widthForTextAutosizing(-1)
+ , m_lineCountForTextAutosizing(NOT_SET)
+#endif
</ins><span class="cx"> {
</span><span class="cx"> setChildrenInline(true);
</span><span class="cx"> }
</span><span class="lines">@@ -3260,5 +3272,121 @@
</span><span class="cx"> m_rareBlockFlowData = std::make_unique<RenderBlockFlow::RenderBlockFlowRareData>(*this);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if ENABLE(IOS_TEXT_AUTOSIZING)
+inline static bool isVisibleRenderText(RenderObject* renderer)
+{
+ if (!renderer->isText())
+ return false;
+ RenderText* renderText = toRenderText(renderer);
+ return !renderText->linesBoundingBox().isEmpty() && !renderText->text()->containsOnlyWhitespace();
</ins><span class="cx"> }
</span><ins>+
+inline static bool resizeTextPermitted(RenderObject* render)
+{
+ // We disallow resizing for text input fields and textarea to address <rdar://problem/5792987> and <rdar://problem/8021123>
+ auto renderer = render->parent();
+ while (renderer) {
+ // Get the first non-shadow HTMLElement and see if it's an input.
+ if (renderer->element() && renderer->element()->isHTMLElement() && !renderer->element()->isInShadowTree()) {
+ const HTMLElement& element = toHTMLElement(*renderer->element());
+ return !isHTMLInputElement(element) && !isHTMLTextAreaElement(element);
+ }
+ renderer = renderer->parent();
+ }
+ return true;
+}
+
+int RenderBlockFlow::immediateLineCount()
+{
+ // Copied and modified from RenderBlock::lineCount.
+ // Only descend into list items.
+ int count = 0;
+ if (style().visibility() == VISIBLE) {
+ if (childrenInline()) {
+ for (RootInlineBox* box = firstRootBox(); box; box = box->nextRootBox())
+ count++;
+ } else {
+ for (RenderObject* obj = firstChild(); obj; obj = obj->nextSibling()) {
+ if (obj->isListItem())
+ count += toRenderBlockFlow(obj)->lineCount();
+ }
+ }
+ }
+ return count;
+}
+
+static bool isNonBlocksOrNonFixedHeightListItems(const RenderObject* render)
+{
+ if (!render->isRenderBlock())
+ return true;
+ if (render->isListItem())
+ return render->style().height().type() != Fixed;
+ return false;
+}
+
+// For now, we auto size single lines of text the same as multiple lines.
+// We've been experimenting with low values for single lines of text.
+static inline float oneLineTextMultiplier(float specifiedSize)
+{
+ return std::max((1.0f / log10f(specifiedSize) * 1.7f), 1.0f);
+}
+
+static inline float textMultiplier(float specifiedSize)
+{
+ return std::max((1.0f / log10f(specifiedSize) * 1.95f), 1.0f);
+}
+
+void RenderBlockFlow::adjustComputedFontSizes(float size, float visibleWidth)
+{
+ // Don't do any work if the block is smaller than the visible area.
+ if (visibleWidth >= width())
+ return;
+
+ unsigned lineCount;
+ if (m_lineCountForTextAutosizing == NOT_SET) {
+ int count = immediateLineCount();
+ if (!count)
+ lineCount = NO_LINE;
+ else if (count == 1)
+ lineCount = ONE_LINE;
+ else
+ lineCount = MULTI_LINE;
+ } else
+ lineCount = m_lineCountForTextAutosizing;
+
+ ASSERT(lineCount != NOT_SET);
+ if (lineCount == NO_LINE)
+ return;
+
+ 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)) {
+ RenderText* text = toRenderText(descendent);
+ RenderStyle& oldStyle = text->style();
+ FontDescription 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);
+ }
+ }
+ }
+}
+#endif // ENABLE(IOS_TEXT_AUTOSIZING)
+
+}
</ins><span class="cx"> // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockFlowh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.h (161789 => 161790)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlockFlow.h        2014-01-12 02:51:19 UTC (rev 161789)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.h        2014-01-12 02:51:25 UTC (rev 161790)
</span><span class="lines">@@ -44,6 +44,12 @@
</span><span class="cx"> template <class Run> class BidiRunList;
</span><span class="cx"> typedef Vector<WordMeasurement, 64> WordMeasurements;
</span><span class="cx">
</span><ins>+#if ENABLE(IOS_TEXT_AUTOSIZING)
+enum LineCount {
+ NOT_SET = 0, NO_LINE = 1, ONE_LINE = 2, MULTI_LINE = 3
+};
+#endif
+
</ins><span class="cx"> class RenderBlockFlow : public RenderBlock {
</span><span class="cx"> public:
</span><span class="cx"> RenderBlockFlow(Element&, PassRef<RenderStyle>);
</span><span class="lines">@@ -526,6 +532,11 @@
</span><span class="cx"> bool namedFlowFragmentNeedsUpdate() const;
</span><span class="cx"> virtual bool canHaveChildren() const OVERRIDE;
</span><span class="cx">
</span><ins>+#if ENABLE(IOS_TEXT_AUTOSIZING)
+ int m_widthForTextAutosizing;
+ unsigned m_lineCountForTextAutosizing : 2;
+#endif
+
</ins><span class="cx"> public:
</span><span class="cx"> // FIXME-BLOCKFLOW: These can be made protected again once all callers have been moved here.
</span><span class="cx"> void adjustLinePositionForPagination(RootInlineBox*, LayoutUnit& deltaOffset, RenderFlowThread*); // Computes a deltaOffset value that put a line at the top of the next page if it doesn't fit on the current page.
</span><span class="lines">@@ -540,6 +551,16 @@
</span><span class="cx"> RenderBlockFlowRareData& ensureRareBlockFlowData();
</span><span class="cx"> void materializeRareBlockFlowData();
</span><span class="cx">
</span><ins>+#if ENABLE(IOS_TEXT_AUTOSIZING)
+ int immediateLineCount();
+ void adjustComputedFontSizes(float size, float visibleWidth);
+ void resetComputedFontSize()
+ {
+ m_widthForTextAutosizing = -1;
+ m_lineCountForTextAutosizing = NOT_SET;
+ }
+#endif
+
</ins><span class="cx"> protected:
</span><span class="cx"> OwnPtr<FloatingObjects> m_floatingObjects;
</span><span class="cx"> std::unique_ptr<RenderBlockFlowRareData> m_rareBlockFlowData;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (161789 => 161790)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderObject.cpp        2014-01-12 02:51:19 UTC (rev 161789)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp        2014-01-12 02:51:25 UTC (rev 161790)
</span><span class="lines">@@ -435,8 +435,8 @@
</span><span class="cx"> depthStack.append(newFixedDepth);
</span><span class="cx">
</span><span class="cx"> int stackSize = depthStack.size();
</span><del>- if (descendent->isRenderBlock() && !descendent->isListItem() && (!stackSize || currentDepth - depthStack[stackSize - 1] > TextAutoSizingFixedHeightDepth))
- static_cast<RenderBlock*>(descendent)->adjustComputedFontSizes(size, visibleWidth);
</del><ins>+ if (descendent->isRenderBlockFlow() && !descendent->isListItem() && (!stackSize || currentDepth - depthStack[stackSize - 1] > TextAutoSizingFixedHeightDepth))
+ toRenderBlockFlow(descendent)->adjustComputedFontSizes(size, visibleWidth);
</ins><span class="cx"> newFixedDepth = 0;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -463,8 +463,8 @@
</span><span class="cx"> depthStack.append(newFixedDepth);
</span><span class="cx">
</span><span class="cx"> int stackSize = depthStack.size();
</span><del>- if (descendent->isRenderBlock() && !descendent->isListItem() && (!stackSize || currentDepth - depthStack[stackSize - 1] > TextAutoSizingFixedHeightDepth))
- toRenderBlock(descendent)->resetComputedFontSize();
</del><ins>+ if (descendent->isRenderBlockFlow() && !descendent->isListItem() && (!stackSize || currentDepth - depthStack[stackSize - 1] > TextAutoSizingFixedHeightDepth))
+ toRenderBlockFlow(descendent)->resetComputedFontSize();
</ins><span class="cx"> newFixedDepth = 0;
</span><span class="cx"> }
</span><span class="cx"> }
</span></span></pre>
</div>
</div>
</body>
</html>