OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Apple Computer, Inc. | 2 * Copyright (C) 2006 Apple Computer, Inc. |
3 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> | 3 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> |
4 * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> | 4 * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> |
5 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> | 5 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> |
6 * Copyright (C) 2008 Rob Buis <buis@kde.org> | 6 * Copyright (C) 2008 Rob Buis <buis@kde.org> |
7 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 7 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
8 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. | 8 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. |
9 * Copyright (C) 2012 Google Inc. | 9 * Copyright (C) 2012 Google Inc. |
10 * | 10 * |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 LayoutUnit beforeEdge = borderBefore() + paddingBefore(); | 242 LayoutUnit beforeEdge = borderBefore() + paddingBefore(); |
243 LayoutUnit afterEdge = | 243 LayoutUnit afterEdge = |
244 borderAfter() + paddingAfter() + scrollbarLogicalHeight(); | 244 borderAfter() + paddingAfter() + scrollbarLogicalHeight(); |
245 setLogicalHeight(beforeEdge); | 245 setLogicalHeight(beforeEdge); |
246 | 246 |
247 LayoutState state(*this); | 247 LayoutState state(*this); |
248 layoutInlineChildren(true, afterEdge); | 248 layoutInlineChildren(true, afterEdge); |
249 | 249 |
250 m_needsReordering = false; | 250 m_needsReordering = false; |
251 | 251 |
252 // If we don't have any line boxes, then make sure the frame rect is still | 252 FloatRect newBoundaries = objectBoundingBox(); |
253 // cleared. | 253 if (!updateParentBoundaries) |
254 if (!firstLineBox()) | 254 updateParentBoundaries = oldBoundaries != newBoundaries; |
255 setFrameRect(LayoutRect()); | |
256 | 255 |
257 m_overflow.reset(); | 256 m_overflow.reset(); |
| 257 addSelfVisualOverflow(LayoutRect(newBoundaries)); |
258 addVisualEffectOverflow(); | 258 addVisualEffectOverflow(); |
259 | 259 |
260 if (!updateParentBoundaries) | |
261 updateParentBoundaries = oldBoundaries != objectBoundingBox(); | |
262 | |
263 // Invalidate all resources of this client if our layout changed. | 260 // Invalidate all resources of this client if our layout changed. |
264 if (everHadLayout() && selfNeedsLayout()) | 261 if (everHadLayout() && selfNeedsLayout()) |
265 SVGResourcesCache::clientLayoutChanged(this); | 262 SVGResourcesCache::clientLayoutChanged(this); |
266 | 263 |
267 // If our bounds changed, notify the parents. | 264 // If our bounds changed, notify the parents. |
268 if (updateParentBoundaries) | 265 if (updateParentBoundaries) |
269 LayoutSVGBlock::setNeedsBoundariesUpdate(); | 266 LayoutSVGBlock::setNeedsBoundariesUpdate(); |
270 | 267 |
271 ASSERT(!m_needsReordering); | 268 ASSERT(!m_needsReordering); |
272 ASSERT(!m_needsTransformUpdate); | 269 ASSERT(!m_needsTransformUpdate); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 return false; | 320 return false; |
324 } | 321 } |
325 | 322 |
326 PositionWithAffinity LayoutSVGText::positionForPoint( | 323 PositionWithAffinity LayoutSVGText::positionForPoint( |
327 const LayoutPoint& pointInContents) { | 324 const LayoutPoint& pointInContents) { |
328 RootInlineBox* rootBox = firstRootBox(); | 325 RootInlineBox* rootBox = firstRootBox(); |
329 if (!rootBox) | 326 if (!rootBox) |
330 return createPositionWithAffinity(0); | 327 return createPositionWithAffinity(0); |
331 | 328 |
332 LayoutPoint clippedPointInContents(pointInContents); | 329 LayoutPoint clippedPointInContents(pointInContents); |
| 330 clippedPointInContents.moveBy(-rootBox->topLeft()); |
333 clippedPointInContents.clampNegativeToZero(); | 331 clippedPointInContents.clampNegativeToZero(); |
| 332 clippedPointInContents.moveBy(rootBox->topLeft()); |
334 | 333 |
335 ASSERT(!rootBox->nextRootBox()); | 334 ASSERT(!rootBox->nextRootBox()); |
336 ASSERT(childrenInline()); | 335 ASSERT(childrenInline()); |
337 | 336 |
338 InlineBox* closestBox = | 337 InlineBox* closestBox = |
339 toSVGRootInlineBox(rootBox)->closestLeafChildForPosition( | 338 toSVGRootInlineBox(rootBox)->closestLeafChildForPosition( |
340 clippedPointInContents); | 339 clippedPointInContents); |
341 if (!closestBox) | 340 if (!closestBox) |
342 return createPositionWithAffinity(0); | 341 return createPositionWithAffinity(0); |
343 | 342 |
344 return closestBox->getLineLayoutItem().positionForPoint( | 343 return closestBox->getLineLayoutItem().positionForPoint( |
345 LayoutPoint(clippedPointInContents.x(), closestBox->y())); | 344 LayoutPoint(clippedPointInContents.x(), closestBox->y())); |
346 } | 345 } |
347 | 346 |
348 void LayoutSVGText::absoluteQuads(Vector<FloatQuad>& quads) const { | 347 void LayoutSVGText::absoluteQuads(Vector<FloatQuad>& quads) const { |
349 quads.append(localToAbsoluteQuad(strokeBoundingBox())); | 348 quads.append(localToAbsoluteQuad(strokeBoundingBox())); |
350 } | 349 } |
351 | 350 |
352 void LayoutSVGText::paint(const PaintInfo& paintInfo, | 351 void LayoutSVGText::paint(const PaintInfo& paintInfo, |
353 const LayoutPoint&) const { | 352 const LayoutPoint&) const { |
354 SVGTextPainter(*this).paint(paintInfo); | 353 SVGTextPainter(*this).paint(paintInfo); |
355 } | 354 } |
356 | 355 |
| 356 FloatRect LayoutSVGText::objectBoundingBox() const { |
| 357 if (const RootInlineBox* box = firstRootBox()) |
| 358 return FloatRect(box->frameRect()); |
| 359 return FloatRect(); |
| 360 } |
| 361 |
357 FloatRect LayoutSVGText::strokeBoundingBox() const { | 362 FloatRect LayoutSVGText::strokeBoundingBox() const { |
358 FloatRect strokeBoundaries = objectBoundingBox(); | 363 FloatRect strokeBoundaries = objectBoundingBox(); |
359 const SVGComputedStyle& svgStyle = style()->svgStyle(); | 364 const SVGComputedStyle& svgStyle = style()->svgStyle(); |
360 if (!svgStyle.hasStroke()) | 365 if (!svgStyle.hasStroke()) |
361 return strokeBoundaries; | 366 return strokeBoundaries; |
362 | 367 |
363 ASSERT(node()); | 368 ASSERT(node()); |
364 ASSERT(node()->isSVGElement()); | 369 ASSERT(node()->isSVGElement()); |
365 SVGLengthContext lengthContext(toSVGElement(node())); | 370 SVGLengthContext lengthContext(toSVGElement(node())); |
366 strokeBoundaries.inflate( | 371 strokeBoundaries.inflate( |
367 lengthContext.valueForLength(svgStyle.strokeWidth())); | 372 lengthContext.valueForLength(svgStyle.strokeWidth())); |
368 return strokeBoundaries; | 373 return strokeBoundaries; |
369 } | 374 } |
370 | 375 |
371 FloatRect LayoutSVGText::visualRectInLocalSVGCoordinates() const { | 376 FloatRect LayoutSVGText::visualRectInLocalSVGCoordinates() const { |
372 FloatRect visualRect = strokeBoundingBox(); | 377 FloatRect visualRect = strokeBoundingBox(); |
373 SVGLayoutSupport::adjustVisualRectWithResources(this, visualRect); | 378 SVGLayoutSupport::adjustVisualRectWithResources(this, visualRect); |
374 | 379 |
375 if (const ShadowList* textShadow = style()->textShadow()) | 380 if (const ShadowList* textShadow = style()->textShadow()) |
376 textShadow->adjustRectForShadow(visualRect); | 381 textShadow->adjustRectForShadow(visualRect); |
377 | 382 |
378 return visualRect; | 383 return visualRect; |
379 } | 384 } |
380 | 385 |
| 386 void LayoutSVGText::addOutlineRects(Vector<LayoutRect>& rects, |
| 387 const LayoutPoint&, |
| 388 IncludeBlockVisualOverflowOrNot) const { |
| 389 rects.append(LayoutRect(objectBoundingBox())); |
| 390 } |
| 391 |
381 bool LayoutSVGText::isObjectBoundingBoxValid() const { | 392 bool LayoutSVGText::isObjectBoundingBoxValid() const { |
382 // If we don't have any line boxes, then consider the bbox invalid. | 393 // If we don't have any line boxes, then consider the bbox invalid. |
383 return firstLineBox(); | 394 return firstLineBox(); |
384 } | 395 } |
385 | 396 |
386 void LayoutSVGText::addChild(LayoutObject* child, LayoutObject* beforeChild) { | 397 void LayoutSVGText::addChild(LayoutObject* child, LayoutObject* beforeChild) { |
387 LayoutSVGBlock::addChild(child, beforeChild); | 398 LayoutSVGBlock::addChild(child, beforeChild); |
388 | 399 |
389 SVGResourcesCache::clientWasAddedToTree(child, child->styleRef()); | 400 SVGResourcesCache::clientWasAddedToTree(child, child->styleRef()); |
390 subtreeChildWasAdded(); | 401 subtreeChildWasAdded(); |
391 } | 402 } |
392 | 403 |
393 void LayoutSVGText::removeChild(LayoutObject* child) { | 404 void LayoutSVGText::removeChild(LayoutObject* child) { |
394 SVGResourcesCache::clientWillBeRemovedFromTree(child); | 405 SVGResourcesCache::clientWillBeRemovedFromTree(child); |
395 subtreeChildWillBeRemoved(); | 406 subtreeChildWillBeRemoved(); |
396 | 407 |
397 LayoutSVGBlock::removeChild(child); | 408 LayoutSVGBlock::removeChild(child); |
398 } | 409 } |
399 | 410 |
400 void LayoutSVGText::invalidateTreeIfNeeded( | 411 void LayoutSVGText::invalidateTreeIfNeeded( |
401 const PaintInvalidationState& paintInvalidationState) { | 412 const PaintInvalidationState& paintInvalidationState) { |
402 // TODO(wangxianzhu): Verify if the inherited | 413 // TODO(wangxianzhu): Verify if the inherited |
403 // LayoutBoxModelObject::invalidateTreeIfNeeded() | 414 // LayoutBoxModelObject::invalidateTreeIfNeeded() |
404 // is applicable here. If yes, remove this overriding method. | 415 // is applicable here. If yes, remove this overriding method. |
405 LayoutObject::invalidateTreeIfNeeded(paintInvalidationState); | 416 LayoutObject::invalidateTreeIfNeeded(paintInvalidationState); |
406 } | 417 } |
407 | 418 |
408 } // namespace blink | 419 } // namespace blink |
OLD | NEW |