Changeset 71246 in webkit
- Timestamp:
- Nov 3, 2010 10:16:23 AM (13 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r71244 r71246 1 2010-11-03 David Hyatt <hyatt@apple.com> 2 3 Reviewed by Dan Bernstein. 4 5 https://bugs.webkit.org/show_bug.cgi?id=48928 6 7 Rename all the selection gap functions to not be directionally specific. Left and Right turn into LogicalLeft and 8 LogicalRight. Horizontal becomes Line. Vertical becomes Block. 9 10 * rendering/RenderBlock.cpp: 11 (WebCore::RenderBlock::selectionGapRectsForRepaint): 12 (WebCore::RenderBlock::paintSelection): 13 (WebCore::RenderBlock::fillSelectionGaps): 14 (WebCore::RenderBlock::fillInlineSelectionGaps): 15 (WebCore::RenderBlock::fillBlockSelectionGaps): 16 (WebCore::RenderBlock::fillLineSelectionGap): 17 (WebCore::RenderBlock::fillBlockSelectionGap): 18 (WebCore::RenderBlock::fillLogicalLeftSelectionGap): 19 (WebCore::RenderBlock::fillLogicalRightSelectionGap): 20 (WebCore::RenderBlock::getSelectionGapInfo): 21 (WebCore::RenderBlock::logicalLeftSelectionOffset): 22 (WebCore::RenderBlock::logicalRightSelectionOffset): 23 * rendering/RenderBlock.h: 24 * rendering/RootInlineBox.cpp: 25 (WebCore::RootInlineBox::fillLineSelectionGap): 26 1 27 2010-11-03 Dimitri Glazkov <dglazkov@chromium.org> 2 28 -
trunk/WebCore/rendering/RenderBlock.cpp
r71177 r71246 2555 2555 2556 2556 int lastTop = 0; 2557 int lastLeft = l eftSelectionOffset(this, lastTop);2558 int lastRight = rightSelectionOffset(this, lastTop);2557 int lastLeft = logicalLeftSelectionOffset(this, lastTop); 2558 int lastRight = logicalRightSelectionOffset(this, lastTop); 2559 2559 2560 2560 return fillSelectionGaps(this, offsetFromRepaintContainer.x(), offsetFromRepaintContainer.y(), offsetFromRepaintContainer.x(), offsetFromRepaintContainer.y(), lastTop, lastLeft, lastRight); … … 2565 2565 if (shouldPaintSelectionGaps() && paintInfo.phase == PaintPhaseForeground) { 2566 2566 int lastTop = 0; 2567 int lastLeft = l eftSelectionOffset(this, lastTop);2568 int lastRight = rightSelectionOffset(this, lastTop);2567 int lastLeft = logicalLeftSelectionOffset(this, lastTop); 2568 int lastRight = logicalRightSelectionOffset(this, lastTop); 2569 2569 paintInfo.context->save(); 2570 2570 IntRect gapRectsBounds = fillSelectionGaps(this, tx, ty, tx, ty, lastTop, lastLeft, lastRight, &paintInfo); … … 2630 2630 // FIXME: We should learn how to gap fill multiple columns and transforms eventually. 2631 2631 lastTop = (ty - blockY) + height(); 2632 lastLeft = l eftSelectionOffset(rootBlock, height());2633 lastRight = rightSelectionOffset(rootBlock, height());2632 lastLeft = logicalLeftSelectionOffset(rootBlock, height()); 2633 lastRight = logicalRightSelectionOffset(rootBlock, height()); 2634 2634 return result; 2635 2635 } … … 2642 2642 // Go ahead and fill the vertical gap all the way to the bottom of our block if the selection extends past our block. 2643 2643 if (rootBlock == this && (selectionState() != SelectionBoth && selectionState() != SelectionEnd)) 2644 result.uniteCenter(fill VerticalSelectionGap(lastTop, lastLeft, lastRight, ty + height(),2645 2644 result.uniteCenter(fillBlockSelectionGap(lastTop, lastLeft, lastRight, ty + height(), 2645 rootBlock, blockX, blockY, paintInfo)); 2646 2646 return result; 2647 2647 } … … 2659 2659 // case. 2660 2660 lastTop = (ty - blockY) + height(); 2661 lastLeft = l eftSelectionOffset(rootBlock, height());2662 lastRight = rightSelectionOffset(rootBlock, height());2661 lastLeft = logicalLeftSelectionOffset(rootBlock, height()); 2662 lastRight = logicalRightSelectionOffset(rootBlock, height()); 2663 2663 } 2664 2664 return result; … … 2676 2676 if (!containsStart && !lastSelectedLine && 2677 2677 selectionState() != SelectionStart && selectionState() != SelectionBoth) 2678 result.uniteCenter(fill VerticalSelectionGap(lastTop, lastLeft, lastRight, ty + selTop,2679 2678 result.uniteCenter(fillBlockSelectionGap(lastTop, lastLeft, lastRight, ty + selTop, 2679 rootBlock, blockX, blockY, paintInfo)); 2680 2680 2681 2681 if (!paintInfo || (ty + selTop < paintInfo->rect.bottom() && ty + selTop + selHeight > paintInfo->rect.y())) … … 2692 2692 // Go ahead and update our lastY to be the bottom of the last selected line. 2693 2693 lastTop = (ty - blockY) + lastSelectedLine->selectionBottom(); 2694 lastLeft = l eftSelectionOffset(rootBlock, lastSelectedLine->selectionBottom());2695 lastRight = rightSelectionOffset(rootBlock, lastSelectedLine->selectionBottom());2694 lastLeft = logicalLeftSelectionOffset(rootBlock, lastSelectedLine->selectionBottom()); 2695 lastRight = logicalRightSelectionOffset(rootBlock, lastSelectedLine->selectionBottom()); 2696 2696 } 2697 2697 return result; … … 2729 2729 if (childState == SelectionEnd || childState == SelectionInside) 2730 2730 // Fill the gap above the object. 2731 result.uniteCenter(fill VerticalSelectionGap(lastTop, lastLeft, lastRight,2732 2731 result.uniteCenter(fillBlockSelectionGap(lastTop, lastLeft, lastRight, 2732 ty + curr->y(), rootBlock, blockX, blockY, paintInfo)); 2733 2733 2734 2734 // Only fill side gaps for objects that paint their own selection if we know for sure the selection is going to extend all the way *past* … … 2739 2739 // Fill side gaps on this object based off its state. 2740 2740 bool leftGap, rightGap; 2741 get HorizontalSelectionGapInfo(childState, leftGap, rightGap);2741 getSelectionGapInfo(childState, leftGap, rightGap); 2742 2742 2743 2743 if (leftGap) 2744 result.uniteLeft(fillL eftSelectionGap(this, curr->x(), curr->y(), curr->height(), rootBlock, blockX, blockY, tx, ty, paintInfo));2744 result.uniteLeft(fillLogicalLeftSelectionGap(this, curr->x(), curr->y(), curr->height(), rootBlock, blockX, blockY, tx, ty, paintInfo)); 2745 2745 if (rightGap) 2746 result.uniteRight(fill RightSelectionGap(this, curr->x() + curr->width(), curr->y(), curr->height(), rootBlock, blockX, blockY, tx, ty, paintInfo));2746 result.uniteRight(fillLogicalRightSelectionGap(this, curr->x() + curr->width(), curr->y(), curr->height(), rootBlock, blockX, blockY, tx, ty, paintInfo)); 2747 2747 2748 2748 // Update lastTop to be just underneath the object. lastLeft and lastRight extend as far as … … 2750 2750 // to the border of the root selection block. 2751 2751 lastTop = (ty - blockY) + (curr->y() + curr->height()); 2752 lastLeft = l eftSelectionOffset(rootBlock, curr->y() + curr->height());2753 lastRight = rightSelectionOffset(rootBlock, curr->y() + curr->height());2752 lastLeft = logicalLeftSelectionOffset(rootBlock, curr->y() + curr->height()); 2753 lastRight = logicalRightSelectionOffset(rootBlock, curr->y() + curr->height()); 2754 2754 } else if (childState != SelectionNone) 2755 2755 // We must be a block that has some selected object inside it. Go ahead and recur. … … 2760 2760 } 2761 2761 2762 IntRect RenderBlock::fill HorizontalSelectionGap(RenderObject* selObj, int xPos, int yPos, int width, int height, const PaintInfo* paintInfo)2762 IntRect RenderBlock::fillLineSelectionGap(RenderObject* selObj, int xPos, int yPos, int width, int height, const PaintInfo* paintInfo) 2763 2763 { 2764 2764 if (width <= 0 || height <= 0) … … 2770 2770 } 2771 2771 2772 IntRect RenderBlock::fill VerticalSelectionGap(int lastTop, int lastLeft, int lastRight, int bottomY, RenderBlock* rootBlock,2773 2772 IntRect RenderBlock::fillBlockSelectionGap(int lastTop, int lastLeft, int lastRight, int bottomY, RenderBlock* rootBlock, 2773 int blockX, int blockY, const PaintInfo* paintInfo) 2774 2774 { 2775 2775 int top = blockY + lastTop; … … 2779 2779 2780 2780 // Get the selection offsets for the bottom of the gap 2781 int left = blockX + max(lastLeft, l eftSelectionOffset(rootBlock, bottomY));2782 int right = blockX + min(lastRight, rightSelectionOffset(rootBlock, bottomY));2781 int left = blockX + max(lastLeft, logicalLeftSelectionOffset(rootBlock, bottomY)); 2782 int right = blockX + min(lastRight, logicalRightSelectionOffset(rootBlock, bottomY)); 2783 2783 int width = right - left; 2784 2784 if (width <= 0) … … 2791 2791 } 2792 2792 2793 IntRect RenderBlock::fillL eftSelectionGap(RenderObject* selObj, int xPos, int yPos, int height, RenderBlock* rootBlock,2794 int blockX, int /*blockY*/, int tx, int ty, const PaintInfo* paintInfo)2793 IntRect RenderBlock::fillLogicalLeftSelectionGap(RenderObject* selObj, int xPos, int yPos, int height, RenderBlock* rootBlock, 2794 int blockX, int /*blockY*/, int tx, int ty, const PaintInfo* paintInfo) 2795 2795 { 2796 2796 int top = yPos + ty; 2797 int left = blockX + max(l eftSelectionOffset(rootBlock, yPos), leftSelectionOffset(rootBlock, yPos + height));2798 int right = min(xPos + tx, blockX + min( rightSelectionOffset(rootBlock, yPos), rightSelectionOffset(rootBlock, yPos + height)));2797 int left = blockX + max(logicalLeftSelectionOffset(rootBlock, yPos), logicalLeftSelectionOffset(rootBlock, yPos + height)); 2798 int right = min(xPos + tx, blockX + min(logicalRightSelectionOffset(rootBlock, yPos), logicalRightSelectionOffset(rootBlock, yPos + height))); 2799 2799 int width = right - left; 2800 2800 if (width <= 0) … … 2807 2807 } 2808 2808 2809 IntRect RenderBlock::fill RightSelectionGap(RenderObject* selObj, int xPos, int yPos, int height, RenderBlock* rootBlock,2810 int blockX, int /*blockY*/, int tx, int ty, const PaintInfo* paintInfo)2811 { 2812 int left = max(xPos + tx, blockX + max(l eftSelectionOffset(rootBlock, yPos), leftSelectionOffset(rootBlock, yPos + height)));2809 IntRect RenderBlock::fillLogicalRightSelectionGap(RenderObject* selObj, int xPos, int yPos, int height, RenderBlock* rootBlock, 2810 int blockX, int /*blockY*/, int tx, int ty, const PaintInfo* paintInfo) 2811 { 2812 int left = max(xPos + tx, blockX + max(logicalLeftSelectionOffset(rootBlock, yPos), logicalLeftSelectionOffset(rootBlock, yPos + height))); 2813 2813 int top = yPos + ty; 2814 int right = blockX + min( rightSelectionOffset(rootBlock, yPos), rightSelectionOffset(rootBlock, yPos + height));2814 int right = blockX + min(logicalRightSelectionOffset(rootBlock, yPos), logicalRightSelectionOffset(rootBlock, yPos + height)); 2815 2815 int width = right - left; 2816 2816 if (width <= 0) … … 2823 2823 } 2824 2824 2825 void RenderBlock::get HorizontalSelectionGapInfo(SelectionState state, bool& leftGap, bool& rightGap)2825 void RenderBlock::getSelectionGapInfo(SelectionState state, bool& leftGap, bool& rightGap) 2826 2826 { 2827 2827 bool ltr = style()->isLeftToRightDirection(); … … 2834 2834 } 2835 2835 2836 int RenderBlock::l eftSelectionOffset(RenderBlock* rootBlock, int yPos)2836 int RenderBlock::logicalLeftSelectionOffset(RenderBlock* rootBlock, int yPos) 2837 2837 { 2838 2838 int left = logicalLeftOffsetForLine(yPos, false); … … 2840 2840 if (rootBlock != this) 2841 2841 // The border can potentially be further extended by our containingBlock(). 2842 return containingBlock()->l eftSelectionOffset(rootBlock, yPos + y());2842 return containingBlock()->logicalLeftSelectionOffset(rootBlock, yPos + y()); 2843 2843 return left; 2844 2844 } … … 2854 2854 } 2855 2855 2856 int RenderBlock:: rightSelectionOffset(RenderBlock* rootBlock, int yPos)2856 int RenderBlock::logicalRightSelectionOffset(RenderBlock* rootBlock, int yPos) 2857 2857 { 2858 2858 int right = logicalRightOffsetForLine(yPos, false); … … 2860 2860 if (rootBlock != this) 2861 2861 // The border can potentially be further extended by our containingBlock(). 2862 return containingBlock()-> rightSelectionOffset(rootBlock, yPos + y());2862 return containingBlock()->logicalRightSelectionOffset(rootBlock, yPos + y()); 2863 2863 return right; 2864 2864 } -
trunk/WebCore/rendering/RenderBlock.h
r70797 r71246 116 116 117 117 GapRects selectionGapRectsForRepaint(RenderBoxModelObject* repaintContainer); 118 IntRect fillL eftSelectionGap(RenderObject* selObj, int xPos, int yPos, int height, RenderBlock* rootBlock,119 int blockX, int blockY, int tx, int ty, const PaintInfo*);120 IntRect fill RightSelectionGap(RenderObject* selObj, int xPos, int yPos, int height, RenderBlock* rootBlock,121 int blockX, int blockY, int tx, int ty, const PaintInfo*);122 IntRect fill HorizontalSelectionGap(RenderObject* selObj, int xPos, int yPos, int width, int height, const PaintInfo*);123 124 void get HorizontalSelectionGapInfo(SelectionState, bool& leftGap, bool& rightGap);118 IntRect fillLogicalLeftSelectionGap(RenderObject* selObj, int xPos, int yPos, int height, RenderBlock* rootBlock, 119 int blockX, int blockY, int tx, int ty, const PaintInfo*); 120 IntRect fillLogicalRightSelectionGap(RenderObject* selObj, int xPos, int yPos, int height, RenderBlock* rootBlock, 121 int blockX, int blockY, int tx, int ty, const PaintInfo*); 122 IntRect fillLineSelectionGap(RenderObject* selObj, int xPos, int yPos, int width, int height, const PaintInfo*); 123 124 void getSelectionGapInfo(SelectionState, bool& leftGap, bool& rightGap); 125 125 126 126 // Helper methods for computing line counts and heights for line counts. … … 538 538 GapRects fillBlockSelectionGaps(RenderBlock* rootBlock, int blockX, int blockY, int tx, int ty, 539 539 int& lastTop, int& lastLeft, int& lastRight, const PaintInfo*); 540 IntRect fill VerticalSelectionGap(int lastTop, int lastLeft, int lastRight, int bottomY, RenderBlock* rootBlock,541 542 int l eftSelectionOffset(RenderBlock* rootBlock, int y);543 int rightSelectionOffset(RenderBlock* rootBlock, int y);540 IntRect fillBlockSelectionGap(int lastTop, int lastLeft, int lastRight, int bottomY, RenderBlock* rootBlock, 541 int blockX, int blockY, const PaintInfo*); 542 int logicalLeftSelectionOffset(RenderBlock* rootBlock, int y); 543 int logicalRightSelectionOffset(RenderBlock* rootBlock, int y); 544 544 545 545 virtual void absoluteRects(Vector<IntRect>&, int tx, int ty); -
trunk/WebCore/rendering/RootInlineBox.cpp
r71055 r71246 250 250 } 251 251 252 GapRects RootInlineBox::fillLineSelectionGap(int selTop, int selHeight, RenderBlock* rootBlock, int blockX, int blockY, int tx, int ty, 253 const PaintInfo* paintInfo) 252 GapRects RootInlineBox::fillLineSelectionGap(int selTop, int selHeight, RenderBlock* rootBlock, int blockX, int blockY, int tx, int ty, const PaintInfo* paintInfo) 254 253 { 255 254 RenderObject::SelectionState lineState = selectionState(); 256 255 257 256 bool leftGap, rightGap; 258 block()->get HorizontalSelectionGapInfo(lineState, leftGap, rightGap);257 block()->getSelectionGapInfo(lineState, leftGap, rightGap); 259 258 260 259 GapRects result; … … 263 262 InlineBox* lastBox = lastSelectedBox(); 264 263 if (leftGap) 265 result.uniteLeft(block()->fillL eftSelectionGap(firstBox->parent()->renderer(),266 firstBox->x(), selTop, selHeight,267 rootBlock, blockX, blockY, tx, ty, paintInfo));264 result.uniteLeft(block()->fillLogicalLeftSelectionGap(firstBox->parent()->renderer(), 265 firstBox->x(), selTop, selHeight, 266 rootBlock, blockX, blockY, tx, ty, paintInfo)); 268 267 if (rightGap) 269 result.uniteRight(block()->fill RightSelectionGap(lastBox->parent()->renderer(),270 lastBox->x() + lastBox->logicalWidth(), selTop, selHeight,271 rootBlock, blockX, blockY, tx, ty, paintInfo));268 result.uniteRight(block()->fillLogicalRightSelectionGap(lastBox->parent()->renderer(), 269 lastBox->x() + lastBox->logicalWidth(), selTop, selHeight, 270 rootBlock, blockX, blockY, tx, ty, paintInfo)); 272 271 273 272 // When dealing with bidi text, a non-contiguous selection region is possible. … … 285 284 if (box->selectionState() != RenderObject::SelectionNone) { 286 285 if (isPreviousBoxSelected) // VisibleSelection may be non-contiguous, see comment above. 287 result.uniteCenter(block()->fill HorizontalSelectionGap(box->parent()->renderer(),288 289 286 result.uniteCenter(block()->fillLineSelectionGap(box->parent()->renderer(), 287 lastX + tx, selTop + ty, 288 box->x() - lastX, selHeight, paintInfo)); 290 289 lastX = box->x() + box->logicalWidth(); 291 290 }
Note: See TracChangeset
for help on using the changeset viewer.