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

Side by Side Diff: Source/core/rendering/RenderInline.cpp

Issue 355843002: Rename style(bool) to styleOrFirstLineStyle(bool) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 6 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
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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 bool checkFonts = document().inNoQuirksMode(); 209 bool checkFonts = document().inNoQuirksMode();
210 bool alwaysCreateLineBoxes = (parentRenderInline && parentRenderInline->alwa ysCreateLineBoxes()) 210 bool alwaysCreateLineBoxes = (parentRenderInline && parentRenderInline->alwa ysCreateLineBoxes())
211 || (parentRenderInline && parentStyle->verticalAlign() != BASELINE) 211 || (parentRenderInline && parentStyle->verticalAlign() != BASELINE)
212 || style()->verticalAlign() != BASELINE 212 || style()->verticalAlign() != BASELINE
213 || style()->textEmphasisMark() != TextEmphasisMarkNone 213 || style()->textEmphasisMark() != TextEmphasisMarkNone
214 || (checkFonts && (!parentStyle->font().fontMetrics().hasIdenticalAscent DescentAndLineGap(style()->font().fontMetrics()) 214 || (checkFonts && (!parentStyle->font().fontMetrics().hasIdenticalAscent DescentAndLineGap(style()->font().fontMetrics())
215 || parentStyle->lineHeight() != style()->lineHeight())); 215 || parentStyle->lineHeight() != style()->lineHeight()));
216 216
217 if (!alwaysCreateLineBoxes && checkFonts && document().styleEngine()->usesFi rstLineRules()) { 217 if (!alwaysCreateLineBoxes && checkFonts && document().styleEngine()->usesFi rstLineRules()) {
218 // Have to check the first line style as well. 218 // Have to check the first line style as well.
219 parentStyle = parent()->style(true); 219 parentStyle = parent()->styleOrFirstLineStyle(true);
220 RenderStyle* childStyle = style(true); 220 RenderStyle* childStyle = styleOrFirstLineStyle(true);
221 alwaysCreateLineBoxes = !parentStyle->font().fontMetrics().hasIdenticalA scentDescentAndLineGap(childStyle->font().fontMetrics()) 221 alwaysCreateLineBoxes = !parentStyle->font().fontMetrics().hasIdenticalA scentDescentAndLineGap(childStyle->font().fontMetrics())
222 || childStyle->verticalAlign() != BASELINE 222 || childStyle->verticalAlign() != BASELINE
223 || parentStyle->lineHeight() != childStyle->lineHeight(); 223 || parentStyle->lineHeight() != childStyle->lineHeight();
224 } 224 }
225 225
226 if (alwaysCreateLineBoxes) { 226 if (alwaysCreateLineBoxes) {
227 if (!fullLayout) 227 if (!fullLayout)
228 dirtyLineBoxes(false); 228 dirtyLineBoxes(false);
229 m_alwaysCreateLineBoxes = true; 229 m_alwaysCreateLineBoxes = true;
230 } 230 }
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()) { 549 for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()) {
550 if (curr->isFloatingOrOutOfFlowPositioned()) 550 if (curr->isFloatingOrOutOfFlowPositioned())
551 continue; 551 continue;
552 552
553 // We want to get the margin box in the inline direction, and then use o ur font ascent/descent in the block 553 // We want to get the margin box in the inline direction, and then use o ur font ascent/descent in the block
554 // direction (aligned to the root box's baseline). 554 // direction (aligned to the root box's baseline).
555 if (curr->isBox()) { 555 if (curr->isBox()) {
556 RenderBox* currBox = toRenderBox(curr); 556 RenderBox* currBox = toRenderBox(curr);
557 if (currBox->inlineBoxWrapper()) { 557 if (currBox->inlineBoxWrapper()) {
558 RootInlineBox& rootBox = currBox->inlineBoxWrapper()->root(); 558 RootInlineBox& rootBox = currBox->inlineBoxWrapper()->root();
559 int logicalTop = rootBox.logicalTop() + (rootBox.renderer().styl e(rootBox.isFirstLineStyle())->font().fontMetrics().ascent() - container->style( rootBox.isFirstLineStyle())->font().fontMetrics().ascent()); 559 int logicalTop = rootBox.logicalTop() + (rootBox.renderer().styl eOrFirstLineStyle(rootBox.isFirstLineStyle())->font().fontMetrics().ascent() - c ontainer->styleOrFirstLineStyle(rootBox.isFirstLineStyle())->font().fontMetrics( ).ascent());
560 int logicalHeight = container->style(rootBox.isFirstLineStyle()) ->font().fontMetrics().height(); 560 int logicalHeight = container->styleOrFirstLineStyle(rootBox.isF irstLineStyle())->font().fontMetrics().height();
561 if (isHorizontal) 561 if (isHorizontal)
562 yield(FloatRect(currBox->inlineBoxWrapper()->x() - currBox-> marginLeft(), logicalTop, (currBox->width() + currBox->marginWidth()).toFloat(), logicalHeight)); 562 yield(FloatRect(currBox->inlineBoxWrapper()->x() - currBox-> marginLeft(), logicalTop, (currBox->width() + currBox->marginWidth()).toFloat(), logicalHeight));
563 else 563 else
564 yield(FloatRect(logicalTop, currBox->inlineBoxWrapper()->y() - currBox->marginTop(), logicalHeight, (currBox->height() + currBox->marginHeig ht()).toFloat())); 564 yield(FloatRect(logicalTop, currBox->inlineBoxWrapper()->y() - currBox->marginTop(), logicalHeight, (currBox->height() + currBox->marginHeig ht()).toFloat()));
565 } 565 }
566 } else if (curr->isRenderInline()) { 566 } else if (curr->isRenderInline()) {
567 // If the child doesn't need line boxes either, then we can recur. 567 // If the child doesn't need line boxes either, then we can recur.
568 RenderInline* currInline = toRenderInline(curr); 568 RenderInline* currInline = toRenderInline(curr);
569 if (!currInline->alwaysCreateLineBoxes()) 569 if (!currInline->alwaysCreateLineBoxes())
570 currInline->generateCulledLineBoxRects(yield, container); 570 currInline->generateCulledLineBoxRects(yield, container);
571 else { 571 else {
572 for (InlineFlowBox* childLine = currInline->firstLineBox(); chil dLine; childLine = childLine->nextLineBox()) { 572 for (InlineFlowBox* childLine = currInline->firstLineBox(); chil dLine; childLine = childLine->nextLineBox()) {
573 RootInlineBox& rootBox = childLine->root(); 573 RootInlineBox& rootBox = childLine->root();
574 int logicalTop = rootBox.logicalTop() + (rootBox.renderer(). style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent() - container->st yle(rootBox.isFirstLineStyle())->font().fontMetrics().ascent()); 574 int logicalTop = rootBox.logicalTop() + (rootBox.renderer(). styleOrFirstLineStyle(rootBox.isFirstLineStyle())->font().fontMetrics().ascent() - container->styleOrFirstLineStyle(rootBox.isFirstLineStyle())->font().fontMetr ics().ascent());
575 int logicalHeight = container->style(rootBox.isFirstLineStyl e())->font().fontMetrics().height(); 575 int logicalHeight = container->styleOrFirstLineStyle(rootBox .isFirstLineStyle())->font().fontMetrics().height();
576 if (isHorizontal) 576 if (isHorizontal)
577 yield(FloatRect(childLine->x() - childLine->marginLogica lLeft(), 577 yield(FloatRect(childLine->x() - childLine->marginLogica lLeft(),
578 logicalTop, 578 logicalTop,
579 childLine->logicalWidth() + childLine->marginLogical Left() + childLine->marginLogicalRight(), 579 childLine->logicalWidth() + childLine->marginLogical Left() + childLine->marginLogicalRight(),
580 logicalHeight)); 580 logicalHeight));
581 else 581 else
582 yield(FloatRect(logicalTop, 582 yield(FloatRect(logicalTop,
583 childLine->y() - childLine->marginLogicalLeft(), 583 childLine->y() - childLine->marginLogicalLeft(),
584 logicalHeight, 584 logicalHeight,
585 childLine->logicalWidth() + childLine->marginLogical Left() + childLine->marginLogicalRight())); 585 childLine->logicalWidth() + childLine->marginLogical Left() + childLine->marginLogicalRight()));
586 } 586 }
587 } 587 }
588 } else if (curr->isText()) { 588 } else if (curr->isText()) {
589 RenderText* currText = toRenderText(curr); 589 RenderText* currText = toRenderText(curr);
590 for (InlineTextBox* childText = currText->firstTextBox(); childText; childText = childText->nextTextBox()) { 590 for (InlineTextBox* childText = currText->firstTextBox(); childText; childText = childText->nextTextBox()) {
591 RootInlineBox& rootBox = childText->root(); 591 RootInlineBox& rootBox = childText->root();
592 int logicalTop = rootBox.logicalTop() + (rootBox.renderer().styl e(rootBox.isFirstLineStyle())->font().fontMetrics().ascent() - container->style( rootBox.isFirstLineStyle())->font().fontMetrics().ascent()); 592 int logicalTop = rootBox.logicalTop() + (rootBox.renderer().styl eOrFirstLineStyle(rootBox.isFirstLineStyle())->font().fontMetrics().ascent() - c ontainer->styleOrFirstLineStyle(rootBox.isFirstLineStyle())->font().fontMetrics( ).ascent());
593 int logicalHeight = container->style(rootBox.isFirstLineStyle()) ->font().fontMetrics().height(); 593 int logicalHeight = container->styleOrFirstLineStyle(rootBox.isF irstLineStyle())->font().fontMetrics().height();
594 if (isHorizontal) 594 if (isHorizontal)
595 yield(FloatRect(childText->x(), logicalTop, childText->logic alWidth(), logicalHeight)); 595 yield(FloatRect(childText->x(), logicalTop, childText->logic alWidth(), logicalHeight));
596 else 596 else
597 yield(FloatRect(logicalTop, childText->y(), logicalHeight, c hildText->logicalWidth())); 597 yield(FloatRect(logicalTop, childText->y(), logicalHeight, c hildText->logicalWidth()));
598 } 598 }
599 } 599 }
600 } 600 }
601 } 601 }
602 602
603 namespace { 603 namespace {
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
1274 { 1274 {
1275 setAlwaysCreateLineBoxes(); 1275 setAlwaysCreateLineBoxes();
1276 InlineFlowBox* flowBox = createInlineFlowBox(); 1276 InlineFlowBox* flowBox = createInlineFlowBox();
1277 m_lineBoxes.appendLineBox(flowBox); 1277 m_lineBoxes.appendLineBox(flowBox);
1278 return flowBox; 1278 return flowBox;
1279 } 1279 }
1280 1280
1281 LayoutUnit RenderInline::lineHeight(bool firstLine, LineDirectionMode /*directio n*/, LinePositionMode /*linePositionMode*/) const 1281 LayoutUnit RenderInline::lineHeight(bool firstLine, LineDirectionMode /*directio n*/, LinePositionMode /*linePositionMode*/) const
1282 { 1282 {
1283 if (firstLine && document().styleEngine()->usesFirstLineRules()) { 1283 if (firstLine && document().styleEngine()->usesFirstLineRules()) {
1284 RenderStyle* s = style(firstLine); 1284 RenderStyle* s = styleOrFirstLineStyle(firstLine);
1285 if (s != style()) 1285 if (s != style())
1286 return s->computedLineHeight(); 1286 return s->computedLineHeight();
1287 } 1287 }
1288 1288
1289 return style()->computedLineHeight(); 1289 return style()->computedLineHeight();
1290 } 1290 }
1291 1291
1292 int RenderInline::baselinePosition(FontBaseline baselineType, bool firstLine, Li neDirectionMode direction, LinePositionMode linePositionMode) const 1292 int RenderInline::baselinePosition(FontBaseline baselineType, bool firstLine, Li neDirectionMode direction, LinePositionMode linePositionMode) const
1293 { 1293 {
1294 ASSERT(linePositionMode == PositionOnContainingLine); 1294 ASSERT(linePositionMode == PositionOnContainingLine);
1295 const FontMetrics& fontMetrics = style(firstLine)->fontMetrics(); 1295 const FontMetrics& fontMetrics = styleOrFirstLineStyle(firstLine)->fontMetri cs();
1296 return fontMetrics.ascent(baselineType) + (lineHeight(firstLine, direction, linePositionMode) - fontMetrics.height()) / 2; 1296 return fontMetrics.ascent(baselineType) + (lineHeight(firstLine, direction, linePositionMode) - fontMetrics.height()) / 2;
1297 } 1297 }
1298 1298
1299 LayoutSize RenderInline::offsetForInFlowPositionedInline(const RenderBox& child) const 1299 LayoutSize RenderInline::offsetForInFlowPositionedInline(const RenderBox& child) const
1300 { 1300 {
1301 // FIXME: This function isn't right with mixed writing modes. 1301 // FIXME: This function isn't right with mixed writing modes.
1302 1302
1303 ASSERT(isInFlowPositioned()); 1303 ASSERT(isInFlowPositioned());
1304 if (!isInFlowPositioned()) 1304 if (!isInFlowPositioned())
1305 return LayoutSize(); 1305 return LayoutSize();
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 container = this; 1564 container = this;
1565 1565
1566 FloatPoint absPos = container->localToAbsolute(); 1566 FloatPoint absPos = container->localToAbsolute();
1567 region.bounds.setX(absPos.x() + region.bounds.x()); 1567 region.bounds.setX(absPos.x() + region.bounds.x());
1568 region.bounds.setY(absPos.y() + region.bounds.y()); 1568 region.bounds.setY(absPos.y() + region.bounds.y());
1569 1569
1570 regions.append(region); 1570 regions.append(region);
1571 } 1571 }
1572 1572
1573 } // namespace WebCore 1573 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderDeprecatedFlexibleBox.cpp ('k') | Source/core/rendering/RenderObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698