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

Side by Side Diff: Source/core/rendering/RenderText.cpp

Issue 889563002: Make RenderObject::style() return a const object (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Blind fix for Mac. Created 5 years, 10 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
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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 { 193 {
194 // There is no need to ever schedule paint invalidations from a style change of a text run, since 194 // There is no need to ever schedule paint invalidations from a style change of a text run, since
195 // we already did this for the parent of the text run. 195 // we already did this for the parent of the text run.
196 // We do have to schedule layouts, though, since a style change can force us to 196 // We do have to schedule layouts, though, since a style change can force us to
197 // need to relayout. 197 // need to relayout.
198 if (diff.needsFullLayout()) { 198 if (diff.needsFullLayout()) {
199 setNeedsLayoutAndPrefWidthsRecalc(); 199 setNeedsLayoutAndPrefWidthsRecalc();
200 m_knownToHaveNoOverflowAndNoFallbackFonts = false; 200 m_knownToHaveNoOverflowAndNoFallbackFonts = false;
201 } 201 }
202 202
203 RenderStyle* newStyle = style(); 203 const RenderStyle* newStyle = style();
204 ETextTransform oldTransform = oldStyle ? oldStyle->textTransform() : TTNONE; 204 ETextTransform oldTransform = oldStyle ? oldStyle->textTransform() : TTNONE;
205 ETextSecurity oldSecurity = oldStyle ? oldStyle->textSecurity() : TSNONE; 205 ETextSecurity oldSecurity = oldStyle ? oldStyle->textSecurity() : TSNONE;
206 if (oldTransform != newStyle->textTransform() || oldSecurity != newStyle->te xtSecurity()) 206 if (oldTransform != newStyle->textTransform() || oldSecurity != newStyle->te xtSecurity())
207 transformText(); 207 transformText();
208 208
209 // This is an optimization that kicks off font load before layout. 209 // This is an optimization that kicks off font load before layout.
210 // In order to make it fast, we only check if the first character of the 210 // In order to make it fast, we only check if the first character of the
211 // text is included in the unicode ranges of the fonts. 211 // text is included in the unicode ranges of the fonts.
212 if (!text().containsOnlyWhitespace()) 212 if (!text().containsOnlyWhitespace())
213 newStyle->font().willUseFontData(text().characterStartingAt(0)); 213 newStyle->font().willUseFontData(text().characterStartingAt(0));
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 661
662 float rootLeft = box->root().logicalLeft(); 662 float rootLeft = box->root().logicalLeft();
663 float rootRight = box->root().logicalRight(); 663 float rootRight = box->root().logicalRight();
664 664
665 // FIXME: should we use the width of the root inline box or the 665 // FIXME: should we use the width of the root inline box or the
666 // width of the containing block for this? 666 // width of the containing block for this?
667 if (extraWidthToEndOfLine) 667 if (extraWidthToEndOfLine)
668 *extraWidthToEndOfLine = (box->root().logicalWidth() + rootLeft) - (left + 1); 668 *extraWidthToEndOfLine = (box->root().logicalWidth() + rootLeft) - (left + 1);
669 669
670 RenderBlock* cb = containingBlock(); 670 RenderBlock* cb = containingBlock();
671 RenderStyle* cbStyle = cb->style(); 671 const RenderStyle* cbStyle = cb->style();
672 672
673 float leftEdge; 673 float leftEdge;
674 float rightEdge; 674 float rightEdge;
675 leftEdge = std::min<float>(0, rootLeft); 675 leftEdge = std::min<float>(0, rootLeft);
676 rightEdge = std::max<float>(cb->logicalWidth().toFloat(), rootRight); 676 rightEdge = std::max<float>(cb->logicalWidth().toFloat(), rootRight);
677 677
678 bool rightAligned = false; 678 bool rightAligned = false;
679 switch (cbStyle->textAlign()) { 679 switch (cbStyle->textAlign()) {
680 case RIGHT: 680 case RIGHT:
681 case WEBKIT_RIGHT: 681 case WEBKIT_RIGHT:
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 return combineText->combinedTextWidth(f); 720 return combineText->combinedTextWidth(f);
721 } 721 }
722 722
723 if (f.isFixedPitch() && f.fontDescription().variant() == FontVariantNormal & & m_isAllASCII && (!glyphOverflow || !glyphOverflow->computeBounds)) { 723 if (f.isFixedPitch() && f.fontDescription().variant() == FontVariantNormal & & m_isAllASCII && (!glyphOverflow || !glyphOverflow->computeBounds)) {
724 bool missingGlyph = false; 724 bool missingGlyph = false;
725 float monospaceCharacterWidth = f.spaceWidth(); 725 float monospaceCharacterWidth = f.spaceWidth();
726 float w = 0; 726 float w = 0;
727 bool isSpace; 727 bool isSpace;
728 ASSERT(m_text); 728 ASSERT(m_text);
729 StringImpl& text = *m_text.impl(); 729 StringImpl& text = *m_text.impl();
730 RenderStyle* renderStyle = style(); 730 const RenderStyle* renderStyle = style();
731 for (int i = start; i < start + len; i++) { 731 for (int i = start; i < start + len; i++) {
732 char c = text[i]; 732 char c = text[i];
733 // If glyph is not present in primary font then we cannot calculate width based on primary 733 // If glyph is not present in primary font then we cannot calculate width based on primary
734 // font property, we need to call "width" method of Font Object. 734 // font property, we need to call "width" method of Font Object.
735 if (!f.primaryFontHasGlyphForCharacter(text[i])) { 735 if (!f.primaryFontHasGlyphForCharacter(text[i])) {
736 missingGlyph = true; 736 missingGlyph = true;
737 break; 737 break;
738 } 738 }
739 if (c <= space) { 739 if (c <= space) {
740 if (c == space || c == newlineCharacter) { 740 if (c == space || c == newlineCharacter) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 GlyphOverflow glyphOverflow; 886 GlyphOverflow glyphOverflow;
887 computePreferredLogicalWidths(leadWidth, fallbackFonts, glyphOverflow); 887 computePreferredLogicalWidths(leadWidth, fallbackFonts, glyphOverflow);
888 888
889 // We shouldn't change our mind once we "know". 889 // We shouldn't change our mind once we "know".
890 ASSERT(!m_knownToHaveNoOverflowAndNoFallbackFonts || (fallbackFonts.isEmpty( ) && glyphOverflow.isZero())); 890 ASSERT(!m_knownToHaveNoOverflowAndNoFallbackFonts || (fallbackFonts.isEmpty( ) && glyphOverflow.isZero()));
891 m_knownToHaveNoOverflowAndNoFallbackFonts = fallbackFonts.isEmpty() && glyph Overflow.isZero(); 891 m_knownToHaveNoOverflowAndNoFallbackFonts = fallbackFonts.isEmpty() && glyph Overflow.isZero();
892 } 892 }
893 893
894 static inline float hyphenWidth(RenderText* renderer, const Font& font, TextDire ction direction) 894 static inline float hyphenWidth(RenderText* renderer, const Font& font, TextDire ction direction)
895 { 895 {
896 RenderStyle* style = renderer->style(); 896 const RenderStyle* style = renderer->style();
897 return font.width(constructTextRun(renderer, font, style->hyphenString().str ing(), style, direction)); 897 return font.width(constructTextRun(renderer, font, style->hyphenString().str ing(), style, direction));
898 } 898 }
899 899
900 void RenderText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si mpleFontData*>& fallbackFonts, GlyphOverflow& glyphOverflow) 900 void RenderText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si mpleFontData*>& fallbackFonts, GlyphOverflow& glyphOverflow)
901 { 901 {
902 ASSERT(m_hasTab || preferredLogicalWidthsDirty() || !m_knownToHaveNoOverflow AndNoFallbackFonts); 902 ASSERT(m_hasTab || preferredLogicalWidthsDirty() || !m_knownToHaveNoOverflow AndNoFallbackFonts);
903 903
904 m_minWidth = 0; 904 m_minWidth = 0;
905 m_maxWidth = 0; 905 m_maxWidth = 0;
906 m_firstLineMinWidth = 0; 906 m_firstLineMinWidth = 0;
907 m_lastLineLineMinWidth = 0; 907 m_lastLineLineMinWidth = 0;
908 908
909 if (isBR()) 909 if (isBR())
910 return; 910 return;
911 911
912 float currMinWidth = 0; 912 float currMinWidth = 0;
913 float currMaxWidth = 0; 913 float currMaxWidth = 0;
914 m_hasBreakableChar = false; 914 m_hasBreakableChar = false;
915 m_hasBreak = false; 915 m_hasBreak = false;
916 m_hasTab = false; 916 m_hasTab = false;
917 m_hasBreakableStart = false; 917 m_hasBreakableStart = false;
918 m_hasBreakableEnd = false; 918 m_hasBreakableEnd = false;
919 m_hasEndWhiteSpace = false; 919 m_hasEndWhiteSpace = false;
920 920
921 RenderStyle* styleToUse = style(); 921 const RenderStyle* styleToUse = style();
922 const Font& f = styleToUse->font(); // FIXME: This ignores first-line. 922 const Font& f = styleToUse->font(); // FIXME: This ignores first-line.
923 float wordSpacing = styleToUse->wordSpacing(); 923 float wordSpacing = styleToUse->wordSpacing();
924 int len = textLength(); 924 int len = textLength();
925 LazyLineBreakIterator breakIterator(m_text, styleToUse->locale()); 925 LazyLineBreakIterator breakIterator(m_text, styleToUse->locale());
926 bool needsWordSpacing = false; 926 bool needsWordSpacing = false;
927 bool ignoringSpaces = false; 927 bool ignoringSpaces = false;
928 bool isSpace = false; 928 bool isSpace = false;
929 bool firstWord = true; 929 bool firstWord = true;
930 bool firstLine = true; 930 bool firstLine = true;
931 int nextBreakable = -1; 931 int nextBreakable = -1;
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after
1882 } 1882 }
1883 secureTextTimer->restartWithNewText(lastTypedCharacterOffset); 1883 secureTextTimer->restartWithNewText(lastTypedCharacterOffset);
1884 } 1884 }
1885 1885
1886 PassRefPtr<AbstractInlineTextBox> RenderText::firstAbstractInlineTextBox() 1886 PassRefPtr<AbstractInlineTextBox> RenderText::firstAbstractInlineTextBox()
1887 { 1887 {
1888 return AbstractInlineTextBox::getOrCreate(this, m_firstTextBox); 1888 return AbstractInlineTextBox::getOrCreate(this, m_firstTextBox);
1889 } 1889 }
1890 1890
1891 } // namespace blink 1891 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698