Changeset 59588 in webkit
- Timestamp:
- May 16, 2010 6:43:49 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r59585 r59588 1 2010-05-16 Dan Bernstein <mitz@apple.com> 2 3 Reviewed by Darin Adler. 4 5 Move transient glyph overflow and fallback font data from a global to the stack 6 https://bugs.webkit.org/show_bug.cgi?id=39050 7 8 * rendering/InlineFlowBox.cpp: 9 (WebCore::InlineFlowBox::placeBoxesHorizontally): Added a GlyphOverflowAndFallbackFontsMap 10 parameter. Read glyph overflow from the map. 11 (WebCore::InlineFlowBox::computeLogicalBoxHeights): Added a GlyphOverflowAndFallbackFontsMap 12 parameter. Read fallback fonts from the map. 13 (WebCore::InlineFlowBox::computeVerticalOverflow): Added a GlyphOverflowAndFallbackFontsMap 14 parameter. Read glyph overflow from the map. 15 * rendering/InlineFlowBox.h: 16 * rendering/InlineTextBox.cpp: Removed setFallbackFonts(), fallbackFonts(), setGlyphOverflow(), 17 and glyphOverflow(). Removed s_glyphOverflowAndFallbackFontsMap. 18 * rendering/InlineTextBox.h: 19 * rendering/RenderBlock.h: 20 * rendering/RenderBlockLineLayout.cpp: 21 (WebCore::RenderBlock::computeHorizontalPositionsForLine): Added a GlyphOverflowAndFallbackFontsMap 22 parameter. Write fallback fonts and glyph overflow into the map. 23 (WebCore::RenderBlock::computeVerticalPositionsForLine): Added a GlyphOverflowAndFallbackFontsMap 24 parameter. Pass it down to verticallyAlignBoxes(). 25 (WebCore::RenderBlock::layoutInlineChildren): Create a GlyphOverflowAndFallbackFontsMap on the 26 stack and pass it down to computeHorizontalPositionsForLine(), computeVerticalPositionsForLine(), 27 and verticallyAlignBoxes(). 28 * rendering/RootInlineBox.cpp: 29 (WebCore::RootInlineBox::verticallyAlignBoxes): Added a GlyphOverflowAndFallbackFontsMap parameter. 30 Pass it down to computeLogicalBoxHeights() and computeVerticalOverflow(). 31 * rendering/RootInlineBox.h: 32 * rendering/SVGRootInlineBox.cpp: 33 (WebCore::SVGRootInlineBox::layoutInlineBoxes): Updated. 34 1 35 2010-05-12 Tony Chang <tony@chromium.org> 2 36 -
trunk/WebCore/rendering/InlineFlowBox.cpp
r59274 r59588 253 253 } 254 254 255 int InlineFlowBox::placeBoxesHorizontally(int xPos, bool& needsWordSpacing )255 int InlineFlowBox::placeBoxesHorizontally(int xPos, bool& needsWordSpacing, GlyphOverflowAndFallbackFontsMap& textBoxDataMap) 256 256 { 257 257 // Set our x position. … … 290 290 rightLayoutOverflow = max(xPos + text->width() - letterSpacing, rightLayoutOverflow); 291 291 292 GlyphOverflow* glyphOverflow = static_cast<InlineTextBox*>(curr)->glyphOverflow(); 292 GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(static_cast<InlineTextBox*>(curr)); 293 GlyphOverflow* glyphOverflow = it == textBoxDataMap.end() ? 0 : &it->second.second; 293 294 294 295 int leftGlyphOverflow = -strokeOverflow - (glyphOverflow ? glyphOverflow->left : 0); … … 320 321 InlineFlowBox* flow = static_cast<InlineFlowBox*>(curr); 321 322 xPos += flow->marginLeft(); 322 xPos = flow->placeBoxesHorizontally(xPos, needsWordSpacing );323 xPos = flow->placeBoxesHorizontally(xPos, needsWordSpacing, textBoxDataMap); 323 324 xPos += flow->marginRight(); 324 325 leftLayoutOverflow = min(leftLayoutOverflow, flow->leftLayoutOverflow()); … … 392 393 393 394 void InlineFlowBox::computeLogicalBoxHeights(int& maxPositionTop, int& maxPositionBottom, 394 int& maxAscent, int& maxDescent, bool strictMode )395 int& maxAscent, int& maxDescent, bool strictMode, GlyphOverflowAndFallbackFontsMap& textBoxDataMap) 395 396 { 396 397 if (isRootInlineBox()) { … … 417 418 int baseline; 418 419 Vector<const SimpleFontData*>* usedFonts = 0; 419 if (curr->isInlineTextBox()) 420 usedFonts = static_cast<InlineTextBox*>(curr)->fallbackFonts(); 420 if (curr->isInlineTextBox()) { 421 GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(static_cast<InlineTextBox*>(curr)); 422 usedFonts = it == textBoxDataMap.end() ? 0 : &it->second.first; 423 } 421 424 422 425 if (usedFonts) { … … 469 472 470 473 if (curr->isInlineFlowBox()) 471 static_cast<InlineFlowBox*>(curr)->computeLogicalBoxHeights(maxPositionTop, maxPositionBottom, maxAscent, maxDescent, strictMode );474 static_cast<InlineFlowBox*>(curr)->computeLogicalBoxHeights(maxPositionTop, maxPositionBottom, maxAscent, maxDescent, strictMode, textBoxDataMap); 472 475 } 473 476 } … … 536 539 } 537 540 538 void InlineFlowBox::computeVerticalOverflow(int lineTop, int lineBottom, bool strictMode )541 void InlineFlowBox::computeVerticalOverflow(int lineTop, int lineBottom, bool strictMode, GlyphOverflowAndFallbackFontsMap& textBoxDataMap) 539 542 { 540 543 int boxHeight = height(); … … 573 576 int strokeOverflow = static_cast<int>(ceilf(rt->style()->textStrokeWidth() / 2.0f)); 574 577 575 GlyphOverflow* glyphOverflow = static_cast<InlineTextBox*>(curr)->glyphOverflow(); 578 GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(static_cast<InlineTextBox*>(curr)); 579 GlyphOverflow* glyphOverflow = it == textBoxDataMap.end() ? 0 : &it->second.second; 576 580 577 581 int topGlyphOverflow = -strokeOverflow - (glyphOverflow ? glyphOverflow->top : 0); … … 589 593 } else if (curr->renderer()->isRenderInline()) { 590 594 InlineFlowBox* flow = static_cast<InlineFlowBox*>(curr); 591 flow->computeVerticalOverflow(lineTop, lineBottom, strictMode );595 flow->computeVerticalOverflow(lineTop, lineBottom, strictMode, textBoxDataMap); 592 596 topLayoutOverflow = min(topLayoutOverflow, flow->topLayoutOverflow()); 593 597 bottomLayoutOverflow = max(bottomLayoutOverflow, flow->bottomLayoutOverflow()); -
trunk/WebCore/rendering/InlineFlowBox.h
r59274 r59588 29 29 class HitTestRequest; 30 30 class HitTestResult; 31 class InlineTextBox; 31 32 class RenderLineBoxList; 33 34 typedef HashMap<const InlineTextBox*, pair<Vector<const SimpleFontData*>, GlyphOverflow> > GlyphOverflowAndFallbackFontsMap; 32 35 33 36 class InlineFlowBox : public InlineBox { … … 125 128 int getFlowSpacingWidth(); 126 129 bool onEndChain(RenderObject* endObject); 127 virtual int placeBoxesHorizontally(int x, bool& needsWordSpacing );130 virtual int placeBoxesHorizontally(int x, bool& needsWordSpacing, GlyphOverflowAndFallbackFontsMap&); 128 131 void computeLogicalBoxHeights(int& maxPositionTop, int& maxPositionBottom, 129 int& maxAscent, int& maxDescent, bool strictMode );132 int& maxAscent, int& maxDescent, bool strictMode, GlyphOverflowAndFallbackFontsMap&); 130 133 void adjustMaxAscentAndDescent(int& maxAscent, int& maxDescent, 131 134 int maxPositionTop, int maxPositionBottom); 132 135 void placeBoxesVertically(int y, int maxHeight, int maxAscent, bool strictMode, int& lineTop, int& lineBottom); 133 void computeVerticalOverflow(int lineTop, int lineBottom, bool strictMode );136 void computeVerticalOverflow(int lineTop, int lineBottom, bool strictMode, GlyphOverflowAndFallbackFontsMap&); 134 137 135 138 void removeChild(InlineBox* child); -
trunk/WebCore/rendering/InlineTextBox.cpp
r59274 r59588 1025 1025 } 1026 1026 1027 void InlineTextBox::setFallbackFonts(const HashSet<const SimpleFontData*>& fallbackFonts)1028 {1029 if (!s_glyphOverflowAndFallbackFontsMap)1030 s_glyphOverflowAndFallbackFontsMap = new GlyphOverflowAndFallbackFontsMap;1031 1032 GlyphOverflowAndFallbackFontsMap::iterator it = s_glyphOverflowAndFallbackFontsMap->add(this, make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).first;1033 ASSERT(it->second.first.isEmpty());1034 copyToVector(fallbackFonts, it->second.first);1035 }1036 1037 Vector<const SimpleFontData*>* InlineTextBox::fallbackFonts() const1038 {1039 if (!s_glyphOverflowAndFallbackFontsMap)1040 return 0;1041 1042 GlyphOverflowAndFallbackFontsMap::iterator it = s_glyphOverflowAndFallbackFontsMap->find(this);1043 if (it == s_glyphOverflowAndFallbackFontsMap->end())1044 return 0;1045 1046 return &it->second.first;1047 }1048 1049 InlineTextBox::GlyphOverflowAndFallbackFontsMap* InlineTextBox::s_glyphOverflowAndFallbackFontsMap = 0;1050 1051 void InlineTextBox::setGlyphOverflow(const GlyphOverflow& glyphOverflow)1052 {1053 if (!s_glyphOverflowAndFallbackFontsMap)1054 s_glyphOverflowAndFallbackFontsMap = new GlyphOverflowAndFallbackFontsMap;1055 1056 GlyphOverflowAndFallbackFontsMap::iterator it = s_glyphOverflowAndFallbackFontsMap->add(this, make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).first;1057 it->second.second = glyphOverflow;1058 }1059 1060 GlyphOverflow* InlineTextBox::glyphOverflow() const1061 {1062 if (!s_glyphOverflowAndFallbackFontsMap)1063 return 0;1064 GlyphOverflowAndFallbackFontsMap::iterator it = s_glyphOverflowAndFallbackFontsMap->find(this);1065 if (it == s_glyphOverflowAndFallbackFontsMap->end())1066 return 0;1067 1068 return &it->second.second;1069 }1070 1071 1027 } // namespace WebCore -
trunk/WebCore/rendering/InlineTextBox.h
r59274 r59588 64 64 void offsetRun(int d) { m_start += d; } 65 65 66 void setFallbackFonts(const HashSet<const SimpleFontData*>&);67 Vector<const SimpleFontData*>* fallbackFonts() const;68 69 void setGlyphOverflow(const GlyphOverflow&);70 GlyphOverflow* glyphOverflow() const;71 72 static void clearGlyphOverflowAndFallbackFontMap()73 {74 if (s_glyphOverflowAndFallbackFontsMap)75 s_glyphOverflowAndFallbackFontsMap->clear();76 }77 78 66 unsigned short truncation() { return m_truncation; } 79 67 … … 139 127 // denote no truncation (the whole run paints) and full truncation (nothing paints at all). 140 128 141 typedef HashMap<const InlineTextBox*, pair<Vector<const SimpleFontData*>, GlyphOverflow> > GlyphOverflowAndFallbackFontsMap;142 static GlyphOverflowAndFallbackFontsMap* s_glyphOverflowAndFallbackFontsMap;143 144 129 protected: 145 130 void paintCompositionBackground(GraphicsContext*, int tx, int ty, RenderStyle*, const Font&, int startPos, int endPos); -
trunk/WebCore/rendering/RenderBlock.h
r57096 r59588 265 265 RootInlineBox* constructLine(unsigned runCount, BidiRun* firstRun, BidiRun* lastRun, bool firstLine, bool lastLine, RenderObject* endObject); 266 266 InlineFlowBox* createLineBoxes(RenderObject*, bool firstLine); 267 void computeHorizontalPositionsForLine(RootInlineBox*, bool firstLine, BidiRun* firstRun, BidiRun* trailingSpaceRun, bool reachedEnd );268 void computeVerticalPositionsForLine(RootInlineBox*, BidiRun* );267 void computeHorizontalPositionsForLine(RootInlineBox*, bool firstLine, BidiRun* firstRun, BidiRun* trailingSpaceRun, bool reachedEnd, GlyphOverflowAndFallbackFontsMap&); 268 void computeVerticalPositionsForLine(RootInlineBox*, BidiRun*, GlyphOverflowAndFallbackFontsMap&); 269 269 void deleteEllipsisLineBoxes(); 270 270 void checkLinesForTextOverflow(); -
trunk/WebCore/rendering/RenderBlockLineLayout.cpp
r59274 r59588 310 310 } 311 311 312 void RenderBlock::computeHorizontalPositionsForLine(RootInlineBox* lineBox, bool firstLine, BidiRun* firstRun, BidiRun* trailingSpaceRun, bool reachedEnd )312 void RenderBlock::computeHorizontalPositionsForLine(RootInlineBox* lineBox, bool firstLine, BidiRun* firstRun, BidiRun* trailingSpaceRun, bool reachedEnd, GlyphOverflowAndFallbackFontsMap& textBoxDataMap) 313 313 { 314 314 // First determine our total width. … … 350 350 ) { 351 351 ASSERT(r->m_box->isText()); 352 static_cast<InlineTextBox*>(r->m_box)->setFallbackFonts(fallbackFonts); 352 GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.add(static_cast<InlineTextBox*>(r->m_box), make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).first; 353 ASSERT(it->second.first.isEmpty()); 354 copyToVector(fallbackFonts, it->second.first); 353 355 } 354 356 if ((glyphOverflow.top || glyphOverflow.bottom || glyphOverflow.left || glyphOverflow.right) … … 358 360 ) { 359 361 ASSERT(r->m_box->isText()); 360 static_cast<InlineTextBox*>(r->m_box)->setGlyphOverflow(glyphOverflow); 362 GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.add(static_cast<InlineTextBox*>(r->m_box), make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).first; 363 it->second.second = glyphOverflow; 361 364 } 362 365 } else if (!r->m_object->isRenderInline()) { … … 475 478 // compute accurate widths for the inline flow boxes). 476 479 needsWordSpacing = false; 477 lineBox->placeBoxesHorizontally(x, needsWordSpacing );478 } 479 480 void RenderBlock::computeVerticalPositionsForLine(RootInlineBox* lineBox, BidiRun* firstRun )481 { 482 setHeight(lineBox->verticallyAlignBoxes(height() ));480 lineBox->placeBoxesHorizontally(x, needsWordSpacing, textBoxDataMap); 481 } 482 483 void RenderBlock::computeVerticalPositionsForLine(RootInlineBox* lineBox, BidiRun* firstRun, GlyphOverflowAndFallbackFontsMap& textBoxDataMap) 484 { 485 setHeight(lineBox->verticallyAlignBoxes(height(), textBoxDataMap)); 483 486 lineBox->setBlockHeight(height()); 484 487 … … 740 743 741 744 // Now we position all of our text runs horizontally. 742 computeHorizontalPositionsForLine(lineBox, firstLine, resolver.firstRun(), trailingSpaceRun, end.atEnd()); 745 GlyphOverflowAndFallbackFontsMap textBoxDataMap; 746 computeHorizontalPositionsForLine(lineBox, firstLine, resolver.firstRun(), trailingSpaceRun, end.atEnd(), textBoxDataMap); 743 747 744 748 // Now position our text runs vertically. 745 computeVerticalPositionsForLine(lineBox, resolver.firstRun()); 746 InlineTextBox::clearGlyphOverflowAndFallbackFontMap(); 749 computeVerticalPositionsForLine(lineBox, resolver.firstRun(), textBoxDataMap); 747 750 748 751 #if ENABLE(SVG) … … 840 843 m_lineBoxes.appendLineBox(trailingFloatsLineBox); 841 844 trailingFloatsLineBox->setConstructed(); 842 trailingFloatsLineBox->verticallyAlignBoxes(height()); 845 GlyphOverflowAndFallbackFontsMap textBoxDataMap; 846 trailingFloatsLineBox->verticallyAlignBoxes(height(), textBoxDataMap); 843 847 trailingFloatsLineBox->setHeight(0); 844 848 trailingFloatsLineBox->setVerticalOverflowPositions(height(), bottomLayoutOverflow, height(), bottomVisualOverflow); -
trunk/WebCore/rendering/RootInlineBox.cpp
r59274 r59588 203 203 } 204 204 205 int RootInlineBox::verticallyAlignBoxes(int heightOfBlock )205 int RootInlineBox::verticallyAlignBoxes(int heightOfBlock, GlyphOverflowAndFallbackFontsMap& textBoxDataMap) 206 206 { 207 207 int maxPositionTop = 0; … … 217 217 bool strictMode = (curr && curr->document()->inStrictMode()); 218 218 219 computeLogicalBoxHeights(maxPositionTop, maxPositionBottom, maxAscent, maxDescent, strictMode );219 computeLogicalBoxHeights(maxPositionTop, maxPositionBottom, maxAscent, maxDescent, strictMode, textBoxDataMap); 220 220 221 221 if (maxAscent + maxDescent < max(maxPositionTop, maxPositionBottom)) … … 226 226 int lineBottom = heightOfBlock; 227 227 placeBoxesVertically(heightOfBlock, maxHeight, maxAscent, strictMode, lineTop, lineBottom); 228 computeVerticalOverflow(lineTop, lineBottom, strictMode );228 computeVerticalOverflow(lineTop, lineBottom, strictMode, textBoxDataMap); 229 229 setLineTopBottomPositions(lineTop, lineBottom); 230 230 -
trunk/WebCore/rendering/RootInlineBox.h
r55928 r59588 62 62 int selectionHeight() const { return max(0, selectionBottom() - selectionTop()); } 63 63 64 virtual int verticallyAlignBoxes(int heightOfBlock );64 virtual int verticallyAlignBoxes(int heightOfBlock, GlyphOverflowAndFallbackFontsMap&); 65 65 void setLineTopBottomPositions(int top, int bottom); 66 66 -
trunk/WebCore/rendering/SVGRootInlineBox.cpp
r59148 r59588 896 896 static_cast<SVGRootInlineBox*>(start)->setHeight(highY - lowY); 897 897 898 start->computeVerticalOverflow(top, bottom, true); 898 GlyphOverflowAndFallbackFontsMap textBoxDataMap; 899 start->computeVerticalOverflow(top, bottom, true, textBoxDataMap); 899 900 static_cast<SVGRootInlineBox*>(start)->setLineTopBottomPositions(top, bottom); 900 901 }
Note: See TracChangeset
for help on using the changeset viewer.