Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: third_party/WebKit/Source/core/layout/line/RootInlineBox.cpp

Issue 1642223002: Delete selection gap code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Integrate feedback. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 return result; 272 return result;
273 273
274 // We have to compute the expansion for annotations over the previous li ne to see how much we should move. 274 // We have to compute the expansion for annotations over the previous li ne to see how much we should move.
275 LayoutUnit lowestAllowedPosition = std::max(prevRootBox()->lineBottom(), lineTop()) - result; 275 LayoutUnit lowestAllowedPosition = std::max(prevRootBox()->lineBottom(), lineTop()) - result;
276 result = prevRootBox()->computeOverAnnotationAdjustment(lowestAllowedPos ition); 276 result = prevRootBox()->computeOverAnnotationAdjustment(lowestAllowedPos ition);
277 } 277 }
278 278
279 return result; 279 return result;
280 } 280 }
281 281
282 GapRects RootInlineBox::lineSelectionGap(const LayoutBlock* rootBlock, const Lay outPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, Layo utUnit selTop, LayoutUnit selHeight, const PaintInfo* paintInfo) const
283 {
284 SelectionState lineState = selectionState();
285
286 bool leftGap, rightGap;
287 block().getSelectionGapInfo(lineState, leftGap, rightGap);
288
289 GapRects result;
290
291 InlineBox* firstBox = firstSelectedBox();
292 InlineBox* lastBox = lastSelectedBox();
293 if (leftGap) {
294 result.uniteLeft(block().logicalLeftSelectionGap(rootBlock, rootBlockPhy sicalPosition, offsetFromRootBlock,
295 firstBox->parent()->lineLayoutItem(), firstBox->logicalLeft(), selTo p, selHeight, paintInfo));
296 }
297 if (rightGap) {
298 result.uniteRight(block().logicalRightSelectionGap(rootBlock, rootBlockP hysicalPosition, offsetFromRootBlock,
299 lastBox->parent()->lineLayoutItem(), lastBox->logicalRight(), selTop , selHeight, paintInfo));
300 }
301
302 // When dealing with bidi text, a non-contiguous selection region is possibl e.
303 // e.g. The logical text aaaAAAbbb (capitals denote RTL text and non-capital s LTR) is laid out
304 // visually as 3 text runs |aaa|bbb|AAA| if we select 4 characters from the start of the text the
305 // selection will look like (underline denotes selection):
306 // |aaa|bbb|AAA|
307 // ___ _
308 // We can see that the |bbb| run is not part of the selection while the runs around it are.
309 if (firstBox && firstBox != lastBox) {
310 // Now fill in any gaps on the line that occurred between two selected e lements.
311 LayoutUnit lastLogicalLeft = firstBox->logicalRight();
312 bool isPreviousBoxSelected = firstBox->selectionState() != SelectionNone ;
313 for (InlineBox* box = firstBox->nextLeafChild(); box; box = box->nextLea fChild()) {
314 if (box->selectionState() != SelectionNone) {
315 LayoutRect logicalRect(lastLogicalLeft, selTop, box->logicalLeft () - lastLogicalLeft, selHeight);
316 logicalRect.move(lineLayoutItem().isHorizontalWritingMode() ? of fsetFromRootBlock : LayoutSize(offsetFromRootBlock.height(), offsetFromRootBlock .width()));
317 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBl ockPhysicalPosition, logicalRect);
318 if (isPreviousBoxSelected && gapRect.width() > 0 && gapRect.heig ht() > 0) {
319 if (paintInfo && box->parent()->lineLayoutItem().style()->vi sibility() == VISIBLE)
320 paintInfo->context.fillRect(FloatRect(gapRect), box->par ent()->lineLayoutItem().selectionBackgroundColor());
321 // VisibleSelection may be non-contiguous, see comment above .
322 result.uniteCenter(gapRect);
323 }
324 lastLogicalLeft = box->logicalRight();
325 }
326 if (box == lastBox)
327 break;
328 isPreviousBoxSelected = box->selectionState() != SelectionNone;
329 }
330 }
331
332 return result;
333 }
334
335 SelectionState RootInlineBox::selectionState() const 282 SelectionState RootInlineBox::selectionState() const
336 { 283 {
337 // Walk over all of the selected boxes. 284 // Walk over all of the selected boxes.
338 SelectionState state = SelectionNone; 285 SelectionState state = SelectionNone;
339 for (InlineBox* box = firstLeafChild(); box; box = box->nextLeafChild()) { 286 for (InlineBox* box = firstLeafChild(); box; box = box->nextLeafChild()) {
340 SelectionState boxState = box->selectionState(); 287 SelectionState boxState = box->selectionState();
341 if ((boxState == SelectionStart && state == SelectionEnd) 288 if ((boxState == SelectionStart && state == SelectionEnd)
342 || (boxState == SelectionEnd && state == SelectionStart)) { 289 || (boxState == SelectionEnd && state == SelectionStart)) {
343 state = SelectionBoth; 290 state = SelectionBoth;
344 } else if (state == SelectionNone || ((boxState == SelectionStart || box State == SelectionEnd) && (state == SelectionNone || state == SelectionInside))) { 291 } else if (state == SelectionNone || ((boxState == SelectionStart || box State == SelectionEnd) && (state == SelectionNone || state == SelectionInside))) {
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 endBox = nullptr; 700 endBox = nullptr;
754 return nullptr; 701 return nullptr;
755 } 702 }
756 703
757 const char* RootInlineBox::boxName() const 704 const char* RootInlineBox::boxName() const
758 { 705 {
759 return "RootInlineBox"; 706 return "RootInlineBox";
760 } 707 }
761 708
762 } // namespace blink 709 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/line/RootInlineBox.h ('k') | third_party/WebKit/Source/core/paint/BlockFlowPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698