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, 2010 Apple Inc. All rights reserved. | 4 * Copyright (C) 2003, 2004, 2005, 2006, 2010 Apple Inc. All rights reserved. |
5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) | 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
11 * | 11 * |
12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
16 * | 16 * |
17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
21 * | 21 * |
22 */ | 22 */ |
23 | 23 |
24 #include "config.h" | 24 #include "config.h" |
25 #include "core/layout/LayoutListItem.h" | 25 #include "core/layout/LayoutListItem.h" |
26 | 26 |
27 #include "core/HTMLNames.h" | 27 #include "core/HTMLNames.h" |
| 28 #include "core/dom/MarkerPseudoElement.h" |
28 #include "core/dom/shadow/ComposedTreeTraversal.h" | 29 #include "core/dom/shadow/ComposedTreeTraversal.h" |
29 #include "core/html/HTMLOListElement.h" | 30 #include "core/html/HTMLOListElement.h" |
30 #include "core/layout/LayoutListMarker.h" | 31 #include "core/layout/LayoutListMarker.h" |
31 #include "core/layout/LayoutView.h" | 32 #include "core/layout/LayoutView.h" |
32 #include "core/layout/TextAutosizer.h" | 33 #include "core/layout/TextAutosizer.h" |
33 #include "wtf/StdLibExtras.h" | 34 #include "wtf/StdLibExtras.h" |
| 35 #include "wtf/TemporaryChange.h" |
34 #include "wtf/text/StringBuilder.h" | 36 #include "wtf/text/StringBuilder.h" |
35 | 37 |
36 namespace blink { | 38 namespace blink { |
37 | 39 |
38 using namespace HTMLNames; | 40 using namespace HTMLNames; |
39 | 41 |
40 LayoutListItem::LayoutListItem(Element* element) | 42 LayoutListItem::LayoutListItem(Element* element) |
41 : LayoutBlockFlow(element) | 43 : LayoutBlockFlow(element) |
42 , m_marker(nullptr) | 44 , m_marker(nullptr) |
43 , m_hasExplicitValue(false) | 45 , m_hasExplicitValue(false) |
44 , m_isValueUpToDate(false) | 46 , m_isValueUpToDate(false) |
45 , m_notInList(false) | 47 , m_notInList(false) |
46 { | 48 { |
47 setInline(false); | 49 setInline(false); |
| 50 setConsumesSubtreeChangeNotification(); |
48 } | 51 } |
49 | 52 |
50 void LayoutListItem::styleDidChange(StyleDifference diff, const ComputedStyle* o
ldStyle) | 53 void LayoutListItem::styleDidChange(StyleDifference diff, const ComputedStyle* o
ldStyle) |
51 { | 54 { |
52 LayoutBlockFlow::styleDidChange(diff, oldStyle); | 55 LayoutBlockFlow::styleDidChange(diff, oldStyle); |
53 | 56 |
| 57 if (RuntimeEnabledFeatures::listMarkerPseudoElementEnabled()) |
| 58 return; |
| 59 |
54 if (style()->listStyleType() != NoneListStyle | 60 if (style()->listStyleType() != NoneListStyle |
55 || (style()->listStyleImage() && !style()->listStyleImage()->errorOccurr
ed())) { | 61 || (style()->listStyleImage() && !style()->listStyleImage()->errorOccurr
ed())) { |
56 if (!m_marker) | 62 if (!m_marker) |
57 m_marker = LayoutListMarker::createAnonymous(this); | 63 m_marker = LayoutListMarker::createAnonymous(this); |
58 m_marker->listItemStyleDidChange(); | 64 m_marker->listItemStyleDidChange(); |
59 } else if (m_marker) { | 65 } else if (m_marker) { |
60 m_marker->destroy(); | 66 m_marker->destroy(); |
61 m_marker = nullptr; | 67 m_marker = nullptr; |
62 } | 68 } |
63 } | 69 } |
64 | 70 |
65 void LayoutListItem::willBeDestroyed() | 71 void LayoutListItem::willBeDestroyed() |
66 { | 72 { |
67 if (m_marker) { | 73 if (m_marker) { |
68 m_marker->destroy(); | 74 if (!RuntimeEnabledFeatures::listMarkerPseudoElementEnabled()) |
| 75 m_marker->destroy(); |
69 m_marker = nullptr; | 76 m_marker = nullptr; |
70 } | 77 } |
71 LayoutBlockFlow::willBeDestroyed(); | 78 LayoutBlockFlow::willBeDestroyed(); |
72 } | 79 } |
73 | 80 |
74 void LayoutListItem::insertedIntoTree() | 81 void LayoutListItem::insertedIntoTree() |
75 { | 82 { |
76 LayoutBlockFlow::insertedIntoTree(); | 83 LayoutBlockFlow::insertedIntoTree(); |
77 | |
78 updateListMarkerNumbers(); | 84 updateListMarkerNumbers(); |
79 } | 85 } |
80 | 86 |
81 void LayoutListItem::willBeRemovedFromTree() | 87 void LayoutListItem::willBeRemovedFromTree() |
82 { | 88 { |
83 LayoutBlockFlow::willBeRemovedFromTree(); | 89 LayoutBlockFlow::willBeRemovedFromTree(); |
| 90 updateListMarkerNumbers(); |
| 91 } |
84 | 92 |
85 updateListMarkerNumbers(); | 93 // FIXME: This causes subtree modifications, which will set the flags and we'll |
| 94 // end up doing the check a second time next frame .... |
| 95 void LayoutListItem::subtreeDidChange() |
| 96 { |
| 97 if (documentBeingDestroyed()) |
| 98 return; |
| 99 |
| 100 if (PseudoElement* element = toElement(node())->pseudoElement(MARKER)) |
| 101 toMarkerPseudoElement(element)->attachListMarker(); |
86 } | 102 } |
87 | 103 |
88 static bool isList(const Node& node) | 104 static bool isList(const Node& node) |
89 { | 105 { |
90 return isHTMLUListElement(node) || isHTMLOListElement(node); | 106 return isHTMLUListElement(node) || isHTMLOListElement(node); |
91 } | 107 } |
92 | 108 |
93 // Returns the enclosing list with respect to the DOM order. | 109 // Returns the enclosing list with respect to the DOM order. |
94 static Node* enclosingList(const LayoutListItem* listItem) | 110 static Node* enclosingList(const LayoutListItem* listItem) |
95 { | 111 { |
(...skipping 26 matching lines...) Expand all Loading... |
122 ASSERT(!current->document().childNeedsDistributionRecalc()); | 138 ASSERT(!current->document().childNeedsDistributionRecalc()); |
123 current = LayoutTreeBuilderTraversal::next(*current, listNode); | 139 current = LayoutTreeBuilderTraversal::next(*current, listNode); |
124 | 140 |
125 while (current) { | 141 while (current) { |
126 if (isList(*current)) { | 142 if (isList(*current)) { |
127 // We've found a nested, independent list: nothing to do here. | 143 // We've found a nested, independent list: nothing to do here. |
128 current = LayoutTreeBuilderTraversal::nextSkippingChildren(*current,
listNode); | 144 current = LayoutTreeBuilderTraversal::nextSkippingChildren(*current,
listNode); |
129 continue; | 145 continue; |
130 } | 146 } |
131 | 147 |
132 LayoutObject* renderer = current->layoutObject(); | 148 LayoutObject* layoutObject = current->layoutObject(); |
133 if (renderer && renderer->isListItem()) | 149 if (layoutObject && layoutObject->isListItem()) |
134 return toLayoutListItem(renderer); | 150 return toLayoutListItem(layoutObject); |
135 | 151 |
136 // FIXME: Can this be optimized to skip the children of the elements wit
hout a renderer? | 152 // FIXME: Can this be optimized to skip the children of the elements wit
hout a layoutObject? |
137 current = LayoutTreeBuilderTraversal::next(*current, listNode); | 153 current = LayoutTreeBuilderTraversal::next(*current, listNode); |
138 } | 154 } |
139 | 155 |
140 return 0; | 156 return 0; |
141 } | 157 } |
142 | 158 |
143 // Returns the previous list item with respect to the DOM order. | 159 // Returns the previous list item with respect to the DOM order. |
144 static LayoutListItem* previousListItem(const Node* listNode, const LayoutListIt
em* item) | 160 static LayoutListItem* previousListItem(const Node* listNode, const LayoutListIt
em* item) |
145 { | 161 { |
146 Node* current = item->node(); | 162 Node* current = item->node(); |
147 ASSERT(current); | 163 ASSERT(current); |
148 ASSERT(!current->document().childNeedsDistributionRecalc()); | 164 ASSERT(!current->document().childNeedsDistributionRecalc()); |
149 for (current = LayoutTreeBuilderTraversal::previous(*current, listNode); cur
rent && current != listNode; current = LayoutTreeBuilderTraversal::previous(*cur
rent, listNode)) { | 165 for (current = LayoutTreeBuilderTraversal::previous(*current, listNode); |
150 LayoutObject* renderer = current->layoutObject(); | 166 current && current != listNode; |
151 if (!renderer || (renderer && !renderer->isListItem())) | 167 current = LayoutTreeBuilderTraversal::previous(*current, listNode)) { |
| 168 |
| 169 LayoutObject* layoutObject = current->layoutObject(); |
| 170 if (!layoutObject || (layoutObject && !layoutObject->isListItem())) |
152 continue; | 171 continue; |
153 Node* otherList = enclosingList(toLayoutListItem(renderer)); | 172 Node* otherList = enclosingList(toLayoutListItem(layoutObject)); |
154 // This item is part of our current list, so it's what we're looking for
. | 173 // This item is part of our current list, so it's what we're looking for
. |
155 if (listNode == otherList) | 174 if (listNode == otherList) |
156 return toLayoutListItem(renderer); | 175 return toLayoutListItem(layoutObject); |
157 // We found ourself inside another list; lets skip the rest of it. | 176 // We found ourself inside another list; lets skip the rest of it. |
158 // Use nextIncludingPseudo() here because the other list itself may actu
ally | 177 // Use nextIncludingPseudo() here because the other list itself may actu
ally |
159 // be a list item itself. We need to examine it, so we do this to counte
ract | 178 // be a list item itself. We need to examine it, so we do this to counte
ract |
160 // the previousIncludingPseudo() that will be done by the loop. | 179 // the previousIncludingPseudo() that will be done by the loop. |
161 if (otherList) | 180 if (otherList) |
162 current = LayoutTreeBuilderTraversal::next(*otherList, listNode); | 181 current = LayoutTreeBuilderTraversal::next(*otherList, listNode); |
163 } | 182 } |
164 return 0; | 183 return 0; |
165 } | 184 } |
166 | 185 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 { | 228 { |
210 m_value = calcValue(); | 229 m_value = calcValue(); |
211 m_isValueUpToDate = true; | 230 m_isValueUpToDate = true; |
212 } | 231 } |
213 | 232 |
214 bool LayoutListItem::isEmpty() const | 233 bool LayoutListItem::isEmpty() const |
215 { | 234 { |
216 return lastChild() == m_marker; | 235 return lastChild() == m_marker; |
217 } | 236 } |
218 | 237 |
219 static LayoutObject* getParentOfFirstLineBox(LayoutBlockFlow* curr, LayoutObject
* marker) | |
220 { | |
221 LayoutObject* firstChild = curr->firstChild(); | |
222 if (!firstChild) | |
223 return 0; | |
224 | |
225 bool inQuirksMode = curr->document().inQuirksMode(); | |
226 for (LayoutObject* currChild = firstChild; currChild; currChild = currChild-
>nextSibling()) { | |
227 if (currChild == marker) | |
228 continue; | |
229 | |
230 if (currChild->isInline() && (!currChild->isLayoutInline() || curr->gene
ratesLineBoxesForInlineChild(currChild))) | |
231 return curr; | |
232 | |
233 if (currChild->isFloating() || currChild->isOutOfFlowPositioned()) | |
234 continue; | |
235 | |
236 if (!currChild->isLayoutBlockFlow() || (currChild->isBox() && toLayoutBo
x(currChild)->isWritingModeRoot())) | |
237 break; | |
238 | |
239 if (curr->isListItem() && inQuirksMode && currChild->node() | |
240 && (isHTMLUListElement(*currChild->node()) || isHTMLOListElement(*cu
rrChild->node()))) | |
241 break; | |
242 | |
243 LayoutObject* lineBox = getParentOfFirstLineBox(toLayoutBlockFlow(currCh
ild), marker); | |
244 if (lineBox) | |
245 return lineBox; | |
246 } | |
247 | |
248 return 0; | |
249 } | |
250 | |
251 void LayoutListItem::updateValue() | 238 void LayoutListItem::updateValue() |
252 { | 239 { |
253 if (!m_hasExplicitValue) { | 240 if (m_hasExplicitValue) |
254 m_isValueUpToDate = false; | 241 return; |
255 if (m_marker) | |
256 m_marker->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(
LayoutInvalidationReason::ListValueChange); | |
257 } | |
258 } | |
259 | 242 |
260 static LayoutObject* firstNonMarkerChild(LayoutObject* parent) | 243 m_isValueUpToDate = false; |
261 { | 244 |
262 LayoutObject* result = parent->slowFirstChild(); | 245 if (m_marker) |
263 while (result && result->isListMarker()) | 246 m_marker->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(Layo
utInvalidationReason::ListValueChange); |
264 result = result->nextSibling(); | |
265 return result; | |
266 } | 247 } |
267 | 248 |
268 void LayoutListItem::updateMarkerLocationAndInvalidateWidth() | 249 void LayoutListItem::updateMarkerLocationAndInvalidateWidth() |
269 { | 250 { |
| 251 ASSERT(!RuntimeEnabledFeatures::listMarkerPseudoElementEnabled()); |
270 ASSERT(m_marker); | 252 ASSERT(m_marker); |
271 | 253 |
272 // FIXME: We should not modify the structure of the render tree | 254 // FIXME: We should not modify the structure of the render tree |
273 // during layout. crbug.com/370461 | 255 // during layout. crbug.com/370461 |
274 DeprecatedDisableModifyLayoutTreeStructureAsserts disabler; | 256 DeprecatedDisableModifyLayoutTreeStructureAsserts disabler; |
275 LayoutState* layoutState = view()->layoutState(); | 257 LayoutState* layoutState = view()->layoutState(); |
276 LayoutFlowThread* currentFlowThread = nullptr; | 258 LayoutFlowThread* currentFlowThread = nullptr; |
277 if (layoutState) { | 259 if (layoutState) { |
278 // We're about to modify the layout tree structure (during layout!), and
any code using | 260 // We're about to modify the layout tree structure (during layout!), and
any code using |
279 // LayoutState might get utterly confused by that. There's no evidence t
hat anything other | 261 // LayoutState might get utterly confused by that. There's no evidence t
hat anything other |
280 // than the flow thread code will suffer, though, so just reset the curr
ent flow thread | 262 // than the flow thread code will suffer, though, so just reset the curr
ent flow thread |
281 // temporarily. | 263 // temporarily. |
282 // FIXME: get rid of this hack, including the flow thread setter in Layo
utState, as part of | 264 // FIXME: get rid of this hack, including the flow thread setter in Layo
utState, as part of |
283 // fixing crbug.com/370461 | 265 // fixing crbug.com/370461 |
284 currentFlowThread = layoutState->flowThread(); | 266 currentFlowThread = layoutState->flowThread(); |
285 layoutState->setFlowThread(nullptr); | 267 layoutState->setFlowThread(nullptr); |
286 } | 268 } |
287 if (updateMarkerLocation()) { | 269 if (updateMarkerLocation()) { |
288 // If the marker is inside we need to redo the preferred width calculati
ons | 270 // If the marker is inside we need to redo the preferred width calculati
ons |
289 // as the size of the item now includes the size of the list marker. | 271 // as the size of the item now includes the size of the list marker. |
290 if (m_marker->isInside()) | 272 if (m_marker->isInside()) |
291 containingBlock()->updateLogicalWidth(); | 273 containingBlock()->updateLogicalWidth(); |
292 } | 274 } |
293 if (layoutState) | 275 if (layoutState) |
294 layoutState->setFlowThread(currentFlowThread); | 276 layoutState->setFlowThread(currentFlowThread); |
295 } | 277 } |
296 | 278 |
297 bool LayoutListItem::updateMarkerLocation() | 279 bool LayoutListItem::updateMarkerLocation() |
298 { | 280 { |
| 281 ASSERT(!RuntimeEnabledFeatures::listMarkerPseudoElementEnabled()); |
299 ASSERT(m_marker); | 282 ASSERT(m_marker); |
| 283 |
300 LayoutObject* markerParent = m_marker->parent(); | 284 LayoutObject* markerParent = m_marker->parent(); |
301 LayoutObject* lineBoxParent = getParentOfFirstLineBox(this, m_marker); | 285 LayoutObject* lineBoxParent = MarkerPseudoElement::parentOfFirstLineBox(this
, m_marker); |
302 if (!lineBoxParent) { | 286 if (!lineBoxParent) { |
303 // If the marker is currently contained inside an anonymous box, then we | 287 // If the marker is currently contained inside an anonymous box, then we |
304 // are the only item in that anonymous box (since no line box parent was | 288 // are the only item in that anonymous box (since no line box parent was |
305 // found). It's ok to just leave the marker where it is in this case. | 289 // found). It's ok to just leave the marker where it is in this case. |
306 if (markerParent && markerParent->isAnonymousBlock()) | 290 if (markerParent && markerParent->isAnonymousBlock()) |
307 lineBoxParent = markerParent; | 291 lineBoxParent = markerParent; |
308 else | 292 else |
309 lineBoxParent = this; | 293 lineBoxParent = this; |
310 } | 294 } |
311 | 295 |
312 if (markerParent != lineBoxParent) { | 296 if (markerParent != lineBoxParent) { |
313 m_marker->remove(); | 297 m_marker->remove(); |
314 lineBoxParent->addChild(m_marker, firstNonMarkerChild(lineBoxParent)); | 298 lineBoxParent->addChild(m_marker, MarkerPseudoElement::firstNonMarkerChi
ld(lineBoxParent)); |
315 m_marker->updateMarginsAndContent(); | 299 m_marker->updateMarginsAndContent(); |
316 // If markerParent is an anonymous block with no children, destroy it. | 300 // If markerParent is an anonymous block with no children, destroy it. |
317 if (markerParent && markerParent->isAnonymousBlock() && !toLayoutBlock(m
arkerParent)->firstChild() && !toLayoutBlock(markerParent)->continuation()) | 301 if (markerParent && markerParent->isAnonymousBlock() && !toLayoutBlock(m
arkerParent)->firstChild() |
| 302 && !toLayoutBlock(markerParent)->continuation()) |
318 markerParent->destroy(); | 303 markerParent->destroy(); |
319 return true; | 304 return true; |
320 } | 305 } |
321 | 306 |
322 return false; | 307 return false; |
323 } | 308 } |
324 | 309 |
325 void LayoutListItem::layout() | 310 void LayoutListItem::layout() |
326 { | 311 { |
327 ASSERT(needsLayout()); | 312 ASSERT(needsLayout()); |
328 | 313 |
329 if (m_marker) { | 314 if (RuntimeEnabledFeatures::listMarkerPseudoElementEnabled()) { |
| 315 if (m_marker) |
| 316 m_marker->updateMarginsAndContent(); |
| 317 |
| 318 } else if (m_marker) { |
330 // The marker must be autosized before calling | 319 // The marker must be autosized before calling |
331 // updateMarkerLocationAndInvalidateWidth. It cannot be done in the | 320 // updateMarkerLocationAndInvalidateWidth. It cannot be done in the |
332 // parent's beginLayout because it is not yet in the render tree. | 321 // parent's beginLayout because it is not yet in the render tree. |
333 if (TextAutosizer* textAutosizer = document().textAutosizer()) | 322 if (TextAutosizer* textAutosizer = document().textAutosizer()) |
334 textAutosizer->inflateListItem(this, m_marker); | 323 textAutosizer->inflateListItem(this, m_marker); |
335 | 324 |
336 updateMarkerLocationAndInvalidateWidth(); | 325 updateMarkerLocationAndInvalidateWidth(); |
337 } | 326 } |
338 | 327 |
339 LayoutBlockFlow::layout(); | 328 LayoutBlockFlow::layout(); |
340 } | 329 } |
341 | 330 |
342 void LayoutListItem::addOverflowFromChildren() | 331 void LayoutListItem::addOverflowFromChildren() |
343 { | 332 { |
344 LayoutBlockFlow::addOverflowFromChildren(); | 333 LayoutBlockFlow::addOverflowFromChildren(); |
345 positionListMarker(); | 334 positionListMarker(m_marker); |
346 } | 335 } |
347 | 336 |
348 void LayoutListItem::positionListMarker() | 337 void LayoutListItem::positionListMarker(LayoutListMarker* marker) |
349 { | 338 { |
350 if (m_marker && m_marker->parent()->isBox() && !m_marker->isInside() && m_ma
rker->inlineBoxWrapper()) { | 339 if (!marker) |
351 LayoutUnit markerOldLogicalLeft = m_marker->logicalLeft(); | 340 return; |
| 341 |
| 342 ASSERT(marker->parent()); |
| 343 if (marker->parent()->isBox() && !marker->isInside() && marker->inlineBoxWra
pper()) { |
| 344 LayoutUnit markerOldLogicalLeft = marker->logicalLeft(); |
352 LayoutUnit blockOffset = 0; | 345 LayoutUnit blockOffset = 0; |
353 LayoutUnit lineOffset = 0; | 346 LayoutUnit lineOffset = 0; |
354 for (LayoutBox* o = m_marker->parentBox(); o != this; o = o->parentBox()
) { | 347 for (LayoutBox* o = marker->parentBox(); o != this; o = o->parentBox())
{ |
355 blockOffset += o->logicalTop(); | 348 blockOffset += o->logicalTop(); |
356 lineOffset += o->logicalLeft(); | 349 lineOffset += o->logicalLeft(); |
357 } | 350 } |
358 | 351 |
359 bool adjustOverflow = false; | 352 bool adjustOverflow = false; |
360 LayoutUnit markerLogicalLeft; | 353 LayoutUnit markerLogicalLeft; |
361 RootInlineBox& root = m_marker->inlineBoxWrapper()->root(); | 354 RootInlineBox& root = marker->inlineBoxWrapper()->root(); |
362 bool hitSelfPaintingLayer = false; | 355 bool hitSelfPaintingLayer = false; |
363 | 356 |
364 LayoutUnit lineTop = root.lineTop(); | 357 LayoutUnit lineTop = root.lineTop(); |
365 LayoutUnit lineBottom = root.lineBottom(); | 358 LayoutUnit lineBottom = root.lineBottom(); |
366 | 359 |
367 // FIXME: Need to account for relative positioning in the layout overflo
w. | 360 // FIXME: Need to account for relative positioning in the layout overflo
w. |
368 if (style()->isLeftToRightDirection()) { | 361 if (style()->isLeftToRightDirection()) { |
369 LayoutUnit leftLineOffset = logicalLeftOffsetForLine(blockOffset, lo
gicalLeftOffsetForLine(blockOffset, false), false); | 362 LayoutUnit leftLineOffset = logicalLeftOffsetForLine(blockOffset, lo
gicalLeftOffsetForLine(blockOffset, false), false); |
370 markerLogicalLeft = leftLineOffset - lineOffset - paddingStart() - b
orderStart() + m_marker->marginStart(); | 363 markerLogicalLeft = leftLineOffset - lineOffset - paddingStart() - b
orderStart() + marker->marginStart(); |
371 m_marker->inlineBoxWrapper()->adjustLineDirectionPosition((markerLog
icalLeft - markerOldLogicalLeft).toFloat()); | 364 marker->inlineBoxWrapper()->adjustLineDirectionPosition((markerLogic
alLeft - markerOldLogicalLeft).toFloat()); |
372 for (InlineFlowBox* box = m_marker->inlineBoxWrapper()->parent(); bo
x; box = box->parent()) { | 365 for (InlineFlowBox* box = marker->inlineBoxWrapper()->parent(); box;
box = box->parent()) { |
373 LayoutRect newLogicalVisualOverflowRect = box->logicalVisualOver
flowRect(lineTop, lineBottom); | 366 LayoutRect newLogicalVisualOverflowRect = box->logicalVisualOver
flowRect(lineTop, lineBottom); |
374 LayoutRect newLogicalLayoutOverflowRect = box->logicalLayoutOver
flowRect(lineTop, lineBottom); | 367 LayoutRect newLogicalLayoutOverflowRect = box->logicalLayoutOver
flowRect(lineTop, lineBottom); |
375 if (markerLogicalLeft < newLogicalVisualOverflowRect.x() && !hit
SelfPaintingLayer) { | 368 if (markerLogicalLeft < newLogicalVisualOverflowRect.x() && !hit
SelfPaintingLayer) { |
376 newLogicalVisualOverflowRect.setWidth(newLogicalVisualOverfl
owRect.maxX() - markerLogicalLeft); | 369 newLogicalVisualOverflowRect.setWidth(newLogicalVisualOverfl
owRect.maxX() - markerLogicalLeft); |
377 newLogicalVisualOverflowRect.setX(markerLogicalLeft); | 370 newLogicalVisualOverflowRect.setX(markerLogicalLeft); |
378 if (box == root) | 371 if (box == root) |
379 adjustOverflow = true; | 372 adjustOverflow = true; |
380 } | 373 } |
381 if (markerLogicalLeft < newLogicalLayoutOverflowRect.x()) { | 374 if (markerLogicalLeft < newLogicalLayoutOverflowRect.x()) { |
382 newLogicalLayoutOverflowRect.setWidth(newLogicalLayoutOverfl
owRect.maxX() - markerLogicalLeft); | 375 newLogicalLayoutOverflowRect.setWidth(newLogicalLayoutOverfl
owRect.maxX() - markerLogicalLeft); |
383 newLogicalLayoutOverflowRect.setX(markerLogicalLeft); | 376 newLogicalLayoutOverflowRect.setX(markerLogicalLeft); |
384 if (box == root) | 377 if (box == root) |
385 adjustOverflow = true; | 378 adjustOverflow = true; |
386 } | 379 } |
387 box->setOverflowFromLogicalRects(newLogicalLayoutOverflowRect, n
ewLogicalVisualOverflowRect, lineTop, lineBottom); | 380 box->setOverflowFromLogicalRects(newLogicalLayoutOverflowRect, n
ewLogicalVisualOverflowRect, lineTop, lineBottom); |
388 if (box->boxModelObject()->hasSelfPaintingLayer()) | 381 if (box->boxModelObject()->hasSelfPaintingLayer()) |
389 hitSelfPaintingLayer = true; | 382 hitSelfPaintingLayer = true; |
390 } | 383 } |
391 } else { | 384 } else { |
392 LayoutUnit rightLineOffset = logicalRightOffsetForLine(blockOffset,
logicalRightOffsetForLine(blockOffset, false), false); | 385 LayoutUnit rightLineOffset = logicalRightOffsetForLine(blockOffset,
logicalRightOffsetForLine(blockOffset, false), false); |
393 markerLogicalLeft = rightLineOffset - lineOffset + paddingStart() +
borderStart() + m_marker->marginEnd(); | 386 markerLogicalLeft = rightLineOffset - lineOffset + paddingStart() +
borderStart() + marker->marginEnd(); |
394 m_marker->inlineBoxWrapper()->adjustLineDirectionPosition((markerLog
icalLeft - markerOldLogicalLeft).toFloat()); | 387 marker->inlineBoxWrapper()->adjustLineDirectionPosition((markerLogic
alLeft - markerOldLogicalLeft).toFloat()); |
395 for (InlineFlowBox* box = m_marker->inlineBoxWrapper()->parent(); bo
x; box = box->parent()) { | 388 for (InlineFlowBox* box = marker->inlineBoxWrapper()->parent(); box;
box = box->parent()) { |
396 LayoutRect newLogicalVisualOverflowRect = box->logicalVisualOver
flowRect(lineTop, lineBottom); | 389 LayoutRect newLogicalVisualOverflowRect = box->logicalVisualOver
flowRect(lineTop, lineBottom); |
397 LayoutRect newLogicalLayoutOverflowRect = box->logicalLayoutOver
flowRect(lineTop, lineBottom); | 390 LayoutRect newLogicalLayoutOverflowRect = box->logicalLayoutOver
flowRect(lineTop, lineBottom); |
398 if (markerLogicalLeft + m_marker->logicalWidth() > newLogicalVis
ualOverflowRect.maxX() && !hitSelfPaintingLayer) { | 391 if (markerLogicalLeft + marker->logicalWidth() > newLogicalVisua
lOverflowRect.maxX() && !hitSelfPaintingLayer) { |
399 newLogicalVisualOverflowRect.setWidth(markerLogicalLeft + m_
marker->logicalWidth() - newLogicalVisualOverflowRect.x()); | 392 newLogicalVisualOverflowRect.setWidth(markerLogicalLeft + ma
rker->logicalWidth() - newLogicalVisualOverflowRect.x()); |
400 if (box == root) | 393 if (box == root) |
401 adjustOverflow = true; | 394 adjustOverflow = true; |
402 } | 395 } |
403 if (markerLogicalLeft + m_marker->logicalWidth() > newLogicalLay
outOverflowRect.maxX()) { | 396 if (markerLogicalLeft + marker->logicalWidth() > newLogicalLayou
tOverflowRect.maxX()) { |
404 newLogicalLayoutOverflowRect.setWidth(markerLogicalLeft + m_
marker->logicalWidth() - newLogicalLayoutOverflowRect.x()); | 397 newLogicalLayoutOverflowRect.setWidth(markerLogicalLeft + ma
rker->logicalWidth() - newLogicalLayoutOverflowRect.x()); |
405 if (box == root) | 398 if (box == root) |
406 adjustOverflow = true; | 399 adjustOverflow = true; |
407 } | 400 } |
408 box->setOverflowFromLogicalRects(newLogicalLayoutOverflowRect, n
ewLogicalVisualOverflowRect, lineTop, lineBottom); | 401 box->setOverflowFromLogicalRects(newLogicalLayoutOverflowRect, n
ewLogicalVisualOverflowRect, lineTop, lineBottom); |
409 | 402 |
410 if (box->boxModelObject()->hasSelfPaintingLayer()) | 403 if (box->boxModelObject()->hasSelfPaintingLayer()) |
411 hitSelfPaintingLayer = true; | 404 hitSelfPaintingLayer = true; |
412 } | 405 } |
413 } | 406 } |
414 | 407 |
415 if (adjustOverflow) { | 408 if (adjustOverflow) { |
416 LayoutRect markerRect(LayoutPoint(markerLogicalLeft + lineOffset, bl
ockOffset), m_marker->size()); | 409 LayoutRect markerRect(LayoutPoint(markerLogicalLeft + lineOffset, bl
ockOffset), marker->size()); |
417 if (!style()->isHorizontalWritingMode()) | 410 if (!style()->isHorizontalWritingMode()) |
418 markerRect = markerRect.transposedRect(); | 411 markerRect = markerRect.transposedRect(); |
419 LayoutBox* o = m_marker; | 412 LayoutBox* o = marker; |
420 bool propagateVisualOverflow = true; | 413 bool propagateVisualOverflow = true; |
421 bool propagateLayoutOverflow = true; | 414 bool propagateLayoutOverflow = true; |
422 do { | 415 do { |
423 o = o->parentBox(); | 416 o = o->parentBox(); |
424 if (o->isLayoutBlock()) { | 417 if (o->isLayoutBlock()) { |
425 if (propagateVisualOverflow) | 418 if (propagateVisualOverflow) |
426 toLayoutBlock(o)->addContentsVisualOverflow(markerRect); | 419 toLayoutBlock(o)->addContentsVisualOverflow(markerRect); |
427 if (propagateLayoutOverflow) | 420 if (propagateLayoutOverflow) |
428 toLayoutBlock(o)->addLayoutOverflow(markerRect); | 421 toLayoutBlock(o)->addLayoutOverflow(markerRect); |
429 } | 422 } |
(...skipping 21 matching lines...) Expand all Loading... |
451 { | 444 { |
452 if (m_marker) | 445 if (m_marker) |
453 return m_marker->text(); | 446 return m_marker->text(); |
454 return nullAtom.string(); | 447 return nullAtom.string(); |
455 } | 448 } |
456 | 449 |
457 void LayoutListItem::explicitValueChanged() | 450 void LayoutListItem::explicitValueChanged() |
458 { | 451 { |
459 if (m_marker) | 452 if (m_marker) |
460 m_marker->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(Layo
utInvalidationReason::ListValueChange); | 453 m_marker->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(Layo
utInvalidationReason::ListValueChange); |
| 454 |
461 Node* listNode = enclosingList(this); | 455 Node* listNode = enclosingList(this); |
462 for (LayoutListItem* item = this; item; item = nextListItem(listNode, item)) | 456 for (LayoutListItem* item = this; item; item = nextListItem(listNode, item)) |
463 item->updateValue(); | 457 item->updateValue(); |
464 } | 458 } |
465 | 459 |
466 void LayoutListItem::setExplicitValue(int value) | 460 void LayoutListItem::setExplicitValue(int value) |
467 { | 461 { |
468 ASSERT(node()); | 462 ASSERT(node()); |
469 | 463 |
470 if (m_hasExplicitValue && m_explicitValue == value) | 464 if (m_hasExplicitValue && m_explicitValue == value) |
(...skipping 11 matching lines...) Expand all Loading... |
482 if (!m_hasExplicitValue) | 476 if (!m_hasExplicitValue) |
483 return; | 477 return; |
484 m_hasExplicitValue = false; | 478 m_hasExplicitValue = false; |
485 m_isValueUpToDate = false; | 479 m_isValueUpToDate = false; |
486 explicitValueChanged(); | 480 explicitValueChanged(); |
487 } | 481 } |
488 | 482 |
489 void LayoutListItem::setNotInList(bool notInList) | 483 void LayoutListItem::setNotInList(bool notInList) |
490 { | 484 { |
491 m_notInList = notInList; | 485 m_notInList = notInList; |
492 if (m_marker) | 486 if (RuntimeEnabledFeatures::listMarkerPseudoElementEnabled() && m_marker) |
| 487 m_marker->updateMarginsAndContent(); |
| 488 else if (m_marker) |
493 updateMarkerLocation(); | 489 updateMarkerLocation(); |
494 } | 490 } |
495 | 491 |
496 static LayoutListItem* previousOrNextItem(bool isListReversed, Node* list, Layou
tListItem* item) | 492 static LayoutListItem* previousOrNextItem(bool isListReversed, Node* list, Layou
tListItem* item) |
497 { | 493 { |
498 return isListReversed ? previousListItem(list, item) : nextListItem(list, it
em); | 494 return isListReversed ? previousListItem(list, item) : nextListItem(list, it
em); |
499 } | 495 } |
500 | 496 |
501 void LayoutListItem::updateListMarkerNumbers() | 497 void LayoutListItem::updateListMarkerNumbers() |
502 { | 498 { |
(...skipping 25 matching lines...) Expand all Loading... |
528 // assume that all the following ones have too. | 524 // assume that all the following ones have too. |
529 // This gives us the opportunity to stop here and avoid | 525 // This gives us the opportunity to stop here and avoid |
530 // marking the same nodes again. | 526 // marking the same nodes again. |
531 break; | 527 break; |
532 } | 528 } |
533 item->updateValue(); | 529 item->updateValue(); |
534 } | 530 } |
535 } | 531 } |
536 | 532 |
537 } // namespace blink | 533 } // namespace blink |
OLD | NEW |