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 2274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2285 } | 2285 } |
2286 if (!haveNormalFlowChild && hasLineIfEmpty()) { | 2286 if (!haveNormalFlowChild && hasLineIfEmpty()) { |
2287 const FontMetrics& fontMetrics = firstLineStyle()->fontMetrics(); | 2287 const FontMetrics& fontMetrics = firstLineStyle()->fontMetrics(); |
2288 return fontMetrics.ascent() | 2288 return fontMetrics.ascent() |
2289 + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - fo
ntMetrics.height()) / 2 | 2289 + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - fo
ntMetrics.height()) / 2 |
2290 + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : bo
rderRight() + paddingRight()); | 2290 + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : bo
rderRight() + paddingRight()); |
2291 } | 2291 } |
2292 return -1; | 2292 return -1; |
2293 } | 2293 } |
2294 | 2294 |
2295 static inline bool isLayoutBlockFlowOrLayoutButton(LayoutObject* layoutObject) | 2295 LayoutBlock* LayoutBlock::enclosingFirstLineStyleBlock() const |
2296 { | |
2297 // We include isLayoutButton in this check because buttons are implemented | |
2298 // using flex box but should still support first-line|first-letter. | |
2299 // The flex box and grid specs require that flex box and grid do not | |
2300 // support first-line|first-letter, though. | |
2301 // FIXME: Remove when buttons are implemented with align-items instead | |
2302 // of flex box. | |
2303 return layoutObject->isLayoutBlockFlow() || layoutObject->isLayoutButton(); | |
2304 } | |
2305 | |
2306 LayoutBlock* LayoutBlock::firstLineBlock() const | |
2307 { | 2296 { |
2308 LayoutBlock* firstLineBlock = const_cast<LayoutBlock*>(this); | 2297 LayoutBlock* firstLineBlock = const_cast<LayoutBlock*>(this); |
2309 bool hasPseudo = false; | 2298 bool hasPseudo = false; |
2310 while (true) { | 2299 while (true) { |
2311 hasPseudo = firstLineBlock->style()->hasPseudoStyle(FIRST_LINE); | 2300 hasPseudo = firstLineBlock->style()->hasPseudoStyle(FIRST_LINE); |
2312 if (hasPseudo) | 2301 if (hasPseudo) |
2313 break; | 2302 break; |
2314 LayoutObject* parentBlock = firstLineBlock->parent(); | 2303 LayoutObject* parentBlock = firstLineBlock->parent(); |
2315 if (firstLineBlock->isReplaced() || firstLineBlock->isFloatingOrOutOfFlo
wPositioned() | 2304 if (firstLineBlock->isReplaced() || firstLineBlock->isFloatingOrOutOfFlo
wPositioned() |
2316 || !parentBlock | 2305 || !parentBlock |
2317 || !isLayoutBlockFlowOrLayoutButton(parentBlock)) | 2306 || !parentBlock->canHaveFirstLineOrFirstLetterStyle()) |
2318 break; | 2307 break; |
2319 ASSERT_WITH_SECURITY_IMPLICATION(parentBlock->isLayoutBlock()); | 2308 ASSERT_WITH_SECURITY_IMPLICATION(parentBlock->isLayoutBlock()); |
2320 if (toLayoutBlock(parentBlock)->firstChild() != firstLineBlock) | 2309 if (toLayoutBlock(parentBlock)->firstChild() != firstLineBlock) |
2321 break; | 2310 break; |
2322 firstLineBlock = toLayoutBlock(parentBlock); | 2311 firstLineBlock = toLayoutBlock(parentBlock); |
2323 } | 2312 } |
2324 | 2313 |
2325 if (!hasPseudo) | 2314 if (!hasPseudo) |
2326 return nullptr; | 2315 return nullptr; |
2327 | 2316 |
2328 return firstLineBlock; | 2317 return firstLineBlock; |
2329 } | 2318 } |
2330 | 2319 |
| 2320 LayoutBlockFlow* LayoutBlock::nearestInnerBlockWithFirstLine() const |
| 2321 { |
| 2322 if (childrenInline()) |
| 2323 return toLayoutBlockFlow(const_cast<LayoutBlock*>(this)); |
| 2324 for (LayoutObject* child = firstChild(); child && !child->isFloatingOrOutOfF
lowPositioned() && child->isLayoutBlockFlow(); child = toLayoutBlock(child)->fir
stChild()) { |
| 2325 if (child->childrenInline()) |
| 2326 return toLayoutBlockFlow(child); |
| 2327 } |
| 2328 return nullptr; |
| 2329 } |
| 2330 |
2331 // Helper methods for obtaining the last line, computing line counts and heights
for line counts | 2331 // Helper methods for obtaining the last line, computing line counts and heights
for line counts |
2332 // (crawling into blocks). | 2332 // (crawling into blocks). |
2333 static bool shouldCheckLines(LayoutObject* obj) | 2333 static bool shouldCheckLines(LayoutObject* obj) |
2334 { | 2334 { |
2335 return !obj->isFloatingOrOutOfFlowPositioned() | 2335 return !obj->isFloatingOrOutOfFlowPositioned() |
2336 && obj->isLayoutBlock() && obj->style()->height().isAuto() | 2336 && obj->isLayoutBlock() && obj->style()->height().isAuto() |
2337 && (!obj->isDeprecatedFlexibleBox() || obj->style()->boxOrient() == VERT
ICAL); | 2337 && (!obj->isDeprecatedFlexibleBox() || obj->style()->boxOrient() == VERT
ICAL); |
2338 } | 2338 } |
2339 | 2339 |
2340 static int getHeightForLineCount(LayoutBlock* block, int lineCount, bool include
Bottom, int& count) | 2340 static int getHeightForLineCount(LayoutBlock* block, int lineCount, bool include
Bottom, int& count) |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2908 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout
Object* obj) const | 2908 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout
Object* obj) const |
2909 { | 2909 { |
2910 showLayoutObject(); | 2910 showLayoutObject(); |
2911 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) | 2911 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) |
2912 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); | 2912 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); |
2913 } | 2913 } |
2914 | 2914 |
2915 #endif | 2915 #endif |
2916 | 2916 |
2917 } // namespace blink | 2917 } // namespace blink |
OLD | NEW |