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

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

Issue 1473363003: Invalidate first line display item clients when first line style changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address mstensho's comments Created 5 years 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
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 2278 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::enclosingFirstLineStyleBlock() 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::nearestInnerBlockWithFirstLine() const
2325 {
2326 if (childrenInline())
2327 return toLayoutBlockFlow(const_cast<LayoutBlock*>(this));
2328 for (LayoutObject* child = firstChild(); child && !child->isFloatingOrOutOfF lowPositioned() && child->isLayoutBlockFlow(); child = toLayoutBlock(child)->fir stChild()) {
2329 if (child->childrenInline())
2330 return toLayoutBlockFlow(child);
2331 }
2332 return nullptr;
2333 }
2334
2335 // Helper methods for obtaining the last line, computing line counts and heights for line counts 2335 // Helper methods for obtaining the last line, computing line counts and heights for line counts
2336 // (crawling into blocks). 2336 // (crawling into blocks).
2337 static bool shouldCheckLines(LayoutObject* obj) 2337 static bool shouldCheckLines(LayoutObject* obj)
2338 { 2338 {
2339 return !obj->isFloatingOrOutOfFlowPositioned() 2339 return !obj->isFloatingOrOutOfFlowPositioned()
2340 && obj->isLayoutBlock() && obj->style()->height().isAuto() 2340 && obj->isLayoutBlock() && obj->style()->height().isAuto()
2341 && (!obj->isDeprecatedFlexibleBox() || obj->style()->boxOrient() == VERT ICAL); 2341 && (!obj->isDeprecatedFlexibleBox() || obj->style()->boxOrient() == VERT ICAL);
2342 } 2342 }
2343 2343
2344 static int getHeightForLineCount(LayoutBlock* block, int lineCount, bool include Bottom, int& count) 2344 static int getHeightForLineCount(LayoutBlock* block, int lineCount, bool include Bottom, int& count)
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
2912 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const 2912 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const
2913 { 2913 {
2914 showLayoutObject(); 2914 showLayoutObject();
2915 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 2915 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
2916 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 2916 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
2917 } 2917 }
2918 2918
2919 #endif 2919 #endif
2920 2920
2921 } // namespace blink 2921 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698