Fix for Bugzilla bug 5500, scrollLeft/Top/Width/Height properties not supported
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 10 Sep 2006 05:37:32 +0000 (05:37 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 10 Sep 2006 05:37:32 +0000 (05:37 +0000)
        on textarea.  Refactored the DOM getters and setters to go through the renderer
        instead of right to the layer.  The renderer functions are virtual so that the
        text control can subclass and forward to its anonymous div.

        Fix for Bugzilla bug 10719, When positioned objects are sizing using their
        containing block width as a guide, they should not ever use the line width like
        non-positioned objects do.

        Reviewed by aroben

        * WebCore.xcodeproj/project.pbxproj:
        * dom/Element.cpp:
        (WebCore::Element::scrollLeft):
        (WebCore::Element::scrollTop):
        (WebCore::Element::setScrollLeft):
        (WebCore::Element::setScrollTop):
        * rendering/RenderBox.cpp:
        (WebCore::RenderBox::containingBlockWidthForPositioned):
        * rendering/RenderObject.cpp:
        (WebCore::RenderObject::clientWidth):
        (WebCore::RenderObject::clientHeight):
        (WebCore::RenderObject::scrollWidth):
        (WebCore::RenderObject::scrollHeight):
        (WebCore::RenderObject::scrollLeft):
        (WebCore::RenderObject::scrollTop):
        (WebCore::RenderObject::setScrollLeft):
        (WebCore::RenderObject::setScrollTop):
        (WebCore::RenderObject::hasStaticX):
        (WebCore::RenderObject::hasStaticY):
        * rendering/RenderObject.h:
        (WebCore::RenderObject::clientLeft):
        (WebCore::RenderObject::clientTop):
        * rendering/RenderTextControl.cpp:
        (WebCore::RenderTextControl::scrollWidth):
        (WebCore::RenderTextControl::scrollHeight):
        (WebCore::RenderTextControl::scrollLeft):
        (WebCore::RenderTextControl::scrollTop):
        (WebCore::RenderTextControl::setScrollLeft):
        (WebCore::RenderTextControl::setScrollTop):
        * rendering/RenderTextControl.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16280 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/dom/Element.cpp
WebCore/rendering/RenderBox.cpp
WebCore/rendering/RenderObject.cpp
WebCore/rendering/RenderObject.h
WebCore/rendering/RenderTextControl.cpp
WebCore/rendering/RenderTextControl.h

index 1ebfe31ac4ed23791a72871a5c9d82fdbc32f139..c152c4a3dab9942ce66ce2ffc90fdc2c05f9b880 100644 (file)
@@ -1,3 +1,47 @@
+2006-09-09  David Hyatt  <hyatt@apple.com>
+
+        Fix for Bugzilla bug 5500, scrollLeft/Top/Width/Height properties not supported
+        on textarea.  Refactored the DOM getters and setters to go through the renderer
+        instead of right to the layer.  The renderer functions are virtual so that the
+        text control can subclass and forward to its anonymous div.
+
+        Fix for Bugzilla bug 10719, When positioned objects are sizing using their
+        containing block width as a guide, they should not ever use the line width like
+        non-positioned objects do.
+
+        Reviewed by aroben
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/Element.cpp:
+        (WebCore::Element::scrollLeft):
+        (WebCore::Element::scrollTop):
+        (WebCore::Element::setScrollLeft):
+        (WebCore::Element::setScrollTop):
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::containingBlockWidthForPositioned):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::clientWidth):
+        (WebCore::RenderObject::clientHeight):
+        (WebCore::RenderObject::scrollWidth):
+        (WebCore::RenderObject::scrollHeight):
+        (WebCore::RenderObject::scrollLeft):
+        (WebCore::RenderObject::scrollTop):
+        (WebCore::RenderObject::setScrollLeft):
+        (WebCore::RenderObject::setScrollTop):
+        (WebCore::RenderObject::hasStaticX):
+        (WebCore::RenderObject::hasStaticY):
+        * rendering/RenderObject.h:
+        (WebCore::RenderObject::clientLeft):
+        (WebCore::RenderObject::clientTop):
+        * rendering/RenderTextControl.cpp:
+        (WebCore::RenderTextControl::scrollWidth):
+        (WebCore::RenderTextControl::scrollHeight):
+        (WebCore::RenderTextControl::scrollLeft):
+        (WebCore::RenderTextControl::scrollTop):
+        (WebCore::RenderTextControl::setScrollLeft):
+        (WebCore::RenderTextControl::setScrollTop):
+        * rendering/RenderTextControl.h:
+
 2006-09-09  David Hyatt  <hyatt@apple.com>
 
         Implement support for the WinIE clientLeft and clientTop extensions.
index ddee2a0dcba3e34eea0a71ac8cf201040c476aa7..f0ecf736960bace9bd76fa1c708be739e847d76e 100644 (file)
                FAE04190097596C9000540BE /* SVGImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE0418E097596C9000540BE /* SVGImageLoader.h */; };
 /* End PBXBuildFile section */
 
+/* Begin PBXBuildStyle section */
+               BCA5EAC20AB2AAAA0009504D /* Development */ = {
+                       isa = PBXBuildStyle;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = NO;
+                       };
+                       name = Development;
+               };
+               BCA5EAC30AB2AAAA0009504D /* Deployment */ = {
+                       isa = PBXBuildStyle;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = YES;
+                       };
+                       name = Deployment;
+               };
+/* End PBXBuildStyle section */
+
 /* Begin PBXContainerItemProxy section */
                DD041FF009D9E3250010AF2A /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
+                       buildSettings = {
+                       };
+                       buildStyles = (
+                               BCA5EAC20AB2AAAA0009504D /* Development */,
+                               BCA5EAC30AB2AAAA0009504D /* Deployment */,
+                       );
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
index 32941fe7a3a39f5c01f79e628b445b5d671e934d..35421c595ab38910aa2b0f9055e5a6f2b368a416 100644 (file)
@@ -272,35 +272,31 @@ int Element::clientHeight()
 int Element::scrollLeft()
 {
     document()->updateLayoutIgnorePendingStylesheets();
-    RenderObject* rend = renderer();
-    if (rend && rend->layer())
-        return rend->layer()->scrollXOffset();
+    if (RenderObject* rend = renderer())
+        return rend->scrollLeft();
     return 0;
 }
 
 int Element::scrollTop()
 {
     document()->updateLayoutIgnorePendingStylesheets();
-    RenderObject* rend = renderer();
-    if (rend && rend->layer())
-        return rend->layer()->scrollYOffset();
+    if (RenderObject* rend = renderer())
+        return rend->scrollTop();
     return 0;
 }
 
 void Element::setScrollLeft(int newLeft)
 {
     document()->updateLayoutIgnorePendingStylesheets();
-    RenderObject *rend = renderer();
-    if (rend && rend->hasOverflowClip())
-        rend->layer()->scrollToXOffset(newLeft);
+    if (RenderObject *rend = renderer())
+        rend->setScrollLeft(newLeft);
 }
 
 void Element::setScrollTop(int newTop)
 {
     document()->updateLayoutIgnorePendingStylesheets();
-    RenderObject *rend = renderer();
-    if (rend && rend->hasOverflowClip())
-        rend->layer()->scrollToYOffset(newTop);
+    if (RenderObject *rend = renderer())
+        rend->setScrollTop(newTop);
 }
 
 int Element::scrollWidth()
index cfdcdcc8c83afba1c4dbcc08974ada742af12950..29f061c10b6b7f8255f4dc048bbbd77ef6052768 100644 (file)
@@ -1491,8 +1491,6 @@ int RenderBox::containingBlockWidthForPositioned(const RenderObject* containingB
         return max(0, (fromRight - fromLeft));
     }
 
-    if (usesLineWidth() && isRenderBlock())
-        return static_cast<const RenderBlock*>(containingBlock)->lineWidth(m_y) + containingBlock->paddingLeft() + containingBlock->paddingRight();
     return containingBlock->width() - containingBlock->borderLeft() - containingBlock->borderRight();
 }
 
index 2fb2c57c3e5d27c4a178903fb6d1efdb3c0e5909..31e95098926e223859e906ac266fdef886375ee7 100644 (file)
@@ -612,15 +612,13 @@ RenderObject* RenderObject::offsetParent() const
 
 // More IE extensions.  clientWidth and clientHeight represent the interior of an object
 // excluding border and scrollbar.
-int
-RenderObject::clientWidth() const
+int RenderObject::clientWidth() const
 {
     return width() - borderLeft() - borderRight() -
         (includeVerticalScrollbarSize() ? layer()->verticalScrollbarWidth() : 0);
 }
 
-int
-RenderObject::clientHeight() const
+int RenderObject::clientHeight() const
 {
     return height() - borderTop() - borderBottom() -
       (includeHorizontalScrollbarSize() ? layer()->horizontalScrollbarHeight() : 0);
@@ -628,18 +626,38 @@ RenderObject::clientHeight() const
 
 // scrollWidth/scrollHeight will be the same as clientWidth/clientHeight unless the
 // object has overflow:hidden/scroll/auto specified and also has overflow.
-int
-RenderObject::scrollWidth() const
+int RenderObject::scrollWidth() const
 {
     return hasOverflowClip() ? layer()->scrollWidth() : overflowWidth();
 }
 
-int
-RenderObject::scrollHeight() const
+int RenderObject::scrollHeight() const
 {
     return hasOverflowClip() ? layer()->scrollHeight() : overflowHeight();
 }
 
+int RenderObject::scrollLeft() const
+{
+    return hasOverflowClip() ? layer()->scrollXOffset() : 0;
+}
+
+int RenderObject::scrollTop() const
+{
+    return hasOverflowClip() ? layer()->scrollYOffset() : 0;
+}
+
+void RenderObject::setScrollLeft(int newLeft)
+{
+    if (hasOverflowClip())
+        layer()->scrollToXOffset(newLeft);
+}
+
+void RenderObject::setScrollTop(int newTop)
+{
+    if (hasOverflowClip())
+        layer()->scrollToYOffset(newTop);
+}
+
 bool RenderObject::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier)
 {
     RenderLayer *l = layer();
@@ -653,16 +671,14 @@ bool RenderObject::scroll(ScrollDirection direction, ScrollGranularity granulari
     return false;
 }
 
-bool
-RenderObject::hasStaticX() const
+bool RenderObject::hasStaticX() const
 {
     return (style()->left().isAuto() && style()->right().isAuto()) ||
             style()->left().isStatic() ||
             style()->right().isStatic();
 }
 
-bool
-RenderObject::hasStaticY() const
+bool RenderObject::hasStaticY() const
 {
     return (style()->top().isAuto() && style()->bottom().isAuto()) || style()->top().isStatic();
 }
index 4586ab14d7be0ac50f9d781c135afe587bb1d5e4..0c5a0bebcfc0ee250041cd56a05464cbd9e22e7c 100644 (file)
@@ -602,15 +602,24 @@ public:
     virtual RenderObject* offsetParent() const;
 
     // More IE extensions.  clientWidth and clientHeight represent the interior of an object
-    // excluding border and scrollbar.
+    // excluding border and scrollbar.  clientLeft/Top are just the borderLeftWidth and borderTopWidth.
+    int clientLeft() const { return borderLeft(); }
+    int clientTop() const { return borderTop(); }
     int clientWidth() const;
     int clientHeight() const;
 
     // scrollWidth/scrollHeight will be the same as clientWidth/clientHeight unless the
     // object has overflow:hidden/scroll/auto specified and also has overflow.
-    int scrollWidth() const;
-    int scrollHeight() const;
-    
+    // scrollLeft/Top return the current scroll position.  These methods are virtual so that objects like
+    // textareas can scroll shadow content (but pretend that they are the objects that are
+    // scrolling).
+    virtual int scrollLeft() const;
+    virtual int scrollTop() const;
+    virtual int scrollWidth() const;
+    virtual int scrollHeight() const;
+    virtual void setScrollLeft(int);
+    virtual void setScrollTop(int);
+
     virtual bool scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier=1.0);
 
     // The following seven functions are used to implement collapsing margins.
index f2dec39117b4ec2f3c009f4b1e006f7b97e96e07..e6a45dea81bb00d475e5dfd8b4197b891336112e 100644 (file)
@@ -428,4 +428,44 @@ void RenderTextControl::selectionChanged(bool userTriggered)
         element->onSelect();
 }
 
+int RenderTextControl::scrollWidth() const
+{
+    if (m_div)
+        return m_div->scrollWidth();
+    return RenderFlexibleBox::scrollWidth();
+}
+
+int RenderTextControl::scrollHeight() const
+{
+    if (m_div)
+        return m_div->scrollHeight();
+    return RenderFlexibleBox::scrollHeight();
+}
+
+int RenderTextControl::scrollLeft() const
+{
+    if (m_div)
+        return m_div->scrollLeft();
+    return RenderFlexibleBox::scrollLeft();
+}
+
+int RenderTextControl::scrollTop() const
+{
+    if (m_div)
+        return m_div->scrollTop();
+    return RenderFlexibleBox::scrollTop();
+}
+
+void RenderTextControl::setScrollLeft(int newLeft)
+{
+    if (m_div)
+        m_div->setScrollLeft(newLeft);
+}
+
+void RenderTextControl::setScrollTop(int newTop)
+{
+    if (m_div)
+        m_div->setScrollTop(newTop);
+}
+
 }
index 185a1463ba989cf4a14c127605bf07e993a5fa27..39f102f7a62d6b342ff928840ada2eb5e1047aaf 100644 (file)
@@ -62,6 +62,14 @@ public:
     void forwardEvent(Event*);
     void selectionChanged(bool userTriggered);
 
+    // Subclassed to forward to our inner div.
+    virtual int scrollLeft() const;
+    virtual int scrollTop() const;
+    virtual int scrollWidth() const;
+    virtual int scrollHeight() const;
+    virtual void setScrollLeft(int);
+    virtual void setScrollTop(int);
+
 private:
     VisiblePosition visiblePositionForIndex(int index);
     int indexForVisiblePosition(const VisiblePosition&);