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

Side by Side Diff: Source/core/rendering/RootInlineBox.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) 2003, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 } 614 }
615 615
616 void RootInlineBox::ascentAndDescentForBox(InlineBox* box, GlyphOverflowAndFallb ackFontsMap& textBoxDataMap, int& ascent, int& descent, 616 void RootInlineBox::ascentAndDescentForBox(InlineBox* box, GlyphOverflowAndFallb ackFontsMap& textBoxDataMap, int& ascent, int& descent,
617 bool& affectsAscent, bool& affectsDes cent) const 617 bool& affectsAscent, bool& affectsDes cent) const
618 { 618 {
619 bool ascentDescentSet = false; 619 bool ascentDescentSet = false;
620 620
621 // Replaced boxes will return 0 for the line-height if line-box-contain says they are 621 // Replaced boxes will return 0 for the line-height if line-box-contain says they are
622 // not to be included. 622 // not to be included.
623 if (box->renderer().isReplaced()) { 623 if (box->renderer().isReplaced()) {
624 if (renderer().style(isFirstLineStyle())->lineBoxContain() & LineBoxCont ainReplaced) { 624 if (renderer().styleOrFirstLineStyle(isFirstLineStyle())->lineBoxContain () & LineBoxContainReplaced) {
625 ascent = box->baselinePosition(baselineType()); 625 ascent = box->baselinePosition(baselineType());
626 descent = box->lineHeight() - ascent; 626 descent = box->lineHeight() - ascent;
627 627
628 // Replaced elements always affect both the ascent and descent. 628 // Replaced elements always affect both the ascent and descent.
629 affectsAscent = true; 629 affectsAscent = true;
630 affectsDescent = true; 630 affectsDescent = true;
631 } 631 }
632 return; 632 return;
633 } 633 }
634 634
635 Vector<const SimpleFontData*>* usedFonts = 0; 635 Vector<const SimpleFontData*>* usedFonts = 0;
636 GlyphOverflow* glyphOverflow = 0; 636 GlyphOverflow* glyphOverflow = 0;
637 if (box->isText()) { 637 if (box->isText()) {
638 GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(toIn lineTextBox(box)); 638 GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(toIn lineTextBox(box));
639 usedFonts = it == textBoxDataMap.end() ? 0 : &it->value.first; 639 usedFonts = it == textBoxDataMap.end() ? 0 : &it->value.first;
640 glyphOverflow = it == textBoxDataMap.end() ? 0 : &it->value.second; 640 glyphOverflow = it == textBoxDataMap.end() ? 0 : &it->value.second;
641 } 641 }
642 642
643 bool includeLeading = includeLeadingForBox(box); 643 bool includeLeading = includeLeadingForBox(box);
644 bool includeFont = includeFontForBox(box); 644 bool includeFont = includeFontForBox(box);
645 645
646 bool setUsedFont = false; 646 bool setUsedFont = false;
647 bool setUsedFontWithLeading = false; 647 bool setUsedFontWithLeading = false;
648 648
649 if (usedFonts && !usedFonts->isEmpty() && (includeFont || (box->renderer().s tyle(isFirstLineStyle())->lineHeight().isNegative() && includeLeading))) { 649 if (usedFonts && !usedFonts->isEmpty() && (includeFont || (box->renderer().s tyleOrFirstLineStyle(isFirstLineStyle())->lineHeight().isNegative() && includeLe ading))) {
650 usedFonts->append(box->renderer().style(isFirstLineStyle())->font().prim aryFont()); 650 usedFonts->append(box->renderer().styleOrFirstLineStyle(isFirstLineStyle ())->font().primaryFont());
651 for (size_t i = 0; i < usedFonts->size(); ++i) { 651 for (size_t i = 0; i < usedFonts->size(); ++i) {
652 const FontMetrics& fontMetrics = usedFonts->at(i)->fontMetrics(); 652 const FontMetrics& fontMetrics = usedFonts->at(i)->fontMetrics();
653 int usedFontAscent = fontMetrics.ascent(baselineType()); 653 int usedFontAscent = fontMetrics.ascent(baselineType());
654 int usedFontDescent = fontMetrics.descent(baselineType()); 654 int usedFontDescent = fontMetrics.descent(baselineType());
655 int halfLeading = (fontMetrics.lineSpacing() - fontMetrics.height()) / 2; 655 int halfLeading = (fontMetrics.lineSpacing() - fontMetrics.height()) / 2;
656 int usedFontAscentAndLeading = usedFontAscent + halfLeading; 656 int usedFontAscentAndLeading = usedFontAscent + halfLeading;
657 int usedFontDescentAndLeading = fontMetrics.lineSpacing() - usedFont AscentAndLeading; 657 int usedFontDescentAndLeading = fontMetrics.lineSpacing() - usedFont AscentAndLeading;
658 if (includeFont) { 658 if (includeFont) {
659 setAscentAndDescent(ascent, descent, usedFontAscent, usedFontDes cent, ascentDescentSet); 659 setAscentAndDescent(ascent, descent, usedFontAscent, usedFontDes cent, ascentDescentSet);
660 setUsedFont = true; 660 setUsedFont = true;
(...skipping 17 matching lines...) Expand all
678 678
679 // Examine the font box for inline flows and text boxes to see if any pa rt of it is above the baseline. 679 // Examine the font box for inline flows and text boxes to see if any pa rt of it is above the baseline.
680 // If the top of our font box relative to the root box baseline is above the root box baseline, then 680 // If the top of our font box relative to the root box baseline is above the root box baseline, then
681 // we are contributing to the maxAscent value. Descent is similar. If an y part of our font box is below 681 // we are contributing to the maxAscent value. Descent is similar. If an y part of our font box is below
682 // the root box's baseline, then we contribute to the maxDescent value. 682 // the root box's baseline, then we contribute to the maxDescent value.
683 affectsAscent = ascentWithLeading - box->logicalTop() > 0; 683 affectsAscent = ascentWithLeading - box->logicalTop() > 0;
684 affectsDescent = descentWithLeading + box->logicalTop() > 0; 684 affectsDescent = descentWithLeading + box->logicalTop() > 0;
685 } 685 }
686 686
687 if (includeFontForBox(box) && !setUsedFont) { 687 if (includeFontForBox(box) && !setUsedFont) {
688 int fontAscent = box->renderer().style(isFirstLineStyle())->fontMetrics( ).ascent(baselineType()); 688 int fontAscent = box->renderer().styleOrFirstLineStyle(isFirstLineStyle( ))->fontMetrics().ascent(baselineType());
689 int fontDescent = box->renderer().style(isFirstLineStyle())->fontMetrics ().descent(baselineType()); 689 int fontDescent = box->renderer().styleOrFirstLineStyle(isFirstLineStyle ())->fontMetrics().descent(baselineType());
690 setAscentAndDescent(ascent, descent, fontAscent, fontDescent, ascentDesc entSet); 690 setAscentAndDescent(ascent, descent, fontAscent, fontDescent, ascentDesc entSet);
691 affectsAscent = fontAscent - box->logicalTop() > 0; 691 affectsAscent = fontAscent - box->logicalTop() > 0;
692 affectsDescent = fontDescent + box->logicalTop() > 0; 692 affectsDescent = fontDescent + box->logicalTop() > 0;
693 } 693 }
694 694
695 if (includeGlyphsForBox(box) && glyphOverflow && glyphOverflow->computeBound s) { 695 if (includeGlyphsForBox(box) && glyphOverflow && glyphOverflow->computeBound s) {
696 setAscentAndDescent(ascent, descent, glyphOverflow->top, glyphOverflow-> bottom, ascentDescentSet); 696 setAscentAndDescent(ascent, descent, glyphOverflow->top, glyphOverflow-> bottom, ascentDescentSet);
697 affectsAscent = glyphOverflow->top - box->logicalTop() > 0; 697 affectsAscent = glyphOverflow->top - box->logicalTop() > 0;
698 affectsDescent = glyphOverflow->bottom + box->logicalTop() > 0; 698 affectsDescent = glyphOverflow->bottom + box->logicalTop() > 0;
699 glyphOverflow->top = std::min(glyphOverflow->top, std::max(0, glyphOverf low->top - box->renderer().style(isFirstLineStyle())->fontMetrics().ascent(basel ineType()))); 699 glyphOverflow->top = std::min(glyphOverflow->top, std::max(0, glyphOverf low->top - box->renderer().styleOrFirstLineStyle(isFirstLineStyle())->fontMetric s().ascent(baselineType())));
700 glyphOverflow->bottom = std::min(glyphOverflow->bottom, std::max(0, glyp hOverflow->bottom - box->renderer().style(isFirstLineStyle())->fontMetrics().des cent(baselineType()))); 700 glyphOverflow->bottom = std::min(glyphOverflow->bottom, std::max(0, glyp hOverflow->bottom - box->renderer().styleOrFirstLineStyle(isFirstLineStyle())->f ontMetrics().descent(baselineType())));
701 } 701 }
702 702
703 if (includeMarginForBox(box)) { 703 if (includeMarginForBox(box)) {
704 LayoutUnit ascentWithMargin = box->renderer().style(isFirstLineStyle())- >fontMetrics().ascent(baselineType()); 704 LayoutUnit ascentWithMargin = box->renderer().styleOrFirstLineStyle(isFi rstLineStyle())->fontMetrics().ascent(baselineType());
705 LayoutUnit descentWithMargin = box->renderer().style(isFirstLineStyle()) ->fontMetrics().descent(baselineType()); 705 LayoutUnit descentWithMargin = box->renderer().styleOrFirstLineStyle(isF irstLineStyle())->fontMetrics().descent(baselineType());
706 if (box->parent() && !box->renderer().isText()) { 706 if (box->parent() && !box->renderer().isText()) {
707 ascentWithMargin += box->boxModelObject()->borderBefore() + box->box ModelObject()->paddingBefore() + box->boxModelObject()->marginBefore(); 707 ascentWithMargin += box->boxModelObject()->borderBefore() + box->box ModelObject()->paddingBefore() + box->boxModelObject()->marginBefore();
708 descentWithMargin += box->boxModelObject()->borderAfter() + box->box ModelObject()->paddingAfter() + box->boxModelObject()->marginAfter(); 708 descentWithMargin += box->boxModelObject()->borderAfter() + box->box ModelObject()->paddingAfter() + box->boxModelObject()->marginAfter();
709 } 709 }
710 setAscentAndDescent(ascent, descent, ascentWithMargin, descentWithMargin , ascentDescentSet); 710 setAscentAndDescent(ascent, descent, ascentWithMargin, descentWithMargin , ascentDescentSet);
711 711
712 // Treat like a replaced element, since we're using the margin box. 712 // Treat like a replaced element, since we're using the margin box.
713 affectsAscent = true; 713 affectsAscent = true;
714 affectsDescent = true; 714 affectsDescent = true;
715 } 715 }
(...skipping 25 matching lines...) Expand all
741 LayoutUnit verticalPosition = 0; 741 LayoutUnit verticalPosition = 0;
742 EVerticalAlign verticalAlign = renderer->style()->verticalAlign(); 742 EVerticalAlign verticalAlign = renderer->style()->verticalAlign();
743 if (verticalAlign == TOP || verticalAlign == BOTTOM) 743 if (verticalAlign == TOP || verticalAlign == BOTTOM)
744 return 0; 744 return 0;
745 745
746 RenderObject* parent = renderer->parent(); 746 RenderObject* parent = renderer->parent();
747 if (parent->isRenderInline() && parent->style()->verticalAlign() != TOP && p arent->style()->verticalAlign() != BOTTOM) 747 if (parent->isRenderInline() && parent->style()->verticalAlign() != TOP && p arent->style()->verticalAlign() != BOTTOM)
748 verticalPosition = box->parent()->logicalTop(); 748 verticalPosition = box->parent()->logicalTop();
749 749
750 if (verticalAlign != BASELINE) { 750 if (verticalAlign != BASELINE) {
751 const Font& font = parent->style(firstLine)->font(); 751 const Font& font = parent->styleOrFirstLineStyle(firstLine)->font();
752 const FontMetrics& fontMetrics = font.fontMetrics(); 752 const FontMetrics& fontMetrics = font.fontMetrics();
753 int fontSize = font.fontDescription().computedPixelSize(); 753 int fontSize = font.fontDescription().computedPixelSize();
754 754
755 LineDirectionMode lineDirection = parent->isHorizontalWritingMode() ? Ho rizontalLine : VerticalLine; 755 LineDirectionMode lineDirection = parent->isHorizontalWritingMode() ? Ho rizontalLine : VerticalLine;
756 756
757 if (verticalAlign == SUB) 757 if (verticalAlign == SUB)
758 verticalPosition += fontSize / 5 + 1; 758 verticalPosition += fontSize / 5 + 1;
759 else if (verticalAlign == SUPER) 759 else if (verticalAlign == SUPER)
760 verticalPosition -= fontSize / 3 + 1; 760 verticalPosition -= fontSize / 3 + 1;
761 else if (verticalAlign == TEXT_TOP) 761 else if (verticalAlign == TEXT_TOP)
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 } 874 }
875 875
876 #ifndef NDEBUG 876 #ifndef NDEBUG
877 const char* RootInlineBox::boxName() const 877 const char* RootInlineBox::boxName() const
878 { 878 {
879 return "RootInlineBox"; 879 return "RootInlineBox";
880 } 880 }
881 #endif 881 #endif
882 882
883 } // namespace WebCore 883 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderText.cpp ('k') | Source/core/rendering/line/BreakingContextInlineHeaders.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698