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

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

Issue 2578403002: Changed EVerticalAlign to an enum class and renamed its members (Closed)
Patch Set: Created 4 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) 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 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 bool isLayoutInline = boxModel.isLayoutInline(); 675 bool isLayoutInline = boxModel.isLayoutInline();
676 if (isLayoutInline && !firstLine) { 676 if (isLayoutInline && !firstLine) {
677 LayoutUnit verticalPosition = 677 LayoutUnit verticalPosition =
678 LayoutUnit(verticalPositionCache.get(boxModel, baselineType())); 678 LayoutUnit(verticalPositionCache.get(boxModel, baselineType()));
679 if (verticalPosition != PositionUndefined) 679 if (verticalPosition != PositionUndefined)
680 return verticalPosition; 680 return verticalPosition;
681 } 681 }
682 682
683 LayoutUnit verticalPosition; 683 LayoutUnit verticalPosition;
684 EVerticalAlign verticalAlign = boxModel.style()->verticalAlign(); 684 EVerticalAlign verticalAlign = boxModel.style()->verticalAlign();
685 if (verticalAlign == VerticalAlignTop || verticalAlign == VerticalAlignBottom) 685 if (verticalAlign == EVerticalAlign::Top ||
686 verticalAlign == EVerticalAlign::Bottom)
686 return LayoutUnit(); 687 return LayoutUnit();
687 688
688 LineLayoutItem parent = boxModel.parent(); 689 LineLayoutItem parent = boxModel.parent();
689 if (parent.isLayoutInline() && 690 if (parent.isLayoutInline() &&
690 parent.style()->verticalAlign() != VerticalAlignTop && 691 parent.style()->verticalAlign() != EVerticalAlign::Top &&
691 parent.style()->verticalAlign() != VerticalAlignBottom) 692 parent.style()->verticalAlign() != EVerticalAlign::Bottom)
692 verticalPosition = box->parent()->logicalTop(); 693 verticalPosition = box->parent()->logicalTop();
693 694
694 if (verticalAlign != VerticalAlignBaseline) { 695 if (verticalAlign != EVerticalAlign::Baseline) {
695 const Font& font = parent.style(firstLine)->font(); 696 const Font& font = parent.style(firstLine)->font();
696 const SimpleFontData* fontData = font.primaryFont(); 697 const SimpleFontData* fontData = font.primaryFont();
697 DCHECK(fontData); 698 DCHECK(fontData);
698 if (!fontData) 699 if (!fontData)
699 return LayoutUnit(); 700 return LayoutUnit();
700 701
701 const FontMetrics& fontMetrics = fontData->getFontMetrics(); 702 const FontMetrics& fontMetrics = fontData->getFontMetrics();
702 int fontSize = font.getFontDescription().computedPixelSize(); 703 int fontSize = font.getFontDescription().computedPixelSize();
703 704
704 LineDirectionMode lineDirection = 705 LineDirectionMode lineDirection =
705 parent.isHorizontalWritingMode() ? HorizontalLine : VerticalLine; 706 parent.isHorizontalWritingMode() ? HorizontalLine : VerticalLine;
706 707
707 if (verticalAlign == VerticalAlignSub) { 708 if (verticalAlign == EVerticalAlign::Sub) {
708 verticalPosition += fontSize / 5 + 1; 709 verticalPosition += fontSize / 5 + 1;
709 } else if (verticalAlign == VerticalAlignSuper) { 710 } else if (verticalAlign == EVerticalAlign::Super) {
710 verticalPosition -= fontSize / 3 + 1; 711 verticalPosition -= fontSize / 3 + 1;
711 } else if (verticalAlign == VerticalAlignTextTop) { 712 } else if (verticalAlign == EVerticalAlign::TextTop) {
712 verticalPosition += 713 verticalPosition +=
713 boxModel.baselinePosition(baselineType(), firstLine, lineDirection) - 714 boxModel.baselinePosition(baselineType(), firstLine, lineDirection) -
714 fontMetrics.ascent(baselineType()); 715 fontMetrics.ascent(baselineType());
715 } else if (verticalAlign == VerticalAlignMiddle) { 716 } else if (verticalAlign == EVerticalAlign::Middle) {
716 verticalPosition = LayoutUnit( 717 verticalPosition = LayoutUnit(
717 (verticalPosition - LayoutUnit(fontMetrics.xHeight() / 2) - 718 (verticalPosition - LayoutUnit(fontMetrics.xHeight() / 2) -
718 boxModel.lineHeight(firstLine, lineDirection) / 2 + 719 boxModel.lineHeight(firstLine, lineDirection) / 2 +
719 boxModel.baselinePosition(baselineType(), firstLine, lineDirection)) 720 boxModel.baselinePosition(baselineType(), firstLine, lineDirection))
720 .round()); 721 .round());
721 } else if (verticalAlign == VerticalAlignTextBottom) { 722 } else if (verticalAlign == EVerticalAlign::TextBottom) {
722 verticalPosition += fontMetrics.descent(baselineType()); 723 verticalPosition += fontMetrics.descent(baselineType());
723 // lineHeight - baselinePosition is always 0 for replaced elements (except 724 // lineHeight - baselinePosition is always 0 for replaced elements (except
724 // inline blocks), so don't bother wasting time in that case. 725 // inline blocks), so don't bother wasting time in that case.
725 if (!boxModel.isAtomicInlineLevel() || 726 if (!boxModel.isAtomicInlineLevel() ||
726 boxModel.isInlineBlockOrInlineTable()) 727 boxModel.isInlineBlockOrInlineTable())
727 verticalPosition -= (boxModel.lineHeight(firstLine, lineDirection) - 728 verticalPosition -= (boxModel.lineHeight(firstLine, lineDirection) -
728 boxModel.baselinePosition( 729 boxModel.baselinePosition(
729 baselineType(), firstLine, lineDirection)); 730 baselineType(), firstLine, lineDirection));
730 } else if (verticalAlign == VerticalAlignBaselineMiddle) { 731 } else if (verticalAlign == EVerticalAlign::BaselineMiddle) {
731 verticalPosition += 732 verticalPosition +=
732 -boxModel.lineHeight(firstLine, lineDirection) / 2 + 733 -boxModel.lineHeight(firstLine, lineDirection) / 2 +
733 boxModel.baselinePosition(baselineType(), firstLine, lineDirection); 734 boxModel.baselinePosition(baselineType(), firstLine, lineDirection);
734 } else if (verticalAlign == VerticalAlignLength) { 735 } else if (verticalAlign == EVerticalAlign::Length) {
735 LayoutUnit lineHeight; 736 LayoutUnit lineHeight;
736 // Per http://www.w3.org/TR/CSS21/visudet.html#propdef-vertical-align: 737 // Per http://www.w3.org/TR/CSS21/visudet.html#propdef-vertical-align:
737 // 'Percentages: refer to the 'line-height' of the element itself'. 738 // 'Percentages: refer to the 'line-height' of the element itself'.
738 if (boxModel.style()->getVerticalAlignLength().isPercentOrCalc()) 739 if (boxModel.style()->getVerticalAlignLength().isPercentOrCalc())
739 lineHeight = LayoutUnit(boxModel.style()->computedLineHeight()); 740 lineHeight = LayoutUnit(boxModel.style()->computedLineHeight());
740 else 741 else
741 lineHeight = boxModel.lineHeight(firstLine, lineDirection); 742 lineHeight = boxModel.lineHeight(firstLine, lineDirection);
742 verticalPosition -= valueForLength( 743 verticalPosition -= valueForLength(
743 boxModel.style()->getVerticalAlignLength(), lineHeight); 744 boxModel.style()->getVerticalAlignLength(), lineHeight);
744 } 745 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 } 782 }
782 endBox = nullptr; 783 endBox = nullptr;
783 return nullptr; 784 return nullptr;
784 } 785 }
785 786
786 const char* RootInlineBox::boxName() const { 787 const char* RootInlineBox::boxName() const {
787 return "RootInlineBox"; 788 return "RootInlineBox";
788 } 789 }
789 790
790 } // namespace blink 791 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/line/InlineFlowBox.cpp ('k') | third_party/WebKit/Source/core/style/ComputedStyle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698