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

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

Issue 2416033003: Remove unsafe getFontMetrics methods (Closed)
Patch Set: Address wkroman suggestions Created 4 years, 2 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) 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 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 // measured width to 0 and adjust glyph bounds accordingly to cover the 614 // measured width to 0 and adjust glyph bounds accordingly to cover the
615 // overflow. 615 // overflow.
616 if (measuredWidth < 0) { 616 if (measuredWidth < 0) {
617 if (measuredWidth < glyphBounds.x()) { 617 if (measuredWidth < glyphBounds.x()) {
618 glyphBounds.expand(glyphBounds.x() - measuredWidth, 0); 618 glyphBounds.expand(glyphBounds.x() - measuredWidth, 0);
619 glyphBounds.setX(measuredWidth); 619 glyphBounds.setX(measuredWidth);
620 } 620 }
621 measuredWidth = 0; 621 measuredWidth = 0;
622 } 622 }
623 623
624 glyphOverflow.setFromBounds(glyphBounds, font.getFontMetrics().floatAscent(), 624 const SimpleFontData* fontData = font.primaryFont();
625 font.getFontMetrics().floatDescent(), 625 DCHECK(fontData);
626 measuredWidth); 626 glyphOverflow.setFromBounds(
627 glyphBounds, fontData ? fontData->getFontMetrics().floatAscent() : 0,
628 fontData ? fontData->getFontMetrics().floatDescent() : 0, measuredWidth);
627 629
628 run->m_box->setLogicalWidth(LayoutUnit(measuredWidth) + hyphenWidth); 630 run->m_box->setLogicalWidth(LayoutUnit(measuredWidth) + hyphenWidth);
629 if (!fallbackFonts.isEmpty()) { 631 if (!fallbackFonts.isEmpty()) {
630 ASSERT(run->m_box->isText()); 632 ASSERT(run->m_box->isText());
631 GlyphOverflowAndFallbackFontsMap::ValueType* it = 633 GlyphOverflowAndFallbackFontsMap::ValueType* it =
632 textBoxDataMap 634 textBoxDataMap
633 .add(toInlineTextBox(run->m_box), 635 .add(toInlineTextBox(run->m_box),
634 std::make_pair(Vector<const SimpleFontData*>(), 636 std::make_pair(Vector<const SimpleFontData*>(),
635 GlyphOverflow())) 637 GlyphOverflow()))
636 .storedValue; 638 .storedValue;
(...skipping 1874 matching lines...) Expand 10 before | Expand all | Expand 10 after
2511 2513
2512 bool LayoutBlockFlow::paintedOutputOfObjectHasNoEffectRegardlessOfSize() const { 2514 bool LayoutBlockFlow::paintedOutputOfObjectHasNoEffectRegardlessOfSize() const {
2513 // LayoutBlockFlow is in charge of paint invalidation of the first line. 2515 // LayoutBlockFlow is in charge of paint invalidation of the first line.
2514 if (firstLineBox()) 2516 if (firstLineBox())
2515 return false; 2517 return false;
2516 2518
2517 return LayoutBlock::paintedOutputOfObjectHasNoEffectRegardlessOfSize(); 2519 return LayoutBlock::paintedOutputOfObjectHasNoEffectRegardlessOfSize();
2518 } 2520 }
2519 2521
2520 } // namespace blink 2522 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698