| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/paint/ObjectPaintInvalidator.h" | 5 #include "core/paint/ObjectPaintInvalidator.h" |
| 6 | 6 |
| 7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
| 8 #include "core/frame/LocalFrame.h" | 8 #include "core/frame/LocalFrame.h" |
| 9 #include "core/layout/LayoutView.h" | 9 #include "core/layout/LayoutView.h" |
| 10 #include "core/layout/api/LayoutPartItem.h" | 10 #include "core/layout/api/LayoutPartItem.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 DEFINE_STATIC_LOCAL(SelectionVisualRectMap, map, ()); | 23 DEFINE_STATIC_LOCAL(SelectionVisualRectMap, map, ()); |
| 24 return map; | 24 return map; |
| 25 } | 25 } |
| 26 | 26 |
| 27 static void setPreviousSelectionVisualRect(const LayoutObject& object, | 27 static void setPreviousSelectionVisualRect(const LayoutObject& object, |
| 28 const LayoutRect& rect) { | 28 const LayoutRect& rect) { |
| 29 DCHECK(object.hasPreviousSelectionVisualRect() == | 29 DCHECK(object.hasPreviousSelectionVisualRect() == |
| 30 selectionVisualRectMap().contains(&object)); | 30 selectionVisualRectMap().contains(&object)); |
| 31 if (rect.isEmpty()) { | 31 if (rect.isEmpty()) { |
| 32 if (object.hasPreviousSelectionVisualRect()) { | 32 if (object.hasPreviousSelectionVisualRect()) { |
| 33 selectionVisualRectMap().remove(&object); | 33 selectionVisualRectMap().erase(&object); |
| 34 object.getMutableForPainting().setHasPreviousSelectionVisualRect(false); | 34 object.getMutableForPainting().setHasPreviousSelectionVisualRect(false); |
| 35 } | 35 } |
| 36 } else { | 36 } else { |
| 37 selectionVisualRectMap().set(&object, rect); | 37 selectionVisualRectMap().set(&object, rect); |
| 38 object.getMutableForPainting().setHasPreviousSelectionVisualRect(true); | 38 object.getMutableForPainting().setHasPreviousSelectionVisualRect(true); |
| 39 } | 39 } |
| 40 } | 40 } |
| 41 | 41 |
| 42 typedef HashMap<const LayoutObject*, LayoutPoint> LocationInBackingMap; | 42 typedef HashMap<const LayoutObject*, LayoutPoint> LocationInBackingMap; |
| 43 static LocationInBackingMap& locationInBackingMap() { | 43 static LocationInBackingMap& locationInBackingMap() { |
| 44 DEFINE_STATIC_LOCAL(LocationInBackingMap, map, ()); | 44 DEFINE_STATIC_LOCAL(LocationInBackingMap, map, ()); |
| 45 return map; | 45 return map; |
| 46 } | 46 } |
| 47 | 47 |
| 48 void ObjectPaintInvalidator::objectWillBeDestroyed(const LayoutObject& object) { | 48 void ObjectPaintInvalidator::objectWillBeDestroyed(const LayoutObject& object) { |
| 49 DCHECK(object.hasPreviousSelectionVisualRect() == | 49 DCHECK(object.hasPreviousSelectionVisualRect() == |
| 50 selectionVisualRectMap().contains(&object)); | 50 selectionVisualRectMap().contains(&object)); |
| 51 if (object.hasPreviousSelectionVisualRect()) | 51 if (object.hasPreviousSelectionVisualRect()) |
| 52 selectionVisualRectMap().remove(&object); | 52 selectionVisualRectMap().erase(&object); |
| 53 | 53 |
| 54 DCHECK(object.hasPreviousLocationInBacking() == | 54 DCHECK(object.hasPreviousLocationInBacking() == |
| 55 locationInBackingMap().contains(&object)); | 55 locationInBackingMap().contains(&object)); |
| 56 if (object.hasPreviousLocationInBacking()) | 56 if (object.hasPreviousLocationInBacking()) |
| 57 locationInBackingMap().remove(&object); | 57 locationInBackingMap().erase(&object); |
| 58 } | 58 } |
| 59 | 59 |
| 60 using LayoutObjectTraversalFunctor = std::function<void(const LayoutObject&)>; | 60 using LayoutObjectTraversalFunctor = std::function<void(const LayoutObject&)>; |
| 61 | 61 |
| 62 static void traverseNonCompositingDescendantsInPaintOrder( | 62 static void traverseNonCompositingDescendantsInPaintOrder( |
| 63 const LayoutObject&, | 63 const LayoutObject&, |
| 64 const LayoutObjectTraversalFunctor&); | 64 const LayoutObjectTraversalFunctor&); |
| 65 | 65 |
| 66 static void | 66 static void |
| 67 traverseNonCompositingDescendantsBelongingToAncestorPaintInvalidationContainer( | 67 traverseNonCompositingDescendantsBelongingToAncestorPaintInvalidationContainer( |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 ? locationInBackingMap().get(&m_object) | 424 ? locationInBackingMap().get(&m_object) |
| 425 : m_object.previousVisualRect().location(); | 425 : m_object.previousVisualRect().location(); |
| 426 } | 426 } |
| 427 | 427 |
| 428 void ObjectPaintInvalidator::setPreviousLocationInBacking( | 428 void ObjectPaintInvalidator::setPreviousLocationInBacking( |
| 429 const LayoutPoint& location) { | 429 const LayoutPoint& location) { |
| 430 DCHECK(m_object.hasPreviousLocationInBacking() == | 430 DCHECK(m_object.hasPreviousLocationInBacking() == |
| 431 locationInBackingMap().contains(&m_object)); | 431 locationInBackingMap().contains(&m_object)); |
| 432 if (location == m_object.previousVisualRect().location()) { | 432 if (location == m_object.previousVisualRect().location()) { |
| 433 if (m_object.hasPreviousLocationInBacking()) { | 433 if (m_object.hasPreviousLocationInBacking()) { |
| 434 locationInBackingMap().remove(&m_object); | 434 locationInBackingMap().erase(&m_object); |
| 435 m_object.getMutableForPainting().setHasPreviousLocationInBacking(false); | 435 m_object.getMutableForPainting().setHasPreviousLocationInBacking(false); |
| 436 } | 436 } |
| 437 } else { | 437 } else { |
| 438 locationInBackingMap().set(&m_object, location); | 438 locationInBackingMap().set(&m_object, location); |
| 439 m_object.getMutableForPainting().setHasPreviousLocationInBacking(true); | 439 m_object.getMutableForPainting().setHasPreviousLocationInBacking(true); |
| 440 } | 440 } |
| 441 } | 441 } |
| 442 | 442 |
| 443 void ObjectPaintInvalidatorWithContext::fullyInvalidatePaint( | 443 void ObjectPaintInvalidatorWithContext::fullyInvalidatePaint( |
| 444 PaintInvalidationReason reason, | 444 PaintInvalidationReason reason, |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 | 604 |
| 605 m_context.paintingLayer->setNeedsRepaint(); | 605 m_context.paintingLayer->setNeedsRepaint(); |
| 606 m_object.invalidateDisplayItemClients(reason); | 606 m_object.invalidateDisplayItemClients(reason); |
| 607 return reason; | 607 return reason; |
| 608 } | 608 } |
| 609 | 609 |
| 610 DisablePaintInvalidationStateAsserts::DisablePaintInvalidationStateAsserts() | 610 DisablePaintInvalidationStateAsserts::DisablePaintInvalidationStateAsserts() |
| 611 : m_disabler(&gDisablePaintInvalidationStateAsserts, true) {} | 611 : m_disabler(&gDisablePaintInvalidationStateAsserts, true) {} |
| 612 | 612 |
| 613 } // namespace blink | 613 } // namespace blink |
| OLD | NEW |