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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp

Issue 1473773002: Clarify naming for fast-path in setLogicalWidthForTextRun (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 | « no previous file | third_party/WebKit/Source/core/layout/LayoutText.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 hyphenWidth = layoutText->hyphenWidth(font, run->direction()); 440 hyphenWidth = layoutText->hyphenWidth(font, run->direction());
441 441
442 float measuredWidth = 0; 442 float measuredWidth = 0;
443 FloatRect glyphBounds; 443 FloatRect glyphBounds;
444 444
445 bool kerningIsEnabled = font.fontDescription().typesettingFeatures() & Kerni ng; 445 bool kerningIsEnabled = font.fontDescription().typesettingFeatures() & Kerni ng;
446 446
447 #if OS(MACOSX) 447 #if OS(MACOSX)
448 // FIXME: Having any font feature settings enabled can lead to selection gap s on 448 // FIXME: Having any font feature settings enabled can lead to selection gap s on
449 // Chromium-mac. https://bugs.webkit.org/show_bug.cgi?id=113418 449 // Chromium-mac. https://bugs.webkit.org/show_bug.cgi?id=113418
450 bool canUseSimpleFontCodePath = layoutText->canUseSimpleFontCodePath() && !f ont.fontDescription().featureSettings(); 450 bool canUseCachedWordMeasurements = layoutText->canUseSimpleFontCodePath() & & !font.fontDescription().featureSettings();
drott 2015/11/25 12:46:24 I am trying to understand what this line actually
451 #else 451 #else
452 bool canUseSimpleFontCodePath = layoutText->canUseSimpleFontCodePath(); 452 bool canUseCachedWordMeasurements = layoutText->canUseSimpleFontCodePath();
453 #endif 453 #endif
454 454
455 if (canUseSimpleFontCodePath) { 455 if (canUseCachedWordMeasurements) {
456 int lastEndOffset = run->m_start; 456 int lastEndOffset = run->m_start;
457 for (size_t i = 0, size = wordMeasurements.size(); i < size && lastEndOf fset < run->m_stop; ++i) { 457 for (size_t i = 0, size = wordMeasurements.size(); i < size && lastEndOf fset < run->m_stop; ++i) {
458 const WordMeasurement& wordMeasurement = wordMeasurements[i]; 458 const WordMeasurement& wordMeasurement = wordMeasurements[i];
459 if (wordMeasurement.startOffset == wordMeasurement.endOffset) 459 if (wordMeasurement.startOffset == wordMeasurement.endOffset)
460 continue; 460 continue;
461 if (wordMeasurement.layoutText != layoutText || wordMeasurement.star tOffset != lastEndOffset || wordMeasurement.endOffset > run->m_stop) 461 if (wordMeasurement.layoutText != layoutText || wordMeasurement.star tOffset != lastEndOffset || wordMeasurement.endOffset > run->m_stop)
462 continue; 462 continue;
463 463
464 lastEndOffset = wordMeasurement.endOffset; 464 lastEndOffset = wordMeasurement.endOffset;
465 if (kerningIsEnabled && lastEndOffset == run->m_stop) { 465 if (kerningIsEnabled && lastEndOffset == run->m_stop) {
466 int wordLength = lastEndOffset - wordMeasurement.startOffset; 466 int wordLength = lastEndOffset - wordMeasurement.startOffset;
467 measuredWidth += layoutText->width(wordMeasurement.startOffset, wordLength, xPos, run->direction(), lineInfo.isFirstLine()); 467 measuredWidth += layoutText->width(wordMeasurement.startOffset, wordLength, xPos, run->direction(), lineInfo.isFirstLine());
468 if (i > 0 && wordLength == 1 && layoutText->characterAt(wordMeas urement.startOffset) == ' ') 468 if (i > 0 && wordLength == 1 && layoutText->characterAt(wordMeas urement.startOffset) == ' ')
469 measuredWidth += layoutText->style()->wordSpacing(); 469 measuredWidth += layoutText->style()->wordSpacing();
470 } else { 470 } else {
471 FloatRect wordGlyphBounds = wordMeasurement.glyphBounds; 471 FloatRect wordGlyphBounds = wordMeasurement.glyphBounds;
472 wordGlyphBounds.move(measuredWidth, 0); 472 wordGlyphBounds.move(measuredWidth, 0);
473 glyphBounds.unite(wordGlyphBounds); 473 glyphBounds.unite(wordGlyphBounds);
474 measuredWidth += wordMeasurement.width; 474 measuredWidth += wordMeasurement.width;
475 } 475 }
476 if (!wordMeasurement.fallbackFonts.isEmpty()) { 476 if (!wordMeasurement.fallbackFonts.isEmpty()) {
477 HashSet<const SimpleFontData*>::const_iterator end = wordMeasure ment.fallbackFonts.end(); 477 HashSet<const SimpleFontData*>::const_iterator end = wordMeasure ment.fallbackFonts.end();
478 for (HashSet<const SimpleFontData*>::const_iterator it = wordMea surement.fallbackFonts.begin(); it != end; ++it) 478 for (HashSet<const SimpleFontData*>::const_iterator it = wordMea surement.fallbackFonts.begin(); it != end; ++it)
479 fallbackFonts.add(*it); 479 fallbackFonts.add(*it);
480 } 480 }
481 } 481 }
482 if (lastEndOffset != run->m_stop) { 482 if (lastEndOffset != run->m_stop) {
483 // If we don't have enough cached data, we'll measure the run again. 483 // If we don't have enough cached data, we'll measure the run again.
484 canUseSimpleFontCodePath = false; 484 canUseCachedWordMeasurements = false;
485 fallbackFonts.clear(); 485 fallbackFonts.clear();
486 } 486 }
487 } 487 }
488 488
489 // Don't put this into 'else' part of the above 'if' because canUseSimpleFon tCodePath may be modified in the 'if' block. 489 // Don't put this into 'else' part of the above 'if' because canUseCachedWor dMeasurements may be modified in the 'if' block.
490 if (!canUseSimpleFontCodePath) 490 if (!canUseCachedWordMeasurements)
491 measuredWidth = layoutText->width(run->m_start, run->m_stop - run->m_sta rt, xPos, run->direction(), lineInfo.isFirstLine(), &fallbackFonts, &glyphBounds ); 491 measuredWidth = layoutText->width(run->m_start, run->m_stop - run->m_sta rt, xPos, run->direction(), lineInfo.isFirstLine(), &fallbackFonts, &glyphBounds );
492 492
493 // Negative word-spacing and/or letter-spacing may cause some glyphs to over flow the left boundary and result 493 // Negative word-spacing and/or letter-spacing may cause some glyphs to over flow the left boundary and result
494 // negative measured width. Reset measured width to 0 and adjust glyph bound s accordingly to cover the overflow. 494 // negative measured width. Reset measured width to 0 and adjust glyph bound s accordingly to cover the overflow.
495 if (measuredWidth < 0) { 495 if (measuredWidth < 0) {
496 if (measuredWidth < glyphBounds.x()) { 496 if (measuredWidth < glyphBounds.x()) {
497 glyphBounds.expand(glyphBounds.x() - measuredWidth, 0); 497 glyphBounds.expand(glyphBounds.x() - measuredWidth, 0);
498 glyphBounds.setX(measuredWidth); 498 glyphBounds.setX(measuredWidth);
499 } 499 }
500 measuredWidth = 0; 500 measuredWidth = 0;
(...skipping 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after
2059 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); 2059 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false);
2060 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight() , false) - logicalLeft; 2060 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight() , false) - logicalLeft;
2061 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); 2061 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0);
2062 2062
2063 if (!style()->isLeftToRightDirection()) 2063 if (!style()->isLeftToRightDirection())
2064 return logicalWidth() - logicalLeft; 2064 return logicalWidth() - logicalLeft;
2065 return logicalLeft; 2065 return logicalLeft;
2066 } 2066 }
2067 2067
2068 } 2068 }
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/LayoutText.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698