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 * (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 1875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1886 toImageContentData(m_style->contentData())->image() : nullptr; | 1886 toImageContentData(m_style->contentData())->image() : nullptr; |
| 1887 StyleImage* oldContentImage = oldStyle && oldStyle->contentData() && oldStyl e->contentData()->isImage() ? | 1887 StyleImage* oldContentImage = oldStyle && oldStyle->contentData() && oldStyl e->contentData()->isImage() ? |
| 1888 toImageContentData(oldStyle->contentData())->image() : nullptr; | 1888 toImageContentData(oldStyle->contentData())->image() : nullptr; |
| 1889 updateImage(oldContentImage, newContentImage); | 1889 updateImage(oldContentImage, newContentImage); |
| 1890 | 1890 |
| 1891 StyleImage* newBoxReflectMaskImage = m_style->boxReflect() ? m_style->boxRef lect()->mask().image() : nullptr; | 1891 StyleImage* newBoxReflectMaskImage = m_style->boxReflect() ? m_style->boxRef lect()->mask().image() : nullptr; |
| 1892 StyleImage* oldBoxReflectMaskImage = oldStyle && oldStyle->boxReflect() ? ol dStyle->boxReflect()->mask().image() : nullptr; | 1892 StyleImage* oldBoxReflectMaskImage = oldStyle && oldStyle->boxReflect() ? ol dStyle->boxReflect()->mask().image() : nullptr; |
| 1893 updateImage(oldBoxReflectMaskImage, newBoxReflectMaskImage); | 1893 updateImage(oldBoxReflectMaskImage, newBoxReflectMaskImage); |
| 1894 | 1894 |
| 1895 updateShapeImage(oldStyle ? oldStyle->shapeOutside() : 0, m_style->shapeOuts ide()); | 1895 updateShapeImage(oldStyle ? oldStyle->shapeOutside() : 0, m_style->shapeOuts ide()); |
| 1896 updateCursorImages(oldStyle ? oldStyle->cursors() : nullptr, m_style->cursor s()); | |
| 1896 | 1897 |
| 1897 bool doesNotNeedLayoutOrPaintInvalidation = !m_parent; | 1898 bool doesNotNeedLayoutOrPaintInvalidation = !m_parent; |
| 1898 | 1899 |
| 1899 styleDidChange(diff, oldStyle.get()); | 1900 styleDidChange(diff, oldStyle.get()); |
| 1900 | 1901 |
| 1901 // FIXME: |this| might be destroyed here. This can currently happen for a La youtTextFragment when | 1902 // FIXME: |this| might be destroyed here. This can currently happen for a La youtTextFragment when |
| 1902 // its first-letter block gets an update in LayoutTextFragment::styleDidChan ge. For LayoutTextFragment(s), | 1903 // its first-letter block gets an update in LayoutTextFragment::styleDidChan ge. For LayoutTextFragment(s), |
| 1903 // we will safely bail out with the doesNotNeedLayoutOrPaintInvalidation fla g. We might want to broaden | 1904 // we will safely bail out with the doesNotNeedLayoutOrPaintInvalidation fla g. We might want to broaden |
| 1904 // this condition in the future as we move layoutObject changes out of layou t and into style changes. | 1905 // this condition in the future as we move layoutObject changes out of layou t and into style changes. |
| 1905 if (doesNotNeedLayoutOrPaintInvalidation) | 1906 if (doesNotNeedLayoutOrPaintInvalidation) |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2110 if (currNew->image()) | 2111 if (currNew->image()) |
| 2111 currNew->image()->addClient(this); | 2112 currNew->image()->addClient(this); |
| 2112 } | 2113 } |
| 2113 | 2114 |
| 2114 for (const FillLayer* currOld = oldLayers; currOld; currOld = currOld->next( )) { | 2115 for (const FillLayer* currOld = oldLayers; currOld; currOld = currOld->next( )) { |
| 2115 if (currOld->image()) | 2116 if (currOld->image()) |
| 2116 currOld->image()->removeClient(this); | 2117 currOld->image()->removeClient(this); |
| 2117 } | 2118 } |
| 2118 } | 2119 } |
| 2119 | 2120 |
| 2121 void LayoutObject::updateCursorImages(const CursorList* oldCursors, const Cursor List* newCursors) | |
| 2122 { | |
| 2123 if (oldCursors && newCursors && *oldCursors == *newCursors) | |
| 2124 return; | |
| 2125 | |
| 2126 if (newCursors) { | |
| 2127 for (const CursorData& cursorNew : *newCursors) { | |
| 2128 if (cursorNew.image()) | |
| 2129 cursorNew.image()->addClient(this); | |
| 2130 } | |
| 2131 } | |
| 2132 | |
| 2133 if (oldCursors) { | |
| 2134 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.
| |
| 2135 if (cursorOld.image()) | |
| 2136 cursorOld.image()->removeClient(this); | |
| 2137 } | |
| 2138 } | |
| 2139 } | |
| 2140 | |
| 2120 void LayoutObject::updateImage(StyleImage* oldImage, StyleImage* newImage) | 2141 void LayoutObject::updateImage(StyleImage* oldImage, StyleImage* newImage) |
| 2121 { | 2142 { |
| 2122 if (oldImage != newImage) { | 2143 if (oldImage != newImage) { |
| 2123 if (oldImage) | 2144 if (oldImage) |
| 2124 oldImage->removeClient(this); | 2145 oldImage->removeClient(this); |
| 2125 if (newImage) | 2146 if (newImage) |
| 2126 newImage->addClient(this); | 2147 newImage->addClient(this); |
| 2127 } | 2148 } |
| 2128 } | 2149 } |
| 2129 | 2150 |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2639 if (StyleImage* maskBoxImage = m_style->maskBoxImage().image()) | 2660 if (StyleImage* maskBoxImage = m_style->maskBoxImage().image()) |
| 2640 maskBoxImage->removeClient(this); | 2661 maskBoxImage->removeClient(this); |
| 2641 | 2662 |
| 2642 if (m_style->contentData() && m_style->contentData()->isImage()) | 2663 if (m_style->contentData() && m_style->contentData()->isImage()) |
| 2643 toImageContentData(m_style->contentData())->image()->removeClient(th is); | 2664 toImageContentData(m_style->contentData())->image()->removeClient(th is); |
| 2644 | 2665 |
| 2645 if (m_style->boxReflect() && m_style->boxReflect()->mask().image()) | 2666 if (m_style->boxReflect() && m_style->boxReflect()->mask().image()) |
| 2646 m_style->boxReflect()->mask().image()->removeClient(this); | 2667 m_style->boxReflect()->mask().image()->removeClient(this); |
| 2647 | 2668 |
| 2648 removeShapeImageClient(m_style->shapeOutside()); | 2669 removeShapeImageClient(m_style->shapeOutside()); |
| 2670 removeCursorImageClient(m_style->cursors()); | |
| 2649 } | 2671 } |
| 2650 | 2672 |
| 2651 if (frameView()) | 2673 if (frameView()) |
| 2652 setIsBackgroundAttachmentFixedObject(false); | 2674 setIsBackgroundAttachmentFixedObject(false); |
| 2653 } | 2675 } |
| 2654 | 2676 |
| 2655 void LayoutObject::insertedIntoTree() | 2677 void LayoutObject::insertedIntoTree() |
| 2656 { | 2678 { |
| 2657 // FIXME: We should ASSERT(isRooted()) here but generated content makes some out-of-order insertion. | 2679 // FIXME: We should ASSERT(isRooted()) here but generated content makes some out-of-order insertion. |
| 2658 | 2680 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2824 } | 2846 } |
| 2825 | 2847 |
| 2826 void LayoutObject::removeShapeImageClient(ShapeValue* shapeValue) | 2848 void LayoutObject::removeShapeImageClient(ShapeValue* shapeValue) |
| 2827 { | 2849 { |
| 2828 if (!shapeValue) | 2850 if (!shapeValue) |
| 2829 return; | 2851 return; |
| 2830 if (StyleImage* shapeImage = shapeValue->image()) | 2852 if (StyleImage* shapeImage = shapeValue->image()) |
| 2831 shapeImage->removeClient(this); | 2853 shapeImage->removeClient(this); |
| 2832 } | 2854 } |
| 2833 | 2855 |
| 2856 void LayoutObject::removeCursorImageClient(const CursorList* cursorList) | |
| 2857 { | |
| 2858 if (!cursorList) | |
| 2859 return; | |
| 2860 for (const CursorData& cursor : *cursorList) { | |
| 2861 if (cursor.image()) | |
| 2862 cursor.image()->removeClient(this); | |
| 2863 } | |
| 2864 } | |
| 2865 | |
| 2834 PositionWithAffinity LayoutObject::positionForPoint(const LayoutPoint&) | 2866 PositionWithAffinity LayoutObject::positionForPoint(const LayoutPoint&) |
| 2835 { | 2867 { |
| 2836 return createPositionWithAffinity(caretMinOffset()); | 2868 return createPositionWithAffinity(caretMinOffset()); |
| 2837 } | 2869 } |
| 2838 | 2870 |
| 2839 void LayoutObject::updateDragState(bool dragOn) | 2871 void LayoutObject::updateDragState(bool dragOn) |
| 2840 { | 2872 { |
| 2841 bool valueChanged = (dragOn != isDragging()); | 2873 bool valueChanged = (dragOn != isDragging()); |
| 2842 setIsDragging(dragOn); | 2874 setIsDragging(dragOn); |
| 2843 if (valueChanged && node()) { | 2875 if (valueChanged && node()) { |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3169 | 3201 |
| 3170 void LayoutObject::imageChanged(ImageResource* image, const IntRect* rect) | 3202 void LayoutObject::imageChanged(ImageResource* image, const IntRect* rect) |
| 3171 { | 3203 { |
| 3172 ASSERT(m_node); | 3204 ASSERT(m_node); |
| 3173 | 3205 |
| 3174 // Image change notifications should not be received during paint because | 3206 // Image change notifications should not be received during paint because |
| 3175 // the resulting invalidations will be cleared following paint. This can als o | 3207 // the resulting invalidations will be cleared following paint. This can als o |
| 3176 // lead to modifying the tree out from under paint(), see: crbug.com/616700. | 3208 // lead to modifying the tree out from under paint(), see: crbug.com/616700. |
| 3177 DCHECK(document().lifecycle().state() != DocumentLifecycle::LifecycleState:: InPaint); | 3209 DCHECK(document().lifecycle().state() != DocumentLifecycle::LifecycleState:: InPaint); |
| 3178 | 3210 |
| 3211 if (const CursorList* cursors = style()->cursors()) { | |
| 3212 for (const CursorData& cursor : *cursors) { | |
| 3213 if (cursor.image() && cursor.image()->cachedImage() == image) { | |
| 3214 if (LocalFrame* frame = this->frame()) { | |
| 3215 // Cursor update scheduling is done by the local root, which is the main frame if there | |
| 3216 // are no RemoteFrame ancestors in the frame tree. Use of lo calFrameRoot() is | |
| 3217 // discouraged but will change when cursor update scheduling is moved from EventHandler | |
| 3218 // to PageEventHandler. | |
| 3219 frame->localFrameRoot()->eventHandler().scheduleCursorUpdate (); | |
| 3220 } | |
| 3221 } | |
| 3222 } | |
| 3223 } | |
| 3224 | |
| 3179 imageChanged(static_cast<WrappedImagePtr>(image), rect); | 3225 imageChanged(static_cast<WrappedImagePtr>(image), rect); |
| 3180 } | 3226 } |
| 3181 | 3227 |
| 3182 Element* LayoutObject::offsetParent(const Element* unclosedBase) const | 3228 Element* LayoutObject::offsetParent(const Element* unclosedBase) const |
| 3183 { | 3229 { |
| 3184 if (isDocumentElement() || isBody()) | 3230 if (isDocumentElement() || isBody()) |
| 3185 return nullptr; | 3231 return nullptr; |
| 3186 | 3232 |
| 3187 if (isFixedPositioned()) | 3233 if (isFixedPositioned()) |
| 3188 return nullptr; | 3234 return nullptr; |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3646 const blink::LayoutObject* root = object1; | 3692 const blink::LayoutObject* root = object1; |
| 3647 while (root->parent()) | 3693 while (root->parent()) |
| 3648 root = root->parent(); | 3694 root = root->parent(); |
| 3649 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); | 3695 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); |
| 3650 } else { | 3696 } else { |
| 3651 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); | 3697 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); |
| 3652 } | 3698 } |
| 3653 } | 3699 } |
| 3654 | 3700 |
| 3655 #endif | 3701 #endif |
| OLD | NEW |