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