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. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. |
7 * All rights reserved. | 7 * All rights reserved. |
8 * Copyright (C) 2009 Google Inc. All rights reserved. | 8 * Copyright (C) 2009 Google Inc. All rights reserved. |
9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. | 9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. |
10 * (http://www.torchmobile.com/) | 10 * (http://www.torchmobile.com/) |
(...skipping 3066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3077 if (RefPtr<ComputedStyle> style = firstLineStyleForCachedUncachedType( | 3077 if (RefPtr<ComputedStyle> style = firstLineStyleForCachedUncachedType( |
3078 Cached, isText() ? parent() : this, m_style.get())) | 3078 Cached, isText() ? parent() : this, m_style.get())) |
3079 return style.get(); | 3079 return style.get(); |
3080 | 3080 |
3081 return m_style.get(); | 3081 return m_style.get(); |
3082 } | 3082 } |
3083 | 3083 |
3084 ComputedStyle* LayoutObject::getCachedPseudoStyle( | 3084 ComputedStyle* LayoutObject::getCachedPseudoStyle( |
3085 PseudoId pseudo, | 3085 PseudoId pseudo, |
3086 const ComputedStyle* parentStyle) const { | 3086 const ComputedStyle* parentStyle) const { |
3087 if (pseudo < FirstInternalPseudoId && !style()->hasPseudoStyle(pseudo)) | 3087 DCHECK_NE(pseudo, PseudoIdBefore); |
| 3088 DCHECK_NE(pseudo, PseudoIdAfter); |
| 3089 if (!node()) |
3088 return nullptr; | 3090 return nullptr; |
3089 | 3091 |
3090 ComputedStyle* cachedStyle = style()->getCachedPseudoStyle(pseudo); | 3092 Element* element = Traversal<Element>::firstAncestorOrSelf(*node()); |
3091 if (cachedStyle) | 3093 if (!element) |
3092 return cachedStyle; | 3094 return nullptr; |
3093 | 3095 |
3094 RefPtr<ComputedStyle> result = | 3096 return element->pseudoStyle(PseudoStyleRequest(pseudo), parentStyle); |
3095 getUncachedPseudoStyle(PseudoStyleRequest(pseudo), parentStyle); | |
3096 if (result) | |
3097 return mutableStyleRef().addCachedPseudoStyle(result.release()); | |
3098 return nullptr; | |
3099 } | 3097 } |
3100 | 3098 |
3101 PassRefPtr<ComputedStyle> LayoutObject::getUncachedPseudoStyle( | 3099 PassRefPtr<ComputedStyle> LayoutObject::getUncachedPseudoStyle( |
3102 const PseudoStyleRequest& pseudoStyleRequest, | 3100 const PseudoStyleRequest& request, |
3103 const ComputedStyle* parentStyle) const { | 3101 const ComputedStyle* parentStyle) const { |
3104 if (pseudoStyleRequest.pseudoId < FirstInternalPseudoId && | 3102 DCHECK_NE(request.pseudoId, PseudoIdBefore); |
3105 !style()->hasPseudoStyle(pseudoStyleRequest.pseudoId)) | 3103 DCHECK_NE(request.pseudoId, PseudoIdAfter); |
3106 return nullptr; | |
3107 | |
3108 if (!parentStyle) | |
3109 parentStyle = style(); | |
3110 | |
3111 if (!node()) | 3104 if (!node()) |
3112 return nullptr; | 3105 return nullptr; |
3113 | 3106 |
3114 Element* element = Traversal<Element>::firstAncestorOrSelf(*node()); | 3107 Element* element = Traversal<Element>::firstAncestorOrSelf(*node()); |
3115 if (!element) | 3108 if (!element) |
3116 return nullptr; | 3109 return nullptr; |
3117 | 3110 |
3118 if (pseudoStyleRequest.pseudoId == PseudoIdFirstLineInherited) { | 3111 return element->getUncachedPseudoStyle(request, parentStyle); |
3119 RefPtr<ComputedStyle> result = | |
3120 document().ensureStyleResolver().styleForElement( | |
3121 element, parentStyle, parentStyle, DisallowStyleSharing); | |
3122 result->setStyleType(PseudoIdFirstLineInherited); | |
3123 return result.release(); | |
3124 } | |
3125 | |
3126 return document().ensureStyleResolver().pseudoStyleForElement( | |
3127 element, pseudoStyleRequest, parentStyle, parentStyle); | |
3128 } | 3112 } |
3129 | 3113 |
3130 PassRefPtr<ComputedStyle> LayoutObject::getUncachedSelectionStyle() const { | 3114 PassRefPtr<ComputedStyle> LayoutObject::getUncachedSelectionStyle() const { |
3131 if (!node()) | 3115 if (!node()) |
3132 return nullptr; | 3116 return nullptr; |
3133 | 3117 |
3134 // In Blink, ::selection only applies to direct children of the element on | 3118 // In Blink, ::selection only applies to direct children of the element on |
3135 // which ::selection is matched. In order to be able to style ::selection | 3119 // which ::selection is matched. In order to be able to style ::selection |
3136 // inside elements implemented with a UA shadow tree, like input::selection, | 3120 // inside elements implemented with a UA shadow tree, like input::selection, |
3137 // we calculate ::selection style on the shadow host for elements inside the | 3121 // we calculate ::selection style on the shadow host for elements inside the |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3647 const blink::LayoutObject* root = object1; | 3631 const blink::LayoutObject* root = object1; |
3648 while (root->parent()) | 3632 while (root->parent()) |
3649 root = root->parent(); | 3633 root = root->parent(); |
3650 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); | 3634 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); |
3651 } else { | 3635 } else { |
3652 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); | 3636 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); |
3653 } | 3637 } |
3654 } | 3638 } |
3655 | 3639 |
3656 #endif | 3640 #endif |
OLD | NEW |