| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 } | 558 } |
| 559 if (!m_languageStack.isEmpty()) | 559 if (!m_languageStack.isEmpty()) |
| 560 child->setLanguage(m_languageStack.last()); | 560 child->setLanguage(m_languageStack.last()); |
| 561 m_currentNode->parserAppendChild(child); | 561 m_currentNode->parserAppendChild(child); |
| 562 m_currentNode = child; | 562 m_currentNode = child; |
| 563 } | 563 } |
| 564 break; | 564 break; |
| 565 } | 565 } |
| 566 case VTTTokenTypes::EndTag: { | 566 case VTTTokenTypes::EndTag: { |
| 567 VTTNodeType nodeType = tokenToNodeType(m_token); | 567 VTTNodeType nodeType = tokenToNodeType(m_token); |
| 568 if (nodeType != VTTNodeTypeNone) { | 568 if (nodeType == VTTNodeTypeNone) |
| 569 if (nodeType == VTTNodeTypeLanguage && m_currentNode->isVTTElement()
&& toVTTElement(m_currentNode.get())->webVTTNodeType() == VTTNodeTypeLanguage) | 569 break; |
| 570 m_languageStack.removeLast(); | 570 |
| 571 if (m_currentNode->parentNode()) | 571 // The only non-VTTElement would be the DocumentFragment root. (Text |
| 572 m_currentNode = m_currentNode->parentNode(); | 572 // nodes and PIs will never appear as m_currentNode.) |
| 573 if (!m_currentNode->isVTTElement()) |
| 574 break; |
| 575 |
| 576 VTTNodeType currentType = toVTTElement(m_currentNode.get())->webVTTNodeT
ype(); |
| 577 bool matchesCurrent = nodeType == currentType; |
| 578 if (!matchesCurrent) { |
| 579 // </ruby> auto-closes <rt>. |
| 580 if (currentType == VTTNodeTypeRubyText && nodeType == VTTNodeTypeRub
y) { |
| 581 if (m_currentNode->parentNode()) |
| 582 m_currentNode = m_currentNode->parentNode(); |
| 583 } else { |
| 584 break; |
| 585 } |
| 573 } | 586 } |
| 587 if (nodeType == VTTNodeTypeLanguage) |
| 588 m_languageStack.removeLast(); |
| 589 if (m_currentNode->parentNode()) |
| 590 m_currentNode = m_currentNode->parentNode(); |
| 574 break; | 591 break; |
| 575 } | 592 } |
| 576 case VTTTokenTypes::TimestampTag: { | 593 case VTTTokenTypes::TimestampTag: { |
| 577 unsigned position = 0; | 594 unsigned position = 0; |
| 578 String charactersString = m_token.characters(); | 595 String charactersString = m_token.characters(); |
| 579 double time = VTTParser::collectTimeStamp(charactersString, &position); | 596 double time = VTTParser::collectTimeStamp(charactersString, &position); |
| 580 if (time != malformedTime) | 597 if (time != malformedTime) |
| 581 m_currentNode->parserAppendChild(ProcessingInstruction::create(docum
ent, "timestamp", charactersString)); | 598 m_currentNode->parserAppendChild(ProcessingInstruction::create(docum
ent, "timestamp", charactersString)); |
| 582 break; | 599 break; |
| 583 } | 600 } |
| 584 default: | 601 default: |
| 585 break; | 602 break; |
| 586 } | 603 } |
| 587 } | 604 } |
| 588 | 605 |
| 589 void VTTParser::skipWhiteSpace(const String& line, unsigned* position) | 606 void VTTParser::skipWhiteSpace(const String& line, unsigned* position) |
| 590 { | 607 { |
| 591 while (*position < line.length() && isASpace(line[*position])) | 608 while (*position < line.length() && isASpace(line[*position])) |
| 592 (*position)++; | 609 (*position)++; |
| 593 } | 610 } |
| 594 | 611 |
| 595 } | 612 } |
| 596 | 613 |
| OLD | NEW |