Chromium Code Reviews| 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/rendering/RenderListItem.h" | 25 #include "core/rendering/RenderListItem.h" |
| 26 | 26 |
| 27 #include "core/HTMLNames.h" | 27 #include "core/HTMLNames.h" |
| 28 #include "core/dom/NodeRenderingTraversal.h" | 28 #include "core/dom/NodeRenderingTraversal.h" |
| 29 #include "core/dom/MarkerPseudoElement.h" | |
| 29 #include "core/html/HTMLOListElement.h" | 30 #include "core/html/HTMLOListElement.h" |
| 30 #include "core/rendering/RenderListMarker.h" | 31 #include "core/rendering/RenderListMarker.h" |
| 31 #include "core/rendering/RenderView.h" | 32 #include "core/rendering/RenderView.h" |
| 32 #include "core/rendering/TextAutosizer.h" | 33 #include "core/rendering/TextAutosizer.h" |
| 33 #include "wtf/StdLibExtras.h" | 34 #include "wtf/StdLibExtras.h" |
| 34 #include "wtf/text/StringBuilder.h" | 35 #include "wtf/text/StringBuilder.h" |
| 35 | 36 |
| 36 namespace blink { | 37 namespace blink { |
| 37 | 38 |
| 38 using namespace HTMLNames; | 39 using namespace HTMLNames; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 50 void RenderListItem::trace(Visitor* visitor) | 51 void RenderListItem::trace(Visitor* visitor) |
| 51 { | 52 { |
| 52 visitor->trace(m_marker); | 53 visitor->trace(m_marker); |
| 53 RenderBlockFlow::trace(visitor); | 54 RenderBlockFlow::trace(visitor); |
| 54 } | 55 } |
| 55 | 56 |
| 56 void RenderListItem::styleDidChange(StyleDifference diff, const RenderStyle* old Style) | 57 void RenderListItem::styleDidChange(StyleDifference diff, const RenderStyle* old Style) |
| 57 { | 58 { |
| 58 RenderBlockFlow::styleDidChange(diff, oldStyle); | 59 RenderBlockFlow::styleDidChange(diff, oldStyle); |
| 59 | 60 |
| 60 if (style()->listStyleType() != NoneListStyle | 61 if (!RuntimeEnabledFeatures::listMarkerPseudoElementEnabled()) { |
|
Julien - ping for review
2014/12/05 19:44:04
We prefer early return.
dsinclair
2015/01/23 20:46:36
Done.
| |
| 61 || (style()->listStyleImage() && !style()->listStyleImage()->errorOccurr ed())) { | 62 if (style()->listStyleType() != NoneListStyle |
| 62 if (!m_marker) | 63 || (style()->listStyleImage() && !style()->listStyleImage()->errorOc curred())) { |
| 63 m_marker = RenderListMarker::createAnonymous(this); | 64 if (!m_marker) |
| 64 m_marker->listItemStyleDidChange(); | 65 m_marker = RenderListMarker::createAnonymous(this); |
| 65 } else if (m_marker) { | 66 m_marker->listItemStyleDidChange(); |
| 66 m_marker->destroy(); | 67 } else if (m_marker) { |
| 67 m_marker = nullptr; | 68 m_marker->destroy(); |
| 69 m_marker = nullptr; | |
| 70 } | |
| 68 } | 71 } |
| 69 } | 72 } |
| 70 | 73 |
| 71 void RenderListItem::willBeDestroyed() | 74 void RenderListItem::willBeDestroyed() |
| 72 { | 75 { |
| 73 if (m_marker) { | 76 if (m_marker) { |
| 74 m_marker->destroy(); | 77 m_marker->destroy(); |
| 75 m_marker = nullptr; | 78 m_marker = nullptr; |
| 76 } | 79 } |
| 80 | |
| 77 RenderBlockFlow::willBeDestroyed(); | 81 RenderBlockFlow::willBeDestroyed(); |
| 78 } | 82 } |
| 79 | 83 |
| 80 void RenderListItem::insertedIntoTree() | 84 void RenderListItem::insertedIntoTree() |
| 81 { | 85 { |
| 82 RenderBlockFlow::insertedIntoTree(); | 86 RenderBlockFlow::insertedIntoTree(); |
| 83 | 87 |
| 84 updateListMarkerNumbers(); | 88 updateListMarkerNumbers(); |
| 85 } | 89 } |
| 86 | 90 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 } | 216 } |
| 213 | 217 |
| 214 void RenderListItem::updateValueNow() const | 218 void RenderListItem::updateValueNow() const |
| 215 { | 219 { |
| 216 m_value = calcValue(); | 220 m_value = calcValue(); |
| 217 m_isValueUpToDate = true; | 221 m_isValueUpToDate = true; |
| 218 } | 222 } |
| 219 | 223 |
| 220 bool RenderListItem::isEmpty() const | 224 bool RenderListItem::isEmpty() const |
| 221 { | 225 { |
| 226 if (RuntimeEnabledFeatures::listMarkerPseudoElementEnabled()) | |
| 227 return isEmpty(); | |
|
Julien - ping for review
2014/12/05 19:44:04
Really nice infinite loop?
dsinclair
2015/01/23 20:46:36
Done.
| |
| 222 return lastChild() == m_marker; | 228 return lastChild() == m_marker; |
| 223 } | 229 } |
| 224 | 230 |
| 225 static RenderObject* getParentOfFirstLineBox(RenderBlockFlow* curr, RenderObject * marker) | |
| 226 { | |
| 227 RenderObject* firstChild = curr->firstChild(); | |
| 228 if (!firstChild) | |
| 229 return 0; | |
| 230 | |
| 231 bool inQuirksMode = curr->document().inQuirksMode(); | |
| 232 for (RenderObject* currChild = firstChild; currChild; currChild = currChild- >nextSibling()) { | |
| 233 if (currChild == marker) | |
| 234 continue; | |
| 235 | |
| 236 if (currChild->isInline() && (!currChild->isRenderInline() || curr->gene ratesLineBoxesForInlineChild(currChild))) | |
| 237 return curr; | |
| 238 | |
| 239 if (currChild->isFloating() || currChild->isOutOfFlowPositioned()) | |
| 240 continue; | |
| 241 | |
| 242 if (!currChild->isRenderBlockFlow() || (currChild->isBox() && toRenderBo x(currChild)->isWritingModeRoot())) | |
| 243 break; | |
| 244 | |
| 245 if (curr->isListItem() && inQuirksMode && currChild->node() && | |
| 246 (isHTMLUListElement(*currChild->node()) || isHTMLOListElement(*currC hild->node()))) | |
| 247 break; | |
| 248 | |
| 249 RenderObject* lineBox = getParentOfFirstLineBox(toRenderBlockFlow(currCh ild), marker); | |
| 250 if (lineBox) | |
| 251 return lineBox; | |
| 252 } | |
| 253 | |
| 254 return 0; | |
| 255 } | |
| 256 | |
| 257 void RenderListItem::updateValue() | 231 void RenderListItem::updateValue() |
| 258 { | 232 { |
| 259 if (!m_hasExplicitValue) { | 233 if (!m_hasExplicitValue) { |
| 260 m_isValueUpToDate = false; | 234 m_isValueUpToDate = false; |
| 261 if (m_marker) | 235 if (RuntimeEnabledFeatures::listMarkerPseudoElementEnabled()) { |
| 236 if (PseudoElement* element = toElement(node())->pseudoElement(MARKER )) | |
| 237 element->renderer()->setNeedsLayoutAndPrefWidthsRecalcAndFullPai ntInvalidation(); | |
| 238 } else if (m_marker) { | |
| 262 m_marker->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( ); | 239 m_marker->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( ); |
| 240 } | |
| 263 } | 241 } |
| 264 } | 242 } |
| 265 | 243 |
| 266 static RenderObject* firstNonMarkerChild(RenderObject* parent) | |
| 267 { | |
| 268 RenderObject* result = parent->slowFirstChild(); | |
| 269 while (result && result->isListMarker()) | |
| 270 result = result->nextSibling(); | |
| 271 return result; | |
| 272 } | |
| 273 | |
| 274 void RenderListItem::updateMarkerLocationAndInvalidateWidth() | 244 void RenderListItem::updateMarkerLocationAndInvalidateWidth() |
| 275 { | 245 { |
| 246 ASSERT(!RuntimeEnabledFeatures::listMarkerPseudoElementEnabled()); | |
| 276 ASSERT(m_marker); | 247 ASSERT(m_marker); |
| 277 | 248 |
| 278 // FIXME: We should not modify the structure of the render tree | 249 // FIXME: We should not modify the structure of the render tree |
| 279 // during layout. crbug.com/370461 | 250 // during layout. crbug.com/370461 |
| 280 DeprecatedDisableModifyRenderTreeStructureAsserts disabler; | 251 DeprecatedDisableModifyRenderTreeStructureAsserts disabler; |
| 281 if (updateMarkerLocation()) { | 252 if (updateMarkerLocation()) { |
| 282 // If the marker is inside we need to redo the preferred width calculati ons | 253 // If the marker is inside we need to redo the preferred width calculati ons |
| 283 // as the size of the item now includes the size of the list marker. | 254 // as the size of the item now includes the size of the list marker. |
| 284 if (m_marker->isInside()) | 255 if (m_marker->isInside()) |
| 285 containingBlock()->updateLogicalWidth(); | 256 containingBlock()->updateLogicalWidth(); |
| 286 } | 257 } |
| 287 } | 258 } |
| 288 | 259 |
| 289 bool RenderListItem::updateMarkerLocation() | 260 bool RenderListItem::updateMarkerLocation() |
| 290 { | 261 { |
| 262 ASSERT(!RuntimeEnabledFeatures::listMarkerPseudoElementEnabled()); | |
| 291 ASSERT(m_marker); | 263 ASSERT(m_marker); |
| 264 | |
| 292 RenderObject* markerParent = m_marker->parent(); | 265 RenderObject* markerParent = m_marker->parent(); |
| 293 RenderObject* lineBoxParent = getParentOfFirstLineBox(this, m_marker); | 266 RenderObject* lineBoxParent = MarkerPseudoElement::getParentOfFirstLineBox(t his, m_marker); |
| 294 if (!lineBoxParent) { | 267 if (!lineBoxParent) { |
| 295 // If the marker is currently contained inside an anonymous box, then we | 268 // If the marker is currently contained inside an anonymous box, then we |
| 296 // are the only item in that anonymous box (since no line box parent was | 269 // are the only item in that anonymous box (since no line box parent was |
| 297 // found). It's ok to just leave the marker where it is in this case. | 270 // found). It's ok to just leave the marker where it is in this case. |
| 298 if (markerParent && markerParent->isAnonymousBlock()) | 271 if (markerParent && markerParent->isAnonymousBlock()) |
| 299 lineBoxParent = markerParent; | 272 lineBoxParent = markerParent; |
| 300 else | 273 else |
| 301 lineBoxParent = this; | 274 lineBoxParent = this; |
| 302 } | 275 } |
| 303 | 276 |
| 304 if (markerParent != lineBoxParent) { | 277 if (markerParent != lineBoxParent) { |
| 305 m_marker->remove(); | 278 m_marker->remove(); |
| 306 lineBoxParent->addChild(m_marker, firstNonMarkerChild(lineBoxParent)); | 279 lineBoxParent->addChild(m_marker, MarkerPseudoElement::firstNonMarkerChi ld(lineBoxParent)); |
| 307 m_marker->updateMarginsAndContent(); | 280 m_marker->updateMarginsAndContent(); |
| 308 // If markerParent is an anonymous block with no children, destroy it. | 281 // If markerParent is an anonymous block with no children, destroy it. |
| 309 if (markerParent && markerParent->isAnonymousBlock() && !toRenderBlock(m arkerParent)->firstChild() && !toRenderBlock(markerParent)->continuation()) | 282 if (markerParent && markerParent->isAnonymousBlock() && !toRenderBlock(m arkerParent)->firstChild() && !toRenderBlock(markerParent)->continuation()) |
| 310 markerParent->destroy(); | 283 markerParent->destroy(); |
| 311 return true; | 284 return true; |
| 312 } | 285 } |
| 313 | 286 |
| 314 return false; | 287 return false; |
| 315 } | 288 } |
| 316 | 289 |
| 317 void RenderListItem::layout() | 290 void RenderListItem::layout() |
| 318 { | 291 { |
| 319 ASSERT(needsLayout()); | 292 ASSERT(needsLayout()); |
| 320 | 293 |
| 321 if (m_marker) { | 294 if (RuntimeEnabledFeatures::listMarkerPseudoElementEnabled()) { |
| 295 if (PseudoElement* element = toElement(node())->pseudoElement(MARKER)) { | |
| 296 ASSERT(element->renderer()->isListMarker()); | |
| 297 RenderListMarker* marker = toRenderListMarker(element->renderer()); | |
| 298 | |
| 299 // The marker must be autosized before calling | |
| 300 // updateMarkerLocationAndInvalidateWidth. It cannot be done in the | |
| 301 // parent's beginLayout because it is not yet in the render tree. | |
| 302 if (TextAutosizer* textAutosizer = document().textAutosizer()) | |
| 303 textAutosizer->inflateListItem(this, marker); | |
| 304 | |
| 305 marker->updateMarginsAndContent(); | |
| 306 if (marker->isInside()) | |
| 307 containingBlock()->updateLogicalWidth(); | |
| 308 } | |
| 309 | |
| 310 } else if (m_marker) { | |
| 322 // The marker must be autosized before calling | 311 // The marker must be autosized before calling |
| 323 // updateMarkerLocationAndInvalidateWidth. It cannot be done in the | 312 // updateMarkerLocationAndInvalidateWidth. It cannot be done in the |
| 324 // parent's beginLayout because it is not yet in the render tree. | 313 // parent's beginLayout because it is not yet in the render tree. |
| 325 if (TextAutosizer* textAutosizer = document().textAutosizer()) | 314 if (TextAutosizer* textAutosizer = document().textAutosizer()) |
| 326 textAutosizer->inflateListItem(this, m_marker); | 315 textAutosizer->inflateListItem(this, m_marker); |
| 327 | 316 |
| 328 updateMarkerLocationAndInvalidateWidth(); | 317 updateMarkerLocationAndInvalidateWidth(); |
| 329 } | 318 } |
| 330 | 319 |
| 331 RenderBlockFlow::layout(); | 320 RenderBlockFlow::layout(); |
| 332 } | 321 } |
| 333 | 322 |
| 334 void RenderListItem::addOverflowFromChildren() | 323 void RenderListItem::addOverflowFromChildren() |
| 335 { | 324 { |
| 336 RenderBlockFlow::addOverflowFromChildren(); | 325 RenderBlockFlow::addOverflowFromChildren(); |
| 337 positionListMarker(); | 326 |
| 327 if (RuntimeEnabledFeatures::listMarkerPseudoElementEnabled()) { | |
| 328 MarkerPseudoElement* markerElement = toMarkerPseudoElement(toElement(nod e())->pseudoElement(MARKER)); | |
| 329 if (markerElement && markerElement->renderer()) { | |
| 330 ASSERT(markerElement->renderer()->isListMarker()); | |
| 331 positionListMarker(toRenderListMarker(markerElement->renderer())); | |
| 332 } | |
| 333 } else { | |
| 334 positionListMarker(m_marker); | |
| 335 } | |
| 338 } | 336 } |
| 339 | 337 |
| 340 void RenderListItem::positionListMarker() | 338 void RenderListItem::positionListMarker(RenderListMarker* marker) |
| 341 { | 339 { |
| 342 if (m_marker && m_marker->parent()->isBox() && !m_marker->isInside() && m_ma rker->inlineBoxWrapper()) { | 340 if (marker && marker->parent()->isBox() && !marker->isInside() && marker->in lineBoxWrapper()) { |
| 343 LayoutUnit markerOldLogicalLeft = m_marker->logicalLeft(); | 341 LayoutUnit markerOldLogicalLeft = marker->logicalLeft(); |
| 344 LayoutUnit blockOffset = 0; | 342 LayoutUnit blockOffset = 0; |
| 345 LayoutUnit lineOffset = 0; | 343 LayoutUnit lineOffset = 0; |
| 346 for (RenderBox* o = m_marker->parentBox(); o != this; o = o->parentBox() ) { | 344 for (RenderBox* o = marker->parentBox(); o != this; o = o->parentBox()) { |
| 347 blockOffset += o->logicalTop(); | 345 blockOffset += o->logicalTop(); |
| 348 lineOffset += o->logicalLeft(); | 346 lineOffset += o->logicalLeft(); |
| 349 } | 347 } |
| 350 | 348 |
| 351 bool adjustOverflow = false; | 349 bool adjustOverflow = false; |
| 352 LayoutUnit markerLogicalLeft; | 350 LayoutUnit markerLogicalLeft; |
| 353 RootInlineBox& root = m_marker->inlineBoxWrapper()->root(); | 351 RootInlineBox& root = marker->inlineBoxWrapper()->root(); |
| 354 bool hitSelfPaintingLayer = false; | 352 bool hitSelfPaintingLayer = false; |
| 355 | 353 |
| 356 LayoutUnit lineTop = root.lineTop(); | 354 LayoutUnit lineTop = root.lineTop(); |
| 357 LayoutUnit lineBottom = root.lineBottom(); | 355 LayoutUnit lineBottom = root.lineBottom(); |
| 358 | 356 |
| 359 // FIXME: Need to account for relative positioning in the layout overflo w. | 357 // FIXME: Need to account for relative positioning in the layout overflo w. |
| 360 if (style()->isLeftToRightDirection()) { | 358 if (style()->isLeftToRightDirection()) { |
| 361 LayoutUnit leftLineOffset = logicalLeftOffsetForLine(blockOffset, lo gicalLeftOffsetForLine(blockOffset, false), false); | 359 LayoutUnit leftLineOffset = logicalLeftOffsetForLine(blockOffset, lo gicalLeftOffsetForLine(blockOffset, false), false); |
| 362 markerLogicalLeft = leftLineOffset - lineOffset - paddingStart() - b orderStart() + m_marker->marginStart(); | 360 markerLogicalLeft = leftLineOffset - lineOffset - paddingStart() - b orderStart() + marker->marginStart(); |
| 363 m_marker->inlineBoxWrapper()->adjustLineDirectionPosition((markerLog icalLeft - markerOldLogicalLeft).toFloat()); | 361 marker->inlineBoxWrapper()->adjustLineDirectionPosition((markerLogic alLeft - markerOldLogicalLeft).toFloat()); |
| 364 for (InlineFlowBox* box = m_marker->inlineBoxWrapper()->parent(); bo x; box = box->parent()) { | 362 for (InlineFlowBox* box = marker->inlineBoxWrapper()->parent(); box; box = box->parent()) { |
| 365 LayoutRect newLogicalVisualOverflowRect = box->logicalVisualOver flowRect(lineTop, lineBottom); | 363 LayoutRect newLogicalVisualOverflowRect = box->logicalVisualOver flowRect(lineTop, lineBottom); |
| 366 LayoutRect newLogicalLayoutOverflowRect = box->logicalLayoutOver flowRect(lineTop, lineBottom); | 364 LayoutRect newLogicalLayoutOverflowRect = box->logicalLayoutOver flowRect(lineTop, lineBottom); |
| 367 if (markerLogicalLeft < newLogicalVisualOverflowRect.x() && !hit SelfPaintingLayer) { | 365 if (markerLogicalLeft < newLogicalVisualOverflowRect.x() && !hit SelfPaintingLayer) { |
| 368 newLogicalVisualOverflowRect.setWidth(newLogicalVisualOverfl owRect.maxX() - markerLogicalLeft); | 366 newLogicalVisualOverflowRect.setWidth(newLogicalVisualOverfl owRect.maxX() - markerLogicalLeft); |
| 369 newLogicalVisualOverflowRect.setX(markerLogicalLeft); | 367 newLogicalVisualOverflowRect.setX(markerLogicalLeft); |
| 370 if (box == root) | 368 if (box == root) |
| 371 adjustOverflow = true; | 369 adjustOverflow = true; |
| 372 } | 370 } |
| 373 if (markerLogicalLeft < newLogicalLayoutOverflowRect.x()) { | 371 if (markerLogicalLeft < newLogicalLayoutOverflowRect.x()) { |
| 374 newLogicalLayoutOverflowRect.setWidth(newLogicalLayoutOverfl owRect.maxX() - markerLogicalLeft); | 372 newLogicalLayoutOverflowRect.setWidth(newLogicalLayoutOverfl owRect.maxX() - markerLogicalLeft); |
| 375 newLogicalLayoutOverflowRect.setX(markerLogicalLeft); | 373 newLogicalLayoutOverflowRect.setX(markerLogicalLeft); |
| 376 if (box == root) | 374 if (box == root) |
| 377 adjustOverflow = true; | 375 adjustOverflow = true; |
| 378 } | 376 } |
| 379 box->setOverflowFromLogicalRects(newLogicalLayoutOverflowRect, n ewLogicalVisualOverflowRect, lineTop, lineBottom); | 377 box->setOverflowFromLogicalRects(newLogicalLayoutOverflowRect, n ewLogicalVisualOverflowRect, lineTop, lineBottom); |
| 380 if (box->boxModelObject()->hasSelfPaintingLayer()) | 378 if (box->boxModelObject()->hasSelfPaintingLayer()) |
| 381 hitSelfPaintingLayer = true; | 379 hitSelfPaintingLayer = true; |
| 382 } | 380 } |
| 383 } else { | 381 } else { |
| 384 LayoutUnit rightLineOffset = logicalRightOffsetForLine(blockOffset, logicalRightOffsetForLine(blockOffset, false), false); | 382 LayoutUnit rightLineOffset = logicalRightOffsetForLine(blockOffset, logicalRightOffsetForLine(blockOffset, false), false); |
| 385 markerLogicalLeft = rightLineOffset - lineOffset + paddingStart() + borderStart() + m_marker->marginEnd(); | 383 markerLogicalLeft = rightLineOffset - lineOffset + paddingStart() + borderStart() + marker->marginEnd(); |
| 386 m_marker->inlineBoxWrapper()->adjustLineDirectionPosition((markerLog icalLeft - markerOldLogicalLeft).toFloat()); | 384 marker->inlineBoxWrapper()->adjustLineDirectionPosition((markerLogic alLeft - markerOldLogicalLeft).toFloat()); |
| 387 for (InlineFlowBox* box = m_marker->inlineBoxWrapper()->parent(); bo x; box = box->parent()) { | 385 for (InlineFlowBox* box = marker->inlineBoxWrapper()->parent(); box; box = box->parent()) { |
| 388 LayoutRect newLogicalVisualOverflowRect = box->logicalVisualOver flowRect(lineTop, lineBottom); | 386 LayoutRect newLogicalVisualOverflowRect = box->logicalVisualOver flowRect(lineTop, lineBottom); |
| 389 LayoutRect newLogicalLayoutOverflowRect = box->logicalLayoutOver flowRect(lineTop, lineBottom); | 387 LayoutRect newLogicalLayoutOverflowRect = box->logicalLayoutOver flowRect(lineTop, lineBottom); |
| 390 if (markerLogicalLeft + m_marker->logicalWidth() > newLogicalVis ualOverflowRect.maxX() && !hitSelfPaintingLayer) { | 388 if (markerLogicalLeft + marker->logicalWidth() > newLogicalVisua lOverflowRect.maxX() && !hitSelfPaintingLayer) { |
| 391 newLogicalVisualOverflowRect.setWidth(markerLogicalLeft + m_ marker->logicalWidth() - newLogicalVisualOverflowRect.x()); | 389 newLogicalVisualOverflowRect.setWidth(markerLogicalLeft + ma rker->logicalWidth() - newLogicalVisualOverflowRect.x()); |
| 392 if (box == root) | 390 if (box == root) |
| 393 adjustOverflow = true; | 391 adjustOverflow = true; |
| 394 } | 392 } |
| 395 if (markerLogicalLeft + m_marker->logicalWidth() > newLogicalLay outOverflowRect.maxX()) { | 393 if (markerLogicalLeft + marker->logicalWidth() > newLogicalLayou tOverflowRect.maxX()) { |
| 396 newLogicalLayoutOverflowRect.setWidth(markerLogicalLeft + m_ marker->logicalWidth() - newLogicalLayoutOverflowRect.x()); | 394 newLogicalLayoutOverflowRect.setWidth(markerLogicalLeft + ma rker->logicalWidth() - newLogicalLayoutOverflowRect.x()); |
| 397 if (box == root) | 395 if (box == root) |
| 398 adjustOverflow = true; | 396 adjustOverflow = true; |
| 399 } | 397 } |
| 400 box->setOverflowFromLogicalRects(newLogicalLayoutOverflowRect, n ewLogicalVisualOverflowRect, lineTop, lineBottom); | 398 box->setOverflowFromLogicalRects(newLogicalLayoutOverflowRect, n ewLogicalVisualOverflowRect, lineTop, lineBottom); |
| 401 | 399 |
| 402 if (box->boxModelObject()->hasSelfPaintingLayer()) | 400 if (box->boxModelObject()->hasSelfPaintingLayer()) |
| 403 hitSelfPaintingLayer = true; | 401 hitSelfPaintingLayer = true; |
| 404 } | 402 } |
| 405 } | 403 } |
| 406 | 404 |
| 407 if (adjustOverflow) { | 405 if (adjustOverflow) { |
| 408 LayoutRect markerRect(markerLogicalLeft + lineOffset, blockOffset, m _marker->width(), m_marker->height()); | 406 LayoutRect markerRect(markerLogicalLeft + lineOffset, blockOffset, m arker->width(), marker->height()); |
| 409 if (!style()->isHorizontalWritingMode()) | 407 if (!style()->isHorizontalWritingMode()) |
| 410 markerRect = markerRect.transposedRect(); | 408 markerRect = markerRect.transposedRect(); |
| 411 RenderBox* o = m_marker; | 409 RenderBox* o = marker; |
| 412 bool propagateVisualOverflow = true; | 410 bool propagateVisualOverflow = true; |
| 413 bool propagateLayoutOverflow = true; | 411 bool propagateLayoutOverflow = true; |
| 414 do { | 412 do { |
| 415 o = o->parentBox(); | 413 o = o->parentBox(); |
| 416 if (o->isRenderBlock()) { | 414 if (o->isRenderBlock()) { |
| 417 if (propagateVisualOverflow) | 415 if (propagateVisualOverflow) |
| 418 toRenderBlock(o)->addContentsVisualOverflow(markerRect); | 416 toRenderBlock(o)->addContentsVisualOverflow(markerRect); |
| 419 if (propagateLayoutOverflow) | 417 if (propagateLayoutOverflow) |
| 420 toRenderBlock(o)->addLayoutOverflow(markerRect); | 418 toRenderBlock(o)->addLayoutOverflow(markerRect); |
| 421 } | 419 } |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 434 void RenderListItem::paint(const PaintInfo& paintInfo, const LayoutPoint& paintO ffset) | 432 void RenderListItem::paint(const PaintInfo& paintInfo, const LayoutPoint& paintO ffset) |
| 435 { | 433 { |
| 436 if (!logicalHeight() && hasOverflowClip()) | 434 if (!logicalHeight() && hasOverflowClip()) |
| 437 return; | 435 return; |
| 438 | 436 |
| 439 RenderBlockFlow::paint(paintInfo, paintOffset); | 437 RenderBlockFlow::paint(paintInfo, paintOffset); |
| 440 } | 438 } |
| 441 | 439 |
| 442 const String& RenderListItem::markerText() const | 440 const String& RenderListItem::markerText() const |
| 443 { | 441 { |
| 444 if (m_marker) | 442 if (RuntimeEnabledFeatures::listMarkerPseudoElementEnabled()) { |
| 443 if (PseudoElement* element = toElement(node())->pseudoElement(MARKER)) { | |
| 444 if (element->renderer()) { | |
| 445 ASSERT(element->renderer()->isListMarker()); | |
| 446 return toRenderListMarker(element->renderer())->text(); | |
| 447 } | |
| 448 } | |
| 449 } else if (m_marker) { | |
| 445 return m_marker->text(); | 450 return m_marker->text(); |
| 451 } | |
| 446 return nullAtom.string(); | 452 return nullAtom.string(); |
| 447 } | 453 } |
| 448 | 454 |
| 449 void RenderListItem::explicitValueChanged() | 455 void RenderListItem::explicitValueChanged() |
| 450 { | 456 { |
| 451 if (m_marker) | 457 if (RuntimeEnabledFeatures::listMarkerPseudoElementEnabled()) { |
| 458 if (PseudoElement* element = toElement(node())->pseudoElement(MARKER)) | |
| 459 element->renderer()->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintIn validation(); | |
| 460 } else if (m_marker) { | |
| 452 m_marker->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); | 461 m_marker->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); |
| 462 } | |
| 463 | |
| 453 Node* listNode = enclosingList(this); | 464 Node* listNode = enclosingList(this); |
| 454 for (RenderListItem* item = this; item; item = nextListItem(listNode, item)) | 465 for (RenderListItem* item = this; item; item = nextListItem(listNode, item)) |
| 455 item->updateValue(); | 466 item->updateValue(); |
| 456 } | 467 } |
| 457 | 468 |
| 458 void RenderListItem::setExplicitValue(int value) | 469 void RenderListItem::setExplicitValue(int value) |
| 459 { | 470 { |
| 460 ASSERT(node()); | 471 ASSERT(node()); |
| 461 | 472 |
| 462 if (m_hasExplicitValue && m_explicitValue == value) | 473 if (m_hasExplicitValue && m_explicitValue == value) |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 474 if (!m_hasExplicitValue) | 485 if (!m_hasExplicitValue) |
| 475 return; | 486 return; |
| 476 m_hasExplicitValue = false; | 487 m_hasExplicitValue = false; |
| 477 m_isValueUpToDate = false; | 488 m_isValueUpToDate = false; |
| 478 explicitValueChanged(); | 489 explicitValueChanged(); |
| 479 } | 490 } |
| 480 | 491 |
| 481 void RenderListItem::setNotInList(bool notInList) | 492 void RenderListItem::setNotInList(bool notInList) |
| 482 { | 493 { |
| 483 m_notInList = notInList; | 494 m_notInList = notInList; |
| 484 if (m_marker) | 495 if (RuntimeEnabledFeatures::listMarkerPseudoElementEnabled()) { |
| 496 if (PseudoElement* element = toElement(node())->pseudoElement(MARKER)) { | |
| 497 ASSERT(element->renderer()); | |
| 498 ASSERT(element->renderer()->isListMarker()); | |
| 499 toRenderListMarker(element->renderer())->updateMarginsAndContent(); | |
| 500 } | |
| 501 } else if (m_marker) { | |
| 485 updateMarkerLocation(); | 502 updateMarkerLocation(); |
| 503 } | |
| 486 } | 504 } |
| 487 | 505 |
| 488 static RenderListItem* previousOrNextItem(bool isListReversed, Node* list, Rende rListItem* item) | 506 static RenderListItem* previousOrNextItem(bool isListReversed, Node* list, Rende rListItem* item) |
| 489 { | 507 { |
| 490 return isListReversed ? previousListItem(list, item) : nextListItem(list, it em); | 508 return isListReversed ? previousListItem(list, item) : nextListItem(list, it em); |
| 491 } | 509 } |
| 492 | 510 |
| 493 void RenderListItem::updateListMarkerNumbers() | 511 void RenderListItem::updateListMarkerNumbers() |
| 494 { | 512 { |
| 495 // If distribution recalc is needed, updateListMarkerNumber will be re-invok ed | 513 // If distribution recalc is needed, updateListMarkerNumber will be re-invok ed |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 520 // assume that all the following ones have too. | 538 // assume that all the following ones have too. |
| 521 // This gives us the opportunity to stop here and avoid | 539 // This gives us the opportunity to stop here and avoid |
| 522 // marking the same nodes again. | 540 // marking the same nodes again. |
| 523 break; | 541 break; |
| 524 } | 542 } |
| 525 item->updateValue(); | 543 item->updateValue(); |
| 526 } | 544 } |
| 527 } | 545 } |
| 528 | 546 |
| 529 } // namespace blink | 547 } // namespace blink |
| OLD | NEW |