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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 ASSERT(isMainThread()); | 144 ASSERT(isMainThread()); |
145 return partitionAlloc(Partitions::getRenderingPartition(), sz); | 145 return partitionAlloc(Partitions::getRenderingPartition(), sz); |
146 } | 146 } |
147 | 147 |
148 void LayoutObject::operator delete(void* ptr) | 148 void LayoutObject::operator delete(void* ptr) |
149 { | 149 { |
150 ASSERT(isMainThread()); | 150 ASSERT(isMainThread()); |
151 partitionFree(ptr); | 151 partitionFree(ptr); |
152 } | 152 } |
153 | 153 |
154 LayoutObject* LayoutObject::createObject(Element* element, const LayoutStyle& st
yle) | 154 LayoutObject* LayoutObject::createObject(Element* element, const ComputedStyle&
style) |
155 { | 155 { |
156 ASSERT(isAllowedToModifyRenderTreeStructure(element->document())); | 156 ASSERT(isAllowedToModifyRenderTreeStructure(element->document())); |
157 | 157 |
158 // Minimal support for content properties replacing an entire element. | 158 // Minimal support for content properties replacing an entire element. |
159 // Works only if we have exactly one piece of content and it's a URL. | 159 // Works only if we have exactly one piece of content and it's a URL. |
160 // Otherwise acts as if we didn't support this feature. | 160 // Otherwise acts as if we didn't support this feature. |
161 const ContentData* contentData = style.contentData(); | 161 const ContentData* contentData = style.contentData(); |
162 if (contentData && !contentData->next() && contentData->isImage() && !elemen
t->isPseudoElement()) { | 162 if (contentData && !contentData->next() && contentData->isImage() && !elemen
t->isPseudoElement()) { |
163 LayoutImage* image = new LayoutImage(element); | 163 LayoutImage* image = new LayoutImage(element); |
164 // LayoutImageResourceStyleImage requires a style being present on the i
mage but we don't want to | 164 // LayoutImageResourceStyleImage requires a style being present on the i
mage but we don't want to |
165 // trigger a style change now as the node is not fully attached. Moving
this code to style change | 165 // trigger a style change now as the node is not fully attached. Moving
this code to style change |
166 // doesn't make sense as it should be run once at renderer creation. | 166 // doesn't make sense as it should be run once at renderer creation. |
167 image->setStyleInternal(const_cast<LayoutStyle*>(&style)); | 167 image->setStyleInternal(const_cast<ComputedStyle*>(&style)); |
168 if (const StyleImage* styleImage = toImageContentData(contentData)->imag
e()) { | 168 if (const StyleImage* styleImage = toImageContentData(contentData)->imag
e()) { |
169 image->setImageResource(LayoutImageResourceStyleImage::create(const_
cast<StyleImage*>(styleImage))); | 169 image->setImageResource(LayoutImageResourceStyleImage::create(const_
cast<StyleImage*>(styleImage))); |
170 image->setIsGeneratedContent(); | 170 image->setIsGeneratedContent(); |
171 } else { | 171 } else { |
172 image->setImageResource(LayoutImageResource::create()); | 172 image->setImageResource(LayoutImageResource::create()); |
173 } | 173 } |
174 image->setStyleInternal(nullptr); | 174 image->setStyleInternal(nullptr); |
175 return image; | 175 return image; |
176 } | 176 } |
177 | 177 |
(...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1516 bool LayoutObject::isSelectable() const | 1516 bool LayoutObject::isSelectable() const |
1517 { | 1517 { |
1518 return !isInert() && !(style()->userSelect() == SELECT_NONE && style()->user
Modify() == READ_ONLY); | 1518 return !isInert() && !(style()->userSelect() == SELECT_NONE && style()->user
Modify() == READ_ONLY); |
1519 } | 1519 } |
1520 | 1520 |
1521 Color LayoutObject::selectionBackgroundColor() const | 1521 Color LayoutObject::selectionBackgroundColor() const |
1522 { | 1522 { |
1523 if (!isSelectable()) | 1523 if (!isSelectable()) |
1524 return Color::transparent; | 1524 return Color::transparent; |
1525 | 1525 |
1526 if (RefPtr<LayoutStyle> pseudoStyle = getUncachedPseudoStyleFromParentOrShad
owHost()) | 1526 if (RefPtr<ComputedStyle> pseudoStyle = getUncachedPseudoStyleFromParentOrSh
adowHost()) |
1527 return resolveColor(*pseudoStyle, CSSPropertyBackgroundColor).blendWithW
hite(); | 1527 return resolveColor(*pseudoStyle, CSSPropertyBackgroundColor).blendWithW
hite(); |
1528 return frame()->selection().isFocusedAndActive() ? | 1528 return frame()->selection().isFocusedAndActive() ? |
1529 LayoutTheme::theme().activeSelectionBackgroundColor() : | 1529 LayoutTheme::theme().activeSelectionBackgroundColor() : |
1530 LayoutTheme::theme().inactiveSelectionBackgroundColor(); | 1530 LayoutTheme::theme().inactiveSelectionBackgroundColor(); |
1531 } | 1531 } |
1532 | 1532 |
1533 Color LayoutObject::selectionColor(int colorProperty) const | 1533 Color LayoutObject::selectionColor(int colorProperty) const |
1534 { | 1534 { |
1535 // If the element is unselectable, or we are only painting the selection, | 1535 // If the element is unselectable, or we are only painting the selection, |
1536 // don't override the foreground color with the selection foreground color. | 1536 // don't override the foreground color with the selection foreground color. |
1537 if (!isSelectable() || (frame()->view()->paintBehavior() & PaintBehaviorSele
ctionOnly)) | 1537 if (!isSelectable() || (frame()->view()->paintBehavior() & PaintBehaviorSele
ctionOnly)) |
1538 return resolveColor(colorProperty); | 1538 return resolveColor(colorProperty); |
1539 | 1539 |
1540 if (RefPtr<LayoutStyle> pseudoStyle = getUncachedPseudoStyleFromParentOrShad
owHost()) | 1540 if (RefPtr<ComputedStyle> pseudoStyle = getUncachedPseudoStyleFromParentOrSh
adowHost()) |
1541 return resolveColor(*pseudoStyle, colorProperty); | 1541 return resolveColor(*pseudoStyle, colorProperty); |
1542 if (!LayoutTheme::theme().supportsSelectionForegroundColors()) | 1542 if (!LayoutTheme::theme().supportsSelectionForegroundColors()) |
1543 return resolveColor(colorProperty); | 1543 return resolveColor(colorProperty); |
1544 return frame()->selection().isFocusedAndActive() ? | 1544 return frame()->selection().isFocusedAndActive() ? |
1545 LayoutTheme::theme().activeSelectionForegroundColor() : | 1545 LayoutTheme::theme().activeSelectionForegroundColor() : |
1546 LayoutTheme::theme().inactiveSelectionForegroundColor(); | 1546 LayoutTheme::theme().inactiveSelectionForegroundColor(); |
1547 } | 1547 } |
1548 | 1548 |
1549 Color LayoutObject::selectionForegroundColor() const | 1549 Color LayoutObject::selectionForegroundColor() const |
1550 { | 1550 { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1624 | 1624 |
1625 // If we have no layer(), just treat a PaintInvalidationLayer hint as a norm
al paint invalidation. | 1625 // If we have no layer(), just treat a PaintInvalidationLayer hint as a norm
al paint invalidation. |
1626 if (diff.needsPaintInvalidationLayer() && !hasLayer()) { | 1626 if (diff.needsPaintInvalidationLayer() && !hasLayer()) { |
1627 diff.clearNeedsPaintInvalidation(); | 1627 diff.clearNeedsPaintInvalidation(); |
1628 diff.setNeedsPaintInvalidationObject(); | 1628 diff.setNeedsPaintInvalidationObject(); |
1629 } | 1629 } |
1630 | 1630 |
1631 return diff; | 1631 return diff; |
1632 } | 1632 } |
1633 | 1633 |
1634 void LayoutObject::setPseudoStyle(PassRefPtr<LayoutStyle> pseudoStyle) | 1634 void LayoutObject::setPseudoStyle(PassRefPtr<ComputedStyle> pseudoStyle) |
1635 { | 1635 { |
1636 ASSERT(pseudoStyle->styleType() == BEFORE || pseudoStyle->styleType() == AFT
ER || pseudoStyle->styleType() == FIRST_LETTER); | 1636 ASSERT(pseudoStyle->styleType() == BEFORE || pseudoStyle->styleType() == AFT
ER || pseudoStyle->styleType() == FIRST_LETTER); |
1637 | 1637 |
1638 // FIXME: We should consider just making all pseudo items use an inherited s
tyle. | 1638 // FIXME: We should consider just making all pseudo items use an inherited s
tyle. |
1639 | 1639 |
1640 // Images are special and must inherit the pseudoStyle so the width and heig
ht of | 1640 // Images are special and must inherit the pseudoStyle so the width and heig
ht of |
1641 // the pseudo element doesn't change the size of the image. In all other cas
es we | 1641 // the pseudo element doesn't change the size of the image. In all other cas
es we |
1642 // can just share the style. | 1642 // can just share the style. |
1643 // | 1643 // |
1644 // Quotes are also LayoutInline, so we need to create an inherited style to
avoid | 1644 // Quotes are also LayoutInline, so we need to create an inherited style to
avoid |
1645 // getting an inline with positioning or an invalid display. | 1645 // getting an inline with positioning or an invalid display. |
1646 // | 1646 // |
1647 if (isImage() || isQuote()) { | 1647 if (isImage() || isQuote()) { |
1648 RefPtr<LayoutStyle> style = LayoutStyle::create(); | 1648 RefPtr<ComputedStyle> style = ComputedStyle::create(); |
1649 style->inheritFrom(*pseudoStyle); | 1649 style->inheritFrom(*pseudoStyle); |
1650 setStyle(style.release()); | 1650 setStyle(style.release()); |
1651 return; | 1651 return; |
1652 } | 1652 } |
1653 | 1653 |
1654 setStyle(pseudoStyle); | 1654 setStyle(pseudoStyle); |
1655 } | 1655 } |
1656 | 1656 |
1657 void LayoutObject::markContainingBlocksForOverflowRecalc() | 1657 void LayoutObject::markContainingBlocksForOverflowRecalc() |
1658 { | 1658 { |
1659 for (LayoutBlock* container = containingBlock(); container && !container->ch
ildNeedsOverflowRecalcAfterStyleChange(); container = container->containingBlock
()) | 1659 for (LayoutBlock* container = containingBlock(); container && !container->ch
ildNeedsOverflowRecalcAfterStyleChange(); container = container->containingBlock
()) |
1660 container->setChildNeedsOverflowRecalcAfterStyleChange(true); | 1660 container->setChildNeedsOverflowRecalcAfterStyleChange(true); |
1661 } | 1661 } |
1662 | 1662 |
1663 void LayoutObject::setNeedsOverflowRecalcAfterStyleChange() | 1663 void LayoutObject::setNeedsOverflowRecalcAfterStyleChange() |
1664 { | 1664 { |
1665 bool neededRecalc = needsOverflowRecalcAfterStyleChange(); | 1665 bool neededRecalc = needsOverflowRecalcAfterStyleChange(); |
1666 setSelfNeedsOverflowRecalcAfterStyleChange(true); | 1666 setSelfNeedsOverflowRecalcAfterStyleChange(true); |
1667 if (!neededRecalc) | 1667 if (!neededRecalc) |
1668 markContainingBlocksForOverflowRecalc(); | 1668 markContainingBlocksForOverflowRecalc(); |
1669 } | 1669 } |
1670 | 1670 |
1671 void LayoutObject::setStyle(PassRefPtr<LayoutStyle> style) | 1671 void LayoutObject::setStyle(PassRefPtr<ComputedStyle> style) |
1672 { | 1672 { |
1673 ASSERT(style); | 1673 ASSERT(style); |
1674 | 1674 |
1675 if (m_style == style) { | 1675 if (m_style == style) { |
1676 // We need to run through adjustStyleDifference() for iframes, plugins,
and canvas so | 1676 // We need to run through adjustStyleDifference() for iframes, plugins,
and canvas so |
1677 // style sharing is disabled for them. That should ensure that we never
hit this code path. | 1677 // style sharing is disabled for them. That should ensure that we never
hit this code path. |
1678 ASSERT(!isLayoutIFrame() && !isEmbeddedObject() && !isCanvas()); | 1678 ASSERT(!isLayoutIFrame() && !isEmbeddedObject() && !isCanvas()); |
1679 return; | 1679 return; |
1680 } | 1680 } |
1681 | 1681 |
1682 StyleDifference diff; | 1682 StyleDifference diff; |
1683 if (m_style) | 1683 if (m_style) |
1684 diff = m_style->visualInvalidationDiff(*style); | 1684 diff = m_style->visualInvalidationDiff(*style); |
1685 | 1685 |
1686 diff = adjustStyleDifference(diff); | 1686 diff = adjustStyleDifference(diff); |
1687 | 1687 |
1688 styleWillChange(diff, *style); | 1688 styleWillChange(diff, *style); |
1689 | 1689 |
1690 RefPtr<LayoutStyle> oldStyle = m_style.release(); | 1690 RefPtr<ComputedStyle> oldStyle = m_style.release(); |
1691 setStyleInternal(style); | 1691 setStyleInternal(style); |
1692 | 1692 |
1693 updateFillImages(oldStyle ? &oldStyle->backgroundLayers() : 0, m_style->back
groundLayers()); | 1693 updateFillImages(oldStyle ? &oldStyle->backgroundLayers() : 0, m_style->back
groundLayers()); |
1694 updateFillImages(oldStyle ? &oldStyle->maskLayers() : 0, m_style->maskLayers
()); | 1694 updateFillImages(oldStyle ? &oldStyle->maskLayers() : 0, m_style->maskLayers
()); |
1695 | 1695 |
1696 updateImage(oldStyle ? oldStyle->borderImage().image() : 0, m_style->borderI
mage().image()); | 1696 updateImage(oldStyle ? oldStyle->borderImage().image() : 0, m_style->borderI
mage().image()); |
1697 updateImage(oldStyle ? oldStyle->maskBoxImage().image() : 0, m_style->maskBo
xImage().image()); | 1697 updateImage(oldStyle ? oldStyle->maskBoxImage().image() : 0, m_style->maskBo
xImage().image()); |
1698 | 1698 |
1699 updateShapeImage(oldStyle ? oldStyle->shapeOutside() : 0, m_style->shapeOuts
ide()); | 1699 updateShapeImage(oldStyle ? oldStyle->shapeOutside() : 0, m_style->shapeOuts
ide()); |
1700 | 1700 |
(...skipping 28 matching lines...) Expand all Loading... |
1729 toLayoutBoxModelObject(this)->layer()->setShouldDoFullPaintInvalidationI
ncludingNonCompositingDescendants(); | 1729 toLayoutBoxModelObject(this)->layer()->setShouldDoFullPaintInvalidationI
ncludingNonCompositingDescendants(); |
1730 else if (diff.needsPaintInvalidationObject() || updatedDiff.needsPaintInvali
dationObject()) | 1730 else if (diff.needsPaintInvalidationObject() || updatedDiff.needsPaintInvali
dationObject()) |
1731 setShouldDoFullPaintInvalidation(); | 1731 setShouldDoFullPaintInvalidation(); |
1732 } | 1732 } |
1733 | 1733 |
1734 static inline bool rendererHasBackground(const LayoutObject* renderer) | 1734 static inline bool rendererHasBackground(const LayoutObject* renderer) |
1735 { | 1735 { |
1736 return renderer && renderer->hasBackground(); | 1736 return renderer && renderer->hasBackground(); |
1737 } | 1737 } |
1738 | 1738 |
1739 void LayoutObject::styleWillChange(StyleDifference diff, const LayoutStyle& newS
tyle) | 1739 void LayoutObject::styleWillChange(StyleDifference diff, const ComputedStyle& ne
wStyle) |
1740 { | 1740 { |
1741 if (m_style) { | 1741 if (m_style) { |
1742 // If our z-index changes value or our visibility changes, | 1742 // If our z-index changes value or our visibility changes, |
1743 // we need to dirty our stacking context's z-order list. | 1743 // we need to dirty our stacking context's z-order list. |
1744 bool visibilityChanged = m_style->visibility() != newStyle.visibility() | 1744 bool visibilityChanged = m_style->visibility() != newStyle.visibility() |
1745 || m_style->zIndex() != newStyle.zIndex() | 1745 || m_style->zIndex() != newStyle.zIndex() |
1746 || m_style->hasAutoZIndex() != newStyle.hasAutoZIndex(); | 1746 || m_style->hasAutoZIndex() != newStyle.hasAutoZIndex(); |
1747 if (visibilityChanged) { | 1747 if (visibilityChanged) { |
1748 document().setAnnotatedRegionsDirty(true); | 1748 document().setAnnotatedRegionsDirty(true); |
1749 if (AXObjectCache* cache = document().existingAXObjectCache()) | 1749 if (AXObjectCache* cache = document().existingAXObjectCache()) |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1821 TouchAction oldTouchAction = m_style ? m_style->touchAction() : TouchActionA
uto; | 1821 TouchAction oldTouchAction = m_style ? m_style->touchAction() : TouchActionA
uto; |
1822 if (node() && !node()->isTextNode() && (oldTouchAction == TouchActionAuto) !
= (newStyle.touchAction() == TouchActionAuto)) { | 1822 if (node() && !node()->isTextNode() && (oldTouchAction == TouchActionAuto) !
= (newStyle.touchAction() == TouchActionAuto)) { |
1823 EventHandlerRegistry& registry = document().frameHost()->eventHandlerReg
istry(); | 1823 EventHandlerRegistry& registry = document().frameHost()->eventHandlerReg
istry(); |
1824 if (newStyle.touchAction() != TouchActionAuto) | 1824 if (newStyle.touchAction() != TouchActionAuto) |
1825 registry.didAddEventHandler(*node(), EventHandlerRegistry::TouchEven
t); | 1825 registry.didAddEventHandler(*node(), EventHandlerRegistry::TouchEven
t); |
1826 else | 1826 else |
1827 registry.didRemoveEventHandler(*node(), EventHandlerRegistry::TouchE
vent); | 1827 registry.didRemoveEventHandler(*node(), EventHandlerRegistry::TouchE
vent); |
1828 } | 1828 } |
1829 } | 1829 } |
1830 | 1830 |
1831 static bool areNonIdenticalCursorListsEqual(const LayoutStyle* a, const LayoutSt
yle* b) | 1831 static bool areNonIdenticalCursorListsEqual(const ComputedStyle* a, const Comput
edStyle* b) |
1832 { | 1832 { |
1833 ASSERT(a->cursors() != b->cursors()); | 1833 ASSERT(a->cursors() != b->cursors()); |
1834 return a->cursors() && b->cursors() && *a->cursors() == *b->cursors(); | 1834 return a->cursors() && b->cursors() && *a->cursors() == *b->cursors(); |
1835 } | 1835 } |
1836 | 1836 |
1837 static inline bool areCursorsEqual(const LayoutStyle* a, const LayoutStyle* b) | 1837 static inline bool areCursorsEqual(const ComputedStyle* a, const ComputedStyle*
b) |
1838 { | 1838 { |
1839 return a->cursor() == b->cursor() && (a->cursors() == b->cursors() || areNon
IdenticalCursorListsEqual(a, b)); | 1839 return a->cursor() == b->cursor() && (a->cursors() == b->cursors() || areNon
IdenticalCursorListsEqual(a, b)); |
1840 } | 1840 } |
1841 | 1841 |
1842 void LayoutObject::styleDidChange(StyleDifference diff, const LayoutStyle* oldSt
yle) | 1842 void LayoutObject::styleDidChange(StyleDifference diff, const ComputedStyle* old
Style) |
1843 { | 1843 { |
1844 if (s_affectsParentBlock) | 1844 if (s_affectsParentBlock) |
1845 handleDynamicFloatPositionChange(); | 1845 handleDynamicFloatPositionChange(); |
1846 | 1846 |
1847 if (!m_parent) | 1847 if (!m_parent) |
1848 return; | 1848 return; |
1849 | 1849 |
1850 if (diff.needsFullLayout()) { | 1850 if (diff.needsFullLayout()) { |
1851 LayoutCounter::rendererStyleChanged(*this, oldStyle, *m_style); | 1851 LayoutCounter::rendererStyleChanged(*this, oldStyle, *m_style); |
1852 | 1852 |
(...skipping 30 matching lines...) Expand all Loading... |
1883 for (LayoutObject* child = slowFirstChild(); child; child = child->nextSibli
ng()) { | 1883 for (LayoutObject* child = slowFirstChild(); child; child = child->nextSibli
ng()) { |
1884 if (!child->isAnonymous() || child->style()->styleType() != NOPSEUDO) | 1884 if (!child->isAnonymous() || child->style()->styleType() != NOPSEUDO) |
1885 continue; | 1885 continue; |
1886 | 1886 |
1887 if (blockChildrenOnly && !child->isLayoutBlock()) | 1887 if (blockChildrenOnly && !child->isLayoutBlock()) |
1888 continue; | 1888 continue; |
1889 | 1889 |
1890 if (child->isLayoutFullScreen() || child->isLayoutFullScreenPlaceholder(
)) | 1890 if (child->isLayoutFullScreen() || child->isLayoutFullScreenPlaceholder(
)) |
1891 continue; | 1891 continue; |
1892 | 1892 |
1893 RefPtr<LayoutStyle> newStyle = LayoutStyle::createAnonymousStyleWithDisp
lay(styleRef(), child->style()->display()); | 1893 RefPtr<ComputedStyle> newStyle = ComputedStyle::createAnonymousStyleWith
Display(styleRef(), child->style()->display()); |
1894 if (!RuntimeEnabledFeatures::regionBasedColumnsEnabled()) { | 1894 if (!RuntimeEnabledFeatures::regionBasedColumnsEnabled()) { |
1895 if (style()->specifiesColumns()) { | 1895 if (style()->specifiesColumns()) { |
1896 if (child->style()->specifiesColumns()) | 1896 if (child->style()->specifiesColumns()) |
1897 newStyle->inheritColumnPropertiesFrom(styleRef()); | 1897 newStyle->inheritColumnPropertiesFrom(styleRef()); |
1898 if (child->style()->columnSpan()) | 1898 if (child->style()->columnSpan()) |
1899 newStyle->setColumnSpan(ColumnSpanAll); | 1899 newStyle->setColumnSpan(ColumnSpanAll); |
1900 } | 1900 } |
1901 } | 1901 } |
1902 | 1902 |
1903 // Preserve the position style of anonymous block continuations as they
can have relative position when | 1903 // Preserve the position style of anonymous block continuations as they
can have relative position when |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2647 { | 2647 { |
2648 setNormalChildNeedsLayout(true); | 2648 setNormalChildNeedsLayout(true); |
2649 layout(); | 2649 layout(); |
2650 } | 2650 } |
2651 | 2651 |
2652 enum StyleCacheState { | 2652 enum StyleCacheState { |
2653 Cached, | 2653 Cached, |
2654 Uncached | 2654 Uncached |
2655 }; | 2655 }; |
2656 | 2656 |
2657 static PassRefPtr<LayoutStyle> firstLineStyleForCachedUncachedType(StyleCacheSta
te type, const LayoutObject* renderer, LayoutStyle* style) | 2657 static PassRefPtr<ComputedStyle> firstLineStyleForCachedUncachedType(StyleCacheS
tate type, const LayoutObject* renderer, ComputedStyle* style) |
2658 { | 2658 { |
2659 const LayoutObject* rendererForFirstLineStyle = renderer; | 2659 const LayoutObject* rendererForFirstLineStyle = renderer; |
2660 if (renderer->isBeforeOrAfterContent()) | 2660 if (renderer->isBeforeOrAfterContent()) |
2661 rendererForFirstLineStyle = renderer->parent(); | 2661 rendererForFirstLineStyle = renderer->parent(); |
2662 | 2662 |
2663 if (rendererForFirstLineStyle->isLayoutBlockFlow() || rendererForFirstLineSt
yle->isLayoutButton()) { | 2663 if (rendererForFirstLineStyle->isLayoutBlockFlow() || rendererForFirstLineSt
yle->isLayoutButton()) { |
2664 if (LayoutBlock* firstLineBlock = rendererForFirstLineStyle->firstLineBl
ock()) { | 2664 if (LayoutBlock* firstLineBlock = rendererForFirstLineStyle->firstLineBl
ock()) { |
2665 if (type == Cached) | 2665 if (type == Cached) |
2666 return firstLineBlock->getCachedPseudoStyle(FIRST_LINE, style); | 2666 return firstLineBlock->getCachedPseudoStyle(FIRST_LINE, style); |
2667 return firstLineBlock->getUncachedPseudoStyle(PseudoStyleRequest(FIR
ST_LINE), style, firstLineBlock == renderer ? style : 0); | 2667 return firstLineBlock->getUncachedPseudoStyle(PseudoStyleRequest(FIR
ST_LINE), style, firstLineBlock == renderer ? style : 0); |
2668 } | 2668 } |
2669 } else if (!rendererForFirstLineStyle->isAnonymous() && rendererForFirstLine
Style->isLayoutInline() | 2669 } else if (!rendererForFirstLineStyle->isAnonymous() && rendererForFirstLine
Style->isLayoutInline() |
2670 && !rendererForFirstLineStyle->node()->isFirstLetterPseudoElement()) { | 2670 && !rendererForFirstLineStyle->node()->isFirstLetterPseudoElement()) { |
2671 const LayoutStyle* parentStyle = rendererForFirstLineStyle->parent()->fi
rstLineStyle(); | 2671 const ComputedStyle* parentStyle = rendererForFirstLineStyle->parent()->
firstLineStyle(); |
2672 if (parentStyle != rendererForFirstLineStyle->parent()->style()) { | 2672 if (parentStyle != rendererForFirstLineStyle->parent()->style()) { |
2673 if (type == Cached) { | 2673 if (type == Cached) { |
2674 // A first-line style is in effect. Cache a first-line style for
ourselves. | 2674 // A first-line style is in effect. Cache a first-line style for
ourselves. |
2675 rendererForFirstLineStyle->mutableStyleRef().setHasPseudoStyle(F
IRST_LINE_INHERITED); | 2675 rendererForFirstLineStyle->mutableStyleRef().setHasPseudoStyle(F
IRST_LINE_INHERITED); |
2676 return rendererForFirstLineStyle->getCachedPseudoStyle(FIRST_LIN
E_INHERITED, parentStyle); | 2676 return rendererForFirstLineStyle->getCachedPseudoStyle(FIRST_LIN
E_INHERITED, parentStyle); |
2677 } | 2677 } |
2678 return rendererForFirstLineStyle->getUncachedPseudoStyle(PseudoStyle
Request(FIRST_LINE_INHERITED), parentStyle, style); | 2678 return rendererForFirstLineStyle->getUncachedPseudoStyle(PseudoStyle
Request(FIRST_LINE_INHERITED), parentStyle, style); |
2679 } | 2679 } |
2680 } | 2680 } |
2681 return nullptr; | 2681 return nullptr; |
2682 } | 2682 } |
2683 | 2683 |
2684 PassRefPtr<LayoutStyle> LayoutObject::uncachedFirstLineStyle(LayoutStyle* style)
const | 2684 PassRefPtr<ComputedStyle> LayoutObject::uncachedFirstLineStyle(ComputedStyle* st
yle) const |
2685 { | 2685 { |
2686 if (!document().styleEngine().usesFirstLineRules()) | 2686 if (!document().styleEngine().usesFirstLineRules()) |
2687 return nullptr; | 2687 return nullptr; |
2688 | 2688 |
2689 ASSERT(!isText()); | 2689 ASSERT(!isText()); |
2690 | 2690 |
2691 return firstLineStyleForCachedUncachedType(Uncached, this, style); | 2691 return firstLineStyleForCachedUncachedType(Uncached, this, style); |
2692 } | 2692 } |
2693 | 2693 |
2694 LayoutStyle* LayoutObject::cachedFirstLineStyle() const | 2694 ComputedStyle* LayoutObject::cachedFirstLineStyle() const |
2695 { | 2695 { |
2696 ASSERT(document().styleEngine().usesFirstLineRules()); | 2696 ASSERT(document().styleEngine().usesFirstLineRules()); |
2697 | 2697 |
2698 if (RefPtr<LayoutStyle> style = firstLineStyleForCachedUncachedType(Cached,
isText() ? parent() : this, m_style.get())) | 2698 if (RefPtr<ComputedStyle> style = firstLineStyleForCachedUncachedType(Cached
, isText() ? parent() : this, m_style.get())) |
2699 return style.get(); | 2699 return style.get(); |
2700 | 2700 |
2701 return m_style.get(); | 2701 return m_style.get(); |
2702 } | 2702 } |
2703 | 2703 |
2704 LayoutStyle* LayoutObject::getCachedPseudoStyle(PseudoId pseudo, const LayoutSty
le* parentStyle) const | 2704 ComputedStyle* LayoutObject::getCachedPseudoStyle(PseudoId pseudo, const Compute
dStyle* parentStyle) const |
2705 { | 2705 { |
2706 if (pseudo < FIRST_INTERNAL_PSEUDOID && !style()->hasPseudoStyle(pseudo)) | 2706 if (pseudo < FIRST_INTERNAL_PSEUDOID && !style()->hasPseudoStyle(pseudo)) |
2707 return 0; | 2707 return 0; |
2708 | 2708 |
2709 LayoutStyle* cachedStyle = style()->getCachedPseudoStyle(pseudo); | 2709 ComputedStyle* cachedStyle = style()->getCachedPseudoStyle(pseudo); |
2710 if (cachedStyle) | 2710 if (cachedStyle) |
2711 return cachedStyle; | 2711 return cachedStyle; |
2712 | 2712 |
2713 RefPtr<LayoutStyle> result = getUncachedPseudoStyle(PseudoStyleRequest(pseud
o), parentStyle); | 2713 RefPtr<ComputedStyle> result = getUncachedPseudoStyle(PseudoStyleRequest(pse
udo), parentStyle); |
2714 if (result) | 2714 if (result) |
2715 return mutableStyleRef().addCachedPseudoStyle(result.release()); | 2715 return mutableStyleRef().addCachedPseudoStyle(result.release()); |
2716 return 0; | 2716 return 0; |
2717 } | 2717 } |
2718 | 2718 |
2719 PassRefPtr<LayoutStyle> LayoutObject::getUncachedPseudoStyle(const PseudoStyleRe
quest& pseudoStyleRequest, const LayoutStyle* parentStyle, const LayoutStyle* ow
nStyle) const | 2719 PassRefPtr<ComputedStyle> LayoutObject::getUncachedPseudoStyle(const PseudoStyle
Request& pseudoStyleRequest, const ComputedStyle* parentStyle, const ComputedSty
le* ownStyle) const |
2720 { | 2720 { |
2721 if (pseudoStyleRequest.pseudoId < FIRST_INTERNAL_PSEUDOID && !ownStyle && !s
tyle()->hasPseudoStyle(pseudoStyleRequest.pseudoId)) | 2721 if (pseudoStyleRequest.pseudoId < FIRST_INTERNAL_PSEUDOID && !ownStyle && !s
tyle()->hasPseudoStyle(pseudoStyleRequest.pseudoId)) |
2722 return nullptr; | 2722 return nullptr; |
2723 | 2723 |
2724 if (!parentStyle) { | 2724 if (!parentStyle) { |
2725 ASSERT(!ownStyle); | 2725 ASSERT(!ownStyle); |
2726 parentStyle = style(); | 2726 parentStyle = style(); |
2727 } | 2727 } |
2728 | 2728 |
2729 if (!node()) | 2729 if (!node()) |
2730 return nullptr; | 2730 return nullptr; |
2731 | 2731 |
2732 Element* element = Traversal<Element>::firstAncestorOrSelf(*node()); | 2732 Element* element = Traversal<Element>::firstAncestorOrSelf(*node()); |
2733 if (!element) | 2733 if (!element) |
2734 return nullptr; | 2734 return nullptr; |
2735 | 2735 |
2736 if (pseudoStyleRequest.pseudoId == FIRST_LINE_INHERITED) { | 2736 if (pseudoStyleRequest.pseudoId == FIRST_LINE_INHERITED) { |
2737 RefPtr<LayoutStyle> result = document().ensureStyleResolver().styleForEl
ement(element, parentStyle, DisallowStyleSharing); | 2737 RefPtr<ComputedStyle> result = document().ensureStyleResolver().styleFor
Element(element, parentStyle, DisallowStyleSharing); |
2738 result->setStyleType(FIRST_LINE_INHERITED); | 2738 result->setStyleType(FIRST_LINE_INHERITED); |
2739 return result.release(); | 2739 return result.release(); |
2740 } | 2740 } |
2741 | 2741 |
2742 return document().ensureStyleResolver().pseudoStyleForElement(element, pseud
oStyleRequest, parentStyle); | 2742 return document().ensureStyleResolver().pseudoStyleForElement(element, pseud
oStyleRequest, parentStyle); |
2743 } | 2743 } |
2744 | 2744 |
2745 PassRefPtr<LayoutStyle> LayoutObject::getUncachedPseudoStyleFromParentOrShadowHo
st() const | 2745 PassRefPtr<ComputedStyle> LayoutObject::getUncachedPseudoStyleFromParentOrShadow
Host() const |
2746 { | 2746 { |
2747 if (!node()) | 2747 if (!node()) |
2748 return nullptr; | 2748 return nullptr; |
2749 | 2749 |
2750 if (ShadowRoot* root = node()->containingShadowRoot()) { | 2750 if (ShadowRoot* root = node()->containingShadowRoot()) { |
2751 if (root->type() == ShadowRoot::ClosedShadowRoot) { | 2751 if (root->type() == ShadowRoot::ClosedShadowRoot) { |
2752 if (Element* shadowHost = node()->shadowHost()) { | 2752 if (Element* shadowHost = node()->shadowHost()) { |
2753 return shadowHost->layoutObject()->getUncachedPseudoStyle(Pseudo
StyleRequest(SELECTION)); | 2753 return shadowHost->layoutObject()->getUncachedPseudoStyle(Pseudo
StyleRequest(SELECTION)); |
2754 } | 2754 } |
2755 } | 2755 } |
2756 } | 2756 } |
2757 | 2757 |
2758 return getUncachedPseudoStyle(PseudoStyleRequest(SELECTION)); | 2758 return getUncachedPseudoStyle(PseudoStyleRequest(SELECTION)); |
2759 } | 2759 } |
2760 | 2760 |
2761 void LayoutObject::getTextDecorations(unsigned decorations, AppliedTextDecoratio
n& underline, AppliedTextDecoration& overline, AppliedTextDecoration& linethroug
h, bool quirksMode, bool firstlineStyle) | 2761 void LayoutObject::getTextDecorations(unsigned decorations, AppliedTextDecoratio
n& underline, AppliedTextDecoration& overline, AppliedTextDecoration& linethroug
h, bool quirksMode, bool firstlineStyle) |
2762 { | 2762 { |
2763 LayoutObject* curr = this; | 2763 LayoutObject* curr = this; |
2764 const LayoutStyle* styleToUse = 0; | 2764 const ComputedStyle* styleToUse = 0; |
2765 unsigned currDecs = TextDecorationNone; | 2765 unsigned currDecs = TextDecorationNone; |
2766 Color resultColor; | 2766 Color resultColor; |
2767 TextDecorationStyle resultStyle; | 2767 TextDecorationStyle resultStyle; |
2768 do { | 2768 do { |
2769 styleToUse = curr->style(firstlineStyle); | 2769 styleToUse = curr->style(firstlineStyle); |
2770 currDecs = styleToUse->textDecoration(); | 2770 currDecs = styleToUse->textDecoration(); |
2771 currDecs &= decorations; | 2771 currDecs &= decorations; |
2772 resultColor = styleToUse->visitedDependentColor(CSSPropertyTextDecoratio
nColor); | 2772 resultColor = styleToUse->visitedDependentColor(CSSPropertyTextDecoratio
nColor); |
2773 resultStyle = styleToUse->textDecorationStyle(); | 2773 resultStyle = styleToUse->textDecorationStyle(); |
2774 // Parameter 'decorations' is cast as an int to enable the bitwise opera
tions below. | 2774 // Parameter 'decorations' is cast as an int to enable the bitwise opera
tions below. |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3230 { | 3230 { |
3231 if (object1) { | 3231 if (object1) { |
3232 const blink::LayoutObject* root = object1; | 3232 const blink::LayoutObject* root = object1; |
3233 while (root->parent()) | 3233 while (root->parent()) |
3234 root = root->parent(); | 3234 root = root->parent(); |
3235 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); | 3235 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); |
3236 } | 3236 } |
3237 } | 3237 } |
3238 | 3238 |
3239 #endif | 3239 #endif |
OLD | NEW |