- Revision
- 203045
- Author
- [email protected]
- Date
- 2016-07-10 20:58:49 -0700 (Sun, 10 Jul 2016)
Log Message
Fix LogicalSelectionOffsetCaches to work with detached render tree.
https://bugs.webkit.org/show_bug.cgi?id=159605
<rdar://problem/27248845>
Reviewed by Brent Fulgham.
Source/WebCore:
When the renderer that is being destroyed is on a selection boundary,
we need to ensure that all its cached pointers across the selection code (e.g. SelectionSubtreeData)
are getting reset. In order to do that, we call clearSelection() on the RenderView.
One of the last steps of clearing selection is to collect the selection gaps. Selection gaps uses this
LogicalSelectionOffsetCaches helper class to collect selection information across blocks.
LogicalSelectionOffsetCaches normally operates on rooted renderers. However we need to ensure sure that
it can also handle renderers that are no longer part of the render tree.
Test: fast/text/selection-on-a-detached-tree.html
* rendering/LogicalSelectionOffsetCaches.h:
(WebCore::LogicalSelectionOffsetCaches::ContainingBlockInfo::setBlock):
(WebCore::LogicalSelectionOffsetCaches::ContainingBlockInfo::logicalLeftSelectionOffset):
(WebCore::LogicalSelectionOffsetCaches::ContainingBlockInfo::logicalRightSelectionOffset):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::logicalLeftSelectionOffset):
(WebCore::RenderBlock::logicalRightSelectionOffset):
LayoutTests:
* fast/text/selection-on-a-detached-tree-expected.txt: Added.
* fast/text/selection-on-a-detached-tree.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (203044 => 203045)
--- trunk/LayoutTests/ChangeLog 2016-07-11 02:52:07 UTC (rev 203044)
+++ trunk/LayoutTests/ChangeLog 2016-07-11 03:58:49 UTC (rev 203045)
@@ -1,3 +1,14 @@
+2016-07-10 Zalan Bujtas <[email protected]>
+
+ Fix LogicalSelectionOffsetCaches to work with detached render tree.
+ https://bugs.webkit.org/show_bug.cgi?id=159605
+ <rdar://problem/27248845>
+
+ Reviewed by Brent Fulgham.
+
+ * fast/text/selection-on-a-detached-tree-expected.txt: Added.
+ * fast/text/selection-on-a-detached-tree.html: Added.
+
2016-07-10 Chris Dumez <[email protected]>
adoptNode() changes css class to lowercase for document loaded with XHR responseType = "document"
Added: trunk/LayoutTests/fast/text/selection-on-a-detached-tree-expected.txt (0 => 203045)
--- trunk/LayoutTests/fast/text/selection-on-a-detached-tree-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/text/selection-on-a-detached-tree-expected.txt 2016-07-11 03:58:49 UTC (rev 203045)
@@ -0,0 +1,6 @@
+
+
+PASS if no
+crash
+or assert.
+
Added: trunk/LayoutTests/fast/text/selection-on-a-detached-tree.html (0 => 203045)
--- trunk/LayoutTests/fast/text/selection-on-a-detached-tree.html (rev 0)
+++ trunk/LayoutTests/fast/text/selection-on-a-detached-tree.html 2016-07-11 03:58:49 UTC (rev 203045)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that we can preform selection operations on detached trees.</title>
+</head>
+<body contentEditable='true'>
+<div><canvas style="position:fixed;"></canvas>PASS if no<table style="position:fixed;"><ul style="position:absolute;">crash</ul><button>or assert.</button></table></div>
+<script>
+if (window.testRunner)
+ testRunner.dumpAsText();
+document.execCommand('selectall', false, null);
+window.document.execCommand('insertunorderedlist', true, null);
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (203044 => 203045)
--- trunk/Source/WebCore/ChangeLog 2016-07-11 02:52:07 UTC (rev 203044)
+++ trunk/Source/WebCore/ChangeLog 2016-07-11 03:58:49 UTC (rev 203045)
@@ -1,3 +1,29 @@
+2016-07-10 Zalan Bujtas <[email protected]>
+
+ Fix LogicalSelectionOffsetCaches to work with detached render tree.
+ https://bugs.webkit.org/show_bug.cgi?id=159605
+ <rdar://problem/27248845>
+
+ Reviewed by Brent Fulgham.
+
+ When the renderer that is being destroyed is on a selection boundary,
+ we need to ensure that all its cached pointers across the selection code (e.g. SelectionSubtreeData)
+ are getting reset. In order to do that, we call clearSelection() on the RenderView.
+ One of the last steps of clearing selection is to collect the selection gaps. Selection gaps uses this
+ LogicalSelectionOffsetCaches helper class to collect selection information across blocks.
+ LogicalSelectionOffsetCaches normally operates on rooted renderers. However we need to ensure sure that
+ it can also handle renderers that are no longer part of the render tree.
+
+ Test: fast/text/selection-on-a-detached-tree.html
+
+ * rendering/LogicalSelectionOffsetCaches.h:
+ (WebCore::LogicalSelectionOffsetCaches::ContainingBlockInfo::setBlock):
+ (WebCore::LogicalSelectionOffsetCaches::ContainingBlockInfo::logicalLeftSelectionOffset):
+ (WebCore::LogicalSelectionOffsetCaches::ContainingBlockInfo::logicalRightSelectionOffset):
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::logicalLeftSelectionOffset):
+ (WebCore::RenderBlock::logicalRightSelectionOffset):
+
2016-07-10 Chris Dumez <[email protected]>
adoptNode() changes css class to lowercase for document loaded with XHR responseType = "document"
Modified: trunk/Source/WebCore/rendering/LogicalSelectionOffsetCaches.h (203044 => 203045)
--- trunk/Source/WebCore/rendering/LogicalSelectionOffsetCaches.h 2016-07-11 02:52:07 UTC (rev 203044)
+++ trunk/Source/WebCore/rendering/LogicalSelectionOffsetCaches.h 2016-07-11 03:58:49 UTC (rev 203045)
@@ -38,7 +38,8 @@
void setBlock(RenderBlock* block, const LogicalSelectionOffsetCaches* cache, bool parentCacheHasFloatsOrFlowThreads = false)
{
m_block = block;
- m_hasFloatsOrFlowThreads = parentCacheHasFloatsOrFlowThreads || m_hasFloatsOrFlowThreads || m_block->containsFloats() || m_block->flowThreadContainingBlock();
+ bool blockHasFloatsOrFlowThreads = m_block ? (m_block->containsFloats() || m_block->flowThreadContainingBlock()) : false;
+ m_hasFloatsOrFlowThreads = parentCacheHasFloatsOrFlowThreads || m_hasFloatsOrFlowThreads || blockHasFloatsOrFlowThreads;
m_cache = cache;
m_cachedLogicalLeftSelectionOffset = false;
m_cachedLogicalRightSelectionOffset = false;
@@ -49,9 +50,9 @@
ASSERT(m_cache);
if (m_hasFloatsOrFlowThreads || !m_cachedLogicalLeftSelectionOffset) {
m_cachedLogicalLeftSelectionOffset = true;
- m_logicalLeftSelectionOffset = m_block->logicalLeftSelectionOffset(rootBlock, position, *m_cache);
+ m_logicalLeftSelectionOffset = m_block ? m_block->logicalLeftSelectionOffset(rootBlock, position, *m_cache) : LayoutUnit::fromPixel(0);
} else
- ASSERT(m_logicalLeftSelectionOffset == m_block->logicalLeftSelectionOffset(rootBlock, position, *m_cache));
+ ASSERT(m_logicalLeftSelectionOffset == (m_block ? m_block->logicalLeftSelectionOffset(rootBlock, position, *m_cache) : LayoutUnit::fromPixel(0)));
return m_logicalLeftSelectionOffset;
}
@@ -60,9 +61,9 @@
ASSERT(m_cache);
if (m_hasFloatsOrFlowThreads || !m_cachedLogicalRightSelectionOffset) {
m_cachedLogicalRightSelectionOffset = true;
- m_logicalRightSelectionOffset = m_block->logicalRightSelectionOffset(rootBlock, position, *m_cache);
+ m_logicalRightSelectionOffset = m_block ? m_block->logicalRightSelectionOffset(rootBlock, position, *m_cache) : LayoutUnit::fromPixel(0);
} else
- ASSERT(m_logicalRightSelectionOffset == m_block->logicalRightSelectionOffset(rootBlock, position, *m_cache));
+ ASSERT(m_logicalRightSelectionOffset == (m_block ? m_block->logicalRightSelectionOffset(rootBlock, position, *m_cache) : LayoutUnit::fromPixel(0)));
return m_logicalRightSelectionOffset;
}
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (203044 => 203045)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2016-07-11 02:52:07 UTC (rev 203044)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2016-07-11 03:58:49 UTC (rev 203045)
@@ -2179,6 +2179,8 @@
ASSERT(currentCache);
auto info = currentCache->containingBlockInfo(*cb);
cb = info.block();
+ if (!cb)
+ break;
currentCache = info.cache();
}
return logicalLeft;
@@ -2201,6 +2203,8 @@
ASSERT(currentCache);
auto info = currentCache->containingBlockInfo(*cb);
cb = info.block();
+ if (!cb)
+ break;
currentCache = info.cache();
}
return logicalRight;