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

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

Issue 2246383002: Remove unused Font argument from InlineTextBox::constructTextRun (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@combine
Patch Set: Created 4 years, 4 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 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Dirk Mueller (mueller@kde.org) 3 * (C) 2000 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 224
225 FontCachePurgePreventer fontCachePurgePreventer; 225 FontCachePurgePreventer fontCachePurgePreventer;
226 226
227 LayoutUnit selTop = root().selectionTop(); 227 LayoutUnit selTop = root().selectionTop();
228 LayoutUnit selHeight = root().selectionHeight(); 228 LayoutUnit selHeight = root().selectionHeight();
229 const ComputedStyle& styleToUse = getLineLayoutItem().styleRef(isFirstLineSt yle()); 229 const ComputedStyle& styleToUse = getLineLayoutItem().styleRef(isFirstLineSt yle());
230 const Font& font = styleToUse.font(); 230 const Font& font = styleToUse.font();
231 231
232 StringBuilder charactersWithHyphen; 232 StringBuilder charactersWithHyphen;
233 bool respectHyphen = ePos == m_len && hasHyphen(); 233 bool respectHyphen = ePos == m_len && hasHyphen();
234 TextRun textRun = constructTextRun(styleToUse, font, respectHyphen ? &charac tersWithHyphen : 0); 234 TextRun textRun = constructTextRun(styleToUse, respectHyphen ? &charactersWi thHyphen : 0);
235 235
236 LayoutPoint startingPoint = LayoutPoint(logicalLeft(), selTop); 236 LayoutPoint startingPoint = LayoutPoint(logicalLeft(), selTop);
237 LayoutRect r; 237 LayoutRect r;
238 if (sPos || ePos != static_cast<int>(m_len)) { 238 if (sPos || ePos != static_cast<int>(m_len)) {
239 r = LayoutRect(enclosingIntRect(font.selectionRectForText(textRun, Float Point(startingPoint), selHeight, sPos, ePos))); 239 r = LayoutRect(enclosingIntRect(font.selectionRectForText(textRun, Float Point(startingPoint), selHeight, sPos, ePos)));
240 } else { // Avoid computing the font width when the entire line box is selec ted as an optimization. 240 } else { // Avoid computing the font width when the entire line box is selec ted as an optimization.
241 r = LayoutRect(enclosingIntRect(LayoutRect(startingPoint, LayoutSize(m_l ogicalWidth, selHeight)))); 241 r = LayoutRect(enclosingIntRect(LayoutRect(startingPoint, LayoutSize(m_l ogicalWidth, selHeight))));
242 } 242 }
243 243
244 LayoutUnit logicalWidth = r.width(); 244 LayoutUnit logicalWidth = r.width();
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 return 0; 483 return 0;
484 484
485 if (lineOffset - logicalLeft() > logicalWidth()) 485 if (lineOffset - logicalLeft() > logicalWidth())
486 return isLeftToRightDirection() ? len() : 0; 486 return isLeftToRightDirection() ? len() : 0;
487 if (lineOffset - logicalLeft() < 0) 487 if (lineOffset - logicalLeft() < 0)
488 return isLeftToRightDirection() ? 0 : len(); 488 return isLeftToRightDirection() ? 0 : len();
489 489
490 LineLayoutText text = getLineLayoutItem(); 490 LineLayoutText text = getLineLayoutItem();
491 const ComputedStyle& style = text.styleRef(isFirstLineStyle()); 491 const ComputedStyle& style = text.styleRef(isFirstLineStyle());
492 const Font& font = style.font(); 492 const Font& font = style.font();
493 return font.offsetForPosition(constructTextRun(style, font), (lineOffset - l ogicalLeft()).toFloat(), includePartialGlyphs); 493 return font.offsetForPosition(constructTextRun(style), (lineOffset - logical Left()).toFloat(), includePartialGlyphs);
494 } 494 }
495 495
496 LayoutUnit InlineTextBox::positionForOffset(int offset) const 496 LayoutUnit InlineTextBox::positionForOffset(int offset) const
497 { 497 {
498 ASSERT(offset >= m_start); 498 ASSERT(offset >= m_start);
499 ASSERT(offset <= m_start + m_len); 499 ASSERT(offset <= m_start + m_len);
500 500
501 if (isLineBreak()) 501 if (isLineBreak())
502 return logicalLeft(); 502 return logicalLeft();
503 503
504 LineLayoutText text = getLineLayoutItem(); 504 LineLayoutText text = getLineLayoutItem();
505 const ComputedStyle& styleToUse = text.styleRef(isFirstLineStyle()); 505 const ComputedStyle& styleToUse = text.styleRef(isFirstLineStyle());
506 const Font& font = styleToUse.font(); 506 const Font& font = styleToUse.font();
507 int from = !isLeftToRightDirection() ? offset - m_start : 0; 507 int from = !isLeftToRightDirection() ? offset - m_start : 0;
508 int to = !isLeftToRightDirection() ? m_len : offset - m_start; 508 int to = !isLeftToRightDirection() ? m_len : offset - m_start;
509 // FIXME: Do we need to add rightBearing here? 509 // FIXME: Do we need to add rightBearing here?
510 return LayoutUnit(font.selectionRectForText(constructTextRun(styleToUse, fon t), IntPoint(logicalLeft(), 0), 0, from, to).maxX()); 510 return LayoutUnit(font.selectionRectForText(constructTextRun(styleToUse), In tPoint(logicalLeft(), 0), 0, from, to).maxX());
511 } 511 }
512 512
513 bool InlineTextBox::containsCaretOffset(int offset) const 513 bool InlineTextBox::containsCaretOffset(int offset) const
514 { 514 {
515 // Offsets before the box are never "in". 515 // Offsets before the box are never "in".
516 if (offset < m_start) 516 if (offset < m_start)
517 return false; 517 return false;
518 518
519 int pastEnd = m_start + m_len; 519 int pastEnd = m_start + m_len;
520 520
(...skipping 17 matching lines...) Expand all
538 { 538 {
539 if (!m_len) 539 if (!m_len)
540 return; 540 return;
541 541
542 FontCachePurgePreventer fontCachePurgePreventer; 542 FontCachePurgePreventer fontCachePurgePreventer;
543 ASSERT(getLineLayoutItem().text()); 543 ASSERT(getLineLayoutItem().text());
544 544
545 const ComputedStyle& styleToUse = getLineLayoutItem().styleRef(isFirstLineSt yle()); 545 const ComputedStyle& styleToUse = getLineLayoutItem().styleRef(isFirstLineSt yle());
546 const Font& font = styleToUse.font(); 546 const Font& font = styleToUse.font();
547 547
548 TextRun textRun = constructTextRun(styleToUse, font); 548 TextRun textRun = constructTextRun(styleToUse);
549 Vector<CharacterRange> ranges = font.individualCharacterRanges(textRun); 549 Vector<CharacterRange> ranges = font.individualCharacterRanges(textRun);
550 DCHECK_EQ(ranges.size(), m_len); 550 DCHECK_EQ(ranges.size(), m_len);
551 551
552 widths.resize(ranges.size()); 552 widths.resize(ranges.size());
553 for (unsigned i = 0; i < ranges.size(); i++) 553 for (unsigned i = 0; i < ranges.size(); i++)
554 widths[i] = ranges[i].width(); 554 widths[i] = ranges[i].width();
555 } 555 }
556 556
557 TextRun InlineTextBox::constructTextRun(const ComputedStyle& style, const Font& font, StringBuilder* charactersWithHyphen) const 557 TextRun InlineTextBox::constructTextRun(const ComputedStyle& style, StringBuilde r* charactersWithHyphen) const
558 { 558 {
559 ASSERT(getLineLayoutItem().text()); 559 ASSERT(getLineLayoutItem().text());
560 560
561 String string = getLineLayoutItem().text(); 561 String string = getLineLayoutItem().text();
562 unsigned startPos = start(); 562 unsigned startPos = start();
563 unsigned length = len(); 563 unsigned length = len();
564 return constructTextRun(style, font, StringView(string, startPos, length), g etLineLayoutItem().textLength() - startPos, charactersWithHyphen); 564 return constructTextRun(style, StringView(string, startPos, length), getLine LayoutItem().textLength() - startPos, charactersWithHyphen);
565 } 565 }
566 566
567 TextRun InlineTextBox::constructTextRun(const ComputedStyle& style, const Font& font, StringView string, int maximumLength, StringBuilder* charactersWithHyphen) const 567 TextRun InlineTextBox::constructTextRun(const ComputedStyle& style, StringView s tring, int maximumLength, StringBuilder* charactersWithHyphen) const
568 { 568 {
569 if (charactersWithHyphen) { 569 if (charactersWithHyphen) {
570 const AtomicString& hyphenString = style.hyphenString(); 570 const AtomicString& hyphenString = style.hyphenString();
571 charactersWithHyphen->reserveCapacity(string.length() + hyphenString.len gth()); 571 charactersWithHyphen->reserveCapacity(string.length() + hyphenString.len gth());
572 charactersWithHyphen->append(string); 572 charactersWithHyphen->append(string);
573 charactersWithHyphen->append(hyphenString); 573 charactersWithHyphen->append(hyphenString);
574 string = charactersWithHyphen->toString(); 574 string = charactersWithHyphen->toString();
575 maximumLength = string.length(); 575 maximumLength = string.length();
576 } 576 }
577 577
578 ASSERT(maximumLength >= static_cast<int>(string.length())); 578 ASSERT(maximumLength >= static_cast<int>(string.length()));
579 579
580 TextRun run(string, textPos().toFloat(), expansion(), expansionBehavior(), d irection(), dirOverride() || style.rtlOrdering() == VisualOrder); 580 TextRun run(string, textPos().toFloat(), expansion(), expansionBehavior(), d irection(), dirOverride() || style.rtlOrdering() == VisualOrder);
581 run.setTabSize(!style.collapseWhiteSpace(), style.getTabSize()); 581 run.setTabSize(!style.collapseWhiteSpace(), style.getTabSize());
582 run.setTextJustify(style.getTextJustify()); 582 run.setTextJustify(style.getTextJustify());
583 583
584 // Propagate the maximum length of the characters buffer to the TextRun, eve n when we're only processing a substring. 584 // Propagate the maximum length of the characters buffer to the TextRun, eve n when we're only processing a substring.
585 run.setCharactersLength(maximumLength); 585 run.setCharactersLength(maximumLength);
586 ASSERT(run.charactersLength() >= run.length()); 586 ASSERT(run.charactersLength() >= run.length());
587 return run; 587 return run;
588 } 588 }
589 589
590 TextRun InlineTextBox::constructTextRunForInspector(const ComputedStyle& style, const Font& font) const 590 TextRun InlineTextBox::constructTextRunForInspector(const ComputedStyle& style) const
591 { 591 {
592 return InlineTextBox::constructTextRun(style, font); 592 return InlineTextBox::constructTextRun(style);
593 } 593 }
594 594
595 const char* InlineTextBox::boxName() const 595 const char* InlineTextBox::boxName() const
596 { 596 {
597 return "InlineTextBox"; 597 return "InlineTextBox";
598 } 598 }
599 599
600 String InlineTextBox::debugName() const 600 String InlineTextBox::debugName() const
601 { 601 {
602 return String(boxName()) + " '" + text() + "'"; 602 return String(boxName()) + " '" + text() + "'";
(...skipping 18 matching lines...) Expand all
621 printedCharacters = fprintf(stderr, "\t%s %p", obj.name(), obj.debugPointer( )); 621 printedCharacters = fprintf(stderr, "\t%s %p", obj.name(), obj.debugPointer( ));
622 const int layoutObjectCharacterOffset = 75; 622 const int layoutObjectCharacterOffset = 75;
623 for (; printedCharacters < layoutObjectCharacterOffset; printedCharacters++) 623 for (; printedCharacters < layoutObjectCharacterOffset; printedCharacters++)
624 fputc(' ', stderr); 624 fputc(' ', stderr);
625 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata()); 625 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata());
626 } 626 }
627 627
628 #endif 628 #endif
629 629
630 } // namespace blink 630 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698