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

rniwa at webkit.org rniwa at webkit.org
Wed Dec 22 15:17:53 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 2bb4a5a5b7e55cbf44a28cf20aad6e8c992aefdc
Author: rniwa at webkit.org <rniwa at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Oct 29 23:15:57 2010 +0000

    2010-10-29  Ryosuke Niwa  <rniwa at webkit.org>
    
            Reviewed by Darin Adler.
    
            Remove RenderTextControl::setSelectionRange
            https://bugs.webkit.org/show_bug.cgi?id=47870
    
            Converted RenderTextControll::setSelectionRange to a global function.
    
            * Api/qwebpage.cpp:
            (QWebPagePrivate::inputMethodEvent): Calls setSelectionRange.
    2010-10-29  Ryosuke Niwa  <rniwa at webkit.org>
    
            Reviewed by Darin Adler.
    
            Remove RenderTextControl::setSelectionRange
            https://bugs.webkit.org/show_bug.cgi?id=47870
    
            Made RenderTextControl::setSelectionRange a global function.
            Removed setSelectionStart, setSelectionEnd, and select from RenderTextControl.
    
            No new tests are added since there is no behavioral change.
    
            * accessibility/AccessibilityRenderObject.cpp:
            (WebCore::AccessibilityRenderObject::setSelectedTextRange): Calls setSelectedTextRange.
            * dom/InputElement.cpp:
            (WebCore::InputElement::updateSelectionRange): Ditto.
            * html/HTMLFormControlElement.cpp:
            (WebCore::HTMLTextFormControlElement::setSelectionStart): Ditto.
            (WebCore::HTMLTextFormControlElement::setSelectionEnd): Ditto.
            (WebCore::HTMLTextFormControlElement::select): Ditto.
            (WebCore::HTMLTextFormControlElement::setSelectionRange): Ditto.
            * rendering/RenderTextControl.cpp:
            (WebCore::RenderTextControl::hasVisibleTextArea): Added.
            (WebCore::setSelectionRange): See above.
            * rendering/RenderTextControl.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70945 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index aeb92c0..44714b7 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,29 @@
+2010-10-29  Ryosuke Niwa  <rniwa at webkit.org>
+
+        Reviewed by Darin Adler.
+
+        Remove RenderTextControl::setSelectionRange
+        https://bugs.webkit.org/show_bug.cgi?id=47870
+
+        Made RenderTextControl::setSelectionRange a global function.
+        Removed setSelectionStart, setSelectionEnd, and select from RenderTextControl.
+
+        No new tests are added since there is no behavioral change.
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::setSelectedTextRange): Calls setSelectedTextRange.
+        * dom/InputElement.cpp:
+        (WebCore::InputElement::updateSelectionRange): Ditto.
+        * html/HTMLFormControlElement.cpp:
+        (WebCore::HTMLTextFormControlElement::setSelectionStart): Ditto.
+        (WebCore::HTMLTextFormControlElement::setSelectionEnd): Ditto.
+        (WebCore::HTMLTextFormControlElement::select): Ditto.
+        (WebCore::HTMLTextFormControlElement::setSelectionRange): Ditto.
+        * rendering/RenderTextControl.cpp:
+        (WebCore::RenderTextControl::hasVisibleTextArea): Added.
+        (WebCore::setSelectionRange): See above.
+        * rendering/RenderTextControl.h:
+
 2010-10-29  Carlos Garcia Campos  <cgarcia at igalia.com>
 
         Reviewed by Andreas Kling.
diff --git a/WebCore/accessibility/AccessibilityRenderObject.cpp b/WebCore/accessibility/AccessibilityRenderObject.cpp
index 95580ad..efa2036 100644
--- a/WebCore/accessibility/AccessibilityRenderObject.cpp
+++ b/WebCore/accessibility/AccessibilityRenderObject.cpp
@@ -1989,11 +1989,10 @@ PlainTextRange AccessibilityRenderObject::selectedTextRange() const
 void AccessibilityRenderObject::setSelectedTextRange(const PlainTextRange& range)
 {
     if (isNativeTextControl()) {
-        RenderTextControl* textControl = toRenderTextControl(m_renderer);
-        textControl->setSelectionRange(range.start, range.start + range.length);
+        setSelectionRange(m_renderer->node(), range.start, range.start + range.length);
         return;
     }
-    
+
     Document* document = m_renderer->document();
     if (!document)
         return;
diff --git a/WebCore/dom/InputElement.cpp b/WebCore/dom/InputElement.cpp
index ecae206..85f37e1 100644
--- a/WebCore/dom/InputElement.cpp
+++ b/WebCore/dom/InputElement.cpp
@@ -107,10 +107,7 @@ void InputElement::updateSelectionRange(InputElement* inputElement, Element* ele
     if (!inputElement->isTextField())
         return;
 
-    element->document()->updateLayoutIgnorePendingStylesheets();
-
-    if (RenderTextControl* renderer = toRenderTextControl(element->renderer()))
-        renderer->setSelectionRange(start, end);
+    setSelectionRange(element, start, end);
 }
 
 void InputElement::aboutToUnload(InputElement* inputElement, Element* element)
diff --git a/WebCore/html/HTMLFormControlElement.cpp b/WebCore/html/HTMLFormControlElement.cpp
index 51b9e20..710cda1 100644
--- a/WebCore/html/HTMLFormControlElement.cpp
+++ b/WebCore/html/HTMLFormControlElement.cpp
@@ -46,11 +46,13 @@
 #include "RenderTheme.h"
 #include "ScriptEventListener.h"
 #include "ValidityState.h"
+#include <limits>
 #include <wtf/Vector.h>
 
 namespace WebCore {
 
 using namespace HTMLNames;
+using namespace std;
 
 HTMLFormControlElement::HTMLFormControlElement(const QualifiedName& tagName, Document* document, HTMLFormElement* form)
     : HTMLElement(tagName, document)
@@ -548,26 +550,22 @@ RenderTextControl* HTMLTextFormControlElement::textRendererAfterUpdateLayout()
 
 void HTMLTextFormControlElement::setSelectionStart(int start)
 {
-    if (RenderTextControl* renderer = textRendererAfterUpdateLayout())
-        renderer->setSelectionStart(start);
+    setSelectionRange(start, max(start, selectionEnd()));
 }
 
 void HTMLTextFormControlElement::setSelectionEnd(int end)
 {
-    if (RenderTextControl* renderer = textRendererAfterUpdateLayout())
-        renderer->setSelectionEnd(end);
+    setSelectionRange(min(end, selectionStart()), end);
 }
 
 void HTMLTextFormControlElement::select()
 {
-    if (RenderTextControl* renderer = textRendererAfterUpdateLayout())
-        renderer->select();
+    setSelectionRange(0, numeric_limits<int>::max());
 }
 
 void HTMLTextFormControlElement::setSelectionRange(int start, int end)
 {
-    if (RenderTextControl* renderer = textRendererAfterUpdateLayout())
-        renderer->setSelectionRange(start, end);
+    WebCore::setSelectionRange(this, start, end);
 }
 
 int HTMLTextFormControlElement::selectionStart()
diff --git a/WebCore/rendering/RenderTextControl.cpp b/WebCore/rendering/RenderTextControl.cpp
index 4855bab..3d6b04b 100644
--- a/WebCore/rendering/RenderTextControl.cpp
+++ b/WebCore/rendering/RenderTextControl.cpp
@@ -216,49 +216,43 @@ int RenderTextControl::selectionEnd()
     return indexForVisiblePosition(frame->selection()->end());
 }
 
-void RenderTextControl::setSelectionStart(int start)
+bool RenderTextControl::hasVisibleTextArea() const
 {
-    HTMLTextFormControlElement* element = static_cast<HTMLTextFormControlElement*>(node());
-    setSelectionRange(start, max(start, element->selectionEnd()));
+    return style()->visibility() == HIDDEN || !m_innerText || !m_innerText->renderer() || !m_innerText->renderBox()->height();
 }
 
-void RenderTextControl::setSelectionEnd(int end)
+void setSelectionRange(Node* node, int start, int end)
 {
-    HTMLTextFormControlElement* element = static_cast<HTMLTextFormControlElement*>(node());
-    setSelectionRange(min(end, element->selectionStart()), end);
-}
+    ASSERT(node);
+    node->document()->updateLayoutIgnorePendingStylesheets();
 
-void RenderTextControl::select()
-{
-    setSelectionRange(0, text().length());
-}
+    if (!node->renderer() || !node->renderer()->isTextControl())
+        return;
 
-void RenderTextControl::setSelectionRange(int start, int end)
-{
     end = max(end, 0);
     start = min(max(start, 0), end);
 
-    ASSERT(!document()->childNeedsAndNotInStyleRecalc());
+    RenderTextControl* control = toRenderTextControl(node->renderer());
 
-    if (style()->visibility() == HIDDEN || !m_innerText || !m_innerText->renderer() || !m_innerText->renderBox()->height()) {
-        cacheSelection(start, end);
+    if (control->hasVisibleTextArea()) {
+        control->cacheSelection(start, end);
         return;
     }
-    VisiblePosition startPosition = visiblePositionForIndex(start);
+    VisiblePosition startPosition = control->visiblePositionForIndex(start);
     VisiblePosition endPosition;
     if (start == end)
         endPosition = startPosition;
     else
-        endPosition = visiblePositionForIndex(end);
+        endPosition = control->visiblePositionForIndex(end);
 
     // startPosition and endPosition can be null position for example when
     // "-webkit-user-select: none" style attribute is specified.
     if (startPosition.isNotNull() && endPosition.isNotNull()) {
-        ASSERT(startPosition.deepEquivalent().node()->shadowAncestorNode() == node() && endPosition.deepEquivalent().node()->shadowAncestorNode() == node());
+        ASSERT(startPosition.deepEquivalent().node()->shadowAncestorNode() == node && endPosition.deepEquivalent().node()->shadowAncestorNode() == node);
     }
     VisibleSelection newSelection = VisibleSelection(startPosition, endPosition);
 
-    if (Frame* frame = this->frame())
+    if (Frame* frame = node->document()->frame())
         frame->selection()->setSelection(newSelection);
 }
 
diff --git a/WebCore/rendering/RenderTextControl.h b/WebCore/rendering/RenderTextControl.h
index 84d7b0b..b75de0e 100644
--- a/WebCore/rendering/RenderTextControl.h
+++ b/WebCore/rendering/RenderTextControl.h
@@ -42,10 +42,6 @@ public:
 
     int selectionStart();
     int selectionEnd();
-    void setSelectionStart(int);
-    void setSelectionEnd(int);
-    void select();
-    void setSelectionRange(int start, int end);
     PassRefPtr<Range> selection(int start, int end) const;
 
     virtual void subtreeHasChanged();
@@ -109,11 +105,16 @@ private:
 
     String finishText(Vector<UChar>&) const;
 
+    bool hasVisibleTextArea() const;
+    friend void setSelectionRange(Node*, int start, int end);
+
     bool m_wasChangedSinceLastChangeEvent;
     bool m_lastChangeWasUserEdit;
     RefPtr<TextControlInnerTextElement> m_innerText;
 };
 
+void setSelectionRange(Node*, int start, int end);
+
 inline RenderTextControl* toRenderTextControl(RenderObject* object)
 { 
     ASSERT(!object || object->isTextControl());
diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp
index cf06726..76ccea6 100644
--- a/WebKit/qt/Api/qwebpage.cpp
+++ b/WebKit/qt/Api/qwebpage.cpp
@@ -1025,14 +1025,9 @@ void QWebPagePrivate::inputMethodEvent(QInputMethodEvent *ev)
     }
 
     RenderObject* renderer = 0;
-    RenderTextControl* renderTextControl = 0;
-
     if (frame->selection()->rootEditableElement())
         renderer = frame->selection()->rootEditableElement()->shadowAncestorNode()->renderer();
 
-    if (renderer && renderer->isTextControl())
-        renderTextControl = toRenderTextControl(renderer);
-
     Vector<CompositionUnderline> underlines;
     bool hasSelection = false;
 
@@ -1059,10 +1054,8 @@ void QWebPagePrivate::inputMethodEvent(QInputMethodEvent *ev)
         case QInputMethodEvent::Selection: {
             hasSelection = true;
             // A selection in the inputMethodEvent is always reflected in the visible text
-            if (renderTextControl) {
-                renderTextControl->setSelectionStart(qMin(a.start, (a.start + a.length)));
-                renderTextControl->setSelectionEnd(qMax(a.start, (a.start + a.length)));
-            }
+            if (renderer && renderer->node())
+                setSelectionRange(renderer->node(), qMin(a.start, (a.start + a.length)), qMax(a.start, (a.start + a.length)));
 
             if (!ev->preeditString().isEmpty()) {
                 editor->setComposition(ev->preeditString(), underlines,
diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index c2dcad8..f621a57 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,3 +1,15 @@
+2010-10-29  Ryosuke Niwa  <rniwa at webkit.org>
+
+        Reviewed by Darin Adler.
+
+        Remove RenderTextControl::setSelectionRange
+        https://bugs.webkit.org/show_bug.cgi?id=47870
+
+        Converted RenderTextControll::setSelectionRange to a global function.
+
+        * Api/qwebpage.cpp:
+        (QWebPagePrivate::inputMethodEvent): Calls setSelectionRange.
+
 2010-10-29  Darin Adler  <darin at apple.com>
 
         Reviewed by Sam Weinig.

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list