Changeset 93279 in webkit


Ignore:
Timestamp:
Aug 17, 2011 8:38:05 PM (13 years ago)
Author:
eae@chromium.org
Message:

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):

Location:
trunk/Source/WebCore
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r93278 r93279  
     12011-08-17  Emil A Eklund  <eae@chromium.org>
     2
     3        Switch html/* to to new layout types
     4        https://bugs.webkit.org/show_bug.cgi?id=66347
     5
     6        Reviewed by Eric Seidel.
     7
     8        Convert HTML* and shadow element to new layout abstraction as a part of
     9        the ongoing conversion work.
     10
     11        No new tests, no new functionality.
     12
     13        * html/HTMLAreaElement.cpp:
     14        (WebCore::HTMLAreaElement::invalidateCachedRegion):
     15        (WebCore::HTMLAreaElement::mapMouseEvent):
     16        (WebCore::HTMLAreaElement::computePath):
     17        (WebCore::HTMLAreaElement::computeRect):
     18        (WebCore::HTMLAreaElement::getRegion):
     19        * html/HTMLAreaElement.h:
     20        * html/HTMLCanvasElement.cpp:
     21        (WebCore::HTMLCanvasElement::paint):
     22        * html/HTMLCanvasElement.h:
     23        * html/HTMLMapElement.cpp:
     24        (WebCore::HTMLMapElement::mapMouseEvent):
     25        * html/HTMLMapElement.h:
     26        * html/ImageDocument.cpp:
     27        (WebCore::ImageDocumentParser::finish):
     28        (WebCore::ImageDocument::scale):
     29        (WebCore::ImageDocument::resizeImageToFit):
     30        (WebCore::ImageDocument::imageFitsInWindow):
     31        * html/ValidationMessage.cpp:
     32        (WebCore::adjustBubblePosition):
     33        * html/canvas/CanvasRenderingContext2D.cpp:
     34        (WebCore::size):
     35        (WebCore::CanvasRenderingContext2D::drawImage):
     36        * html/shadow/MediaControlElements.cpp:
     37        (WebCore::MediaControlPanelElement::startDrag):
     38        (WebCore::MediaControlPanelElement::continueDrag):
     39        (WebCore::MediaControlPanelElement::setPosition):
     40        (WebCore::MediaControlPanelElement::defaultEventHandler):
     41        * html/shadow/MediaControlElements.h:
     42        * html/shadow/SliderThumbElement.cpp:
     43        (WebCore::SliderThumbElement::dragFrom):
     44        (WebCore::SliderThumbElement::setPositionFromPoint):
     45        * html/shadow/SliderThumbElement.h:
     46        * rendering/RenderImage.cpp:
     47        (WebCore::RenderImage::nodeAtPoint):
     48
    1492011-08-17  David Grogan  <dgrogan@chromium.org>
    250
  • trunk/Source/WebCore/html/HTMLAreaElement.cpp

    r91404 r93279  
    7676void HTMLAreaElement::invalidateCachedRegion()
    7777{
    78     m_lastSize = IntSize(-1, -1);
    79 }
    80 
    81 bool HTMLAreaElement::mapMouseEvent(int x, int y, const IntSize& size, HitTestResult& result)
     78    m_lastSize = LayoutSize(-1, -1);
     79}
     80
     81bool HTMLAreaElement::mapMouseEvent(LayoutPoint location, const LayoutSize& size, HitTestResult& result)
    8282{
    8383    if (m_lastSize != size) {
     
    8686    }
    8787
    88     if (!m_region->contains(IntPoint(x, y)))
     88    if (!m_region->contains(location))
    8989        return false;
    9090   
     
    103103
    104104    // Default should default to the size of the containing object.
    105     IntSize size = m_lastSize;
     105    LayoutSize size = m_lastSize;
    106106    if (m_shape == Default)
    107107        size = obj->absoluteOutlineBounds().size();
     
    119119}
    120120   
    121 IntRect HTMLAreaElement::computeRect(RenderObject* obj) const
    122 {
    123     return enclosingIntRect(computePath(obj).boundingRect());
    124 }
    125 
    126 Path HTMLAreaElement::getRegion(const IntSize& size) const
     121LayoutRect HTMLAreaElement::computeRect(RenderObject* obj) const
     122{
     123    return enclosingLayoutRect(computePath(obj).boundingRect());
     124}
     125
     126Path HTMLAreaElement::getRegion(const LayoutSize& size) const
    127127{
    128128    if (!m_coords && m_shape != Default)
    129129        return Path();
    130130
    131     int width = size.width();
    132     int height = size.height();
     131    LayoutUnit width = size.width();
     132    LayoutUnit height = size.height();
    133133
    134134    // If element omits the shape attribute, select shape based on number of coordinates.
  • trunk/Source/WebCore/html/HTMLAreaElement.h

    r91404 r93279  
    2525
    2626#include "HTMLAnchorElement.h"
    27 #include "IntSize.h"
     27#include "LayoutTypes.h"
    2828#include <wtf/OwnArrayPtr.h>
    2929
     
    4040    bool isDefault() const { return m_shape == Default; }
    4141
    42     bool mapMouseEvent(int x, int y, const IntSize&, HitTestResult&);
     42    bool mapMouseEvent(LayoutPoint location, const LayoutSize&, HitTestResult&);
    4343
    44     IntRect computeRect(RenderObject*) const;
     44    LayoutRect computeRect(RenderObject*) const;
    4545    Path computePath(RenderObject*) const;
    4646
     
    6161   
    6262    enum Shape { Default, Poly, Rect, Circle, Unknown };
    63     Path getRegion(const IntSize&) const;
     63    Path getRegion(const LayoutSize&) const;
    6464    void invalidateCachedRegion();
    6565
     
    6767    OwnArrayPtr<Length> m_coords;
    6868    int m_coordsLen;
    69     IntSize m_lastSize;
     69    LayoutSize m_lastSize;
    7070    Shape m_shape;
    7171};
  • trunk/Source/WebCore/html/HTMLCanvasElement.cpp

    r93157 r93279  
    265265}
    266266
    267 void HTMLCanvasElement::paint(GraphicsContext* context, const IntRect& r, bool useLowQualityScale)
     267void HTMLCanvasElement::paint(GraphicsContext* context, const LayoutRect& r, bool useLowQualityScale)
    268268{
    269269    // Clear the dirty rect
  • trunk/Source/WebCore/html/HTMLCanvasElement.h

    r93275 r93279  
    9898    void didDraw(const FloatRect&);
    9999
    100     void paint(GraphicsContext*, const IntRect&, bool useLowQualityScale = false);
     100    void paint(GraphicsContext*, const LayoutRect&, bool useLowQualityScale = false);
    101101
    102102    GraphicsContext* drawingContext() const;
  • trunk/Source/WebCore/html/HTMLMapElement.cpp

    r91404 r93279  
    5959}
    6060
    61 bool HTMLMapElement::mapMouseEvent(int x, int y, const IntSize& size, HitTestResult& result)
     61bool HTMLMapElement::mapMouseEvent(LayoutPoint location, const LayoutSize& size, HitTestResult& result)
    6262{
    6363    HTMLAreaElement* defaultArea = 0;
     
    6969                if (!defaultArea)
    7070                    defaultArea = areaElt;
    71             } else if (areaElt->mapMouseEvent(x, y, size, result))
     71            } else if (areaElt->mapMouseEvent(location, size, result))
    7272                return true;
    7373        }
  • trunk/Source/WebCore/html/HTMLMapElement.h

    r91404 r93279  
    2828namespace WebCore {
    2929
    30 class IntSize;
    3130class HitTestResult;
    3231class HTMLImageElement;
     
    4039    const AtomicString& getName() const { return m_name; }
    4140
    42     bool mapMouseEvent(int x, int y, const IntSize&, HitTestResult&);
     41    bool mapMouseEvent(LayoutPoint location, const LayoutSize&, HitTestResult&);
    4342   
    4443    HTMLImageElement* imageElement();
  • trunk/Source/WebCore/html/ImageDocument.cpp

    r88623 r93279  
    156156        // Report the natural image size in the page title, regardless of zoom
    157157        // level.
    158         IntSize size = cachedImage->imageSize(1.0f);
     158        LayoutSize size = cachedImage->imageSize(1.0f);
    159159        if (size.width()) {
    160160            // Compute the title, we use the decoded filename of the resource, falling
     
    236236        return 1;
    237237
    238     IntSize imageSize = m_imageElement->cachedImage()->imageSize(pageZoomFactor(this));
    239     IntSize windowSize = IntSize(view->width(), view->height());
     238    LayoutSize imageSize = m_imageElement->cachedImage()->imageSize(pageZoomFactor(this));
     239    LayoutSize windowSize = IntSize(view->width(), view->height());
    240240   
    241241    float widthScale = (float)windowSize.width() / imageSize.width();
     
    250250        return;
    251251
    252     IntSize imageSize = m_imageElement->cachedImage()->imageSize(pageZoomFactor(this));
     252    LayoutSize imageSize = m_imageElement->cachedImage()->imageSize(pageZoomFactor(this));
    253253
    254254    float scale = this->scale();
     
    327327        return true;
    328328
    329     IntSize imageSize = m_imageElement->cachedImage()->imageSize(pageZoomFactor(this));
    330     IntSize windowSize = IntSize(view->width(), view->height());
     329    LayoutSize imageSize = m_imageElement->cachedImage()->imageSize(pageZoomFactor(this));
     330    LayoutSize windowSize = LayoutSize(view->width(), view->height());
    331331   
    332332    return imageSize.width() <= windowSize.width() && imageSize.height() <= windowSize.height();   
  • trunk/Source/WebCore/html/ValidationMessage.cpp

    r92585 r93279  
    107107}
    108108
    109 static void adjustBubblePosition(const IntRect& hostRect, HTMLElement* bubble)
     109static void adjustBubblePosition(const LayoutRect& hostRect, HTMLElement* bubble)
    110110{
    111111    ASSERT(bubble);
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r93275 r93279  
    11861186}
    11871187
    1188 static IntSize size(HTMLImageElement* image)
     1188static LayoutSize size(HTMLImageElement* image)
    11891189{
    11901190    if (CachedImage* cachedImage = image->cachedImage())
     
    12161216        return;
    12171217    }
    1218     IntSize s = size(image);
     1218    LayoutSize s = size(image);
    12191219    drawImage(image, x, y, s.width(), s.height(), ec);
    12201220}
     
    12271227        return;
    12281228    }
    1229     IntSize s = size(image);
     1229    LayoutSize s = size(image);
    12301230    drawImage(image, FloatRect(0, 0, s.width(), s.height()), FloatRect(x, y, width, height), ec);
    12311231}
  • trunk/Source/WebCore/html/shadow/MediaControlElements.cpp

    r92347 r93279  
    123123}
    124124
    125 void MediaControlPanelElement::startDrag(const IntPoint& eventLocation)
     125void MediaControlPanelElement::startDrag(const LayoutPoint& eventLocation)
    126126{
    127127    if (!m_canBeDragged)
     
    147147}
    148148
    149 void MediaControlPanelElement::continueDrag(const IntPoint& eventLocation)
     149void MediaControlPanelElement::continueDrag(const LayoutPoint& eventLocation)
    150150{
    151151    if (!m_isBeingDragged)
    152152        return;
    153153
    154     IntSize distanceDragged = eventLocation - m_dragStartEventLocation;
     154    LayoutSize distanceDragged = eventLocation - m_dragStartEventLocation;
    155155    setPosition(m_dragStartPosition + distanceDragged);
    156156}
     
    170170}
    171171
    172 void MediaControlPanelElement::setPosition(const IntPoint& position)
     172void MediaControlPanelElement::setPosition(const LayoutPoint& position)
    173173{
    174174    CSSMutableStyleDeclaration* style = getInlineStyleDecl();
     
    200200
    201201    if (event->isMouseEvent()) {
    202         IntPoint location = static_cast<MouseEvent*>(event)->absoluteLocation();
     202        LayoutPoint location = static_cast<MouseEvent*>(event)->absoluteLocation();
    203203        if (event->type() == eventNames().mousedownEvent) {
    204204            startDrag(location);
  • trunk/Source/WebCore/html/shadow/MediaControlElements.h

    r88546 r93279  
    109109    virtual void defaultEventHandler(Event*);
    110110
    111     void startDrag(const IntPoint& eventLocation);
    112     void continueDrag(const IntPoint& eventLocation);
     111    void startDrag(const LayoutPoint& eventLocation);
     112    void continueDrag(const LayoutPoint& eventLocation);
    113113    void endDrag();
    114114
    115     void setPosition(const IntPoint&);
     115    void setPosition(const LayoutPoint&);
    116116
    117117    bool m_canBeDragged;
    118118    bool m_isBeingDragged;
    119     IntPoint m_dragStartPosition;
    120     IntPoint m_dragStartEventLocation;
     119    LayoutPoint m_dragStartPosition;
     120    LayoutPoint m_dragStartEventLocation;
    121121};
    122122
  • trunk/Source/WebCore/html/shadow/SliderThumbElement.cpp

    r91827 r93279  
    196196}
    197197
    198 void SliderThumbElement::dragFrom(const IntPoint& point)
     198void SliderThumbElement::dragFrom(const LayoutPoint& point)
    199199{
    200200    setPositionFromPoint(point);
     
    202202}
    203203
    204 void SliderThumbElement::setPositionFromPoint(const IntPoint& point)
     204void SliderThumbElement::setPositionFromPoint(const LayoutPoint& point)
    205205{
    206206    HTMLInputElement* input = hostInput();
     
    209209        return;
    210210
    211     IntPoint offset = roundedIntPoint(input->renderer()->absoluteToLocal(point, false, true));
     211    LayoutPoint offset = roundedLayoutPoint(input->renderer()->absoluteToLocal(point, false, true));
    212212    bool isVertical = hasVerticalAppearance(input);
    213     int trackSize;
    214     int position;
    215     int currentPosition;
     213    LayoutUnit trackSize;
     214    LayoutUnit position;
     215    LayoutUnit currentPosition;
    216216    // We need to calculate currentPosition from absolute points becaue the
    217217    // renderer for this node is usually on a layer and renderBox()->x() and
    218218    // y() are unusable.
    219     IntPoint absoluteThumbOrigin = renderBox()->absoluteBoundingBoxRect().location();
    220     IntPoint absoluteSliderContentOrigin = roundedIntPoint(input->renderer()->localToAbsolute());
     219    LayoutPoint absoluteThumbOrigin = renderBox()->absoluteBoundingBoxRect().location();
     220    LayoutPoint absoluteSliderContentOrigin = roundedLayoutPoint(input->renderer()->localToAbsolute());
    221221    if (isVertical) {
    222222        trackSize = input->renderBox()->contentHeight() - renderBox()->height();
     
    228228        currentPosition = absoluteThumbOrigin.x() - absoluteSliderContentOrigin.x();
    229229    }
    230     position = max(0, min(position, trackSize));
     230    position = max<LayoutUnit>(0, min(position, trackSize));
    231231    if (position == currentPosition)
    232232        return;
  • trunk/Source/WebCore/html/shadow/SliderThumbElement.h

    r91574 r93279  
    5353    void setPositionFromValue();
    5454
    55     void dragFrom(const IntPoint&);
     55    void dragFrom(const LayoutPoint&);
    5656    virtual void defaultEventHandler(Event*);
    5757    virtual void detach();
     
    6868    void startDragging();
    6969    void stopDragging();
    70     void setPositionFromPoint(const IntPoint&);
     70    void setPositionFromPoint(const LayoutPoint&);
    7171
    7272    bool m_inDragMode;
  • trunk/Source/WebCore/rendering/RenderImage.cpp

    r91628 r93279  
    438438        if (HTMLMapElement* map = imageMap()) {
    439439            IntRect contentBox = contentBoxRect();
    440             float zoom = style()->effectiveZoom();
    441             LayoutUnit mapX = roundedLayoutUnit((pointInContainer.x() - accumulatedOffset.x() - this->x() - contentBox.x()) / zoom);
    442             LayoutUnit mapY = roundedLayoutUnit((pointInContainer.y() - accumulatedOffset.y() - this->y() - contentBox.y()) / zoom);
    443             if (map->mapMouseEvent(mapX, mapY, contentBox.size(), tempResult))
     440            float scaleFactor = 1 / style()->effectiveZoom();
     441            LayoutPoint mapLocation(pointInContainer.x() - accumulatedOffset.x() - this->x() - contentBox.x(), pointInContainer.y() - accumulatedOffset.y() - this->y() - contentBox.y());
     442            mapLocation.scale(scaleFactor, scaleFactor);
     443           
     444            if (map->mapMouseEvent(mapLocation, contentBox.size(), tempResult))
    444445                tempResult.setInnerNonSharedNode(node());
    445446        }
Note: See TracChangeset for help on using the changeset viewer.