Changeset 62537 in webkit


Ignore:
Timestamp:
Jul 6, 2010 1:16:50 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-07-06 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

Implement bookmarking for HTML5 Adoption Agency algorithm
https://bugs.webkit.org/show_bug.cgi?id=41659

Added 3 new adoption tests because the suite didn't
cover all the bookmarking cases.

  • html5lib/runner-expected-html5.txt:
    • Fixes tests!
  • html5lib/resources/adoption01.dat

2010-07-06 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

Implement bookmarking for HTML5 Adoption Agency algorithm
https://bugs.webkit.org/show_bug.cgi?id=41659

Was easier than I expected it to be.
Fixes a bunch of html5lib/runner.html tests.

  • html/HTMLFormattingElementList.cpp: (WebCore::HTMLFormattingElementList::bookmarkFor): (WebCore::HTMLFormattingElementList::insertAt):
  • html/HTMLFormattingElementList.h: (WebCore::HTMLFormattingElementList::Bookmark::Bookmark): (WebCore::HTMLFormattingElementList::Bookmark::moveToAfter): (WebCore::HTMLFormattingElementList::Bookmark::elementBefore): (WebCore::HTMLFormattingElementList::Bookmark::elementAfter):
  • html/HTMLTreeBuilder.cpp: (WebCore::HTMLTreeBuilder::callTheAdoptionAgency):
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r62534 r62537  
     12010-07-06  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Implement bookmarking for HTML5 Adoption Agency algorithm
     6        https://bugs.webkit.org/show_bug.cgi?id=41659
     7
     8        Added 3 new adoption tests because the suite didn't
     9        cover all the bookmarking cases.
     10
     11        * html5lib/runner-expected-html5.txt:
     12         - Fixes tests!
     13        * html5lib/resources/adoption01.dat
     14
    1152010-07-06  Nikolas Zimmermann  <nzimmermann@rim.com>
    216
  • trunk/LayoutTests/html5lib/resources/adoption01.dat

    r62468 r62537  
    8383|       "3"
    8484|     <table>
     85
     86#data
     87<b><b><a><p></a>
     88#errors
     89#document
     90| <html>
     91|   <head>
     92|   <body>
     93|     <b>
     94|       <b>
     95|         <a>
     96|         <p>
     97|           <a>
     98
     99#data
     100<b><a><b><p></a>
     101#errors
     102#document
     103| <html>
     104|   <head>
     105|   <body>
     106|     <b>
     107|       <a>
     108|         <b>
     109|       <b>
     110|         <p>
     111|           <a>
     112
     113#data
     114<a><b><b><p></a>
     115#errors
     116#document
     117| <html>
     118|   <head>
     119|   <body>
     120|     <a>
     121|       <b>
     122|         <b>
     123|     <b>
     124|       <b>
     125|         <p>
     126|           <a>
  • trunk/LayoutTests/html5lib/runner-expected-html5.txt

    r62533 r62537  
    141433
    151550
    16 51
    171656
    18 60
    19 61
    20 72
    21 73
    22 74
    23 75
    24 76
    251778
    261879
     
    299291|     "-->  EOF"
    300292
    301 Test 51 of 113 in resources/tests1.dat failed. Input:
    302 <b><p></b>TEST
    303 Got:
    304 | <html>
    305 |   <head>
    306 |   <body>
    307 |     <b>
    308 |     <p>
    309 |       <b>
    310 |         "TEST"
    311 Expected:
    312 | <html>
    313 |   <head>
    314 |   <body>
    315 |     <b>
    316 |     <p>
    317 |       <b>
    318 |       "TEST"
    319 
    320293Test 56 of 113 in resources/tests1.dat failed. Input:
    321294<font><p>hello<b>cruel</font>world
     
    329302|         "hello"
    330303|         <b>
    331 |           "cruelworld"
     304|           "cruel"
     305|       "world"
    332306Expected:
    333307| <html>
     
    342316|       <b>
    343317|         "world"
    344 
    345 Test 60 of 113 in resources/tests1.dat failed. Input:
    346 <b>A<cite>B<div>C</b>D
    347 Got:
    348 | <html>
    349 |   <head>
    350 |   <body>
    351 |     <b>
    352 |       "A"
    353 |       <cite>
    354 |         "B"
    355 |     <div>
    356 |       <b>
    357 |         "CD"
    358 Expected:
    359 | <html>
    360 |   <head>
    361 |   <body>
    362 |     <b>
    363 |       "A"
    364 |       <cite>
    365 |         "B"
    366 |     <div>
    367 |       <b>
    368 |         "C"
    369 |       "D"
    370 
    371 Test 61 of 113 in resources/tests1.dat failed. Input:
    372 <cite><b><cite><i><cite><i><cite><i><div>X</b>TEST
    373 Got:
    374 | <html>
    375 |   <head>
    376 |   <body>
    377 |     <cite>
    378 |       <b>
    379 |         <cite>
    380 |           <i>
    381 |             <cite>
    382 |               <i>
    383 |                 <cite>
    384 |                   <i>
    385 |       <i>
    386 |         <i>
    387 |           <i>
    388 |             <div>
    389 |               <b>
    390 |                 "XTEST"
    391 Expected:
    392 | <html>
    393 |   <head>
    394 |   <body>
    395 |     <cite>
    396 |       <b>
    397 |         <cite>
    398 |           <i>
    399 |             <cite>
    400 |               <i>
    401 |                 <cite>
    402 |                   <i>
    403 |       <i>
    404 |         <i>
    405 |           <i>
    406 |             <div>
    407 |               <b>
    408 |                 "X"
    409 |               "TEST"
    410 
    411 Test 72 of 113 in resources/tests1.dat failed. Input:
    412 <DIV> abc <B> def <I> ghi <P> jkl </B> mno
    413 Got:
    414 | <html>
    415 |   <head>
    416 |   <body>
    417 |     <div>
    418 |       " abc "
    419 |       <b>
    420 |         " def "
    421 |         <i>
    422 |           " ghi "
    423 |       <i>
    424 |         <p>
    425 |           <b>
    426 |             " jkl  mno"
    427 Expected:
    428 | <html>
    429 |   <head>
    430 |   <body>
    431 |     <div>
    432 |       " abc "
    433 |       <b>
    434 |         " def "
    435 |         <i>
    436 |           " ghi "
    437 |       <i>
    438 |         <p>
    439 |           <b>
    440 |             " jkl "
    441 |           " mno"
    442 
    443 Test 73 of 113 in resources/tests1.dat failed. Input:
    444 <DIV> abc <B> def <I> ghi <P> jkl </B> mno </I>
    445 Got:
    446 | <html>
    447 |   <head>
    448 |   <body>
    449 |     <div>
    450 |       " abc "
    451 |       <b>
    452 |         " def "
    453 |         <i>
    454 |           " ghi "
    455 |       <i>
    456 |       <p>
    457 |         <i>
    458 |           <b>
    459 |             " jkl  mno "
    460 Expected:
    461 | <html>
    462 |   <head>
    463 |   <body>
    464 |     <div>
    465 |       " abc "
    466 |       <b>
    467 |         " def "
    468 |         <i>
    469 |           " ghi "
    470 |       <i>
    471 |       <p>
    472 |         <i>
    473 |           <b>
    474 |             " jkl "
    475 |           " mno "
    476 
    477 Test 74 of 113 in resources/tests1.dat failed. Input:
    478 <DIV> abc <B> def <I> ghi <P> jkl </B> mno </I> pqr
    479 Got:
    480 | <html>
    481 |   <head>
    482 |   <body>
    483 |     <div>
    484 |       " abc "
    485 |       <b>
    486 |         " def "
    487 |         <i>
    488 |           " ghi "
    489 |       <i>
    490 |       <p>
    491 |         <i>
    492 |           <b>
    493 |             " jkl  mno  pqr"
    494 Expected:
    495 | <html>
    496 |   <head>
    497 |   <body>
    498 |     <div>
    499 |       " abc "
    500 |       <b>
    501 |         " def "
    502 |         <i>
    503 |           " ghi "
    504 |       <i>
    505 |       <p>
    506 |         <i>
    507 |           <b>
    508 |             " jkl "
    509 |           " mno "
    510 |         " pqr"
    511 
    512 Test 75 of 113 in resources/tests1.dat failed. Input:
    513 <DIV> abc <B> def <I> ghi <P> jkl </B> mno </I> pqr </P>
    514 Got:
    515 | <html>
    516 |   <head>
    517 |   <body>
    518 |     <div>
    519 |       " abc "
    520 |       <b>
    521 |         " def "
    522 |         <i>
    523 |           " ghi "
    524 |       <i>
    525 |       <p>
    526 |         <i>
    527 |           <b>
    528 |             " jkl  mno  pqr "
    529 Expected:
    530 | <html>
    531 |   <head>
    532 |   <body>
    533 |     <div>
    534 |       " abc "
    535 |       <b>
    536 |         " def "
    537 |         <i>
    538 |           " ghi "
    539 |       <i>
    540 |       <p>
    541 |         <i>
    542 |           <b>
    543 |             " jkl "
    544 |           " mno "
    545 |         " pqr "
    546 
    547 Test 76 of 113 in resources/tests1.dat failed. Input:
    548 <DIV> abc <B> def <I> ghi <P> jkl </B> mno </I> pqr </P> stu
    549 Got:
    550 | <html>
    551 |   <head>
    552 |   <body>
    553 |     <div>
    554 |       " abc "
    555 |       <b>
    556 |         " def "
    557 |         <i>
    558 |           " ghi "
    559 |       <i>
    560 |       <p>
    561 |         <i>
    562 |           <b>
    563 |             " jkl  mno  pqr "
    564 |       " stu"
    565 Expected:
    566 | <html>
    567 |   <head>
    568 |   <body>
    569 |     <div>
    570 |       " abc "
    571 |       <b>
    572 |         " def "
    573 |         <i>
    574 |           " ghi "
    575 |       <i>
    576 |       <p>
    577 |         <i>
    578 |           <b>
    579 |             " jkl "
    580 |           " mno "
    581 |         " pqr "
    582 |       " stu"
    583318
    584319Test 78 of 113 in resources/tests1.dat failed. Input:
     
    216218976
    216318987
    2164 8
    2165 9
    21661899
    21671900Test 1 of 9 in resources/tests8.dat failed. Input:
     
    23042037|     "x"
    23052038|     <table>
    2306 
    2307 Test 8 of 9 in resources/tests8.dat failed. Input:
    2308 <b>a<div></div><div></b>y
    2309 Got:
    2310 | <html>
    2311 |   <head>
    2312 |   <body>
    2313 |     <b>
    2314 |       "a"
    2315 |       <div>
    2316 |     <div>
    2317 |       <b>
    2318 |         "y"
    2319 Expected:
    2320 | <html>
    2321 |   <head>
    2322 |   <body>
    2323 |     <b>
    2324 |       "a"
    2325 |       <div>
    2326 |     <div>
    2327 |       <b>
    2328 |       "y"
    2329 
    2330 Test 9 of 9 in resources/tests8.dat failed. Input:
    2331 <a><div><p></a>
    2332 Got:
    2333 | <html>
    2334 |   <head>
    2335 |   <body>
    2336 |     <a>
    2337 |     <div>
    2338 |       <a>
    2339 |         <p>
    2340 Expected:
    2341 | <html>
    2342 |   <head>
    2343 |   <body>
    2344 |     <a>
    2345 |     <div>
    2346 |       <a>
    2347 |       <p>
    2348 |         <a>
    23492039resources/tests9.dat:
    235020401
     
    47454435
    47464436resources/adoption01.dat:
    4747 2
    474844373
    474944384
     
    475144406
    47524441
    4753 Test 2 of 6 in resources/adoption01.dat failed. Input:
    4754 <a>1<p>2</a>3</p>
    4755 Got:
    4756 | <html>
    4757 |   <head>
    4758 |   <body>
    4759 |     <a>
    4760 |       "1"
    4761 |     <p>
    4762 |       <a>
    4763 |         "23"
    4764 Expected:
    4765 | <html>
    4766 |   <head>
    4767 |   <body>
    4768 |     <a>
    4769 |       "1"
    4770 |     <p>
    4771 |       <a>
    4772 |         "2"
    4773 |       "3"
    4774 
    4775 Test 3 of 6 in resources/adoption01.dat failed. Input:
     4442Test 3 of 9 in resources/adoption01.dat failed. Input:
    47764443<a>1<button>2</a>3</button>
    47774444Got:
     
    47934460|     "3"
    47944461
    4795 Test 4 of 6 in resources/adoption01.dat failed. Input:
     4462Test 4 of 9 in resources/adoption01.dat failed. Input:
    47964463<a>1<b>2</a>3</b>
    47974464Got:
     
    48154482|       "3"
    48164483
    4817 Test 5 of 6 in resources/adoption01.dat failed. Input:
     4484Test 5 of 9 in resources/adoption01.dat failed. Input:
    48184485<a>1<div>2<div>3</a>4</div>5</div>
    48194486Got:
     
    48264493|       <a>
    48274494|         "2"
    4828 |         <div>
    4829 |           "34"
     4495|       <div>
     4496|         <a>
     4497|           "3"
     4498|         "4"
    48304499|     "5"
    48314500Expected:
     
    48444513|       "5"
    48454514
    4846 Test 6 of 6 in resources/adoption01.dat failed. Input:
     4515Test 6 of 9 in resources/adoption01.dat failed. Input:
    48474516<table><a>1<p>2</a>3</p>
    48484517Got:
     
    48524521|     <p>
    48534522|       <a>
    4854 |         "23"
     4523|         "2"
     4524|       "3"
    48554525|     <table>
    48564526|       <a>
  • trunk/WebCore/ChangeLog

    r62536 r62537  
     12010-07-06  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Implement bookmarking for HTML5 Adoption Agency algorithm
     6        https://bugs.webkit.org/show_bug.cgi?id=41659
     7
     8        Was easier than I expected it to be.
     9        Fixes a bunch of html5lib/runner.html tests.
     10
     11        * html/HTMLFormattingElementList.cpp:
     12        (WebCore::HTMLFormattingElementList::bookmarkFor):
     13        (WebCore::HTMLFormattingElementList::insertAt):
     14        * html/HTMLFormattingElementList.h:
     15        (WebCore::HTMLFormattingElementList::Bookmark::Bookmark):
     16        (WebCore::HTMLFormattingElementList::Bookmark::moveToAfter):
     17        (WebCore::HTMLFormattingElementList::Bookmark::elementBefore):
     18        (WebCore::HTMLFormattingElementList::Bookmark::elementAfter):
     19        * html/HTMLTreeBuilder.cpp:
     20        (WebCore::HTMLTreeBuilder::callTheAdoptionAgency):
     21
    1222010-07-06  Adam Barth  <abarth@webkit.org>
    223
  • trunk/WebCore/html/HTMLFormattingElementList.cpp

    r62469 r62537  
    110110}
    111111
     112HTMLFormattingElementList::Bookmark HTMLFormattingElementList::bookmarkFor(Element* element)
     113{
     114    size_t index = m_entries.find(element);
     115    ASSERT(index != notFound);
     116    Element* elementBefore = (index > 1) ? m_entries[index - 1].element() : 0;
     117    Element* elementAfter = (index < m_entries.size() - 1) ? m_entries[index + 1].element() : 0;
     118    return Bookmark(elementBefore, elementAfter);
     119}
     120
     121void HTMLFormattingElementList::insertAt(Element* element, const Bookmark& bookmark)
     122{
     123    size_t beforeIndex = notFound;
     124    if (bookmark.elementBefore()) {
     125        beforeIndex = m_entries.find(bookmark.elementBefore());
     126        ASSERT(beforeIndex != notFound);
     127    }
     128    size_t afterIndex = notFound;
     129    if (bookmark.elementAfter()) {
     130        afterIndex = m_entries.find(bookmark.elementAfter());
     131        ASSERT(afterIndex != notFound);
     132    }
     133
     134    if (!bookmark.elementBefore()) {
     135        if (bookmark.elementAfter())
     136            ASSERT(!afterIndex);
     137        m_entries.prepend(element);
     138    } else {
     139        if (bookmark.elementAfter()) {
     140            // Bookmarks are not general purpose.  They're only for the Adoption
     141            // Agency. Assume the bookmarked element was already removed.
     142            ASSERT(beforeIndex + 1 == afterIndex);
     143        }
     144        m_entries.insert(beforeIndex + 1, element);
     145    }
     146}
     147
    112148void HTMLFormattingElementList::append(Element* element)
    113149{
  • trunk/WebCore/html/HTMLFormattingElementList.h

    r62469 r62537  
    6565    };
    6666
     67    class Bookmark {
     68    public:
     69        Bookmark(Element* before, Element* after)
     70            : m_before(before)
     71            , m_after(after)
     72        {
     73        }
     74
     75        void moveToAfter(Element* before)
     76        {
     77            m_before = before;
     78            m_after = 0;
     79        }
     80
     81        Element* elementBefore() const { return m_before; }
     82        Element* elementAfter() const { return m_after; }
     83
     84    private:
     85        Element* m_before;
     86        Element* m_after;
     87    };
     88
    6789    bool isEmpty() const { return !size(); }
    6890    size_t size() const { return m_entries.size(); }
     
    7496    void append(Element*);
    7597    void remove(Element*);
     98
     99    Bookmark bookmarkFor(Element*);
     100    void insertAt(Element*, const Bookmark&);
    76101
    77102    void appendMarker();
  • trunk/WebCore/html/HTMLTreeBuilder.cpp

    r62536 r62537  
    11771177        Element* commonAncestor = formattingElementRecord->next()->element();
    11781178        // 5.
    1179         notImplemented(); // bookmark?
     1179        HTMLFormattingElementList::Bookmark bookmark = m_activeFormattingElements.bookmarkFor(formattingElement);
    11801180        // 6.
    11811181        HTMLElementStack::ElementRecord* node = furthestBlock;
     
    11961196            if (node == formattingElementRecord)
    11971197                break;
    1198             // 6.4
    1199             if (lastNode == furthestBlock)
    1200                 notImplemented(); // move bookmark.
    12011198            // 6.5
    12021199            // FIXME: We're supposed to save the original token in the entry.
     
    12081205            nodeEntry->replaceElement(newElement.get());
    12091206            node->replaceElement(newElement.release());
     1207            // 6.4 -- Intentionally out of order to handle the case where node
     1208            // was replaced in 6.5.
     1209            // http://www.w3.org/Bugs/Public/show_bug.cgi?id=10096
     1210            if (lastNode == furthestBlock)
     1211                bookmark.moveToAfter(node->element());
    12101212            // 6.6
    12111213            // Use appendChild instead of parserAddChild to handle possible reparenting.
     
    12371239        // 11
    12381240        m_activeFormattingElements.remove(formattingElement);
    1239         notImplemented(); // insert new element at bookmark
     1241        m_activeFormattingElements.insertAt(newElement.get(), bookmark);
    12401242        // 12
    12411243        m_openElements.remove(formattingElement);
Note: See TracChangeset for help on using the changeset viewer.