OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2007 David Smith (catfish.man@gmail.com) | 4 * (C) 2007 David Smith (catfish.man@gmail.com) |
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 | 209 |
210 LayoutUnit lowestFloatBottom = 0; | 210 LayoutUnit lowestFloatBottom = 0; |
211 const FloatingObjectSet& floatingObjectSet = set(); | 211 const FloatingObjectSet& floatingObjectSet = set(); |
212 FloatingObjectSetIterator end = floatingObjectSet.end(); | 212 FloatingObjectSetIterator end = floatingObjectSet.end(); |
213 if (floatType == FloatingObject::FloatLeftRight) { | 213 if (floatType == FloatingObject::FloatLeftRight) { |
214 FloatingObject* lowestFloatingObjectLeft = nullptr; | 214 FloatingObject* lowestFloatingObjectLeft = nullptr; |
215 FloatingObject* lowestFloatingObjectRight = nullptr; | 215 FloatingObject* lowestFloatingObjectRight = nullptr; |
216 LayoutUnit lowestFloatBottomLeft = 0; | 216 LayoutUnit lowestFloatBottomLeft = 0; |
217 LayoutUnit lowestFloatBottomRight = 0; | 217 LayoutUnit lowestFloatBottomRight = 0; |
218 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end
; ++it) { | 218 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end
; ++it) { |
219 FloatingObject* floatingObject = it->get(); | 219 FloatingObject& floatingObject = *it->get(); |
220 if (floatingObject->isPlaced()) { | 220 if (floatingObject.isPlaced()) { |
221 FloatingObject::Type curType = floatingObject->type(); | 221 FloatingObject::Type curType = floatingObject.type(); |
222 LayoutUnit curFloatLogicalBottom = m_layoutObject->logicalBottom
ForFloat(floatingObject); | 222 LayoutUnit curFloatLogicalBottom = m_layoutObject->logicalBottom
ForFloat(floatingObject); |
223 if (curType & FloatingObject::FloatLeft && curFloatLogicalBottom
> lowestFloatBottomLeft) { | 223 if (curType & FloatingObject::FloatLeft && curFloatLogicalBottom
> lowestFloatBottomLeft) { |
224 lowestFloatBottomLeft = curFloatLogicalBottom; | 224 lowestFloatBottomLeft = curFloatLogicalBottom; |
225 lowestFloatingObjectLeft = floatingObject; | 225 lowestFloatingObjectLeft = &floatingObject; |
226 } | 226 } |
227 if (curType & FloatingObject::FloatRight && curFloatLogicalBotto
m > lowestFloatBottomRight) { | 227 if (curType & FloatingObject::FloatRight && curFloatLogicalBotto
m > lowestFloatBottomRight) { |
228 lowestFloatBottomRight = curFloatLogicalBottom; | 228 lowestFloatBottomRight = curFloatLogicalBottom; |
229 lowestFloatingObjectRight = floatingObject; | 229 lowestFloatingObjectRight = &floatingObject; |
230 } | 230 } |
231 } | 231 } |
232 } | 232 } |
233 lowestFloatBottom = std::max(lowestFloatBottomLeft, lowestFloatBottomRig
ht); | 233 lowestFloatBottom = std::max(lowestFloatBottomLeft, lowestFloatBottomRig
ht); |
234 setCachedLowestFloatLogicalBottom(isInHorizontalWritingMode, FloatingObj
ect::FloatLeft, lowestFloatingObjectLeft); | 234 setCachedLowestFloatLogicalBottom(isInHorizontalWritingMode, FloatingObj
ect::FloatLeft, lowestFloatingObjectLeft); |
235 setCachedLowestFloatLogicalBottom(isInHorizontalWritingMode, FloatingObj
ect::FloatRight, lowestFloatingObjectRight); | 235 setCachedLowestFloatLogicalBottom(isInHorizontalWritingMode, FloatingObj
ect::FloatRight, lowestFloatingObjectRight); |
236 } else { | 236 } else { |
237 FloatingObject* lowestFloatingObject = nullptr; | 237 FloatingObject* lowestFloatingObject = nullptr; |
238 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end
; ++it) { | 238 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end
; ++it) { |
239 FloatingObject* floatingObject = it->get(); | 239 FloatingObject& floatingObject = *it->get(); |
240 if (floatingObject->isPlaced() && floatingObject->type() == floatTyp
e) { | 240 if (floatingObject.isPlaced() && floatingObject.type() == floatType)
{ |
241 if (m_layoutObject->logicalBottomForFloat(floatingObject) > lowe
stFloatBottom) { | 241 if (m_layoutObject->logicalBottomForFloat(floatingObject) > lowe
stFloatBottom) { |
242 lowestFloatingObject = floatingObject; | 242 lowestFloatingObject = &floatingObject; |
243 lowestFloatBottom = m_layoutObject->logicalBottomForFloat(fl
oatingObject); | 243 lowestFloatBottom = m_layoutObject->logicalBottomForFloat(fl
oatingObject); |
244 } | 244 } |
245 } | 245 } |
246 } | 246 } |
247 setCachedLowestFloatLogicalBottom(isInHorizontalWritingMode, floatType,
lowestFloatingObject); | 247 setCachedLowestFloatLogicalBottom(isInHorizontalWritingMode, floatType,
lowestFloatingObject); |
248 } | 248 } |
249 | 249 |
250 return lowestFloatBottom; | 250 return lowestFloatBottom; |
251 } | 251 } |
252 | 252 |
253 bool FloatingObjects::hasLowestFloatLogicalBottomCached(bool isHorizontal, Float
ingObject::Type type) const | 253 bool FloatingObjects::hasLowestFloatLogicalBottomCached(bool isHorizontal, Float
ingObject::Type type) const |
254 { | 254 { |
255 int floatIndex = static_cast<int>(type) - 1; | 255 int floatIndex = static_cast<int>(type) - 1; |
256 ASSERT(floatIndex < static_cast<int>(sizeof(m_lowestFloatBottomCache) / size
of(FloatBottomCachedValue))); | 256 ASSERT(floatIndex < static_cast<int>(sizeof(m_lowestFloatBottomCache) / size
of(FloatBottomCachedValue))); |
257 ASSERT(floatIndex >= 0); | 257 ASSERT(floatIndex >= 0); |
258 return (m_cachedHorizontalWritingMode == isHorizontal && !m_lowestFloatBotto
mCache[floatIndex].dirty); | 258 return (m_cachedHorizontalWritingMode == isHorizontal && !m_lowestFloatBotto
mCache[floatIndex].dirty); |
259 } | 259 } |
260 | 260 |
261 LayoutUnit FloatingObjects::getCachedlowestFloatLogicalBottom(FloatingObject::Ty
pe type) const | 261 LayoutUnit FloatingObjects::getCachedlowestFloatLogicalBottom(FloatingObject::Ty
pe type) const |
262 { | 262 { |
263 int floatIndex = static_cast<int>(type) - 1; | 263 int floatIndex = static_cast<int>(type) - 1; |
264 ASSERT(floatIndex < static_cast<int>(sizeof(m_lowestFloatBottomCache) / size
of(FloatBottomCachedValue))); | 264 ASSERT(floatIndex < static_cast<int>(sizeof(m_lowestFloatBottomCache) / size
of(FloatBottomCachedValue))); |
265 ASSERT(floatIndex >= 0); | 265 ASSERT(floatIndex >= 0); |
266 if (!m_lowestFloatBottomCache[floatIndex].floatingObject) | 266 if (!m_lowestFloatBottomCache[floatIndex].floatingObject) |
267 return LayoutUnit(); | 267 return LayoutUnit(); |
268 return m_layoutObject->logicalBottomForFloat(m_lowestFloatBottomCache[floatI
ndex].floatingObject); | 268 return m_layoutObject->logicalBottomForFloat(*m_lowestFloatBottomCache[float
Index].floatingObject); |
269 } | 269 } |
270 | 270 |
271 void FloatingObjects::setCachedLowestFloatLogicalBottom(bool isHorizontal, Float
ingObject::Type type, FloatingObject* floatingObject) | 271 void FloatingObjects::setCachedLowestFloatLogicalBottom(bool isHorizontal, Float
ingObject::Type type, FloatingObject* floatingObject) |
272 { | 272 { |
273 int floatIndex = static_cast<int>(type) - 1; | 273 int floatIndex = static_cast<int>(type) - 1; |
274 ASSERT(floatIndex < static_cast<int>(sizeof(m_lowestFloatBottomCache) / size
of(FloatBottomCachedValue))); | 274 ASSERT(floatIndex < static_cast<int>(sizeof(m_lowestFloatBottomCache) / size
of(FloatBottomCachedValue))); |
275 ASSERT(floatIndex >= 0); | 275 ASSERT(floatIndex >= 0); |
276 m_cachedHorizontalWritingMode = isHorizontal; | 276 m_cachedHorizontalWritingMode = isHorizontal; |
277 m_lowestFloatBottomCache[floatIndex].floatingObject = floatingObject; | 277 m_lowestFloatBottomCache[floatIndex].floatingObject = floatingObject; |
278 m_lowestFloatBottomCache[floatIndex].dirty = false; | 278 m_lowestFloatBottomCache[floatIndex].dirty = false; |
279 } | 279 } |
280 | 280 |
281 FloatingObject* FloatingObjects::lowestFloatingObject() const | 281 FloatingObject* FloatingObjects::lowestFloatingObject() const |
282 { | 282 { |
283 bool isInHorizontalWritingMode = m_horizontalWritingMode; | 283 bool isInHorizontalWritingMode = m_horizontalWritingMode; |
284 if (!hasLowestFloatLogicalBottomCached(isInHorizontalWritingMode, FloatingOb
ject::FloatLeft) && !hasLowestFloatLogicalBottomCached(isInHorizontalWritingMode
, FloatingObject::FloatRight)) | 284 if (!hasLowestFloatLogicalBottomCached(isInHorizontalWritingMode, FloatingOb
ject::FloatLeft) && !hasLowestFloatLogicalBottomCached(isInHorizontalWritingMode
, FloatingObject::FloatRight)) |
285 return nullptr; | 285 return nullptr; |
286 FloatingObject* lowestLeftObject = m_lowestFloatBottomCache[0].floatingObjec
t; | 286 FloatingObject* lowestLeftObject = m_lowestFloatBottomCache[0].floatingObjec
t; |
287 FloatingObject* lowestRightObject = m_lowestFloatBottomCache[1].floatingObje
ct; | 287 FloatingObject* lowestRightObject = m_lowestFloatBottomCache[1].floatingObje
ct; |
288 LayoutUnit lowestFloatBottomLeft = lowestLeftObject ? m_layoutObject->logica
lBottomForFloat(lowestLeftObject) : LayoutUnit(); | 288 LayoutUnit lowestFloatBottomLeft = lowestLeftObject ? m_layoutObject->logica
lBottomForFloat(*lowestLeftObject) : LayoutUnit(); |
289 LayoutUnit lowestFloatBottomRight = lowestRightObject ? m_layoutObject->logi
calBottomForFloat(lowestRightObject) : LayoutUnit(); | 289 LayoutUnit lowestFloatBottomRight = lowestRightObject ? m_layoutObject->logi
calBottomForFloat(*lowestRightObject) : LayoutUnit(); |
290 | 290 |
291 if (lowestFloatBottomLeft > lowestFloatBottomRight) | 291 if (lowestFloatBottomLeft > lowestFloatBottomRight) |
292 return lowestLeftObject; | 292 return lowestLeftObject; |
293 return lowestRightObject; | 293 return lowestRightObject; |
294 } | 294 } |
295 | 295 |
296 void FloatingObjects::markLowestFloatLogicalBottomCacheAsDirty() | 296 void FloatingObjects::markLowestFloatLogicalBottomCacheAsDirty() |
297 { | 297 { |
298 for (size_t i = 0; i < sizeof(m_lowestFloatBottomCache) / sizeof(FloatBottom
CachedValue); ++i) | 298 for (size_t i = 0; i < sizeof(m_lowestFloatBottomCache) / sizeof(FloatBottom
CachedValue); ++i) |
299 m_lowestFloatBottomCache[i].dirty = true; | 299 m_lowestFloatBottomCache[i].dirty = true; |
(...skipping 18 matching lines...) Expand all Loading... |
318 } | 318 } |
319 | 319 |
320 inline void FloatingObjects::decreaseObjectsCount(FloatingObject::Type type) | 320 inline void FloatingObjects::decreaseObjectsCount(FloatingObject::Type type) |
321 { | 321 { |
322 if (type == FloatingObject::FloatLeft) | 322 if (type == FloatingObject::FloatLeft) |
323 m_leftObjectsCount--; | 323 m_leftObjectsCount--; |
324 else | 324 else |
325 m_rightObjectsCount--; | 325 m_rightObjectsCount--; |
326 } | 326 } |
327 | 327 |
328 inline FloatingObjectInterval FloatingObjects::intervalForFloatingObject(Floatin
gObject* floatingObject) | 328 inline FloatingObjectInterval FloatingObjects::intervalForFloatingObject(Floatin
gObject& floatingObject) |
329 { | 329 { |
330 if (m_horizontalWritingMode) | 330 if (m_horizontalWritingMode) |
331 return FloatingObjectInterval(floatingObject->frameRect().pixelSnappedY(
), floatingObject->frameRect().pixelSnappedMaxY(), floatingObject); | 331 return FloatingObjectInterval(floatingObject.frameRect().pixelSnappedY()
, floatingObject.frameRect().pixelSnappedMaxY(), &floatingObject); |
332 return FloatingObjectInterval(floatingObject->frameRect().pixelSnappedX(), f
loatingObject->frameRect().pixelSnappedMaxX(), floatingObject); | 332 return FloatingObjectInterval(floatingObject.frameRect().pixelSnappedX(), fl
oatingObject.frameRect().pixelSnappedMaxX(), &floatingObject); |
333 } | 333 } |
334 | 334 |
335 void FloatingObjects::addPlacedObject(FloatingObject* floatingObject) | 335 void FloatingObjects::addPlacedObject(FloatingObject& floatingObject) |
336 { | 336 { |
337 ASSERT(!floatingObject->isInPlacedTree()); | 337 ASSERT(!floatingObject.isInPlacedTree()); |
338 | 338 |
339 floatingObject->setIsPlaced(true); | 339 floatingObject.setIsPlaced(true); |
340 if (m_placedFloatsTree.isInitialized()) | 340 if (m_placedFloatsTree.isInitialized()) |
341 m_placedFloatsTree.add(intervalForFloatingObject(floatingObject)); | 341 m_placedFloatsTree.add(intervalForFloatingObject(floatingObject)); |
342 | 342 |
343 #if ENABLE(ASSERT) | 343 #if ENABLE(ASSERT) |
344 floatingObject->setIsInPlacedTree(true); | 344 floatingObject.setIsInPlacedTree(true); |
345 #endif | 345 #endif |
346 markLowestFloatLogicalBottomCacheAsDirty(); | 346 markLowestFloatLogicalBottomCacheAsDirty(); |
347 } | 347 } |
348 | 348 |
349 void FloatingObjects::removePlacedObject(FloatingObject* floatingObject) | 349 void FloatingObjects::removePlacedObject(FloatingObject& floatingObject) |
350 { | 350 { |
351 ASSERT(floatingObject->isPlaced() && floatingObject->isInPlacedTree()); | 351 ASSERT(floatingObject.isPlaced() && floatingObject.isInPlacedTree()); |
352 | 352 |
353 if (m_placedFloatsTree.isInitialized()) { | 353 if (m_placedFloatsTree.isInitialized()) { |
354 bool removed = m_placedFloatsTree.remove(intervalForFloatingObject(float
ingObject)); | 354 bool removed = m_placedFloatsTree.remove(intervalForFloatingObject(float
ingObject)); |
355 ASSERT_UNUSED(removed, removed); | 355 ASSERT_UNUSED(removed, removed); |
356 } | 356 } |
357 | 357 |
358 floatingObject->setIsPlaced(false); | 358 floatingObject.setIsPlaced(false); |
359 #if ENABLE(ASSERT) | 359 #if ENABLE(ASSERT) |
360 floatingObject->setIsInPlacedTree(false); | 360 floatingObject.setIsInPlacedTree(false); |
361 #endif | 361 #endif |
362 markLowestFloatLogicalBottomCacheAsDirty(); | 362 markLowestFloatLogicalBottomCacheAsDirty(); |
363 } | 363 } |
364 | 364 |
365 FloatingObject* FloatingObjects::add(PassOwnPtr<FloatingObject> floatingObject) | 365 FloatingObject* FloatingObjects::add(PassOwnPtr<FloatingObject> floatingObject) |
366 { | 366 { |
367 FloatingObject* newObject = floatingObject.leakPtr(); | 367 FloatingObject* newObject = floatingObject.leakPtr(); |
368 increaseObjectsCount(newObject->type()); | 368 increaseObjectsCount(newObject->type()); |
369 m_set.add(adoptPtr(newObject)); | 369 m_set.add(adoptPtr(newObject)); |
370 if (newObject->isPlaced()) | 370 if (newObject->isPlaced()) |
371 addPlacedObject(newObject); | 371 addPlacedObject(*newObject); |
372 markLowestFloatLogicalBottomCacheAsDirty(); | 372 markLowestFloatLogicalBottomCacheAsDirty(); |
373 return newObject; | 373 return newObject; |
374 } | 374 } |
375 | 375 |
376 void FloatingObjects::remove(FloatingObject* toBeRemoved) | 376 void FloatingObjects::remove(FloatingObject* toBeRemoved) |
377 { | 377 { |
378 decreaseObjectsCount(toBeRemoved->type()); | 378 decreaseObjectsCount(toBeRemoved->type()); |
379 OwnPtr<FloatingObject> floatingObject = m_set.take(toBeRemoved); | 379 OwnPtr<FloatingObject> floatingObject = m_set.take(toBeRemoved); |
380 ASSERT(floatingObject->isPlaced() || !floatingObject->isInPlacedTree()); | 380 ASSERT(floatingObject->isPlaced() || !floatingObject->isInPlacedTree()); |
381 if (floatingObject->isPlaced()) | 381 if (floatingObject->isPlaced()) |
382 removePlacedObject(floatingObject.get()); | 382 removePlacedObject(*floatingObject); |
383 markLowestFloatLogicalBottomCacheAsDirty(); | 383 markLowestFloatLogicalBottomCacheAsDirty(); |
384 ASSERT(!floatingObject->originatingLine()); | 384 ASSERT(!floatingObject->originatingLine()); |
385 } | 385 } |
386 | 386 |
387 void FloatingObjects::computePlacedFloatsTree() | 387 void FloatingObjects::computePlacedFloatsTree() |
388 { | 388 { |
389 ASSERT(!m_placedFloatsTree.isInitialized()); | 389 ASSERT(!m_placedFloatsTree.isInitialized()); |
390 if (m_set.isEmpty()) | 390 if (m_set.isEmpty()) |
391 return; | 391 return; |
392 m_placedFloatsTree.initIfNeeded(m_layoutObject->view()->intervalArena()); | 392 m_placedFloatsTree.initIfNeeded(m_layoutObject->view()->intervalArena()); |
393 FloatingObjectSetIterator it = m_set.begin(); | 393 FloatingObjectSetIterator it = m_set.begin(); |
394 FloatingObjectSetIterator end = m_set.end(); | 394 FloatingObjectSetIterator end = m_set.end(); |
395 for (; it != end; ++it) { | 395 for (; it != end; ++it) { |
396 FloatingObject* floatingObject = it->get(); | 396 FloatingObject& floatingObject = *it->get(); |
397 if (floatingObject->isPlaced()) | 397 if (floatingObject.isPlaced()) |
398 m_placedFloatsTree.add(intervalForFloatingObject(floatingObject)); | 398 m_placedFloatsTree.add(intervalForFloatingObject(floatingObject)); |
399 } | 399 } |
400 } | 400 } |
401 | 401 |
402 LayoutUnit FloatingObjects::logicalLeftOffsetForPositioningFloat(LayoutUnit fixe
dOffset, LayoutUnit logicalTop, LayoutUnit *heightRemaining) | 402 LayoutUnit FloatingObjects::logicalLeftOffsetForPositioningFloat(LayoutUnit fixe
dOffset, LayoutUnit logicalTop, LayoutUnit *heightRemaining) |
403 { | 403 { |
404 int logicalTopAsInt = roundToInt(logicalTop); | 404 int logicalTopAsInt = roundToInt(logicalTop); |
405 ComputeFloatOffsetForFloatLayoutAdapter<FloatingObject::FloatLeft> adapter(m
_layoutObject, logicalTopAsInt, logicalTopAsInt, fixedOffset); | 405 ComputeFloatOffsetForFloatLayoutAdapter<FloatingObject::FloatLeft> adapter(m
_layoutObject, logicalTopAsInt, logicalTopAsInt, fixedOffset); |
406 placedFloatsTree().allOverlapsWithAdapter(adapter); | 406 placedFloatsTree().allOverlapsWithAdapter(adapter); |
407 | 407 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 // The bottom of the object overlaps the float | 461 // The bottom of the object overlaps the float |
462 if (objectBottom > objectTop && objectBottom > floatTop && objectBottom <= f
loatBottom) | 462 if (objectBottom > objectTop && objectBottom > floatTop && objectBottom <= f
loatBottom) |
463 return true; | 463 return true; |
464 | 464 |
465 return false; | 465 return false; |
466 } | 466 } |
467 | 467 |
468 template<> | 468 template<> |
469 inline bool ComputeFloatOffsetForFloatLayoutAdapter<FloatingObject::FloatLeft>::
updateOffsetIfNeeded(const FloatingObject& floatingObject) | 469 inline bool ComputeFloatOffsetForFloatLayoutAdapter<FloatingObject::FloatLeft>::
updateOffsetIfNeeded(const FloatingObject& floatingObject) |
470 { | 470 { |
471 LayoutUnit logicalRight = m_layoutObject->logicalRightForFloat(&floatingObje
ct); | 471 LayoutUnit logicalRight = m_layoutObject->logicalRightForFloat(floatingObjec
t); |
472 if (logicalRight > m_offset) { | 472 if (logicalRight > m_offset) { |
473 m_offset = logicalRight; | 473 m_offset = logicalRight; |
474 return true; | 474 return true; |
475 } | 475 } |
476 return false; | 476 return false; |
477 } | 477 } |
478 | 478 |
479 template<> | 479 template<> |
480 inline bool ComputeFloatOffsetForFloatLayoutAdapter<FloatingObject::FloatRight>:
:updateOffsetIfNeeded(const FloatingObject& floatingObject) | 480 inline bool ComputeFloatOffsetForFloatLayoutAdapter<FloatingObject::FloatRight>:
:updateOffsetIfNeeded(const FloatingObject& floatingObject) |
481 { | 481 { |
482 LayoutUnit logicalLeft = m_layoutObject->logicalLeftForFloat(&floatingObject
); | 482 LayoutUnit logicalLeft = m_layoutObject->logicalLeftForFloat(floatingObject)
; |
483 if (logicalLeft < m_offset) { | 483 if (logicalLeft < m_offset) { |
484 m_offset = logicalLeft; | 484 m_offset = logicalLeft; |
485 return true; | 485 return true; |
486 } | 486 } |
487 return false; | 487 return false; |
488 } | 488 } |
489 | 489 |
490 template <FloatingObject::Type FloatTypeValue> | 490 template <FloatingObject::Type FloatTypeValue> |
491 LayoutUnit ComputeFloatOffsetForFloatLayoutAdapter<FloatTypeValue>::heightRemain
ing() const | 491 LayoutUnit ComputeFloatOffsetForFloatLayoutAdapter<FloatTypeValue>::heightRemain
ing() const |
492 { | 492 { |
493 return this->m_outermostFloat ? this->m_layoutObject->logicalBottomForFloat(
this->m_outermostFloat) - this->m_lineTop : LayoutUnit(1); | 493 return this->m_outermostFloat ? this->m_layoutObject->logicalBottomForFloat(
*this->m_outermostFloat) - this->m_lineTop : LayoutUnit(1); |
494 } | 494 } |
495 | 495 |
496 template <FloatingObject::Type FloatTypeValue> | 496 template <FloatingObject::Type FloatTypeValue> |
497 inline void ComputeFloatOffsetAdapter<FloatTypeValue>::collectIfNeeded(const Int
ervalType& interval) | 497 inline void ComputeFloatOffsetAdapter<FloatTypeValue>::collectIfNeeded(const Int
ervalType& interval) |
498 { | 498 { |
499 const FloatingObject* floatingObject = interval.data(); | 499 const FloatingObject& floatingObject = *(interval.data()); |
500 if (floatingObject->type() != FloatTypeValue || !rangesIntersect(interval.lo
w(), interval.high(), m_lineTop, m_lineBottom)) | 500 if (floatingObject.type() != FloatTypeValue || !rangesIntersect(interval.low
(), interval.high(), m_lineTop, m_lineBottom)) |
501 return; | 501 return; |
502 | 502 |
503 // Make sure the float hasn't changed since it was added to the placed float
s tree. | 503 // Make sure the float hasn't changed since it was added to the placed float
s tree. |
504 ASSERT(floatingObject->isPlaced()); | 504 ASSERT(floatingObject.isPlaced()); |
505 ASSERT(interval.low() == m_layoutObject->pixelSnappedLogicalTopForFloat(floa
tingObject)); | 505 ASSERT(interval.low() == m_layoutObject->pixelSnappedLogicalTopForFloat(floa
tingObject)); |
506 ASSERT(interval.high() == m_layoutObject->pixelSnappedLogicalBottomForFloat(
floatingObject)); | 506 ASSERT(interval.high() == m_layoutObject->pixelSnappedLogicalBottomForFloat(
floatingObject)); |
507 | 507 |
508 bool floatIsNewExtreme = updateOffsetIfNeeded(*floatingObject); | 508 bool floatIsNewExtreme = updateOffsetIfNeeded(floatingObject); |
509 if (floatIsNewExtreme) | 509 if (floatIsNewExtreme) |
510 m_outermostFloat = floatingObject; | 510 m_outermostFloat = &floatingObject; |
511 } | 511 } |
512 | 512 |
513 template<> | 513 template<> |
514 inline bool ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatLeft>::u
pdateOffsetIfNeeded(const FloatingObject& floatingObject) | 514 inline bool ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatLeft>::u
pdateOffsetIfNeeded(const FloatingObject& floatingObject) |
515 { | 515 { |
516 LayoutUnit logicalRight = m_layoutObject->logicalRightForFloat(&floatingObje
ct); | 516 LayoutUnit logicalRight = m_layoutObject->logicalRightForFloat(floatingObjec
t); |
517 if (ShapeOutsideInfo* shapeOutside = floatingObject.layoutObject()->shapeOut
sideInfo()) { | 517 if (ShapeOutsideInfo* shapeOutside = floatingObject.layoutObject()->shapeOut
sideInfo()) { |
518 ShapeOutsideDeltas shapeDeltas = shapeOutside->computeDeltasForContainin
gBlockLine(*m_layoutObject, floatingObject, m_lineTop, m_lineBottom - m_lineTop)
; | 518 ShapeOutsideDeltas shapeDeltas = shapeOutside->computeDeltasForContainin
gBlockLine(*m_layoutObject, floatingObject, m_lineTop, m_lineBottom - m_lineTop)
; |
519 if (!shapeDeltas.lineOverlapsShape()) | 519 if (!shapeDeltas.lineOverlapsShape()) |
520 return false; | 520 return false; |
521 | 521 |
522 logicalRight += shapeDeltas.rightMarginBoxDelta(); | 522 logicalRight += shapeDeltas.rightMarginBoxDelta(); |
523 } | 523 } |
524 if (logicalRight > m_offset) { | 524 if (logicalRight > m_offset) { |
525 m_offset = logicalRight; | 525 m_offset = logicalRight; |
526 return true; | 526 return true; |
527 } | 527 } |
528 | 528 |
529 return false; | 529 return false; |
530 } | 530 } |
531 | 531 |
532 template<> | 532 template<> |
533 inline bool ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatRight>::
updateOffsetIfNeeded(const FloatingObject& floatingObject) | 533 inline bool ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatRight>::
updateOffsetIfNeeded(const FloatingObject& floatingObject) |
534 { | 534 { |
535 LayoutUnit logicalLeft = m_layoutObject->logicalLeftForFloat(&floatingObject
); | 535 LayoutUnit logicalLeft = m_layoutObject->logicalLeftForFloat(floatingObject)
; |
536 if (ShapeOutsideInfo* shapeOutside = floatingObject.layoutObject()->shapeOut
sideInfo()) { | 536 if (ShapeOutsideInfo* shapeOutside = floatingObject.layoutObject()->shapeOut
sideInfo()) { |
537 ShapeOutsideDeltas shapeDeltas = shapeOutside->computeDeltasForContainin
gBlockLine(*m_layoutObject, floatingObject, m_lineTop, m_lineBottom - m_lineTop)
; | 537 ShapeOutsideDeltas shapeDeltas = shapeOutside->computeDeltasForContainin
gBlockLine(*m_layoutObject, floatingObject, m_lineTop, m_lineBottom - m_lineTop)
; |
538 if (!shapeDeltas.lineOverlapsShape()) | 538 if (!shapeDeltas.lineOverlapsShape()) |
539 return false; | 539 return false; |
540 | 540 |
541 logicalLeft += shapeDeltas.leftMarginBoxDelta(); | 541 logicalLeft += shapeDeltas.leftMarginBoxDelta(); |
542 } | 542 } |
543 if (logicalLeft < m_offset) { | 543 if (logicalLeft < m_offset) { |
544 m_offset = logicalLeft; | 544 m_offset = logicalLeft; |
545 return true; | 545 return true; |
(...skipping 10 matching lines...) Expand all Loading... |
556 } | 556 } |
557 | 557 |
558 String ValueToString<FloatingObject*>::string(const FloatingObject* floatingObje
ct) | 558 String ValueToString<FloatingObject*>::string(const FloatingObject* floatingObje
ct) |
559 { | 559 { |
560 return String::format("%p (%dx%d %dx%d)", floatingObject, floatingObject->fr
ameRect().pixelSnappedX(), floatingObject->frameRect().pixelSnappedY(), floating
Object->frameRect().pixelSnappedMaxX(), floatingObject->frameRect().pixelSnapped
MaxY()); | 560 return String::format("%p (%dx%d %dx%d)", floatingObject, floatingObject->fr
ameRect().pixelSnappedX(), floatingObject->frameRect().pixelSnappedY(), floating
Object->frameRect().pixelSnappedMaxX(), floatingObject->frameRect().pixelSnapped
MaxY()); |
561 } | 561 } |
562 #endif | 562 #endif |
563 | 563 |
564 | 564 |
565 } // namespace blink | 565 } // namespace blink |
OLD | NEW |