Changeset 72235 in webkit
- Timestamp:
- Nov 17, 2010 12:55:40 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 9 added
- 48 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r72231 r72235 1 2010-11-17 Dave Hyatt <hyatt@apple.com> 2 3 Reviewed by Sam Weinig. 4 5 https://bugs.webkit.org/show_bug.cgi?id=48537 6 7 Fonts with no vertical metrics should synthesize baselines when they appear 8 on lines that do use fonts with vertical metrics. Basically we want to make 9 sure that English text behaves like vertical-align:middle, i.e., its baseline 10 should be treated as though it cuts through the middle of the ascent+descent. 11 12 The way this works is that each line in the line box tree is labeled as having 13 a baseline type that is either ideographic or alphabetic for the purposes of 14 vertical alignment. A line becomes ideographic if any font with vertical tables 15 is either explicitly specified as the primary font or in any of the used fonts 16 in the text on that line. 17 18 This baselineType is passed down to computeLogicalBoxHeights and placeBoxesInBlockDirection, 19 and passed to the ascent and descent methods of the fonts that are examined. 20 The underlying Font code selects an appropriate baseline given the type passed in. 21 22 This patch also rewrites vertical alignment to lop 4 bytes off all RenderInlines and 23 to instead carry around the cached vertical positions for RenderInlines in a new 24 VerticalPositionCache object. This cache only lives for a single layout 25 operation, but it does cache information across all the lines built and placed during the 26 layout. 27 28 This matches the old behavior, since every call to layoutInlineChildren invalidated 29 all of the vertical positions in all of the RenderInlines anyway. 30 31 The VerticalPositionCache consists of two HashMaps, and it caches vertical alignment 32 positions for both alphabetic and ideographic baseline types. 33 34 The vertical-align computation has now been moved out of RenderBoxModelObject and 35 RenderInline and just placed right into verticalPositionForBox in InlineFlowBox. 36 This function has been changed to no longer be recursive when checking parents, 37 and it now relies on the fact that the parent vertical alignment computation result 38 has already been stored in the logicalTop() of that parent's line box. By checking 39 the line box logicalTop() value instead of recurring, the performance of first lines 40 now significantly improves to no longer have O(n^2) behavior in the depth of the line 41 box tree on the first line. 42 43 All of the baselinePosition functions on the various RenderObjects have been amended 44 to take a FontBaseline as the first argument. This patch does not attempt to fix up 45 MathML or form controls yet and just hardcodes AlphabeticBaselines for those renderers. 46 47 The RenderTableCell baselinePosition virtual method has been made non-virtual and had 48 all arguments removed, since it actually had no real connection with the rest of the 49 baseline positioning system. Cell baseline positioning works by calling firstLineBoxBaseline, 50 and that method has been patched to use the cached baselineType for the first line box 51 when computing the baseline of that line. 52 53 Added fast/blockflow/vertical-baseline-alignment.html and fast/blockflow/vertical-align-table-baseline.html 54 55 * fast/blockflow/vertical-align-table-baseline.html: Added. 56 * fast/blockflow/vertical-baseline-alignment.html: Added. 57 * platform/mac/fast/blockflow/vertical-align-table-baseline-expected.checksum: Added. 58 * platform/mac/fast/blockflow/vertical-align-table-baseline-expected.png: Added. 59 * platform/mac/fast/blockflow/vertical-align-table-baseline-expected.txt: Added. 60 * platform/mac/fast/blockflow/vertical-baseline-alignment-expected.checksum: Added. 61 * platform/mac/fast/blockflow/vertical-baseline-alignment-expected.png: Added. 62 * platform/mac/fast/blockflow/vertical-baseline-alignment-expected.txt: Added. 63 * platform/mac/fast/blockflow/vertical-font-fallback-expected.checksum: 64 * platform/mac/fast/blockflow/vertical-font-fallback-expected.png: 65 * platform/mac/fast/blockflow/vertical-font-fallback-expected.txt: 66 * platform/mac/fast/repaint/repaint-across-writing-mode-boundary-expected.checksum: 67 * platform/mac/fast/repaint/repaint-across-writing-mode-boundary-expected.png: 68 * platform/mac/fast/repaint/repaint-across-writing-mode-boundary-expected.txt: 69 1 70 2010-11-17 Martin Robinson <mrobinson@igalia.com> 2 71 -
trunk/LayoutTests/platform/mac/fast/blockflow/vertical-font-fallback-expected.checksum
r72173 r72235 1 1a38c793aeaed823708cc6bd9330c2d3 1 3c29af017e24ccc90fe35bd1d4377664 -
trunk/LayoutTests/platform/mac/fast/blockflow/vertical-font-fallback-expected.txt
r72173 r72235 5 5 RenderBody {BODY} at (50,50) size 700x277 6 6 RenderBlock {DIV} at (0,0) size 556x277 [bgcolor=#EEEEEE] 7 RenderBlock {DIV} at (1,1) size 277x12 7[bgcolor=#FFEEEE]8 RenderBlock {P} at (14,28) size 249x2 2[bgcolor=#FFAAAA] [border: (20px solid #FF8888) none (20px solid #FF8888)]9 RenderText {#text} at (21, 0) size 181x2310 text run at (21, 0) width 181: "\x{7B2C}\x{4E00}\x{6BB5}\x{843D} paragraph 1"11 RenderBlock {P} at (14,7 7) size 249x22[bgcolor=#FFAAAA] [border: (20px solid #FF8888) none (20px solid #FF8888)]12 RenderText {#text} at (21, 0) size 181x2313 text run at (21, 0) width 181: "\x{7B2C}\x{4E8C}\x{6BB5}\x{843D} paragraph 2"7 RenderBlock {DIV} at (1,1) size 277x129 [bgcolor=#FFEEEE] 8 RenderBlock {P} at (14,28) size 249x23 [bgcolor=#FFAAAA] [border: (20px solid #FF8888) none (20px solid #FF8888)] 9 RenderText {#text} at (21,1) size 181x23 10 text run at (21,1) width 181: "\x{7B2C}\x{4E00}\x{6BB5}\x{843D} paragraph 1" 11 RenderBlock {P} at (14,78) size 249x23 [bgcolor=#FFAAAA] [border: (20px solid #FF8888) none (20px solid #FF8888)] 12 RenderText {#text} at (21,1) size 181x23 13 text run at (21,1) width 181: "\x{7B2C}\x{4E8C}\x{6BB5}\x{843D} paragraph 2" 14 14 RenderBlock {DIV} at (278,1) size 277x275 [bgcolor=#FFFFEE] 15 15 RenderBlock {P} at (14,28) size 62x219 [bgcolor=#FFAAAA] [border: (20px solid #FF8888) none (20px solid #FF8888)] -
trunk/LayoutTests/platform/mac/fast/repaint/repaint-across-writing-mode-boundary-expected.checksum
r72173 r72235 1 7df50cf92359b0a4f0ba95b803db77aa 1 14415853860aa0e125353aa6fcdd7c35 -
trunk/LayoutTests/platform/mac/fast/repaint/repaint-across-writing-mode-boundary-expected.txt
r72173 r72235 5 5 RenderBody {BODY} at (50,50) size 700x277 6 6 RenderBlock {DIV} at (0,0) size 556x277 [bgcolor=#EEEEEE] 7 RenderBlock {DIV} at (1,1) size 277x12 7[bgcolor=#FFEEEE]8 RenderBlock {P} at (14,28) size 249x2 2[bgcolor=#FFAAAA] [border: (20px solid #FF8888) none (20px solid #FF8888)]9 RenderText {#text} at (21, 0) size 181x2310 text run at (21, 0) width 181: "\x{7B2C}\x{4E00}\x{6BB5}\x{843D} paragraph 1"11 RenderBlock {P} at (14,7 7) size 249x22[bgcolor=#FFAAAA] [border: (20px solid #FF8888) none (20px solid #FF8888)]12 RenderText {#text} at (21, 0) size 181x2313 text run at (21, 0) width 181: "\x{7B2C}\x{4E8C}\x{6BB5}\x{843D} paragraph 2"7 RenderBlock {DIV} at (1,1) size 277x129 [bgcolor=#FFEEEE] 8 RenderBlock {P} at (14,28) size 249x23 [bgcolor=#FFAAAA] [border: (20px solid #FF8888) none (20px solid #FF8888)] 9 RenderText {#text} at (21,1) size 181x23 10 text run at (21,1) width 181: "\x{7B2C}\x{4E00}\x{6BB5}\x{843D} paragraph 1" 11 RenderBlock {P} at (14,78) size 249x23 [bgcolor=#FFAAAA] [border: (20px solid #FF8888) none (20px solid #FF8888)] 12 RenderText {#text} at (21,1) size 181x23 13 text run at (21,1) width 181: "\x{7B2C}\x{4E8C}\x{6BB5}\x{843D} paragraph 2" 14 14 RenderBlock {DIV} at (278,1) size 277x275 [bgcolor=#FFFFEE] 15 15 RenderBlock {P} at (14,28) size 62x219 [bgcolor=#FFAAAA] [border: (20px solid #FF8888) none (20px solid #FF8888)] -
trunk/WebCore/ChangeLog
r72232 r72235 1 2010-11-17 Dave Hyatt <hyatt@apple.com> 2 3 Reviewed by Sam Weinig. 4 5 https://bugs.webkit.org/show_bug.cgi?id=48537 6 7 Fonts with no vertical metrics should synthesize baselines when they appear 8 on lines that do use fonts with vertical metrics. Basically we want to make 9 sure that English text behaves like vertical-align:middle, i.e., its baseline 10 should be treated as though it cuts through the middle of the ascent+descent. 11 12 The way this works is that each line in the line box tree is labeled as having 13 a baseline type that is either ideographic or alphabetic for the purposes of 14 vertical alignment. A line becomes ideographic if any font with vertical tables 15 is either explicitly specified as the primary font or in any of the used fonts 16 in the text on that line. 17 18 This baselineType is passed down to computeLogicalBoxHeights and placeBoxesInBlockDirection, 19 and passed to the ascent and descent methods of the fonts that are examined. 20 The underlying Font code selects an appropriate baseline given the type passed in. 21 22 This patch also rewrites vertical alignment to lop 4 bytes off all RenderInlines and 23 to instead carry around the cached vertical positions for RenderInlines in a new 24 VerticalPositionCache object. This cache only lives for a single layout 25 operation, but it does cache information across all the lines built and placed during the 26 layout. 27 28 This matches the old behavior, since every call to layoutInlineChildren invalidated 29 all of the vertical positions in all of the RenderInlines anyway. 30 31 The VerticalPositionCache consists of two HashMaps, and it caches vertical alignment 32 positions for both alphabetic and ideographic baseline types. 33 34 The vertical-align computation has now been moved out of RenderBoxModelObject and 35 RenderInline and just placed right into verticalPositionForBox in InlineFlowBox. 36 This function has been changed to no longer be recursive when checking parents, 37 and it now relies on the fact that the parent vertical alignment computation result 38 has already been stored in the logicalTop() of that parent's line box. By checking 39 the line box logicalTop() value instead of recurring, the performance of first lines 40 now significantly improves to no longer have O(n^2) behavior in the depth of the line 41 box tree on the first line. 42 43 All of the baselinePosition functions on the various RenderObjects have been amended 44 to take a FontBaseline as the first argument. This patch does not attempt to fix up 45 MathML or form controls yet and just hardcodes AlphabeticBaselines for those renderers. 46 47 The RenderTableCell baselinePosition virtual method has been made non-virtual and had 48 all arguments removed, since it actually had no real connection with the rest of the 49 baseline positioning system. Cell baseline positioning works by calling firstLineBoxBaseline, 50 and that method has been patched to use the cached baselineType for the first line box 51 when computing the baseline of that line. 52 53 Added fast/blockflow/vertical-baseline-alignment.html and fast/blockflow/vertical-align-table-baseline.html. 54 55 * WebCore.xcodeproj/project.pbxproj: 56 * mathml/RenderMathMLFraction.cpp: 57 (WebCore::RenderMathMLFraction::baselinePosition): 58 * mathml/RenderMathMLFraction.h: 59 * mathml/RenderMathMLOperator.cpp: 60 (WebCore::RenderMathMLOperator::baselinePosition): 61 * mathml/RenderMathMLOperator.h: 62 * mathml/RenderMathMLRow.cpp: 63 (WebCore::RenderMathMLRow::baselinePosition): 64 * mathml/RenderMathMLRow.h: 65 * mathml/RenderMathMLSubSup.cpp: 66 (WebCore::RenderMathMLSubSup::baselinePosition): 67 * mathml/RenderMathMLSubSup.h: 68 * mathml/RenderMathMLUnderOver.cpp: 69 (WebCore::RenderMathMLUnderOver::layout): 70 (WebCore::RenderMathMLUnderOver::baselinePosition): 71 * mathml/RenderMathMLUnderOver.h: 72 * platform/graphics/SimpleFontData.h: 73 * rendering/InlineBox.h: 74 (WebCore::InlineBox::baselinePosition): 75 * rendering/InlineFlowBox.cpp: 76 (WebCore::verticalPositionForBox): 77 (WebCore::InlineFlowBox::computeLogicalBoxHeights): 78 (WebCore::InlineFlowBox::placeBoxesInBlockDirection): 79 * rendering/InlineFlowBox.h: 80 * rendering/InlineTextBox.cpp: 81 (WebCore::InlineTextBox::baselinePosition): 82 * rendering/InlineTextBox.h: 83 * rendering/RenderBlock.cpp: 84 (WebCore::RenderBlock::baselinePosition): 85 (WebCore::RenderBlock::firstLineBoxBaseline): 86 (WebCore::RenderBlock::lastLineBoxBaseline): 87 * rendering/RenderBlock.h: 88 * rendering/RenderBlockLineLayout.cpp: 89 (WebCore::RenderBlock::computeBlockDirectionPositionsForLine): 90 (WebCore::RenderBlock::layoutInlineChildren): 91 * rendering/RenderBox.cpp: 92 (WebCore::RenderBox::baselinePosition): 93 * rendering/RenderBox.h: 94 * rendering/RenderBoxModelObject.cpp: 95 * rendering/RenderBoxModelObject.h: 96 * rendering/RenderFileUploadControl.cpp: 97 (WebCore::RenderFileUploadControl::paintObject): 98 * rendering/RenderInline.cpp: 99 (WebCore::RenderInline::RenderInline): 100 (WebCore::RenderInline::baselinePosition): 101 * rendering/RenderInline.h: 102 * rendering/RenderListBox.cpp: 103 (WebCore::RenderListBox::baselinePosition): 104 * rendering/RenderListBox.h: 105 * rendering/RenderListMarker.cpp: 106 (WebCore::RenderListMarker::baselinePosition): 107 * rendering/RenderListMarker.h: 108 * rendering/RenderSlider.cpp: 109 (WebCore::RenderSlider::baselinePosition): 110 * rendering/RenderSlider.h: 111 * rendering/RenderTableCell.cpp: 112 (WebCore::RenderTableCell::baselinePosition): 113 * rendering/RenderTableCell.h: 114 * rendering/RenderTextControlMultiLine.cpp: 115 (WebCore::RenderTextControlMultiLine::baselinePosition): 116 * rendering/RenderTextControlMultiLine.h: 117 * rendering/RootInlineBox.cpp: 118 (WebCore::RootInlineBox::alignBoxesInBlockDirection): 119 * rendering/RootInlineBox.h: 120 (WebCore::RootInlineBox::baselinePosition): 121 * rendering/VerticalPositionCache.h: Added. 122 (WebCore::VerticalPositionCache::VerticalPositionCache): 123 (WebCore::VerticalPositionCache::get): 124 (WebCore::VerticalPositionCache::set): 125 * rendering/svg/SVGInlineTextBox.cpp: 126 (WebCore::SVGInlineTextBox::calculateBoundaries): 127 1 128 2010-11-17 Sam Weinig <sam@webkit.org> 2 129 -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r72232 r72235 5017 5017 BCA169A20BFD55B40019CA76 /* JSHTMLTableCaptionElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCA169A00BFD55B40019CA76 /* JSHTMLTableCaptionElement.cpp */; }; 5018 5018 BCA169A30BFD55B40019CA76 /* JSHTMLTableCaptionElement.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA169A10BFD55B40019CA76 /* JSHTMLTableCaptionElement.h */; }; 5019 BCA257151293C010007A263D /* VerticalPositionCache.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA257141293C010007A263D /* VerticalPositionCache.h */; }; 5019 5020 BCA2B061105047600043BD1C /* UserScript.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA2B0601050475F0043BD1C /* UserScript.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5020 5021 BCA2B08B10505BCD0043BD1C /* UserScriptTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA2B08A10505BCD0043BD1C /* UserScriptTypes.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 11051 11052 BCA169A00BFD55B40019CA76 /* JSHTMLTableCaptionElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLTableCaptionElement.cpp; sourceTree = "<group>"; }; 11052 11053 BCA169A10BFD55B40019CA76 /* JSHTMLTableCaptionElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLTableCaptionElement.h; sourceTree = "<group>"; }; 11054 BCA257141293C010007A263D /* VerticalPositionCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VerticalPositionCache.h; sourceTree = "<group>"; }; 11053 11055 BCA2B0601050475F0043BD1C /* UserScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserScript.h; sourceTree = "<group>"; }; 11054 11056 BCA2B08A10505BCD0043BD1C /* UserScriptTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserScriptTypes.h; sourceTree = "<group>"; }; … … 18105 18107 0F500AB00F54DB3100EEF928 /* TransformState.cpp */, 18106 18108 0F500AAE0F54DB1B00EEF928 /* TransformState.h */, 18109 BCA257141293C010007A263D /* VerticalPositionCache.h */, 18107 18110 ); 18108 18111 path = rendering; … … 21337 21340 3888F6EF128C9889000CA8E0 /* InspectorFileSystemAgent.h in Headers */, 21338 21341 BCB92D4F1293550B00C8387F /* FontBaseline.h in Headers */, 21342 BCA257151293C010007A263D /* VerticalPositionCache.h in Headers */, 21339 21343 BCAE1FA712939DB7004CB026 /* ScrollAnimatorMac.h in Headers */, 21340 21344 ); -
trunk/WebCore/mathml/RenderMathMLFraction.cpp
r70221 r72235 168 168 } 169 169 170 int RenderMathMLFraction::baselinePosition( bool firstLine, LineDirectionMode lineDirection, LinePositionMode linePositionMode) const170 int RenderMathMLFraction::baselinePosition(FontBaseline, bool firstLine, LineDirectionMode lineDirection, LinePositionMode linePositionMode) const 171 171 { 172 172 if (firstChild() && firstChild()->isRenderMathMLBlock()) { … … 178 178 return numerator->offsetHeight() + style()->fontSize() / 3; 179 179 } 180 return RenderBlock::baselinePosition( firstLine, lineDirection, linePositionMode);180 return RenderBlock::baselinePosition(AlphabeticBaseline, firstLine, lineDirection, linePositionMode); 181 181 } 182 182 -
trunk/WebCore/mathml/RenderMathMLFraction.h
r70072 r72235 39 39 virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0); 40 40 virtual void updateFromElement(); 41 virtual int baselinePosition( bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;41 virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; 42 42 virtual void paint(PaintInfo&, int tx, int ty); 43 43 protected: -
trunk/WebCore/mathml/RenderMathMLOperator.cpp
r70221 r72235 333 333 } 334 334 335 int RenderMathMLOperator::baselinePosition( bool firstLine, LineDirectionMode lineDirection, LinePositionMode linePositionMode) const335 int RenderMathMLOperator::baselinePosition(FontBaseline, bool firstLine, LineDirectionMode lineDirection, LinePositionMode linePositionMode) const 336 336 { 337 337 if (m_isStacked) 338 338 return m_stretchHeight * 2 / 3 - (m_stretchHeight - static_cast<int>(m_stretchHeight / gOperatorExpansion)) / 2; 339 return RenderBlock::baselinePosition( firstLine, lineDirection, linePositionMode);339 return RenderBlock::baselinePosition(AlphabeticBaseline, firstLine, lineDirection, linePositionMode); 340 340 } 341 341 -
trunk/WebCore/mathml/RenderMathMLOperator.h
r70072 r72235 42 42 virtual void updateFromElement(); 43 43 virtual bool isChildAllowed(RenderObject*, RenderStyle*) const; 44 virtual int baselinePosition( bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;44 virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; 45 45 46 46 protected: -
trunk/WebCore/mathml/RenderMathMLRow.cpp
r70221 r72235 120 120 } 121 121 122 int RenderMathMLRow::baselinePosition( bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const122 int RenderMathMLRow::baselinePosition(FontBaseline, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const 123 123 { 124 124 if (firstChild() && firstChild()->isRenderMathMLBlock()) { 125 125 RenderMathMLBlock* block = toRenderMathMLBlock(firstChild()); 126 126 if (block->isRenderMathMLOperator()) 127 return block->y() + block->baselinePosition( firstLine, direction, linePositionMode);127 return block->y() + block->baselinePosition(AlphabeticBaseline, firstLine, direction, linePositionMode); 128 128 } 129 129 130 return RenderBlock::baselinePosition( firstLine, direction, linePositionMode);130 return RenderBlock::baselinePosition(AlphabeticBaseline, firstLine, direction, linePositionMode); 131 131 } 132 132 -
trunk/WebCore/mathml/RenderMathMLRow.h
r70221 r72235 38 38 virtual bool isRenderMathMLRow() const { return true; } 39 39 virtual int nonOperatorHeight() const; 40 virtual int baselinePosition( bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;40 virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; 41 41 virtual void stretchToHeight(int) {} 42 42 protected: -
trunk/WebCore/mathml/RenderMathMLSubSup.cpp
r70221 r72235 174 174 } 175 175 176 int RenderMathMLSubSup::baselinePosition( bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const176 int RenderMathMLSubSup::baselinePosition(FontBaseline, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const 177 177 { 178 178 RenderObject* base = firstChild(); … … 195 195 // The baseline is top spacing of the base + the baseline of the base + adjusted space for zoom 196 196 float zoomFactor = style()->effectiveZoom(); 197 return topAdjust + box->baselinePosition( firstLine, direction, linePositionMode) + static_cast<int>((zoomFactor > 1.25 ? 2 : 3) * zoomFactor);197 return topAdjust + box->baselinePosition(AlphabeticBaseline, firstLine, direction, linePositionMode) + static_cast<int>((zoomFactor > 1.25 ? 2 : 3) * zoomFactor); 198 198 } 199 199 break; … … 201 201 case Sub: 202 202 RenderBoxModelObject* box = toRenderBoxModelObject(base); 203 baseline = box->baselinePosition( firstLine, direction, linePositionMode);203 baseline = box->baselinePosition(AlphabeticBaseline, firstLine, direction, linePositionMode); 204 204 break; 205 205 } -
trunk/WebCore/mathml/RenderMathMLSubSup.h
r70072 r72235 42 42 virtual int nonOperatorHeight() const; 43 43 virtual void stretchToHeight(int pixelHeight); 44 virtual int baselinePosition( bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;44 virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; 45 45 46 46 protected: -
trunk/WebCore/mathml/RenderMathMLUnderOver.cpp
r70221 r72235 159 159 break; 160 160 161 int overSpacing = static_cast<int>(gOverSpacingAdjustment * (getOffsetHeight(over) - toRenderBoxModelObject(over->firstChild())->baselinePosition( true, HorizontalLine)));161 int overSpacing = static_cast<int>(gOverSpacingAdjustment * (getOffsetHeight(over) - toRenderBoxModelObject(over->firstChild())->baselinePosition(AlphabeticBaseline, true, HorizontalLine))); 162 162 163 163 // base row wrapper … … 189 189 // FIXME: We need to look at the space between a single maximum height of 190 190 // the line boxes and the baseline and squeeze them together 191 int underSpacing = baseHeight - toRenderBoxModelObject(base)->baselinePosition( true, HorizontalLine);191 int underSpacing = baseHeight - toRenderBoxModelObject(base)->baselinePosition(AlphabeticBaseline, true, HorizontalLine); 192 192 193 193 // adjust the base's intrusion into the under … … 210 210 if (!over->firstChild()->isBoxModelObject()) 211 211 break; 212 int overSpacing = static_cast<int>(gOverSpacingAdjustment * (getOffsetHeight(over) - toRenderBoxModelObject(over->firstChild())->baselinePosition( true, HorizontalLine)));212 int overSpacing = static_cast<int>(gOverSpacingAdjustment * (getOffsetHeight(over) - toRenderBoxModelObject(over->firstChild())->baselinePosition(AlphabeticBaseline, true, HorizontalLine))); 213 213 214 214 // base row wrapper … … 230 230 // FIXME: We need to look at the space between a single maximum height of 231 231 // the line boxes and the baseline and squeeze them together 232 int underSpacing = baseHeight - toRenderBoxModelObject(base)->baselinePosition( true, HorizontalLine);232 int underSpacing = baseHeight - toRenderBoxModelObject(base)->baselinePosition(AlphabeticBaseline, true, HorizontalLine); 233 233 234 234 RenderObject* under = lastChild(); … … 244 244 } 245 245 246 int RenderMathMLUnderOver::baselinePosition( bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const246 int RenderMathMLUnderOver::baselinePosition(FontBaseline, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const 247 247 { 248 248 RenderObject* current = firstChild(); 249 249 if (!current) 250 return RenderBlock::baselinePosition( firstLine, direction, linePositionMode);250 return RenderBlock::baselinePosition(AlphabeticBaseline, firstLine, direction, linePositionMode); 251 251 252 252 int baseline = 0; … … 261 261 if (!base || !base->isBoxModelObject()) 262 262 break; 263 baseline += toRenderBoxModelObject(base)->baselinePosition( firstLine, HorizontalLine, linePositionMode);263 baseline += toRenderBoxModelObject(base)->baselinePosition(AlphabeticBaseline, firstLine, HorizontalLine, linePositionMode); 264 264 // added the negative top margin 265 265 baseline += current->style()->marginTop().value(); … … 269 269 RenderObject* base = current->firstChild(); 270 270 if (base && base->isBoxModelObject()) 271 baseline += toRenderBoxModelObject(base)->baselinePosition( true, HorizontalLine);271 baseline += toRenderBoxModelObject(base)->baselinePosition(AlphabeticBaseline, true, HorizontalLine); 272 272 } 273 273 -
trunk/WebCore/mathml/RenderMathMLUnderOver.h
r70072 r72235 41 41 virtual bool hasBase() const { return true; } 42 42 virtual int nonOperatorHeight() const; 43 virtual int baselinePosition( bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;43 virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; 44 44 virtual void stretchToHeight(int pixelHeight); 45 45 private: -
trunk/WebCore/platform/graphics/SimpleFontData.h
r72165 r72235 81 81 SimpleFontData* brokenIdeographFontData() const; 82 82 83 // vertical metrics 83 // FIXME: Use the actual metrics for fonts with vertical tables instead of just hard-coding. If the font is horizontally oriented or 84 // a broken ideographic font, then just hard-code to split ascent/descent down the middle. Otherwise we should actually use the metrics 85 // from the font itself. 84 86 int ascent(FontBaseline baselineType = AlphabeticBaseline) const { return baselineType == AlphabeticBaseline ? m_ascent : height() - height() / 2; } 85 87 int descent(FontBaseline baselineType = AlphabeticBaseline) const { return baselineType == AlphabeticBaseline ? m_descent : height() / 2; } -
trunk/WebCore/rendering/InlineBox.h
r71700 r72235 256 256 int logicalHeight() const; 257 257 258 virtual int baselinePosition( ) const { return boxModelObject()->baselinePosition(m_firstLine, isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine); }258 virtual int baselinePosition(FontBaseline baselineType) const { return boxModelObject()->baselinePosition(baselineType, m_firstLine, isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine); } 259 259 virtual int lineHeight() const { return boxModelObject()->lineHeight(m_firstLine, isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine); } 260 260 -
trunk/WebCore/rendering/InlineFlowBox.cpp
r72173 r72235 36 36 #include "RootInlineBox.h" 37 37 #include "Text.h" 38 #include "VerticalPositionCache.h" 38 39 39 40 #include <math.h> … … 425 426 } 426 427 427 static int verticalPositionForBox(InlineBox* curr, bool firstLine) 428 { 429 if (curr->renderer()->isText()) 430 return curr->parent()->logicalTop(); 431 if (curr->renderer()->isBox()) 432 return toRenderBox(curr->renderer())->verticalPosition(firstLine); 433 return toRenderInline(curr->renderer())->verticalPositionFromCache(firstLine); 428 static int verticalPositionForBox(InlineBox* box, FontBaseline baselineType, bool firstLine, VerticalPositionCache& verticalPositionCache) 429 { 430 if (box->renderer()->isText()) 431 return box->parent()->logicalTop(); 432 433 RenderBoxModelObject* renderer = box->boxModelObject(); 434 ASSERT(renderer->isInline()); 435 if (!renderer->isInline()) 436 return 0; 437 438 // This method determines the vertical position for inline elements. 439 if (firstLine && !renderer->document()->usesFirstLineRules()) 440 firstLine = false; 441 442 // Check the cache. 443 bool isRenderInline = renderer->isRenderInline(); 444 if (isRenderInline && !firstLine) { 445 int verticalPosition = verticalPositionCache.get(renderer, baselineType); 446 if (verticalPosition != PositionUndefined) 447 return verticalPosition; 448 } 449 450 int verticalPosition = 0; 451 EVerticalAlign verticalAlign = renderer->style()->verticalAlign(); 452 if (verticalAlign == TOP) 453 verticalPosition = PositionTop; 454 else if (verticalAlign == BOTTOM) 455 verticalPosition = PositionBottom; 456 else { 457 RenderObject* parent = renderer->parent(); 458 if (parent->isRenderInline() && parent->style()->verticalAlign() != TOP && parent->style()->verticalAlign() != BOTTOM) 459 verticalPosition = box->parent()->logicalTop(); 460 461 if (verticalAlign != BASELINE) { 462 const Font& font = parent->style(firstLine)->font(); 463 int fontSize = font.pixelSize(); 464 465 LineDirectionMode lineDirection = parent->style()->isHorizontalWritingMode() ? HorizontalLine : VerticalLine; 466 467 if (verticalAlign == SUB) 468 verticalPosition += fontSize / 5 + 1; 469 else if (verticalAlign == SUPER) 470 verticalPosition -= fontSize / 3 + 1; 471 else if (verticalAlign == TEXT_TOP) 472 verticalPosition += renderer->baselinePosition(baselineType, firstLine, lineDirection) - font.ascent(baselineType); 473 else if (verticalAlign == MIDDLE) 474 verticalPosition += -static_cast<int>(font.xHeight() / 2) - renderer->lineHeight(firstLine, lineDirection) / 2 + renderer->baselinePosition(baselineType, firstLine, lineDirection); 475 else if (verticalAlign == TEXT_BOTTOM) { 476 verticalPosition += font.descent(baselineType); 477 // lineHeight - baselinePosition is always 0 for replaced elements (except inline blocks), so don't bother wasting time in that case. 478 if (!renderer->isReplaced() || renderer->isInlineBlockOrInlineTable()) 479 verticalPosition -= (renderer->lineHeight(firstLine, lineDirection) - renderer->baselinePosition(baselineType, firstLine, lineDirection)); 480 } else if (verticalAlign == BASELINE_MIDDLE) 481 verticalPosition += -renderer->lineHeight(firstLine, lineDirection) / 2 + renderer->baselinePosition(baselineType, firstLine, lineDirection); 482 else if (verticalAlign == LENGTH) 483 verticalPosition -= renderer->style()->verticalAlignLength().calcValue(renderer->lineHeight(firstLine, lineDirection)); 484 } 485 } 486 487 // Store the cached value. 488 if (isRenderInline && !firstLine) 489 verticalPositionCache.set(renderer, baselineType, verticalPosition); 490 491 return verticalPosition; 434 492 } 435 493 436 494 void InlineFlowBox::computeLogicalBoxHeights(int& maxPositionTop, int& maxPositionBottom, 437 495 int& maxAscent, int& maxDescent, bool& setMaxAscent, bool& setMaxDescent, 438 bool strictMode, GlyphOverflowAndFallbackFontsMap& textBoxDataMap) 496 bool strictMode, GlyphOverflowAndFallbackFontsMap& textBoxDataMap, 497 FontBaseline baselineType, VerticalPositionCache& verticalPositionCache) 439 498 { 440 499 // The primary purpose of this function is to compute the maximal ascent and descent values for … … 451 510 // Examine our root box. 452 511 int height = lineHeight(); 453 int baseline = baselinePosition( );512 int baseline = baselinePosition(baselineType); 454 513 if (hasTextChildren() || strictMode) { 455 514 int ascent = baseline; … … 481 540 // and the root box's baseline. The value is negative if the child box's baseline is above the 482 541 // root box's baseline, and it is positive if the child box's baseline is below the root box's baseline. 483 curr->setLogicalTop(verticalPositionForBox(curr, m_firstLine));542 curr->setLogicalTop(verticalPositionForBox(curr, baselineType, m_firstLine, verticalPositionCache)); 484 543 485 544 int lineHeight; … … 498 557 int baselineToBottom = 0; 499 558 for (size_t i = 0; i < usedFonts->size(); ++i) { 500 int halfLeading = (usedFonts->at(i)->lineSpacing() - usedFonts->at(i)-> ascent() - usedFonts->at(i)->descent()) / 2;501 int usedFontAscent = halfLeading + usedFonts->at(i)->ascent( );559 int halfLeading = (usedFonts->at(i)->lineSpacing() - usedFonts->at(i)->height()) / 2; 560 int usedFontAscent = halfLeading + usedFonts->at(i)->ascent(baselineType); 502 561 int usedFontDescent = usedFonts->at(i)->lineSpacing() - usedFontAscent; 503 562 if (!baselineSet) { … … 513 572 } else { 514 573 lineHeight = curr->lineHeight(); 515 baseline = curr->baselinePosition( );574 baseline = curr->baselinePosition(baselineType); 516 575 if (curr->isText() || isInlineFlow) { 517 576 // Examine the font box for inline flows and text boxes to see if any part of it is above the baseline. 518 577 // If the top of our font box relative to the root box baseline is above the root box baseline, then 519 578 // we are contributing to the maxAscent value. 520 affectsAscent = curr->renderer()->style(m_firstLine)->font().ascent( ) - curr->logicalTop() > 0;579 affectsAscent = curr->renderer()->style(m_firstLine)->font().ascent(baselineType) - curr->logicalTop() > 0; 521 580 522 581 // Descent is similar. If any part of our font box is below the root box's baseline, then 523 582 // we contribute to the maxDescent value. 524 affectsDescent = curr->renderer()->style(m_firstLine)->font().descent( ) + curr->logicalTop() > 0;583 affectsDescent = curr->renderer()->style(m_firstLine)->font().descent(baselineType) + curr->logicalTop() > 0; 525 584 } else { 526 585 // Replaced elements always affect both the ascent and descent. … … 556 615 557 616 if (curr->isInlineFlowBox()) 558 static_cast<InlineFlowBox*>(curr)->computeLogicalBoxHeights(maxPositionTop, maxPositionBottom, maxAscent, maxDescent, setMaxAscent, setMaxDescent, strictMode, textBoxDataMap); 559 } 560 } 561 562 void InlineFlowBox::placeBoxesInBlockDirection(int top, int maxHeight, int maxAscent, bool strictMode, int& lineTop, int& lineBottom, bool& setLineTop) 617 static_cast<InlineFlowBox*>(curr)->computeLogicalBoxHeights(maxPositionTop, maxPositionBottom, maxAscent, maxDescent, 618 setMaxAscent, setMaxDescent, strictMode, textBoxDataMap, 619 baselineType, verticalPositionCache); 620 } 621 } 622 623 void InlineFlowBox::placeBoxesInBlockDirection(int top, int maxHeight, int maxAscent, bool strictMode, int& lineTop, int& lineBottom, bool& setLineTop, FontBaseline baselineType) 563 624 { 564 625 if (isRootInlineBox()) 565 setLogicalTop(top + maxAscent - baselinePosition( )); // Place our root box.626 setLogicalTop(top + maxAscent - baselinePosition(baselineType)); // Place our root box. 566 627 567 628 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { … … 573 634 bool isInlineFlow = curr->isInlineFlowBox(); 574 635 if (isInlineFlow) 575 static_cast<InlineFlowBox*>(curr)->placeBoxesInBlockDirection(top, maxHeight, maxAscent, strictMode, lineTop, lineBottom, setLineTop );636 static_cast<InlineFlowBox*>(curr)->placeBoxesInBlockDirection(top, maxHeight, maxAscent, strictMode, lineTop, lineBottom, setLineTop, baselineType); 576 637 577 638 bool childAffectsTopBottomPos = true; … … 583 644 if ((isInlineFlow && !static_cast<InlineFlowBox*>(curr)->hasTextChildren()) && !curr->boxModelObject()->hasInlineDirectionBordersOrPadding() && !strictMode) 584 645 childAffectsTopBottomPos = false; 585 int posAdjust = maxAscent - curr->baselinePosition( );646 int posAdjust = maxAscent - curr->baselinePosition(baselineType); 586 647 curr->setLogicalTop(curr->logicalTop() + top + posAdjust); 587 648 } … … 590 651 if (curr->isText() || curr->isInlineFlowBox()) { 591 652 const Font& font = curr->renderer()->style(m_firstLine)->font(); 592 newLogicalTop += curr->baselinePosition( ) - font.ascent();653 newLogicalTop += curr->baselinePosition(baselineType) - font.ascent(baselineType); 593 654 if (curr->isInlineFlowBox()) { 594 655 RenderBoxModelObject* boxObject = toRenderBoxModelObject(curr->renderer()); … … 616 677 if (isRootInlineBox()) { 617 678 const Font& font = renderer()->style(m_firstLine)->font(); 618 setLogicalTop(logicalTop() + baselinePosition( ) - font.ascent());679 setLogicalTop(logicalTop() + baselinePosition(baselineType) - font.ascent(baselineType)); 619 680 620 681 if (hasTextChildren() || strictMode) { -
trunk/WebCore/rendering/InlineFlowBox.h
r72168 r72235 31 31 class InlineTextBox; 32 32 class RenderLineBoxList; 33 class VerticalPositionCache; 33 34 34 35 typedef HashMap<const InlineTextBox*, pair<Vector<const SimpleFontData*>, GlyphOverflow> > GlyphOverflowAndFallbackFontsMap; … … 157 158 void computeLogicalBoxHeights(int& maxPositionTop, int& maxPositionBottom, 158 159 int& maxAscent, int& maxDescent, bool& setMaxAscent, bool& setMaxDescent, 159 bool strictMode, GlyphOverflowAndFallbackFontsMap& );160 bool strictMode, GlyphOverflowAndFallbackFontsMap&, FontBaseline, VerticalPositionCache&); 160 161 void adjustMaxAscentAndDescent(int& maxAscent, int& maxDescent, 161 162 int maxPositionTop, int maxPositionBottom); 162 void placeBoxesInBlockDirection(int logicalTop, int maxHeight, int maxAscent, bool strictMode, int& lineTop, int& lineBottom, bool& setLineTop );163 void placeBoxesInBlockDirection(int logicalTop, int maxHeight, int maxAscent, bool strictMode, int& lineTop, int& lineBottom, bool& setLineTop, FontBaseline); 163 164 void flipLinesInBlockDirection(int lineTop, int lineBottom); 164 165 void computeBlockDirectionOverflow(int lineTop, int lineBottom, bool strictMode, GlyphOverflowAndFallbackFontsMap&); -
trunk/WebCore/rendering/InlineTextBox.cpp
r71851 r72235 44 44 namespace WebCore { 45 45 46 int InlineTextBox::baselinePosition( ) const46 int InlineTextBox::baselinePosition(FontBaseline baselineType) const 47 47 { 48 48 if (!isText() || !parent()) 49 49 return 0; 50 return parent()->baselinePosition( );50 return parent()->baselinePosition(baselineType); 51 51 } 52 52 -
trunk/WebCore/rendering/InlineTextBox.h
r71465 r72235 71 71 72 72 73 virtual int baselinePosition( ) const;73 virtual int baselinePosition(FontBaseline) const; 74 74 virtual int lineHeight() const; 75 75 -
trunk/WebCore/rendering/RenderBlock.cpp
r71851 r72235 5258 5258 } 5259 5259 5260 int RenderBlock::baselinePosition( bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const5260 int RenderBlock::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const 5261 5261 { 5262 5262 // Inline blocks are replaced elements. Otherwise, just pass off to … … 5287 5287 return direction == HorizontalLine ? marginTop() + baselinePos : marginRight() + baselinePos; 5288 5288 5289 return RenderBox::baselinePosition( firstLine, direction, linePositionMode);5289 return RenderBox::baselinePosition(baselineType, firstLine, direction, linePositionMode); 5290 5290 } 5291 5291 5292 5292 const Font& f = style(firstLine)->font(); 5293 return f.ascent( ) + (lineHeight(firstLine, direction, linePositionMode) - f.height()) / 2;5293 return f.ascent(baselineType) + (lineHeight(firstLine, direction, linePositionMode) - f.height()) / 2; 5294 5294 } 5295 5295 … … 5301 5301 if (childrenInline()) { 5302 5302 if (firstLineBox()) 5303 return firstLineBox()->logicalTop() + style(true)->font().ascent( );5303 return firstLineBox()->logicalTop() + style(true)->font().ascent(firstRootBox()->baselineType()); 5304 5304 else 5305 5305 return -1; … … 5331 5331 } 5332 5332 if (lastLineBox()) 5333 return lastLineBox()->logicalTop() + style(lastLineBox() == firstLineBox())->font().ascent( );5333 return lastLineBox()->logicalTop() + style(lastLineBox() == firstLineBox())->font().ascent(lastRootBox()->baselineType()); 5334 5334 return -1; 5335 5335 } else { -
trunk/WebCore/rendering/RenderBlock.h
r71465 r72235 59 59 // These two functions are overridden for inline-block. 60 60 virtual int lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; 61 virtual int baselinePosition( bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;61 virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; 62 62 63 63 RenderLineBoxList* lineBoxes() { return &m_lineBoxes; } … … 459 459 InlineFlowBox* createLineBoxes(RenderObject*, bool firstLine); 460 460 void computeInlineDirectionPositionsForLine(RootInlineBox*, bool firstLine, BidiRun* firstRun, BidiRun* trailingSpaceRun, bool reachedEnd, GlyphOverflowAndFallbackFontsMap&); 461 void computeBlockDirectionPositionsForLine(RootInlineBox*, BidiRun*, GlyphOverflowAndFallbackFontsMap& );461 void computeBlockDirectionPositionsForLine(RootInlineBox*, BidiRun*, GlyphOverflowAndFallbackFontsMap&, VerticalPositionCache&); 462 462 void deleteEllipsisLineBoxes(); 463 463 void checkLinesForTextOverflow(); -
trunk/WebCore/rendering/RenderBlockLineLayout.cpp
r71851 r72235 36 36 #include "Settings.h" 37 37 #include "TrailingFloatsRootInlineBox.h" 38 #include "VerticalPositionCache.h" 38 39 #include "break_lines.h" 39 40 #include <wtf/AlwaysInline.h> … … 471 472 } 472 473 473 void RenderBlock::computeBlockDirectionPositionsForLine(RootInlineBox* lineBox, BidiRun* firstRun, GlyphOverflowAndFallbackFontsMap& textBoxDataMap) 474 { 475 setLogicalHeight(lineBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap)); 474 void RenderBlock::computeBlockDirectionPositionsForLine(RootInlineBox* lineBox, BidiRun* firstRun, GlyphOverflowAndFallbackFontsMap& textBoxDataMap, 475 VerticalPositionCache& verticalPositionCache) 476 { 477 setLogicalHeight(lineBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, verticalPositionCache)); 476 478 lineBox->setBlockLogicalHeight(logicalHeight()); 477 479 … … 568 570 dirtyLineBoxesForRenderer(o, fullLayout); 569 571 o->setNeedsLayout(false); 570 if (!o->isText())571 toRenderInline(o)->invalidateVerticalPosition(); // FIXME: Should do better here and not always invalidate everything.572 572 } 573 573 o = bidiNext(this, o, 0, false, &endOfInline); … … 648 648 bool isLineEmpty = true; 649 649 bool paginated = view()->layoutState() && view()->layoutState()->isPaginated(); 650 651 VerticalPositionCache verticalPositionCache; 650 652 651 653 while (!end.atEnd()) { … … 749 751 750 752 // Now position our text runs vertically. 751 computeBlockDirectionPositionsForLine(lineBox, resolver.firstRun(), textBoxDataMap );753 computeBlockDirectionPositionsForLine(lineBox, resolver.firstRun(), textBoxDataMap, verticalPositionCache); 752 754 753 755 #if ENABLE(SVG) … … 879 881 trailingFloatsLineBox->setConstructed(); 880 882 GlyphOverflowAndFallbackFontsMap textBoxDataMap; 881 trailingFloatsLineBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap); 883 VerticalPositionCache verticalPositionCache; 884 trailingFloatsLineBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, verticalPositionCache); 882 885 trailingFloatsLineBox->setBlockDirectionOverflowPositions(logicalHeight(), bottomLayoutOverflow, logicalHeight(), bottomVisualOverflow); 883 886 trailingFloatsLineBox->setBlockLogicalHeight(logicalHeight()); -
trunk/WebCore/rendering/RenderBox.cpp
r71980 r72235 3190 3190 } 3191 3191 3192 int RenderBox::baselinePosition(bool /*firstLine*/, LineDirectionMode direction, LinePositionMode /*linePositionMode*/) const 3193 { 3194 if (isReplaced()) 3195 return direction == HorizontalLine ? m_marginTop + height() + m_marginBottom : m_marginRight + width() + m_marginLeft; 3192 int RenderBox::baselinePosition(FontBaseline baselineType, bool /*firstLine*/, LineDirectionMode direction, LinePositionMode /*linePositionMode*/) const 3193 { 3194 if (isReplaced()) { 3195 int result = direction == HorizontalLine ? m_marginTop + height() + m_marginBottom : m_marginRight + width() + m_marginLeft; 3196 if (baselineType == AlphabeticBaseline) 3197 return result; 3198 return result - result / 2; 3199 } 3196 3200 return 0; 3197 3201 } -
trunk/WebCore/rendering/RenderBox.h
r71851 r72235 379 379 380 380 virtual int lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; 381 virtual int baselinePosition( bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;381 virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; 382 382 383 383 enum FlippingAdjustment { ChildToParentFlippingAdjustment, ParentToChildFlippingAdjustment }; -
trunk/WebCore/rendering/RenderBoxModelObject.cpp
r71055 r72235 846 846 } 847 847 848 int RenderBoxModelObject::verticalPosition(bool firstLine) const849 {850 // This method determines the vertical position for inline elements.851 ASSERT(isInline());852 if (!isInline())853 return 0;854 855 int vpos = 0;856 EVerticalAlign va = style()->verticalAlign();857 if (va == TOP)858 vpos = PositionTop;859 else if (va == BOTTOM)860 vpos = PositionBottom;861 else {862 bool checkParent = parent()->isRenderInline() && parent()->style()->verticalAlign() != TOP && parent()->style()->verticalAlign() != BOTTOM;863 vpos = checkParent ? toRenderInline(parent())->verticalPositionFromCache(firstLine) : 0;864 // don't allow elements nested inside text-top to have a different valignment.865 if (va == BASELINE)866 return vpos;867 868 const Font& f = parent()->style(firstLine)->font();869 int fontsize = f.pixelSize();870 871 LineDirectionMode lineDirection = parent()->style()->isHorizontalWritingMode() ? HorizontalLine : VerticalLine;872 873 if (va == SUB)874 vpos += fontsize / 5 + 1;875 else if (va == SUPER)876 vpos -= fontsize / 3 + 1;877 else if (va == TEXT_TOP)878 vpos += baselinePosition(firstLine, lineDirection) - f.ascent();879 else if (va == MIDDLE)880 vpos += -static_cast<int>(f.xHeight() / 2) - lineHeight(firstLine, lineDirection) / 2 + baselinePosition(firstLine, lineDirection);881 else if (va == TEXT_BOTTOM) {882 vpos += f.descent();883 // lineHeight - baselinePosition is always 0 for replaced elements (except inline blocks), so don't bother wasting time in that case.884 if (!isReplaced() || style()->display() == INLINE_BLOCK)885 vpos -= (lineHeight(firstLine, lineDirection) - baselinePosition(firstLine, lineDirection));886 } else if (va == BASELINE_MIDDLE)887 vpos += -lineHeight(firstLine, lineDirection) / 2 + baselinePosition(firstLine, lineDirection);888 else if (va == LENGTH)889 vpos -= style()->verticalAlignLength().calcValue(lineHeight(firstLine, lineDirection));890 }891 892 return vpos;893 }894 895 848 bool RenderBoxModelObject::paintNinePieceImage(GraphicsContext* graphicsContext, int tx, int ty, int w, int h, const RenderStyle* style, 896 849 const NinePieceImage& ninePieceImage, CompositeOperator op) -
trunk/WebCore/rendering/RenderBoxModelObject.h
r70843 r72235 28 28 29 29 namespace WebCore { 30 31 // Values for vertical alignment.32 const int PositionTop = -0x7fffffff;33 const int PositionBottom = 0x7fffffff;34 const int PositionUndefined = 0x80000000;35 30 36 31 // Modes for some of the line-related functions. … … 114 109 void paintBoxShadow(GraphicsContext*, int tx, int ty, int w, int h, const RenderStyle*, ShadowStyle, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true); 115 110 void paintFillLayerExtended(const PaintInfo&, const Color&, const FillLayer*, int tx, int ty, int width, int height, InlineFlowBox* = 0, CompositeOperator = CompositeSourceOver, RenderObject* backgroundObject = 0); 116 117 // The difference between this inline's baseline position and the line's baseline position.118 int verticalPosition(bool firstLine) const;119 111 120 112 // Overridden by subclasses to determine line height and baseline position. 121 113 virtual int lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const = 0; 122 virtual int baselinePosition( bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const = 0;114 virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const = 0; 123 115 124 116 // Called by RenderObject::destroy() (and RenderWidget::destroy()) and is the only way layers should ever be destroyed -
trunk/WebCore/rendering/RenderFileUploadControl.cpp
r70072 r72235 232 232 int textY = buttonRenderer->absoluteBoundingBoxRect().y() 233 233 + buttonRenderer->marginTop() + buttonRenderer->borderTop() + buttonRenderer->paddingTop() 234 + buttonRenderer->baselinePosition( true, HorizontalLine, PositionOnContainingLine);234 + buttonRenderer->baselinePosition(AlphabeticBaseline, true, HorizontalLine, PositionOnContainingLine); 235 235 236 236 paintInfo.context->setFillColor(style()->visitedDependentColor(CSSPropertyColor), style()->colorSpace()); -
trunk/WebCore/rendering/RenderInline.cpp
r71851 r72235 49 49 , m_continuation(0) 50 50 , m_lineHeight(-1) 51 , m_verticalPosition(PositionUndefined)52 51 { 53 52 setChildrenInline(true); … … 904 903 } 905 904 906 int RenderInline::baselinePosition( bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const905 int RenderInline::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const 907 906 { 908 907 const Font& f = style(firstLine)->font(); 909 return f.ascent() + (lineHeight(firstLine, direction, linePositionMode) - f.height()) / 2; 910 } 911 912 int RenderInline::verticalPositionFromCache(bool firstLine) const 913 { 914 if (firstLine) // We're only really a first-line style if the document actually uses first-line rules. 915 firstLine = document()->usesFirstLineRules(); 916 int vpos = m_verticalPosition; 917 if (m_verticalPosition == PositionUndefined || firstLine) { 918 vpos = verticalPosition(firstLine); 919 if (!firstLine) 920 m_verticalPosition = vpos; 921 } 922 return vpos; 908 return f.ascent(baselineType) + (lineHeight(firstLine, direction, linePositionMode) - f.height()) / 2; 923 909 } 924 910 -
trunk/WebCore/rendering/RenderInline.h
r70072 r72235 78 78 void paintOutline(GraphicsContext*, int tx, int ty); 79 79 80 int verticalPositionFromCache(bool firstLine) const;81 void invalidateVerticalPosition() { m_verticalPosition = PositionUndefined; }82 83 80 protected: 84 81 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle); … … 135 132 136 133 virtual int lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; 137 virtual int baselinePosition( bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;134 virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; 138 135 139 136 virtual void childBecameNonInline(RenderObject* child); … … 160 157 // <b> will just have an inline as its continuation. 161 158 mutable int m_lineHeight; 162 mutable int m_verticalPosition;163 159 }; 164 160 -
trunk/WebCore/rendering/RenderListBox.cpp
r70072 r72235 239 239 } 240 240 241 int RenderListBox::baselinePosition( bool firstLine, LineDirectionMode lineDirection, LinePositionMode linePositionMode) const242 { 243 return RenderBox::baselinePosition( firstLine, lineDirection, linePositionMode) - baselineAdjustment;241 int RenderListBox::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode lineDirection, LinePositionMode linePositionMode) const 242 { 243 return RenderBox::baselinePosition(baselineType, firstLine, lineDirection, linePositionMode) - baselineAdjustment; 244 244 } 245 245 -
trunk/WebCore/rendering/RenderListBox.h
r70072 r72235 72 72 73 73 virtual void computePreferredLogicalWidths(); 74 virtual int baselinePosition( bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;74 virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; 75 75 virtual void computeLogicalHeight(); 76 76 -
trunk/WebCore/rendering/RenderListMarker.cpp
r71700 r72235 1531 1531 } 1532 1532 1533 int RenderListMarker::baselinePosition( bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const1533 int RenderListMarker::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const 1534 1534 { 1535 1535 if (!isImage()) 1536 return m_listItem->baselinePosition( firstLine, direction, PositionOfInteriorLineBoxes);1537 return RenderBox::baselinePosition( firstLine, direction, linePositionMode);1536 return m_listItem->baselinePosition(baselineType, firstLine, direction, PositionOfInteriorLineBoxes); 1537 return RenderBox::baselinePosition(baselineType, firstLine, direction, linePositionMode); 1538 1538 } 1539 1539 -
trunk/WebCore/rendering/RenderListMarker.h
r70072 r72235 60 60 61 61 virtual int lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; 62 virtual int baselinePosition( bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;62 virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; 63 63 64 64 bool isImage() const; -
trunk/WebCore/rendering/RenderSlider.cpp
r71851 r72235 156 156 } 157 157 158 int RenderSlider::baselinePosition(bool /*firstLine*/, LineDirectionMode, LinePositionMode) const 159 { 158 int RenderSlider::baselinePosition(FontBaseline, bool /*firstLine*/, LineDirectionMode, LinePositionMode) const 159 { 160 // FIXME: Patch this function for writing-mode. 160 161 return height() + marginTop(); 161 162 } -
trunk/WebCore/rendering/RenderSlider.h
r70072 r72235 43 43 virtual bool isSlider() const { return true; } 44 44 45 virtual int baselinePosition( bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;45 virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; 46 46 virtual void computePreferredLogicalWidths(); 47 47 virtual void layout(); -
trunk/WebCore/rendering/RenderTableCell.cpp
r71251 r72235 291 291 } 292 292 293 int RenderTableCell::baselinePosition(bool firstLine, LineDirectionMode lineDirection, LinePositionMode linePositionMode) const 294 { 295 // FIXME: This function still needs to be patched for writing-mode. 296 if (linePositionMode == PositionOfInteriorLineBoxes) 297 return RenderBlock::baselinePosition(firstLine, lineDirection, linePositionMode); 298 293 int RenderTableCell::baselinePosition() const 294 { 299 295 // <http://www.w3.org/TR/2007/CR-CSS21-20070719/tables.html#height-layout>: The baseline of a cell is the baseline of 300 296 // the first in-flow line box in the cell, or the first in-flow table-row in the cell, whichever comes first. If there … … 303 299 if (firstLineBaseline != -1) 304 300 return firstLineBaseline; 305 return padding Top() + borderTop() + contentHeight();301 return paddingBefore() + borderBefore() + contentLogicalHeight(); 306 302 } 307 303 -
trunk/WebCore/rendering/RenderTableCell.h
r71251 r72235 99 99 void paintBackgroundsBehindCell(PaintInfo&, int tx, int ty, RenderObject* backgroundObject); 100 100 101 virtual int baselinePosition(bool firstLine = false, LineDirectionMode = HorizontalLine, LinePositionMode = PositionOnContainingLine) const;101 int baselinePosition() const; 102 102 103 103 void setIntrinsicPaddingBefore(int p) { m_intrinsicPaddingBefore = p; } -
trunk/WebCore/rendering/RenderTextControlMultiLine.cpp
r72052 r72235 95 95 } 96 96 97 int RenderTextControlMultiLine::baselinePosition( bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const97 int RenderTextControlMultiLine::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const 98 98 { 99 return RenderBox::baselinePosition( firstLine, direction, linePositionMode);99 return RenderBox::baselinePosition(baselineType, firstLine, direction, linePositionMode); 100 100 } 101 101 -
trunk/WebCore/rendering/RenderTextControlMultiLine.h
r72052 r72235 44 44 virtual int preferredContentWidth(float charWidth) const; 45 45 virtual void adjustControlHeightBasedOnLineHeight(int lineHeight); 46 virtual int baselinePosition( bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;46 virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const; 47 47 48 48 virtual void updateFromElement(); -
trunk/WebCore/rendering/RootInlineBox.cpp
r72168 r72235 216 216 } 217 217 218 int RootInlineBox::alignBoxesInBlockDirection(int heightOfBlock, GlyphOverflowAndFallbackFontsMap& textBoxDataMap )218 int RootInlineBox::alignBoxesInBlockDirection(int heightOfBlock, GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache& verticalPositionCache) 219 219 { 220 220 #if ENABLE(SVG) … … 236 236 m_baselineType = requiresIdeographicBaseline(textBoxDataMap) ? IdeographicBaseline : AlphabeticBaseline; 237 237 238 computeLogicalBoxHeights(maxPositionTop, maxPositionBottom, maxAscent, maxDescent, setMaxAscent, setMaxDescent, noQuirksMode, textBoxDataMap); 238 computeLogicalBoxHeights(maxPositionTop, maxPositionBottom, maxAscent, maxDescent, setMaxAscent, setMaxDescent, noQuirksMode, 239 textBoxDataMap, m_baselineType, verticalPositionCache); 239 240 240 241 if (maxAscent + maxDescent < max(maxPositionTop, maxPositionBottom)) … … 245 246 int lineBottom = heightOfBlock; 246 247 bool setLineTop = false; 247 placeBoxesInBlockDirection(heightOfBlock, maxHeight, maxAscent, noQuirksMode, lineTop, lineBottom, setLineTop );248 placeBoxesInBlockDirection(heightOfBlock, maxHeight, maxAscent, noQuirksMode, lineTop, lineBottom, setLineTop, m_baselineType); 248 249 computeBlockDirectionOverflow(lineTop, lineBottom, noQuirksMode, textBoxDataMap); 249 250 setLineTopBottomPositions(lineTop, lineBottom); -
trunk/WebCore/rendering/RootInlineBox.h
r72168 r72235 58 58 int selectionHeight() const { return max(0, selectionBottom() - selectionTop()); } 59 59 60 int alignBoxesInBlockDirection(int heightOfBlock, GlyphOverflowAndFallbackFontsMap& );60 int alignBoxesInBlockDirection(int heightOfBlock, GlyphOverflowAndFallbackFontsMap&, VerticalPositionCache&); 61 61 void setLineTopBottomPositions(int top, int bottom); 62 62 … … 89 89 virtual void clearTruncation(); 90 90 91 virtual int baselinePosition( ) const { return boxModelObject()->baselinePosition(m_firstLine, isHorizontal() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); }91 virtual int baselinePosition(FontBaseline baselineType) const { return boxModelObject()->baselinePosition(baselineType, m_firstLine, isHorizontal() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); } 92 92 virtual int lineHeight() const { return boxModelObject()->lineHeight(m_firstLine, isHorizontal() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); } 93 93 -
trunk/WebCore/rendering/svg/SVGInlineTextBox.cpp
r71067 r72235 589 589 ASSERT(style); 590 590 591 int baseline = baselinePosition( );591 int baseline = baselinePosition(AlphabeticBaseline); 592 592 int heightDifference = baseline - style->font().ascent(); 593 593
Note: See TracChangeset
for help on using the changeset viewer.