[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

morrita at google.com morrita at google.com
Wed Dec 22 12:02:38 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 4d5f5470fc3cb812ada87b1d6a4d5983181d266f
Author: morrita at google.com <morrita at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Aug 13 01:44:51 2010 +0000

    2010-08-12  MORITA Hajime  <morrita at google.com>
    
            Reviewed by Tony Chang.
    
            [Refactoring] TextEvent class has to many flags
            https://bugs.webkit.org/show_bug.cgi?id=43893
    
            Turned TextEvent::m_isLineBreak, TextEvent::m_isBacktab, TextEvent::m_isPaste
            into single TextEvent::m_inputType enumeration.
    
            No functional change. No new tests.
    
            * dom/TextEvent.cpp:
            (WebCore::TextEvent::selectInputType):
            (WebCore::TextEvent::create):
            (WebCore::TextEvent::createForPlainTextPaste):
            (WebCore::TextEvent::createForFragmentPaste):
            (WebCore::TextEvent::TextEvent):
            * dom/TextEvent.h:
            (WebCore::TextEvent::):
            (WebCore::TextEvent::isLineBreak):
            (WebCore::TextEvent::isBackTab):
            (WebCore::TextEvent::isPaste):
            * page/EventHandler.cpp:
            (WebCore::EventHandler::handleTextInputEvent):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65287 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 3d954cb..207608e 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,29 @@
+2010-08-12  MORITA Hajime  <morrita at google.com>
+
+        Reviewed by Tony Chang.
+
+        [Refactoring] TextEvent class has to many flags
+        https://bugs.webkit.org/show_bug.cgi?id=43893
+
+        Turned TextEvent::m_isLineBreak, TextEvent::m_isBacktab, TextEvent::m_isPaste 
+        into single TextEvent::m_inputType enumeration.
+        
+        No functional change. No new tests.
+
+        * dom/TextEvent.cpp:
+        (WebCore::TextEvent::selectInputType):
+        (WebCore::TextEvent::create):
+        (WebCore::TextEvent::createForPlainTextPaste):
+        (WebCore::TextEvent::createForFragmentPaste):
+        (WebCore::TextEvent::TextEvent):
+        * dom/TextEvent.h:
+        (WebCore::TextEvent::):
+        (WebCore::TextEvent::isLineBreak):
+        (WebCore::TextEvent::isBackTab):
+        (WebCore::TextEvent::isPaste):
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::handleTextInputEvent):
+
 2010-08-12  Kenneth Russell  <kbr at google.com>
 
         Reviewed by David Levin.
diff --git a/WebCore/dom/TextEvent.cpp b/WebCore/dom/TextEvent.cpp
index 5dc39e3..e49e2ab 100644
--- a/WebCore/dom/TextEvent.cpp
+++ b/WebCore/dom/TextEvent.cpp
@@ -31,43 +31,58 @@
 
 namespace WebCore {
 
+TextEvent::InputType TextEvent::selectInputType(bool isLineBreak, bool isBackTab)
+{
+    if (isLineBreak)
+        return TextEvent::InputTypeLineBreak;
+    if (isBackTab)
+        return TextEvent::InputTypeBackTab;
+    return TextEvent::InputTypeKeyboard;
+}
+
 PassRefPtr<TextEvent> TextEvent::create()
 {
     return adoptRef(new TextEvent);
 }
 
-PassRefPtr<TextEvent> TextEvent::create(PassRefPtr<AbstractView> view, const String& data)
+PassRefPtr<TextEvent> TextEvent::create(PassRefPtr<AbstractView> view, const String& data, TextEvent::InputType inputType)
 {
-    return adoptRef(new TextEvent(view, data));
+    return adoptRef(new TextEvent(view, data, inputType));
 }
 
 PassRefPtr<TextEvent> TextEvent::createForPlainTextPaste(PassRefPtr<AbstractView> view, const String& data, bool shouldSmartReplace)
 {
-    return adoptRef(new TextEvent(view, data, 0, true, shouldSmartReplace));
+    return adoptRef(new TextEvent(view, data, 0, shouldSmartReplace, false));
 }
 
 PassRefPtr<TextEvent> TextEvent::createForFragmentPaste(PassRefPtr<AbstractView> view, PassRefPtr<DocumentFragment> data, bool shouldSmartReplace, bool shouldMatchStyle)
 {
-    return adoptRef(new TextEvent(view, "", data, true, shouldSmartReplace, shouldMatchStyle));
+    return adoptRef(new TextEvent(view, "", data, shouldSmartReplace, shouldMatchStyle));
 }
 
 TextEvent::TextEvent()
-    : m_isLineBreak(false)
-    , m_isBackTab(false)
-    , m_isPaste(false)
+    : m_inputType(TextEvent::InputTypeKeyboard)
+    , m_shouldSmartReplace(false)
+    , m_shouldMatchStyle(false)
+{
+}
+
+TextEvent::TextEvent(PassRefPtr<AbstractView> view, const String& data, InputType inputType)
+    : UIEvent(eventNames().textInputEvent, true, true, view, 0)
+    , m_inputType(inputType)
+    , m_data(data)
+    , m_pastingFragment(0)
     , m_shouldSmartReplace(false)
     , m_shouldMatchStyle(false)
 {
 }
 
 TextEvent::TextEvent(PassRefPtr<AbstractView> view, const String& data, PassRefPtr<DocumentFragment> pastingFragment,
-                     bool isPaste, bool shouldSmartReplace, bool shouldMatchStyle)
+                     bool shouldSmartReplace, bool shouldMatchStyle)
     : UIEvent(eventNames().textInputEvent, true, true, view, 0)
+    , m_inputType(TextEvent::InputTypePaste)
     , m_data(data)
-    , m_isLineBreak(false)
-    , m_isBackTab(false)
     , m_pastingFragment(pastingFragment)
-    , m_isPaste(isPaste)
     , m_shouldSmartReplace(shouldSmartReplace)
     , m_shouldMatchStyle(shouldMatchStyle)
 {
diff --git a/WebCore/dom/TextEvent.h b/WebCore/dom/TextEvent.h
index 2e2eb95..a450bc0 100644
--- a/WebCore/dom/TextEvent.h
+++ b/WebCore/dom/TextEvent.h
@@ -34,8 +34,16 @@ namespace WebCore {
 
     class TextEvent : public UIEvent {
     public:
+        enum InputType {
+            InputTypeKeyboard, // any newline characters in the text are line breaks only, not paragraph separators.
+            InputTypeLineBreak, // any tab characters in the text are backtabs.
+            InputTypeBackTab,
+            InputTypePaste
+        };
+
+        static InputType selectInputType(bool isLineBreak, bool isBackTab);
         static PassRefPtr<TextEvent> create();
-        static PassRefPtr<TextEvent> create(PassRefPtr<AbstractView> view, const String& data);
+        static PassRefPtr<TextEvent> create(PassRefPtr<AbstractView> view, const String& data, InputType = InputTypeKeyboard);
         static PassRefPtr<TextEvent> createForPlainTextPaste(PassRefPtr<AbstractView> view, const String& data, bool shouldSmartReplace);
         static PassRefPtr<TextEvent> createForFragmentPaste(PassRefPtr<AbstractView> view, PassRefPtr<DocumentFragment> data, bool shouldSmartReplace, bool shouldMatchStyle);
 
@@ -47,30 +55,23 @@ namespace WebCore {
 
         virtual bool isTextEvent() const;
 
-        // If true, any newline characters in the text are line breaks only, not paragraph separators.
-        bool isLineBreak() const { return m_isLineBreak; }
-        void setIsLineBreak(bool isLineBreak) { m_isLineBreak = isLineBreak; }
-
-        // If true, any tab characters in the text are backtabs.
-        bool isBackTab() const { return m_isBackTab; }
-        void setIsBackTab(bool isBackTab) { m_isBackTab = isBackTab; }
+        bool isLineBreak() const { return m_inputType == InputTypeLineBreak; }
+        bool isBackTab() const { return m_inputType == InputTypeBackTab; }
+        bool isPaste() const { return m_inputType == InputTypePaste; }
 
-        bool isPaste() const { return m_isPaste; }
         bool shouldSmartReplace() const { return m_shouldSmartReplace; }
         bool shouldMatchStyle() const { return m_shouldMatchStyle; }
         DocumentFragment* pastingFragment() const { return m_pastingFragment.get(); }
 
     private:
         TextEvent();
-        TextEvent(PassRefPtr<AbstractView>, const String& data, PassRefPtr<DocumentFragment> = 0,
-                  bool isPaste = false, bool shouldSmartReplace = false, bool shouldMatchStyle = false);
-
+        TextEvent(PassRefPtr<AbstractView>, const String& data, InputType = InputTypeKeyboard);
+        TextEvent(PassRefPtr<AbstractView>, const String& data, PassRefPtr<DocumentFragment>,
+                  bool shouldSmartReplace, bool shouldMatchStyle);
+        InputType m_inputType;
         String m_data;
-        bool m_isLineBreak;
-        bool m_isBackTab;
 
         RefPtr<DocumentFragment> m_pastingFragment;
-        bool m_isPaste; // FIXME: Should use inputMode after it be available: http://webkit.org/b/42805
         bool m_shouldSmartReplace;
         bool m_shouldMatchStyle;
     };
diff --git a/WebCore/page/EventHandler.cpp b/WebCore/page/EventHandler.cpp
index 8a16181..d0adb4e 100644
--- a/WebCore/page/EventHandler.cpp
+++ b/WebCore/page/EventHandler.cpp
@@ -2629,6 +2629,7 @@ bool EventHandler::handleTextInputEvent(const String& text, Event* underlyingEve
     // Platforms should differentiate real commands like selectAll from text input in disguise (like insertNewline),
     // and avoid dispatching text input events from keydown default handlers.
     ASSERT(!underlyingEvent || !underlyingEvent->isKeyboardEvent() || static_cast<KeyboardEvent*>(underlyingEvent)->type() == eventNames().keypressEvent);
+    ASSERT(!(isLineBreak && isBackTab));
 
     if (!m_frame)
         return false;
@@ -2644,10 +2645,9 @@ bool EventHandler::handleTextInputEvent(const String& text, Event* underlyingEve
     if (FrameView* view = m_frame->view())
         view->resetDeferredRepaintDelay();
 
-    RefPtr<TextEvent> event = TextEvent::create(m_frame->domWindow(), text);
+    RefPtr<TextEvent> event = TextEvent::create(m_frame->domWindow(), text, TextEvent::selectInputType(isLineBreak, isBackTab));
     event->setUnderlyingEvent(underlyingEvent);
-    event->setIsLineBreak(isLineBreak);
-    event->setIsBackTab(isBackTab);
+
     ExceptionCode ec;
     target->dispatchEvent(event, ec);
     return event->defaultHandled();

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list