OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. |
3 * Copyright (C) 2011 Apple Inc. All rights reserved. | 3 * Copyright (C) 2011 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 HTMLStackItem* item = pos->stackItem().get(); | 452 HTMLStackItem* item = pos->stackItem().get(); |
453 if (item->hasLocalName(targetTag)) | 453 if (item->hasLocalName(targetTag)) |
454 return true; | 454 return true; |
455 if (isMarker(item)) | 455 if (isMarker(item)) |
456 return false; | 456 return false; |
457 } | 457 } |
458 ASSERT_NOT_REACHED(); // <html> is always on the stack and is a scope marker
. | 458 ASSERT_NOT_REACHED(); // <html> is always on the stack and is a scope marker
. |
459 return false; | 459 return false; |
460 } | 460 } |
461 | 461 |
| 462 template <bool isMarker(HTMLStackItem*)> |
| 463 bool inScopeCommon(HTMLElementStack::ElementRecord* top, const QualifiedName& ta
rgetTag) |
| 464 { |
| 465 for (HTMLElementStack::ElementRecord* pos = top; pos; pos = pos->next()) { |
| 466 HTMLStackItem* item = pos->stackItem().get(); |
| 467 if (item->hasTagName(targetTag)) |
| 468 return true; |
| 469 if (isMarker(item)) |
| 470 return false; |
| 471 } |
| 472 ASSERT_NOT_REACHED(); // <html> is always on the stack and is a scope marker
. |
| 473 return false; |
| 474 } |
| 475 |
462 bool HTMLElementStack::hasNumberedHeaderElementInScope() const | 476 bool HTMLElementStack::hasNumberedHeaderElementInScope() const |
463 { | 477 { |
464 for (ElementRecord* record = m_top.get(); record; record = record->next()) { | 478 for (ElementRecord* record = m_top.get(); record; record = record->next()) { |
465 HTMLStackItem* item = record->stackItem().get(); | 479 HTMLStackItem* item = record->stackItem().get(); |
466 if (item->isNumberedHeaderElement()) | 480 if (item->isNumberedHeaderElement()) |
467 return true; | 481 return true; |
468 if (isScopeMarker(item)) | 482 if (isScopeMarker(item)) |
469 return false; | 483 return false; |
470 } | 484 } |
471 ASSERT_NOT_REACHED(); // <html> is always on the stack and is a scope marker
. | 485 ASSERT_NOT_REACHED(); // <html> is always on the stack and is a scope marker
. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 return inListItemScope(tagName.localName()); | 521 return inListItemScope(tagName.localName()); |
508 } | 522 } |
509 | 523 |
510 bool HTMLElementStack::inTableScope(const AtomicString& targetTag) const | 524 bool HTMLElementStack::inTableScope(const AtomicString& targetTag) const |
511 { | 525 { |
512 return inScopeCommon<isTableScopeMarker>(m_top.get(), targetTag); | 526 return inScopeCommon<isTableScopeMarker>(m_top.get(), targetTag); |
513 } | 527 } |
514 | 528 |
515 bool HTMLElementStack::inTableScope(const QualifiedName& tagName) const | 529 bool HTMLElementStack::inTableScope(const QualifiedName& tagName) const |
516 { | 530 { |
517 // FIXME: Is localName() right for non-html elements? | 531 return inScopeCommon<isTableScopeMarker>(m_top.get(), tagName); |
518 return inTableScope(tagName.localName()); | |
519 } | 532 } |
520 | 533 |
521 bool HTMLElementStack::inButtonScope(const AtomicString& targetTag) const | 534 bool HTMLElementStack::inButtonScope(const AtomicString& targetTag) const |
522 { | 535 { |
523 return inScopeCommon<isButtonScopeMarker>(m_top.get(), targetTag); | 536 return inScopeCommon<isButtonScopeMarker>(m_top.get(), targetTag); |
524 } | 537 } |
525 | 538 |
526 bool HTMLElementStack::inButtonScope(const QualifiedName& tagName) const | 539 bool HTMLElementStack::inButtonScope(const QualifiedName& tagName) const |
527 { | 540 { |
528 // FIXME: Is localName() right for non-html elements? | 541 // FIXME: Is localName() right for non-html elements? |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 | 638 |
626 void HTMLElementStack::show() | 639 void HTMLElementStack::show() |
627 { | 640 { |
628 for (ElementRecord* record = m_top.get(); record; record = record->next()) | 641 for (ElementRecord* record = m_top.get(); record; record = record->next()) |
629 record->element()->showNode(); | 642 record->element()->showNode(); |
630 } | 643 } |
631 | 644 |
632 #endif | 645 #endif |
633 | 646 |
634 } | 647 } |
OLD | NEW |