Skip to content
  • rniwa@webkit.org's avatar
    2010-10-21 Ryosuke Niwa <rniwa@webkit.org> · 601e805e
    rniwa@webkit.org authored
            Reviewed by Tony Chang.
    
            removeFormat needs to be reimplemented
            https://bugs.webkit.org/show_bug.cgi?id=43017
    
            Reimplemented execCommand('RemoveFormat', false, null). New implementation removes
            the same elements removed by Internet Explorer. Because WebKit supports StyleWithCSS
            we also reset any editing styles to match that of the root editable element
            while Internet Explorer does not remove any CSS styles.
    
            New implementation uses ApplyStyleCommand to remove appropriate elements and reset the style.
            Added new constructor and member variable to ApplyStyleCommand to support mass-removal of elements
            since it's inefficient to call ApplyStyleCommand on each element we're removing.
    
            To avoid an infinite loop in pushDownInlineStyleAroundNode when mass-removing, WebKit no longer
            push down element one level at a time. Instead, we keep a stack of styled elements to be applied,
            and apply wrap siblings of targetNode's ancestors by all of them at once.
    
            Tests: editing/execCommand/remove-format-elements.html
                   editing/execCommand/remove-format-multiple-elements.html
    
            * editing/ApplyStyleCommand.cpp:
            (WebCore::ApplyStyleCommand::ApplyStyleCommand): Added; this version takes style and a function pointer
            to a boolean function that determines which element needs to removed, and set m_removeOnly to true.
            (WebCore::ApplyStyleCommand::doApply): Added support for m_isInlineElementToRemoveFunction.
            (WebCore::ApplyStyleCommand::applyBlockStyle): Ditto.
            (WebCore::ApplyStyleCommand::applyInlineStyleToNodeRange): Exits early if m_removeOnly is true.
            (WebCore::ApplyStyleCommand::isStyledInlineElementToRemove): Added.
            (WebCore::ApplyStyleCommand::removeStyleFromRunBeforeApplyingStyle): Calls isStyledInlineElementToRemove.
            (WebCore::ApplyStyleCommand::removeInlineStyleFromElement): Ditto.
            (WebCore::ApplyStyleCommand::removeInlineStyle): Ditto.
            (WebCore::ApplyStyleCommand::pushDownInlineStyleAroundNode): See above.
            * editing/ApplyStyleCommand.h:
            (WebCore::ApplyStyleCommand::create): Added.
            * editing/RemoveFormatCommand.cpp:
            (WebCore::isElementForRemoveFormatCommand): Added.
            (WebCore::RemoveFormatCommand::doApply): Rewritten.
    2010-10-21  Ryosuke Niwa  <rniwa@webkit.org>
    
            Reviewed by Tony Chang.
    
            removeFormat needs to be reimplemented
            https://bugs.webkit.org/show_bug.cgi?id=43017
    
            * editing/execCommand/19403-expected.txt: hr element is no longer removed erroneously.
            * editing/execCommand/19403.html: Updated the test description.
            * editing/execCommand/4786404-1-expected.txt: Change in text nodes but identical rendering.
            * editing/execCommand/4786404-2-expected.txt: Ditto.
            * editing/execCommand/4920488-expected.txt: Preserves anchor element on RemoveFormat.
            * editing/execCommand/4920488.html: Updated the test description.
            * editing/execCommand/4920742-1-expected.txt: Preserves div elements.
            * editing/execCommand/5049671.html: Updated the test to dump twice before and after RemoveFormat.
            This was a test to ensure WebKit removes anchor elements but we no longer removes anchor elements.
            * editing/execCommand/5049671-expected.txt:
            * editing/execCommand/5573879.html: Updated the test description because WebKit no longer removes
            lists on RemoveFormat.
            * editing/execCommand/5573879-expected.txt:
            * editing/execCommand/5770834-1-expected.txt: Removed redundant text-align property value.
            * editing/execCommand/remove-format-elements-expected.txt: Added.
            * editing/execCommand/remove-format-elements.html: Added.
            * editing/execCommand/remove-format-multiple-elements-expected.txt: Added.
            * editing/execCommand/remove-format-multiple-elements.html: Added.
            * editing/execCommand/remove-formatting-2-expected.txt: Change in text nodes but identical rendering.
            * editing/execCommand/remove-formatting-expected.txt: WebKit no longer removes anchor, table,
            tbody, tr, and td elements.
            * editing/execCommand/script-tests/remove-format-multiple-elements.js: Added.
            (testRemoveFormat):
            (selectAll):
            (selectSecondWord):
            (selectFirstTwoWords):
            (selectLastTwoWords):
            (selectLastWord):
            * editing/execCommand/script-tests/toggle-link.js: Anchor wraps div instead of div wrapping anchor.
            * editing/execCommand/script-tests/toggle-unlink.js: Ditto.
            * editing/execCommand/toggle-link-expected.txt: Ditto.
            * editing/execCommand/toggle-unlink-expected.txt: Ditto.
            * editing/execCommand/unlink-expected.txt: i wraps div instead of i wrapping anchor.
            * editing/inserting/space-after-removeformat-expected.txt: Editing delegate change.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70283 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    601e805e