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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBlock.cpp

Issue 1952753002: Move parts of baseline calculation over to LayoutBlockFlow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « no previous file | third_party/WebKit/Source/core/layout/LayoutBlockFlow.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 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2007 David Smith (catfish.man@gmail.com) 4 * (C) 2007 David Smith (catfish.man@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
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 22 matching lines...) Expand all
33 #include "core/editing/EditingUtilities.h" 33 #include "core/editing/EditingUtilities.h"
34 #include "core/editing/Editor.h" 34 #include "core/editing/Editor.h"
35 #include "core/editing/FrameSelection.h" 35 #include "core/editing/FrameSelection.h"
36 #include "core/frame/FrameView.h" 36 #include "core/frame/FrameView.h"
37 #include "core/frame/LocalFrame.h" 37 #include "core/frame/LocalFrame.h"
38 #include "core/frame/Settings.h" 38 #include "core/frame/Settings.h"
39 #include "core/html/HTMLMarqueeElement.h" 39 #include "core/html/HTMLMarqueeElement.h"
40 #include "core/layout/HitTestLocation.h" 40 #include "core/layout/HitTestLocation.h"
41 #include "core/layout/HitTestResult.h" 41 #include "core/layout/HitTestResult.h"
42 #include "core/layout/LayoutAnalyzer.h" 42 #include "core/layout/LayoutAnalyzer.h"
43 #include "core/layout/LayoutDeprecatedFlexibleBox.h"
44 #include "core/layout/LayoutFlexibleBox.h" 43 #include "core/layout/LayoutFlexibleBox.h"
45 #include "core/layout/LayoutFlowThread.h" 44 #include "core/layout/LayoutFlowThread.h"
46 #include "core/layout/LayoutGrid.h" 45 #include "core/layout/LayoutGrid.h"
47 #include "core/layout/LayoutInline.h" 46 #include "core/layout/LayoutInline.h"
48 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" 47 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h"
49 #include "core/layout/LayoutObject.h" 48 #include "core/layout/LayoutObject.h"
50 #include "core/layout/LayoutTableCell.h" 49 #include "core/layout/LayoutTableCell.h"
51 #include "core/layout/LayoutTextCombine.h" 50 #include "core/layout/LayoutTextCombine.h"
52 #include "core/layout/LayoutTextControl.h" 51 #include "core/layout/LayoutTextControl.h"
53 #include "core/layout/LayoutTextFragment.h" 52 #include "core/layout/LayoutTextFragment.h"
(...skipping 2028 matching lines...) Expand 10 before | Expand all | Expand 10 after
2082 } 2081 }
2083 2082
2084 LayoutUnit LayoutBlock::minLineHeightForReplacedObject(bool isFirstLine, LayoutU nit replacedHeight) const 2083 LayoutUnit LayoutBlock::minLineHeightForReplacedObject(bool isFirstLine, LayoutU nit replacedHeight) const
2085 { 2084 {
2086 if (!document().inNoQuirksMode() && replacedHeight) 2085 if (!document().inNoQuirksMode() && replacedHeight)
2087 return replacedHeight; 2086 return replacedHeight;
2088 2087
2089 return std::max<LayoutUnit>(replacedHeight, lineHeight(isFirstLine, isHorizo ntalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes)) ; 2088 return std::max<LayoutUnit>(replacedHeight, lineHeight(isFirstLine, isHorizo ntalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes)) ;
2090 } 2089 }
2091 2090
2091 // TODO(mstensho): Figure out if all of this baseline code is needed here, or if it should be moved
2092 // down to LayoutBlockFlow. LayoutDeprecatedFlexibleBox and LayoutGrid lack base line calculation
2093 // overrides, so the code is here just for them. Just walking the block children in logical order
2094 // seems rather wrong for those two layout modes, though.
2095
2092 int LayoutBlock::firstLineBoxBaseline() const 2096 int LayoutBlock::firstLineBoxBaseline() const
2093 { 2097 {
2098 ASSERT(!childrenInline());
2094 if (isWritingModeRoot() && !isRubyRun()) 2099 if (isWritingModeRoot() && !isRubyRun())
2095 return -1; 2100 return -1;
2096 2101
2097 if (childrenInline()) {
2098 if (firstLineBox())
2099 return firstLineBox()->logicalTop() + style(true)->getFontMetrics(). ascent(firstRootBox()->baselineType());
2100 return -1;
2101 }
2102 for (LayoutBox* curr = firstChildBox(); curr; curr = curr->nextSiblingBox()) { 2102 for (LayoutBox* curr = firstChildBox(); curr; curr = curr->nextSiblingBox()) {
2103 if (!curr->isFloatingOrOutOfFlowPositioned()) { 2103 if (!curr->isFloatingOrOutOfFlowPositioned()) {
2104 int result = curr->firstLineBoxBaseline(); 2104 int result = curr->firstLineBoxBaseline();
2105 if (result != -1) 2105 if (result != -1)
2106 return curr->logicalTop() + result; // Translate to our coordina te space. 2106 return curr->logicalTop() + result; // Translate to our coordina te space.
2107 } 2107 }
2108 } 2108 }
2109 return -1; 2109 return -1;
2110 } 2110 }
2111 2111
2112 int LayoutBlock::inlineBlockBaseline(LineDirectionMode lineDirection) const 2112 int LayoutBlock::inlineBlockBaseline(LineDirectionMode lineDirection) const
2113 { 2113 {
2114 // CSS2.1 states that the baseline of an 'inline-block' is: 2114 ASSERT(!childrenInline());
2115 // the baseline of the last line box in the normal flow, unless it has
2116 // either no in-flow line boxes or if its 'overflow' property has a computed
2117 // value other than 'visible', in which case the baseline is the bottom
2118 // margin edge.
2119 // We likewise avoid using the last line box in the case of size containment ,
2120 // where the block's contents shouldn't be considered when laying out its
2121 // ancestors or siblings.
2122
2123 if ((!style()->isOverflowVisible() && !shouldIgnoreOverflowPropertyForInline BlockBaseline()) || style()->containsSize()) { 2115 if ((!style()->isOverflowVisible() && !shouldIgnoreOverflowPropertyForInline BlockBaseline()) || style()->containsSize()) {
2124 // We are not calling LayoutBox::baselinePosition here because the calle r should add the margin-top/margin-right, not us. 2116 // We are not calling LayoutBox::baselinePosition here because the calle r should add the margin-top/margin-right, not us.
2125 return lineDirection == HorizontalLine ? size().height() + marginBottom( ) : size().width() + marginLeft(); 2117 return lineDirection == HorizontalLine ? size().height() + marginBottom( ) : size().width() + marginLeft();
2126 } 2118 }
2127 2119
2128 if (isWritingModeRoot() && !isRubyRun()) 2120 if (isWritingModeRoot() && !isRubyRun())
2129 return -1; 2121 return -1;
2130 2122
2131 if (childrenInline()) {
2132 if (!firstLineBox() && hasLineIfEmpty()) {
2133 const FontMetrics& fontMetrics = firstLineStyle()->getFontMetrics();
2134 return fontMetrics.ascent()
2135 + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - fontMetrics.height()) / 2
2136 + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : borderRight() + paddingRight());
2137 }
2138 if (lastLineBox())
2139 return lastLineBox()->logicalTop() + style(lastLineBox() == firstLin eBox())->getFontMetrics().ascent(lastRootBox()->baselineType());
2140 return -1;
2141 }
2142
2143 bool haveNormalFlowChild = false; 2123 bool haveNormalFlowChild = false;
2144 for (LayoutBox* curr = lastChildBox(); curr; curr = curr->previousSiblingBox ()) { 2124 for (LayoutBox* curr = lastChildBox(); curr; curr = curr->previousSiblingBox ()) {
2145 if (!curr->isFloatingOrOutOfFlowPositioned()) { 2125 if (!curr->isFloatingOrOutOfFlowPositioned()) {
2146 haveNormalFlowChild = true; 2126 haveNormalFlowChild = true;
2147 int result = curr->inlineBlockBaseline(lineDirection); 2127 int result = curr->inlineBlockBaseline(lineDirection);
2148 if (result != -1) 2128 if (result != -1)
2149 return curr->logicalTop() + result; // Translate to our coordina te space. 2129 return curr->logicalTop() + result; // Translate to our coordina te space.
2150 } 2130 }
2151 } 2131 }
2152 if (!haveNormalFlowChild && hasLineIfEmpty()) { 2132 if (!haveNormalFlowChild && hasLineIfEmpty()) {
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
2646 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const 2626 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const
2647 { 2627 {
2648 showLayoutObject(); 2628 showLayoutObject();
2649 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 2629 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
2650 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 2630 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
2651 } 2631 }
2652 2632
2653 #endif 2633 #endif
2654 2634
2655 } // namespace blink 2635 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/LayoutBlockFlow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698