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

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

Issue 2025503002: Revert of Expand WTF::StringView's API to be more like StringPiece. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 546
547 widths.resize(ranges.size()); 547 widths.resize(ranges.size());
548 for (unsigned i = 0; i < ranges.size(); i++) 548 for (unsigned i = 0; i < ranges.size(); i++)
549 widths[i] = ranges[i].width(); 549 widths[i] = ranges[i].width();
550 } 550 }
551 551
552 TextRun InlineTextBox::constructTextRun(const ComputedStyle& style, const Font& font, StringBuilder* charactersWithHyphen) const 552 TextRun InlineTextBox::constructTextRun(const ComputedStyle& style, const Font& font, StringBuilder* charactersWithHyphen) const
553 { 553 {
554 ASSERT(getLineLayoutItem().text()); 554 ASSERT(getLineLayoutItem().text());
555 555
556 String string = getLineLayoutItem().text(); 556 StringView string = getLineLayoutItem().text().createView();
557 unsigned startPos = start(); 557 unsigned startPos = start();
558 unsigned length = len(); 558 unsigned length = len();
559 return constructTextRun(style, font, StringView(string, startPos, length), g etLineLayoutItem().textLength() - startPos, charactersWithHyphen); 559
560 if (string.length() != length || startPos)
561 string.narrow(startPos, length);
562
563 return constructTextRun(style, font, string, getLineLayoutItem().textLength( ) - startPos, charactersWithHyphen);
560 } 564 }
561 565
562 TextRun InlineTextBox::constructTextRun(const ComputedStyle& style, const Font& font, StringView string, int maximumLength, StringBuilder* charactersWithHyphen) const 566 TextRun InlineTextBox::constructTextRun(const ComputedStyle& style, const Font& font, StringView string, int maximumLength, StringBuilder* charactersWithHyphen) const
563 { 567 {
564 if (charactersWithHyphen) { 568 if (charactersWithHyphen) {
565 const AtomicString& hyphenString = style.hyphenString(); 569 const AtomicString& hyphenString = style.hyphenString();
566 charactersWithHyphen->reserveCapacity(string.length() + hyphenString.len gth()); 570 charactersWithHyphen->reserveCapacity(string.length() + hyphenString.len gth());
567 charactersWithHyphen->append(string); 571 charactersWithHyphen->append(string);
568 charactersWithHyphen->append(hyphenString); 572 charactersWithHyphen->append(hyphenString);
569 string = charactersWithHyphen->toString(); 573 string = charactersWithHyphen->toString().createView();
570 maximumLength = string.length(); 574 maximumLength = string.length();
571 } 575 }
572 576
573 ASSERT(maximumLength >= static_cast<int>(string.length())); 577 ASSERT(maximumLength >= static_cast<int>(string.length()));
574 578
575 TextRun run(string, textPos().toFloat(), expansion(), expansionBehavior(), d irection(), dirOverride() || style.rtlOrdering() == VisualOrder); 579 TextRun run(string, textPos().toFloat(), expansion(), expansionBehavior(), d irection(), dirOverride() || style.rtlOrdering() == VisualOrder);
576 run.setTabSize(!style.collapseWhiteSpace(), style.getTabSize()); 580 run.setTabSize(!style.collapseWhiteSpace(), style.getTabSize());
577 run.setTextJustify(style.getTextJustify()); 581 run.setTextJustify(style.getTextJustify());
578 582
579 // Propagate the maximum length of the characters buffer to the TextRun, eve n when we're only processing a substring. 583 // Propagate the maximum length of the characters buffer to the TextRun, eve n when we're only processing a substring.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 printedCharacters = fprintf(stderr, "\t%s %p", obj.name(), obj.debugPointer( )); 620 printedCharacters = fprintf(stderr, "\t%s %p", obj.name(), obj.debugPointer( ));
617 const int layoutObjectCharacterOffset = 75; 621 const int layoutObjectCharacterOffset = 75;
618 for (; printedCharacters < layoutObjectCharacterOffset; printedCharacters++) 622 for (; printedCharacters < layoutObjectCharacterOffset; printedCharacters++)
619 fputc(' ', stderr); 623 fputc(' ', stderr);
620 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata()); 624 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata());
621 } 625 }
622 626
623 #endif 627 #endif
624 628
625 } // namespace blink 629 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698