| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 Google Inc. All rights reserved. | 2 * Copyright (c) 2012 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved. | 3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 if (run) | 373 if (run) |
| 374 m_runs.append(std::move(run)); | 374 m_runs.append(std::move(run)); |
| 375 } | 375 } |
| 376 | 376 |
| 377 PassRefPtr<ShapeResult> ShapeResult::createForTabulationCharacters( | 377 PassRefPtr<ShapeResult> ShapeResult::createForTabulationCharacters( |
| 378 const Font* font, | 378 const Font* font, |
| 379 const TextRun& textRun, | 379 const TextRun& textRun, |
| 380 float positionOffset, | 380 float positionOffset, |
| 381 unsigned count) { | 381 unsigned count) { |
| 382 const SimpleFontData* fontData = font->primaryFont(); | 382 const SimpleFontData* fontData = font->primaryFont(); |
| 383 std::unique_ptr<ShapeResult::RunInfo> run = wrapUnique(new ShapeResult::RunInf
o( | 383 // Tab characters are always LTR or RTL, not TTB, even when |
| 384 fontData, | 384 // isVerticalAnyUpright(). |
| 385 // Tab characters are always LTR or RTL, not TTB, even when isVerticalAnyU
pright(). | 385 std::unique_ptr<ShapeResult::RunInfo> run = |
| 386 textRun.rtl() ? HB_DIRECTION_RTL : HB_DIRECTION_LTR, HB_SCRIPT_COMMON, 0, | 386 wrapUnique(new ShapeResult::RunInfo( |
| 387 count, count)); | 387 fontData, textRun.rtl() ? HB_DIRECTION_RTL : HB_DIRECTION_LTR, |
| 388 HB_SCRIPT_COMMON, 0, count, count)); |
| 388 float position = textRun.xPos() + positionOffset; | 389 float position = textRun.xPos() + positionOffset; |
| 389 float startPosition = position; | 390 float startPosition = position; |
| 390 for (unsigned i = 0; i < count; i++) { | 391 for (unsigned i = 0; i < count; i++) { |
| 391 float advance = font->tabWidth(*fontData, textRun.getTabSize(), position); | 392 float advance = font->tabWidth(*fontData, textRun.getTabSize(), position); |
| 392 run->m_glyphData[i].characterIndex = i; | 393 run->m_glyphData[i].characterIndex = i; |
| 393 run->setGlyphAndPositions(i, fontData->spaceGlyph(), advance, 0, 0); | 394 run->setGlyphAndPositions(i, fontData->spaceGlyph(), advance, 0, 0); |
| 394 position += advance; | 395 position += advance; |
| 395 } | 396 } |
| 396 run->m_width = position - startPosition; | 397 run->m_width = position - startPosition; |
| 397 | 398 |
| 398 RefPtr<ShapeResult> result = | 399 RefPtr<ShapeResult> result = |
| 399 ShapeResult::create(font, count, textRun.direction()); | 400 ShapeResult::create(font, count, textRun.direction()); |
| 400 result->m_width = run->m_width; | 401 result->m_width = run->m_width; |
| 401 result->m_numGlyphs = count; | 402 result->m_numGlyphs = count; |
| 402 DCHECK_EQ(result->m_numGlyphs, count); // no overflow | 403 DCHECK_EQ(result->m_numGlyphs, count); // no overflow |
| 403 result->m_hasVerticalOffsets = | 404 result->m_hasVerticalOffsets = |
| 404 fontData->platformData().isVerticalAnyUpright(); | 405 fontData->platformData().isVerticalAnyUpright(); |
| 405 result->m_runs.append(std::move(run)); | 406 result->m_runs.append(std::move(run)); |
| 406 return result.release(); | 407 return result.release(); |
| 407 } | 408 } |
| 408 | 409 |
| 409 } // namespace blink | 410 } // namespace blink |
| OLD | NEW |