- Revision
- 204778
- Author
- [email protected]
- Date
- 2016-08-23 01:23:31 -0700 (Tue, 23 Aug 2016)
Log Message
Merge r203045 - 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: releases/WebKitGTK/webkit-2.12/LayoutTests/ChangeLog (204777 => 204778)
--- releases/WebKitGTK/webkit-2.12/LayoutTests/ChangeLog 2016-08-23 08:22:25 UTC (rev 204777)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/ChangeLog 2016-08-23 08:23:31 UTC (rev 204778)
@@ -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-01 Zalan Bujtas <[email protected]>
prepareForDestruction() always needs to be called before destroying the Document object.
Added: releases/WebKitGTK/webkit-2.12/LayoutTests/fast/text/selection-on-a-detached-tree-expected.txt (0 => 204778)
--- releases/WebKitGTK/webkit-2.12/LayoutTests/fast/text/selection-on-a-detached-tree-expected.txt (rev 0)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/fast/text/selection-on-a-detached-tree-expected.txt 2016-08-23 08:23:31 UTC (rev 204778)
@@ -0,0 +1,6 @@
+
+
+PASS if no
+crash
+or assert.
+
Added: releases/WebKitGTK/webkit-2.12/LayoutTests/fast/text/selection-on-a-detached-tree.html (0 => 204778)
--- releases/WebKitGTK/webkit-2.12/LayoutTests/fast/text/selection-on-a-detached-tree.html (rev 0)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/fast/text/selection-on-a-detached-tree.html 2016-08-23 08:23:31 UTC (rev 204778)
@@ -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: releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog (204777 => 204778)
--- releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog 2016-08-23 08:22:25 UTC (rev 204777)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog 2016-08-23 08:23:31 UTC (rev 204778)
@@ -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-01 Zalan Bujtas <[email protected]>
prepareForDestruction() always needs to be called before destroying the Document object.
Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/rendering/LogicalSelectionOffsetCaches.h (204777 => 204778)
--- releases/WebKitGTK/webkit-2.12/Source/WebCore/rendering/LogicalSelectionOffsetCaches.h 2016-08-23 08:22:25 UTC (rev 204777)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/rendering/LogicalSelectionOffsetCaches.h 2016-08-23 08:23:31 UTC (rev 204778)
@@ -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: releases/WebKitGTK/webkit-2.12/Source/WebCore/rendering/RenderBlock.cpp (204777 => 204778)
--- releases/WebKitGTK/webkit-2.12/Source/WebCore/rendering/RenderBlock.cpp 2016-08-23 08:22:25 UTC (rev 204777)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/rendering/RenderBlock.cpp 2016-08-23 08:23:31 UTC (rev 204778)
@@ -2180,6 +2180,8 @@
ASSERT(currentCache);
auto info = currentCache->containingBlockInfo(*cb);
cb = info.block();
+ if (!cb)
+ break;
currentCache = info.cache();
}
return logicalLeft;
@@ -2202,6 +2204,8 @@
ASSERT(currentCache);
auto info = currentCache->containingBlockInfo(*cb);
cb = info.block();
+ if (!cb)
+ break;
currentCache = info.cache();
}
return logicalRight;