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

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

Issue 2797423005: Always use original ascent/descent for FontMetrics::floatAscent|floatDescent (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1939 matching lines...) Expand 10 before | Expand all | Expand 10 after
1950 LayoutRect logicalVisualOverflow = curr->logicalOverflowRect(); 1950 LayoutRect logicalVisualOverflow = curr->logicalOverflowRect();
1951 logicalLeftSide = std::min(logicalLeftSide, logicalVisualOverflow.x()); 1951 logicalLeftSide = std::min(logicalLeftSide, logicalVisualOverflow.x());
1952 logicalRightSide = std::max(logicalRightSide, logicalVisualOverflow.maxX()); 1952 logicalRightSide = std::max(logicalRightSide, logicalVisualOverflow.maxX());
1953 } 1953 }
1954 1954
1955 LayoutUnit logicalTop = firstTextBox()->logicalTopVisualOverflow(); 1955 LayoutUnit logicalTop = firstTextBox()->logicalTopVisualOverflow();
1956 LayoutUnit logicalWidth = logicalRightSide - logicalLeftSide; 1956 LayoutUnit logicalWidth = logicalRightSide - logicalLeftSide;
1957 LayoutUnit logicalHeight = 1957 LayoutUnit logicalHeight =
1958 lastTextBox()->logicalBottomVisualOverflow() - logicalTop; 1958 lastTextBox()->logicalBottomVisualOverflow() - logicalTop;
1959 1959
1960 // Inflate visual overflow if we have adjusted ascent/descent causing the 1960 // Inflate visual overflow if we have rounded down ascent/descent causing the
1961 // painted glyphs to overflow the layout geometries based on the adjusted 1961 // painted glyphs to overflow the layout geometries based on the rounded down
1962 // ascent/descent. 1962 // ascent/descent.
1963 int inflationForAscent = 0; 1963 int inflationForAscent = 0;
1964 int inflationForDescent = 0; 1964 int inflationForDescent = 0;
1965 const auto* font = 1965 const auto* font =
1966 styleRef(firstTextBox()->isFirstLineStyle()).font().primaryFont(); 1966 styleRef(firstTextBox()->isFirstLineStyle()).font().primaryFont();
1967 if (font) { 1967 if (font &&
1968 inflationForAscent = 1968 font->getFontMetrics().ascent() < font->getFontMetrics().floatAscent())
1969 font->getFontMetrics().visualOverflowInflationForAscent(); 1969 inflationForAscent = 1;
1970 }
1971 if (lastTextBox()->isFirstLineStyle() != firstTextBox()->isFirstLineStyle()) 1970 if (lastTextBox()->isFirstLineStyle() != firstTextBox()->isFirstLineStyle())
1972 font = styleRef(lastTextBox()->isFirstLineStyle()).font().primaryFont(); 1971 font = styleRef(lastTextBox()->isFirstLineStyle()).font().primaryFont();
1973 if (font) { 1972 if (font &&
1974 inflationForDescent = 1973 font->getFontMetrics().descent() < font->getFontMetrics().floatDescent())
1975 font->getFontMetrics().visualOverflowInflationForDescent(); 1974 inflationForDescent = 1;
1976 }
1977 logicalTop -= inflationForAscent; 1975 logicalTop -= inflationForAscent;
1978 logicalHeight += inflationForAscent + inflationForDescent; 1976 logicalHeight += inflationForAscent + inflationForDescent;
1979 1977
1980 LayoutRect rect(logicalLeftSide, logicalTop, logicalWidth, logicalHeight); 1978 LayoutRect rect(logicalLeftSide, logicalTop, logicalWidth, logicalHeight);
1981 if (!style()->isHorizontalWritingMode()) 1979 if (!style()->isHorizontalWritingMode())
1982 rect = rect.transposedRect(); 1980 rect = rect.transposedRect();
1983 return rect; 1981 return rect;
1984 } 1982 }
1985 1983
1986 LayoutRect LayoutText::localVisualRect() const { 1984 LayoutRect LayoutText::localVisualRect() const {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
2112 LayoutRect rect = LayoutRect( 2110 LayoutRect rect = LayoutRect(
2113 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height())); 2111 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height()));
2114 LayoutBlock* block = containingBlock(); 2112 LayoutBlock* block = containingBlock();
2115 if (block && hasTextBoxes()) 2113 if (block && hasTextBoxes())
2116 block->adjustChildDebugRect(rect); 2114 block->adjustChildDebugRect(rect);
2117 2115
2118 return rect; 2116 return rect;
2119 } 2117 }
2120 2118
2121 } // namespace blink 2119 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698