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. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. |
6 * All rights reserved. | 6 * All rights reserved. |
7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
10 * (http://www.torchmobile.com/) | 10 * (http://www.torchmobile.com/) |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
304 | 304 |
305 CSSSelector::RelationType relation = context.selector->Relation(); | 305 CSSSelector::RelationType relation = context.selector->Relation(); |
306 | 306 |
307 // Disable :visited matching when we see the first link or try to match | 307 // Disable :visited matching when we see the first link or try to match |
308 // anything else than an ancestors. | 308 // anything else than an ancestors. |
309 if (!context.is_sub_selector && | 309 if (!context.is_sub_selector && |
310 (context.element->IsLink() || (relation != CSSSelector::kDescendant && | 310 (context.element->IsLink() || (relation != CSSSelector::kDescendant && |
311 relation != CSSSelector::kChild))) | 311 relation != CSSSelector::kChild))) |
312 next_context.visited_match_type = kVisitedMatchDisabled; | 312 next_context.visited_match_type = kVisitedMatchDisabled; |
313 | 313 |
314 // The ParentElement() method will walk up to the host element for :host() and | |
315 // :host-context() rules in the same scope as the element we are matching. | |
316 // For kSharingRules, we don't know which scope the rules came from, so we are | |
317 // using nullptr as scope. This is a workaround to make ParentElement() walk | |
318 // up to the host when matching :host rules by assuming the scope of the :host | |
319 // rule is the same as the element we are matching rules for. | |
320 if (mode_ == kSharingRules && next_context.selector->IsHostPseudoClass()) | |
321 next_context.scope = next_context.element->ContainingShadowRoot(); | |
322 | |
314 next_context.in_rightmost_compound = false; | 323 next_context.in_rightmost_compound = false; |
315 next_context.is_sub_selector = false; | 324 next_context.is_sub_selector = false; |
316 next_context.previous_element = context.element; | 325 next_context.previous_element = context.element; |
317 next_context.pseudo_id = kPseudoIdNone; | 326 next_context.pseudo_id = kPseudoIdNone; |
318 | 327 |
319 switch (relation) { | 328 switch (relation) { |
320 case CSSSelector::kDescendant: | 329 case CSSSelector::kDescendant: |
321 if (context.selector->RelationIsAffectedByPseudoContent()) { | 330 if (context.selector->RelationIsAffectedByPseudoContent()) { |
322 for (Element* element = context.element; element; | 331 for (Element* element = context.element; element; |
323 element = element->parentElement()) { | 332 element = element->parentElement()) { |
324 if (MatchForPseudoContent(next_context, *element, result) == | 333 if (MatchForPseudoContent(next_context, *element, result) == |
325 kSelectorMatches) | 334 kSelectorMatches) |
326 return kSelectorMatches; | 335 return kSelectorMatches; |
327 } | 336 } |
328 return kSelectorFailsCompletely; | 337 return kSelectorFailsCompletely; |
329 } | 338 } |
330 | 339 |
331 if (next_context.selector->GetPseudoType() == CSSSelector::kPseudoShadow) | 340 if (next_context.selector->GetPseudoType() == CSSSelector::kPseudoShadow) |
332 return MatchForPseudoShadow( | 341 return MatchForPseudoShadow( |
333 next_context, context.element->ContainingShadowRoot(), result); | 342 next_context, context.element->ContainingShadowRoot(), result); |
334 | 343 |
335 for (next_context.element = ParentElement(context); next_context.element; | 344 for (next_context.element = ParentElement(next_context); |
kochi
2017/04/19 10:21:12
This looks like a bug, but is this for bug 711539?
rune
2017/04/19 22:49:47
The element is initially the same for context and
kochi
2017/04/20 10:45:21
Acknowledged.
| |
345 next_context.element; | |
336 next_context.element = ParentElement(next_context)) { | 346 next_context.element = ParentElement(next_context)) { |
337 MatchStatus match = MatchSelector(next_context, result); | 347 MatchStatus match = MatchSelector(next_context, result); |
338 if (match == kSelectorMatches || match == kSelectorFailsCompletely) | 348 if (match == kSelectorMatches || match == kSelectorFailsCompletely) |
339 return match; | 349 return match; |
340 if (NextSelectorExceedsScope(next_context)) | 350 if (NextSelectorExceedsScope(next_context)) |
341 return kSelectorFailsCompletely; | 351 return kSelectorFailsCompletely; |
342 } | 352 } |
343 return kSelectorFailsCompletely; | 353 return kSelectorFailsCompletely; |
344 case CSSSelector::kChild: { | 354 case CSSSelector::kChild: { |
345 if (context.selector->RelationIsAffectedByPseudoContent()) | 355 if (context.selector->RelationIsAffectedByPseudoContent()) |
346 return MatchForPseudoContent(next_context, *context.element, result); | 356 return MatchForPseudoContent(next_context, *context.element, result); |
347 | 357 |
348 if (next_context.selector->GetPseudoType() == CSSSelector::kPseudoShadow) | 358 if (next_context.selector->GetPseudoType() == CSSSelector::kPseudoShadow) |
349 return MatchForPseudoShadow(next_context, context.element->parentNode(), | 359 return MatchForPseudoShadow(next_context, context.element->parentNode(), |
350 result); | 360 result); |
351 | 361 |
352 next_context.element = ParentElement(context); | 362 next_context.element = ParentElement(next_context); |
kochi
2017/04/19 10:21:12
Ditto
| |
353 if (!next_context.element) | 363 if (!next_context.element) |
354 return kSelectorFailsCompletely; | 364 return kSelectorFailsCompletely; |
355 return MatchSelector(next_context, result); | 365 return MatchSelector(next_context, result); |
356 } | 366 } |
357 case CSSSelector::kDirectAdjacent: | 367 case CSSSelector::kDirectAdjacent: |
358 // Shadow roots can't have sibling elements | 368 // Shadow roots can't have sibling elements |
359 if (next_context.selector->GetPseudoType() == CSSSelector::kPseudoShadow) | 369 if (next_context.selector->GetPseudoType() == CSSSelector::kPseudoShadow) |
360 return kSelectorFailsCompletely; | 370 return kSelectorFailsCompletely; |
361 | 371 |
362 if (mode_ == kResolvingStyle) { | 372 if (mode_ == kResolvingStyle) { |
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1351 bool SelectorChecker::MatchesFocusPseudoClass(const Element& element) { | 1361 bool SelectorChecker::MatchesFocusPseudoClass(const Element& element) { |
1352 bool force_pseudo_state = false; | 1362 bool force_pseudo_state = false; |
1353 probe::forcePseudoState(const_cast<Element*>(&element), | 1363 probe::forcePseudoState(const_cast<Element*>(&element), |
1354 CSSSelector::kPseudoFocus, &force_pseudo_state); | 1364 CSSSelector::kPseudoFocus, &force_pseudo_state); |
1355 if (force_pseudo_state) | 1365 if (force_pseudo_state) |
1356 return true; | 1366 return true; |
1357 return element.IsFocused() && IsFrameFocused(element); | 1367 return element.IsFocused() && IsFrameFocused(element); |
1358 } | 1368 } |
1359 | 1369 |
1360 } // namespace blink | 1370 } // namespace blink |
OLD | NEW |