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/MarkerPseudoElement.h" | |
| 28 #include "core/dom/NodeRenderingTraversal.h" | 29 #include "core/dom/NodeRenderingTraversal.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 |
| (...skipping 12 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 |
| 61 if (RuntimeEnabledFeatures::listMarkerPseudoElementEnabled()) | |
| 62 return; | |
| 63 | |
| 60 if (style()->listStyleType() != NoneListStyle | 64 if (style()->listStyleType() != NoneListStyle |
| 61 || (style()->listStyleImage() && !style()->listStyleImage()->errorOccurr ed())) { | 65 || (style()->listStyleImage() && !style()->listStyleImage()->errorOccurr ed())) { |
| 62 if (!m_marker) | 66 if (!m_marker) |
| 63 m_marker = RenderListMarker::createAnonymous(this); | 67 m_marker = RenderListMarker::createAnonymous(this); |
| 64 m_marker->listItemStyleDidChange(); | 68 m_marker->listItemStyleDidChange(); |
| 65 } else if (m_marker) { | 69 } else if (m_marker) { |
| 66 m_marker->destroy(); | 70 m_marker->destroy(); |
| 67 m_marker = nullptr; | 71 m_marker = nullptr; |
| 68 } | 72 } |
| 69 } | 73 } |
| 70 | 74 |
| 71 void RenderListItem::willBeDestroyed() | 75 void RenderListItem::willBeDestroyed() |
| 72 { | 76 { |
| 73 if (m_marker) { | 77 if (m_marker) { |
| 74 m_marker->destroy(); | 78 m_marker->destroy(); |
| 75 m_marker = nullptr; | 79 m_marker = nullptr; |
| 76 } | 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 | |
| 84 updateListMarkerNumbers(); | 87 updateListMarkerNumbers(); |
| 85 } | 88 } |
| 86 | 89 |
| 87 void RenderListItem::willBeRemovedFromTree() | 90 void RenderListItem::willBeRemovedFromTree() |
| 88 { | 91 { |
| 89 RenderBlockFlow::willBeRemovedFromTree(); | 92 RenderBlockFlow::willBeRemovedFromTree(); |
| 90 | |
| 91 updateListMarkerNumbers(); | 93 updateListMarkerNumbers(); |
| 92 } | 94 } |
| 93 | 95 |
| 94 static bool isList(const Node& node) | 96 static bool isList(const Node& node) |
| 95 { | 97 { |
| 96 return isHTMLUListElement(node) || isHTMLOListElement(node); | 98 return isHTMLUListElement(node) || isHTMLOListElement(node); |
| 97 } | 99 } |
| 98 | 100 |
| 99 // Returns the enclosing list with respect to the DOM order. | 101 // Returns the enclosing list with respect to the DOM order. |
| 100 static Node* enclosingList(const RenderListItem* listItem) | 102 static Node* enclosingList(const RenderListItem* listItem) |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 } | 214 } |
| 213 | 215 |
| 214 void RenderListItem::updateValueNow() const | 216 void RenderListItem::updateValueNow() const |
| 215 { | 217 { |
| 216 m_value = calcValue(); | 218 m_value = calcValue(); |
| 217 m_isValueUpToDate = true; | 219 m_isValueUpToDate = true; |
| 218 } | 220 } |
| 219 | 221 |
| 220 bool RenderListItem::isEmpty() const | 222 bool RenderListItem::isEmpty() const |
| 221 { | 223 { |
| 224 if (RuntimeEnabledFeatures::listMarkerPseudoElementEnabled()) { | |
| 225 PseudoElement* element = toElement(node())->pseudoElement(MARKER); | |
| 226 return !(element && lastChild() != element->renderer()); | |
| 227 } | |
| 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 PseudoElement* element = toElement(node())->pseudoElement(MARKER); | |
| 296 if (element && element->renderer()) { | |
| 297 ASSERT(element->renderer()->isListMarker()); | |
| 298 RenderListMarker* marker = toRenderListMarker(element->renderer()); | |
| 299 | |
| 300 marker->updateMarginsAndContent(); | |
| 301 | |
| 302 // FIXME: Is this needed? | |
| 303 if (marker->isInside()) | |
| 304 containingBlock()->updateLogicalWidth(); | |
| 305 } | |
| 306 | |
| 307 } else if (m_marker) { | |
| 322 // The marker must be autosized before calling | 308 // The marker must be autosized before calling |
| 323 // updateMarkerLocationAndInvalidateWidth. It cannot be done in the | 309 // updateMarkerLocationAndInvalidateWidth. It cannot be done in the |
| 324 // parent's beginLayout because it is not yet in the render tree. | 310 // parent's beginLayout because it is not yet in the render tree. |
| 325 if (TextAutosizer* textAutosizer = document().textAutosizer()) | 311 if (TextAutosizer* textAutosizer = document().textAutosizer()) |
| 326 textAutosizer->inflateListItem(this, m_marker); | 312 textAutosizer->inflateListItem(this, m_marker); |
| 327 | 313 |
| 328 updateMarkerLocationAndInvalidateWidth(); | 314 updateMarkerLocationAndInvalidateWidth(); |
| 329 } | 315 } |
| 330 | 316 |
| 331 RenderBlockFlow::layout(); | 317 RenderBlockFlow::layout(); |
| 332 } | 318 } |
| 333 | 319 |
| 334 void RenderListItem::addOverflowFromChildren() | 320 void RenderListItem::addOverflowFromChildren() |
| 335 { | 321 { |
| 336 RenderBlockFlow::addOverflowFromChildren(); | 322 RenderBlockFlow::addOverflowFromChildren(); |
| 337 positionListMarker(); | 323 |
| 324 if (RuntimeEnabledFeatures::listMarkerPseudoElementEnabled()) { | |
| 325 MarkerPseudoElement* markerElement = toMarkerPseudoElement(toElement(nod e())->pseudoElement(MARKER)); | |
| 326 if (markerElement && markerElement->renderer()) { | |
| 327 ASSERT(markerElement->renderer()->isListMarker()); | |
| 328 positionListMarker(toRenderListMarker(markerElement->renderer())); | |
| 329 } | |
| 330 } else { | |
| 331 positionListMarker(m_marker); | |
| 332 } | |
| 338 } | 333 } |
| 339 | 334 |
| 340 void RenderListItem::positionListMarker() | 335 void RenderListItem::positionListMarker(RenderListMarker* marker) |
| 341 { | 336 { |
| 342 if (m_marker && m_marker->parent()->isBox() && !m_marker->isInside() && m_ma rker->inlineBoxWrapper()) { | 337 if (!marker) |
| 343 LayoutUnit markerOldLogicalLeft = m_marker->logicalLeft(); | 338 return; |
| 339 | |
| 340 ASSERT(marker->parent()); | |
| 341 if (marker->parent()->isBox() && !marker->isInside() && marker->inlineBoxWra pper()) { | |
| 342 LayoutUnit markerOldLogicalLeft = marker->logicalLeft(); | |
| 344 LayoutUnit blockOffset = 0; | 343 LayoutUnit blockOffset = 0; |
| 345 LayoutUnit lineOffset = 0; | 344 LayoutUnit lineOffset = 0; |
| 346 for (RenderBox* o = m_marker->parentBox(); o != this; o = o->parentBox() ) { | 345 for (RenderBox* o = marker->parentBox(); o != this; o = o->parentBox()) { |
| 347 blockOffset += o->logicalTop(); | 346 blockOffset += o->logicalTop(); |
| 348 lineOffset += o->logicalLeft(); | 347 lineOffset += o->logicalLeft(); |
| 349 } | 348 } |
| 350 | 349 |
| 351 bool adjustOverflow = false; | 350 bool adjustOverflow = false; |
| 352 LayoutUnit markerLogicalLeft; | 351 LayoutUnit markerLogicalLeft; |
| 353 RootInlineBox& root = m_marker->inlineBoxWrapper()->root(); | 352 RootInlineBox& root = marker->inlineBoxWrapper()->root(); |
| 354 bool hitSelfPaintingLayer = false; | 353 bool hitSelfPaintingLayer = false; |
| 355 | 354 |
| 356 LayoutUnit lineTop = root.lineTop(); | 355 LayoutUnit lineTop = root.lineTop(); |
| 357 LayoutUnit lineBottom = root.lineBottom(); | 356 LayoutUnit lineBottom = root.lineBottom(); |
| 358 | 357 |
| 359 // FIXME: Need to account for relative positioning in the layout overflo w. | 358 // FIXME: Need to account for relative positioning in the layout overflo w. |
| 360 if (style()->isLeftToRightDirection()) { | 359 if (style()->isLeftToRightDirection()) { |
| 361 LayoutUnit leftLineOffset = logicalLeftOffsetForLine(blockOffset, lo gicalLeftOffsetForLine(blockOffset, false), false); | 360 LayoutUnit leftLineOffset = logicalLeftOffsetForLine(blockOffset, lo gicalLeftOffsetForLine(blockOffset, false), false); |
| 362 markerLogicalLeft = leftLineOffset - lineOffset - paddingStart() - b orderStart() + m_marker->marginStart(); | 361 markerLogicalLeft = leftLineOffset - lineOffset - paddingStart() - b orderStart() + marker->marginStart(); |
| 363 m_marker->inlineBoxWrapper()->adjustLineDirectionPosition((markerLog icalLeft - markerOldLogicalLeft).toFloat()); | 362 marker->inlineBoxWrapper()->adjustLineDirectionPosition((markerLogic alLeft - markerOldLogicalLeft).toFloat()); |
| 364 for (InlineFlowBox* box = m_marker->inlineBoxWrapper()->parent(); bo x; box = box->parent()) { | 363 for (InlineFlowBox* box = marker->inlineBoxWrapper()->parent(); box; box = box->parent()) { |
| 365 LayoutRect newLogicalVisualOverflowRect = box->logicalVisualOver flowRect(lineTop, lineBottom); | 364 LayoutRect newLogicalVisualOverflowRect = box->logicalVisualOver flowRect(lineTop, lineBottom); |
| 366 LayoutRect newLogicalLayoutOverflowRect = box->logicalLayoutOver flowRect(lineTop, lineBottom); | 365 LayoutRect newLogicalLayoutOverflowRect = box->logicalLayoutOver flowRect(lineTop, lineBottom); |
| 367 if (markerLogicalLeft < newLogicalVisualOverflowRect.x() && !hit SelfPaintingLayer) { | 366 if (markerLogicalLeft < newLogicalVisualOverflowRect.x() && !hit SelfPaintingLayer) { |
| 368 newLogicalVisualOverflowRect.setWidth(newLogicalVisualOverfl owRect.maxX() - markerLogicalLeft); | 367 newLogicalVisualOverflowRect.setWidth(newLogicalVisualOverfl owRect.maxX() - markerLogicalLeft); |
| 369 newLogicalVisualOverflowRect.setX(markerLogicalLeft); | 368 newLogicalVisualOverflowRect.setX(markerLogicalLeft); |
| 370 if (box == root) | 369 if (box == root) |
| 371 adjustOverflow = true; | 370 adjustOverflow = true; |
| 372 } | 371 } |
| 373 if (markerLogicalLeft < newLogicalLayoutOverflowRect.x()) { | 372 if (markerLogicalLeft < newLogicalLayoutOverflowRect.x()) { |
| 374 newLogicalLayoutOverflowRect.setWidth(newLogicalLayoutOverfl owRect.maxX() - markerLogicalLeft); | 373 newLogicalLayoutOverflowRect.setWidth(newLogicalLayoutOverfl owRect.maxX() - markerLogicalLeft); |
| 375 newLogicalLayoutOverflowRect.setX(markerLogicalLeft); | 374 newLogicalLayoutOverflowRect.setX(markerLogicalLeft); |
| 376 if (box == root) | 375 if (box == root) |
| 377 adjustOverflow = true; | 376 adjustOverflow = true; |
| 378 } | 377 } |
| 379 box->setOverflowFromLogicalRects(newLogicalLayoutOverflowRect, n ewLogicalVisualOverflowRect, lineTop, lineBottom); | 378 box->setOverflowFromLogicalRects(newLogicalLayoutOverflowRect, n ewLogicalVisualOverflowRect, lineTop, lineBottom); |
| 380 if (box->boxModelObject()->hasSelfPaintingLayer()) | 379 if (box->boxModelObject()->hasSelfPaintingLayer()) |
| 381 hitSelfPaintingLayer = true; | 380 hitSelfPaintingLayer = true; |
| 382 } | 381 } |
| 383 } else { | 382 } else { |
| 384 LayoutUnit rightLineOffset = logicalRightOffsetForLine(blockOffset, logicalRightOffsetForLine(blockOffset, false), false); | 383 LayoutUnit rightLineOffset = logicalRightOffsetForLine(blockOffset, logicalRightOffsetForLine(blockOffset, false), false); |
| 385 markerLogicalLeft = rightLineOffset - lineOffset + paddingStart() + borderStart() + m_marker->marginEnd(); | 384 markerLogicalLeft = rightLineOffset - lineOffset + paddingStart() + borderStart() + marker->marginEnd(); |
| 386 m_marker->inlineBoxWrapper()->adjustLineDirectionPosition((markerLog icalLeft - markerOldLogicalLeft).toFloat()); | 385 marker->inlineBoxWrapper()->adjustLineDirectionPosition((markerLogic alLeft - markerOldLogicalLeft).toFloat()); |
| 387 for (InlineFlowBox* box = m_marker->inlineBoxWrapper()->parent(); bo x; box = box->parent()) { | 386 for (InlineFlowBox* box = marker->inlineBoxWrapper()->parent(); box; box = box->parent()) { |
| 388 LayoutRect newLogicalVisualOverflowRect = box->logicalVisualOver flowRect(lineTop, lineBottom); | 387 LayoutRect newLogicalVisualOverflowRect = box->logicalVisualOver flowRect(lineTop, lineBottom); |
| 389 LayoutRect newLogicalLayoutOverflowRect = box->logicalLayoutOver flowRect(lineTop, lineBottom); | 388 LayoutRect newLogicalLayoutOverflowRect = box->logicalLayoutOver flowRect(lineTop, lineBottom); |
| 390 if (markerLogicalLeft + m_marker->logicalWidth() > newLogicalVis ualOverflowRect.maxX() && !hitSelfPaintingLayer) { | 389 if (markerLogicalLeft + marker->logicalWidth() > newLogicalVisua lOverflowRect.maxX() && !hitSelfPaintingLayer) { |
| 391 newLogicalVisualOverflowRect.setWidth(markerLogicalLeft + m_ marker->logicalWidth() - newLogicalVisualOverflowRect.x()); | 390 newLogicalVisualOverflowRect.setWidth(markerLogicalLeft + ma rker->logicalWidth() - newLogicalVisualOverflowRect.x()); |
| 392 if (box == root) | 391 if (box == root) |
| 393 adjustOverflow = true; | 392 adjustOverflow = true; |
| 394 } | 393 } |
| 395 if (markerLogicalLeft + m_marker->logicalWidth() > newLogicalLay outOverflowRect.maxX()) { | 394 if (markerLogicalLeft + marker->logicalWidth() > newLogicalLayou tOverflowRect.maxX()) { |
| 396 newLogicalLayoutOverflowRect.setWidth(markerLogicalLeft + m_ marker->logicalWidth() - newLogicalLayoutOverflowRect.x()); | 395 newLogicalLayoutOverflowRect.setWidth(markerLogicalLeft + ma rker->logicalWidth() - newLogicalLayoutOverflowRect.x()); |
| 397 if (box == root) | 396 if (box == root) |
| 398 adjustOverflow = true; | 397 adjustOverflow = true; |
| 399 } | 398 } |
| 400 box->setOverflowFromLogicalRects(newLogicalLayoutOverflowRect, n ewLogicalVisualOverflowRect, lineTop, lineBottom); | 399 box->setOverflowFromLogicalRects(newLogicalLayoutOverflowRect, n ewLogicalVisualOverflowRect, lineTop, lineBottom); |
| 401 | 400 |
| 402 if (box->boxModelObject()->hasSelfPaintingLayer()) | 401 if (box->boxModelObject()->hasSelfPaintingLayer()) |
| 403 hitSelfPaintingLayer = true; | 402 hitSelfPaintingLayer = true; |
| 404 } | 403 } |
| 405 } | 404 } |
| 406 | 405 |
| 407 if (adjustOverflow) { | 406 if (adjustOverflow) { |
| 408 LayoutRect markerRect(LayoutPoint(markerLogicalLeft + lineOffset, bl ockOffset), m_marker->size()); | 407 LayoutRect markerRect(LayoutPoint(markerLogicalLeft + lineOffset, bl ockOffset), marker->size()); |
| 409 if (!style()->isHorizontalWritingMode()) | 408 if (!style()->isHorizontalWritingMode()) |
| 410 markerRect = markerRect.transposedRect(); | 409 markerRect = markerRect.transposedRect(); |
| 411 RenderBox* o = m_marker; | 410 RenderBox* o = marker; |
| 412 bool propagateVisualOverflow = true; | 411 bool propagateVisualOverflow = true; |
| 413 bool propagateLayoutOverflow = true; | 412 bool propagateLayoutOverflow = true; |
| 414 do { | 413 do { |
| 415 o = o->parentBox(); | 414 o = o->parentBox(); |
| 416 if (o->isRenderBlock()) { | 415 if (o->isRenderBlock()) { |
| 417 if (propagateVisualOverflow) | 416 if (propagateVisualOverflow) |
| 418 toRenderBlock(o)->addContentsVisualOverflow(markerRect); | 417 toRenderBlock(o)->addContentsVisualOverflow(markerRect); |
| 419 if (propagateLayoutOverflow) | 418 if (propagateLayoutOverflow) |
| 420 toRenderBlock(o)->addLayoutOverflow(markerRect); | 419 toRenderBlock(o)->addLayoutOverflow(markerRect); |
| 421 } | 420 } |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 434 void RenderListItem::paint(const PaintInfo& paintInfo, const LayoutPoint& paintO ffset) | 433 void RenderListItem::paint(const PaintInfo& paintInfo, const LayoutPoint& paintO ffset) |
| 435 { | 434 { |
| 436 if (!logicalHeight() && hasOverflowClip()) | 435 if (!logicalHeight() && hasOverflowClip()) |
| 437 return; | 436 return; |
| 438 | 437 |
| 439 RenderBlockFlow::paint(paintInfo, paintOffset); | 438 RenderBlockFlow::paint(paintInfo, paintOffset); |
| 440 } | 439 } |
| 441 | 440 |
| 442 const String& RenderListItem::markerText() const | 441 const String& RenderListItem::markerText() const |
| 443 { | 442 { |
| 444 if (m_marker) | 443 if (RuntimeEnabledFeatures::listMarkerPseudoElementEnabled()) { |
| 444 if (PseudoElement* element = toElement(node())->pseudoElement(MARKER)) { | |
| 445 if (element->renderer()) { | |
| 446 ASSERT(element->renderer()->isListMarker()); | |
| 447 return toRenderListMarker(element->renderer())->text(); | |
| 448 } | |
| 449 } | |
| 450 } else if (m_marker) { | |
| 445 return m_marker->text(); | 451 return m_marker->text(); |
| 452 } | |
| 446 return nullAtom.string(); | 453 return nullAtom.string(); |
| 447 } | 454 } |
| 448 | 455 |
| 449 void RenderListItem::explicitValueChanged() | 456 void RenderListItem::explicitValueChanged() |
| 450 { | 457 { |
| 451 if (m_marker) | 458 if (RuntimeEnabledFeatures::listMarkerPseudoElementEnabled()) { |
| 459 if (PseudoElement* element = toElement(node())->pseudoElement(MARKER)) | |
| 460 element->renderer()->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintIn validation(); | |
| 461 } else if (m_marker) { | |
| 452 m_marker->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); | 462 m_marker->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); |
| 463 } | |
| 464 | |
| 453 Node* listNode = enclosingList(this); | 465 Node* listNode = enclosingList(this); |
| 454 for (RenderListItem* item = this; item; item = nextListItem(listNode, item)) | 466 for (RenderListItem* item = this; item; item = nextListItem(listNode, item)) |
| 455 item->updateValue(); | 467 item->updateValue(); |
| 456 } | 468 } |
| 457 | 469 |
| 458 void RenderListItem::setExplicitValue(int value) | 470 void RenderListItem::setExplicitValue(int value) |
| 459 { | 471 { |
| 460 ASSERT(node()); | 472 ASSERT(node()); |
| 461 | 473 |
| 462 if (m_hasExplicitValue && m_explicitValue == value) | 474 if (m_hasExplicitValue && m_explicitValue == value) |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 474 if (!m_hasExplicitValue) | 486 if (!m_hasExplicitValue) |
| 475 return; | 487 return; |
| 476 m_hasExplicitValue = false; | 488 m_hasExplicitValue = false; |
| 477 m_isValueUpToDate = false; | 489 m_isValueUpToDate = false; |
| 478 explicitValueChanged(); | 490 explicitValueChanged(); |
| 479 } | 491 } |
| 480 | 492 |
| 481 void RenderListItem::setNotInList(bool notInList) | 493 void RenderListItem::setNotInList(bool notInList) |
| 482 { | 494 { |
| 483 m_notInList = notInList; | 495 m_notInList = notInList; |
| 484 if (m_marker) | 496 if (RuntimeEnabledFeatures::listMarkerPseudoElementEnabled()) { |
| 497 if (PseudoElement* element = toElement(node())->pseudoElement(MARKER)) { | |
| 498 ASSERT(element->renderer()); | |
| 499 ASSERT(element->renderer()->isListMarker()); | |
| 500 toRenderListMarker(element->renderer())->updateMarginsAndContent(); | |
|
Julien - ping for review
2015/02/04 01:56:34
This will need some explanations.
dsinclair
2015/02/04 04:41:33
This is the one bit that was needed from the old u
| |
| 501 } | |
| 502 } else if (m_marker) { | |
| 485 updateMarkerLocation(); | 503 updateMarkerLocation(); |
| 504 } | |
| 486 } | 505 } |
| 487 | 506 |
| 488 static RenderListItem* previousOrNextItem(bool isListReversed, Node* list, Rende rListItem* item) | 507 static RenderListItem* previousOrNextItem(bool isListReversed, Node* list, Rende rListItem* item) |
| 489 { | 508 { |
| 490 return isListReversed ? previousListItem(list, item) : nextListItem(list, it em); | 509 return isListReversed ? previousListItem(list, item) : nextListItem(list, it em); |
| 491 } | 510 } |
| 492 | 511 |
| 493 void RenderListItem::updateListMarkerNumbers() | 512 void RenderListItem::updateListMarkerNumbers() |
| 494 { | 513 { |
| 495 // If distribution recalc is needed, updateListMarkerNumber will be re-invok ed | 514 // 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. | 539 // assume that all the following ones have too. |
| 521 // This gives us the opportunity to stop here and avoid | 540 // This gives us the opportunity to stop here and avoid |
| 522 // marking the same nodes again. | 541 // marking the same nodes again. |
| 523 break; | 542 break; |
| 524 } | 543 } |
| 525 item->updateValue(); | 544 item->updateValue(); |
| 526 } | 545 } |
| 527 } | 546 } |
| 528 | 547 |
| 529 } // namespace blink | 548 } // namespace blink |
| OLD | NEW |