OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. | 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. |
4 * All right reserved. | 4 * All right reserved. |
5 * Copyright (C) 2010 Google Inc. All rights reserved. | 5 * Copyright (C) 2010 Google Inc. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 2381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2392 styleRef(), ellipsisDirection)); | 2392 styleRef(), ellipsisDirection)); |
2393 } | 2393 } |
2394 } | 2394 } |
2395 | 2395 |
2396 // For LTR text truncation, we want to get the right edge of our padding box, | 2396 // For LTR text truncation, we want to get the right edge of our padding box, |
2397 // and then we want to see if the right edge of a line box exceeds that. | 2397 // and then we want to see if the right edge of a line box exceeds that. |
2398 // For RTL, we use the left edge of the padding box and check the left edge of | 2398 // For RTL, we use the left edge of the padding box and check the left edge of |
2399 // the line box to see if it is less Include the scrollbar for overflow | 2399 // the line box to see if it is less Include the scrollbar for overflow |
2400 // blocks, which means we want to use "contentWidth()". | 2400 // blocks, which means we want to use "contentWidth()". |
2401 bool ltr = style()->isLeftToRightDirection(); | 2401 bool ltr = style()->isLeftToRightDirection(); |
2402 ETextAlign textAlign = style()->textAlign(); | |
2403 IndentTextOrNot indentText = IndentText; | 2402 IndentTextOrNot indentText = IndentText; |
2404 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { | 2403 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { |
2405 LayoutUnit currLogicalLeft = curr->logicalLeft(); | 2404 LayoutUnit currLogicalLeft = curr->logicalLeft(); |
2406 LayoutUnit blockRightEdge = | 2405 LayoutUnit blockRightEdge = |
2407 logicalRightOffsetForLine(curr->lineTop(), indentText); | 2406 logicalRightOffsetForLine(curr->lineTop(), indentText); |
2408 LayoutUnit blockLeftEdge = | 2407 LayoutUnit blockLeftEdge = |
2409 logicalLeftOffsetForLine(curr->lineTop(), indentText); | 2408 logicalLeftOffsetForLine(curr->lineTop(), indentText); |
2410 LayoutUnit lineBoxEdge = | 2409 LayoutUnit lineBoxEdge = |
2411 ltr ? currLogicalLeft + curr->logicalWidth() : currLogicalLeft; | 2410 ltr ? currLogicalLeft + curr->logicalWidth() : currLogicalLeft; |
2412 if ((ltr && lineBoxEdge > blockRightEdge) || | 2411 if ((ltr && lineBoxEdge > blockRightEdge) || |
2413 (!ltr && lineBoxEdge < blockLeftEdge)) { | 2412 (!ltr && lineBoxEdge < blockLeftEdge)) { |
2414 // This line spills out of our box in the appropriate direction. Now we | 2413 // This line spills out of our box in the appropriate direction. Now we |
2415 // need to see if the line can be truncated. In order for truncation to | 2414 // need to see if the line can be truncated. In order for truncation to |
2416 // be possible, the line must have sufficient space to accommodate our | 2415 // be possible, the line must have sufficient space to accommodate our |
2417 // truncation string, and no replaced elements (images, tables) can | 2416 // truncation string, and no replaced elements (images, tables) can |
2418 // overlap the ellipsis space. | 2417 // overlap the ellipsis space. |
2419 | 2418 |
2420 LayoutUnit width(indentText == IndentText ? firstLineEllipsisWidth | 2419 LayoutUnit width(indentText == IndentText ? firstLineEllipsisWidth |
2421 : ellipsisWidth); | 2420 : ellipsisWidth); |
2422 LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge; | 2421 LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge; |
2423 if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, | 2422 if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, |
2424 width)) { | 2423 width)) { |
2425 LayoutUnit totalLogicalWidth = curr->placeEllipsis( | 2424 placeEllipsis(curr, blockLeftEdge, blockRightEdge, selectedEllipsisStr, |
2426 selectedEllipsisStr, ltr, blockLeftEdge, blockRightEdge, width); | 2425 width, LayoutUnit(), false); |
2427 LayoutUnit logicalLeft; // We are only interested in the delta from the | 2426 } else { |
2428 // base position. | 2427 tryPlacingEllipsisOnAtomicInlines(curr, blockRightEdge, blockLeftEdge, |
2429 LayoutUnit availableLogicalWidth = blockRightEdge - blockLeftEdge; | 2428 width, selectedEllipsisStr); |
2430 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, | |
2431 totalLogicalWidth, availableLogicalWidth, | |
2432 0); | |
2433 if (ltr) | |
2434 curr->moveInInlineDirection(logicalLeft); | |
2435 else | |
2436 curr->moveInInlineDirection( | |
2437 logicalLeft - (availableLogicalWidth - totalLogicalWidth)); | |
2438 } | 2429 } |
2439 } | 2430 } |
2440 indentText = DoNotIndentText; | 2431 indentText = DoNotIndentText; |
2441 } | 2432 } |
2442 } | 2433 } |
2443 | 2434 |
2435 void LayoutBlockFlow::tryPlacingEllipsisOnAtomicInlines( | |
2436 RootInlineBox* root, | |
2437 LayoutUnit blockRightEdge, | |
2438 LayoutUnit blockLeftEdge, | |
2439 LayoutUnit ellipsisWidth, | |
2440 const AtomicString& selectedEllipsisStr) { | |
2441 bool ltr = style()->isLeftToRightDirection(); | |
2442 LayoutUnit logicalLeftOffset = blockLeftEdge; | |
2443 | |
2444 bool foundBox = false; | |
2445 for (InlineBox* box = ltr ? root->firstChild() : root->lastChild(); box; | |
2446 box = ltr ? box->nextOnLine() : box->prevOnLine()) { | |
2447 if (!box->getLineLayoutItem().isAtomicInlineLevel() || | |
2448 !box->getLineLayoutItem().isLayoutBlockFlow()) | |
2449 continue; | |
2450 | |
2451 RootInlineBox* firstRootBox = | |
2452 LineLayoutBlockFlow(box->getLineLayoutItem()).firstRootBox(); | |
2453 if (!firstRootBox) | |
2454 continue; | |
2455 | |
2456 bool placedEllipsis = false; | |
2457 // Move the right edge of the block in so that we can test it against the | |
2458 // width of the root line boxes. | |
2459 for (RootInlineBox* curr = firstRootBox; curr; curr = curr->nextRootBox()) { | |
eae
2017/02/21 21:55:17
It might be easier to move the ltr check outside o
| |
2460 LayoutUnit currLogicalLeft = logicalLeftOffset + curr->logicalLeft(); | |
2461 LayoutUnit ellipsisEdge = | |
2462 ltr ? currLogicalLeft + curr->logicalWidth() + ellipsisWidth | |
2463 : box->logicalLeft() + curr->logicalLeft() - ellipsisWidth; | |
2464 | |
2465 if ((ltr && ellipsisEdge > blockRightEdge) || | |
2466 (!ltr && ellipsisEdge < blockLeftEdge)) { | |
2467 placeEllipsis( | |
2468 curr, blockLeftEdge, blockRightEdge, selectedEllipsisStr, | |
2469 ellipsisWidth, | |
2470 ltr ? logicalLeftOffset : LayoutUnit(box->logicalLeft().ceil()), | |
2471 foundBox); | |
2472 placedEllipsis = true; | |
2473 } | |
2474 } | |
2475 foundBox |= placedEllipsis; | |
2476 logicalLeftOffset += box->logicalWidth(); | |
2477 } | |
2478 } | |
2479 | |
2480 void LayoutBlockFlow::placeEllipsis(RootInlineBox* curr, | |
2481 LayoutUnit blockLeftEdge, | |
2482 LayoutUnit blockRightEdge, | |
2483 const AtomicString& selectedEllipsisStr, | |
2484 LayoutUnit ellipsisWidth, | |
2485 LayoutUnit logicalLeftOffset, | |
2486 bool foundBox) { | |
2487 bool ltr = style()->isLeftToRightDirection(); | |
2488 ETextAlign textAlign = style()->textAlign(); | |
2489 LayoutUnit totalLogicalWidth = curr->placeEllipsis( | |
2490 selectedEllipsisStr, ltr, blockLeftEdge, blockRightEdge, ellipsisWidth, | |
2491 logicalLeftOffset, foundBox); | |
2492 LayoutUnit logicalLeft; | |
2493 LayoutUnit availableLogicalWidth = blockRightEdge - blockLeftEdge; | |
2494 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, | |
2495 totalLogicalWidth, availableLogicalWidth, 0); | |
2496 if (ltr) { | |
2497 curr->moveInInlineDirection(logicalLeft); | |
2498 } else { | |
2499 curr->moveInInlineDirection(logicalLeft - | |
2500 (availableLogicalWidth - totalLogicalWidth)); | |
eae
2017/02/21 21:55:17
What happens if totalLogicalWidth is more than ava
| |
2501 } | |
2502 } | |
2503 | |
2444 void LayoutBlockFlow::markLinesDirtyInBlockRange(LayoutUnit logicalTop, | 2504 void LayoutBlockFlow::markLinesDirtyInBlockRange(LayoutUnit logicalTop, |
2445 LayoutUnit logicalBottom, | 2505 LayoutUnit logicalBottom, |
2446 RootInlineBox* highest) { | 2506 RootInlineBox* highest) { |
2447 if (logicalTop >= logicalBottom) | 2507 if (logicalTop >= logicalBottom) |
2448 return; | 2508 return; |
2449 | 2509 |
2450 RootInlineBox* lowestDirtyLine = lastRootBox(); | 2510 RootInlineBox* lowestDirtyLine = lastRootBox(); |
2451 RootInlineBox* afterLowest = lowestDirtyLine; | 2511 RootInlineBox* afterLowest = lowestDirtyLine; |
2452 while (lowestDirtyLine && | 2512 while (lowestDirtyLine && |
2453 lowestDirtyLine->lineBottomWithLeading() >= logicalBottom && | 2513 lowestDirtyLine->lineBottomWithLeading() >= logicalBottom && |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2512 | 2572 |
2513 bool LayoutBlockFlow::paintedOutputOfObjectHasNoEffectRegardlessOfSize() const { | 2573 bool LayoutBlockFlow::paintedOutputOfObjectHasNoEffectRegardlessOfSize() const { |
2514 // LayoutBlockFlow is in charge of paint invalidation of the first line. | 2574 // LayoutBlockFlow is in charge of paint invalidation of the first line. |
2515 if (firstLineBox()) | 2575 if (firstLineBox()) |
2516 return false; | 2576 return false; |
2517 | 2577 |
2518 return LayoutBlock::paintedOutputOfObjectHasNoEffectRegardlessOfSize(); | 2578 return LayoutBlock::paintedOutputOfObjectHasNoEffectRegardlessOfSize(); |
2519 } | 2579 } |
2520 | 2580 |
2521 } // namespace blink | 2581 } // namespace blink |
OLD | NEW |