Title: [184825] trunk
- Revision
- 184825
- Author
- [email protected]
- Date
- 2015-05-23 09:06:36 -0700 (Sat, 23 May 2015)
Log Message
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.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (184824 => 184825)
--- trunk/LayoutTests/ChangeLog 2015-05-23 15:07:27 UTC (rev 184824)
+++ trunk/LayoutTests/ChangeLog 2015-05-23 16:06:36 UTC (rev 184825)
@@ -1,3 +1,19 @@
+2015-05-23 Zalan Bujtas <[email protected]>
+
+ 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.
+
2015-05-22 Alexey Proskuryakov <[email protected]>
Update tests broken by MediaPlaybackRequiresUserGesture renaming.
Added: trunk/LayoutTests/fast/text/simple-line-layout-inner-text-with-flow-content-expected.txt (0 => 184825)
--- 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)
@@ -0,0 +1 @@
+PASS if no crash or ASSERT in debug.fo
Added: trunk/LayoutTests/fast/text/simple-line-layout-inner-text-with-flow-content.html (0 => 184825)
--- 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)
@@ -0,0 +1,19 @@
+<!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>
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (184824 => 184825)
--- 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)
@@ -1,3 +1,22 @@
+2015-05-23 Zalan Bujtas <[email protected]>
+
+ 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:
+
2015-05-22 Mark Lam <[email protected]>
Document::ensurePlugInsInjectedScript() should evaluate the injected script on its own frame.
Modified: trunk/Source/WebCore/editing/TextIterator.cpp (184824 => 184825)
--- 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)
@@ -528,7 +528,6 @@
return false;
auto& renderer = *textNode.renderer();
- const auto* previousTextNode = m_lastTextNode;
m_lastTextNode = &textNode;
String rendererText = renderer.text();
@@ -565,23 +564,26 @@
if (const auto* layout = renderer.simpleLineLayout()) {
if (renderer.style().visibility() != VISIBLE && !(m_behavior & TextIteratorIgnoresStyleVisibility))
return true;
+ ASSERT(renderer.parent());
+ ASSERT(is<RenderBlockFlow>(*renderer.parent()));
+ const auto& blockFlow = downcast<RenderBlockFlow>(*renderer.parent());
// Use the simple layout runs to iterate over the text content.
- ASSERT(renderer.parent() && is<RenderBlockFlow>(renderer.parent()));
+ 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;
+
unsigned endPosition = (m_node == m_endContainer) ? static_cast<unsigned>(m_endOffset) : rendererText.length();
- const auto& blockFlow = downcast<RenderBlockFlow>(*renderer.parent());
if (!m_flowRunResolverCache || &m_flowRunResolverCache->flow() != &blockFlow) {
- m_previousTextLengthInFlow = m_flowRunResolverCache ? 0 : textNodeOffsetInFlow(textNode);
+ m_accumulatedSimpleTextLengthInFlow = m_flowRunResolverCache ? 0 : textNodeOffsetInFlow(textNode);
m_flowRunResolverCache = std::make_unique<SimpleLineLayout::RunResolver>(blockFlow, *layout);
- } 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();
}
// Skip to m_offset position.
auto range = m_flowRunResolverCache->rangeForRenderer(renderer);
auto it = range.begin();
auto end = range.end();
- while (it != end && (*it).end() <= (static_cast<unsigned>(m_offset) + m_previousTextLengthInFlow))
+ while (it != end && (*it).end() <= (static_cast<unsigned>(m_offset) + m_accumulatedSimpleTextLengthInFlow))
++it;
if (m_nextRunNeedsWhitespace && rendererText[m_offset - 1] == '\n') {
emitCharacter(' ', textNode, nullptr, m_offset, m_offset + 1);
@@ -600,10 +602,11 @@
const auto run = *it;
ASSERT(run.end() - run.start() <= rendererText.length());
// contentStart skips leading whitespace.
- unsigned contentStart = std::max<unsigned>(m_offset, run.start() - m_previousTextLengthInFlow);
- unsigned contentEnd = std::min(endPosition, run.end() - m_previousTextLengthInFlow);
+ 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);
// Check if whitespace adjustment is needed when crossing renderer boundary.
- if (previousTextNode && previousTextNode != &textNode) {
+ if (isNewTextNode) {
bool lastCharacterIsNotWhitespace = m_lastCharacter && !renderer.style().isCollapsibleWhiteSpace(m_lastCharacter);
bool addTrailingWhitespaceForPrevious = m_lastTextNodeEndedWithCollapsedSpace && lastCharacterIsNotWhitespace;
bool leadingWhitespaceIsNeededForCurrent = contentStart > static_cast<unsigned>(m_offset) && lastCharacterIsNotWhitespace;
Modified: trunk/Source/WebCore/editing/TextIterator.h (184824 => 184825)
--- 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)
@@ -168,7 +168,8 @@
// Used to do simple line layout run logic.
bool m_nextRunNeedsWhitespace { false };
- unsigned m_previousTextLengthInFlow { 0 };
+ unsigned m_accumulatedSimpleTextLengthInFlow { 0 };
+ Text* m_previousSimpleTextNodeInFlow { nullptr };
std::unique_ptr<SimpleLineLayout::RunResolver> m_flowRunResolverCache;
// Used when text boxes are out of order (Hebrew/Arabic with embedded LTR text)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes