Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/LayoutObject.cpp |
| diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.cpp b/third_party/WebKit/Source/core/layout/LayoutObject.cpp |
| index c2580420c02f4c091e01ae0b105f340926273b41..fa07279c839bc96a83e13dd6d00cfd45b7f228b4 100644 |
| --- a/third_party/WebKit/Source/core/layout/LayoutObject.cpp |
| +++ b/third_party/WebKit/Source/core/layout/LayoutObject.cpp |
| @@ -1893,6 +1893,7 @@ void LayoutObject::setStyle(PassRefPtr<ComputedStyle> style) |
| updateImage(oldBoxReflectMaskImage, newBoxReflectMaskImage); |
| updateShapeImage(oldStyle ? oldStyle->shapeOutside() : 0, m_style->shapeOutside()); |
| + updateCursorImages(oldStyle ? oldStyle->cursors() : nullptr, m_style->cursors()); |
| bool doesNotNeedLayoutOrPaintInvalidation = !m_parent; |
| @@ -2117,6 +2118,26 @@ void LayoutObject::updateFillImages(const FillLayer* oldLayers, const FillLayer& |
| } |
| } |
| +void LayoutObject::updateCursorImages(const CursorList* oldCursors, const CursorList* newCursors) |
| +{ |
| + if (oldCursors && newCursors && *oldCursors == *newCursors) |
| + return; |
| + |
| + if (newCursors) { |
| + for (const CursorData& cursorNew : *newCursors) { |
| + if (cursorNew.image()) |
| + cursorNew.image()->addClient(this); |
| + } |
| + } |
| + |
| + if (oldCursors) { |
| + for (const CursorData& cursorOld : *oldCursors) { |
|
dtapuska
2016/07/08 18:35:57
Can you just call removeCursorImageClient here?
chongz
2016/07/11 17:31:56
Done.
|
| + if (cursorOld.image()) |
| + cursorOld.image()->removeClient(this); |
| + } |
| + } |
| +} |
| + |
| void LayoutObject::updateImage(StyleImage* oldImage, StyleImage* newImage) |
| { |
| if (oldImage != newImage) { |
| @@ -2646,6 +2667,7 @@ void LayoutObject::willBeDestroyed() |
| m_style->boxReflect()->mask().image()->removeClient(this); |
| removeShapeImageClient(m_style->shapeOutside()); |
| + removeCursorImageClient(m_style->cursors()); |
| } |
| if (frameView()) |
| @@ -2831,6 +2853,16 @@ void LayoutObject::removeShapeImageClient(ShapeValue* shapeValue) |
| shapeImage->removeClient(this); |
| } |
| +void LayoutObject::removeCursorImageClient(const CursorList* cursorList) |
| +{ |
| + if (!cursorList) |
| + return; |
| + for (const CursorData& cursor : *cursorList) { |
| + if (cursor.image()) |
| + cursor.image()->removeClient(this); |
| + } |
| +} |
| + |
| PositionWithAffinity LayoutObject::positionForPoint(const LayoutPoint&) |
| { |
| return createPositionWithAffinity(caretMinOffset()); |
| @@ -3176,6 +3208,20 @@ void LayoutObject::imageChanged(ImageResource* image, const IntRect* rect) |
| // lead to modifying the tree out from under paint(), see: crbug.com/616700. |
| DCHECK(document().lifecycle().state() != DocumentLifecycle::LifecycleState::InPaint); |
| + if (const CursorList* cursors = style()->cursors()) { |
| + for (const CursorData& cursor : *cursors) { |
| + if (cursor.image() && cursor.image()->cachedImage() == image) { |
| + if (LocalFrame* frame = this->frame()) { |
| + // Cursor update scheduling is done by the local root, which is the main frame if there |
| + // are no RemoteFrame ancestors in the frame tree. Use of localFrameRoot() is |
| + // discouraged but will change when cursor update scheduling is moved from EventHandler |
| + // to PageEventHandler. |
| + frame->localFrameRoot()->eventHandler().scheduleCursorUpdate(); |
| + } |
| + } |
| + } |
| + } |
| + |
| imageChanged(static_cast<WrappedImagePtr>(image), rect); |
| } |