<!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>[184825] trunk</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/184825">184825</a></dd>
<dt>Author</dt> <dd>zalan@apple.com</dd>
<dt>Date</dt> <dd>2015-05-23 09:06:36 -0700 (Sat, 23 May 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Simple line layout: Ignore -webkit-flow-*content while collecting text content for innerText.
https://bugs.webkit.org/show_bug.cgi?id=145344
rdar://problem/20959522
Reviewed by Antti Koivisto.
This patch ensures that when a -webkit-flow-into content is present in a simple line layout container,
we skip it while collecting the text content for innerText.
It's not always guaranteed that a simple line layout container only contains simple text nodes. In such cases,
we need to ensure that text offset computing only takes the simple text nodes into account.
Source/WebCore:
Test: fast/text/simple-line-layout-inner-text-with-flow-content.html
* editing/TextIterator.cpp:
(WebCore::TextIterator::handleTextNode):
* editing/TextIterator.h:
LayoutTests:
* fast/text/simple-line-layout-inner-text-with-flow-content-expected.txt: Added.
* fast/text/simple-line-layout-inner-text-with-flow-content.html: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreeditingTextIteratorcpp">trunk/Source/WebCore/editing/TextIterator.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingTextIteratorh">trunk/Source/WebCore/editing/TextIterator.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfasttextsimplelinelayoutinnertextwithflowcontentexpectedtxt">trunk/LayoutTests/fast/text/simple-line-layout-inner-text-with-flow-content-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasttextsimplelinelayoutinnertextwithflowcontenthtml">trunk/LayoutTests/fast/text/simple-line-layout-inner-text-with-flow-content.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (184824 => 184825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-05-23 15:07:27 UTC (rev 184824)
+++ trunk/LayoutTests/ChangeLog        2015-05-23 16:06:36 UTC (rev 184825)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2015-05-23 Zalan Bujtas <zalan@apple.com>
+
+ Simple line layout: Ignore -webkit-flow-*content while collecting text content for innerText.
+ https://bugs.webkit.org/show_bug.cgi?id=145344
+ rdar://problem/20959522
+
+ Reviewed by Antti Koivisto.
+
+ This patch ensures that when a -webkit-flow-into content is present in a simple line layout container,
+ we skip it while collecting the text content for innerText.
+ It's not always guaranteed that a simple line layout container only contains simple text nodes. In such cases,
+ we need to ensure that text offset computing only takes the simple text nodes into account.
+
+ * fast/text/simple-line-layout-inner-text-with-flow-content-expected.txt: Added.
+ * fast/text/simple-line-layout-inner-text-with-flow-content.html: Added.
+
</ins><span class="cx"> 2015-05-22 Alexey Proskuryakov <ap@apple.com>
</span><span class="cx">
</span><span class="cx"> Update tests broken by MediaPlaybackRequiresUserGesture renaming.
</span></span></pre></div>
<a id="trunkLayoutTestsfasttextsimplelinelayoutinnertextwithflowcontentexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/simple-line-layout-inner-text-with-flow-content-expected.txt (0 => 184825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/simple-line-layout-inner-text-with-flow-content-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/text/simple-line-layout-inner-text-with-flow-content-expected.txt        2015-05-23 16:06:36 UTC (rev 184825)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+PASS if no crash or ASSERT in debug.fo
</ins></span></pre></div>
<a id="trunkLayoutTestsfasttextsimplelinelayoutinnertextwithflowcontenthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/simple-line-layout-inner-text-with-flow-content.html (0 => 184825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/simple-line-layout-inner-text-with-flow-content.html         (rev 0)
+++ trunk/LayoutTests/fast/text/simple-line-layout-inner-text-with-flow-content.html        2015-05-23 16:06:36 UTC (rev 184825)
</span><span class="lines">@@ -0,0 +1,19 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that innerText works fine when a flow node is present in a simple line layout container.</title>
+<style>
+ .to {
+ -webkit-flow-into: redirectToNowhere;
+ }
+</style>
+<script>
+        if (window.testRunner)
+         testRunner.dumpAsText();
+</script>
+</head>
+<body><div id=foo>PASS if no crash or ASSERT in debug.<span class="to">f</span>o</div>
+<script>
+ document.getElementById("foo").innerText;
+</script>
+</body>
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (184824 => 184825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-05-23 15:07:27 UTC (rev 184824)
+++ trunk/Source/WebCore/ChangeLog        2015-05-23 16:06:36 UTC (rev 184825)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2015-05-23 Zalan Bujtas <zalan@apple.com>
+
+ Simple line layout: Ignore -webkit-flow-*content while collecting text content for innerText.
+ https://bugs.webkit.org/show_bug.cgi?id=145344
+ rdar://problem/20959522
+
+ Reviewed by Antti Koivisto.
+
+ This patch ensures that when a -webkit-flow-into content is present in a simple line layout container,
+ we skip it while collecting the text content for innerText.
+ It's not always guaranteed that a simple line layout container only contains simple text nodes. In such cases,
+ we need to ensure that text offset computing only takes the simple text nodes into account.
+
+ Test: fast/text/simple-line-layout-inner-text-with-flow-content.html
+
+ * editing/TextIterator.cpp:
+ (WebCore::TextIterator::handleTextNode):
+ * editing/TextIterator.h:
+
</ins><span class="cx"> 2015-05-22 Mark Lam <mark.lam@apple.com>
</span><span class="cx">
</span><span class="cx"> Document::ensurePlugInsInjectedScript() should evaluate the injected script on its own frame.
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingTextIteratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/TextIterator.cpp (184824 => 184825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/TextIterator.cpp        2015-05-23 15:07:27 UTC (rev 184824)
+++ trunk/Source/WebCore/editing/TextIterator.cpp        2015-05-23 16:06:36 UTC (rev 184825)
</span><span class="lines">@@ -528,7 +528,6 @@
</span><span class="cx"> return false;
</span><span class="cx">
</span><span class="cx"> auto& renderer = *textNode.renderer();
</span><del>- const auto* previousTextNode = m_lastTextNode;
</del><span class="cx"> m_lastTextNode = &textNode;
</span><span class="cx"> String rendererText = renderer.text();
</span><span class="cx">
</span><span class="lines">@@ -565,23 +564,26 @@
</span><span class="cx"> if (const auto* layout = renderer.simpleLineLayout()) {
</span><span class="cx"> if (renderer.style().visibility() != VISIBLE && !(m_behavior & TextIteratorIgnoresStyleVisibility))
</span><span class="cx"> return true;
</span><ins>+ ASSERT(renderer.parent());
+ ASSERT(is<RenderBlockFlow>(*renderer.parent()));
+ const auto& blockFlow = downcast<RenderBlockFlow>(*renderer.parent());
</ins><span class="cx"> // Use the simple layout runs to iterate over the text content.
</span><del>- ASSERT(renderer.parent() && is<RenderBlockFlow>(renderer.parent()));
</del><ins>+ bool isNewTextNode = m_previousSimpleTextNodeInFlow && m_previousSimpleTextNodeInFlow != &textNode;
+ // Simple line layout run positions are all absolute to the parent flow.
+ // Offsetting is required when multiple renderers are present.
+ m_accumulatedSimpleTextLengthInFlow += isNewTextNode ? m_previousSimpleTextNodeInFlow->renderer()->text()->length() : 0;
+ m_previousSimpleTextNodeInFlow = &textNode;
+
</ins><span class="cx"> unsigned endPosition = (m_node == m_endContainer) ? static_cast<unsigned>(m_endOffset) : rendererText.length();
</span><del>- const auto& blockFlow = downcast<RenderBlockFlow>(*renderer.parent());
</del><span class="cx"> if (!m_flowRunResolverCache || &m_flowRunResolverCache->flow() != &blockFlow) {
</span><del>- m_previousTextLengthInFlow = m_flowRunResolverCache ? 0 : textNodeOffsetInFlow(textNode);
</del><ins>+ m_accumulatedSimpleTextLengthInFlow = m_flowRunResolverCache ? 0 : textNodeOffsetInFlow(textNode);
</ins><span class="cx"> m_flowRunResolverCache = std::make_unique<SimpleLineLayout::RunResolver>(blockFlow, *layout);
</span><del>- } else if (previousTextNode && previousTextNode != &textNode) {
- // Simple line layout run positions are all absolute to the parent flow.
- // Offsetting is required when multiple renderers are present.
- m_previousTextLengthInFlow += previousTextNode->renderer()->text()->length();
</del><span class="cx"> }
</span><span class="cx"> // Skip to m_offset position.
</span><span class="cx"> auto range = m_flowRunResolverCache->rangeForRenderer(renderer);
</span><span class="cx"> auto it = range.begin();
</span><span class="cx"> auto end = range.end();
</span><del>- while (it != end && (*it).end() <= (static_cast<unsigned>(m_offset) + m_previousTextLengthInFlow))
</del><ins>+ while (it != end && (*it).end() <= (static_cast<unsigned>(m_offset) + m_accumulatedSimpleTextLengthInFlow))
</ins><span class="cx"> ++it;
</span><span class="cx"> if (m_nextRunNeedsWhitespace && rendererText[m_offset - 1] == '\n') {
</span><span class="cx"> emitCharacter(' ', textNode, nullptr, m_offset, m_offset + 1);
</span><span class="lines">@@ -600,10 +602,11 @@
</span><span class="cx"> const auto run = *it;
</span><span class="cx"> ASSERT(run.end() - run.start() <= rendererText.length());
</span><span class="cx"> // contentStart skips leading whitespace.
</span><del>- unsigned contentStart = std::max<unsigned>(m_offset, run.start() - m_previousTextLengthInFlow);
- unsigned contentEnd = std::min(endPosition, run.end() - m_previousTextLengthInFlow);
</del><ins>+ unsigned contentStart = std::max<unsigned>(m_offset, run.start() - m_accumulatedSimpleTextLengthInFlow);
+ unsigned contentEnd = std::min(endPosition, run.end() - m_accumulatedSimpleTextLengthInFlow);
+ ASSERT_WITH_SECURITY_IMPLICATION(contentStart <= contentEnd);
</ins><span class="cx"> // Check if whitespace adjustment is needed when crossing renderer boundary.
</span><del>- if (previousTextNode && previousTextNode != &textNode) {
</del><ins>+ if (isNewTextNode) {
</ins><span class="cx"> bool lastCharacterIsNotWhitespace = m_lastCharacter && !renderer.style().isCollapsibleWhiteSpace(m_lastCharacter);
</span><span class="cx"> bool addTrailingWhitespaceForPrevious = m_lastTextNodeEndedWithCollapsedSpace && lastCharacterIsNotWhitespace;
</span><span class="cx"> bool leadingWhitespaceIsNeededForCurrent = contentStart > static_cast<unsigned>(m_offset) && lastCharacterIsNotWhitespace;
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingTextIteratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/TextIterator.h (184824 => 184825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/TextIterator.h        2015-05-23 15:07:27 UTC (rev 184824)
+++ trunk/Source/WebCore/editing/TextIterator.h        2015-05-23 16:06:36 UTC (rev 184825)
</span><span class="lines">@@ -168,7 +168,8 @@
</span><span class="cx">
</span><span class="cx"> // Used to do simple line layout run logic.
</span><span class="cx"> bool m_nextRunNeedsWhitespace { false };
</span><del>- unsigned m_previousTextLengthInFlow { 0 };
</del><ins>+ unsigned m_accumulatedSimpleTextLengthInFlow { 0 };
+ Text* m_previousSimpleTextNodeInFlow { nullptr };
</ins><span class="cx"> std::unique_ptr<SimpleLineLayout::RunResolver> m_flowRunResolverCache;
</span><span class="cx">
</span><span class="cx"> // Used when text boxes are out of order (Hebrew/Arabic with embedded LTR text)
</span></span></pre>
</div>
</div>
</body>
</html>