| OLD | NEW |
| 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. All r
ight reserved. | 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ight reserved. |
| 4 * Copyright (C) 2010 Google Inc. All rights reserved. | 4 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 // Chromium-mac. https://bugs.webkit.org/show_bug.cgi?id=113418 | 391 // Chromium-mac. https://bugs.webkit.org/show_bug.cgi?id=113418 |
| 392 bool canUseSimpleFontCodePath = layoutText->canUseSimpleFontCodePath() && !f
ont.fontDescription().featureSettings(); | 392 bool canUseSimpleFontCodePath = layoutText->canUseSimpleFontCodePath() && !f
ont.fontDescription().featureSettings(); |
| 393 #else | 393 #else |
| 394 bool canUseSimpleFontCodePath = layoutText->canUseSimpleFontCodePath(); | 394 bool canUseSimpleFontCodePath = layoutText->canUseSimpleFontCodePath(); |
| 395 #endif | 395 #endif |
| 396 | 396 |
| 397 if (canUseSimpleFontCodePath) { | 397 if (canUseSimpleFontCodePath) { |
| 398 int lastEndOffset = run->m_start; | 398 int lastEndOffset = run->m_start; |
| 399 for (size_t i = 0, size = wordMeasurements.size(); i < size && lastEndOf
fset < run->m_stop; ++i) { | 399 for (size_t i = 0, size = wordMeasurements.size(); i < size && lastEndOf
fset < run->m_stop; ++i) { |
| 400 const WordMeasurement& wordMeasurement = wordMeasurements[i]; | 400 const WordMeasurement& wordMeasurement = wordMeasurements[i]; |
| 401 if (wordMeasurement.width <=0 || wordMeasurement.startOffset == word
Measurement.endOffset) | 401 if (wordMeasurement.startOffset == wordMeasurement.endOffset) |
| 402 continue; | 402 continue; |
| 403 if (wordMeasurement.layoutText != layoutText || wordMeasurement.star
tOffset != lastEndOffset || wordMeasurement.endOffset > run->m_stop) | 403 if (wordMeasurement.layoutText != layoutText || wordMeasurement.star
tOffset != lastEndOffset || wordMeasurement.endOffset > run->m_stop) |
| 404 continue; | 404 continue; |
| 405 | 405 |
| 406 lastEndOffset = wordMeasurement.endOffset; | 406 lastEndOffset = wordMeasurement.endOffset; |
| 407 if (kerningIsEnabled && lastEndOffset == run->m_stop) { | 407 if (kerningIsEnabled && lastEndOffset == run->m_stop) { |
| 408 int wordLength = lastEndOffset - wordMeasurement.startOffset; | 408 int wordLength = lastEndOffset - wordMeasurement.startOffset; |
| 409 measuredWidth += layoutText->width(wordMeasurement.startOffset,
wordLength, xPos, run->direction(), lineInfo.isFirstLine()); | 409 measuredWidth += layoutText->width(wordMeasurement.startOffset,
wordLength, xPos, run->direction(), lineInfo.isFirstLine()); |
| 410 if (i > 0 && wordLength == 1 && layoutText->characterAt(wordMeas
urement.startOffset) == ' ') | 410 if (i > 0 && wordLength == 1 && layoutText->characterAt(wordMeas
urement.startOffset) == ' ') |
| 411 measuredWidth += layoutText->style()->wordSpacing(); | 411 measuredWidth += layoutText->style()->wordSpacing(); |
| 412 } else { | 412 } else { |
| 413 FloatRect wordGlyphBounds = wordMeasurement.glyphBounds; | 413 FloatRect wordGlyphBounds = wordMeasurement.glyphBounds; |
| 414 wordGlyphBounds.move(measuredWidth, 0); | 414 wordGlyphBounds.move(measuredWidth, 0); |
| 415 glyphBounds.unite(wordGlyphBounds); | 415 glyphBounds.unite(wordGlyphBounds); |
| 416 measuredWidth += wordMeasurement.width; | 416 measuredWidth += wordMeasurement.width; |
| 417 } | 417 } |
| 418 if (!wordMeasurement.fallbackFonts.isEmpty()) { | 418 if (!wordMeasurement.fallbackFonts.isEmpty()) { |
| 419 HashSet<const SimpleFontData*>::const_iterator end = wordMeasure
ment.fallbackFonts.end(); | 419 HashSet<const SimpleFontData*>::const_iterator end = wordMeasure
ment.fallbackFonts.end(); |
| 420 for (HashSet<const SimpleFontData*>::const_iterator it = wordMea
surement.fallbackFonts.begin(); it != end; ++it) | 420 for (HashSet<const SimpleFontData*>::const_iterator it = wordMea
surement.fallbackFonts.begin(); it != end; ++it) |
| 421 fallbackFonts.add(*it); | 421 fallbackFonts.add(*it); |
| 422 } | 422 } |
| 423 } | 423 } |
| 424 if (measuredWidth && lastEndOffset != run->m_stop) { | 424 if (lastEndOffset != run->m_stop) { |
| 425 // If we don't have enough cached data, we'll measure the run again. | 425 // If we don't have enough cached data, we'll measure the run again. |
| 426 measuredWidth = 0; | 426 canUseSimpleFontCodePath = false; |
| 427 fallbackFonts.clear(); | 427 fallbackFonts.clear(); |
| 428 } | 428 } |
| 429 } | 429 } |
| 430 | 430 |
| 431 if (!measuredWidth) | 431 // Don't put this into 'else' part of the above 'if' because canUseSimpleFon
tCodePath may be modified in the 'if' block. |
| 432 if (!canUseSimpleFontCodePath) |
| 432 measuredWidth = layoutText->width(run->m_start, run->m_stop - run->m_sta
rt, xPos, run->direction(), lineInfo.isFirstLine(), &fallbackFonts, &glyphBounds
); | 433 measuredWidth = layoutText->width(run->m_start, run->m_stop - run->m_sta
rt, xPos, run->direction(), lineInfo.isFirstLine(), &fallbackFonts, &glyphBounds
); |
| 433 | 434 |
| 435 // Negative word-spacing and/or letter-spacing may cause some glyphs to over
flow the left boundary and result |
| 436 // negative measured width. Reset measured width to 0 and adjust glyph bound
s accordingly to cover the overflow. |
| 437 if (measuredWidth < 0) { |
| 438 glyphBounds.move(measuredWidth, 0); |
| 439 measuredWidth = 0; |
| 440 } |
| 441 |
| 434 glyphOverflow.setFromBounds(glyphBounds, font.fontMetrics().floatAscent(), f
ont.fontMetrics().floatDescent(), measuredWidth); | 442 glyphOverflow.setFromBounds(glyphBounds, font.fontMetrics().floatAscent(), f
ont.fontMetrics().floatDescent(), measuredWidth); |
| 435 | 443 |
| 436 run->m_box->setLogicalWidth(measuredWidth + hyphenWidth); | 444 run->m_box->setLogicalWidth(measuredWidth + hyphenWidth); |
| 437 if (!fallbackFonts.isEmpty()) { | 445 if (!fallbackFonts.isEmpty()) { |
| 438 ASSERT(run->m_box->isText()); | 446 ASSERT(run->m_box->isText()); |
| 439 GlyphOverflowAndFallbackFontsMap::ValueType* it = textBoxDataMap.add(toI
nlineTextBox(run->m_box), std::make_pair(Vector<const SimpleFontData*>(), GlyphO
verflow())).storedValue; | 447 GlyphOverflowAndFallbackFontsMap::ValueType* it = textBoxDataMap.add(toI
nlineTextBox(run->m_box), std::make_pair(Vector<const SimpleFontData*>(), GlyphO
verflow())).storedValue; |
| 440 ASSERT(it->value.first.isEmpty()); | 448 ASSERT(it->value.first.isEmpty()); |
| 441 copyToVector(fallbackFonts, it->value.first); | 449 copyToVector(fallbackFonts, it->value.first); |
| 442 run->m_box->parent()->clearDescendantsHaveSameLineHeightAndBaseline(); | 450 run->m_box->parent()->clearDescendantsHaveSameLineHeightAndBaseline(); |
| 443 } | 451 } |
| (...skipping 1613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2057 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); | 2065 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); |
| 2058 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight()
, false) - logicalLeft; | 2066 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight()
, false) - logicalLeft; |
| 2059 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); | 2067 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); |
| 2060 | 2068 |
| 2061 if (!style()->isLeftToRightDirection()) | 2069 if (!style()->isLeftToRightDirection()) |
| 2062 return logicalWidth() - logicalLeft; | 2070 return logicalWidth() - logicalLeft; |
| 2063 return logicalLeft; | 2071 return logicalLeft; |
| 2064 } | 2072 } |
| 2065 | 2073 |
| 2066 } | 2074 } |
| OLD | NEW |