OLD | NEW |
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 2176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2187 { | 2187 { |
2188 if (childrenInline()) | 2188 if (childrenInline()) |
2189 return toLayoutBlockFlow(const_cast<LayoutBlock*>(this)); | 2189 return toLayoutBlockFlow(const_cast<LayoutBlock*>(this)); |
2190 for (LayoutObject* child = firstChild(); child && !child->isFloatingOrOutOfF
lowPositioned() && child->isLayoutBlockFlow(); child = toLayoutBlock(child)->fir
stChild()) { | 2190 for (LayoutObject* child = firstChild(); child && !child->isFloatingOrOutOfF
lowPositioned() && child->isLayoutBlockFlow(); child = toLayoutBlock(child)->fir
stChild()) { |
2191 if (child->childrenInline()) | 2191 if (child->childrenInline()) |
2192 return toLayoutBlockFlow(child); | 2192 return toLayoutBlockFlow(child); |
2193 } | 2193 } |
2194 return nullptr; | 2194 return nullptr; |
2195 } | 2195 } |
2196 | 2196 |
2197 // Helper methods for obtaining the last line, computing line counts and heights
for line counts | |
2198 // (crawling into blocks). | |
2199 static bool shouldCheckLines(LayoutObject* obj) | |
2200 { | |
2201 return !obj->isFloatingOrOutOfFlowPositioned() | |
2202 && obj->isLayoutBlock() && obj->style()->height().isAuto() | |
2203 && (!obj->isDeprecatedFlexibleBox() || obj->style()->boxOrient() == VERT
ICAL); | |
2204 } | |
2205 | |
2206 static int getHeightForLineCount(LayoutBlock* block, int lineCount, bool include
Bottom, int& count) | |
2207 { | |
2208 if (block->style()->visibility() == VISIBLE) { | |
2209 if (block->isLayoutBlockFlow() && block->childrenInline()) { | |
2210 for (RootInlineBox* box = toLayoutBlockFlow(block)->firstRootBox();
box; box = box->nextRootBox()) { | |
2211 if (++count == lineCount) | |
2212 return box->lineBottom() + (includeBottom ? (block->borderBo
ttom() + block->paddingBottom()) : LayoutUnit()); | |
2213 } | |
2214 } else { | |
2215 LayoutBox* normalFlowChildWithoutLines = nullptr; | |
2216 for (LayoutBox* obj = block->firstChildBox(); obj; obj = obj->nextSi
blingBox()) { | |
2217 if (shouldCheckLines(obj)) { | |
2218 int result = getHeightForLineCount(toLayoutBlock(obj), lineC
ount, false, count); | |
2219 if (result != -1) | |
2220 return result + obj->location().y() + (includeBottom ? (
block->borderBottom() + block->paddingBottom()) : LayoutUnit()); | |
2221 } else if (!obj->isFloatingOrOutOfFlowPositioned()) { | |
2222 normalFlowChildWithoutLines = obj; | |
2223 } | |
2224 } | |
2225 if (normalFlowChildWithoutLines && lineCount == 0) | |
2226 return normalFlowChildWithoutLines->location().y() + normalFlowC
hildWithoutLines->size().height(); | |
2227 } | |
2228 } | |
2229 | |
2230 return -1; | |
2231 } | |
2232 | |
2233 RootInlineBox* LayoutBlock::lineAtIndex(int i) const | |
2234 { | |
2235 ASSERT(i >= 0); | |
2236 | |
2237 if (style()->visibility() != VISIBLE) | |
2238 return nullptr; | |
2239 | |
2240 if (childrenInline()) { | |
2241 for (RootInlineBox* box = firstRootBox(); box; box = box->nextRootBox())
{ | |
2242 if (!i--) | |
2243 return box; | |
2244 } | |
2245 } else { | |
2246 for (LayoutObject* child = firstChild(); child; child = child->nextSibli
ng()) { | |
2247 if (!shouldCheckLines(child)) | |
2248 continue; | |
2249 if (RootInlineBox* box = toLayoutBlock(child)->lineAtIndex(i)) | |
2250 return box; | |
2251 } | |
2252 } | |
2253 | |
2254 return nullptr; | |
2255 } | |
2256 | |
2257 int LayoutBlock::lineCount(const RootInlineBox* stopRootInlineBox, bool* found)
const | |
2258 { | |
2259 int count = 0; | |
2260 | |
2261 if (style()->visibility() == VISIBLE) { | |
2262 if (childrenInline()) { | |
2263 for (RootInlineBox* box = firstRootBox(); box; box = box->nextRootBo
x()) { | |
2264 count++; | |
2265 if (box == stopRootInlineBox) { | |
2266 if (found) | |
2267 *found = true; | |
2268 break; | |
2269 } | |
2270 } | |
2271 } else { | |
2272 for (LayoutObject* obj = firstChild(); obj; obj = obj->nextSibling()
) { | |
2273 if (shouldCheckLines(obj)) { | |
2274 bool recursiveFound = false; | |
2275 count += toLayoutBlock(obj)->lineCount(stopRootInlineBox, &r
ecursiveFound); | |
2276 if (recursiveFound) { | |
2277 if (found) | |
2278 *found = true; | |
2279 break; | |
2280 } | |
2281 } | |
2282 } | |
2283 } | |
2284 } | |
2285 return count; | |
2286 } | |
2287 | |
2288 int LayoutBlock::heightForLineCount(int lineCount) | |
2289 { | |
2290 int count = 0; | |
2291 return getHeightForLineCount(this, lineCount, true, count); | |
2292 } | |
2293 | |
2294 void LayoutBlock::clearTruncation() | |
2295 { | |
2296 if (style()->visibility() == VISIBLE) { | |
2297 if (childrenInline() && hasMarkupTruncation()) { | |
2298 setHasMarkupTruncation(false); | |
2299 for (RootInlineBox* box = firstRootBox(); box; box = box->nextRootBo
x()) | |
2300 box->clearTruncation(); | |
2301 } else { | |
2302 for (LayoutObject* obj = firstChild(); obj; obj = obj->nextSibling()
) { | |
2303 if (shouldCheckLines(obj)) | |
2304 toLayoutBlock(obj)->clearTruncation(); | |
2305 } | |
2306 } | |
2307 } | |
2308 } | |
2309 | |
2310 void LayoutBlock::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accum
ulatedOffset) const | 2197 void LayoutBlock::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accum
ulatedOffset) const |
2311 { | 2198 { |
2312 // For blocks inside inlines, we go ahead and include margins so that we run
right up to the | 2199 // For blocks inside inlines, we go ahead and include margins so that we run
right up to the |
2313 // inline boxes above and below us (thus getting merged with them to form a
single irregular | 2200 // inline boxes above and below us (thus getting merged with them to form a
single irregular |
2314 // shape). | 2201 // shape). |
2315 if (isAnonymousBlockContinuation()) { | 2202 if (isAnonymousBlockContinuation()) { |
2316 // FIXME: This is wrong for vertical writing-modes. | 2203 // FIXME: This is wrong for vertical writing-modes. |
2317 // https://bugs.webkit.org/show_bug.cgi?id=46781 | 2204 // https://bugs.webkit.org/show_bug.cgi?id=46781 |
2318 LayoutRect rect(accumulatedOffset, size()); | 2205 LayoutRect rect(accumulatedOffset, size()); |
2319 rect.expand(collapsedMarginBoxLogicalOutsets()); | 2206 rect.expand(collapsedMarginBoxLogicalOutsets()); |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2759 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout
Object* obj) const | 2646 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout
Object* obj) const |
2760 { | 2647 { |
2761 showLayoutObject(); | 2648 showLayoutObject(); |
2762 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) | 2649 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) |
2763 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); | 2650 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); |
2764 } | 2651 } |
2765 | 2652 |
2766 #endif | 2653 #endif |
2767 | 2654 |
2768 } // namespace blink | 2655 } // namespace blink |
OLD | NEW |