OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 // as layout overflow. This rectangle must include transforms and relative | 1154 // as layout overflow. This rectangle must include transforms and relative |
1155 // positioning and be adjusted for writing-mode differences. | 1155 // positioning and be adjusted for writing-mode differences. |
1156 LayoutRect childLogicalLayoutOverflow = | 1156 LayoutRect childLogicalLayoutOverflow = |
1157 box.logicalLayoutOverflowRectForPropagation( | 1157 box.logicalLayoutOverflowRectForPropagation( |
1158 getLineLayoutItem().styleRef()); | 1158 getLineLayoutItem().styleRef()); |
1159 childLogicalLayoutOverflow.move(inlineBox->logicalLeft(), | 1159 childLogicalLayoutOverflow.move(inlineBox->logicalLeft(), |
1160 inlineBox->logicalTop()); | 1160 inlineBox->logicalTop()); |
1161 logicalLayoutOverflow.unite(childLogicalLayoutOverflow); | 1161 logicalLayoutOverflow.unite(childLogicalLayoutOverflow); |
1162 } | 1162 } |
1163 | 1163 |
| 1164 static void computeGlyphOverflow( |
| 1165 InlineTextBox* text, |
| 1166 const LineLayoutText& layoutText, |
| 1167 GlyphOverflowAndFallbackFontsMap& textBoxDataMap) { |
| 1168 HashSet<const SimpleFontData*> fallbackFonts; |
| 1169 FloatRect glyphBounds; |
| 1170 GlyphOverflow glyphOverflow; |
| 1171 float measuredWidth = |
| 1172 layoutText.width(text->start(), text->len(), LayoutUnit(), |
| 1173 text->direction(), false, &fallbackFonts, &glyphBounds); |
| 1174 const Font& font = layoutText.style()->font(); |
| 1175 const SimpleFontData* fontData = font.primaryFont(); |
| 1176 DCHECK(fontData); |
| 1177 glyphOverflow.setFromBounds( |
| 1178 glyphBounds, fontData ? fontData->getFontMetrics().floatAscent() : 0, |
| 1179 fontData ? fontData->getFontMetrics().floatDescent() : 0, measuredWidth); |
| 1180 if (!fallbackFonts.isEmpty()) { |
| 1181 GlyphOverflowAndFallbackFontsMap::ValueType* it = |
| 1182 textBoxDataMap |
| 1183 .insert(text, std::make_pair(Vector<const SimpleFontData*>(), |
| 1184 GlyphOverflow())) |
| 1185 .storedValue; |
| 1186 DCHECK(it->value.first.isEmpty()); |
| 1187 copyToVector(fallbackFonts, it->value.first); |
| 1188 } |
| 1189 if (!glyphOverflow.isApproximatelyZero()) { |
| 1190 GlyphOverflowAndFallbackFontsMap::ValueType* it = |
| 1191 textBoxDataMap |
| 1192 .insert(text, std::make_pair(Vector<const SimpleFontData*>(), |
| 1193 GlyphOverflow())) |
| 1194 .storedValue; |
| 1195 it->value.second = glyphOverflow; |
| 1196 } |
| 1197 } |
| 1198 |
1164 void InlineFlowBox::computeOverflow( | 1199 void InlineFlowBox::computeOverflow( |
1165 LayoutUnit lineTop, | 1200 LayoutUnit lineTop, |
1166 LayoutUnit lineBottom, | 1201 LayoutUnit lineBottom, |
1167 GlyphOverflowAndFallbackFontsMap& textBoxDataMap) { | 1202 GlyphOverflowAndFallbackFontsMap& textBoxDataMap) { |
1168 // If we know we have no overflow, we can just bail. | 1203 // If we know we have no overflow, we can just bail. |
1169 if (knownToHaveNoOverflow()) { | 1204 if (knownToHaveNoOverflow()) { |
1170 ASSERT(!m_overflow); | 1205 ASSERT(!m_overflow); |
1171 return; | 1206 return; |
1172 } | 1207 } |
1173 | 1208 |
(...skipping 15 matching lines...) Expand all Loading... |
1189 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { | 1224 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { |
1190 if (curr->getLineLayoutItem().isOutOfFlowPositioned()) | 1225 if (curr->getLineLayoutItem().isOutOfFlowPositioned()) |
1191 continue; // Positioned placeholders don't affect calculations. | 1226 continue; // Positioned placeholders don't affect calculations. |
1192 | 1227 |
1193 if (curr->getLineLayoutItem().isText()) { | 1228 if (curr->getLineLayoutItem().isText()) { |
1194 InlineTextBox* text = toInlineTextBox(curr); | 1229 InlineTextBox* text = toInlineTextBox(curr); |
1195 LineLayoutText rt = text->getLineLayoutItem(); | 1230 LineLayoutText rt = text->getLineLayoutItem(); |
1196 if (rt.isBR()) | 1231 if (rt.isBR()) |
1197 continue; | 1232 continue; |
1198 LayoutRect textBoxOverflow(text->logicalFrameRect()); | 1233 LayoutRect textBoxOverflow(text->logicalFrameRect()); |
1199 addTextBoxVisualOverflow(text, textBoxDataMap, textBoxOverflow); | 1234 if (textBoxDataMap.isEmpty()) { |
| 1235 // An empty glyph map means that we're computing overflow without |
| 1236 // a layout, so calculate the glyph overflow on the fly. |
| 1237 GlyphOverflowAndFallbackFontsMap glyphOverflowForText; |
| 1238 computeGlyphOverflow(text, rt, glyphOverflowForText); |
| 1239 addTextBoxVisualOverflow(text, glyphOverflowForText, textBoxOverflow); |
| 1240 } else { |
| 1241 addTextBoxVisualOverflow(text, textBoxDataMap, textBoxOverflow); |
| 1242 } |
1200 logicalVisualOverflow.unite(textBoxOverflow); | 1243 logicalVisualOverflow.unite(textBoxOverflow); |
1201 } else if (curr->getLineLayoutItem().isLayoutInline()) { | 1244 } else if (curr->getLineLayoutItem().isLayoutInline()) { |
1202 InlineFlowBox* flow = toInlineFlowBox(curr); | 1245 InlineFlowBox* flow = toInlineFlowBox(curr); |
1203 flow->computeOverflow(lineTop, lineBottom, textBoxDataMap); | 1246 flow->computeOverflow(lineTop, lineBottom, textBoxDataMap); |
1204 if (!flow->boxModelObject().hasSelfPaintingLayer()) | 1247 if (!flow->boxModelObject().hasSelfPaintingLayer()) |
1205 logicalVisualOverflow.unite( | 1248 logicalVisualOverflow.unite( |
1206 flow->logicalVisualOverflowRect(lineTop, lineBottom)); | 1249 flow->logicalVisualOverflowRect(lineTop, lineBottom)); |
1207 LayoutRect childLayoutOverflow = | 1250 LayoutRect childLayoutOverflow = |
1208 flow->logicalLayoutOverflowRect(lineTop, lineBottom); | 1251 flow->logicalLayoutOverflowRect(lineTop, lineBottom); |
1209 childLayoutOverflow.move( | 1252 childLayoutOverflow.move( |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1689 ASSERT(child->prevOnLine() == prev); | 1732 ASSERT(child->prevOnLine() == prev); |
1690 prev = child; | 1733 prev = child; |
1691 } | 1734 } |
1692 ASSERT(prev == m_lastChild); | 1735 ASSERT(prev == m_lastChild); |
1693 #endif | 1736 #endif |
1694 } | 1737 } |
1695 | 1738 |
1696 #endif | 1739 #endif |
1697 | 1740 |
1698 } // namespace blink | 1741 } // namespace blink |
OLD | NEW |