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

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

Issue 2345633007: Don't overflow in LayoutText::width() on a huge length. (Closed)
Patch Set: Tweak test ranges for Mac results. Created 4 years, 3 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 1557 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 } 1568 }
1569 1569
1570 m_containsReversedText |= !s->isLeftToRightDirection(); 1570 m_containsReversedText |= !s->isLeftToRightDirection();
1571 } 1571 }
1572 1572
1573 float LayoutText::width(unsigned from, unsigned len, LayoutUnit xPos, TextDirect ion textDirection, bool firstLine, HashSet<const SimpleFontData*>* fallbackFonts , FloatRect* glyphBounds) const 1573 float LayoutText::width(unsigned from, unsigned len, LayoutUnit xPos, TextDirect ion textDirection, bool firstLine, HashSet<const SimpleFontData*>* fallbackFonts , FloatRect* glyphBounds) const
1574 { 1574 {
1575 if (from >= textLength()) 1575 if (from >= textLength())
1576 return 0; 1576 return 0;
1577 1577
1578 if (from + len > textLength()) 1578 if (len > textLength() || from + len > textLength())
1579 len = textLength() - from; 1579 len = textLength() - from;
1580 1580
1581 return width(from, len, style(firstLine)->font(), xPos, textDirection, fallb ackFonts, glyphBounds); 1581 return width(from, len, style(firstLine)->font(), xPos, textDirection, fallb ackFonts, glyphBounds);
1582 } 1582 }
1583 1583
1584 float LayoutText::width(unsigned from, unsigned len, const Font& f, LayoutUnit x Pos, TextDirection textDirection, HashSet<const SimpleFontData*>* fallbackFonts, FloatRect* glyphBounds) const 1584 float LayoutText::width(unsigned from, unsigned len, const Font& f, LayoutUnit x Pos, TextDirection textDirection, HashSet<const SimpleFontData*>* fallbackFonts, FloatRect* glyphBounds) const
1585 { 1585 {
1586 ASSERT(from + len <= textLength()); 1586 ASSERT(from + len <= textLength());
1587 if (!textLength()) 1587 if (!textLength())
1588 return 0; 1588 return 0;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1809 LayoutRect rect = 1809 LayoutRect rect =
1810 LayoutRect(IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox. height())); 1810 LayoutRect(IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox. height()));
1811 LayoutBlock* block = containingBlock(); 1811 LayoutBlock* block = containingBlock();
1812 if (block && hasTextBoxes()) 1812 if (block && hasTextBoxes())
1813 block->adjustChildDebugRect(rect); 1813 block->adjustChildDebugRect(rect);
1814 1814
1815 return rect; 1815 return rect;
1816 } 1816 }
1817 1817
1818 } // namespace blink 1818 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/BUILD.gn ('k') | third_party/WebKit/Source/core/layout/LayoutTextTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698