| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) | 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) |
| 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. |
| 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
| 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
| 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
| 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 // if the last matched element is a shadow host, the condition above isn't m
et, even though it | 57 // if the last matched element is a shadow host, the condition above isn't m
et, even though it |
| 58 // should be. | 58 // should be. |
| 59 return context.element == context.scope->shadowHost(); | 59 return context.element == context.scope->shadowHost(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 bool SelectorChecker::match(const SelectorCheckingContext& context) const | 62 bool SelectorChecker::match(const SelectorCheckingContext& context) const |
| 63 { | 63 { |
| 64 // FIXME(sky): Get rid of SelectorCheckingContext. | 64 // FIXME(sky): Get rid of SelectorCheckingContext. |
| 65 SelectorCheckingContext matchContext(context); | 65 SelectorCheckingContext matchContext(context); |
| 66 | 66 |
| 67 bool isShadowHost = isHostInItsShadowTree(*context.element, context.scope) | 67 bool isShadowHost = isHostInItsShadowTree(*context.element, context.scope); |
| 68 && !(context.contextFlags & TreatShadowHostAsNormalScope); | |
| 69 | 68 |
| 70 while (true) { | 69 while (true) { |
| 71 const CSSSelector& selector = *matchContext.selector; | 70 const CSSSelector& selector = *matchContext.selector; |
| 72 // Only :host and :host-context() should match the host: | 71 // Only :host and :host-context() should match the host: |
| 73 // http://drafts.csswg.org/css-scoping/#host-element | 72 // http://drafts.csswg.org/css-scoping/#host-element |
| 74 if (isShadowHost && !selector.isHostPseudoClass()) | 73 if (isShadowHost && !selector.isHostPseudoClass()) |
| 75 return false; | 74 return false; |
| 76 if (!checkOne(matchContext)) | 75 if (!checkOne(matchContext)) |
| 77 return false; | 76 return false; |
| 78 if (selector.isLastInTagHistory()) | 77 if (selector.isLastInTagHistory()) |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 const ContainerNode* shadowHost = context.scope->shadowHost(); | 279 const ContainerNode* shadowHost = context.scope->shadowHost(); |
| 281 if (!shadowHost || shadowHost != element) | 280 if (!shadowHost || shadowHost != element) |
| 282 return false; | 281 return false; |
| 283 ASSERT(element.shadow()); | 282 ASSERT(element.shadow()); |
| 284 | 283 |
| 285 // For empty parameter case, i.e. just :host or :host(). | 284 // For empty parameter case, i.e. just :host or :host(). |
| 286 if (!selector.selectorList()) | 285 if (!selector.selectorList()) |
| 287 return true; | 286 return true; |
| 288 | 287 |
| 289 SelectorCheckingContext subContext(context); | 288 SelectorCheckingContext subContext(context); |
| 290 subContext.contextFlags = TreatShadowHostAsNormalScope; | 289 |
| 290 // Treat the inside of :host() rules as if they were defined in the |
| 291 // same scope as the host. |
| 292 subContext.scope = &context.element->treeScope().rootNode(); |
| 291 | 293 |
| 292 for (subContext.selector = selector.selectorList()->first(); subCont
ext.selector; subContext.selector = CSSSelectorList::next(*subContext.selector))
{ | 294 for (subContext.selector = selector.selectorList()->first(); subCont
ext.selector; subContext.selector = CSSSelectorList::next(*subContext.selector))
{ |
| 293 if (match(subContext)) | 295 if (match(subContext)) |
| 294 return true; | 296 return true; |
| 295 } | 297 } |
| 296 return false; | 298 return false; |
| 297 } | 299 } |
| 298 | 300 |
| 299 case CSSSelector::PseudoUnknown: | 301 case CSSSelector::PseudoUnknown: |
| 300 case CSSSelector::PseudoNotParsed: | 302 case CSSSelector::PseudoNotParsed: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 311 return false; | 313 return false; |
| 312 LocalFrame* frame = element.document().frame(); | 314 LocalFrame* frame = element.document().frame(); |
| 313 if (!frame) | 315 if (!frame) |
| 314 return false; | 316 return false; |
| 315 if (!frame->selection().isFocusedAndActive()) | 317 if (!frame->selection().isFocusedAndActive()) |
| 316 return false; | 318 return false; |
| 317 return true; | 319 return true; |
| 318 } | 320 } |
| 319 | 321 |
| 320 } | 322 } |
| OLD | NEW |