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

Side by Side Diff: Source/core/layout/line/BreakingContextInlineHeaders.h

Issue 1060113003: Blink use old style character string notation for Unicode (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase patch Created 5 years, 7 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 | « no previous file | Source/platform/fonts/SimpleFontData.cpp » ('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 * Copyright (C) 2013 Adobe Systems Incorporated. 5 * Copyright (C) 2013 Adobe Systems Incorporated.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 if (it.object()->isFloatingOrOutOfFlowPositioned()) 187 if (it.object()->isFloatingOrOutOfFlowPositioned())
188 return false; 188 return false;
189 189
190 if (it.object()->isLayoutInline() && !alwaysRequiresLineBox(it.object()) && !requiresLineBoxForContent(toLayoutInline(it.object()), lineInfo)) 190 if (it.object()->isLayoutInline() && !alwaysRequiresLineBox(it.object()) && !requiresLineBoxForContent(toLayoutInline(it.object()), lineInfo))
191 return false; 191 return false;
192 192
193 if (!shouldCollapseWhiteSpace(it.object()->styleRef(), lineInfo, whitespaceP osition) || it.object()->isBR()) 193 if (!shouldCollapseWhiteSpace(it.object()->styleRef(), lineInfo, whitespaceP osition) || it.object()->isBR())
194 return true; 194 return true;
195 195
196 UChar current = it.current(); 196 UChar current = it.current();
197 bool notJustWhitespace = current != ' ' && current != '\t' && current != sof tHyphen && (current != '\n' || it.object()->preservesNewline()); 197 bool notJustWhitespace = current != space && current != characterTabulation && current != softHyphen && (current != newlineCharacter || it.object()->preserv esNewline());
198 return notJustWhitespace || isEmptyInline(it.object()); 198 return notJustWhitespace || isEmptyInline(it.object());
199 } 199 }
200 200
201 inline void setStaticPositions(LayoutBlockFlow* block, LayoutBox* child) 201 inline void setStaticPositions(LayoutBlockFlow* block, LayoutBox* child)
202 { 202 {
203 ASSERT(child->isOutOfFlowPositioned()); 203 ASSERT(child->isOutOfFlowPositioned());
204 // FIXME: The math here is actually not really right. It's a best-guess appr oximation that 204 // FIXME: The math here is actually not really right. It's a best-guess appr oximation that
205 // will work for the common cases 205 // will work for the common cases
206 LayoutObject* containerBlock = child->container(); 206 LayoutObject* containerBlock = child->container();
207 LayoutUnit blockHeight = block->logicalHeight(); 207 LayoutUnit blockHeight = block->logicalHeight();
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 float wordTrailingSpaceWidth = (font.fontDescription().typesettingFeatures() & Kerning) ? 581 float wordTrailingSpaceWidth = (font.fontDescription().typesettingFeatures() & Kerning) ?
582 font.width(constructTextRun(layoutText, font, &space, 1, style, style.di rection())) + wordSpacing 582 font.width(constructTextRun(layoutText, font, &space, 1, style, style.di rection())) + wordSpacing
583 : 0; 583 : 0;
584 584
585 UChar lastCharacter = m_layoutTextInfo.m_lineBreakIterator.lastCharacter(); 585 UChar lastCharacter = m_layoutTextInfo.m_lineBreakIterator.lastCharacter();
586 UChar secondToLastCharacter = m_layoutTextInfo.m_lineBreakIterator.secondToL astCharacter(); 586 UChar secondToLastCharacter = m_layoutTextInfo.m_lineBreakIterator.secondToL astCharacter();
587 for (; m_current.offset() < layoutText->textLength(); m_current.fastIncremen tInTextNode()) { 587 for (; m_current.offset() < layoutText->textLength(); m_current.fastIncremen tInTextNode()) {
588 bool previousCharacterIsSpace = m_currentCharacterIsSpace; 588 bool previousCharacterIsSpace = m_currentCharacterIsSpace;
589 bool previousCharacterShouldCollapseIfPreWap = m_currentCharacterShouldC ollapseIfPreWap; 589 bool previousCharacterShouldCollapseIfPreWap = m_currentCharacterShouldC ollapseIfPreWap;
590 UChar c = m_current.current(); 590 UChar c = m_current.current();
591 m_currentCharacterShouldCollapseIfPreWap = m_currentCharacterIsSpace = c == ' ' || c == '\t' || (!m_preservesNewline && (c == '\n')); 591 m_currentCharacterShouldCollapseIfPreWap = m_currentCharacterIsSpace = c == space || c == characterTabulation || (!m_preservesNewline && (c == newlineCh aracter));
592 592
593 if (!m_collapseWhiteSpace || !m_currentCharacterIsSpace) 593 if (!m_collapseWhiteSpace || !m_currentCharacterIsSpace)
594 m_lineInfo.setEmpty(false, m_block, &m_width); 594 m_lineInfo.setEmpty(false, m_block, &m_width);
595 595
596 if (c == softHyphen && m_autoWrap && !hyphenWidth) { 596 if (c == softHyphen && m_autoWrap && !hyphenWidth) {
597 hyphenWidth = measureHyphenWidth(layoutText, font, textDirectionFrom Unicode(m_resolver.position().direction())); 597 hyphenWidth = measureHyphenWidth(layoutText, font, textDirectionFrom Unicode(m_resolver.position().direction()));
598 m_width.addUncommittedWidth(hyphenWidth); 598 m_width.addUncommittedWidth(hyphenWidth);
599 } 599 }
600 600
601 bool applyWordSpacing = false; 601 bool applyWordSpacing = false;
602 602
603 if (breakWords && !midWordBreak) { 603 if (breakWords && !midWordBreak) {
604 wrapW += charWidth; 604 wrapW += charWidth;
605 bool midWordBreakIsBeforeSurrogatePair = U16_IS_LEAD(c) && m_current .offset() + 1 < layoutText->textLength() && U16_IS_TRAIL((*layoutText)[m_current .offset() + 1]); 605 bool midWordBreakIsBeforeSurrogatePair = U16_IS_LEAD(c) && m_current .offset() + 1 < layoutText->textLength() && U16_IS_TRAIL((*layoutText)[m_current .offset() + 1]);
606 charWidth = textWidth(layoutText, m_current.offset(), midWordBreakIs BeforeSurrogatePair ? 2 : 1, font, m_width.committedWidth() + wrapW, m_collapseW hiteSpace); 606 charWidth = textWidth(layoutText, m_current.offset(), midWordBreakIs BeforeSurrogatePair ? 2 : 1, font, m_width.committedWidth() + wrapW, m_collapseW hiteSpace);
607 midWordBreak = m_width.committedWidth() + wrapW + charWidth > m_widt h.availableWidth(); 607 midWordBreak = m_width.committedWidth() + wrapW + charWidth > m_widt h.availableWidth();
608 } 608 }
609 609
610 int nextBreakablePosition = m_current.nextBreakablePosition(); 610 int nextBreakablePosition = m_current.nextBreakablePosition();
611 bool betweenWords = c == '\n' || (m_currWS != PRE && !m_atStart && m_lay outTextInfo.m_lineBreakIterator.isBreakable(m_current.offset(), nextBreakablePos ition, breakAll ? LineBreakType::BreakAll : keepAll ? LineBreakType::KeepAll : L ineBreakType::Normal)); 611 bool betweenWords = c == newlineCharacter || (m_currWS != PRE && !m_atSt art && m_layoutTextInfo.m_lineBreakIterator.isBreakable(m_current.offset(), next BreakablePosition, breakAll ? LineBreakType::BreakAll : keepAll ? LineBreakType: :KeepAll : LineBreakType::Normal));
612 m_current.setNextBreakablePosition(nextBreakablePosition); 612 m_current.setNextBreakablePosition(nextBreakablePosition);
613 613
614 if (betweenWords || midWordBreak) { 614 if (betweenWords || midWordBreak) {
615 bool stoppedIgnoringSpaces = false; 615 bool stoppedIgnoringSpaces = false;
616 if (m_ignoringSpaces) { 616 if (m_ignoringSpaces) {
617 lastSpaceWordSpacing = 0; 617 lastSpaceWordSpacing = 0;
618 if (!m_currentCharacterIsSpace) { 618 if (!m_currentCharacterIsSpace) {
619 // Stop ignoring spaces and begin at this 619 // Stop ignoring spaces and begin at this
620 // new point. 620 // new point.
621 m_ignoringSpaces = false; 621 m_ignoringSpaces = false;
622 wordSpacingForWordMeasurement = 0; 622 wordSpacingForWordMeasurement = 0;
623 lastSpace = m_current.offset(); // e.g., "Foo goo", don't add in any of the ignored spaces. 623 lastSpace = m_current.offset(); // e.g., "Foo goo", don't add in any of the ignored spaces.
624 m_lineMidpointState.stopIgnoringSpaces(InlineIterator(0, m_c urrent.object(), m_current.offset())); 624 m_lineMidpointState.stopIgnoringSpaces(InlineIterator(0, m_c urrent.object(), m_current.offset()));
625 stoppedIgnoringSpaces = true; 625 stoppedIgnoringSpaces = true;
626 } else { 626 } else {
627 // Just keep ignoring these spaces. 627 // Just keep ignoring these spaces.
628 nextCharacter(c, lastCharacter, secondToLastCharacter); 628 nextCharacter(c, lastCharacter, secondToLastCharacter);
629 continue; 629 continue;
630 } 630 }
631 } 631 }
632 632
633 wordMeasurements.grow(wordMeasurements.size() + 1); 633 wordMeasurements.grow(wordMeasurements.size() + 1);
634 WordMeasurement& wordMeasurement = wordMeasurements.last(); 634 WordMeasurement& wordMeasurement = wordMeasurements.last();
635 635
636 wordMeasurement.layoutText = layoutText; 636 wordMeasurement.layoutText = layoutText;
637 wordMeasurement.endOffset = m_current.offset(); 637 wordMeasurement.endOffset = m_current.offset();
638 wordMeasurement.startOffset = lastSpace; 638 wordMeasurement.startOffset = lastSpace;
639 639
640 float additionalTempWidth; 640 float additionalTempWidth;
641 if (wordTrailingSpaceWidth && c == ' ') 641 if (wordTrailingSpaceWidth && c == space)
642 additionalTempWidth = textWidth(layoutText, lastSpace, m_current .offset() + 1 - lastSpace, font, m_width.currentWidth(), m_collapseWhiteSpace, & wordMeasurement.fallbackFonts) - wordTrailingSpaceWidth; 642 additionalTempWidth = textWidth(layoutText, lastSpace, m_current .offset() + 1 - lastSpace, font, m_width.currentWidth(), m_collapseWhiteSpace, & wordMeasurement.fallbackFonts) - wordTrailingSpaceWidth;
643 else 643 else
644 additionalTempWidth = textWidth(layoutText, lastSpace, m_current .offset() - lastSpace, font, m_width.currentWidth(), m_collapseWhiteSpace, &word Measurement.fallbackFonts); 644 additionalTempWidth = textWidth(layoutText, lastSpace, m_current .offset() - lastSpace, font, m_width.currentWidth(), m_collapseWhiteSpace, &word Measurement.fallbackFonts);
645 645
646 wordMeasurement.width = additionalTempWidth + wordSpacingForWordMeas urement; 646 wordMeasurement.width = additionalTempWidth + wordSpacingForWordMeas urement;
647 additionalTempWidth += lastSpaceWordSpacing; 647 additionalTempWidth += lastSpaceWordSpacing;
648 m_width.addUncommittedWidth(additionalTempWidth); 648 m_width.addUncommittedWidth(additionalTempWidth);
649 649
650 if (m_collapseWhiteSpace && previousCharacterIsSpace && m_currentCha racterIsSpace && additionalTempWidth) 650 if (m_collapseWhiteSpace && previousCharacterIsSpace && m_currentCha racterIsSpace && additionalTempWidth)
651 m_width.setTrailingWhitespaceWidth(additionalTempWidth); 651 m_width.setTrailingWhitespaceWidth(additionalTempWidth);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 if (!betweenWords || (midWordBreak && !m_autoWrap)) 702 if (!betweenWords || (midWordBreak && !m_autoWrap))
703 m_width.addUncommittedWidth(-additionalTempWidth); 703 m_width.addUncommittedWidth(-additionalTempWidth);
704 if (hyphenWidth) { 704 if (hyphenWidth) {
705 // Subtract the width of the soft hyphen out since we fi t on a line. 705 // Subtract the width of the soft hyphen out since we fi t on a line.
706 m_width.addUncommittedWidth(-hyphenWidth); 706 m_width.addUncommittedWidth(-hyphenWidth);
707 hyphenWidth = 0; 707 hyphenWidth = 0;
708 } 708 }
709 } 709 }
710 } 710 }
711 711
712 if (c == '\n' && m_preservesNewline) { 712 if (c == newlineCharacter && m_preservesNewline) {
713 if (!stoppedIgnoringSpaces && m_current.offset()) 713 if (!stoppedIgnoringSpaces && m_current.offset())
714 m_lineMidpointState.ensureCharacterGetsLineBox(m_current); 714 m_lineMidpointState.ensureCharacterGetsLineBox(m_current);
715 m_lineBreak.moveTo(m_current.object(), m_current.offset(), m_cur rent.nextBreakablePosition()); 715 m_lineBreak.moveTo(m_current.object(), m_current.offset(), m_cur rent.nextBreakablePosition());
716 m_lineBreak.increment(); 716 m_lineBreak.increment();
717 m_lineInfo.setPreviousLineBrokeCleanly(true); 717 m_lineInfo.setPreviousLineBrokeCleanly(true);
718 return true; 718 return true;
719 } 719 }
720 720
721 if (m_autoWrap && betweenWords) { 721 if (m_autoWrap && betweenWords) {
722 m_width.commit(); 722 m_width.commit();
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 } else if (m_nextObject && m_current.object()->isText() && m_nextObject->isT ext() && !m_nextObject->isBR() && (m_autoWrap || m_nextObject->style()->autoWrap ())) { 832 } else if (m_nextObject && m_current.object()->isText() && m_nextObject->isT ext() && !m_nextObject->isBR() && (m_autoWrap || m_nextObject->style()->autoWrap ())) {
833 if (m_autoWrap && m_currentCharacterIsSpace) { 833 if (m_autoWrap && m_currentCharacterIsSpace) {
834 checkForBreak = true; 834 checkForBreak = true;
835 } else { 835 } else {
836 LayoutText* nextText = toLayoutText(m_nextObject); 836 LayoutText* nextText = toLayoutText(m_nextObject);
837 if (nextText->textLength()) { 837 if (nextText->textLength()) {
838 UChar c = nextText->characterAt(0); 838 UChar c = nextText->characterAt(0);
839 // If the next item on the line is text, and if we did not end w ith 839 // If the next item on the line is text, and if we did not end w ith
840 // a space, then the next text run continues our word (and so it needs to 840 // a space, then the next text run continues our word (and so it needs to
841 // keep adding to the uncommitted width. Just update and continu e. 841 // keep adding to the uncommitted width. Just update and continu e.
842 checkForBreak = !m_currentCharacterIsSpace && (c == ' ' || c == '\t' || (c == '\n' && !m_nextObject->preservesNewline())); 842 checkForBreak = !m_currentCharacterIsSpace && (c == space || c = = characterTabulation || (c == newlineCharacter && !m_nextObject->preservesNewli ne()));
843 } else if (nextText->isWordBreak()) { 843 } else if (nextText->isWordBreak()) {
844 checkForBreak = true; 844 checkForBreak = true;
845 } 845 }
846 846
847 if (!m_width.fitsOnLine() && !m_width.committedWidth()) 847 if (!m_width.fitsOnLine() && !m_width.committedWidth())
848 m_width.fitBelowFloats(m_lineInfo.isFirstLine()); 848 m_width.fitBelowFloats(m_lineInfo.isFirstLine());
849 849
850 bool canPlaceOnLine = m_width.fitsOnLine() || !m_autoWrapWasEverTrue OnLine; 850 bool canPlaceOnLine = m_width.fitsOnLine() || !m_autoWrapWasEverTrue OnLine;
851 if (canPlaceOnLine && checkForBreak) { 851 if (canPlaceOnLine && checkForBreak) {
852 m_width.commit(); 852 m_width.commit();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 898
899 if (style.textIndentType() == TextIndentHanging) 899 if (style.textIndentType() == TextIndentHanging)
900 shouldIndentText = shouldIndentText == IndentText ? DoNotIndentText : In dentText; 900 shouldIndentText = shouldIndentText == IndentText ? DoNotIndentText : In dentText;
901 901
902 return shouldIndentText; 902 return shouldIndentText;
903 } 903 }
904 904
905 } 905 }
906 906
907 #endif // BreakingContextInlineHeaders_h 907 #endif // BreakingContextInlineHeaders_h
OLDNEW
« no previous file with comments | « no previous file | Source/platform/fonts/SimpleFontData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698