| 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 1881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1892 return false; | 1892 return false; |
| 1893 } | 1893 } |
| 1894 | 1894 |
| 1895 inline bool RenderObject::shouldRepaintForStyleDifference(StyleDifference diff)
const | 1895 inline bool RenderObject::shouldRepaintForStyleDifference(StyleDifference diff)
const |
| 1896 { | 1896 { |
| 1897 return diff == StyleDifferenceRepaint || (diff == StyleDifferenceRepaintIfTe
xtOrColorChange && hasImmediateNonWhitespaceTextChildOrPropertiesDependentOnColo
r()); | 1897 return diff == StyleDifferenceRepaint || (diff == StyleDifferenceRepaintIfTe
xtOrColorChange && hasImmediateNonWhitespaceTextChildOrPropertiesDependentOnColo
r()); |
| 1898 } | 1898 } |
| 1899 | 1899 |
| 1900 void RenderObject::setStyle(PassRefPtr<RenderStyle> style) | 1900 void RenderObject::setStyle(PassRefPtr<RenderStyle> style) |
| 1901 { | 1901 { |
| 1902 ASSERT(style); |
| 1903 |
| 1902 if (m_style == style) { | 1904 if (m_style == style) { |
| 1903 // We need to run through adjustStyleDifference() for iframes, plugins,
and canvas so | 1905 // We need to run through adjustStyleDifference() for iframes, plugins,
and canvas so |
| 1904 // style sharing is disabled for them. That should ensure that we never
hit this code path. | 1906 // style sharing is disabled for them. That should ensure that we never
hit this code path. |
| 1905 ASSERT(!isRenderIFrame() && !isEmbeddedObject() && !isCanvas()); | 1907 ASSERT(!isRenderIFrame() && !isEmbeddedObject() && !isCanvas()); |
| 1906 return; | 1908 return; |
| 1907 } | 1909 } |
| 1908 | 1910 |
| 1909 StyleDifference diff = StyleDifferenceEqual; | 1911 StyleDifference diff = StyleDifferenceEqual; |
| 1910 unsigned contextSensitiveProperties = ContextSensitivePropertyNone; | 1912 unsigned contextSensitiveProperties = ContextSensitivePropertyNone; |
| 1911 if (m_style) | 1913 if (m_style) |
| 1912 diff = m_style->visualInvalidationDiff(style.get(), contextSensitiveProp
erties); | 1914 diff = m_style->visualInvalidationDiff(*style, contextSensitivePropertie
s); |
| 1913 | 1915 |
| 1914 diff = adjustStyleDifference(diff, contextSensitiveProperties); | 1916 diff = adjustStyleDifference(diff, contextSensitiveProperties); |
| 1915 | 1917 |
| 1916 styleWillChange(diff, style.get()); | 1918 styleWillChange(diff, *style); |
| 1917 | 1919 |
| 1918 RefPtr<RenderStyle> oldStyle = m_style.release(); | 1920 RefPtr<RenderStyle> oldStyle = m_style.release(); |
| 1919 setStyleInternal(style); | 1921 setStyleInternal(style); |
| 1920 | 1922 |
| 1921 updateFillImages(oldStyle ? oldStyle->backgroundLayers() : 0, m_style ? m_st
yle->backgroundLayers() : 0); | 1923 updateFillImages(oldStyle ? oldStyle->backgroundLayers() : 0, m_style ? m_st
yle->backgroundLayers() : 0); |
| 1922 updateFillImages(oldStyle ? oldStyle->maskLayers() : 0, m_style ? m_style->m
askLayers() : 0); | 1924 updateFillImages(oldStyle ? oldStyle->maskLayers() : 0, m_style ? m_style->m
askLayers() : 0); |
| 1923 | 1925 |
| 1924 updateImage(oldStyle ? oldStyle->borderImage().image() : 0, m_style ? m_styl
e->borderImage().image() : 0); | 1926 updateImage(oldStyle ? oldStyle->borderImage().image() : 0, m_style ? m_styl
e->borderImage().image() : 0); |
| 1925 updateImage(oldStyle ? oldStyle->maskBoxImage().image() : 0, m_style ? m_sty
le->maskBoxImage().image() : 0); | 1927 updateImage(oldStyle ? oldStyle->maskBoxImage().image() : 0, m_style ? m_sty
le->maskBoxImage().image() : 0); |
| 1926 | 1928 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1958 // not having an outline to having an outline. | 1960 // not having an outline to having an outline. |
| 1959 repaint(); | 1961 repaint(); |
| 1960 } | 1962 } |
| 1961 } | 1963 } |
| 1962 | 1964 |
| 1963 static inline bool rendererHasBackground(const RenderObject* renderer) | 1965 static inline bool rendererHasBackground(const RenderObject* renderer) |
| 1964 { | 1966 { |
| 1965 return renderer && renderer->hasBackground(); | 1967 return renderer && renderer->hasBackground(); |
| 1966 } | 1968 } |
| 1967 | 1969 |
| 1968 void RenderObject::styleWillChange(StyleDifference diff, const RenderStyle* newS
tyle) | 1970 void RenderObject::styleWillChange(StyleDifference diff, const RenderStyle& newS
tyle) |
| 1969 { | 1971 { |
| 1970 if (m_style) { | 1972 if (m_style) { |
| 1971 // If our z-index changes value or our visibility changes, | 1973 // If our z-index changes value or our visibility changes, |
| 1972 // we need to dirty our stacking context's z-order list. | 1974 // we need to dirty our stacking context's z-order list. |
| 1973 if (newStyle) { | 1975 bool visibilityChanged = m_style->visibility() != newStyle.visibility() |
| 1974 bool visibilityChanged = m_style->visibility() != newStyle->visibili
ty() | 1976 || m_style->zIndex() != newStyle.zIndex() |
| 1975 || m_style->zIndex() != newStyle->zIndex() | 1977 || m_style->hasAutoZIndex() != newStyle.hasAutoZIndex(); |
| 1976 || m_style->hasAutoZIndex() != newStyle->hasAutoZIndex(); | 1978 if (visibilityChanged) { |
| 1977 if (visibilityChanged) { | 1979 document().setAnnotatedRegionsDirty(true); |
| 1978 document().setAnnotatedRegionsDirty(true); | 1980 if (AXObjectCache* cache = document().existingAXObjectCache()) |
| 1979 if (AXObjectCache* cache = document().existingAXObjectCache()) | 1981 cache->childrenChanged(parent()); |
| 1980 cache->childrenChanged(parent()); | 1982 } |
| 1981 } | |
| 1982 | 1983 |
| 1983 // Keep layer hierarchy visibility bits up to date if visibility cha
nges. | 1984 // Keep layer hierarchy visibility bits up to date if visibility changes
. |
| 1984 if (m_style->visibility() != newStyle->visibility()) { | 1985 if (m_style->visibility() != newStyle.visibility()) { |
| 1985 // We might not have an enclosing layer yet because we might not
be in the tree. | 1986 // We might not have an enclosing layer yet because we might not be
in the tree. |
| 1986 if (RenderLayer* layer = enclosingLayer()) { | 1987 if (RenderLayer* layer = enclosingLayer()) { |
| 1987 if (newStyle->visibility() == VISIBLE) { | 1988 if (newStyle.visibility() == VISIBLE) { |
| 1988 layer->setHasVisibleContent(); | 1989 layer->setHasVisibleContent(); |
| 1989 } else if (layer->hasVisibleContent() && (this == layer->ren
derer() || layer->renderer()->style()->visibility() != VISIBLE)) { | 1990 } else if (layer->hasVisibleContent() && (this == layer->rendere
r() || layer->renderer()->style()->visibility() != VISIBLE)) { |
| 1990 layer->dirtyVisibleContentStatus(); | 1991 layer->dirtyVisibleContentStatus(); |
| 1991 if (diff > StyleDifferenceRepaintLayer) | 1992 if (diff > StyleDifferenceRepaintLayer) |
| 1992 repaint(); | 1993 repaint(); |
| 1993 } | |
| 1994 } | 1994 } |
| 1995 } | 1995 } |
| 1996 } | 1996 } |
| 1997 | 1997 |
| 1998 if (m_parent && (newStyle->outlineSize() < m_style->outlineSize() || sho
uldRepaintForStyleDifference(diff))) | 1998 if (m_parent && (newStyle.outlineSize() < m_style->outlineSize() || shou
ldRepaintForStyleDifference(diff))) |
| 1999 repaint(); | 1999 repaint(); |
| 2000 if (isFloating() && (m_style->floating() != newStyle->floating())) | 2000 if (isFloating() && (m_style->floating() != newStyle.floating())) |
| 2001 // For changes in float styles, we need to conceivably remove oursel
ves | 2001 // For changes in float styles, we need to conceivably remove oursel
ves |
| 2002 // from the floating objects list. | 2002 // from the floating objects list. |
| 2003 toRenderBox(this)->removeFloatingOrPositionedChildFromBlockLists(); | 2003 toRenderBox(this)->removeFloatingOrPositionedChildFromBlockLists(); |
| 2004 else if (isOutOfFlowPositioned() && (m_style->position() != newStyle->po
sition())) | 2004 else if (isOutOfFlowPositioned() && (m_style->position() != newStyle.pos
ition())) |
| 2005 // For changes in positioning styles, we need to conceivably remove
ourselves | 2005 // For changes in positioning styles, we need to conceivably remove
ourselves |
| 2006 // from the positioned objects list. | 2006 // from the positioned objects list. |
| 2007 toRenderBox(this)->removeFloatingOrPositionedChildFromBlockLists(); | 2007 toRenderBox(this)->removeFloatingOrPositionedChildFromBlockLists(); |
| 2008 | 2008 |
| 2009 s_affectsParentBlock = isFloatingOrOutOfFlowPositioned() | 2009 s_affectsParentBlock = isFloatingOrOutOfFlowPositioned() |
| 2010 && (!newStyle->isFloating() && !newStyle->hasOutOfFlowPosition()) | 2010 && (!newStyle.isFloating() && !newStyle.hasOutOfFlowPosition()) |
| 2011 && parent() && (parent()->isRenderBlockFlow() || parent()->isRenderI
nline()); | 2011 && parent() && (parent()->isRenderBlockFlow() || parent()->isRenderI
nline()); |
| 2012 | 2012 |
| 2013 // Clearing these bits is required to avoid leaving stale renderers. | 2013 // Clearing these bits is required to avoid leaving stale renderers. |
| 2014 // FIXME: We shouldn't need that hack if our logic was totally correct. | 2014 // FIXME: We shouldn't need that hack if our logic was totally correct. |
| 2015 if (diff == StyleDifferenceLayout || diff == StyleDifferenceLayoutPositi
onedMovementOnly) { | 2015 if (diff == StyleDifferenceLayout || diff == StyleDifferenceLayoutPositi
onedMovementOnly) { |
| 2016 setFloating(false); | 2016 setFloating(false); |
| 2017 clearPositionedState(); | 2017 clearPositionedState(); |
| 2018 } | 2018 } |
| 2019 } else | 2019 } else |
| 2020 s_affectsParentBlock = false; | 2020 s_affectsParentBlock = false; |
| 2021 | 2021 |
| 2022 if (view()->frameView()) { | 2022 if (view()->frameView()) { |
| 2023 bool shouldBlitOnFixedBackgroundImage = false; | 2023 bool shouldBlitOnFixedBackgroundImage = false; |
| 2024 #if ENABLE(FAST_MOBILE_SCROLLING) | 2024 #if ENABLE(FAST_MOBILE_SCROLLING) |
| 2025 // On low-powered/mobile devices, preventing blitting on a scroll can ca
use noticeable delays | 2025 // On low-powered/mobile devices, preventing blitting on a scroll can ca
use noticeable delays |
| 2026 // when scrolling a page with a fixed background image. As an optimizati
on, assuming there are | 2026 // when scrolling a page with a fixed background image. As an optimizati
on, assuming there are |
| 2027 // no fixed positoned elements on the page, we can acclerate scrolling (
via blitting) if we | 2027 // no fixed positoned elements on the page, we can acclerate scrolling (
via blitting) if we |
| 2028 // ignore the CSS property "background-attachment: fixed". | 2028 // ignore the CSS property "background-attachment: fixed". |
| 2029 shouldBlitOnFixedBackgroundImage = true; | 2029 shouldBlitOnFixedBackgroundImage = true; |
| 2030 #endif | 2030 #endif |
| 2031 | 2031 |
| 2032 bool newStyleSlowScroll = newStyle && !shouldBlitOnFixedBackgroundImage
&& newStyle->hasFixedBackgroundImage(); | 2032 bool newStyleSlowScroll = !shouldBlitOnFixedBackgroundImage && newStyle.
hasFixedBackgroundImage(); |
| 2033 bool oldStyleSlowScroll = m_style && !shouldBlitOnFixedBackgroundImage &
& m_style->hasFixedBackgroundImage(); | 2033 bool oldStyleSlowScroll = m_style && !shouldBlitOnFixedBackgroundImage &
& m_style->hasFixedBackgroundImage(); |
| 2034 | 2034 |
| 2035 bool drawsRootBackground = isRoot() || (isBody() && !rendererHasBackgrou
nd(document().documentElement()->renderer())); | 2035 bool drawsRootBackground = isRoot() || (isBody() && !rendererHasBackgrou
nd(document().documentElement()->renderer())); |
| 2036 if (drawsRootBackground && !shouldBlitOnFixedBackgroundImage) { | 2036 if (drawsRootBackground && !shouldBlitOnFixedBackgroundImage) { |
| 2037 if (view()->compositor()->supportsFixedRootBackgroundCompositing())
{ | 2037 if (view()->compositor()->supportsFixedRootBackgroundCompositing())
{ |
| 2038 if (newStyleSlowScroll && newStyle->hasEntirelyFixedBackground()
) | 2038 if (newStyleSlowScroll && newStyle.hasEntirelyFixedBackground()) |
| 2039 newStyleSlowScroll = false; | 2039 newStyleSlowScroll = false; |
| 2040 | 2040 |
| 2041 if (oldStyleSlowScroll && m_style->hasEntirelyFixedBackground()) | 2041 if (oldStyleSlowScroll && m_style->hasEntirelyFixedBackground()) |
| 2042 oldStyleSlowScroll = false; | 2042 oldStyleSlowScroll = false; |
| 2043 } | 2043 } |
| 2044 } | 2044 } |
| 2045 | 2045 |
| 2046 if (oldStyleSlowScroll != newStyleSlowScroll) { | 2046 if (oldStyleSlowScroll != newStyleSlowScroll) { |
| 2047 if (oldStyleSlowScroll) | 2047 if (oldStyleSlowScroll) |
| 2048 view()->frameView()->removeSlowRepaintObject(); | 2048 view()->frameView()->removeSlowRepaintObject(); |
| 2049 if (newStyleSlowScroll) | 2049 if (newStyleSlowScroll) |
| 2050 view()->frameView()->addSlowRepaintObject(); | 2050 view()->frameView()->addSlowRepaintObject(); |
| 2051 } | 2051 } |
| 2052 } | 2052 } |
| 2053 | 2053 |
| 2054 // Elements with non-auto touch-action will send a SetTouchAction message | 2054 // Elements with non-auto touch-action will send a SetTouchAction message |
| 2055 // on touchstart in EventHandler::handleTouchEvent, and so effectively have | 2055 // on touchstart in EventHandler::handleTouchEvent, and so effectively have |
| 2056 // a touchstart handler that must be reported. | 2056 // a touchstart handler that must be reported. |
| 2057 // | 2057 // |
| 2058 // Since a CSS property cannot be applied directly to a text node, a | 2058 // Since a CSS property cannot be applied directly to a text node, a |
| 2059 // handler will have already been added for its parent so ignore it. | 2059 // handler will have already been added for its parent so ignore it. |
| 2060 TouchAction oldTouchAction = m_style ? m_style->touchAction() : TouchActionA
uto; | 2060 TouchAction oldTouchAction = m_style ? m_style->touchAction() : TouchActionA
uto; |
| 2061 if (node() && !node()->isTextNode() && (oldTouchAction == TouchActionAuto) !
= (newStyle->touchAction() == TouchActionAuto)) { | 2061 if (node() && !node()->isTextNode() && (oldTouchAction == TouchActionAuto) !
= (newStyle.touchAction() == TouchActionAuto)) { |
| 2062 if (newStyle->touchAction() != TouchActionAuto) | 2062 if (newStyle.touchAction() != TouchActionAuto) |
| 2063 document().didAddTouchEventHandler(node()); | 2063 document().didAddTouchEventHandler(node()); |
| 2064 else | 2064 else |
| 2065 document().didRemoveTouchEventHandler(node()); | 2065 document().didRemoveTouchEventHandler(node()); |
| 2066 } | 2066 } |
| 2067 } | 2067 } |
| 2068 | 2068 |
| 2069 static bool areNonIdenticalCursorListsEqual(const RenderStyle* a, const RenderSt
yle* b) | 2069 static bool areNonIdenticalCursorListsEqual(const RenderStyle* a, const RenderSt
yle* b) |
| 2070 { | 2070 { |
| 2071 ASSERT(a->cursors() != b->cursors()); | 2071 ASSERT(a->cursors() != b->cursors()); |
| 2072 return a->cursors() && b->cursors() && *a->cursors() == *b->cursors(); | 2072 return a->cursors() && b->cursors() && *a->cursors() == *b->cursors(); |
| (...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3333 { | 3333 { |
| 3334 if (object1) { | 3334 if (object1) { |
| 3335 const WebCore::RenderObject* root = object1; | 3335 const WebCore::RenderObject* root = object1; |
| 3336 while (root->parent()) | 3336 while (root->parent()) |
| 3337 root = root->parent(); | 3337 root = root->parent(); |
| 3338 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); | 3338 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); |
| 3339 } | 3339 } |
| 3340 } | 3340 } |
| 3341 | 3341 |
| 3342 #endif | 3342 #endif |
| OLD | NEW |