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

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

Issue 1196213002: Remove duplicate measure hyphen string method (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Making hyphenWidth as inline and removing static nature Created 5 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
« no previous file with comments | « Source/core/layout/LayoutText.h ('k') | Source/core/layout/line/BreakingContextInlineHeaders.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 17 matching lines...) Expand all
28 #include "core/dom/AXObjectCache.h" 28 #include "core/dom/AXObjectCache.h"
29 #include "core/dom/Text.h" 29 #include "core/dom/Text.h"
30 #include "core/editing/VisiblePosition.h" 30 #include "core/editing/VisiblePosition.h"
31 #include "core/editing/iterators/TextIterator.h" 31 #include "core/editing/iterators/TextIterator.h"
32 #include "core/frame/FrameView.h" 32 #include "core/frame/FrameView.h"
33 #include "core/frame/Settings.h" 33 #include "core/frame/Settings.h"
34 #include "core/html/parser/TextResourceDecoder.h" 34 #include "core/html/parser/TextResourceDecoder.h"
35 #include "core/layout/LayoutBlock.h" 35 #include "core/layout/LayoutBlock.h"
36 #include "core/layout/LayoutTextCombine.h" 36 #include "core/layout/LayoutTextCombine.h"
37 #include "core/layout/LayoutView.h" 37 #include "core/layout/LayoutView.h"
38 #include "core/layout/TextRunConstructor.h"
39 #include "core/layout/line/AbstractInlineTextBox.h" 38 #include "core/layout/line/AbstractInlineTextBox.h"
40 #include "core/layout/line/EllipsisBox.h" 39 #include "core/layout/line/EllipsisBox.h"
41 #include "core/layout/line/GlyphOverflow.h" 40 #include "core/layout/line/GlyphOverflow.h"
42 #include "core/layout/line/InlineTextBox.h" 41 #include "core/layout/line/InlineTextBox.h"
43 #include "core/paint/DeprecatedPaintLayer.h" 42 #include "core/paint/DeprecatedPaintLayer.h"
44 #include "platform/fonts/Character.h" 43 #include "platform/fonts/Character.h"
45 #include "platform/fonts/FontCache.h" 44 #include "platform/fonts/FontCache.h"
46 #include "platform/geometry/FloatQuad.h" 45 #include "platform/geometry/FloatQuad.h"
47 #include "platform/text/BidiResolver.h" 46 #include "platform/text/BidiResolver.h"
48 #include "platform/text/TextBreakIterator.h" 47 #include "platform/text/TextBreakIterator.h"
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 return m_maxWidth; 849 return m_maxWidth;
851 } 850 }
852 851
853 void LayoutText::computePreferredLogicalWidths(float leadWidth) 852 void LayoutText::computePreferredLogicalWidths(float leadWidth)
854 { 853 {
855 HashSet<const SimpleFontData*> fallbackFonts; 854 HashSet<const SimpleFontData*> fallbackFonts;
856 FloatRect glyphBounds; 855 FloatRect glyphBounds;
857 computePreferredLogicalWidths(leadWidth, fallbackFonts, glyphBounds); 856 computePreferredLogicalWidths(leadWidth, fallbackFonts, glyphBounds);
858 } 857 }
859 858
860 static inline float hyphenWidth(LayoutText* layoutObject, const Font& font, Text Direction direction)
861 {
862 const ComputedStyle& style = layoutObject->styleRef();
863 return font.width(constructTextRun(layoutObject, font, style.hyphenString(). string(), style, direction));
864 }
865
866 void LayoutText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si mpleFontData*>& fallbackFonts, FloatRect& glyphBounds) 859 void LayoutText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si mpleFontData*>& fallbackFonts, FloatRect& glyphBounds)
867 { 860 {
868 ASSERT(m_hasTab || preferredLogicalWidthsDirty() || !m_knownToHaveNoOverflow AndNoFallbackFonts); 861 ASSERT(m_hasTab || preferredLogicalWidthsDirty() || !m_knownToHaveNoOverflow AndNoFallbackFonts);
869 862
870 m_minWidth = 0; 863 m_minWidth = 0;
871 m_maxWidth = 0; 864 m_maxWidth = 0;
872 m_firstLineMinWidth = 0; 865 m_firstLineMinWidth = 0;
873 m_lastLineLineMinWidth = 0; 866 m_lastLineLineMinWidth = 0;
874 867
875 if (isBR()) 868 if (isBR())
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 cachedWordTrailingSpaceWidth[textDirection] = f.width(constr uctTextRun(this, f, &spaceCharacter, 1, styleToUse, textDirection)) + wordSpacin g; 1005 cachedWordTrailingSpaceWidth[textDirection] = f.width(constr uctTextRun(this, f, &spaceCharacter, 1, styleToUse, textDirection)) + wordSpacin g;
1013 wordTrailingSpaceWidth = cachedWordTrailingSpaceWidth[textDirect ion]; 1006 wordTrailingSpaceWidth = cachedWordTrailingSpaceWidth[textDirect ion];
1014 } 1007 }
1015 1008
1016 float w; 1009 float w;
1017 if (wordTrailingSpaceWidth && isSpace) { 1010 if (wordTrailingSpaceWidth && isSpace) {
1018 w = widthFromFont(f, i, wordLen + 1, leadWidth, currMaxWidth, te xtDirection, &fallbackFonts, &glyphBounds) - wordTrailingSpaceWidth; 1011 w = widthFromFont(f, i, wordLen + 1, leadWidth, currMaxWidth, te xtDirection, &fallbackFonts, &glyphBounds) - wordTrailingSpaceWidth;
1019 } else { 1012 } else {
1020 w = widthFromFont(f, i, wordLen, leadWidth, currMaxWidth, textDi rection, &fallbackFonts, &glyphBounds); 1013 w = widthFromFont(f, i, wordLen, leadWidth, currMaxWidth, textDi rection, &fallbackFonts, &glyphBounds);
1021 if (c == softHyphenCharacter) 1014 if (c == softHyphenCharacter)
1022 currMinWidth += hyphenWidth(this, f, textDirection); 1015 currMinWidth += hyphenWidth(f, textDirection);
1023 } 1016 }
1024 1017
1025 currMinWidth += w; 1018 currMinWidth += w;
1026 if (betweenWords) { 1019 if (betweenWords) {
1027 if (lastWordBoundary == i) 1020 if (lastWordBoundary == i)
1028 currMaxWidth += w; 1021 currMaxWidth += w;
1029 else 1022 else
1030 currMaxWidth += widthFromFont(f, lastWordBoundary, j - lastW ordBoundary, leadWidth, currMaxWidth, textDirection, &fallbackFonts, &glyphBound s); 1023 currMaxWidth += widthFromFont(f, lastWordBoundary, j - lastW ordBoundary, leadWidth, currMaxWidth, textDirection, &fallbackFonts, &glyphBound s);
1031 lastWordBoundary = j; 1024 lastWordBoundary = j;
1032 } 1025 }
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
1862 } 1855 }
1863 1856
1864 void LayoutText::invalidateDisplayItemClients(const LayoutBoxModelObject& paintI nvalidationContainer) const 1857 void LayoutText::invalidateDisplayItemClients(const LayoutBoxModelObject& paintI nvalidationContainer) const
1865 { 1858 {
1866 LayoutObject::invalidateDisplayItemClients(paintInvalidationContainer); 1859 LayoutObject::invalidateDisplayItemClients(paintInvalidationContainer);
1867 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) 1860 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox())
1868 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box); 1861 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box);
1869 } 1862 }
1870 1863
1871 } // namespace blink 1864 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutText.h ('k') | Source/core/layout/line/BreakingContextInlineHeaders.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698