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

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

Issue 1033943002: Rename LayoutStyle to papayawhip (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: ensureComputedStyle Created 5 years, 8 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 | « Source/core/layout/LayoutText.h ('k') | Source/core/layout/LayoutTextCombine.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 * (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 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 bool LayoutText::isTextFragment() const 176 bool LayoutText::isTextFragment() const
177 { 177 {
178 return false; 178 return false;
179 } 179 }
180 180
181 bool LayoutText::isWordBreak() const 181 bool LayoutText::isWordBreak() const
182 { 182 {
183 return false; 183 return false;
184 } 184 }
185 185
186 void LayoutText::styleDidChange(StyleDifference diff, const LayoutStyle* oldStyl e) 186 void LayoutText::styleDidChange(StyleDifference diff, const ComputedStyle* oldSt yle)
187 { 187 {
188 // There is no need to ever schedule paint invalidations from a style change of a text run, since 188 // There is no need to ever schedule paint invalidations from a style change of a text run, since
189 // we already did this for the parent of the text run. 189 // we already did this for the parent of the text run.
190 // We do have to schedule layouts, though, since a style change can force us to 190 // We do have to schedule layouts, though, since a style change can force us to
191 // need to relayout. 191 // need to relayout.
192 if (diff.needsFullLayout()) { 192 if (diff.needsFullLayout()) {
193 setNeedsLayoutAndPrefWidthsRecalc(); 193 setNeedsLayoutAndPrefWidthsRecalc();
194 m_knownToHaveNoOverflowAndNoFallbackFonts = false; 194 m_knownToHaveNoOverflowAndNoFallbackFonts = false;
195 } 195 }
196 196
197 const LayoutStyle& newStyle = styleRef(); 197 const ComputedStyle& newStyle = styleRef();
198 ETextTransform oldTransform = oldStyle ? oldStyle->textTransform() : TTNONE; 198 ETextTransform oldTransform = oldStyle ? oldStyle->textTransform() : TTNONE;
199 ETextSecurity oldSecurity = oldStyle ? oldStyle->textSecurity() : TSNONE; 199 ETextSecurity oldSecurity = oldStyle ? oldStyle->textSecurity() : TSNONE;
200 if (oldTransform != newStyle.textTransform() || oldSecurity != newStyle.text Security()) 200 if (oldTransform != newStyle.textTransform() || oldSecurity != newStyle.text Security())
201 transformText(); 201 transformText();
202 202
203 // This is an optimization that kicks off font load before layout. 203 // This is an optimization that kicks off font load before layout.
204 // In order to make it fast, we only check if the first character of the 204 // In order to make it fast, we only check if the first character of the
205 // text is included in the unicode ranges of the fonts. 205 // text is included in the unicode ranges of the fonts.
206 if (!text().containsOnlyWhitespace()) 206 if (!text().containsOnlyWhitespace())
207 newStyle.font().willUseFontData(text().characterStartingAt(0)); 207 newStyle.font().willUseFontData(text().characterStartingAt(0));
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 657
658 float rootLeft = box->root().logicalLeft(); 658 float rootLeft = box->root().logicalLeft();
659 float rootRight = box->root().logicalRight(); 659 float rootRight = box->root().logicalRight();
660 660
661 // FIXME: should we use the width of the root inline box or the 661 // FIXME: should we use the width of the root inline box or the
662 // width of the containing block for this? 662 // width of the containing block for this?
663 if (extraWidthToEndOfLine) 663 if (extraWidthToEndOfLine)
664 *extraWidthToEndOfLine = (box->root().logicalWidth() + rootLeft) - (left + 1); 664 *extraWidthToEndOfLine = (box->root().logicalWidth() + rootLeft) - (left + 1);
665 665
666 LayoutBlock* cb = containingBlock(); 666 LayoutBlock* cb = containingBlock();
667 const LayoutStyle& cbStyle = cb->styleRef(); 667 const ComputedStyle& cbStyle = cb->styleRef();
668 668
669 float leftEdge; 669 float leftEdge;
670 float rightEdge; 670 float rightEdge;
671 leftEdge = std::min<float>(0, rootLeft); 671 leftEdge = std::min<float>(0, rootLeft);
672 rightEdge = std::max<float>(cb->logicalWidth().toFloat(), rootRight); 672 rightEdge = std::max<float>(cb->logicalWidth().toFloat(), rootRight);
673 673
674 bool rightAligned = false; 674 bool rightAligned = false;
675 switch (cbStyle.textAlign()) { 675 switch (cbStyle.textAlign()) {
676 case RIGHT: 676 case RIGHT:
677 case WEBKIT_RIGHT: 677 case WEBKIT_RIGHT:
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 return combineText->combinedTextWidth(f); 716 return combineText->combinedTextWidth(f);
717 } 717 }
718 718
719 if (f.isFixedPitch() && f.fontDescription().variant() == FontVariantNormal & & m_isAllASCII && (!glyphOverflow || !glyphOverflow->computeBounds)) { 719 if (f.isFixedPitch() && f.fontDescription().variant() == FontVariantNormal & & m_isAllASCII && (!glyphOverflow || !glyphOverflow->computeBounds)) {
720 bool missingGlyph = false; 720 bool missingGlyph = false;
721 float monospaceCharacterWidth = f.spaceWidth(); 721 float monospaceCharacterWidth = f.spaceWidth();
722 float w = 0; 722 float w = 0;
723 bool isSpace; 723 bool isSpace;
724 ASSERT(m_text); 724 ASSERT(m_text);
725 StringImpl& text = *m_text.impl(); 725 StringImpl& text = *m_text.impl();
726 const LayoutStyle& layoutStyle = styleRef(); 726 const ComputedStyle& computedStyle = styleRef();
727 for (int i = start; i < start + len; i++) { 727 for (int i = start; i < start + len; i++) {
728 char c = text[i]; 728 char c = text[i];
729 // If glyph is not present in primary font then we cannot calculate width based on primary 729 // If glyph is not present in primary font then we cannot calculate width based on primary
730 // font property, we need to call "width" method of Font Object. 730 // font property, we need to call "width" method of Font Object.
731 if (!f.primaryFontHasGlyphForCharacter(text[i])) { 731 if (!f.primaryFontHasGlyphForCharacter(text[i])) {
732 missingGlyph = true; 732 missingGlyph = true;
733 break; 733 break;
734 } 734 }
735 if (c <= space) { 735 if (c <= space) {
736 if (c == space || c == newlineCharacter) { 736 if (c == space || c == newlineCharacter) {
737 w += monospaceCharacterWidth; 737 w += monospaceCharacterWidth;
738 isSpace = true; 738 isSpace = true;
739 } else if (c == characterTabulation) { 739 } else if (c == characterTabulation) {
740 if (layoutStyle.collapseWhiteSpace()) { 740 if (computedStyle.collapseWhiteSpace()) {
741 w += monospaceCharacterWidth; 741 w += monospaceCharacterWidth;
742 isSpace = true; 742 isSpace = true;
743 } else { 743 } else {
744 w += f.tabWidth(layoutStyle.tabSize(), xPos + w); 744 w += f.tabWidth(computedStyle.tabSize(), xPos + w);
745 isSpace = false; 745 isSpace = false;
746 } 746 }
747 } else { 747 } else {
748 isSpace = false; 748 isSpace = false;
749 } 749 }
750 } else { 750 } else {
751 w += monospaceCharacterWidth; 751 w += monospaceCharacterWidth;
752 isSpace = false; 752 isSpace = false;
753 } 753 }
754 if (isSpace && i > start) 754 if (isSpace && i > start)
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 GlyphOverflow glyphOverflow; 888 GlyphOverflow glyphOverflow;
889 computePreferredLogicalWidths(leadWidth, fallbackFonts, glyphOverflow); 889 computePreferredLogicalWidths(leadWidth, fallbackFonts, glyphOverflow);
890 890
891 // We shouldn't change our mind once we "know". 891 // We shouldn't change our mind once we "know".
892 ASSERT(!m_knownToHaveNoOverflowAndNoFallbackFonts || (fallbackFonts.isEmpty( ) && glyphOverflow.isZero())); 892 ASSERT(!m_knownToHaveNoOverflowAndNoFallbackFonts || (fallbackFonts.isEmpty( ) && glyphOverflow.isZero()));
893 m_knownToHaveNoOverflowAndNoFallbackFonts = fallbackFonts.isEmpty() && glyph Overflow.isZero(); 893 m_knownToHaveNoOverflowAndNoFallbackFonts = fallbackFonts.isEmpty() && glyph Overflow.isZero();
894 } 894 }
895 895
896 static inline float hyphenWidth(LayoutText* renderer, const Font& font, TextDire ction direction) 896 static inline float hyphenWidth(LayoutText* renderer, const Font& font, TextDire ction direction)
897 { 897 {
898 const LayoutStyle& style = renderer->styleRef(); 898 const ComputedStyle& style = renderer->styleRef();
899 return font.width(constructTextRun(renderer, font, style.hyphenString().stri ng(), style, direction)); 899 return font.width(constructTextRun(renderer, font, style.hyphenString().stri ng(), style, direction));
900 } 900 }
901 901
902 void LayoutText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si mpleFontData*>& fallbackFonts, GlyphOverflow& glyphOverflow) 902 void LayoutText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si mpleFontData*>& fallbackFonts, GlyphOverflow& glyphOverflow)
903 { 903 {
904 ASSERT(m_hasTab || preferredLogicalWidthsDirty() || !m_knownToHaveNoOverflow AndNoFallbackFonts); 904 ASSERT(m_hasTab || preferredLogicalWidthsDirty() || !m_knownToHaveNoOverflow AndNoFallbackFonts);
905 905
906 m_minWidth = 0; 906 m_minWidth = 0;
907 m_maxWidth = 0; 907 m_maxWidth = 0;
908 m_firstLineMinWidth = 0; 908 m_firstLineMinWidth = 0;
909 m_lastLineLineMinWidth = 0; 909 m_lastLineLineMinWidth = 0;
910 910
911 if (isBR()) 911 if (isBR())
912 return; 912 return;
913 913
914 float currMinWidth = 0; 914 float currMinWidth = 0;
915 float currMaxWidth = 0; 915 float currMaxWidth = 0;
916 m_hasBreakableChar = false; 916 m_hasBreakableChar = false;
917 m_hasBreak = false; 917 m_hasBreak = false;
918 m_hasTab = false; 918 m_hasTab = false;
919 m_hasBreakableStart = false; 919 m_hasBreakableStart = false;
920 m_hasBreakableEnd = false; 920 m_hasBreakableEnd = false;
921 m_hasEndWhiteSpace = false; 921 m_hasEndWhiteSpace = false;
922 922
923 const LayoutStyle& styleToUse = styleRef(); 923 const ComputedStyle& styleToUse = styleRef();
924 const Font& f = styleToUse.font(); // FIXME: This ignores first-line. 924 const Font& f = styleToUse.font(); // FIXME: This ignores first-line.
925 float wordSpacing = styleToUse.wordSpacing(); 925 float wordSpacing = styleToUse.wordSpacing();
926 int len = textLength(); 926 int len = textLength();
927 LazyLineBreakIterator breakIterator(m_text, styleToUse.locale()); 927 LazyLineBreakIterator breakIterator(m_text, styleToUse.locale());
928 bool needsWordSpacing = false; 928 bool needsWordSpacing = false;
929 bool ignoringSpaces = false; 929 bool ignoringSpaces = false;
930 bool isSpace = false; 930 bool isSpace = false;
931 bool firstWord = true; 931 bool firstWord = true;
932 bool firstLine = true; 932 bool firstLine = true;
933 int nextBreakable = -1; 933 int nextBreakable = -1;
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 prev = (*previousString)[previousString->length() - 1]; 1344 prev = (*previousString)[previousString->length() - 1];
1345 } 1345 }
1346 return prev; 1346 return prev;
1347 } 1347 }
1348 1348
1349 void LayoutText::addLayerHitTestRects(LayerHitTestRects&, const DeprecatedPaintL ayer* currentLayer, const LayoutPoint& layerOffset, const LayoutRect& containerR ect) const 1349 void LayoutText::addLayerHitTestRects(LayerHitTestRects&, const DeprecatedPaintL ayer* currentLayer, const LayoutPoint& layerOffset, const LayoutRect& containerR ect) const
1350 { 1350 {
1351 // Text nodes aren't event targets, so don't descend any further. 1351 // Text nodes aren't event targets, so don't descend any further.
1352 } 1352 }
1353 1353
1354 void applyTextTransform(const LayoutStyle* style, String& text, UChar previousCh aracter) 1354 void applyTextTransform(const ComputedStyle* style, String& text, UChar previous Character)
1355 { 1355 {
1356 if (!style) 1356 if (!style)
1357 return; 1357 return;
1358 1358
1359 switch (style->textTransform()) { 1359 switch (style->textTransform()) {
1360 case TTNONE: 1360 case TTNONE:
1361 break; 1361 break;
1362 case CAPITALIZE: 1362 case CAPITALIZE:
1363 makeCapitalized(&text, previousCharacter); 1363 makeCapitalized(&text, previousCharacter);
1364 break; 1364 break;
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
1898 } 1898 }
1899 1899
1900 void LayoutText::invalidateDisplayItemClients(const LayoutBoxModelObject& paintI nvalidationContainer) const 1900 void LayoutText::invalidateDisplayItemClients(const LayoutBoxModelObject& paintI nvalidationContainer) const
1901 { 1901 {
1902 LayoutObject::invalidateDisplayItemClients(paintInvalidationContainer); 1902 LayoutObject::invalidateDisplayItemClients(paintInvalidationContainer);
1903 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) 1903 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox())
1904 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box); 1904 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box);
1905 } 1905 }
1906 1906
1907 } // namespace blink 1907 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutText.h ('k') | Source/core/layout/LayoutTextCombine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698