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

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

Issue 2702853002: [LayoutNG] Shape items with context (Closed)
Patch Set: Add null check Created 3 years, 10 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 | « third_party/WebKit/Source/platform/fonts/shaping/ShapeResultBuffer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/fonts/shaping/ShapeResultBuffer.h" 5 #include "platform/fonts/shaping/ShapeResultBuffer.h"
6 6
7 #include "platform/fonts/CharacterRange.h" 7 #include "platform/fonts/CharacterRange.h"
8 #include "platform/fonts/GlyphBuffer.h" 8 #include "platform/fonts/GlyphBuffer.h"
9 #include "platform/fonts/SimpleFontData.h" 9 #include "platform/fonts/SimpleFontData.h"
10 #include "platform/fonts/shaping/ShapeResultInlineHeaders.h" 10 #include "platform/fonts/shaping/ShapeResultInlineHeaders.h"
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 advance += fillGlyphBufferForTextEmphasisRun( 305 advance += fillGlyphBufferForTextEmphasisRun(
306 glyphBuffer, wordResult->m_runs[i].get(), textRun, emphasisData, 306 glyphBuffer, wordResult->m_runs[i].get(), textRun, emphasisData,
307 advance, from, to, resolvedOffset); 307 advance, from, to, resolvedOffset);
308 } 308 }
309 wordOffset += wordResult->numCharacters() * (textRun.rtl() ? -1 : 1); 309 wordOffset += wordResult->numCharacters() * (textRun.rtl() ? -1 : 1);
310 } 310 }
311 311
312 return advance; 312 return advance;
313 } 313 }
314 314
315 // TODO(eae): This is a bit of a hack to allow reuse of the implementation
316 // for both ShapeResultBuffer and single ShapeResult use cases. Ideally the
317 // logic should move into ShapeResult itself and then the ShapeResultBuffer
318 // implementation may wrap that.
315 CharacterRange ShapeResultBuffer::getCharacterRange( 319 CharacterRange ShapeResultBuffer::getCharacterRange(
320 RefPtr<const ShapeResult> result,
321 TextDirection direction,
322 float totalWidth,
323 unsigned from,
324 unsigned to) {
325 Vector<RefPtr<const ShapeResult>, 64> results;
326 results.push_back(result);
327 return getCharacterRangeInternal(results, direction, totalWidth, from, to);
328 }
329
330 CharacterRange ShapeResultBuffer::getCharacterRangeInternal(
316 const Vector<RefPtr<const ShapeResult>, 64>& results, 331 const Vector<RefPtr<const ShapeResult>, 64>& results,
317 TextDirection direction, 332 TextDirection direction,
318 float totalWidth, 333 float totalWidth,
319 unsigned absoluteFrom, 334 unsigned absoluteFrom,
320 unsigned absoluteTo) { 335 unsigned absoluteTo) {
321 float currentX = 0; 336 float currentX = 0;
322 float fromX = 0; 337 float fromX = 0;
323 float toX = 0; 338 float toX = 0;
324 bool foundFromX = false; 339 bool foundFromX = false;
325 bool foundToX = false; 340 bool foundToX = false;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 fromX = toX = 0; 412 fromX = toX = 0;
398 if (fromX < toX) 413 if (fromX < toX)
399 return CharacterRange(fromX, toX); 414 return CharacterRange(fromX, toX);
400 return CharacterRange(toX, fromX); 415 return CharacterRange(toX, fromX);
401 } 416 }
402 417
403 CharacterRange ShapeResultBuffer::getCharacterRange(TextDirection direction, 418 CharacterRange ShapeResultBuffer::getCharacterRange(TextDirection direction,
404 float totalWidth, 419 float totalWidth,
405 unsigned from, 420 unsigned from,
406 unsigned to) const { 421 unsigned to) const {
407 return getCharacterRange(m_results, direction, totalWidth, from, to); 422 return getCharacterRangeInternal(m_results, direction, totalWidth, from, to);
408 } 423 }
409 424
410 void ShapeResultBuffer::addRunInfoRanges(const ShapeResult::RunInfo& runInfo, 425 void ShapeResultBuffer::addRunInfoRanges(const ShapeResult::RunInfo& runInfo,
411 float offset, 426 float offset,
412 Vector<CharacterRange>& ranges) { 427 Vector<CharacterRange>& ranges) {
413 Vector<float> characterWidths(runInfo.m_numCharacters); 428 Vector<float> characterWidths(runInfo.m_numCharacters);
414 for (const auto& glyph : runInfo.m_glyphData) 429 for (const auto& glyph : runInfo.m_glyphData)
415 characterWidths[glyph.characterIndex] += glyph.advance; 430 characterWidths[glyph.characterIndex] += glyph.advance;
416 431
417 for (unsigned characterIndex = 0; characterIndex < runInfo.m_numCharacters; 432 for (unsigned characterIndex = 0; characterIndex < runInfo.m_numCharacters;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 totalOffset += offsetForWord; 493 totalOffset += offsetForWord;
479 if (targetX >= 0 && targetX <= wordResult->width()) 494 if (targetX >= 0 && targetX <= wordResult->width())
480 return totalOffset; 495 return totalOffset;
481 targetX -= wordResult->width(); 496 targetX -= wordResult->width();
482 } 497 }
483 } 498 }
484 return totalOffset; 499 return totalOffset;
485 } 500 }
486 501
487 } // namespace blink 502 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/shaping/ShapeResultBuffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698