Switch html/* to to new layout types
authoreae@chromium.org <eae@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Aug 2011 03:38:05 +0000 (03:38 +0000)
committereae@chromium.org <eae@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Aug 2011 03:38:05 +0000 (03:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=66347

Reviewed by Eric Seidel.

Convert HTML* and shadow element to new layout abstraction as a part of
the ongoing conversion work.

No new tests, no new functionality.

* html/HTMLAreaElement.cpp:
(WebCore::HTMLAreaElement::invalidateCachedRegion):
(WebCore::HTMLAreaElement::mapMouseEvent):
(WebCore::HTMLAreaElement::computePath):
(WebCore::HTMLAreaElement::computeRect):
(WebCore::HTMLAreaElement::getRegion):
* html/HTMLAreaElement.h:
* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::paint):
* html/HTMLCanvasElement.h:
* html/HTMLMapElement.cpp:
(WebCore::HTMLMapElement::mapMouseEvent):
* html/HTMLMapElement.h:
* html/ImageDocument.cpp:
(WebCore::ImageDocumentParser::finish):
(WebCore::ImageDocument::scale):
(WebCore::ImageDocument::resizeImageToFit):
(WebCore::ImageDocument::imageFitsInWindow):
* html/ValidationMessage.cpp:
(WebCore::adjustBubblePosition):
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::size):
(WebCore::CanvasRenderingContext2D::drawImage):
* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlPanelElement::startDrag):
(WebCore::MediaControlPanelElement::continueDrag):
(WebCore::MediaControlPanelElement::setPosition):
(WebCore::MediaControlPanelElement::defaultEventHandler):
* html/shadow/MediaControlElements.h:
* html/shadow/SliderThumbElement.cpp:
(WebCore::SliderThumbElement::dragFrom):
(WebCore::SliderThumbElement::setPositionFromPoint):
* html/shadow/SliderThumbElement.h:
* rendering/RenderImage.cpp:
(WebCore::RenderImage::nodeAtPoint):

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

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLAreaElement.cpp
Source/WebCore/html/HTMLAreaElement.h
Source/WebCore/html/HTMLCanvasElement.cpp
Source/WebCore/html/HTMLCanvasElement.h
Source/WebCore/html/HTMLMapElement.cpp
Source/WebCore/html/HTMLMapElement.h
Source/WebCore/html/ImageDocument.cpp
Source/WebCore/html/ValidationMessage.cpp
Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
Source/WebCore/html/shadow/MediaControlElements.cpp
Source/WebCore/html/shadow/MediaControlElements.h
Source/WebCore/html/shadow/SliderThumbElement.cpp
Source/WebCore/html/shadow/SliderThumbElement.h
Source/WebCore/rendering/RenderImage.cpp

index d6e7c0e..87e2283 100644 (file)
@@ -1,3 +1,51 @@
+2011-08-17  Emil A Eklund  <eae@chromium.org>
+
+        Switch html/* to to new layout types
+        https://bugs.webkit.org/show_bug.cgi?id=66347
+
+        Reviewed by Eric Seidel.
+
+        Convert HTML* and shadow element to new layout abstraction as a part of
+        the ongoing conversion work.
+
+        No new tests, no new functionality.
+
+        * html/HTMLAreaElement.cpp:
+        (WebCore::HTMLAreaElement::invalidateCachedRegion):
+        (WebCore::HTMLAreaElement::mapMouseEvent):
+        (WebCore::HTMLAreaElement::computePath):
+        (WebCore::HTMLAreaElement::computeRect):
+        (WebCore::HTMLAreaElement::getRegion):
+        * html/HTMLAreaElement.h:
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::paint):
+        * html/HTMLCanvasElement.h:
+        * html/HTMLMapElement.cpp:
+        (WebCore::HTMLMapElement::mapMouseEvent):
+        * html/HTMLMapElement.h:
+        * html/ImageDocument.cpp:
+        (WebCore::ImageDocumentParser::finish):
+        (WebCore::ImageDocument::scale):
+        (WebCore::ImageDocument::resizeImageToFit):
+        (WebCore::ImageDocument::imageFitsInWindow):
+        * html/ValidationMessage.cpp:
+        (WebCore::adjustBubblePosition):
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::size):
+        (WebCore::CanvasRenderingContext2D::drawImage):
+        * html/shadow/MediaControlElements.cpp:
+        (WebCore::MediaControlPanelElement::startDrag):
+        (WebCore::MediaControlPanelElement::continueDrag):
+        (WebCore::MediaControlPanelElement::setPosition):
+        (WebCore::MediaControlPanelElement::defaultEventHandler):
+        * html/shadow/MediaControlElements.h:
+        * html/shadow/SliderThumbElement.cpp:
+        (WebCore::SliderThumbElement::dragFrom):
+        (WebCore::SliderThumbElement::setPositionFromPoint):
+        * html/shadow/SliderThumbElement.h:
+        * rendering/RenderImage.cpp:
+        (WebCore::RenderImage::nodeAtPoint):
+
 2011-08-17  David Grogan  <dgrogan@chromium.org>
 
         Change references to leveldb.gyp to leveldatabase.gyp as part of the
index fbacea5..c2e8d6e 100644 (file)
@@ -75,17 +75,17 @@ void HTMLAreaElement::parseMappedAttribute(Attribute* attr)
 
 void HTMLAreaElement::invalidateCachedRegion()
 {
-    m_lastSize = IntSize(-1, -1);
+    m_lastSize = LayoutSize(-1, -1);
 }
 
-bool HTMLAreaElement::mapMouseEvent(int x, int y, const IntSize& size, HitTestResult& result)
+bool HTMLAreaElement::mapMouseEvent(LayoutPoint location, const LayoutSize& size, HitTestResult& result)
 {
     if (m_lastSize != size) {
         m_region = adoptPtr(new Path(getRegion(size)));
         m_lastSize = size;
     }
 
-    if (!m_region->contains(IntPoint(x, y)))
+    if (!m_region->contains(location))
         return false;
     
     result.setInnerNode(this);
@@ -102,7 +102,7 @@ Path HTMLAreaElement::computePath(RenderObject* obj) const
     FloatPoint absPos = obj->localToAbsolute();
 
     // Default should default to the size of the containing object.
-    IntSize size = m_lastSize;
+    LayoutSize size = m_lastSize;
     if (m_shape == Default)
         size = obj->absoluteOutlineBounds().size();
     
@@ -118,18 +118,18 @@ Path HTMLAreaElement::computePath(RenderObject* obj) const
     return p;
 }
     
-IntRect HTMLAreaElement::computeRect(RenderObject* obj) const
+LayoutRect HTMLAreaElement::computeRect(RenderObject* obj) const
 {
-    return enclosingIntRect(computePath(obj).boundingRect());
+    return enclosingLayoutRect(computePath(obj).boundingRect());
 }
 
-Path HTMLAreaElement::getRegion(const IntSize& size) const
+Path HTMLAreaElement::getRegion(const LayoutSize& size) const
 {
     if (!m_coords && m_shape != Default)
         return Path();
 
-    int width = size.width();
-    int height = size.height();
+    LayoutUnit width = size.width();
+    LayoutUnit height = size.height();
 
     // If element omits the shape attribute, select shape based on number of coordinates.
     Shape shape = m_shape;
index 8ad1cbc..c43ba6d 100644 (file)
@@ -24,7 +24,7 @@
 #define HTMLAreaElement_h
 
 #include "HTMLAnchorElement.h"
-#include "IntSize.h"
+#include "LayoutTypes.h"
 #include <wtf/OwnArrayPtr.h>
 
 namespace WebCore {
@@ -39,9 +39,9 @@ public:
 
     bool isDefault() const { return m_shape == Default; }
 
-    bool mapMouseEvent(int x, int y, const IntSize&, HitTestResult&);
+    bool mapMouseEvent(LayoutPoint location, const LayoutSize&, HitTestResult&);
 
-    IntRect computeRect(RenderObject*) const;
+    LayoutRect computeRect(RenderObject*) const;
     Path computePath(RenderObject*) const;
 
     // The parent map's image.
@@ -60,13 +60,13 @@ private:
     virtual void setFocus(bool);
     
     enum Shape { Default, Poly, Rect, Circle, Unknown };
-    Path getRegion(const IntSize&) const;
+    Path getRegion(const LayoutSize&) const;
     void invalidateCachedRegion();
 
     OwnPtr<Path> m_region;
     OwnArrayPtr<Length> m_coords;
     int m_coordsLen;
-    IntSize m_lastSize;
+    LayoutSize m_lastSize;
     Shape m_shape;
 };
 
index 2a7ad1d..1a0cb21 100644 (file)
@@ -264,7 +264,7 @@ void HTMLCanvasElement::reset()
         (*it)->canvasResized(this);
 }
 
-void HTMLCanvasElement::paint(GraphicsContext* context, const IntRect& r, bool useLowQualityScale)
+void HTMLCanvasElement::paint(GraphicsContext* context, const LayoutRect& r, bool useLowQualityScale)
 {
     // Clear the dirty rect
     m_dirtyRect = FloatRect();
index acf6186..f265f42 100644 (file)
@@ -97,7 +97,7 @@ public:
     // Used for rendering
     void didDraw(const FloatRect&);
 
-    void paint(GraphicsContext*, const IntRect&, bool useLowQualityScale = false);
+    void paint(GraphicsContext*, const LayoutRect&, bool useLowQualityScale = false);
 
     GraphicsContext* drawingContext() const;
     GraphicsContext* existingDrawingContext() const;
index f83bdc4..e944dad 100644 (file)
@@ -58,7 +58,7 @@ HTMLMapElement::~HTMLMapElement()
 {
 }
 
-bool HTMLMapElement::mapMouseEvent(int x, int y, const IntSize& size, HitTestResult& result)
+bool HTMLMapElement::mapMouseEvent(LayoutPoint location, const LayoutSize& size, HitTestResult& result)
 {
     HTMLAreaElement* defaultArea = 0;
     Node *node = this;
@@ -68,7 +68,7 @@ bool HTMLMapElement::mapMouseEvent(int x, int y, const IntSize& size, HitTestRes
             if (areaElt->isDefault()) {
                 if (!defaultArea)
                     defaultArea = areaElt;
-            } else if (areaElt->mapMouseEvent(x, y, size, result))
+            } else if (areaElt->mapMouseEvent(location, size, result))
                 return true;
         }
     }
index 8e356b4..3006766 100644 (file)
@@ -27,7 +27,6 @@
 
 namespace WebCore {
 
-class IntSize;
 class HitTestResult;
 class HTMLImageElement;
     
@@ -39,7 +38,7 @@ public:
 
     const AtomicString& getName() const { return m_name; }
 
-    bool mapMouseEvent(int x, int y, const IntSize&, HitTestResult&);
+    bool mapMouseEvent(LayoutPoint location, const LayoutSize&, HitTestResult&);
     
     HTMLImageElement* imageElement();
     PassRefPtr<HTMLCollection> areas();
index 8f4b5e9..ddcb03f 100644 (file)
@@ -155,7 +155,7 @@ void ImageDocumentParser::finish()
 
         // Report the natural image size in the page title, regardless of zoom
         // level.
-        IntSize size = cachedImage->imageSize(1.0f);
+        LayoutSize size = cachedImage->imageSize(1.0f);
         if (size.width()) {
             // Compute the title, we use the decoded filename of the resource, falling
             // back on the (decoded) hostname if there is no path.
@@ -235,8 +235,8 @@ float ImageDocument::scale() const
     if (!view)
         return 1;
 
-    IntSize imageSize = m_imageElement->cachedImage()->imageSize(pageZoomFactor(this));
-    IntSize windowSize = IntSize(view->width(), view->height());
+    LayoutSize imageSize = m_imageElement->cachedImage()->imageSize(pageZoomFactor(this));
+    LayoutSize windowSize = IntSize(view->width(), view->height());
     
     float widthScale = (float)windowSize.width() / imageSize.width();
     float heightScale = (float)windowSize.height() / imageSize.height();
@@ -249,7 +249,7 @@ void ImageDocument::resizeImageToFit()
     if (!m_imageElement)
         return;
 
-    IntSize imageSize = m_imageElement->cachedImage()->imageSize(pageZoomFactor(this));
+    LayoutSize imageSize = m_imageElement->cachedImage()->imageSize(pageZoomFactor(this));
 
     float scale = this->scale();
     m_imageElement->setWidth(static_cast<int>(imageSize.width() * scale));
@@ -326,8 +326,8 @@ bool ImageDocument::imageFitsInWindow() const
     if (!view)
         return true;
 
-    IntSize imageSize = m_imageElement->cachedImage()->imageSize(pageZoomFactor(this));
-    IntSize windowSize = IntSize(view->width(), view->height());
+    LayoutSize imageSize = m_imageElement->cachedImage()->imageSize(pageZoomFactor(this));
+    LayoutSize windowSize = LayoutSize(view->width(), view->height());
     
     return imageSize.width() <= windowSize.width() && imageSize.height() <= windowSize.height();    
 }
index de57136..0d1f174 100644 (file)
@@ -106,7 +106,7 @@ void ValidationMessage::setMessageDOMAndStartTimer(Timer<ValidationMessage>*)
     }
 }
 
-static void adjustBubblePosition(const IntRect& hostRect, HTMLElement* bubble)
+static void adjustBubblePosition(const LayoutRect& hostRect, HTMLElement* bubble)
 {
     ASSERT(bubble);
     if (hostRect.isEmpty())
index 9054057..9d859c3 100644 (file)
@@ -1185,7 +1185,7 @@ void CanvasRenderingContext2D::applyShadow()
     c->setLegacyShadow(FloatSize(width, -height), state().m_shadowBlur, state().m_shadowColor, ColorSpaceDeviceRGB);
 }
 
-static IntSize size(HTMLImageElement* image)
+static LayoutSize size(HTMLImageElement* image)
 {
     if (CachedImage* cachedImage = image->cachedImage())
         return cachedImage->imageSize(1.0f); // FIXME: Not sure about this.
@@ -1215,7 +1215,7 @@ void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, float x, float
         ec = TYPE_MISMATCH_ERR;
         return;
     }
-    IntSize s = size(image);
+    LayoutSize s = size(image);
     drawImage(image, x, y, s.width(), s.height(), ec);
 }
 
@@ -1226,7 +1226,7 @@ void CanvasRenderingContext2D::drawImage(HTMLImageElement* image,
         ec = TYPE_MISMATCH_ERR;
         return;
     }
-    IntSize s = size(image);
+    LayoutSize s = size(image);
     drawImage(image, FloatRect(0, 0, s.width(), s.height()), FloatRect(x, y, width, height), ec);
 }
 
index 4a99ca3..cb95b1b 100644 (file)
@@ -122,7 +122,7 @@ const AtomicString& MediaControlPanelElement::shadowPseudoId() const
     return id;
 }
 
-void MediaControlPanelElement::startDrag(const IntPoint& eventLocation)
+void MediaControlPanelElement::startDrag(const LayoutPoint& eventLocation)
 {
     if (!m_canBeDragged)
         return;
@@ -146,12 +146,12 @@ void MediaControlPanelElement::startDrag(const IntPoint& eventLocation)
     m_isBeingDragged = true;
 }
 
-void MediaControlPanelElement::continueDrag(const IntPoint& eventLocation)
+void MediaControlPanelElement::continueDrag(const LayoutPoint& eventLocation)
 {
     if (!m_isBeingDragged)
         return;
 
-    IntSize distanceDragged = eventLocation - m_dragStartEventLocation;
+    LayoutSize distanceDragged = eventLocation - m_dragStartEventLocation;
     setPosition(m_dragStartPosition + distanceDragged);
 }
 
@@ -169,7 +169,7 @@ void MediaControlPanelElement::endDrag()
     frame->eventHandler()->setCapturingMouseEventsNode(0);
 }
 
-void MediaControlPanelElement::setPosition(const IntPoint& position)
+void MediaControlPanelElement::setPosition(const LayoutPoint& position)
 {
     CSSMutableStyleDeclaration* style = getInlineStyleDecl();
 
@@ -199,7 +199,7 @@ void MediaControlPanelElement::defaultEventHandler(Event* event)
     MediaControlElement::defaultEventHandler(event);
 
     if (event->isMouseEvent()) {
-        IntPoint location = static_cast<MouseEvent*>(event)->absoluteLocation();
+        LayoutPoint location = static_cast<MouseEvent*>(event)->absoluteLocation();
         if (event->type() == eventNames().mousedownEvent) {
             startDrag(location);
             event->setDefaultHandled();
index 2128d66..0679183 100644 (file)
@@ -108,16 +108,16 @@ private:
     virtual const AtomicString& shadowPseudoId() const;
     virtual void defaultEventHandler(Event*);
 
-    void startDrag(const IntPoint& eventLocation);
-    void continueDrag(const IntPoint& eventLocation);
+    void startDrag(const LayoutPoint& eventLocation);
+    void continueDrag(const LayoutPoint& eventLocation);
     void endDrag();
 
-    void setPosition(const IntPoint&);
+    void setPosition(const LayoutPoint&);
 
     bool m_canBeDragged;
     bool m_isBeingDragged;
-    IntPoint m_dragStartPosition;
-    IntPoint m_dragStartEventLocation;
+    LayoutPoint m_dragStartPosition;
+    LayoutPoint m_dragStartEventLocation;
 };
 
 // ----------------------------
index 3cd3535..5d178af 100644 (file)
@@ -195,29 +195,29 @@ Node* SliderThumbElement::focusDelegate()
     return hostInput();
 }
 
-void SliderThumbElement::dragFrom(const IntPoint& point)
+void SliderThumbElement::dragFrom(const LayoutPoint& point)
 {
     setPositionFromPoint(point);
     startDragging();
 }
 
-void SliderThumbElement::setPositionFromPoint(const IntPoint& point)
+void SliderThumbElement::setPositionFromPoint(const LayoutPoint& point)
 {
     HTMLInputElement* input = hostInput();
 
     if (!input->renderer() || !renderer())
         return;
 
-    IntPoint offset = roundedIntPoint(input->renderer()->absoluteToLocal(point, false, true));
+    LayoutPoint offset = roundedLayoutPoint(input->renderer()->absoluteToLocal(point, false, true));
     bool isVertical = hasVerticalAppearance(input);
-    int trackSize;
-    int position;
-    int currentPosition;
+    LayoutUnit trackSize;
+    LayoutUnit position;
+    LayoutUnit currentPosition;
     // We need to calculate currentPosition from absolute points becaue the
     // renderer for this node is usually on a layer and renderBox()->x() and
     // y() are unusable.
-    IntPoint absoluteThumbOrigin = renderBox()->absoluteBoundingBoxRect().location();
-    IntPoint absoluteSliderContentOrigin = roundedIntPoint(input->renderer()->localToAbsolute());
+    LayoutPoint absoluteThumbOrigin = renderBox()->absoluteBoundingBoxRect().location();
+    LayoutPoint absoluteSliderContentOrigin = roundedLayoutPoint(input->renderer()->localToAbsolute());
     if (isVertical) {
         trackSize = input->renderBox()->contentHeight() - renderBox()->height();
         position = offset.y() - renderBox()->height() / 2;
@@ -227,7 +227,7 @@ void SliderThumbElement::setPositionFromPoint(const IntPoint& point)
         position = offset.x() - renderBox()->width() / 2;
         currentPosition = absoluteThumbOrigin.x() - absoluteSliderContentOrigin.x();
     }
-    position = max(0, min(position, trackSize));
+    position = max<LayoutUnit>(0, min(position, trackSize));
     if (position == currentPosition)
         return;
 
index 4a7b046..e2d8b66 100644 (file)
@@ -52,7 +52,7 @@ public:
 
     void setPositionFromValue();
 
-    void dragFrom(const IntPoint&);
+    void dragFrom(const LayoutPoint&);
     virtual void defaultEventHandler(Event*);
     virtual void detach();
     virtual const AtomicString& shadowPseudoId() const;
@@ -67,7 +67,7 @@ private:
     virtual Node* focusDelegate();
     void startDragging();
     void stopDragging();
-    void setPositionFromPoint(const IntPoint&);
+    void setPositionFromPoint(const LayoutPoint&);
 
     bool m_inDragMode;
 };
index 04347d4..7022cda 100644 (file)
@@ -437,10 +437,11 @@ bool RenderImage::nodeAtPoint(const HitTestRequest& request, HitTestResult& resu
     if (tempResult.innerNode() && node()) {
         if (HTMLMapElement* map = imageMap()) {
             IntRect contentBox = contentBoxRect();
-            float zoom = style()->effectiveZoom();
-            LayoutUnit mapX = roundedLayoutUnit((pointInContainer.x() - accumulatedOffset.x() - this->x() - contentBox.x()) / zoom);
-            LayoutUnit mapY = roundedLayoutUnit((pointInContainer.y() - accumulatedOffset.y() - this->y() - contentBox.y()) / zoom);
-            if (map->mapMouseEvent(mapX, mapY, contentBox.size(), tempResult))
+            float scaleFactor = 1 / style()->effectiveZoom();
+            LayoutPoint mapLocation(pointInContainer.x() - accumulatedOffset.x() - this->x() - contentBox.x(), pointInContainer.y() - accumulatedOffset.y() - this->y() - contentBox.y());
+            mapLocation.scale(scaleFactor, scaleFactor);
+            
+            if (map->mapMouseEvent(mapLocation, contentBox.size(), tempResult))
                 tempResult.setInnerNonSharedNode(node());
         }
     }