Changeset 149432 in webkit


Ignore:
Timestamp:
May 1, 2013 7:17:12 AM (11 years ago)
Author:
sergio@webkit.org
Message:

Show a block cursor in overtype mode
https://bugs.webkit.org/show_bug.cgi?id=114819

Reviewed by Ryosuke Niwa.

.:

  • Source/autotools/symbols.filter: export some extra symbols for

testing purposes.

Source/WebCore:

Test: editing/selection/block-cursor-overtype-mode.html

Overtype mode will use block cursor instead of a caret to
highlight the next character to be replaced. It will fully cover
the next character to be replaced (except at the end of a line
where the usual blinking caret will be shown).

This new block cursor is internally implemented as a selection
(not exposed to JavaScript) because the selection code knows how
to deal with bidi text.

  • WebCore.exp.in: Export symbols for testing purposes.
  • WebCore.order: Ditto.
  • editing/Editor.cpp:

(WebCore::Editor::toggleOverwriteModeEnabled): Added a call to
FrameLoader::setShouldShowBlockCursor.
(WebCore):

  • editing/Editor.h:

(Editor):

  • editing/FrameSelection.cpp:

(WebCore::FrameSelection::FrameSelection):
(WebCore::FrameSelection::updateAppearance): Use a 1-character
long selection to paint the cursor in overtype mode.
(WebCore::FrameSelection::setShouldShowBlockCursor):
(WebCore):

  • editing/FrameSelection.h:

(WebCore::FrameSelection::shouldShowBlockCursor):
(FrameSelection):

  • testing/Internals.cpp:

(WebCore):
(WebCore::Internals::selectionBounds): Added a new method which
returns the IntRect issued by FrameSelection::bounds().

  • testing/Internals.h: Ditto.
  • testing/Internals.idl: Ditto.

Source/WebKit:

Export three more WebCore symbols.

  • WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in:

Source/WebKit/win:

Export three more WebCore symbols.

  • WebKit.vcproj/WebKitExports.def.in:

LayoutTests:

New test case for the new block cursor to be used in overtype
mode. The test verifies that the 1-pixel long caret is replaced by
a selection like 1-character long block cursor when in overtype
mode. This test covers LTR and RTL text in LTR and RTL blocks and
bidi text.

  • editing/selection/block-cursor-overtype-mode-expected.txt: Added.
  • editing/selection/block-cursor-overtype-mode.html: Added.
Location:
trunk
Files:
2 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r149362 r149432  
     12013-05-01  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        Show a block cursor in overtype mode
     4        https://bugs.webkit.org/show_bug.cgi?id=114819
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * Source/autotools/symbols.filter: export some extra symbols for
     9        testing purposes.
     10
    1112013-04-30  Christophe Dumez  <ch.dumez@sisa.samsung.com>
    212
  • trunk/LayoutTests/ChangeLog

    r149407 r149432  
     12013-05-01  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        Show a block cursor in overtype mode
     4        https://bugs.webkit.org/show_bug.cgi?id=114819
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        New test case for the new block cursor to be used in overtype
     9        mode. The test verifies that the 1-pixel long caret is replaced by
     10        a selection like 1-character long block cursor when in overtype
     11        mode. This test covers LTR and RTL text in LTR and RTL blocks and
     12        bidi text.
     13
     14        * editing/selection/block-cursor-overtype-mode-expected.txt: Added.
     15        * editing/selection/block-cursor-overtype-mode.html: Added.
     16
    1172013-04-30  David Hyatt  <hyatt@apple.com>
    218
  • trunk/Source/WebCore/ChangeLog

    r149423 r149432  
     12013-05-01  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        Show a block cursor in overtype mode
     4        https://bugs.webkit.org/show_bug.cgi?id=114819
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Test: editing/selection/block-cursor-overtype-mode.html
     9
     10        Overtype mode will use block cursor instead of a caret to
     11        highlight the next character to be replaced. It will fully cover
     12        the next character to be replaced (except at the end of a line
     13        where the usual blinking caret will be shown).
     14
     15        This new block cursor is internally implemented as a selection
     16        (not exposed to JavaScript) because the selection code knows how
     17        to deal with bidi text.
     18
     19        * WebCore.exp.in: Export symbols for testing purposes.
     20        * WebCore.order: Ditto.
     21        * editing/Editor.cpp:
     22        (WebCore::Editor::toggleOverwriteModeEnabled): Added a call to
     23        FrameLoader::setShouldShowBlockCursor.
     24        (WebCore):
     25        * editing/Editor.h:
     26        (Editor):
     27        * editing/FrameSelection.cpp:
     28        (WebCore::FrameSelection::FrameSelection):
     29        (WebCore::FrameSelection::updateAppearance): Use a 1-character
     30        long selection to paint the cursor in overtype mode.
     31        (WebCore::FrameSelection::setShouldShowBlockCursor):
     32        (WebCore):
     33        * editing/FrameSelection.h:
     34        (WebCore::FrameSelection::shouldShowBlockCursor):
     35        (FrameSelection):
     36        * testing/Internals.cpp:
     37        (WebCore):
     38        (WebCore::Internals::selectionBounds): Added a new method which
     39        returns the IntRect issued by FrameSelection::bounds().
     40        * testing/Internals.h: Ditto.
     41        * testing/Internals.idl: Ditto.
     42
    1432013-04-30  Darin Adler  <darin@apple.com>
    244
  • trunk/Source/WebCore/WebCore.exp.in

    r149417 r149432  
    6969__ZN3WTF6StringC1EPK10__CFString
    7070__ZN7WebCore10ClientRectC1ERKNS_7IntRectE
     71__ZN7WebCore10ClientRectC1ERKNS_9FloatRectE
    7172__ZN7WebCore10ClientRectC1Ev
    7273__ZN7WebCore10CredentialC1ERKN3WTF6StringES4_NS_21CredentialPersistenceE
     
    961962__ZN7WebCore6Editor7commandERKN3WTF6StringE
    962963__ZN7WebCore6Editor7outdentEv
     964__ZN7WebCore6Editor26toggleOverwriteModeEnabledEv
    963965__ZN7WebCore6JSNode6s_infoE
    964966__ZN7WebCore6Region5uniteERKS0_
  • trunk/Source/WebCore/WebCore.order

    r148696 r149432  
    4286042860__ZN7WebCoreL12gFunctionMapE
    4286142861__ZN7WebCoreL12gFunctionMapE
     42862__ZN7WebCore6Editor26toggleOverwriteModeEnabledEv
  • trunk/Source/WebCore/editing/Editor.cpp

    r149322 r149432  
    31253125}
    31263126
     3127void Editor::toggleOverwriteModeEnabled()
     3128{
     3129    m_overwriteModeEnabled = !m_overwriteModeEnabled;
     3130    frame()->selection()->setShouldShowBlockCursor(m_overwriteModeEnabled);
     3131};
     3132
    31273133} // namespace WebCore
  • trunk/Source/WebCore/editing/Editor.h

    r146907 r149432  
    247247
    248248    bool isOverwriteModeEnabled() const { return m_overwriteModeEnabled; }
    249     void toggleOverwriteModeEnabled() { m_overwriteModeEnabled = !m_overwriteModeEnabled; }
     249    void toggleOverwriteModeEnabled();
    250250
    251251#if USE(APPKIT)
  • trunk/Source/WebCore/editing/FrameSelection.cpp

    r149223 r149432  
    115115    , m_isCaretBlinkingSuspended(false)
    116116    , m_focused(frame && frame->page() && frame->page()->focusController()->focusedFrame() == frame)
     117    , m_shouldShowBlockCursor(false)
    117118{
    118119    if (shouldAlwaysUseDirectionalSelection(m_frame))
     
    17541755void FrameSelection::updateAppearance()
    17551756{
     1757    // Paint a block cursor instead of a caret in overtype mode unless the caret is at the end of a line (in this case
     1758    // the FrameSelection will paint a blinking caret as usual).
     1759    VisiblePosition forwardPosition;
     1760    if (m_shouldShowBlockCursor && m_selection.isCaret()) {
     1761        forwardPosition = modifyExtendingForward(CharacterGranularity);
     1762        m_caretPaint = forwardPosition.isNull();
     1763    }
     1764
    17561765#if ENABLE(TEXT_CARET)
    17571766    bool caretRectChangedOrCleared = recomputeCaretRect();
    17581767
    17591768    bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBrowsingEnabled();
    1760     bool shouldBlink = caretIsVisible() && isCaret() && (isContentEditable() || caretBrowsing);
     1769    bool shouldBlink = caretIsVisible() && isCaret() && (isContentEditable() || caretBrowsing) && forwardPosition.isNull();
    17611770
    17621771    // If the caret moved, stop the blink timer so we can restart with a
     
    17841793    // Construct a new VisibleSolution, since m_selection is not necessarily valid, and the following steps
    17851794    // assume a valid selection. See <https://bugs.webkit.org/show_bug.cgi?id=69563> and <rdar://problem/10232866>.
    1786     VisibleSelection selection(m_selection.visibleStart(), m_selection.visibleEnd());
     1795    VisibleSelection selection(m_selection.visibleStart(), forwardPosition.isNotNull() ? forwardPosition : m_selection.visibleEnd());
    17871796
    17881797    if (!selection.isRange()) {
     
    20572066}
    20582067
     2068void FrameSelection::setShouldShowBlockCursor(bool shouldShowBlockCursor)
     2069{
     2070    m_shouldShowBlockCursor = shouldShowBlockCursor;
     2071
     2072    m_frame->document()->updateLayoutIgnorePendingStylesheets();
     2073
     2074    updateAppearance();
     2075}
     2076
    20592077#ifndef NDEBUG
    20602078
  • trunk/Source/WebCore/editing/FrameSelection.h

    r148987 r149432  
    256256    void setSelectionFromNone();
    257257
     258    bool shouldShowBlockCursor() const { return m_shouldShowBlockCursor; }
     259    void setShouldShowBlockCursor(bool);
     260
    258261private:
    259262    enum EPositionType { START, END, BASE, EXTENT };
     
    312315    bool m_isCaretBlinkingSuspended : 1;
    313316    bool m_focused : 1;
     317    bool m_shouldShowBlockCursor : 1;
    314318};
    315319
  • trunk/Source/WebCore/testing/Internals.cpp

    r149262 r149432  
    22962296    return ranges->nearest(time);
    22972297}
    2298 #endif
    2299 
    2300 }
     2298
     2299PassRefPtr<ClientRect> Internals::selectionBounds(ExceptionCode& ec)
     2300{
     2301    Document* document = contextDocument();
     2302    if (!document || !document->frame() || !document->frame()->selection()) {
     2303        ec = INVALID_ACCESS_ERR;
     2304        return ClientRect::create();
     2305    }
     2306
     2307    return ClientRect::create(document->frame()->selection()->bounds());
     2308}
     2309
     2310#endif
     2311
     2312}
  • trunk/Source/WebCore/testing/Internals.h

    r148288 r149432  
    329329#endif
    330330
     331    PassRefPtr<ClientRect> selectionBounds(ExceptionCode&);
     332
    331333private:
    332334    explicit Internals(Document*);
  • trunk/Source/WebCore/testing/Internals.idl

    r149368 r149432  
    288288
    289289    boolean isSelectPopupVisible(Node node);
     290
     291    ClientRect selectionBounds() raises(DOMException);
    290292};
  • trunk/Source/WebKit/ChangeLog

    r149385 r149432  
     12013-05-01  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        Show a block cursor in overtype mode
     4        https://bugs.webkit.org/show_bug.cgi?id=114819
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Export three more WebCore symbols.
     9
     10        * WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in:
     11
    1122013-04-29  Brent Fulgham  <bfulgham@webkit.org>
    213
  • trunk/Source/WebKit/WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in

    r149263 r149432  
    156156        ??1Range@WebCore@@QAE@XZ
    157157        ?toNode@WebCore@@YAPAVNode@1@VJSValue@JSC@@@Z
     158        ??0ClientRect@WebCore@@AAE@ABVFloatRect@1@@Z
    158159        ??0ClientRect@WebCore@@AAE@ABVIntRect@1@@Z
    159160        ??0ClientRect@WebCore@@AAE@XZ
     
    188189        ?find@StringImpl@WTF@@QAEIPAV12@@Z
    189190        ?absoluteCaretBounds@FrameSelection@WebCore@@QAE?AVIntRect@2@XZ
     191        ?bounds@FrameSelection@WebCore@@QBE?AVFloatRect@2@_N@Z
    190192        ?fromUTF8@String@WTF@@SA?AV12@PBE@Z
    191193        ?fromUTF8WithLatin1Fallback@String@WTF@@SA?AV12@PBEI@Z
     
    318320        ?isContinuousSpellCheckingEnabled@Editor@WebCore@@QBE_NXZ
    319321        ?toggleContinuousSpellChecking@Editor@WebCore@@QAEXXZ
     322        ?toggleOverwriteModeEnabled@Editor@WebCore@@QAEXXZ
    320323#if ENABLE(FULLSCREEN_API)
    321324        ?webkitWillEnterFullScreenForElement@Document@WebCore@@QAEXPAVElement@2@@Z
  • trunk/Source/WebKit/win/ChangeLog

    r149385 r149432  
     12013-05-01  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        Show a block cursor in overtype mode
     4        https://bugs.webkit.org/show_bug.cgi?id=114819
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Export three more WebCore symbols.
     9
     10        * WebKit.vcproj/WebKitExports.def.in:
     11
    1122013-04-29  Brent Fulgham  <bfulgham@webkit.org>
    213
  • trunk/Source/WebKit/win/WebKit.vcproj/WebKitExports.def.in

    r149263 r149432  
    157157        ??1Range@WebCore@@QAE@XZ
    158158        ?toNode@WebCore@@YAPAVNode@1@VJSValue@JSC@@@Z
     159        ??0ClientRect@WebCore@@AAE@ABVFloatRect@1@@Z
    159160        ??0ClientRect@WebCore@@AAE@ABVIntRect@1@@Z
    160161        ??0ClientRect@WebCore@@AAE@XZ
     
    189190        ?find@StringImpl@WTF@@QAEIPAV12@@Z
    190191        ?absoluteCaretBounds@FrameSelection@WebCore@@QAE?AVIntRect@2@XZ
     192        ?bounds@FrameSelection@WebCore@@QBE?AVFloatRect@2@_N@Z
    191193        ?fromUTF8@String@WTF@@SA?AV12@PBE@Z
    192194        ?fromUTF8WithLatin1Fallback@String@WTF@@SA?AV12@PBEI@Z
     
    319321        ?isContinuousSpellCheckingEnabled@Editor@WebCore@@QBE_NXZ
    320322        ?toggleContinuousSpellChecking@Editor@WebCore@@QAEXXZ
     323        ?toggleOverwriteModeEnabled@Editor@WebCore@@QAEXXZ
    321324#if ENABLE(FULLSCREEN_API)
    322325        ?webkitWillEnterFullScreenForElement@Document@WebCore@@QAEXPAVElement@2@@Z
  • trunk/Source/autotools/symbols.filter

    r149262 r149432  
    312312_ZNK7WebCore8Document13nodesFromRectEiijjjjj;
    313313_ZTVN7WebCore14StaticNodeListE;
     314_ZN7WebCore6Editor26toggleOverwriteModeEnabledEv;
     315_ZNK7WebCore14FrameSelection6boundsEb;
     316_ZN7WebCore10ClientRectC1ERKNS_9FloatRectE;
    314317
    315318local:
Note: See TracChangeset for help on using the changeset viewer.