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

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

Issue 1203743002: Include glyph overflows caused by negative spacing into visual overflow (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « LayoutTests/fast/text/international/rtl-negative-letter-spacing.html ('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 /* 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
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 if (measuredWidth < 0) {
eae 2015/06/23 22:28:54 This could use a comment.
Xianzhu 2015/06/23 22:43:32 Done.
436 glyphBounds.move(measuredWidth, 0);
437 measuredWidth = 0;
438 }
439
434 glyphOverflow.setFromBounds(glyphBounds, font.fontMetrics().floatAscent(), f ont.fontMetrics().floatDescent(), measuredWidth); 440 glyphOverflow.setFromBounds(glyphBounds, font.fontMetrics().floatAscent(), f ont.fontMetrics().floatDescent(), measuredWidth);
435 441
436 run->m_box->setLogicalWidth(measuredWidth + hyphenWidth); 442 run->m_box->setLogicalWidth(measuredWidth + hyphenWidth);
437 if (!fallbackFonts.isEmpty()) { 443 if (!fallbackFonts.isEmpty()) {
438 ASSERT(run->m_box->isText()); 444 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; 445 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()); 446 ASSERT(it->value.first.isEmpty());
441 copyToVector(fallbackFonts, it->value.first); 447 copyToVector(fallbackFonts, it->value.first);
442 run->m_box->parent()->clearDescendantsHaveSameLineHeightAndBaseline(); 448 run->m_box->parent()->clearDescendantsHaveSameLineHeightAndBaseline();
443 } 449 }
(...skipping 1613 matching lines...) Expand 10 before | Expand all | Expand 10 after
2057 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); 2063 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false);
2058 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight() , false) - logicalLeft; 2064 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight() , false) - logicalLeft;
2059 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); 2065 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0);
2060 2066
2061 if (!style()->isLeftToRightDirection()) 2067 if (!style()->isLeftToRightDirection())
2062 return logicalWidth() - logicalLeft; 2068 return logicalWidth() - logicalLeft;
2063 return logicalLeft; 2069 return logicalLeft;
2064 } 2070 }
2065 2071
2066 } 2072 }
OLDNEW
« no previous file with comments | « LayoutTests/fast/text/international/rtl-negative-letter-spacing.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698