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

Side by Side Diff: third_party/WebKit/Source/core/layout/line/RootInlineBox.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) 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 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 return LayoutUnit(); 723 return LayoutUnit();
724 724
725 LineLayoutItem parent = boxModel.parent(); 725 LineLayoutItem parent = boxModel.parent();
726 if (parent.isLayoutInline() && 726 if (parent.isLayoutInline() &&
727 parent.style()->verticalAlign() != VerticalAlignTop && 727 parent.style()->verticalAlign() != VerticalAlignTop &&
728 parent.style()->verticalAlign() != VerticalAlignBottom) 728 parent.style()->verticalAlign() != VerticalAlignBottom)
729 verticalPosition = box->parent()->logicalTop(); 729 verticalPosition = box->parent()->logicalTop();
730 730
731 if (verticalAlign != VerticalAlignBaseline) { 731 if (verticalAlign != VerticalAlignBaseline) {
732 const Font& font = parent.style(firstLine)->font(); 732 const Font& font = parent.style(firstLine)->font();
733 const FontMetrics& fontMetrics = font.getFontMetrics(); 733 const SimpleFontData* fontData = font.primaryFont();
734 DCHECK(fontData);
735 if (!fontData)
736 return LayoutUnit();
737
738 const FontMetrics& fontMetrics = fontData->getFontMetrics();
734 int fontSize = font.getFontDescription().computedPixelSize(); 739 int fontSize = font.getFontDescription().computedPixelSize();
735 740
736 LineDirectionMode lineDirection = 741 LineDirectionMode lineDirection =
737 parent.isHorizontalWritingMode() ? HorizontalLine : VerticalLine; 742 parent.isHorizontalWritingMode() ? HorizontalLine : VerticalLine;
738 743
739 if (verticalAlign == VerticalAlignSub) { 744 if (verticalAlign == VerticalAlignSub) {
740 verticalPosition += fontSize / 5 + 1; 745 verticalPosition += fontSize / 5 + 1;
741 } else if (verticalAlign == VerticalAlignSuper) { 746 } else if (verticalAlign == VerticalAlignSuper) {
742 verticalPosition -= fontSize / 3 + 1; 747 verticalPosition -= fontSize / 3 + 1;
743 } else if (verticalAlign == VerticalAlignTextTop) { 748 } else if (verticalAlign == VerticalAlignTextTop) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 } 818 }
814 endBox = nullptr; 819 endBox = nullptr;
815 return nullptr; 820 return nullptr;
816 } 821 }
817 822
818 const char* RootInlineBox::boxName() const { 823 const char* RootInlineBox::boxName() const {
819 return "RootInlineBox"; 824 return "RootInlineBox";
820 } 825 }
821 826
822 } // namespace blink 827 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698