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 removeCursorImageClient(oldCursors); | |
| 2133 } | |
| 2134 | |
| 2120 void LayoutObject::updateImage(StyleImage* oldImage, StyleImage* newImage) | 2135 void LayoutObject::updateImage(StyleImage* oldImage, StyleImage* newImage) |
| 2121 { | 2136 { |
| 2122 if (oldImage != newImage) { | 2137 if (oldImage != newImage) { |
| 2123 if (oldImage) | 2138 if (oldImage) |
| 2124 oldImage->removeClient(this); | 2139 oldImage->removeClient(this); |
| 2125 if (newImage) | 2140 if (newImage) |
| 2126 newImage->addClient(this); | 2141 newImage->addClient(this); |
| 2127 } | 2142 } |
| 2128 } | 2143 } |
| 2129 | 2144 |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2639 if (StyleImage* maskBoxImage = m_style->maskBoxImage().image()) | 2654 if (StyleImage* maskBoxImage = m_style->maskBoxImage().image()) |
| 2640 maskBoxImage->removeClient(this); | 2655 maskBoxImage->removeClient(this); |
| 2641 | 2656 |
| 2642 if (m_style->contentData() && m_style->contentData()->isImage()) | 2657 if (m_style->contentData() && m_style->contentData()->isImage()) |
| 2643 toImageContentData(m_style->contentData())->image()->removeClient(th is); | 2658 toImageContentData(m_style->contentData())->image()->removeClient(th is); |
| 2644 | 2659 |
| 2645 if (m_style->boxReflect() && m_style->boxReflect()->mask().image()) | 2660 if (m_style->boxReflect() && m_style->boxReflect()->mask().image()) |
| 2646 m_style->boxReflect()->mask().image()->removeClient(this); | 2661 m_style->boxReflect()->mask().image()->removeClient(this); |
| 2647 | 2662 |
| 2648 removeShapeImageClient(m_style->shapeOutside()); | 2663 removeShapeImageClient(m_style->shapeOutside()); |
| 2664 removeCursorImageClient(m_style->cursors()); | |
| 2649 } | 2665 } |
| 2650 | 2666 |
| 2651 if (frameView()) | 2667 if (frameView()) |
| 2652 setIsBackgroundAttachmentFixedObject(false); | 2668 setIsBackgroundAttachmentFixedObject(false); |
| 2653 } | 2669 } |
| 2654 | 2670 |
| 2655 void LayoutObject::insertedIntoTree() | 2671 void LayoutObject::insertedIntoTree() |
| 2656 { | 2672 { |
| 2657 // FIXME: We should ASSERT(isRooted()) here but generated content makes some out-of-order insertion. | 2673 // FIXME: We should ASSERT(isRooted()) here but generated content makes some out-of-order insertion. |
| 2658 | 2674 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2824 } | 2840 } |
| 2825 | 2841 |
| 2826 void LayoutObject::removeShapeImageClient(ShapeValue* shapeValue) | 2842 void LayoutObject::removeShapeImageClient(ShapeValue* shapeValue) |
| 2827 { | 2843 { |
| 2828 if (!shapeValue) | 2844 if (!shapeValue) |
| 2829 return; | 2845 return; |
| 2830 if (StyleImage* shapeImage = shapeValue->image()) | 2846 if (StyleImage* shapeImage = shapeValue->image()) |
| 2831 shapeImage->removeClient(this); | 2847 shapeImage->removeClient(this); |
| 2832 } | 2848 } |
| 2833 | 2849 |
| 2850 void LayoutObject::removeCursorImageClient(const CursorList* cursorList) | |
| 2851 { | |
| 2852 if (!cursorList) | |
| 2853 return; | |
| 2854 for (const CursorData& cursor : *cursorList) { | |
| 2855 if (cursor.image()) | |
| 2856 cursor.image()->removeClient(this); | |
| 2857 } | |
| 2858 } | |
| 2859 | |
| 2834 PositionWithAffinity LayoutObject::positionForPoint(const LayoutPoint&) | 2860 PositionWithAffinity LayoutObject::positionForPoint(const LayoutPoint&) |
| 2835 { | 2861 { |
| 2836 return createPositionWithAffinity(caretMinOffset()); | 2862 return createPositionWithAffinity(caretMinOffset()); |
| 2837 } | 2863 } |
| 2838 | 2864 |
| 2839 void LayoutObject::updateDragState(bool dragOn) | 2865 void LayoutObject::updateDragState(bool dragOn) |
| 2840 { | 2866 { |
| 2841 bool valueChanged = (dragOn != isDragging()); | 2867 bool valueChanged = (dragOn != isDragging()); |
| 2842 setIsDragging(dragOn); | 2868 setIsDragging(dragOn); |
| 2843 if (valueChanged && node()) { | 2869 if (valueChanged && node()) { |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3169 | 3195 |
| 3170 void LayoutObject::imageChanged(ImageResource* image, const IntRect* rect) | 3196 void LayoutObject::imageChanged(ImageResource* image, const IntRect* rect) |
| 3171 { | 3197 { |
| 3172 ASSERT(m_node); | 3198 ASSERT(m_node); |
| 3173 | 3199 |
| 3174 // Image change notifications should not be received during paint because | 3200 // Image change notifications should not be received during paint because |
| 3175 // the resulting invalidations will be cleared following paint. This can als o | 3201 // 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. | 3202 // lead to modifying the tree out from under paint(), see: crbug.com/616700. |
| 3177 DCHECK(document().lifecycle().state() != DocumentLifecycle::LifecycleState:: InPaint); | 3203 DCHECK(document().lifecycle().state() != DocumentLifecycle::LifecycleState:: InPaint); |
| 3178 | 3204 |
| 3205 if (const CursorList* cursors = style()->cursors()) { | |
|
eae
2016/07/12 16:16:00
I'm not entirely sure how we handle cursor images
chongz
2016/07/12 20:08:12
I've moved the logic to |LayoutFrame|, will it be
| |
| 3206 for (const CursorData& cursor : *cursors) { | |
| 3207 if (cursor.image() && cursor.image()->cachedImage() == image) { | |
| 3208 if (LocalFrame* frame = this->frame()) { | |
| 3209 // Cursor update scheduling is done by the local root, which is the main frame if there | |
| 3210 // are no RemoteFrame ancestors in the frame tree. Use of lo calFrameRoot() is | |
| 3211 // discouraged but will change when cursor update scheduling is moved from EventHandler | |
| 3212 // to PageEventHandler. | |
| 3213 frame->localFrameRoot()->eventHandler().scheduleCursorUpdate (); | |
| 3214 } | |
| 3215 } | |
| 3216 } | |
| 3217 } | |
| 3218 | |
| 3179 imageChanged(static_cast<WrappedImagePtr>(image), rect); | 3219 imageChanged(static_cast<WrappedImagePtr>(image), rect); |
| 3180 } | 3220 } |
| 3181 | 3221 |
| 3182 Element* LayoutObject::offsetParent(const Element* unclosedBase) const | 3222 Element* LayoutObject::offsetParent(const Element* unclosedBase) const |
| 3183 { | 3223 { |
| 3184 if (isDocumentElement() || isBody()) | 3224 if (isDocumentElement() || isBody()) |
| 3185 return nullptr; | 3225 return nullptr; |
| 3186 | 3226 |
| 3187 if (isFixedPositioned()) | 3227 if (isFixedPositioned()) |
| 3188 return nullptr; | 3228 return nullptr; |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3646 const blink::LayoutObject* root = object1; | 3686 const blink::LayoutObject* root = object1; |
| 3647 while (root->parent()) | 3687 while (root->parent()) |
| 3648 root = root->parent(); | 3688 root = root->parent(); |
| 3649 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); | 3689 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); |
| 3650 } else { | 3690 } else { |
| 3651 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); | 3691 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); |
| 3652 } | 3692 } |
| 3653 } | 3693 } |
| 3654 | 3694 |
| 3655 #endif | 3695 #endif |
| OLD | NEW |