Changeset 109529 in webkit


Ignore:
Timestamp:
Mar 2, 2012 1:20:39 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Implement DefaultParagraphSeparator execCommand, to let authors choose the default block element
https://bugs.webkit.org/show_bug.cgi?id=59961

Patch by Pablo Flouret <pablof@motorola.com> on 2012-03-02
Reviewed by Ryosuke Niwa.

Source/WebCore:

http://dvcs.w3.org/hg/editing/raw-file/tip/editing.html#the-defaultparagraphseparator-command

Test: editing/execCommand/default-paragraph-separator.html

  • editing/Editor.cpp:

(WebCore::Editor::Editor):

  • editing/Editor.h:

(WebCore::Editor::defaultParagraphSeparator):
(WebCore::Editor::setDefaultParagraphSeparator):
(Editor):

  • editing/EditorCommand.cpp:

(WebCore::executeDefaultParagraphSeparator):
(WebCore):
(WebCore::valueDefaultParagraphSeparator):
(WebCore::createCommandMap):

  • editing/htmlediting.cpp:

(WebCore::createDefaultParagraphElement):

  • html/HTMLParagraphElement.cpp:

(WebCore::HTMLParagraphElement::create):
(WebCore):

  • html/HTMLParagraphElement.h:

(HTMLParagraphElement):

Added create(Document*) method that defaults to pTag as the QualifiedName.

LayoutTests:

  • editing/execCommand/default-paragraph-separator-expected.txt: Added.
  • editing/execCommand/default-paragraph-separator.html: Added.
Location:
trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r109523 r109529  
     12012-03-02  Pablo Flouret  <pablof@motorola.com>
     2
     3        Implement DefaultParagraphSeparator execCommand, to let authors choose the default block element
     4        https://bugs.webkit.org/show_bug.cgi?id=59961
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * editing/execCommand/default-paragraph-separator-expected.txt: Added.
     9        * editing/execCommand/default-paragraph-separator.html: Added.
     10
    1112012-03-02  Mike Lawther  <mikelawther@chromium.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r109528 r109529  
     12012-03-02  Pablo Flouret  <pablof@motorola.com>
     2
     3        Implement DefaultParagraphSeparator execCommand, to let authors choose the default block element
     4        https://bugs.webkit.org/show_bug.cgi?id=59961
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        http://dvcs.w3.org/hg/editing/raw-file/tip/editing.html#the-defaultparagraphseparator-command
     9
     10        Test: editing/execCommand/default-paragraph-separator.html
     11
     12        * editing/Editor.cpp:
     13        (WebCore::Editor::Editor):
     14        * editing/Editor.h:
     15        (WebCore::Editor::defaultParagraphSeparator):
     16        (WebCore::Editor::setDefaultParagraphSeparator):
     17        (Editor):
     18        * editing/EditorCommand.cpp:
     19        (WebCore::executeDefaultParagraphSeparator):
     20        (WebCore):
     21        (WebCore::valueDefaultParagraphSeparator):
     22        (WebCore::createCommandMap):
     23        * editing/htmlediting.cpp:
     24        (WebCore::createDefaultParagraphElement):
     25
     26        * html/HTMLParagraphElement.cpp:
     27        (WebCore::HTMLParagraphElement::create):
     28        (WebCore):
     29        * html/HTMLParagraphElement.h:
     30        (HTMLParagraphElement):
     31            Added create(Document*) method that defaults to pTag as the QualifiedName.
     32
    1332012-03-02  Kenneth Russell  <kbr@google.com>
    234
  • trunk/Source/WebCore/editing/Editor.cpp

    r108772 r109529  
    847847    , m_spellingCorrector(adoptPtr(new SpellingCorrectionController(frame)))
    848848    , m_areMarkedTextMatchesHighlighted(false)
     849    , m_defaultParagraphSeparator(EditorParagraphSeparatorIsDiv)
    849850{
    850851}
  • trunk/Source/WebCore/editing/Editor.h

    r108462 r109529  
    8181
    8282enum EditorCommandSource { CommandFromMenuOrKeyBinding, CommandFromDOM, CommandFromDOMWithUserInterface };
     83enum EditorParagraphSeparator { EditorParagraphSeparatorIsDiv, EditorParagraphSeparatorIsP };
    8384
    8485class Editor {
     
    384385    void deviceScaleFactorChanged();
    385386
     387    EditorParagraphSeparator defaultParagraphSeparator() const { return m_defaultParagraphSeparator; }
     388    void setDefaultParagraphSeparator(EditorParagraphSeparator separator) { m_defaultParagraphSeparator = separator; }
     389
    386390private:
    387391    Frame* m_frame;
     
    401405    VisibleSelection m_mark;
    402406    bool m_areMarkedTextMatchesHighlighted;
     407    EditorParagraphSeparator m_defaultParagraphSeparator;
    403408
    404409    bool canDeleteRange(Range*) const;
  • trunk/Source/WebCore/editing/EditorCommand.cpp

    r108462 r109529  
    308308}
    309309
     310static bool executeDefaultParagraphSeparator(Frame* frame, Event*, EditorCommandSource, const String& value)
     311{
     312    if (equalIgnoringCase(value, "div"))
     313        frame->editor()->setDefaultParagraphSeparator(EditorParagraphSeparatorIsDiv);
     314    else if (equalIgnoringCase(value, "p"))
     315        frame->editor()->setDefaultParagraphSeparator(EditorParagraphSeparatorIsP);
     316
     317    return true;
     318}
     319
    310320static bool executeDelete(Frame* frame, Event*, EditorCommandSource source, const String&)
    311321{
     
    13791389}
    13801390
     1391static String valueDefaultParagraphSeparator(Frame* frame, Event*)
     1392{
     1393    switch (frame->editor()->defaultParagraphSeparator()) {
     1394    case EditorParagraphSeparatorIsDiv:
     1395        return divTag.localName();
     1396    case EditorParagraphSeparatorIsP:
     1397        return pTag.localName();
     1398    }
     1399
     1400    ASSERT_NOT_REACHED();
     1401    return String();
     1402}
     1403
    13811404static String valueFontName(Frame* frame, Event*)
    13821405{
     
    14301453        { "CreateLink", { executeCreateLink, supported, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
    14311454        { "Cut", { executeCut, supportedCopyCut, enabledCut, stateNone, valueNull, notTextInsertion, allowExecutionWhenDisabled } },
     1455        { "DefaultParagraphSeparator", { executeDefaultParagraphSeparator, supported, enabled, stateNone, valueDefaultParagraphSeparator, notTextInsertion, doNotAllowExecutionWhenDisabled} },
    14321456        { "Delete", { executeDelete, supported, enabledDelete, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
    14331457        { "DeleteBackward", { executeDeleteBackward, supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
  • trunk/Source/WebCore/editing/htmlediting.cpp

    r108009 r109529  
    3030#include "Document.h"
    3131#include "EditingText.h"
     32#include "Editor.h"
     33#include "Frame.h"
    3234#include "HTMLBRElement.h"
    3335#include "HTMLDivElement.h"
     
    3941#include "HTMLObjectElement.h"
    4042#include "HTMLOListElement.h"
     43#include "HTMLParagraphElement.h"
    4144#include "HTMLUListElement.h"
    4245#include "PositionIterator.h"
     
    845848PassRefPtr<HTMLElement> createDefaultParagraphElement(Document* document)
    846849{
    847     return HTMLDivElement::create(document);
     850    switch (document->frame()->editor()->defaultParagraphSeparator()) {
     851    case EditorParagraphSeparatorIsDiv:
     852        return HTMLDivElement::create(document);
     853    case EditorParagraphSeparatorIsP:
     854        return HTMLParagraphElement::create(document);
     855    }
     856
     857    ASSERT_NOT_REACHED();
     858    return 0;
    848859}
    849860
  • trunk/Source/WebCore/html/HTMLParagraphElement.cpp

    r109149 r109529  
    4040}
    4141
     42PassRefPtr<HTMLParagraphElement> HTMLParagraphElement::create(Document* document)
     43{
     44    return adoptRef(new HTMLParagraphElement(pTag, document));
     45}
     46
    4247PassRefPtr<HTMLParagraphElement> HTMLParagraphElement::create(const QualifiedName& tagName, Document* document)
    4348{
  • trunk/Source/WebCore/html/HTMLParagraphElement.h

    r109149 r109529  
    3030class HTMLParagraphElement : public HTMLElement {
    3131public:
     32    static PassRefPtr<HTMLParagraphElement> create(Document*);
    3233    static PassRefPtr<HTMLParagraphElement> create(const QualifiedName&, Document*);
    3334
Note: See TracChangeset for help on using the changeset viewer.