Source/WebCore/ChangeLog

 12011-08-16 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 NOBODY (OOPS!).
 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-16 Scott Byer <scottbyer@chromium.org>
250
351 Fix spelling error.
93178

Source/WebCore/html/HTMLAreaElement.cpp

@@void HTMLAreaElement::parseMappedAttribu
7575
7676void HTMLAreaElement::invalidateCachedRegion()
7777{
78  m_lastSize = IntSize(-1, -1);
 78 m_lastSize = LayoutSize(-1, -1);
7979}
8080
81 bool HTMLAreaElement::mapMouseEvent(int x, int y, const IntSize& size, HitTestResult& result)
 81bool HTMLAreaElement::mapMouseEvent(LayoutPoint location, const LayoutSize& size, HitTestResult& result)
8282{
8383 if (m_lastSize != size) {
8484 m_region = adoptPtr(new Path(getRegion(size)));
8585 m_lastSize = size;
8686 }
8787
88  if (!m_region->contains(IntPoint(x, y)))
 88 if (!m_region->contains(location))
8989 return false;
9090
9191 result.setInnerNode(this);

@@Path HTMLAreaElement::computePath(Render
102102 FloatPoint absPos = obj->localToAbsolute();
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();
108108

@@Path HTMLAreaElement::computePath(Render
118118 return p;
119119}
120120
121 IntRect HTMLAreaElement::computeRect(RenderObject* obj) const
 121LayoutRect HTMLAreaElement::computeRect(RenderObject* obj) const
122122{
123  return enclosingIntRect(computePath(obj).boundingRect());
 123 return enclosingLayoutRect(computePath(obj).boundingRect());
124124}
125125
126 Path HTMLAreaElement::getRegion(const IntSize& size) const
 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.
135135 Shape shape = m_shape;
93161

Source/WebCore/html/HTMLAreaElement.h

2424#define HTMLAreaElement_h
2525
2626#include "HTMLAnchorElement.h"
27 #include "IntSize.h"
 27#include "LayoutTypes.h"
2828#include <wtf/OwnArrayPtr.h>
2929
3030namespace WebCore {

@@public:
3939
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
4747 // The parent map's image.

@@private:
6060 virtual void setFocus(bool);
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
6666 OwnPtr<Path> m_region;
6767 OwnArrayPtr<Length> m_coords;
6868 int m_coordsLen;
69  IntSize m_lastSize;
 69 LayoutSize m_lastSize;
7070 Shape m_shape;
7171};
7272
93161

Source/WebCore/html/HTMLCanvasElement.cpp

@@void HTMLCanvasElement::reset()
264264 (*it)->canvasResized(this);
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
270270 m_dirtyRect = FloatRect();
93161

Source/WebCore/html/HTMLCanvasElement.h

@@public:
9797 // Used for rendering
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;
103103 GraphicsContext* existingDrawingContext() const;
93161

Source/WebCore/html/HTMLMapElement.cpp

@@HTMLMapElement::~HTMLMapElement()
5858{
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;
6464 Node *node = this;

@@bool HTMLMapElement::mapMouseEvent(int x
6868 if (areaElt->isDefault()) {
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 }
7474 }
93161

Source/WebCore/html/HTMLMapElement.h

2727
2828namespace WebCore {
2929
30 class IntSize;
3130class HitTestResult;
3231class HTMLImageElement;
3332

@@public:
3938
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();
4544 PassRefPtr<HTMLCollection> areas();
93161

Source/WebCore/html/ImageDocument.cpp

@@void ImageDocumentParser::finish()
155155
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
161161 // back on the (decoded) hostname if there is no path.

@@float ImageDocument::scale() const
235235 if (!view)
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();
242242 float heightScale = (float)windowSize.height() / imageSize.height();

@@void ImageDocument::resizeImageToFit()
249249 if (!m_imageElement)
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();
255255 m_imageElement->setWidth(static_cast<int>(imageSize.width() * scale));

@@bool ImageDocument::imageFitsInWindow()
326326 if (!view)
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();
333333}
93161

Source/WebCore/html/ValidationMessage.cpp

@@void ValidationMessage::setMessageDOMAnd
106106 }
107107}
108108
109 static void adjustBubblePosition(const IntRect& hostRect, HTMLElement* bubble)
 109static void adjustBubblePosition(const LayoutRect& hostRect, HTMLElement* bubble)
110110{
111111 ASSERT(bubble);
112112 if (hostRect.isEmpty())
93161

Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

@@void CanvasRenderingContext2D::applyShad
11791179 c->setLegacyShadow(FloatSize(width, -height), state().m_shadowBlur, state().m_shadowColor, ColorSpaceDeviceRGB);
11801180}
11811181
1182 static IntSize size(HTMLImageElement* image)
 1182static LayoutSize size(HTMLImageElement* image)
11831183{
11841184 if (CachedImage* cachedImage = image->cachedImage())
11851185 return cachedImage->imageSize(1.0f); // FIXME: Not sure about this.

@@void CanvasRenderingContext2D::drawImage
12091209 ec = TYPE_MISMATCH_ERR;
12101210 return;
12111211 }
1212  IntSize s = size(image);
 1212 LayoutSize s = size(image);
12131213 drawImage(image, x, y, s.width(), s.height(), ec);
12141214}
12151215

@@void CanvasRenderingContext2D::drawImage
12201220 ec = TYPE_MISMATCH_ERR;
12211221 return;
12221222 }
1223  IntSize s = size(image);
 1223 LayoutSize s = size(image);
12241224 drawImage(image, FloatRect(0, 0, s.width(), s.height()), FloatRect(x, y, width, height), ec);
12251225}
12261226
93161

Source/WebCore/html/shadow/MediaControlElements.cpp

@@const AtomicString& MediaControlPanelEle
122122 return id;
123123}
124124
125 void MediaControlPanelElement::startDrag(const IntPoint& eventLocation)
 125void MediaControlPanelElement::startDrag(const LayoutPoint& eventLocation)
126126{
127127 if (!m_canBeDragged)
128128 return;

@@void MediaControlPanelElement::startDrag
146146 m_isBeingDragged = true;
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}
157157

@@void MediaControlPanelElement::endDrag()
169169 frame->eventHandler()->setCapturingMouseEventsNode(0);
170170}
171171
172 void MediaControlPanelElement::setPosition(const IntPoint& position)
 172void MediaControlPanelElement::setPosition(const LayoutPoint& position)
173173{
174174 CSSMutableStyleDeclaration* style = getInlineStyleDecl();
175175

@@void MediaControlPanelElement::defaultEv
199199 MediaControlElement::defaultEventHandler(event);
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);
205205 event->setDefaultHandled();
93161

Source/WebCore/html/shadow/MediaControlElements.h

@@private:
108108 virtual const AtomicString& shadowPseudoId() const;
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
123123// ----------------------------
93161

Source/WebCore/html/shadow/SliderThumbElement.cpp

@@Node* SliderThumbElement::focusDelegate(
195195 return hostInput();
196196}
197197
198 void SliderThumbElement::dragFrom(const IntPoint& point)
 198void SliderThumbElement::dragFrom(const LayoutPoint& point)
199199{
200200 setPositionFromPoint(point);
201201 startDragging();
202202}
203203
204 void SliderThumbElement::setPositionFromPoint(const IntPoint& point)
 204void SliderThumbElement::setPositionFromPoint(const LayoutPoint& point)
205205{
206206 HTMLInputElement* input = hostInput();
207207
208208 if (!input->renderer() || !renderer())
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();
223223 position = offset.y() - renderBox()->height() / 2;

@@void SliderThumbElement::setPositionFrom
227227 position = offset.x() - renderBox()->width() / 2;
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;
233233
93161

Source/WebCore/html/shadow/SliderThumbElement.h

@@public:
5252
5353 void setPositionFromValue();
5454
55  void dragFrom(const IntPoint&);
 55 void dragFrom(const LayoutPoint&);
5656 virtual void defaultEventHandler(Event*);
5757 virtual void detach();
5858 virtual const AtomicString& shadowPseudoId() const;

@@private:
6767 virtual Node* focusDelegate();
6868 void startDragging();
6969 void stopDragging();
70  void setPositionFromPoint(const IntPoint&);
 70 void setPositionFromPoint(const LayoutPoint&);
7171
7272 bool m_inDragMode;
7373};
93161

Source/WebCore/rendering/RenderImage.cpp

@@bool RenderImage::nodeAtPoint(const HitT
437437 if (tempResult.innerNode() && node()) {
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 if (scaleFactor != 1.0f)
 443 mapLocation.scale(scaleFactor, scaleFactor);
 444
 445 if (map->mapMouseEvent(mapLocation, contentBox.size(), tempResult))
444446 tempResult.setInnerNonSharedNode(node());
445447 }
446448 }
93161