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

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

Issue 1922223003: Change linesBoundingBox to return LayoutRect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Dirk Mueller (mueller@kde.org) 3 * (C) 2000 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after
1514 ASSERT(run.charactersLength() >= run.length()); 1514 ASSERT(run.charactersLength() >= run.length());
1515 1515
1516 run.setTabSize(!style()->collapseWhiteSpace(), style()->getTabSize()); 1516 run.setTabSize(!style()->collapseWhiteSpace(), style()->getTabSize());
1517 run.setXPos(xPos.toFloat()); 1517 run.setXPos(xPos.toFloat());
1518 w = f.width(run, fallbackFonts, glyphBounds); 1518 w = f.width(run, fallbackFonts, glyphBounds);
1519 } 1519 }
1520 1520
1521 return w; 1521 return w;
1522 } 1522 }
1523 1523
1524 IntRect LayoutText::linesBoundingBox() const 1524 LayoutRect LayoutText::linesBoundingBox() const
1525 { 1525 {
1526 IntRect result; 1526 LayoutRect result;
1527 1527
1528 ASSERT(!firstTextBox() == !lastTextBox()); // Either both are null or both e xist. 1528 ASSERT(!firstTextBox() == !lastTextBox()); // Either both are null or both e xist.
1529 if (firstTextBox() && lastTextBox()) { 1529 if (firstTextBox() && lastTextBox()) {
1530 // Return the width of the minimal left side and the maximal right side. 1530 // Return the width of the minimal left side and the maximal right side.
1531 float logicalLeftSide = 0; 1531 float logicalLeftSide = 0;
1532 float logicalRightSide = 0; 1532 float logicalRightSide = 0;
1533 for (InlineTextBox* curr = firstTextBox(); curr; curr = curr->nextTextBo x()) { 1533 for (InlineTextBox* curr = firstTextBox(); curr; curr = curr->nextTextBo x()) {
1534 if (curr == firstTextBox() || curr->logicalLeft() < logicalLeftSide) 1534 if (curr == firstTextBox() || curr->logicalLeft() < logicalLeftSide)
1535 logicalLeftSide = curr->logicalLeft().toFloat(); 1535 logicalLeftSide = curr->logicalLeft().toFloat();
1536 if (curr == firstTextBox() || curr->logicalRight() > logicalRightSid e) 1536 if (curr == firstTextBox() || curr->logicalRight() > logicalRightSid e)
1537 logicalRightSide = curr->logicalRight().toFloat(); 1537 logicalRightSide = curr->logicalRight().toFloat();
1538 } 1538 }
1539 1539
1540 bool isHorizontal = style()->isHorizontalWritingMode(); 1540 bool isHorizontal = style()->isHorizontalWritingMode();
1541 1541
1542 float x = isHorizontal ? logicalLeftSide : firstTextBox()->x().toFloat() ; 1542 float x = isHorizontal ? logicalLeftSide : firstTextBox()->x().toFloat() ;
1543 float y = isHorizontal ? firstTextBox()->y().toFloat() : logicalLeftSide ; 1543 float y = isHorizontal ? firstTextBox()->y().toFloat() : logicalLeftSide ;
1544 float width = isHorizontal ? logicalRightSide - logicalLeftSide : lastTe xtBox()->logicalBottom() - x; 1544 float width = isHorizontal ? logicalRightSide - logicalLeftSide : lastTe xtBox()->logicalBottom() - x;
1545 float height = isHorizontal ? lastTextBox()->logicalBottom() - y : logic alRightSide - logicalLeftSide; 1545 float height = isHorizontal ? lastTextBox()->logicalBottom() - y : logic alRightSide - logicalLeftSide;
1546 result = enclosingIntRect(FloatRect(x, y, width, height)); 1546 result = enclosingLayoutRect(FloatRect(x, y, width, height));
1547 } 1547 }
1548 1548
1549 return result; 1549 return result;
1550 } 1550 }
1551 1551
1552 LayoutRect LayoutText::visualOverflowRect() const 1552 LayoutRect LayoutText::visualOverflowRect() const
1553 { 1553 {
1554 if (!firstTextBox()) 1554 if (!firstTextBox())
1555 return LayoutRect(); 1555 return LayoutRect();
1556 1556
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) { 1699 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) {
1700 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box, in validationReason); 1700 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box, in validationReason);
1701 if (box->truncation() != cNoTruncation) { 1701 if (box->truncation() != cNoTruncation) {
1702 if (EllipsisBox* ellipsisBox = box->root().ellipsisBox()) 1702 if (EllipsisBox* ellipsisBox = box->root().ellipsisBox())
1703 paintInvalidationContainer.invalidateDisplayItemClientOnBacking( *ellipsisBox, invalidationReason); 1703 paintInvalidationContainer.invalidateDisplayItemClientOnBacking( *ellipsisBox, invalidationReason);
1704 } 1704 }
1705 } 1705 }
1706 } 1706 }
1707 1707
1708 } // namespace blink 1708 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutText.h ('k') | third_party/WebKit/Source/core/layout/LayoutTreeAsText.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698