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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/shaping/ShapeResult.cpp

Issue 2740083002: Add support for shaper-driven line breaking to HarfBuzzShaper (Closed)
Patch Set: Try to fix test failures 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
OLDNEW
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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 m_runs.insert(pos, std::move(run)); 410 m_runs.insert(pos, std::move(run));
411 break; 411 break;
412 } 412 }
413 } 413 }
414 } 414 }
415 // If we didn't find an existing slot to place it, append. 415 // If we didn't find an existing slot to place it, append.
416 if (run) 416 if (run)
417 m_runs.push_back(std::move(run)); 417 m_runs.push_back(std::move(run));
418 } 418 }
419 419
420 void ShapeResult::copyRange(unsigned startOffset,
421 unsigned endOffset,
422 ShapeResult* target) const {
423 unsigned index = target->m_numCharacters;
424 for (const auto& run : m_runs) {
425 unsigned runStart = (*run).m_startIndex;
426 unsigned runEnd = runStart + (*run).m_numCharacters;
427
428 if (startOffset < runEnd && endOffset > runStart) {
429 unsigned start = startOffset > runStart ? startOffset - runStart : 0;
430 unsigned end = std::min(endOffset - runStart, runEnd);
431 DCHECK(end > start);
432
433 ShapeResult::RunInfo* subRun = (*run).createSubRun(start, end);
434 subRun->m_startIndex = index;
435 target->m_runs.push_back(WTF::wrapUnique(subRun));
436 target->m_width += subRun->m_width;
437 index += subRun->m_numCharacters;
438 }
439 }
440
441 target->m_numCharacters = index;
442 }
443
420 PassRefPtr<ShapeResult> ShapeResult::createForTabulationCharacters( 444 PassRefPtr<ShapeResult> ShapeResult::createForTabulationCharacters(
421 const Font* font, 445 const Font* font,
422 const TextRun& textRun, 446 const TextRun& textRun,
423 float positionOffset, 447 float positionOffset,
424 unsigned count) { 448 unsigned count) {
425 const SimpleFontData* fontData = font->primaryFont(); 449 const SimpleFontData* fontData = font->primaryFont();
426 // Tab characters are always LTR or RTL, not TTB, even when 450 // Tab characters are always LTR or RTL, not TTB, even when
427 // isVerticalAnyUpright(). 451 // isVerticalAnyUpright().
428 std::unique_ptr<ShapeResult::RunInfo> run = 452 std::unique_ptr<ShapeResult::RunInfo> run =
429 WTF::wrapUnique(new ShapeResult::RunInfo( 453 WTF::wrapUnique(new ShapeResult::RunInfo(
(...skipping 14 matching lines...) Expand all
444 result->m_width = run->m_width; 468 result->m_width = run->m_width;
445 result->m_numGlyphs = count; 469 result->m_numGlyphs = count;
446 DCHECK_EQ(result->m_numGlyphs, count); // no overflow 470 DCHECK_EQ(result->m_numGlyphs, count); // no overflow
447 result->m_hasVerticalOffsets = 471 result->m_hasVerticalOffsets =
448 fontData->platformData().isVerticalAnyUpright(); 472 fontData->platformData().isVerticalAnyUpright();
449 result->m_runs.push_back(std::move(run)); 473 result->m_runs.push_back(std::move(run));
450 return result.release(); 474 return result.release();
451 } 475 }
452 476
453 } // namespace blink 477 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698