Changeset 209427 in webkit
- Timestamp:
- Dec 6, 2016 3:06:42 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r209425 r209427 1 2016-12-06 Zalan Bujtas <zalan@apple.com> 2 3 Can not select whole line when using flexbox 4 https://bugs.webkit.org/show_bug.cgi?id=165299 5 6 Reviewed by David Hyatt. 7 8 * fast/flexbox/flexbox-fail-to-select-same-line-expected.html: Added. 9 * fast/flexbox/flexbox-fail-to-select-same-line.html: Added. 10 1 11 2016-12-06 Jer Noble <jer.noble@apple.com> 2 12 -
trunk/Source/WebCore/ChangeLog
r209426 r209427 1 2016-12-06 Zalan Bujtas <zalan@apple.com> 2 3 Can not select whole line when using flexbox 4 https://bugs.webkit.org/show_bug.cgi?id=165299 5 6 Reviewed by David Hyatt. 7 8 RootInlineBox::selectionTopAdjustedForPrecedingBlock assumes that the preceding block is 9 always above the current line. However in certain layout contexts (flex as an example) the block before 10 could just be on the same line as the current one. 11 12 This patch checks if we actually need to adjust the selection top to avoid vertical selection overlap. 13 14 Test: fast/flexbox/flexbox-fail-to-select-same-line.html 15 16 * rendering/RenderBlock.cpp: 17 (WebCore::RenderBlock::blockBeforeWithinSelectionRoot): Deleted. 18 * rendering/RenderBlock.h: 19 * rendering/RootInlineBox.cpp: 20 (WebCore::blockBeforeWithinSelectionRoot): 21 (WebCore::RootInlineBox::selectionTopAdjustedForPrecedingBlock): 22 1 23 2016-12-06 Ryosuke Niwa <rniwa@webkit.org> 2 24 -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r208985 r209427 2202 2202 } 2203 2203 2204 RenderBlock* RenderBlock::blockBeforeWithinSelectionRoot(LayoutSize& offset) const2205 {2206 if (isSelectionRoot())2207 return nullptr;2208 2209 const RenderElement* object = this;2210 RenderObject* sibling;2211 do {2212 sibling = object->previousSibling();2213 while (sibling && (!is<RenderBlock>(*sibling) || downcast<RenderBlock>(*sibling).isSelectionRoot()))2214 sibling = sibling->previousSibling();2215 2216 offset -= LayoutSize(downcast<RenderBlock>(*object).logicalLeft(), downcast<RenderBlock>(*object).logicalTop());2217 object = object->parent();2218 } while (!sibling && is<RenderBlock>(object) && !downcast<RenderBlock>(*object).isSelectionRoot());2219 2220 if (!sibling)2221 return nullptr;2222 2223 RenderBlock* beforeBlock = downcast<RenderBlock>(sibling);2224 2225 offset += LayoutSize(beforeBlock->logicalLeft(), beforeBlock->logicalTop());2226 2227 RenderObject* child = beforeBlock->lastChild();2228 while (is<RenderBlock>(child)) {2229 beforeBlock = downcast<RenderBlock>(child);2230 offset += LayoutSize(beforeBlock->logicalLeft(), beforeBlock->logicalTop());2231 child = beforeBlock->lastChild();2232 }2233 return beforeBlock;2234 }2235 2236 2204 TrackedRendererListHashSet* RenderBlock::positionedObjects() const 2237 2205 { -
trunk/Source/WebCore/rendering/RenderBlock.h
r208985 r209427 177 177 RenderBoxModelObject* selObj, LayoutUnit logicalRight, LayoutUnit logicalTop, LayoutUnit logicalHeight, const LogicalSelectionOffsetCaches&, const PaintInfo*); 178 178 void getSelectionGapInfo(SelectionState, bool& leftGap, bool& rightGap); 179 RenderBlock* blockBeforeWithinSelectionRoot(LayoutSize& offset) const;179 bool isSelectionRoot() const; 180 180 181 181 LayoutRect logicalRectToPhysicalRect(const LayoutPoint& physicalPosition, const LayoutRect& logicalRect); … … 458 458 } 459 459 bool shouldPaintSelectionGaps() const final; 460 bool isSelectionRoot() const;461 460 GapRects selectionGaps(RenderBlock& rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, 462 461 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLogicalRight, const LogicalSelectionOffsetCaches&, const PaintInfo* = 0); -
trunk/Source/WebCore/rendering/RootInlineBox.cpp
r208112 r209427 642 642 } 643 643 644 static RenderBlock* blockBeforeWithinSelectionRoot(const RenderBlockFlow& blockFlow, LayoutSize& offset) 645 { 646 if (blockFlow.isSelectionRoot()) 647 return nullptr; 648 649 const RenderElement* object = &blockFlow; 650 RenderObject* sibling; 651 do { 652 sibling = object->previousSibling(); 653 while (sibling && (!is<RenderBlock>(*sibling) || downcast<RenderBlock>(*sibling).isSelectionRoot())) 654 sibling = sibling->previousSibling(); 655 656 offset -= LayoutSize(downcast<RenderBlock>(*object).logicalLeft(), downcast<RenderBlock>(*object).logicalTop()); 657 object = object->parent(); 658 } while (!sibling && is<RenderBlock>(object) && !downcast<RenderBlock>(*object).isSelectionRoot()); 659 660 if (!sibling) 661 return nullptr; 662 663 RenderBlock* beforeBlock = downcast<RenderBlock>(sibling); 664 665 offset += LayoutSize(beforeBlock->logicalLeft(), beforeBlock->logicalTop()); 666 667 RenderObject* child = beforeBlock->lastChild(); 668 while (is<RenderBlock>(child)) { 669 beforeBlock = downcast<RenderBlock>(child); 670 offset += LayoutSize(beforeBlock->logicalLeft(), beforeBlock->logicalTop()); 671 child = beforeBlock->lastChild(); 672 } 673 return beforeBlock; 674 } 675 644 676 LayoutUnit RootInlineBox::selectionTopAdjustedForPrecedingBlock() const 645 677 { … … 647 679 LayoutUnit top = selectionTop(); 648 680 649 RenderObject::SelectionStateblockSelectionState = rootBox.blockFlow().selectionState();681 auto blockSelectionState = rootBox.blockFlow().selectionState(); 650 682 if (blockSelectionState != RenderObject::SelectionInside && blockSelectionState != RenderObject::SelectionEnd) 651 683 return top; 652 684 653 685 LayoutSize offsetToBlockBefore; 654 if (RenderBlock* block = rootBox.blockFlow().blockBeforeWithinSelectionRoot(offsetToBlockBefore)) { 655 if (is<RenderBlockFlow>(*block)) { 656 if (RootInlineBox* lastLine = downcast<RenderBlockFlow>(*block).lastRootBox()) { 657 RenderObject::SelectionState lastLineSelectionState = lastLine->selectionState(); 658 if (lastLineSelectionState != RenderObject::SelectionInside && lastLineSelectionState != RenderObject::SelectionStart) 659 return top; 660 661 LayoutUnit lastLineSelectionBottom = lastLine->selectionBottom() + offsetToBlockBefore.height(); 662 top = std::max(top, lastLineSelectionBottom); 663 } 664 } 665 } 666 686 auto* blockBefore = blockBeforeWithinSelectionRoot(rootBox.blockFlow(), offsetToBlockBefore); 687 if (!is<RenderBlockFlow>(blockBefore)) 688 return top; 689 690 // Do not adjust blocks sharing the same line. 691 if (!offsetToBlockBefore.height()) 692 return top; 693 694 if (auto* lastLine = downcast<RenderBlockFlow>(*blockBefore).lastRootBox()) { 695 RenderObject::SelectionState lastLineSelectionState = lastLine->selectionState(); 696 if (lastLineSelectionState != RenderObject::SelectionInside && lastLineSelectionState != RenderObject::SelectionStart) 697 return top; 698 699 LayoutUnit lastLineSelectionBottom = lastLine->selectionBottom() + offsetToBlockBefore.height(); 700 top = std::max(top, lastLineSelectionBottom); 701 } 667 702 return top; 668 703 }
Note: See TracChangeset
for help on using the changeset viewer.