Title: [185665] trunk
Revision
185665
Author
[email protected]
Date
2015-06-17 14:06:58 -0700 (Wed, 17 Jun 2015)

Log Message

Selection cache produces invalid result when ancestor has float element.
https://bugs.webkit.org/show_bug.cgi?id=146042
rdar://problem/20604592

Reviewed by Ryosuke Niwa.

Selection cache already takes floats into account, however it's not enough to check current
block against floats. Any of the ancestor's float starting from the selection root block
can impact the selection offsets.

Source/WebCore:

Test: fast/block/selection-cache-is-incorrect-when-non-direct-parent-has-float.html

* rendering/LogicalSelectionOffsetCaches.h:
(WebCore::LogicalSelectionOffsetCaches::ContainingBlockInfo::ContainingBlockInfo):
(WebCore::LogicalSelectionOffsetCaches::ContainingBlockInfo::setBlock):
(WebCore::LogicalSelectionOffsetCaches::ContainingBlockInfo::block):
(WebCore::LogicalSelectionOffsetCaches::ContainingBlockInfo::cache):
(WebCore::LogicalSelectionOffsetCaches::ContainingBlockInfo::hasFloatsOrFlowThreads):
(WebCore::LogicalSelectionOffsetCaches::LogicalSelectionOffsetCaches):

LayoutTests:

* fast/block/selection-cache-is-incorrect-when-non-direct-parent-has-float-expected.txt: Added.
* fast/block/selection-cache-is-incorrect-when-non-direct-parent-has-float.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (185664 => 185665)


--- trunk/LayoutTests/ChangeLog	2015-06-17 20:41:03 UTC (rev 185664)
+++ trunk/LayoutTests/ChangeLog	2015-06-17 21:06:58 UTC (rev 185665)
@@ -1,3 +1,18 @@
+2015-06-17  Zalan Bujtas  <[email protected]>
+
+        Selection cache produces invalid result when ancestor has float element.
+        https://bugs.webkit.org/show_bug.cgi?id=146042
+        rdar://problem/20604592
+
+        Reviewed by Ryosuke Niwa.
+
+        Selection cache already takes floats into account, however it's not enough to check current
+        block against floats. Any of the ancestor's float starting from the selection root block
+        can impact the selection offsets.
+
+        * fast/block/selection-cache-is-incorrect-when-non-direct-parent-has-float-expected.txt: Added.
+        * fast/block/selection-cache-is-incorrect-when-non-direct-parent-has-float.html: Added.
+
 2015-06-17  Joanmarie Diggs  <[email protected]>
 
         AX: [ATK] Expose element tag name as an object attribute

Added: trunk/LayoutTests/fast/block/selection-cache-is-incorrect-when-non-direct-parent-has-float-expected.txt (0 => 185665)


--- trunk/LayoutTests/fast/block/selection-cache-is-incorrect-when-non-direct-parent-has-float-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/block/selection-cache-is-incorrect-when-non-direct-parent-has-float-expected.txt	2015-06-17 21:06:58 UTC (rev 185665)
@@ -0,0 +1,2 @@
+Pass if no crash or assert in debug.
+bar

Added: trunk/LayoutTests/fast/block/selection-cache-is-incorrect-when-non-direct-parent-has-float.html (0 => 185665)


--- trunk/LayoutTests/fast/block/selection-cache-is-incorrect-when-non-direct-parent-has-float.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/selection-cache-is-incorrect-when-non-direct-parent-has-float.html	2015-06-17 21:06:58 UTC (rev 185665)
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+    ol {
+	    margin: 0px;
+    }
+
+    .float {
+        float: left;
+        width: 100px;
+	    height: 100px;
+    }
+</style>
+<script>
+    if (window.testRunner)
+        testRunner.dumpAsText();
+</script>
+</head>
+<body>
+    <ol><li>Pass if no crash or assert in debug.</li></ol>
+    <div class=float>bar</div>
+    <script>
+        document.designMode = "on";
+        document.execCommand("SelectAll");
+    </script>
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (185664 => 185665)


--- trunk/Source/WebCore/ChangeLog	2015-06-17 20:41:03 UTC (rev 185664)
+++ trunk/Source/WebCore/ChangeLog	2015-06-17 21:06:58 UTC (rev 185665)
@@ -1,3 +1,25 @@
+2015-06-17  Zalan Bujtas  <[email protected]>
+
+        Selection cache produces invalid result when ancestor has float element.
+        https://bugs.webkit.org/show_bug.cgi?id=146042
+        rdar://problem/20604592
+
+        Reviewed by Ryosuke Niwa.
+
+        Selection cache already takes floats into account, however it's not enough to check current
+        block against floats. Any of the ancestor's float starting from the selection root block
+        can impact the selection offsets.
+
+        Test: fast/block/selection-cache-is-incorrect-when-non-direct-parent-has-float.html
+
+        * rendering/LogicalSelectionOffsetCaches.h:
+        (WebCore::LogicalSelectionOffsetCaches::ContainingBlockInfo::ContainingBlockInfo):
+        (WebCore::LogicalSelectionOffsetCaches::ContainingBlockInfo::setBlock):
+        (WebCore::LogicalSelectionOffsetCaches::ContainingBlockInfo::block):
+        (WebCore::LogicalSelectionOffsetCaches::ContainingBlockInfo::cache):
+        (WebCore::LogicalSelectionOffsetCaches::ContainingBlockInfo::hasFloatsOrFlowThreads):
+        (WebCore::LogicalSelectionOffsetCaches::LogicalSelectionOffsetCaches):
+
 2015-06-17  Joanmarie Diggs  <[email protected]>
 
         AX: [ATK] Expose element tag name as an object attribute

Modified: trunk/Source/WebCore/rendering/LogicalSelectionOffsetCaches.h (185664 => 185665)


--- trunk/Source/WebCore/rendering/LogicalSelectionOffsetCaches.h	2015-06-17 20:41:03 UTC (rev 185664)
+++ trunk/Source/WebCore/rendering/LogicalSelectionOffsetCaches.h	2015-06-17 21:06:58 UTC (rev 185665)
@@ -30,25 +30,20 @@
     class ContainingBlockInfo {
     public:
         ContainingBlockInfo()
-            : m_block(0)
-            , m_cache(0)
-            , m_hasFloatsOrFlowThreads(false)
+            : m_hasFloatsOrFlowThreads(false)
             , m_cachedLogicalLeftSelectionOffset(false)
             , m_cachedLogicalRightSelectionOffset(false)
         { }
 
-        void setBlock(RenderBlock* block, const LogicalSelectionOffsetCaches* cache)
+        void setBlock(RenderBlock* block, const LogicalSelectionOffsetCaches* cache, bool parentCacheHasFloatsOrFlowThreads = false)
         {
             m_block = block;
-            m_hasFloatsOrFlowThreads = m_hasFloatsOrFlowThreads || m_block->containsFloats() || m_block->flowThreadContainingBlock();
+            m_hasFloatsOrFlowThreads = parentCacheHasFloatsOrFlowThreads || m_hasFloatsOrFlowThreads || m_block->containsFloats() || m_block->flowThreadContainingBlock();
             m_cache = cache;
             m_cachedLogicalLeftSelectionOffset = false;
             m_cachedLogicalRightSelectionOffset = false;
         }
 
-        RenderBlock* block() const { return m_block; }
-        const LogicalSelectionOffsetCaches* cache() const { return m_cache; }
-
         LayoutUnit logicalLeftSelectionOffset(RenderBlock& rootBlock, LayoutUnit position) const
         {
             ASSERT(m_cache);
@@ -71,9 +66,13 @@
             return m_logicalRightSelectionOffset;
         }
 
+        RenderBlock* block() const { return m_block; }
+        const LogicalSelectionOffsetCaches* cache() const { return m_cache; }
+        bool hasFloatsOrFlowThreads() const { return m_hasFloatsOrFlowThreads; }
+
     private:
-        RenderBlock* m_block;
-        const LogicalSelectionOffsetCaches* m_cache;
+        RenderBlock* m_block { nullptr };
+        const LogicalSelectionOffsetCaches* m_cache { nullptr };
         bool m_hasFloatsOrFlowThreads : 1;
         mutable bool m_cachedLogicalLeftSelectionOffset : 1;
         mutable bool m_cachedLogicalRightSelectionOffset : 1;
@@ -102,12 +101,12 @@
         , m_containingBlockForAbsolutePosition(cache.m_containingBlockForAbsolutePosition)
     {
         if (block.canContainFixedPositionObjects())
-            m_containingBlockForFixedPosition.setBlock(&block, &cache);
+            m_containingBlockForFixedPosition.setBlock(&block, &cache, cache.m_containingBlockForFixedPosition.hasFloatsOrFlowThreads());
 
         if (block.canContainAbsolutelyPositionedObjects() && !block.isRenderInline() && !block.isAnonymousBlock())
-            m_containingBlockForFixedPosition.setBlock(&block, &cache);
+            m_containingBlockForAbsolutePosition.setBlock(&block, &cache, cache.m_containingBlockForAbsolutePosition.hasFloatsOrFlowThreads());
 
-        m_containingBlockForInflowPosition.setBlock(&block, &cache);
+        m_containingBlockForInflowPosition.setBlock(&block, &cache, cache.m_containingBlockForInflowPosition.hasFloatsOrFlowThreads());
     }
 
     const ContainingBlockInfo& containingBlockInfo(RenderBlock& block) const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to