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

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

Issue 1411823002: Lists: Minor code style revisions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@472084_fix_overflow_hidden
Patch Set: Created 5 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 Apple Inc. All rights reserv ed. 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv ed.
5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
6 * Copyright (C) 2010 Daniel Bates (dbates@intudata.com) 6 * Copyright (C) 2010 Daniel Bates (dbates@intudata.com)
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 18 matching lines...) Expand all
29 #include "core/layout/LayoutAnalyzer.h" 29 #include "core/layout/LayoutAnalyzer.h"
30 #include "core/layout/LayoutListItem.h" 30 #include "core/layout/LayoutListItem.h"
31 #include "core/layout/TextRunConstructor.h" 31 #include "core/layout/TextRunConstructor.h"
32 #include "core/paint/ListMarkerPainter.h" 32 #include "core/paint/ListMarkerPainter.h"
33 #include "core/paint/PaintLayer.h" 33 #include "core/paint/PaintLayer.h"
34 #include "platform/fonts/Font.h" 34 #include "platform/fonts/Font.h"
35 #include "wtf/text/StringBuilder.h" 35 #include "wtf/text/StringBuilder.h"
36 36
37 namespace blink { 37 namespace blink {
38 38
39 const int cMarkerPadding = 7; 39 const int cMarkerPaddingPx = 7;
40 40
41 enum SequenceType { NumericSequence, AlphabeticSequence }; 41 enum SequenceType { NumericSequence, AlphabeticSequence };
42 42
43 static String toRoman(int number, bool upper) 43 static String toRoman(int number, bool upper)
44 { 44 {
45 // FIXME: CSS3 describes how to make this work for much larger numbers, 45 // FIXME: CSS3 describes how to make this work for much larger numbers,
46 // using overbars and special characters. It also specifies the characters 46 // using overbars and special characters. It also specifies the characters
47 // in the range U+2160 to U+217F instead of standard ASCII ones. 47 // in the range U+2160 to U+217F instead of standard ASCII ones.
48 ASSERT(number >= 1 && number <= 3999); 48 ASSERT(number >= 1 && number <= 3999);
49 49
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 { 1027 {
1028 return m_image && !m_image->errorOccurred(); 1028 return m_image && !m_image->errorOccurred();
1029 } 1029 }
1030 1030
1031 LayoutRect LayoutListMarker::localSelectionRect() const 1031 LayoutRect LayoutListMarker::localSelectionRect() const
1032 { 1032 {
1033 InlineBox* box = inlineBoxWrapper(); 1033 InlineBox* box = inlineBoxWrapper();
1034 if (!box) 1034 if (!box)
1035 return LayoutRect(LayoutPoint(), size()); 1035 return LayoutRect(LayoutPoint(), size());
1036 RootInlineBox& root = inlineBoxWrapper()->root(); 1036 RootInlineBox& root = inlineBoxWrapper()->root();
1037 LayoutUnit newLogicalTop = root.block().style()->isFlippedBlocksWritingMode( ) ? inlineBoxWrapper()->logicalBottom() - root.selectionBottom() : root.selectio nTop() - inlineBoxWrapper()->logicalTop(); 1037 const ComputedStyle* blockStyle = root.block().style();
1038 if (root.block().style()->isHorizontalWritingMode()) 1038 LayoutUnit newLogicalTop = blockStyle->isFlippedBlocksWritingMode()
1039 return LayoutRect(0, newLogicalTop, size().width(), root.selectionHeight ()); 1039 ? inlineBoxWrapper()->logicalBottom() - root.selectionBottom()
1040 return LayoutRect(newLogicalTop, 0, root.selectionHeight(), size().height()) ; 1040 : root.selectionTop() - inlineBoxWrapper()->logicalTop();
1041 return blockStyle->isHorizontalWritingMode()
1042 ? LayoutRect(0, newLogicalTop, size().width(), root.selectionHeight())
1043 : LayoutRect(newLogicalTop, 0, root.selectionHeight(), size().height());
1041 } 1044 }
1042 1045
1043 void LayoutListMarker::paint(const PaintInfo& paintInfo, const LayoutPoint& pain tOffset) const 1046 void LayoutListMarker::paint(const PaintInfo& paintInfo, const LayoutPoint& pain tOffset) const
1044 { 1047 {
1045 ListMarkerPainter(*this).paint(paintInfo, paintOffset); 1048 ListMarkerPainter(*this).paint(paintInfo, paintOffset);
1046 } 1049 }
1047 1050
1048 void LayoutListMarker::layout() 1051 void LayoutListMarker::layout()
1049 { 1052 {
1050 ASSERT(needsLayout()); 1053 ASSERT(needsLayout());
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 1175
1173 void LayoutListMarker::updateMargins() 1176 void LayoutListMarker::updateMargins()
1174 { 1177 {
1175 const FontMetrics& fontMetrics = style()->fontMetrics(); 1178 const FontMetrics& fontMetrics = style()->fontMetrics();
1176 1179
1177 LayoutUnit marginStart = 0; 1180 LayoutUnit marginStart = 0;
1178 LayoutUnit marginEnd = 0; 1181 LayoutUnit marginEnd = 0;
1179 1182
1180 if (isInside()) { 1183 if (isInside()) {
1181 if (isImage()) { 1184 if (isImage()) {
1182 marginEnd = cMarkerPadding; 1185 marginEnd = cMarkerPaddingPx;
1183 } else { 1186 } else {
1184 switch (listStyleCategory()) { 1187 switch (listStyleCategory()) {
1185 case ListStyleCategory::Symbol: 1188 case ListStyleCategory::Symbol:
1186 marginStart = -1; 1189 marginStart = -1;
1187 marginEnd = fontMetrics.ascent() - minPreferredLogicalWidth() + 1; 1190 marginEnd = fontMetrics.ascent() - minPreferredLogicalWidth() + 1;
1188 break; 1191 break;
1189 default: 1192 default:
1190 break; 1193 break;
1191 } 1194 }
1192 } 1195 }
1193 } else { 1196 } else {
1194 if (style()->isLeftToRightDirection()) { 1197 if (style()->isLeftToRightDirection()) {
1195 if (isImage()) { 1198 if (isImage()) {
1196 marginStart = -minPreferredLogicalWidth() - cMarkerPadding; 1199 marginStart = -minPreferredLogicalWidth() - cMarkerPaddingPx;
1197 } else { 1200 } else {
1198 int offset = fontMetrics.ascent() * 2 / 3; 1201 int offset = fontMetrics.ascent() * 2 / 3;
1199 switch (listStyleCategory()) { 1202 switch (listStyleCategory()) {
1200 case ListStyleCategory::None: 1203 case ListStyleCategory::None:
1201 break; 1204 break;
1202 case ListStyleCategory::Symbol: 1205 case ListStyleCategory::Symbol:
1203 marginStart = -offset - cMarkerPadding - 1; 1206 marginStart = -offset - cMarkerPaddingPx - 1;
1204 break; 1207 break;
1205 default: 1208 default:
1206 marginStart = m_text.isEmpty() ? LayoutUnit() : -minPreferre dLogicalWidth(); 1209 marginStart = m_text.isEmpty() ? LayoutUnit() : -minPreferre dLogicalWidth();
1207 } 1210 }
1208 } 1211 }
1209 marginEnd = -marginStart - minPreferredLogicalWidth(); 1212 marginEnd = -marginStart - minPreferredLogicalWidth();
1210 } else { 1213 } else {
1211 if (isImage()) { 1214 if (isImage()) {
1212 marginEnd = cMarkerPadding; 1215 marginEnd = cMarkerPaddingPx;
1213 } else { 1216 } else {
1214 int offset = fontMetrics.ascent() * 2 / 3; 1217 int offset = fontMetrics.ascent() * 2 / 3;
1215 switch (listStyleCategory()) { 1218 switch (listStyleCategory()) {
1216 case ListStyleCategory::None: 1219 case ListStyleCategory::None:
1217 break; 1220 break;
1218 case ListStyleCategory::Symbol: 1221 case ListStyleCategory::Symbol:
1219 marginEnd = offset + cMarkerPadding + 1 - minPreferredLogica lWidth(); 1222 marginEnd = offset + cMarkerPaddingPx + 1 - minPreferredLogi calWidth();
1220 break; 1223 break;
1221 default: 1224 default:
1222 marginEnd = 0; 1225 marginEnd = 0;
1223 } 1226 }
1224 } 1227 }
1225 marginStart = -marginEnd - minPreferredLogicalWidth(); 1228 marginStart = -marginEnd - minPreferredLogicalWidth();
1226 } 1229 }
1227 1230
1228 } 1231 }
1229 1232
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1384 if (style()) { 1387 if (style()) {
1385 // Reuse the current margins. Otherwise resetting the margins to initial values 1388 // Reuse the current margins. Otherwise resetting the margins to initial values
1386 // would trigger unnecessary layout. 1389 // would trigger unnecessary layout.
1387 newStyle->setMarginStart(style()->marginStart()); 1390 newStyle->setMarginStart(style()->marginStart());
1388 newStyle->setMarginEnd(style()->marginRight()); 1391 newStyle->setMarginEnd(style()->marginRight());
1389 } 1392 }
1390 setStyle(newStyle.release()); 1393 setStyle(newStyle.release());
1391 } 1394 }
1392 1395
1393 } // namespace blink 1396 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698