OLD | NEW |
---|---|
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. | 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. |
5 * All rights reserved. | 5 * All rights reserved. |
6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) | 6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) |
7 * Copyright (C) 2010 Daniel Bates (dbates@intudata.com) | 7 * Copyright (C) 2010 Daniel Bates (dbates@intudata.com) |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 25 matching lines...) Expand all Loading... | |
36 namespace blink { | 36 namespace blink { |
37 | 37 |
38 const int cMarkerPaddingPx = 7; | 38 const int cMarkerPaddingPx = 7; |
39 | 39 |
40 // TODO(glebl): Move to WebKit/Source/core/css/html.css after | 40 // TODO(glebl): Move to WebKit/Source/core/css/html.css after |
41 // Blink starts to support ::marker crbug.com/457718 | 41 // Blink starts to support ::marker crbug.com/457718 |
42 // Recommended UA margin for list markers. | 42 // Recommended UA margin for list markers. |
43 const int cUAMarkerMarginEm = 1; | 43 const int cUAMarkerMarginEm = 1; |
44 | 44 |
45 LayoutListMarker::LayoutListMarker(LayoutListItem* item) | 45 LayoutListMarker::LayoutListMarker(LayoutListItem* item) |
46 : LayoutBox(nullptr), m_listItem(item) { | 46 : LayoutBox(nullptr), m_listItem(item), m_lineOffset() { |
47 setInline(true); | 47 setInline(true); |
48 setIsAtomicInlineLevel(true); | 48 setIsAtomicInlineLevel(true); |
49 } | 49 } |
50 | 50 |
51 LayoutListMarker::~LayoutListMarker() {} | 51 LayoutListMarker::~LayoutListMarker() {} |
52 | 52 |
53 void LayoutListMarker::willBeDestroyed() { | 53 void LayoutListMarker::willBeDestroyed() { |
54 if (m_image) | 54 if (m_image) |
55 m_image->removeClient(this); | 55 m_image->removeClient(this); |
56 LayoutBox::willBeDestroyed(); | 56 LayoutBox::willBeDestroyed(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 | 132 |
133 void LayoutListMarker::paint(const PaintInfo& paintInfo, | 133 void LayoutListMarker::paint(const PaintInfo& paintInfo, |
134 const LayoutPoint& paintOffset) const { | 134 const LayoutPoint& paintOffset) const { |
135 ListMarkerPainter(*this).paint(paintInfo, paintOffset); | 135 ListMarkerPainter(*this).paint(paintInfo, paintOffset); |
136 } | 136 } |
137 | 137 |
138 void LayoutListMarker::layout() { | 138 void LayoutListMarker::layout() { |
139 ASSERT(needsLayout()); | 139 ASSERT(needsLayout()); |
140 LayoutAnalyzer::Scope analyzer(*this); | 140 LayoutAnalyzer::Scope analyzer(*this); |
141 | 141 |
142 LayoutUnit blockOffset; | |
143 for (LayoutBox* o = parentBox(); o != listItem(); o = o->parentBox()) { | |
eae
2016/12/07 21:30:45
Is parentBox guaranteed to be non-null? If not we
| |
144 blockOffset += o->logicalTop(); | |
145 } | |
146 if (listItem()->style()->isLeftToRightDirection()) { | |
147 m_lineOffset = listItem()->logicalLeftOffsetForLine( | |
148 blockOffset, DoNotIndentText, LayoutUnit()); | |
149 } else { | |
150 m_lineOffset = listItem()->logicalRightOffsetForLine( | |
151 blockOffset, DoNotIndentText, LayoutUnit()); | |
152 } | |
142 if (isImage()) { | 153 if (isImage()) { |
143 updateMarginsAndContent(); | 154 updateMarginsAndContent(); |
144 LayoutSize imageSize(imageBulletSize()); | 155 LayoutSize imageSize(imageBulletSize()); |
145 setWidth(imageSize.width()); | 156 setWidth(imageSize.width()); |
146 setHeight(imageSize.height()); | 157 setHeight(imageSize.height()); |
147 } else { | 158 } else { |
148 const SimpleFontData* fontData = style()->font().primaryFont(); | 159 const SimpleFontData* fontData = style()->font().primaryFont(); |
149 DCHECK(fontData); | 160 DCHECK(fontData); |
150 setLogicalWidth(minPreferredLogicalWidth()); | 161 setLogicalWidth(minPreferredLogicalWidth()); |
151 setLogicalHeight( | 162 setLogicalHeight( |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
486 if (style()) { | 497 if (style()) { |
487 // Reuse the current margins. Otherwise resetting the margins to initial | 498 // Reuse the current margins. Otherwise resetting the margins to initial |
488 // values would trigger unnecessary layout. | 499 // values would trigger unnecessary layout. |
489 newStyle->setMarginStart(style()->marginStart()); | 500 newStyle->setMarginStart(style()->marginStart()); |
490 newStyle->setMarginEnd(style()->marginRight()); | 501 newStyle->setMarginEnd(style()->marginRight()); |
491 } | 502 } |
492 setStyle(newStyle.release()); | 503 setStyle(newStyle.release()); |
493 } | 504 } |
494 | 505 |
495 } // namespace blink | 506 } // namespace blink |
OLD | NEW |