| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 return partitionAlloc(Partitions::getRenderingPartition(), sz); | 148 return partitionAlloc(Partitions::getRenderingPartition(), sz); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void RenderObject::operator delete(void* ptr) | 151 void RenderObject::operator delete(void* ptr) |
| 152 { | 152 { |
| 153 ASSERT(isMainThread()); | 153 ASSERT(isMainThread()); |
| 154 partitionFree(ptr); | 154 partitionFree(ptr); |
| 155 } | 155 } |
| 156 #endif | 156 #endif |
| 157 | 157 |
| 158 RenderObject* RenderObject::createObject(Element* element, RenderStyle* style) | 158 RenderObject* RenderObject::createObject(Element* element, const RenderStyle* st
yle) |
| 159 { | 159 { |
| 160 ASSERT(isAllowedToModifyRenderTreeStructure(element->document())); | 160 ASSERT(isAllowedToModifyRenderTreeStructure(element->document())); |
| 161 | 161 |
| 162 // Minimal support for content properties replacing an entire element. | 162 // Minimal support for content properties replacing an entire element. |
| 163 // Works only if we have exactly one piece of content and it's a URL. | 163 // Works only if we have exactly one piece of content and it's a URL. |
| 164 // Otherwise acts as if we didn't support this feature. | 164 // Otherwise acts as if we didn't support this feature. |
| 165 const ContentData* contentData = style->contentData(); | 165 const ContentData* contentData = style->contentData(); |
| 166 if (contentData && !contentData->next() && contentData->isImage() && !elemen
t->isPseudoElement()) { | 166 if (contentData && !contentData->next() && contentData->isImage() && !elemen
t->isPseudoElement()) { |
| 167 RenderImage* image = new RenderImage(element); | 167 RenderImage* image = new RenderImage(element); |
| 168 // RenderImageResourceStyleImage requires a style being present on the i
mage but we don't want to | 168 // RenderImageResourceStyleImage requires a style being present on the i
mage but we don't want to |
| 169 // trigger a style change now as the node is not fully attached. Moving
this code to style change | 169 // trigger a style change now as the node is not fully attached. Moving
this code to style change |
| 170 // doesn't make sense as it should be run once at renderer creation. | 170 // doesn't make sense as it should be run once at renderer creation. |
| 171 image->setStyleInternal(style); | 171 image->setStyleInternal(const_cast<RenderStyle*>(style)); |
| 172 if (const StyleImage* styleImage = toImageContentData(contentData)->imag
e()) { | 172 if (const StyleImage* styleImage = toImageContentData(contentData)->imag
e()) { |
| 173 image->setImageResource(RenderImageResourceStyleImage::create(const_
cast<StyleImage*>(styleImage))); | 173 image->setImageResource(RenderImageResourceStyleImage::create(const_
cast<StyleImage*>(styleImage))); |
| 174 image->setIsGeneratedContent(); | 174 image->setIsGeneratedContent(); |
| 175 } else | 175 } else |
| 176 image->setImageResource(RenderImageResource::create()); | 176 image->setImageResource(RenderImageResource::create()); |
| 177 image->setStyleInternal(nullptr); | 177 image->setStyleInternal(nullptr); |
| 178 return image; | 178 return image; |
| 179 } | 179 } |
| 180 | 180 |
| 181 switch (style->display()) { | 181 switch (style->display()) { |
| (...skipping 1658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1840 if (blockChildrenOnly && !child->isRenderBlock()) | 1840 if (blockChildrenOnly && !child->isRenderBlock()) |
| 1841 continue; | 1841 continue; |
| 1842 | 1842 |
| 1843 if (child->isRenderFullScreen() || child->isRenderFullScreenPlaceholder(
)) | 1843 if (child->isRenderFullScreen() || child->isRenderFullScreenPlaceholder(
)) |
| 1844 continue; | 1844 continue; |
| 1845 | 1845 |
| 1846 RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisp
lay(style(), child->style()->display()); | 1846 RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisp
lay(style(), child->style()->display()); |
| 1847 if (!document().regionBasedColumnsEnabled()) { | 1847 if (!document().regionBasedColumnsEnabled()) { |
| 1848 if (style()->specifiesColumns()) { | 1848 if (style()->specifiesColumns()) { |
| 1849 if (child->style()->specifiesColumns()) | 1849 if (child->style()->specifiesColumns()) |
| 1850 newStyle->inheritColumnPropertiesFrom(style()); | 1850 newStyle->inheritColumnPropertiesFrom(*style()); |
| 1851 if (child->style()->columnSpan()) | 1851 if (child->style()->columnSpan()) |
| 1852 newStyle->setColumnSpan(ColumnSpanAll); | 1852 newStyle->setColumnSpan(ColumnSpanAll); |
| 1853 } | 1853 } |
| 1854 } | 1854 } |
| 1855 | 1855 |
| 1856 // Preserve the position style of anonymous block continuations as they
can have relative position when | 1856 // Preserve the position style of anonymous block continuations as they
can have relative position when |
| 1857 // they contain block descendants of relative positioned inlines. | 1857 // they contain block descendants of relative positioned inlines. |
| 1858 if (child->isRelPositioned() && toRenderBlock(child)->isAnonymousBlockCo
ntinuation()) | 1858 if (child->isRelPositioned() && toRenderBlock(child)->isAnonymousBlockCo
ntinuation()) |
| 1859 newStyle->setPosition(child->style()->position()); | 1859 newStyle->setPosition(child->style()->position()); |
| 1860 | 1860 |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2622 rendererForFirstLineStyle = renderer->parent(); | 2622 rendererForFirstLineStyle = renderer->parent(); |
| 2623 | 2623 |
| 2624 if (rendererForFirstLineStyle->isRenderBlockFlow() || rendererForFirstLineSt
yle->isRenderButton()) { | 2624 if (rendererForFirstLineStyle->isRenderBlockFlow() || rendererForFirstLineSt
yle->isRenderButton()) { |
| 2625 if (RenderBlock* firstLineBlock = rendererForFirstLineStyle->firstLineBl
ock()) { | 2625 if (RenderBlock* firstLineBlock = rendererForFirstLineStyle->firstLineBl
ock()) { |
| 2626 if (type == Cached) | 2626 if (type == Cached) |
| 2627 return firstLineBlock->getCachedPseudoStyle(FIRST_LINE, style); | 2627 return firstLineBlock->getCachedPseudoStyle(FIRST_LINE, style); |
| 2628 return firstLineBlock->getUncachedPseudoStyle(PseudoStyleRequest(FIR
ST_LINE), style, firstLineBlock == renderer ? style : 0); | 2628 return firstLineBlock->getUncachedPseudoStyle(PseudoStyleRequest(FIR
ST_LINE), style, firstLineBlock == renderer ? style : 0); |
| 2629 } | 2629 } |
| 2630 } else if (!rendererForFirstLineStyle->isAnonymous() && rendererForFirstLine
Style->isRenderInline() | 2630 } else if (!rendererForFirstLineStyle->isAnonymous() && rendererForFirstLine
Style->isRenderInline() |
| 2631 && !rendererForFirstLineStyle->node()->isFirstLetterPseudoElement()) { | 2631 && !rendererForFirstLineStyle->node()->isFirstLetterPseudoElement()) { |
| 2632 RenderStyle* parentStyle = rendererForFirstLineStyle->parent()->firstLin
eStyle(); | 2632 const RenderStyle* parentStyle = rendererForFirstLineStyle->parent()->fi
rstLineStyle(); |
| 2633 if (parentStyle != rendererForFirstLineStyle->parent()->style()) { | 2633 if (parentStyle != rendererForFirstLineStyle->parent()->style()) { |
| 2634 if (type == Cached) { | 2634 if (type == Cached) { |
| 2635 // A first-line style is in effect. Cache a first-line style for
ourselves. | 2635 // A first-line style is in effect. Cache a first-line style for
ourselves. |
| 2636 rendererForFirstLineStyle->style()->setHasPseudoStyle(FIRST_LINE
_INHERITED); | 2636 rendererForFirstLineStyle->deprecatedMutableStyle()->setHasPseud
oStyle(FIRST_LINE_INHERITED); |
| 2637 return rendererForFirstLineStyle->getCachedPseudoStyle(FIRST_LIN
E_INHERITED, parentStyle); | 2637 return rendererForFirstLineStyle->getCachedPseudoStyle(FIRST_LIN
E_INHERITED, parentStyle); |
| 2638 } | 2638 } |
| 2639 return rendererForFirstLineStyle->getUncachedPseudoStyle(PseudoStyle
Request(FIRST_LINE_INHERITED), parentStyle, style); | 2639 return rendererForFirstLineStyle->getUncachedPseudoStyle(PseudoStyle
Request(FIRST_LINE_INHERITED), parentStyle, style); |
| 2640 } | 2640 } |
| 2641 } | 2641 } |
| 2642 return nullptr; | 2642 return nullptr; |
| 2643 } | 2643 } |
| 2644 | 2644 |
| 2645 PassRefPtr<RenderStyle> RenderObject::uncachedFirstLineStyle(RenderStyle* style)
const | 2645 PassRefPtr<RenderStyle> RenderObject::uncachedFirstLineStyle(RenderStyle* style)
const |
| 2646 { | 2646 { |
| 2647 if (!document().styleEngine()->usesFirstLineRules()) | 2647 if (!document().styleEngine()->usesFirstLineRules()) |
| 2648 return nullptr; | 2648 return nullptr; |
| 2649 | 2649 |
| 2650 ASSERT(!isText()); | 2650 ASSERT(!isText()); |
| 2651 | 2651 |
| 2652 return firstLineStyleForCachedUncachedType(Uncached, this, style); | 2652 return firstLineStyleForCachedUncachedType(Uncached, this, style); |
| 2653 } | 2653 } |
| 2654 | 2654 |
| 2655 RenderStyle* RenderObject::cachedFirstLineStyle() const | 2655 RenderStyle* RenderObject::cachedFirstLineStyle() const |
| 2656 { | 2656 { |
| 2657 ASSERT(document().styleEngine()->usesFirstLineRules()); | 2657 ASSERT(document().styleEngine()->usesFirstLineRules()); |
| 2658 | 2658 |
| 2659 if (RefPtr<RenderStyle> style = firstLineStyleForCachedUncachedType(Cached,
isText() ? parent() : this, m_style.get())) | 2659 if (RefPtr<RenderStyle> style = firstLineStyleForCachedUncachedType(Cached,
isText() ? parent() : this, m_style.get())) |
| 2660 return style.get(); | 2660 return style.get(); |
| 2661 | 2661 |
| 2662 return m_style.get(); | 2662 return m_style.get(); |
| 2663 } | 2663 } |
| 2664 | 2664 |
| 2665 RenderStyle* RenderObject::getCachedPseudoStyle(PseudoId pseudo, RenderStyle* pa
rentStyle) const | 2665 RenderStyle* RenderObject::getCachedPseudoStyle(PseudoId pseudo, const RenderSty
le* parentStyle) const |
| 2666 { | 2666 { |
| 2667 if (pseudo < FIRST_INTERNAL_PSEUDOID && !style()->hasPseudoStyle(pseudo)) | 2667 if (pseudo < FIRST_INTERNAL_PSEUDOID && !style()->hasPseudoStyle(pseudo)) |
| 2668 return 0; | 2668 return 0; |
| 2669 | 2669 |
| 2670 RenderStyle* cachedStyle = style()->getCachedPseudoStyle(pseudo); | 2670 RenderStyle* cachedStyle = style()->getCachedPseudoStyle(pseudo); |
| 2671 if (cachedStyle) | 2671 if (cachedStyle) |
| 2672 return cachedStyle; | 2672 return cachedStyle; |
| 2673 | 2673 |
| 2674 RefPtr<RenderStyle> result = getUncachedPseudoStyle(PseudoStyleRequest(pseud
o), parentStyle); | 2674 RefPtr<RenderStyle> result = getUncachedPseudoStyle(PseudoStyleRequest(pseud
o), parentStyle); |
| 2675 if (result) | 2675 if (result) |
| 2676 return style()->addCachedPseudoStyle(result.release()); | 2676 return deprecatedMutableStyle()->addCachedPseudoStyle(result.release()); |
| 2677 return 0; | 2677 return 0; |
| 2678 } | 2678 } |
| 2679 | 2679 |
| 2680 PassRefPtr<RenderStyle> RenderObject::getUncachedPseudoStyle(const PseudoStyleRe
quest& pseudoStyleRequest, RenderStyle* parentStyle, RenderStyle* ownStyle) cons
t | 2680 PassRefPtr<RenderStyle> RenderObject::getUncachedPseudoStyle(const PseudoStyleRe
quest& pseudoStyleRequest, const RenderStyle* parentStyle, const RenderStyle* ow
nStyle) const |
| 2681 { | 2681 { |
| 2682 if (pseudoStyleRequest.pseudoId < FIRST_INTERNAL_PSEUDOID && !ownStyle && !s
tyle()->hasPseudoStyle(pseudoStyleRequest.pseudoId)) | 2682 if (pseudoStyleRequest.pseudoId < FIRST_INTERNAL_PSEUDOID && !ownStyle && !s
tyle()->hasPseudoStyle(pseudoStyleRequest.pseudoId)) |
| 2683 return nullptr; | 2683 return nullptr; |
| 2684 | 2684 |
| 2685 if (!parentStyle) { | 2685 if (!parentStyle) { |
| 2686 ASSERT(!ownStyle); | 2686 ASSERT(!ownStyle); |
| 2687 parentStyle = style(); | 2687 parentStyle = style(); |
| 2688 } | 2688 } |
| 2689 | 2689 |
| 2690 if (!node()) | 2690 if (!node()) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2715 } | 2715 } |
| 2716 } | 2716 } |
| 2717 } | 2717 } |
| 2718 | 2718 |
| 2719 return getUncachedPseudoStyle(PseudoStyleRequest(SELECTION)); | 2719 return getUncachedPseudoStyle(PseudoStyleRequest(SELECTION)); |
| 2720 } | 2720 } |
| 2721 | 2721 |
| 2722 void RenderObject::getTextDecorations(unsigned decorations, AppliedTextDecoratio
n& underline, AppliedTextDecoration& overline, AppliedTextDecoration& linethroug
h, bool quirksMode, bool firstlineStyle) | 2722 void RenderObject::getTextDecorations(unsigned decorations, AppliedTextDecoratio
n& underline, AppliedTextDecoration& overline, AppliedTextDecoration& linethroug
h, bool quirksMode, bool firstlineStyle) |
| 2723 { | 2723 { |
| 2724 RenderObject* curr = this; | 2724 RenderObject* curr = this; |
| 2725 RenderStyle* styleToUse = 0; | 2725 const RenderStyle* styleToUse = 0; |
| 2726 unsigned currDecs = TextDecorationNone; | 2726 unsigned currDecs = TextDecorationNone; |
| 2727 Color resultColor; | 2727 Color resultColor; |
| 2728 TextDecorationStyle resultStyle; | 2728 TextDecorationStyle resultStyle; |
| 2729 do { | 2729 do { |
| 2730 styleToUse = curr->style(firstlineStyle); | 2730 styleToUse = curr->style(firstlineStyle); |
| 2731 currDecs = styleToUse->textDecoration(); | 2731 currDecs = styleToUse->textDecoration(); |
| 2732 currDecs &= decorations; | 2732 currDecs &= decorations; |
| 2733 resultColor = styleToUse->visitedDependentColor(CSSPropertyTextDecoratio
nColor); | 2733 resultColor = styleToUse->visitedDependentColor(CSSPropertyTextDecoratio
nColor); |
| 2734 resultStyle = styleToUse->textDecorationStyle(); | 2734 resultStyle = styleToUse->textDecorationStyle(); |
| 2735 // Parameter 'decorations' is cast as an int to enable the bitwise opera
tions below. | 2735 // Parameter 'decorations' is cast as an int to enable the bitwise opera
tions below. |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3158 { | 3158 { |
| 3159 if (object1) { | 3159 if (object1) { |
| 3160 const blink::RenderObject* root = object1; | 3160 const blink::RenderObject* root = object1; |
| 3161 while (root->parent()) | 3161 while (root->parent()) |
| 3162 root = root->parent(); | 3162 root = root->parent(); |
| 3163 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); | 3163 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); |
| 3164 } | 3164 } |
| 3165 } | 3165 } |
| 3166 | 3166 |
| 3167 #endif | 3167 #endif |
| OLD | NEW |