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 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) | 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv
ed. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv
ed. |
7 * Copyright (C) 2009 Google Inc. All rights reserved. | 7 * Copyright (C) 2009 Google Inc. All rights reserved. |
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 #include "wtf/text/WTFString.h" | 90 #include "wtf/text/WTFString.h" |
91 #include <algorithm> | 91 #include <algorithm> |
92 #ifndef NDEBUG | 92 #ifndef NDEBUG |
93 #include <stdio.h> | 93 #include <stdio.h> |
94 #endif | 94 #endif |
95 | 95 |
96 namespace blink { | 96 namespace blink { |
97 | 97 |
98 namespace { | 98 namespace { |
99 | 99 |
100 static bool gModifyRenderTreeStructureAnyState = false; | 100 static bool gModifyLayoutTreeStructureAnyState = false; |
101 | 101 |
102 static bool gDisablePaintInvalidationStateAsserts = false; | 102 static bool gDisablePaintInvalidationStateAsserts = false; |
103 | 103 |
104 } // namespace | 104 } // namespace |
105 | 105 |
106 using namespace HTMLNames; | 106 using namespace HTMLNames; |
107 | 107 |
108 #if ENABLE(ASSERT) | 108 #if ENABLE(ASSERT) |
109 | 109 |
110 LayoutObject::SetLayoutNeededForbiddenScope::SetLayoutNeededForbiddenScope(Layou
tObject& layoutObject) | 110 LayoutObject::SetLayoutNeededForbiddenScope::SetLayoutNeededForbiddenScope(Layou
tObject& layoutObject) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 } | 146 } |
147 | 147 |
148 void LayoutObject::operator delete(void* ptr) | 148 void LayoutObject::operator delete(void* ptr) |
149 { | 149 { |
150 ASSERT(isMainThread()); | 150 ASSERT(isMainThread()); |
151 partitionFree(ptr); | 151 partitionFree(ptr); |
152 } | 152 } |
153 | 153 |
154 LayoutObject* LayoutObject::createObject(Element* element, const ComputedStyle&
style) | 154 LayoutObject* LayoutObject::createObject(Element* element, const ComputedStyle&
style) |
155 { | 155 { |
156 ASSERT(isAllowedToModifyRenderTreeStructure(element->document())); | 156 ASSERT(isAllowedToModifyLayoutTreeStructure(element->document())); |
157 | 157 |
158 // Minimal support for content properties replacing an entire element. | 158 // Minimal support for content properties replacing an entire element. |
159 // Works only if we have exactly one piece of content and it's a URL. | 159 // Works only if we have exactly one piece of content and it's a URL. |
160 // Otherwise acts as if we didn't support this feature. | 160 // Otherwise acts as if we didn't support this feature. |
161 const ContentData* contentData = style.contentData(); | 161 const ContentData* contentData = style.contentData(); |
162 if (contentData && !contentData->next() && contentData->isImage() && !elemen
t->isPseudoElement()) { | 162 if (contentData && !contentData->next() && contentData->isImage() && !elemen
t->isPseudoElement()) { |
163 LayoutImage* image = new LayoutImage(element); | 163 LayoutImage* image = new LayoutImage(element); |
164 // LayoutImageResourceStyleImage requires a style being present on the i
mage but we don't want to | 164 // LayoutImageResourceStyleImage requires a style being present on the i
mage but we don't want to |
165 // trigger a style change now as the node is not fully attached. Moving
this code to style change | 165 // trigger a style change now as the node is not fully attached. Moving
this code to style change |
166 // doesn't make sense as it should be run once at renderer creation. | 166 // doesn't make sense as it should be run once at layoutObject creation. |
167 image->setStyleInternal(const_cast<ComputedStyle*>(&style)); | 167 image->setStyleInternal(const_cast<ComputedStyle*>(&style)); |
168 if (const StyleImage* styleImage = toImageContentData(contentData)->imag
e()) { | 168 if (const StyleImage* styleImage = toImageContentData(contentData)->imag
e()) { |
169 image->setImageResource(LayoutImageResourceStyleImage::create(const_
cast<StyleImage*>(styleImage))); | 169 image->setImageResource(LayoutImageResourceStyleImage::create(const_
cast<StyleImage*>(styleImage))); |
170 image->setIsGeneratedContent(); | 170 image->setIsGeneratedContent(); |
171 } else { | 171 } else { |
172 image->setImageResource(LayoutImageResource::create()); | 172 image->setImageResource(LayoutImageResource::create()); |
173 } | 173 } |
174 image->setStyleInternal(nullptr); | 174 image->setStyleInternal(nullptr); |
175 return image; | 175 return image; |
176 } | 176 } |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 return !isTable(); | 296 return !isTable(); |
297 if (newChild->isTableRow()) | 297 if (newChild->isTableRow()) |
298 return !isTableSection(); | 298 return !isTableSection(); |
299 if (newChild->isTableCell()) | 299 if (newChild->isTableCell()) |
300 return !isTableRow(); | 300 return !isTableRow(); |
301 return false; | 301 return false; |
302 } | 302 } |
303 | 303 |
304 void LayoutObject::addChild(LayoutObject* newChild, LayoutObject* beforeChild) | 304 void LayoutObject::addChild(LayoutObject* newChild, LayoutObject* beforeChild) |
305 { | 305 { |
306 ASSERT(isAllowedToModifyRenderTreeStructure(document())); | 306 ASSERT(isAllowedToModifyLayoutTreeStructure(document())); |
307 | 307 |
308 LayoutObjectChildList* children = virtualChildren(); | 308 LayoutObjectChildList* children = virtualChildren(); |
309 ASSERT(children); | 309 ASSERT(children); |
310 if (!children) | 310 if (!children) |
311 return; | 311 return; |
312 | 312 |
313 if (requiresAnonymousTableWrappers(newChild)) { | 313 if (requiresAnonymousTableWrappers(newChild)) { |
314 // Generate an anonymous table or reuse existing one from previous child | 314 // Generate an anonymous table or reuse existing one from previous child |
315 // Per: 17.2.1 Anonymous table objects 3. Generate missing parents | 315 // Per: 17.2.1 Anonymous table objects 3. Generate missing parents |
316 // http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes | 316 // http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes |
317 LayoutTable* table; | 317 LayoutTable* table; |
318 LayoutObject* afterChild = beforeChild ? beforeChild->previousSibling()
: children->lastChild(); | 318 LayoutObject* afterChild = beforeChild ? beforeChild->previousSibling()
: children->lastChild(); |
319 if (afterChild && afterChild->isAnonymous() && afterChild->isTable() &&
!afterChild->isBeforeContent()) { | 319 if (afterChild && afterChild->isAnonymous() && afterChild->isTable() &&
!afterChild->isBeforeContent()) { |
320 table = toLayoutTable(afterChild); | 320 table = toLayoutTable(afterChild); |
321 } else { | 321 } else { |
322 table = LayoutTable::createAnonymousWithParent(this); | 322 table = LayoutTable::createAnonymousWithParent(this); |
323 addChild(table, beforeChild); | 323 addChild(table, beforeChild); |
324 } | 324 } |
325 table->addChild(newChild); | 325 table->addChild(newChild); |
326 } else { | 326 } else { |
327 children->insertChildNode(this, newChild, beforeChild); | 327 children->insertChildNode(this, newChild, beforeChild); |
328 } | 328 } |
329 | 329 |
330 if (newChild->isText() && newChild->style()->textTransform() == CAPITALIZE) | 330 if (newChild->isText() && newChild->style()->textTransform() == CAPITALIZE) |
331 toLayoutText(newChild)->transformText(); | 331 toLayoutText(newChild)->transformText(); |
332 | 332 |
333 // SVG creates renderers for <g display="none">, as SVG requires children of
hidden | 333 // SVG creates layoutObjects for <g display="none">, as SVG requires childre
n of hidden |
334 // <g>s to have renderers - at least that's how our implementation works. Co
nsider: | 334 // <g>s to have layoutObjects - at least that's how our implementation works
. Consider: |
335 // <g display="none"><foreignObject><body style="position: relative">FOO... | 335 // <g display="none"><foreignObject><body style="position: relative">FOO... |
336 // - layerTypeRequired() would return true for the <body>, creating a new La
yer | 336 // - layerTypeRequired() would return true for the <body>, creating a new La
yer |
337 // - when the document is painted, both layers are painted. The <body> layer
doesn't | 337 // - when the document is painted, both layers are painted. The <body> layer
doesn't |
338 // know that it's inside a "hidden SVG subtree", and thus paints, even if
it shouldn't. | 338 // know that it's inside a "hidden SVG subtree", and thus paints, even if
it shouldn't. |
339 // To avoid the problem alltogether, detect early if we're inside a hidden S
VG subtree | 339 // To avoid the problem alltogether, detect early if we're inside a hidden S
VG subtree |
340 // and stop creating layers at all for these cases - they're not used anyway
s. | 340 // and stop creating layers at all for these cases - they're not used anyway
s. |
341 if (newChild->hasLayer() && !layerCreationAllowedForSubtree()) | 341 if (newChild->hasLayer() && !layerCreationAllowedForSubtree()) |
342 toLayoutBoxModelObject(newChild)->layer()->removeOnlyThisLayer(); | 342 toLayoutBoxModelObject(newChild)->layer()->removeOnlyThisLayer(); |
343 } | 343 } |
344 | 344 |
345 void LayoutObject::removeChild(LayoutObject* oldChild) | 345 void LayoutObject::removeChild(LayoutObject* oldChild) |
346 { | 346 { |
347 ASSERT(isAllowedToModifyRenderTreeStructure(document())); | 347 ASSERT(isAllowedToModifyLayoutTreeStructure(document())); |
348 | 348 |
349 LayoutObjectChildList* children = virtualChildren(); | 349 LayoutObjectChildList* children = virtualChildren(); |
350 ASSERT(children); | 350 ASSERT(children); |
351 if (!children) | 351 if (!children) |
352 return; | 352 return; |
353 | 353 |
354 children->removeChildNode(this, oldChild); | 354 children->removeChildNode(this, oldChild); |
355 } | 355 } |
356 | 356 |
357 LayoutObject* LayoutObject::nextInPreOrder() const | 357 LayoutObject* LayoutObject::nextInPreOrder() const |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 | 534 |
535 return 0; | 535 return 0; |
536 } | 536 } |
537 | 537 |
538 DeprecatedPaintLayer* LayoutObject::enclosingLayer() const | 538 DeprecatedPaintLayer* LayoutObject::enclosingLayer() const |
539 { | 539 { |
540 for (const LayoutObject* current = this; current; current = current->parent(
)) { | 540 for (const LayoutObject* current = this; current; current = current->parent(
)) { |
541 if (current->hasLayer()) | 541 if (current->hasLayer()) |
542 return toLayoutBoxModelObject(current)->layer(); | 542 return toLayoutBoxModelObject(current)->layer(); |
543 } | 543 } |
544 // FIXME: we should get rid of detached render subtrees, at which point this
code should | 544 // FIXME: we should get rid of detached layout subtrees, at which point this
code should |
545 // not be reached. crbug.com/411429 | 545 // not be reached. crbug.com/411429 |
546 return 0; | 546 return 0; |
547 } | 547 } |
548 | 548 |
549 bool LayoutObject::scrollRectToVisible(const LayoutRect& rect, const ScrollAlign
ment& alignX, const ScrollAlignment& alignY) | 549 bool LayoutObject::scrollRectToVisible(const LayoutRect& rect, const ScrollAlign
ment& alignX, const ScrollAlignment& alignY) |
550 { | 550 { |
551 LayoutBox* enclosingBox = this->enclosingBox(); | 551 LayoutBox* enclosingBox = this->enclosingBox(); |
552 if (!enclosingBox) | 552 if (!enclosingBox) |
553 return false; | 553 return false; |
554 | 554 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 // Not in the middle of layout so have to find the thread the slow way. | 609 // Not in the middle of layout so have to find the thread the slow way. |
610 LayoutObject* curr = const_cast<LayoutObject*>(this); | 610 LayoutObject* curr = const_cast<LayoutObject*>(this); |
611 while (curr) { | 611 while (curr) { |
612 if (curr->isLayoutFlowThread()) | 612 if (curr->isLayoutFlowThread()) |
613 return toLayoutFlowThread(curr); | 613 return toLayoutFlowThread(curr); |
614 curr = curr->containingBlock(); | 614 curr = curr->containingBlock(); |
615 } | 615 } |
616 return 0; | 616 return 0; |
617 } | 617 } |
618 | 618 |
619 // FIXME: This could be used when changing the size of a renderer without childr
en to skip some invalidations. | 619 // FIXME: This could be used when changing the size of a layoutObject without ch
ildren to skip some invalidations. |
620 // FIXME: This is incorrect for document element. Remove this when we enable sli
mming paint. | 620 // FIXME: This is incorrect for document element. Remove this when we enable sli
mming paint. |
621 static inline bool rendererHasNoBoxEffectObsolete(const LayoutObject& object) | 621 static inline bool layoutObjectHasNoBoxEffectObsolete(const LayoutObject& object
) |
622 { | 622 { |
623 return !object.style()->hasVisualOverflowingEffect() && !object.style()->has
Border() && !object.style()->hasBackground(); | 623 return !object.style()->hasVisualOverflowingEffect() && !object.style()->has
Border() && !object.style()->hasBackground(); |
624 } | 624 } |
625 | 625 |
626 bool LayoutObject::skipInvalidationWhenLaidOutChildren() const | 626 bool LayoutObject::skipInvalidationWhenLaidOutChildren() const |
627 { | 627 { |
628 if (!neededLayoutBecauseOfChildren()) | 628 if (!neededLayoutBecauseOfChildren()) |
629 return false; | 629 return false; |
630 | 630 |
631 // SVG renderers need to be invalidated when their children are laid out. | 631 // SVG layoutObjects need to be invalidated when their children are laid out
. |
632 // LayoutBlocks with line boxes are responsible to invalidate them so we can
't ignore them. | 632 // LayoutBlocks with line boxes are responsible to invalidate them so we can
't ignore them. |
633 if (isSVG() || (isLayoutBlockFlow() && toLayoutBlockFlow(this)->firstLineBox
())) | 633 if (isSVG() || (isLayoutBlockFlow() && toLayoutBlockFlow(this)->firstLineBox
())) |
634 return false; | 634 return false; |
635 | 635 |
636 // In case scrollbars got repositioned (which will typically happen if the l
ayout object got | 636 // In case scrollbars got repositioned (which will typically happen if the l
ayout object got |
637 // resized), we cannot skip invalidation. | 637 // resized), we cannot skip invalidation. |
638 if (hasNonCompositedScrollbars()) | 638 if (hasNonCompositedScrollbars()) |
639 return false; | 639 return false; |
640 | 640 |
641 if (RuntimeEnabledFeatures::slimmingPaintEnabled() && isDocumentElement()) | 641 if (RuntimeEnabledFeatures::slimmingPaintEnabled() && isDocumentElement()) |
642 return !hasBoxEffect(); | 642 return !hasBoxEffect(); |
643 | 643 |
644 return rendererHasNoBoxEffectObsolete(*this); | 644 return layoutObjectHasNoBoxEffectObsolete(*this); |
645 } | 645 } |
646 | 646 |
647 LayoutBlock* LayoutObject::firstLineBlock() const | 647 LayoutBlock* LayoutObject::firstLineBlock() const |
648 { | 648 { |
649 return 0; | 649 return 0; |
650 } | 650 } |
651 | 651 |
652 static inline bool objectIsRelayoutBoundary(const LayoutObject* object) | 652 static inline bool objectIsRelayoutBoundary(const LayoutObject* object) |
653 { | 653 { |
654 // FIXME: In future it may be possible to broaden these conditions in order
to improve performance. | 654 // FIXME: In future it may be possible to broaden these conditions in order
to improve performance. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 object->setNeedsSimplifiedNormalFlowLayout(true); | 718 object->setNeedsSimplifiedNormalFlowLayout(true); |
719 ASSERT(!object->isSetNeedsLayoutForbidden()); | 719 ASSERT(!object->isSetNeedsLayoutForbidden()); |
720 } else { | 720 } else { |
721 if (object->normalChildNeedsLayout()) | 721 if (object->normalChildNeedsLayout()) |
722 return; | 722 return; |
723 object->setNormalChildNeedsLayout(true); | 723 object->setNormalChildNeedsLayout(true); |
724 ASSERT(!object->isSetNeedsLayoutForbidden()); | 724 ASSERT(!object->isSetNeedsLayoutForbidden()); |
725 } | 725 } |
726 | 726 |
727 if (layouter) { | 727 if (layouter) { |
728 layouter->addRendererToLayout(object); | 728 layouter->recordObjectMarkedForLayout(object); |
729 if (object == layouter->root()) | 729 if (object == layouter->root()) |
730 return; | 730 return; |
731 } | 731 } |
732 | 732 |
733 if (object == newRoot) | 733 if (object == newRoot) |
734 return; | 734 return; |
735 | 735 |
736 last = object; | 736 last = object; |
737 if (scheduleRelayout && objectIsRelayoutBoundary(last)) | 737 if (scheduleRelayout && objectIsRelayoutBoundary(last)) |
738 break; | 738 break; |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1334 setPreviousPositionFromPaintInvalidationBacking(newLocation); | 1334 setPreviousPositionFromPaintInvalidationBacking(newLocation); |
1335 | 1335 |
1336 PaintInvalidationReason invalidationReason = paintInvalidationReason(paintIn
validationContainer, oldBounds, oldLocation, newBounds, newLocation); | 1336 PaintInvalidationReason invalidationReason = paintInvalidationReason(paintIn
validationContainer, oldBounds, oldLocation, newBounds, newLocation); |
1337 | 1337 |
1338 // We need to invalidate the selection before checking for whether we are do
ing a full invalidation. | 1338 // We need to invalidate the selection before checking for whether we are do
ing a full invalidation. |
1339 // This is because we need to update the old rect regardless. | 1339 // This is because we need to update the old rect regardless. |
1340 invalidateSelectionIfNeeded(paintInvalidationContainer, invalidationReason); | 1340 invalidateSelectionIfNeeded(paintInvalidationContainer, invalidationReason); |
1341 | 1341 |
1342 // If we are set to do a full paint invalidation that means the LayoutView w
ill issue | 1342 // If we are set to do a full paint invalidation that means the LayoutView w
ill issue |
1343 // paint invalidations. We can then skip issuing of paint invalidations for
the child | 1343 // paint invalidations. We can then skip issuing of paint invalidations for
the child |
1344 // renderers as they'll be covered by the LayoutView. | 1344 // layoutObjects as they'll be covered by the LayoutView. |
1345 // However, slimming paint mode requires paint invalidation of the child ren
derers. | 1345 // However, slimming paint mode requires paint invalidation of the child lay
outObjects. |
1346 if (view()->doingFullPaintInvalidation() && !RuntimeEnabledFeatures::slimmin
gPaintEnabled()) | 1346 if (view()->doingFullPaintInvalidation() && !RuntimeEnabledFeatures::slimmin
gPaintEnabled()) |
1347 return invalidationReason; | 1347 return invalidationReason; |
1348 | 1348 |
1349 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "LayoutObject:
:invalidatePaintIfNeeded()", | 1349 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "LayoutObject:
:invalidatePaintIfNeeded()", |
1350 "object", this->debugName().ascii(), | 1350 "object", this->debugName().ascii(), |
1351 "info", jsonObjectForOldAndNewRects(oldBounds, oldLocation, newBounds, n
ewLocation)); | 1351 "info", jsonObjectForOldAndNewRects(oldBounds, oldLocation, newBounds, n
ewLocation)); |
1352 | 1352 |
1353 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { | 1353 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { |
1354 bool boxDecorationBackgroundObscured = boxDecorationBackgroundIsKnownToB
eObscured(); | 1354 bool boxDecorationBackgroundObscured = boxDecorationBackgroundIsKnownToB
eObscured(); |
1355 if (!isFullPaintInvalidationReason(invalidationReason) && boxDecorationB
ackgroundObscured != m_bitfields.lastBoxDecorationBackgroundObscured()) | 1355 if (!isFullPaintInvalidationReason(invalidationReason) && boxDecorationB
ackgroundObscured != m_bitfields.lastBoxDecorationBackgroundObscured()) |
(...skipping 29 matching lines...) Expand all Loading... |
1385 if (shouldDoFullPaintInvalidation()) | 1385 if (shouldDoFullPaintInvalidation()) |
1386 return m_bitfields.fullPaintInvalidationReason(); | 1386 return m_bitfields.fullPaintInvalidationReason(); |
1387 | 1387 |
1388 // If the bounds are the same then we know that none of the statements below | 1388 // If the bounds are the same then we know that none of the statements below |
1389 // can match, so we can early out since we will not need to do any | 1389 // can match, so we can early out since we will not need to do any |
1390 // invalidation. | 1390 // invalidation. |
1391 if (oldBounds == newBounds) | 1391 if (oldBounds == newBounds) |
1392 return PaintInvalidationNone; | 1392 return PaintInvalidationNone; |
1393 | 1393 |
1394 // If we shifted, we don't know the exact reason so we are conservative and
trigger a full invalidation. Shifting could | 1394 // If we shifted, we don't know the exact reason so we are conservative and
trigger a full invalidation. Shifting could |
1395 // be caused by some layout property (left / top) or some in-flow renderer i
nserted / removed before us in the tree. | 1395 // be caused by some layout property (left / top) or some in-flow layoutObje
ct inserted / removed before us in the tree. |
1396 if (newBounds.location() != oldBounds.location()) | 1396 if (newBounds.location() != oldBounds.location()) |
1397 return PaintInvalidationBoundsChange; | 1397 return PaintInvalidationBoundsChange; |
1398 | 1398 |
1399 // This covers the case where we mark containing blocks for layout | 1399 // This covers the case where we mark containing blocks for layout |
1400 // and they change size but don't have anything to paint. This is | 1400 // and they change size but don't have anything to paint. This is |
1401 // a pretty common case for <body> as we add / remove children | 1401 // a pretty common case for <body> as we add / remove children |
1402 // (and the default background is done by FrameView). | 1402 // (and the default background is done by FrameView). |
1403 if (skipInvalidationWhenLaidOutChildren()) | 1403 if (skipInvalidationWhenLaidOutChildren()) |
1404 return PaintInvalidationNone; | 1404 return PaintInvalidationNone; |
1405 | 1405 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1604 { | 1604 { |
1605 return selectionColor(CSSPropertyWebkitTextEmphasisColor); | 1605 return selectionColor(CSSPropertyWebkitTextEmphasisColor); |
1606 } | 1606 } |
1607 | 1607 |
1608 void LayoutObject::selectionStartEnd(int& spos, int& epos) const | 1608 void LayoutObject::selectionStartEnd(int& spos, int& epos) const |
1609 { | 1609 { |
1610 view()->selectionStartEnd(spos, epos); | 1610 view()->selectionStartEnd(spos, epos); |
1611 } | 1611 } |
1612 | 1612 |
1613 // Called when an object that was floating or positioned becomes a normal flow o
bject | 1613 // Called when an object that was floating or positioned becomes a normal flow o
bject |
1614 // again. We have to make sure the render tree updates as needed to accommodate
the new | 1614 // again. We have to make sure the layout tree updates as needed to accommodate
the new |
1615 // normal flow object. | 1615 // normal flow object. |
1616 static inline void handleDynamicFloatPositionChange(LayoutObject* object) | 1616 static inline void handleDynamicFloatPositionChange(LayoutObject* object) |
1617 { | 1617 { |
1618 // We have gone from not affecting the inline status of the parent flow to s
uddenly | 1618 // We have gone from not affecting the inline status of the parent flow to s
uddenly |
1619 // having an impact. See if there is a mismatch between the parent flow's | 1619 // having an impact. See if there is a mismatch between the parent flow's |
1620 // childrenInline() state and our state. | 1620 // childrenInline() state and our state. |
1621 object->setInline(object->style()->isDisplayInlineType()); | 1621 object->setInline(object->style()->isDisplayInlineType()); |
1622 if (object->isInline() != object->parent()->childrenInline()) { | 1622 if (object->isInline() != object->parent()->childrenInline()) { |
1623 if (!object->isInline()) { | 1623 if (!object->isInline()) { |
1624 toLayoutBoxModelObject(object->parent())->childBecameNonInline(objec
t); | 1624 toLayoutBoxModelObject(object->parent())->childBecameNonInline(objec
t); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1750 | 1750 |
1751 updateShapeImage(oldStyle ? oldStyle->shapeOutside() : 0, m_style->shapeOuts
ide()); | 1751 updateShapeImage(oldStyle ? oldStyle->shapeOutside() : 0, m_style->shapeOuts
ide()); |
1752 | 1752 |
1753 bool doesNotNeedLayoutOrPaintInvalidation = !m_parent; | 1753 bool doesNotNeedLayoutOrPaintInvalidation = !m_parent; |
1754 | 1754 |
1755 styleDidChange(diff, oldStyle.get()); | 1755 styleDidChange(diff, oldStyle.get()); |
1756 | 1756 |
1757 // FIXME: |this| might be destroyed here. This can currently happen for a La
youtTextFragment when | 1757 // FIXME: |this| might be destroyed here. This can currently happen for a La
youtTextFragment when |
1758 // its first-letter block gets an update in LayoutTextFragment::styleDidChan
ge. For LayoutTextFragment(s), | 1758 // its first-letter block gets an update in LayoutTextFragment::styleDidChan
ge. For LayoutTextFragment(s), |
1759 // we will safely bail out with the doesNotNeedLayoutOrPaintInvalidation fla
g. We might want to broaden | 1759 // we will safely bail out with the doesNotNeedLayoutOrPaintInvalidation fla
g. We might want to broaden |
1760 // this condition in the future as we move renderer changes out of layout an
d into style changes. | 1760 // this condition in the future as we move layoutObject changes out of layou
t and into style changes. |
1761 if (doesNotNeedLayoutOrPaintInvalidation) | 1761 if (doesNotNeedLayoutOrPaintInvalidation) |
1762 return; | 1762 return; |
1763 | 1763 |
1764 // Now that the layer (if any) has been updated, we need to adjust the diff
again, | 1764 // Now that the layer (if any) has been updated, we need to adjust the diff
again, |
1765 // check whether we should layout now, and decide if we need to invalidate p
aints. | 1765 // check whether we should layout now, and decide if we need to invalidate p
aints. |
1766 StyleDifference updatedDiff = adjustStyleDifference(diff); | 1766 StyleDifference updatedDiff = adjustStyleDifference(diff); |
1767 | 1767 |
1768 if (!diff.needsFullLayout()) { | 1768 if (!diff.needsFullLayout()) { |
1769 if (updatedDiff.needsFullLayout()) | 1769 if (updatedDiff.needsFullLayout()) |
1770 setNeedsLayoutAndPrefWidthsRecalc(LayoutInvalidationReason::StyleCha
nge); | 1770 setNeedsLayoutAndPrefWidthsRecalc(LayoutInvalidationReason::StyleCha
nge); |
1771 else if (updatedDiff.needsPositionedMovementLayout()) | 1771 else if (updatedDiff.needsPositionedMovementLayout()) |
1772 setNeedsPositionedMovementLayout(); | 1772 setNeedsPositionedMovementLayout(); |
1773 } | 1773 } |
1774 | 1774 |
1775 if (diff.transformChanged() && !needsLayout()) { | 1775 if (diff.transformChanged() && !needsLayout()) { |
1776 if (LayoutBlock* container = containingBlock()) | 1776 if (LayoutBlock* container = containingBlock()) |
1777 container->setNeedsOverflowRecalcAfterStyleChange(); | 1777 container->setNeedsOverflowRecalcAfterStyleChange(); |
1778 } | 1778 } |
1779 | 1779 |
1780 if (updatedDiff.needsPaintInvalidationLayer()) | 1780 if (updatedDiff.needsPaintInvalidationLayer()) |
1781 toLayoutBoxModelObject(this)->layer()->setShouldDoFullPaintInvalidationI
ncludingNonCompositingDescendants(); | 1781 toLayoutBoxModelObject(this)->layer()->setShouldDoFullPaintInvalidationI
ncludingNonCompositingDescendants(); |
1782 else if (diff.needsPaintInvalidationObject() || updatedDiff.needsPaintInvali
dationObject()) | 1782 else if (diff.needsPaintInvalidationObject() || updatedDiff.needsPaintInvali
dationObject()) |
1783 setShouldDoFullPaintInvalidation(); | 1783 setShouldDoFullPaintInvalidation(); |
1784 } | 1784 } |
1785 | 1785 |
1786 static inline bool rendererHasBackground(const LayoutObject* renderer) | 1786 static inline bool layoutObjectHasBackground(const LayoutObject* layoutObject) |
1787 { | 1787 { |
1788 return renderer && renderer->hasBackground(); | 1788 return layoutObject && layoutObject->hasBackground(); |
1789 } | 1789 } |
1790 | 1790 |
1791 void LayoutObject::styleWillChange(StyleDifference diff, const ComputedStyle& ne
wStyle) | 1791 void LayoutObject::styleWillChange(StyleDifference diff, const ComputedStyle& ne
wStyle) |
1792 { | 1792 { |
1793 if (m_style) { | 1793 if (m_style) { |
1794 // If our z-index changes value or our visibility changes, | 1794 // If our z-index changes value or our visibility changes, |
1795 // we need to dirty our stacking context's z-order list. | 1795 // we need to dirty our stacking context's z-order list. |
1796 bool visibilityChanged = m_style->visibility() != newStyle.visibility() | 1796 bool visibilityChanged = m_style->visibility() != newStyle.visibility() |
1797 || m_style->zIndex() != newStyle.zIndex() | 1797 || m_style->zIndex() != newStyle.zIndex() |
1798 || m_style->hasAutoZIndex() != newStyle.hasAutoZIndex(); | 1798 || m_style->hasAutoZIndex() != newStyle.hasAutoZIndex(); |
(...skipping 17 matching lines...) Expand all Loading... |
1816 } else if (isOutOfFlowPositioned() && (m_style->position() != newStyle.p
osition())) { | 1816 } else if (isOutOfFlowPositioned() && (m_style->position() != newStyle.p
osition())) { |
1817 // For changes in positioning styles, we need to conceivably remove
ourselves | 1817 // For changes in positioning styles, we need to conceivably remove
ourselves |
1818 // from the positioned objects list. | 1818 // from the positioned objects list. |
1819 toLayoutBox(this)->removeFloatingOrPositionedChildFromBlockLists(); | 1819 toLayoutBox(this)->removeFloatingOrPositionedChildFromBlockLists(); |
1820 } | 1820 } |
1821 | 1821 |
1822 s_affectsParentBlock = isFloatingOrOutOfFlowPositioned() | 1822 s_affectsParentBlock = isFloatingOrOutOfFlowPositioned() |
1823 && (!newStyle.isFloating() && !newStyle.hasOutOfFlowPosition()) | 1823 && (!newStyle.isFloating() && !newStyle.hasOutOfFlowPosition()) |
1824 && parent() && (parent()->isLayoutBlockFlow() || parent()->isLayoutI
nline()); | 1824 && parent() && (parent()->isLayoutBlockFlow() || parent()->isLayoutI
nline()); |
1825 | 1825 |
1826 // Clearing these bits is required to avoid leaving stale renderers. | 1826 // Clearing these bits is required to avoid leaving stale layoutObjects. |
1827 // FIXME: We shouldn't need that hack if our logic was totally correct. | 1827 // FIXME: We shouldn't need that hack if our logic was totally correct. |
1828 if (diff.needsLayout()) { | 1828 if (diff.needsLayout()) { |
1829 setFloating(false); | 1829 setFloating(false); |
1830 clearPositionedState(); | 1830 clearPositionedState(); |
1831 } | 1831 } |
1832 } else { | 1832 } else { |
1833 s_affectsParentBlock = false; | 1833 s_affectsParentBlock = false; |
1834 } | 1834 } |
1835 | 1835 |
1836 if (view()->frameView()) { | 1836 if (view()->frameView()) { |
1837 bool shouldBlitOnFixedBackgroundImage = false; | 1837 bool shouldBlitOnFixedBackgroundImage = false; |
1838 if (RuntimeEnabledFeatures::fastMobileScrollingEnabled()) { | 1838 if (RuntimeEnabledFeatures::fastMobileScrollingEnabled()) { |
1839 // On low-powered/mobile devices, preventing blitting on a scroll ca
n cause noticeable delays | 1839 // On low-powered/mobile devices, preventing blitting on a scroll ca
n cause noticeable delays |
1840 // when scrolling a page with a fixed background image. As an optimi
zation, assuming there are | 1840 // when scrolling a page with a fixed background image. As an optimi
zation, assuming there are |
1841 // no fixed positoned elements on the page, we can acclerate scrolli
ng (via blitting) if we | 1841 // no fixed positoned elements on the page, we can acclerate scrolli
ng (via blitting) if we |
1842 // ignore the CSS property "background-attachment: fixed". | 1842 // ignore the CSS property "background-attachment: fixed". |
1843 shouldBlitOnFixedBackgroundImage = true; | 1843 shouldBlitOnFixedBackgroundImage = true; |
1844 } | 1844 } |
1845 bool newStyleSlowScroll = !shouldBlitOnFixedBackgroundImage && newStyle.
hasFixedBackgroundImage(); | 1845 bool newStyleSlowScroll = !shouldBlitOnFixedBackgroundImage && newStyle.
hasFixedBackgroundImage(); |
1846 bool oldStyleSlowScroll = m_style && !shouldBlitOnFixedBackgroundImage &
& m_style->hasFixedBackgroundImage(); | 1846 bool oldStyleSlowScroll = m_style && !shouldBlitOnFixedBackgroundImage &
& m_style->hasFixedBackgroundImage(); |
1847 | 1847 |
1848 bool drawsRootBackground = isDocumentElement() || (isBody() && !renderer
HasBackground(document().documentElement()->layoutObject())); | 1848 bool drawsRootBackground = isDocumentElement() || (isBody() && !layoutOb
jectHasBackground(document().documentElement()->layoutObject())); |
1849 if (drawsRootBackground && !shouldBlitOnFixedBackgroundImage) { | 1849 if (drawsRootBackground && !shouldBlitOnFixedBackgroundImage) { |
1850 if (view()->compositor()->supportsFixedRootBackgroundCompositing())
{ | 1850 if (view()->compositor()->supportsFixedRootBackgroundCompositing())
{ |
1851 if (newStyleSlowScroll && newStyle.hasEntirelyFixedBackground()) | 1851 if (newStyleSlowScroll && newStyle.hasEntirelyFixedBackground()) |
1852 newStyleSlowScroll = false; | 1852 newStyleSlowScroll = false; |
1853 | 1853 |
1854 if (oldStyleSlowScroll && m_style->hasEntirelyFixedBackground()) | 1854 if (oldStyleSlowScroll && m_style->hasEntirelyFixedBackground()) |
1855 oldStyleSlowScroll = false; | 1855 oldStyleSlowScroll = false; |
1856 } | 1856 } |
1857 } | 1857 } |
1858 | 1858 |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2133 FloatPoint LayoutObject::localToInvalidationBackingPoint(const LayoutPoint& loca
lPoint, DeprecatedPaintLayer** backingLayer) | 2133 FloatPoint LayoutObject::localToInvalidationBackingPoint(const LayoutPoint& loca
lPoint, DeprecatedPaintLayer** backingLayer) |
2134 { | 2134 { |
2135 const LayoutBoxModelObject* paintInvalidationContainer = containerForPaintIn
validation(); | 2135 const LayoutBoxModelObject* paintInvalidationContainer = containerForPaintIn
validation(); |
2136 ASSERT(paintInvalidationContainer); | 2136 ASSERT(paintInvalidationContainer); |
2137 ASSERT(paintInvalidationContainer->layer()); | 2137 ASSERT(paintInvalidationContainer->layer()); |
2138 | 2138 |
2139 if (backingLayer) | 2139 if (backingLayer) |
2140 *backingLayer = paintInvalidationContainer->layer(); | 2140 *backingLayer = paintInvalidationContainer->layer(); |
2141 FloatPoint containerPoint = localToContainerPoint(FloatPoint(localPoint), pa
intInvalidationContainer, TraverseDocumentBoundaries); | 2141 FloatPoint containerPoint = localToContainerPoint(FloatPoint(localPoint), pa
intInvalidationContainer, TraverseDocumentBoundaries); |
2142 | 2142 |
2143 // A renderer can have no invalidation backing if it is from a detached fram
e, | 2143 // A layoutObject can have no invalidation backing if it is from a detached
frame, |
2144 // or when forced compositing is disabled. | 2144 // or when forced compositing is disabled. |
2145 if (paintInvalidationContainer->layer()->compositingState() == NotComposited
) | 2145 if (paintInvalidationContainer->layer()->compositingState() == NotComposited
) |
2146 return containerPoint; | 2146 return containerPoint; |
2147 | 2147 |
2148 DeprecatedPaintLayer::mapPointToPaintBackingCoordinates(paintInvalidationCon
tainer, containerPoint); | 2148 DeprecatedPaintLayer::mapPointToPaintBackingCoordinates(paintInvalidationCon
tainer, containerPoint); |
2149 return containerPoint; | 2149 return containerPoint; |
2150 } | 2150 } |
2151 | 2151 |
2152 LayoutSize LayoutObject::offsetFromContainer(const LayoutObject* o, const Layout
Point& point, bool* offsetDependsOnPoint) const | 2152 LayoutSize LayoutObject::offsetFromContainer(const LayoutObject* o, const Layout
Point& point, bool* offsetDependsOnPoint) const |
2153 { | 2153 { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2191 { | 2191 { |
2192 if (extraWidthToEndOfLine) | 2192 if (extraWidthToEndOfLine) |
2193 *extraWidthToEndOfLine = 0; | 2193 *extraWidthToEndOfLine = 0; |
2194 | 2194 |
2195 return LayoutRect(); | 2195 return LayoutRect(); |
2196 } | 2196 } |
2197 | 2197 |
2198 void LayoutObject::computeLayerHitTestRects(LayerHitTestRects& layerRects) const | 2198 void LayoutObject::computeLayerHitTestRects(LayerHitTestRects& layerRects) const |
2199 { | 2199 { |
2200 // Figure out what layer our container is in. Any offset (or new layer) for
this | 2200 // Figure out what layer our container is in. Any offset (or new layer) for
this |
2201 // renderer within it's container will be applied in addLayerHitTestRects. | 2201 // layoutObject within it's container will be applied in addLayerHitTestRect
s. |
2202 LayoutPoint layerOffset; | 2202 LayoutPoint layerOffset; |
2203 const DeprecatedPaintLayer* currentLayer = 0; | 2203 const DeprecatedPaintLayer* currentLayer = 0; |
2204 | 2204 |
2205 if (!hasLayer()) { | 2205 if (!hasLayer()) { |
2206 LayoutObject* container = this->container(); | 2206 LayoutObject* container = this->container(); |
2207 currentLayer = container->enclosingLayer(); | 2207 currentLayer = container->enclosingLayer(); |
2208 if (container && currentLayer->layoutObject() != container) { | 2208 if (container && currentLayer->layoutObject() != container) { |
2209 layerOffset.move(container->offsetFromAncestorContainer(currentLayer
->layoutObject())); | 2209 layerOffset.move(container->offsetFromAncestorContainer(currentLayer
->layoutObject())); |
2210 // If the layer itself is scrolled, we have to undo the subtraction
of its scroll | 2210 // If the layer itself is scrolled, we have to undo the subtraction
of its scroll |
2211 // offset since we want the offset relative to the scrolling content
, not the | 2211 // offset since we want the offset relative to the scrolling content
, not the |
2212 // element itself. | 2212 // element itself. |
2213 if (currentLayer->layoutObject()->hasOverflowClip()) | 2213 if (currentLayer->layoutObject()->hasOverflowClip()) |
2214 layerOffset.move(currentLayer->layoutBox()->scrolledContentOffse
t()); | 2214 layerOffset.move(currentLayer->layoutBox()->scrolledContentOffse
t()); |
2215 } | 2215 } |
2216 } | 2216 } |
2217 | 2217 |
2218 this->addLayerHitTestRects(layerRects, currentLayer, layerOffset, LayoutRect
()); | 2218 this->addLayerHitTestRects(layerRects, currentLayer, layerOffset, LayoutRect
()); |
2219 } | 2219 } |
2220 | 2220 |
2221 void LayoutObject::addLayerHitTestRects(LayerHitTestRects& layerRects, const Dep
recatedPaintLayer* currentLayer, const LayoutPoint& layerOffset, const LayoutRec
t& containerRect) const | 2221 void LayoutObject::addLayerHitTestRects(LayerHitTestRects& layerRects, const Dep
recatedPaintLayer* currentLayer, const LayoutPoint& layerOffset, const LayoutRec
t& containerRect) const |
2222 { | 2222 { |
2223 ASSERT(currentLayer); | 2223 ASSERT(currentLayer); |
2224 ASSERT(currentLayer == this->enclosingLayer()); | 2224 ASSERT(currentLayer == this->enclosingLayer()); |
2225 | 2225 |
2226 // Compute the rects for this renderer only and add them to the results. | 2226 // Compute the rects for this layoutObject only and add them to the results. |
2227 // Note that we could avoid passing the offset and instead adjust each resul
t, but this | 2227 // Note that we could avoid passing the offset and instead adjust each resul
t, but this |
2228 // seems slightly simpler. | 2228 // seems slightly simpler. |
2229 Vector<LayoutRect> ownRects; | 2229 Vector<LayoutRect> ownRects; |
2230 LayoutRect newContainerRect; | 2230 LayoutRect newContainerRect; |
2231 computeSelfHitTestRects(ownRects, layerOffset); | 2231 computeSelfHitTestRects(ownRects, layerOffset); |
2232 | 2232 |
2233 // When we get to have a lot of rects on a layer, the performance cost of tr
acking those | 2233 // When we get to have a lot of rects on a layer, the performance cost of tr
acking those |
2234 // rects outweighs the benefit of doing compositor thread hit testing. | 2234 // rects outweighs the benefit of doing compositor thread hit testing. |
2235 // FIXME: This limit needs to be low due to the O(n^2) algorithm in | 2235 // FIXME: This limit needs to be low due to the O(n^2) algorithm in |
2236 // WebLayer::setTouchEventHandlerRegion - crbug.com/300282. | 2236 // WebLayer::setTouchEventHandlerRegion - crbug.com/300282. |
2237 const size_t maxRectsPerLayer = 100; | 2237 const size_t maxRectsPerLayer = 100; |
2238 | 2238 |
2239 LayerHitTestRects::iterator iter = layerRects.find(currentLayer); | 2239 LayerHitTestRects::iterator iter = layerRects.find(currentLayer); |
2240 Vector<LayoutRect>* iterValue; | 2240 Vector<LayoutRect>* iterValue; |
2241 if (iter == layerRects.end()) | 2241 if (iter == layerRects.end()) |
2242 iterValue = &layerRects.add(currentLayer, Vector<LayoutRect>()).storedVa
lue->value; | 2242 iterValue = &layerRects.add(currentLayer, Vector<LayoutRect>()).storedVa
lue->value; |
2243 else | 2243 else |
2244 iterValue = &iter->value; | 2244 iterValue = &iter->value; |
2245 for (size_t i = 0; i < ownRects.size(); i++) { | 2245 for (size_t i = 0; i < ownRects.size(); i++) { |
2246 if (!containerRect.contains(ownRects[i])) { | 2246 if (!containerRect.contains(ownRects[i])) { |
2247 iterValue->append(ownRects[i]); | 2247 iterValue->append(ownRects[i]); |
2248 if (iterValue->size() > maxRectsPerLayer) { | 2248 if (iterValue->size() > maxRectsPerLayer) { |
2249 // Just mark the entire layer instead, and switch to walking the
layer | 2249 // Just mark the entire layer instead, and switch to walking the
layer |
2250 // tree instead of the render tree. | 2250 // tree instead of the layout tree. |
2251 layerRects.remove(currentLayer); | 2251 layerRects.remove(currentLayer); |
2252 currentLayer->addLayerHitTestRects(layerRects); | 2252 currentLayer->addLayerHitTestRects(layerRects); |
2253 return; | 2253 return; |
2254 } | 2254 } |
2255 if (newContainerRect.isEmpty()) | 2255 if (newContainerRect.isEmpty()) |
2256 newContainerRect = ownRects[i]; | 2256 newContainerRect = ownRects[i]; |
2257 } | 2257 } |
2258 } | 2258 } |
2259 if (newContainerRect.isEmpty()) | 2259 if (newContainerRect.isEmpty()) |
2260 newContainerRect = containerRect; | 2260 newContainerRect = containerRect; |
(...skipping 15 matching lines...) Expand all Loading... |
2276 bool LayoutObject::isRooted() const | 2276 bool LayoutObject::isRooted() const |
2277 { | 2277 { |
2278 const LayoutObject* object = this; | 2278 const LayoutObject* object = this; |
2279 while (object->parent() && !object->hasLayer()) | 2279 while (object->parent() && !object->hasLayer()) |
2280 object = object->parent(); | 2280 object = object->parent(); |
2281 if (object->hasLayer()) | 2281 if (object->hasLayer()) |
2282 return toLayoutBoxModelObject(object)->layer()->root()->isRootLayer(); | 2282 return toLayoutBoxModelObject(object)->layer()->root()->isRootLayer(); |
2283 return false; | 2283 return false; |
2284 } | 2284 } |
2285 | 2285 |
2286 LayoutObject* LayoutObject::rendererForRootBackground() | 2286 LayoutObject* LayoutObject::layoutObjectForRootBackground() |
2287 { | 2287 { |
2288 ASSERT(isDocumentElement()); | 2288 ASSERT(isDocumentElement()); |
2289 if (!hasBackground() && isHTMLHtmlElement(node())) { | 2289 if (!hasBackground() && isHTMLHtmlElement(node())) { |
2290 // Locate the <body> element using the DOM. This is easier than trying | 2290 // Locate the <body> element using the DOM. This is easier than trying |
2291 // to crawl around a render tree with potential :before/:after content a
nd | 2291 // to crawl around a layout tree with potential :before/:after content a
nd |
2292 // anonymous blocks created by inline <body> tags etc. We can locate the
<body> | 2292 // anonymous blocks created by inline <body> tags etc. We can locate the
<body> |
2293 // render object very easily via the DOM. | 2293 // layout object very easily via the DOM. |
2294 HTMLElement* body = document().body(); | 2294 HTMLElement* body = document().body(); |
2295 LayoutObject* bodyObject = isHTMLBodyElement(body) ? body->layoutObject(
) : 0; | 2295 LayoutObject* bodyObject = isHTMLBodyElement(body) ? body->layoutObject(
) : 0; |
2296 if (bodyObject) | 2296 if (bodyObject) |
2297 return bodyObject; | 2297 return bodyObject; |
2298 } | 2298 } |
2299 | 2299 |
2300 return this; | 2300 return this; |
2301 } | 2301 } |
2302 | 2302 |
2303 RespectImageOrientationEnum LayoutObject::shouldRespectImageOrientation() const | 2303 RespectImageOrientationEnum LayoutObject::shouldRespectImageOrientation() const |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2385 } | 2385 } |
2386 | 2386 |
2387 void LayoutObject::willBeDestroyed() | 2387 void LayoutObject::willBeDestroyed() |
2388 { | 2388 { |
2389 // Destroy any leftover anonymous children. | 2389 // Destroy any leftover anonymous children. |
2390 LayoutObjectChildList* children = virtualChildren(); | 2390 LayoutObjectChildList* children = virtualChildren(); |
2391 if (children) | 2391 if (children) |
2392 children->destroyLeftoverChildren(); | 2392 children->destroyLeftoverChildren(); |
2393 | 2393 |
2394 if (LocalFrame* frame = this->frame()) { | 2394 if (LocalFrame* frame = this->frame()) { |
2395 // If this renderer is being autoscrolled, stop the autoscrolling. | 2395 // If this layoutObject is being autoscrolled, stop the autoscrolling. |
2396 if (frame->page()) | 2396 if (frame->page()) |
2397 frame->page()->autoscrollController().stopAutoscrollIfNeeded(this); | 2397 frame->page()->autoscrollController().stopAutoscrollIfNeeded(this); |
2398 | 2398 |
2399 if (frame->view() && frame->view()->viewportLayoutObject() == this) | 2399 if (frame->view() && frame->view()->viewportLayoutObject() == this) |
2400 frame->view()->clearViewportLayoutObject(); | 2400 frame->view()->clearViewportLayoutObject(); |
2401 } | 2401 } |
2402 | 2402 |
2403 // For accessibility management, notify the parent of the imminent change to
its child set. | 2403 // For accessibility management, notify the parent of the imminent change to
its child set. |
2404 // We do it now, before remove(), while the parent pointer is still availabl
e. | 2404 // We do it now, before remove(), while the parent pointer is still availabl
e. |
2405 if (AXObjectCache* cache = document().existingAXObjectCache()) | 2405 if (AXObjectCache* cache = document().existingAXObjectCache()) |
2406 cache->childrenChanged(this->parent()); | 2406 cache->childrenChanged(this->parent()); |
2407 | 2407 |
2408 remove(); | 2408 remove(); |
2409 | 2409 |
2410 // The remove() call above may invoke axObjectCache()->childrenChanged() on
the parent, which may require the AX render | 2410 // The remove() call above may invoke axObjectCache()->childrenChanged() on
the parent, which may require the AX layout |
2411 // object for this renderer. So we remove the AX render object now, after th
e renderer is removed. | 2411 // object for this layoutObject. So we remove the AX layout object now, afte
r the layoutObject is removed. |
2412 if (AXObjectCache* cache = document().existingAXObjectCache()) | 2412 if (AXObjectCache* cache = document().existingAXObjectCache()) |
2413 cache->remove(this); | 2413 cache->remove(this); |
2414 | 2414 |
2415 // If this renderer had a parent, remove should have destroyed any counters | 2415 // If this layoutObject had a parent, remove should have destroyed any count
ers |
2416 // attached to this renderer and marked the affected other counters for | 2416 // attached to this layoutObject and marked the affected other counters for |
2417 // reevaluation. This apparently redundant check is here for the case when | 2417 // reevaluation. This apparently redundant check is here for the case when |
2418 // this renderer had no parent at the time remove() was called. | 2418 // this layoutObject had no parent at the time remove() was called. |
2419 | 2419 |
2420 if (hasCounterNodeMap()) | 2420 if (hasCounterNodeMap()) |
2421 LayoutCounter::destroyCounterNodes(*this); | 2421 LayoutCounter::destroyCounterNodes(*this); |
2422 | 2422 |
2423 // Remove the handler if node had touch-action set. Handlers are not added | 2423 // Remove the handler if node had touch-action set. Handlers are not added |
2424 // for text nodes so don't try removing for one too. Need to check if | 2424 // for text nodes so don't try removing for one too. Need to check if |
2425 // m_style is null in cases of partial construction. Any handler we added | 2425 // m_style is null in cases of partial construction. Any handler we added |
2426 // previously may have already been removed by the Document independently. | 2426 // previously may have already been removed by the Document independently. |
2427 if (node() && !node()->isTextNode() && m_style && m_style->touchAction() !=
TouchActionAuto) { | 2427 if (node() && !node()->isTextNode() && m_style && m_style->touchAction() !=
TouchActionAuto) { |
2428 EventHandlerRegistry& registry = document().frameHost()->eventHandlerReg
istry(); | 2428 EventHandlerRegistry& registry = document().frameHost()->eventHandlerReg
istry(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2483 if (!layer) | 2483 if (!layer) |
2484 layer = parent()->enclosingLayer(); | 2484 layer = parent()->enclosingLayer(); |
2485 removeLayers(layer); | 2485 removeLayers(layer); |
2486 } | 2486 } |
2487 | 2487 |
2488 if (isOutOfFlowPositioned() && parent()->childrenInline()) | 2488 if (isOutOfFlowPositioned() && parent()->childrenInline()) |
2489 parent()->dirtyLinesFromChangedChild(this); | 2489 parent()->dirtyLinesFromChangedChild(this); |
2490 | 2490 |
2491 removeFromLayoutFlowThread(); | 2491 removeFromLayoutFlowThread(); |
2492 | 2492 |
2493 // Update cached boundaries in SVG renderers if a child is removed. | 2493 // Update cached boundaries in SVG layoutObjects if a child is removed. |
2494 if (parent()->isSVG()) | 2494 if (parent()->isSVG()) |
2495 parent()->setNeedsBoundariesUpdate(); | 2495 parent()->setNeedsBoundariesUpdate(); |
2496 } | 2496 } |
2497 | 2497 |
2498 void LayoutObject::removeFromLayoutFlowThread() | 2498 void LayoutObject::removeFromLayoutFlowThread() |
2499 { | 2499 { |
2500 if (flowThreadState() == NotInsideFlowThread) | 2500 if (flowThreadState() == NotInsideFlowThread) |
2501 return; | 2501 return; |
2502 | 2502 |
2503 // Sometimes we remove the element from the flow, but it's not destroyed at
that time. | 2503 // Sometimes we remove the element from the flow, but it's not destroyed at
that time. |
2504 // It's only until later when we actually destroy it and remove all the chil
dren from it. | 2504 // It's only until later when we actually destroy it and remove all the chil
dren from it. |
2505 // Currently, that happens for firstLetter elements and list markers. | 2505 // Currently, that happens for firstLetter elements and list markers. |
2506 // Pass in the flow thread so that we don't have to look it up for all the c
hildren. | 2506 // Pass in the flow thread so that we don't have to look it up for all the c
hildren. |
2507 // If we're a column spanner, we need to use our parent to find the flow thr
ead, since a spanner | 2507 // If we're a column spanner, we need to use our parent to find the flow thr
ead, since a spanner |
2508 // doesn't have the flow thread in its containing block chain. We still need
to notify the flow | 2508 // doesn't have the flow thread in its containing block chain. We still need
to notify the flow |
2509 // thread when the renderer removed happens to be a spanner, so that we get
rid of the spanner | 2509 // thread when the layoutObject removed happens to be a spanner, so that we
get rid of the spanner |
2510 // placeholder, and column sets around the placeholder get merged. | 2510 // placeholder, and column sets around the placeholder get merged. |
2511 LayoutFlowThread* flowThread = isColumnSpanAll() ? parent()->flowThreadConta
iningBlock() : flowThreadContainingBlock(); | 2511 LayoutFlowThread* flowThread = isColumnSpanAll() ? parent()->flowThreadConta
iningBlock() : flowThreadContainingBlock(); |
2512 removeFromLayoutFlowThreadRecursive(flowThread); | 2512 removeFromLayoutFlowThreadRecursive(flowThread); |
2513 } | 2513 } |
2514 | 2514 |
2515 void LayoutObject::removeFromLayoutFlowThreadRecursive(LayoutFlowThread* renderF
lowThread) | 2515 void LayoutObject::removeFromLayoutFlowThreadRecursive(LayoutFlowThread* layoutF
lowThread) |
2516 { | 2516 { |
2517 if (const LayoutObjectChildList* children = virtualChildren()) { | 2517 if (const LayoutObjectChildList* children = virtualChildren()) { |
2518 for (LayoutObject* child = children->firstChild(); child; child = child-
>nextSibling()) { | 2518 for (LayoutObject* child = children->firstChild(); child; child = child-
>nextSibling()) { |
2519 if (child->isLayoutFlowThread()) | 2519 if (child->isLayoutFlowThread()) |
2520 continue; // Don't descend into inner fragmentation contexts. | 2520 continue; // Don't descend into inner fragmentation contexts. |
2521 child->removeFromLayoutFlowThreadRecursive(child->isLayoutFlowThread
() ? toLayoutFlowThread(child) : renderFlowThread); | 2521 child->removeFromLayoutFlowThreadRecursive(child->isLayoutFlowThread
() ? toLayoutFlowThread(child) : layoutFlowThread); |
2522 } | 2522 } |
2523 } | 2523 } |
2524 | 2524 |
2525 if (renderFlowThread && renderFlowThread != this) | 2525 if (layoutFlowThread && layoutFlowThread != this) |
2526 renderFlowThread->flowThreadDescendantWillBeRemoved(this); | 2526 layoutFlowThread->flowThreadDescendantWillBeRemoved(this); |
2527 setFlowThreadState(NotInsideFlowThread); | 2527 setFlowThreadState(NotInsideFlowThread); |
2528 RELEASE_ASSERT(!spannerPlaceholder()); | 2528 RELEASE_ASSERT(!spannerPlaceholder()); |
2529 } | 2529 } |
2530 | 2530 |
2531 void LayoutObject::destroyAndCleanupAnonymousWrappers() | 2531 void LayoutObject::destroyAndCleanupAnonymousWrappers() |
2532 { | 2532 { |
2533 // If the tree is destroyed, there is no need for a clean-up phase. | 2533 // If the tree is destroyed, there is no need for a clean-up phase. |
2534 if (documentBeingDestroyed()) { | 2534 if (documentBeingDestroyed()) { |
2535 destroy(); | 2535 destroy(); |
2536 return; | 2536 return; |
2537 } | 2537 } |
2538 | 2538 |
2539 LayoutObject* destroyRoot = this; | 2539 LayoutObject* destroyRoot = this; |
2540 for (LayoutObject* destroyRootParent = destroyRoot->parent(); destroyRootPar
ent && destroyRootParent->isAnonymous(); destroyRoot = destroyRootParent, destro
yRootParent = destroyRootParent->parent()) { | 2540 for (LayoutObject* destroyRootParent = destroyRoot->parent(); destroyRootPar
ent && destroyRootParent->isAnonymous(); destroyRoot = destroyRootParent, destro
yRootParent = destroyRootParent->parent()) { |
2541 // Anonymous block continuations are tracked and destroyed elsewhere (se
e the bottom of LayoutBlock::removeChild) | 2541 // Anonymous block continuations are tracked and destroyed elsewhere (se
e the bottom of LayoutBlock::removeChild) |
2542 if (destroyRootParent->isLayoutBlock() && toLayoutBlock(destroyRootParen
t)->isAnonymousBlockContinuation()) | 2542 if (destroyRootParent->isLayoutBlock() && toLayoutBlock(destroyRootParen
t)->isAnonymousBlockContinuation()) |
2543 break; | 2543 break; |
2544 // A flow thread is tracked by its containing block. Whether its childre
n are removed or not is irrelevant. | 2544 // A flow thread is tracked by its containing block. Whether its childre
n are removed or not is irrelevant. |
2545 if (destroyRootParent->isLayoutFlowThread()) | 2545 if (destroyRootParent->isLayoutFlowThread()) |
2546 break; | 2546 break; |
2547 // Column spans are tracked elsewhere. | 2547 // Column spans are tracked elsewhere. |
2548 if (destroyRootParent->isAnonymousColumnSpanBlock()) | 2548 if (destroyRootParent->isAnonymousColumnSpanBlock()) |
2549 break; | 2549 break; |
2550 | 2550 |
2551 if (destroyRootParent->slowFirstChild() != destroyRoot || destroyRootPar
ent->slowLastChild() != destroyRoot) | 2551 if (destroyRootParent->slowFirstChild() != destroyRoot || destroyRootPar
ent->slowLastChild() != destroyRoot) |
2552 break; // Need to keep the anonymous parent, since it won't become e
mpty by the removal of this renderer. | 2552 break; // Need to keep the anonymous parent, since it won't become e
mpty by the removal of this layoutObject. |
2553 } | 2553 } |
2554 | 2554 |
2555 destroyRoot->destroy(); | 2555 destroyRoot->destroy(); |
2556 | 2556 |
2557 // WARNING: |this| is deleted here. | 2557 // WARNING: |this| is deleted here. |
2558 } | 2558 } |
2559 | 2559 |
2560 void LayoutObject::destroy() | 2560 void LayoutObject::destroy() |
2561 { | 2561 { |
2562 willBeDestroyed(); | 2562 willBeDestroyed(); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2649 return inside; | 2649 return inside; |
2650 } | 2650 } |
2651 | 2651 |
2652 void LayoutObject::updateHitTestResult(HitTestResult& result, const LayoutPoint&
point) | 2652 void LayoutObject::updateHitTestResult(HitTestResult& result, const LayoutPoint&
point) |
2653 { | 2653 { |
2654 if (result.innerNode()) | 2654 if (result.innerNode()) |
2655 return; | 2655 return; |
2656 | 2656 |
2657 Node* node = this->node(); | 2657 Node* node = this->node(); |
2658 | 2658 |
2659 // If we hit the anonymous renderers inside generated content we should | 2659 // If we hit the anonymous layoutObjects inside generated content we should |
2660 // actually hit the generated content so walk up to the PseudoElement. | 2660 // actually hit the generated content so walk up to the PseudoElement. |
2661 if (!node && parent() && parent()->isBeforeOrAfterContent()) { | 2661 if (!node && parent() && parent()->isBeforeOrAfterContent()) { |
2662 for (LayoutObject* renderer = parent(); renderer && !node; renderer = re
nderer->parent()) | 2662 for (LayoutObject* layoutObject = parent(); layoutObject && !node; layou
tObject = layoutObject->parent()) |
2663 node = renderer->node(); | 2663 node = layoutObject->node(); |
2664 } | 2664 } |
2665 | 2665 |
2666 if (node) { | 2666 if (node) { |
2667 result.setInnerNode(node); | 2667 result.setInnerNode(node); |
2668 result.setLocalPoint(point); | 2668 result.setLocalPoint(point); |
2669 } | 2669 } |
2670 } | 2670 } |
2671 | 2671 |
2672 bool LayoutObject::nodeAtPoint(HitTestResult&, const HitTestLocation& /*location
InContainer*/, const LayoutPoint& /*accumulatedOffset*/, HitTestAction) | 2672 bool LayoutObject::nodeAtPoint(HitTestResult&, const HitTestLocation& /*location
InContainer*/, const LayoutPoint& /*accumulatedOffset*/, HitTestAction) |
2673 { | 2673 { |
(...skipping 29 matching lines...) Expand all Loading... |
2703 { | 2703 { |
2704 setNormalChildNeedsLayout(true); | 2704 setNormalChildNeedsLayout(true); |
2705 layout(); | 2705 layout(); |
2706 } | 2706 } |
2707 | 2707 |
2708 enum StyleCacheState { | 2708 enum StyleCacheState { |
2709 Cached, | 2709 Cached, |
2710 Uncached | 2710 Uncached |
2711 }; | 2711 }; |
2712 | 2712 |
2713 static PassRefPtr<ComputedStyle> firstLineStyleForCachedUncachedType(StyleCacheS
tate type, const LayoutObject* renderer, ComputedStyle* style) | 2713 static PassRefPtr<ComputedStyle> firstLineStyleForCachedUncachedType(StyleCacheS
tate type, const LayoutObject* layoutObject, ComputedStyle* style) |
2714 { | 2714 { |
2715 const LayoutObject* rendererForFirstLineStyle = renderer; | 2715 const LayoutObject* layoutObjectForFirstLineStyle = layoutObject; |
2716 if (renderer->isBeforeOrAfterContent()) | 2716 if (layoutObject->isBeforeOrAfterContent()) |
2717 rendererForFirstLineStyle = renderer->parent(); | 2717 layoutObjectForFirstLineStyle = layoutObject->parent(); |
2718 | 2718 |
2719 if (rendererForFirstLineStyle->isLayoutBlockFlow() || rendererForFirstLineSt
yle->isLayoutButton()) { | 2719 if (layoutObjectForFirstLineStyle->isLayoutBlockFlow() || layoutObjectForFir
stLineStyle->isLayoutButton()) { |
2720 if (LayoutBlock* firstLineBlock = rendererForFirstLineStyle->firstLineBl
ock()) { | 2720 if (LayoutBlock* firstLineBlock = layoutObjectForFirstLineStyle->firstLi
neBlock()) { |
2721 if (type == Cached) | 2721 if (type == Cached) |
2722 return firstLineBlock->getCachedPseudoStyle(FIRST_LINE, style); | 2722 return firstLineBlock->getCachedPseudoStyle(FIRST_LINE, style); |
2723 return firstLineBlock->getUncachedPseudoStyle(PseudoStyleRequest(FIR
ST_LINE), style, firstLineBlock == renderer ? style : 0); | 2723 return firstLineBlock->getUncachedPseudoStyle(PseudoStyleRequest(FIR
ST_LINE), style, firstLineBlock == layoutObject ? style : 0); |
2724 } | 2724 } |
2725 } else if (!rendererForFirstLineStyle->isAnonymous() && rendererForFirstLine
Style->isLayoutInline() | 2725 } else if (!layoutObjectForFirstLineStyle->isAnonymous() && layoutObjectForF
irstLineStyle->isLayoutInline() |
2726 && !rendererForFirstLineStyle->node()->isFirstLetterPseudoElement()) { | 2726 && !layoutObjectForFirstLineStyle->node()->isFirstLetterPseudoElement())
{ |
2727 const ComputedStyle* parentStyle = rendererForFirstLineStyle->parent()->
firstLineStyle(); | 2727 const ComputedStyle* parentStyle = layoutObjectForFirstLineStyle->parent
()->firstLineStyle(); |
2728 if (parentStyle != rendererForFirstLineStyle->parent()->style()) { | 2728 if (parentStyle != layoutObjectForFirstLineStyle->parent()->style()) { |
2729 if (type == Cached) { | 2729 if (type == Cached) { |
2730 // A first-line style is in effect. Cache a first-line style for
ourselves. | 2730 // A first-line style is in effect. Cache a first-line style for
ourselves. |
2731 rendererForFirstLineStyle->mutableStyleRef().setHasPseudoStyle(F
IRST_LINE_INHERITED); | 2731 layoutObjectForFirstLineStyle->mutableStyleRef().setHasPseudoSty
le(FIRST_LINE_INHERITED); |
2732 return rendererForFirstLineStyle->getCachedPseudoStyle(FIRST_LIN
E_INHERITED, parentStyle); | 2732 return layoutObjectForFirstLineStyle->getCachedPseudoStyle(FIRST
_LINE_INHERITED, parentStyle); |
2733 } | 2733 } |
2734 return rendererForFirstLineStyle->getUncachedPseudoStyle(PseudoStyle
Request(FIRST_LINE_INHERITED), parentStyle, style); | 2734 return layoutObjectForFirstLineStyle->getUncachedPseudoStyle(PseudoS
tyleRequest(FIRST_LINE_INHERITED), parentStyle, style); |
2735 } | 2735 } |
2736 } | 2736 } |
2737 return nullptr; | 2737 return nullptr; |
2738 } | 2738 } |
2739 | 2739 |
2740 PassRefPtr<ComputedStyle> LayoutObject::uncachedFirstLineStyle(ComputedStyle* st
yle) const | 2740 PassRefPtr<ComputedStyle> LayoutObject::uncachedFirstLineStyle(ComputedStyle* st
yle) const |
2741 { | 2741 { |
2742 if (!document().styleEngine().usesFirstLineRules()) | 2742 if (!document().styleEngine().usesFirstLineRules()) |
2743 return nullptr; | 2743 return nullptr; |
2744 | 2744 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2885 FloatRect absBounds = localToAbsoluteQuad(localBounds).boundingBox(); | 2885 FloatRect absBounds = localToAbsoluteQuad(localBounds).boundingBox(); |
2886 | 2886 |
2887 AnnotatedRegionValue region; | 2887 AnnotatedRegionValue region; |
2888 region.draggable = style()->getDraggableRegionMode() == DraggableRegionDrag; | 2888 region.draggable = style()->getDraggableRegionMode() == DraggableRegionDrag; |
2889 region.bounds = LayoutRect(absBounds); | 2889 region.bounds = LayoutRect(absBounds); |
2890 regions.append(region); | 2890 regions.append(region); |
2891 } | 2891 } |
2892 | 2892 |
2893 void LayoutObject::collectAnnotatedRegions(Vector<AnnotatedRegionValue>& regions
) | 2893 void LayoutObject::collectAnnotatedRegions(Vector<AnnotatedRegionValue>& regions
) |
2894 { | 2894 { |
2895 // RenderTexts don't have their own style, they just use their parent's styl
e, | 2895 // LayoutTexts don't have their own style, they just use their parent's styl
e, |
2896 // so we don't want to include them. | 2896 // so we don't want to include them. |
2897 if (isText()) | 2897 if (isText()) |
2898 return; | 2898 return; |
2899 | 2899 |
2900 addAnnotatedRegions(regions); | 2900 addAnnotatedRegions(regions); |
2901 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextSibling()
) | 2901 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextSibling()
) |
2902 curr->collectAnnotatedRegions(regions); | 2902 curr->collectAnnotatedRegions(regions); |
2903 } | 2903 } |
2904 | 2904 |
2905 bool LayoutObject::willRenderImage(ImageResource*) | 2905 bool LayoutObject::willRenderImage(ImageResource*) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2950 return current - 1; | 2950 return current - 1; |
2951 } | 2951 } |
2952 | 2952 |
2953 int LayoutObject::nextOffset(int current) const | 2953 int LayoutObject::nextOffset(int current) const |
2954 { | 2954 { |
2955 return current + 1; | 2955 return current + 1; |
2956 } | 2956 } |
2957 | 2957 |
2958 bool LayoutObject::isInert() const | 2958 bool LayoutObject::isInert() const |
2959 { | 2959 { |
2960 const LayoutObject* renderer = this; | 2960 const LayoutObject* layoutObject = this; |
2961 while (!renderer->node()) | 2961 while (!layoutObject->node()) |
2962 renderer = renderer->parent(); | 2962 layoutObject = layoutObject->parent(); |
2963 return renderer->node()->isInert(); | 2963 return layoutObject->node()->isInert(); |
2964 } | 2964 } |
2965 | 2965 |
2966 // touch-action applies to all elements with both width AND height properties. | 2966 // touch-action applies to all elements with both width AND height properties. |
2967 // According to the CSS Box Model Spec (http://dev.w3.org/csswg/css-box/#the-wid
th-and-height-properties) | 2967 // According to the CSS Box Model Spec (http://dev.w3.org/csswg/css-box/#the-wid
th-and-height-properties) |
2968 // width applies to all elements but non-replaced inline elements, table rows, a
nd row groups and | 2968 // width applies to all elements but non-replaced inline elements, table rows, a
nd row groups and |
2969 // height applies to all elements but non-replaced inline elements, table column
s, and column groups. | 2969 // height applies to all elements but non-replaced inline elements, table column
s, and column groups. |
2970 bool LayoutObject::supportsTouchAction() const | 2970 bool LayoutObject::supportsTouchAction() const |
2971 { | 2971 { |
2972 if (isInline() && !isReplaced()) | 2972 if (isInline() && !isReplaced()) |
2973 return false; | 2973 return false; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3012 // Webkit specific extension where offsetParent stops at zoom level chan
ges. | 3012 // Webkit specific extension where offsetParent stops at zoom level chan
ges. |
3013 if (effectiveZoom != ancestor->style()->effectiveZoom()) | 3013 if (effectiveZoom != ancestor->style()->effectiveZoom()) |
3014 break; | 3014 break; |
3015 } | 3015 } |
3016 | 3016 |
3017 return node && node->isElementNode() ? toElement(node) : 0; | 3017 return node && node->isElementNode() ? toElement(node) : 0; |
3018 } | 3018 } |
3019 | 3019 |
3020 PositionWithAffinity LayoutObject::createPositionWithAffinity(int offset, EAffin
ity affinity) | 3020 PositionWithAffinity LayoutObject::createPositionWithAffinity(int offset, EAffin
ity affinity) |
3021 { | 3021 { |
3022 // If this is a non-anonymous renderer in an editable area, then it's simple
. | 3022 // If this is a non-anonymous layoutObject in an editable area, then it's si
mple. |
3023 if (Node* node = nonPseudoNode()) { | 3023 if (Node* node = nonPseudoNode()) { |
3024 if (!node->hasEditableStyle()) { | 3024 if (!node->hasEditableStyle()) { |
3025 // If it can be found, we prefer a visually equivalent position that
is editable. | 3025 // If it can be found, we prefer a visually equivalent position that
is editable. |
3026 Position position = createLegacyEditingPosition(node, offset); | 3026 Position position = createLegacyEditingPosition(node, offset); |
3027 Position candidate = position.downstream(CanCrossEditingBoundary); | 3027 Position candidate = position.downstream(CanCrossEditingBoundary); |
3028 if (candidate.deprecatedNode()->hasEditableStyle()) | 3028 if (candidate.deprecatedNode()->hasEditableStyle()) |
3029 return PositionWithAffinity(candidate, affinity); | 3029 return PositionWithAffinity(candidate, affinity); |
3030 candidate = position.upstream(CanCrossEditingBoundary); | 3030 candidate = position.upstream(CanCrossEditingBoundary); |
3031 if (candidate.deprecatedNode()->hasEditableStyle()) | 3031 if (candidate.deprecatedNode()->hasEditableStyle()) |
3032 return PositionWithAffinity(candidate, affinity); | 3032 return PositionWithAffinity(candidate, affinity); |
3033 } | 3033 } |
3034 // FIXME: Eliminate legacy editing positions | 3034 // FIXME: Eliminate legacy editing positions |
3035 return PositionWithAffinity(createLegacyEditingPosition(node, offset), a
ffinity); | 3035 return PositionWithAffinity(createLegacyEditingPosition(node, offset), a
ffinity); |
3036 } | 3036 } |
3037 | 3037 |
3038 // We don't want to cross the boundary between editable and non-editable | 3038 // We don't want to cross the boundary between editable and non-editable |
3039 // regions of the document, but that is either impossible or at least | 3039 // regions of the document, but that is either impossible or at least |
3040 // extremely unlikely in any normal case because we stop as soon as we | 3040 // extremely unlikely in any normal case because we stop as soon as we |
3041 // find a single non-anonymous renderer. | 3041 // find a single non-anonymous layoutObject. |
3042 | 3042 |
3043 // Find a nearby non-anonymous renderer. | 3043 // Find a nearby non-anonymous layoutObject. |
3044 LayoutObject* child = this; | 3044 LayoutObject* child = this; |
3045 while (LayoutObject* parent = child->parent()) { | 3045 while (LayoutObject* parent = child->parent()) { |
3046 // Find non-anonymous content after. | 3046 // Find non-anonymous content after. |
3047 for (LayoutObject* renderer = child->nextInPreOrder(parent); renderer; r
enderer = renderer->nextInPreOrder(parent)) { | 3047 for (LayoutObject* layoutObject = child->nextInPreOrder(parent); layoutO
bject; layoutObject = layoutObject->nextInPreOrder(parent)) { |
3048 if (Node* node = renderer->nonPseudoNode()) | 3048 if (Node* node = layoutObject->nonPseudoNode()) |
3049 return PositionWithAffinity(firstPositionInOrBeforeNode(node), D
OWNSTREAM); | 3049 return PositionWithAffinity(firstPositionInOrBeforeNode(node), D
OWNSTREAM); |
3050 } | 3050 } |
3051 | 3051 |
3052 // Find non-anonymous content before. | 3052 // Find non-anonymous content before. |
3053 for (LayoutObject* renderer = child->previousInPreOrder(); renderer; ren
derer = renderer->previousInPreOrder()) { | 3053 for (LayoutObject* layoutObject = child->previousInPreOrder(); layoutObj
ect; layoutObject = layoutObject->previousInPreOrder()) { |
3054 if (renderer == parent) | 3054 if (layoutObject == parent) |
3055 break; | 3055 break; |
3056 if (Node* node = renderer->nonPseudoNode()) | 3056 if (Node* node = layoutObject->nonPseudoNode()) |
3057 return PositionWithAffinity(lastPositionInOrAfterNode(node), DOW
NSTREAM); | 3057 return PositionWithAffinity(lastPositionInOrAfterNode(node), DOW
NSTREAM); |
3058 } | 3058 } |
3059 | 3059 |
3060 // Use the parent itself unless it too is anonymous. | 3060 // Use the parent itself unless it too is anonymous. |
3061 if (Node* node = parent->nonPseudoNode()) | 3061 if (Node* node = parent->nonPseudoNode()) |
3062 return PositionWithAffinity(firstPositionInOrBeforeNode(node), DOWNS
TREAM); | 3062 return PositionWithAffinity(firstPositionInOrBeforeNode(node), DOWNS
TREAM); |
3063 | 3063 |
3064 // Repeat at the next level up. | 3064 // Repeat at the next level up. |
3065 child = parent; | 3065 child = parent; |
3066 } | 3066 } |
(...skipping 20 matching lines...) Expand all Loading... |
3087 { | 3087 { |
3088 if (needsLayout()) | 3088 if (needsLayout()) |
3089 return false; | 3089 return false; |
3090 | 3090 |
3091 const LayoutBlock* containingBlock = this->containingBlock(); | 3091 const LayoutBlock* containingBlock = this->containingBlock(); |
3092 return containingBlock ? !containingBlock->needsLayout() : false; | 3092 return containingBlock ? !containingBlock->needsLayout() : false; |
3093 } | 3093 } |
3094 | 3094 |
3095 void LayoutObject::setNeedsBoundariesUpdate() | 3095 void LayoutObject::setNeedsBoundariesUpdate() |
3096 { | 3096 { |
3097 if (LayoutObject* renderer = parent()) | 3097 if (LayoutObject* layoutObject = parent()) |
3098 renderer->setNeedsBoundariesUpdate(); | 3098 layoutObject->setNeedsBoundariesUpdate(); |
3099 } | 3099 } |
3100 | 3100 |
3101 FloatRect LayoutObject::objectBoundingBox() const | 3101 FloatRect LayoutObject::objectBoundingBox() const |
3102 { | 3102 { |
3103 ASSERT_NOT_REACHED(); | 3103 ASSERT_NOT_REACHED(); |
3104 return FloatRect(); | 3104 return FloatRect(); |
3105 } | 3105 } |
3106 | 3106 |
3107 FloatRect LayoutObject::strokeBoundingBox() const | 3107 FloatRect LayoutObject::strokeBoundingBox() const |
3108 { | 3108 { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3222 // booleans that are cleared below. | 3222 // booleans that are cleared below. |
3223 ASSERT(paintInvalidationState.forceCheckForPaintInvalidation() || paintInval
idationStateIsDirty()); | 3223 ASSERT(paintInvalidationState.forceCheckForPaintInvalidation() || paintInval
idationStateIsDirty()); |
3224 clearShouldDoFullPaintInvalidation(); | 3224 clearShouldDoFullPaintInvalidation(); |
3225 setNeededLayoutBecauseOfChildren(false); | 3225 setNeededLayoutBecauseOfChildren(false); |
3226 setShouldInvalidateOverflowForPaint(false); | 3226 setShouldInvalidateOverflowForPaint(false); |
3227 clearLayoutDidGetCalledSinceLastFrame(); | 3227 clearLayoutDidGetCalledSinceLastFrame(); |
3228 clearMayNeedPaintInvalidation(); | 3228 clearMayNeedPaintInvalidation(); |
3229 clearShouldInvalidateSelection(); | 3229 clearShouldInvalidateSelection(); |
3230 } | 3230 } |
3231 | 3231 |
3232 bool LayoutObject::isAllowedToModifyRenderTreeStructure(Document& document) | 3232 bool LayoutObject::isAllowedToModifyLayoutTreeStructure(Document& document) |
3233 { | 3233 { |
3234 return DeprecatedDisableModifyRenderTreeStructureAsserts::canModifyRenderTre
eStateInAnyState() | 3234 return DeprecatedDisableModifyLayoutTreeStructureAsserts::canModifyLayoutTre
eStateInAnyState() |
3235 || document.lifecycle().stateAllowsRenderTreeMutations(); | 3235 || document.lifecycle().stateAllowsLayoutTreeMutations(); |
3236 } | 3236 } |
3237 | 3237 |
3238 DeprecatedDisableModifyRenderTreeStructureAsserts::DeprecatedDisableModifyRender
TreeStructureAsserts() | 3238 DeprecatedDisableModifyLayoutTreeStructureAsserts::DeprecatedDisableModifyLayout
TreeStructureAsserts() |
3239 : m_disabler(gModifyRenderTreeStructureAnyState, true) | 3239 : m_disabler(gModifyLayoutTreeStructureAnyState, true) |
3240 { | 3240 { |
3241 } | 3241 } |
3242 | 3242 |
3243 bool DeprecatedDisableModifyRenderTreeStructureAsserts::canModifyRenderTreeState
InAnyState() | 3243 bool DeprecatedDisableModifyLayoutTreeStructureAsserts::canModifyLayoutTreeState
InAnyState() |
3244 { | 3244 { |
3245 return gModifyRenderTreeStructureAnyState; | 3245 return gModifyLayoutTreeStructureAnyState; |
3246 } | 3246 } |
3247 | 3247 |
3248 DisablePaintInvalidationStateAsserts::DisablePaintInvalidationStateAsserts() | 3248 DisablePaintInvalidationStateAsserts::DisablePaintInvalidationStateAsserts() |
3249 : m_disabler(gDisablePaintInvalidationStateAsserts, true) | 3249 : m_disabler(gDisablePaintInvalidationStateAsserts, true) |
3250 { | 3250 { |
3251 } | 3251 } |
3252 | 3252 |
3253 // Since we're only painting non-composited layers, we know that they all share
the same paintInvalidationContainer. | 3253 // Since we're only painting non-composited layers, we know that they all share
the same paintInvalidationContainer. |
3254 void LayoutObject::invalidatePaintIncludingNonCompositingDescendants() | 3254 void LayoutObject::invalidatePaintIncludingNonCompositingDescendants() |
3255 { | 3255 { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3294 { | 3294 { |
3295 if (object1) { | 3295 if (object1) { |
3296 const blink::LayoutObject* root = object1; | 3296 const blink::LayoutObject* root = object1; |
3297 while (root->parent()) | 3297 while (root->parent()) |
3298 root = root->parent(); | 3298 root = root->parent(); |
3299 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); | 3299 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); |
3300 } | 3300 } |
3301 } | 3301 } |
3302 | 3302 |
3303 #endif | 3303 #endif |
OLD | NEW |