| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
| 9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
| 10 * disclaimer. | 10 * disclaimer. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 RenderFlowThread::RenderFlowThread() | 48 RenderFlowThread::RenderFlowThread() |
| 49 : RenderBlockFlow(0) | 49 : RenderBlockFlow(0) |
| 50 , m_regionsInvalidated(false) | 50 , m_regionsInvalidated(false) |
| 51 , m_regionsHaveUniformLogicalHeight(true) | 51 , m_regionsHaveUniformLogicalHeight(true) |
| 52 , m_pageLogicalSizeChanged(false) | 52 , m_pageLogicalSizeChanged(false) |
| 53 { | 53 { |
| 54 setFlowThreadState(InsideOutOfFlowThread); | 54 setFlowThreadState(InsideOutOfFlowThread); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void RenderFlowThread::addRegionToThread(RenderRegion* renderRegion) | |
| 58 { | |
| 59 ASSERT(renderRegion); | |
| 60 m_regionList.add(renderRegion); | |
| 61 renderRegion->setIsValid(true); | |
| 62 } | |
| 63 | |
| 64 void RenderFlowThread::removeRegionFromThread(RenderRegion* renderRegion) | 57 void RenderFlowThread::removeRegionFromThread(RenderRegion* renderRegion) |
| 65 { | 58 { |
| 66 ASSERT(renderRegion); | 59 ASSERT(renderRegion); |
| 67 m_regionList.remove(renderRegion); | 60 m_regionList.remove(renderRegion); |
| 68 } | 61 } |
| 69 | 62 |
| 70 void RenderFlowThread::invalidateRegions() | 63 void RenderFlowThread::invalidateRegions() |
| 71 { | 64 { |
| 72 if (m_regionsInvalidated) { | 65 if (m_regionsInvalidated) { |
| 73 ASSERT(selfNeedsLayout()); | 66 ASSERT(selfNeedsLayout()); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 // Let each region figure out the proper enclosing flow thread. | 181 // Let each region figure out the proper enclosing flow thread. |
| 189 CurrentRenderFlowThreadDisabler disabler(view()); | 182 CurrentRenderFlowThreadDisabler disabler(view()); |
| 190 | 183 |
| 191 for (RenderRegionList::const_iterator iter = m_regionList.begin(); iter != m
_regionList.end(); ++iter) { | 184 for (RenderRegionList::const_iterator iter = m_regionList.begin(); iter != m
_regionList.end(); ++iter) { |
| 192 RenderRegion* region = *iter; | 185 RenderRegion* region = *iter; |
| 193 | 186 |
| 194 region->repaintFlowThreadContent(repaintRect); | 187 region->repaintFlowThreadContent(repaintRect); |
| 195 } | 188 } |
| 196 } | 189 } |
| 197 | 190 |
| 198 RenderRegion* RenderFlowThread::regionAtBlockOffset(LayoutUnit offset, bool exte
ndLastRegion, RegionAutoGenerationPolicy autoGenerationPolicy) | 191 RenderRegion* RenderFlowThread::regionAtBlockOffset(LayoutUnit offset) const |
| 199 { | 192 { |
| 200 ASSERT(!m_regionsInvalidated); | 193 ASSERT(!m_regionsInvalidated); |
| 201 | 194 |
| 202 if (autoGenerationPolicy == AllowRegionAutoGeneration) | |
| 203 autoGenerateRegionsToBlockOffset(offset); | |
| 204 | |
| 205 if (offset <= 0) | 195 if (offset <= 0) |
| 206 return m_regionList.isEmpty() ? 0 : m_regionList.first(); | 196 return m_regionList.isEmpty() ? 0 : m_regionList.first(); |
| 207 | 197 |
| 208 RegionSearchAdapter adapter(offset); | 198 RegionSearchAdapter adapter(offset); |
| 209 m_regionIntervalTree.allOverlapsWithAdapter<RegionSearchAdapter>(adapter); | 199 m_regionIntervalTree.allOverlapsWithAdapter<RegionSearchAdapter>(adapter); |
| 210 | 200 |
| 211 // If no region was found, the offset is in the flow thread overflow. | 201 // If no region was found, the offset is in the flow thread overflow. |
| 212 // The last region will contain the offset if extendLastRegion is set or if
the last region is a set. | |
| 213 if (!adapter.result() && !m_regionList.isEmpty()) | 202 if (!adapter.result() && !m_regionList.isEmpty()) |
| 214 return m_regionList.last(); | 203 return m_regionList.last(); |
| 215 | 204 |
| 216 return adapter.result(); | 205 return adapter.result(); |
| 217 } | 206 } |
| 218 | 207 |
| 219 LayoutPoint RenderFlowThread::adjustedPositionRelativeToOffsetParent(const Rende
rBoxModelObject& boxModelObject, const LayoutPoint& startPoint) | 208 LayoutPoint RenderFlowThread::adjustedPositionRelativeToOffsetParent(const Rende
rBoxModelObject& boxModelObject, const LayoutPoint& startPoint) |
| 220 { | 209 { |
| 221 LayoutPoint referencePoint = startPoint; | 210 LayoutPoint referencePoint = startPoint; |
| 222 | 211 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 return 0; | 321 return 0; |
| 333 | 322 |
| 334 LayoutRect boxRect = transformState.mappedQuad().enclosingBoundingBox(); | 323 LayoutRect boxRect = transformState.mappedQuad().enclosingBoundingBox(); |
| 335 flipForWritingMode(boxRect); | 324 flipForWritingMode(boxRect); |
| 336 | 325 |
| 337 // FIXME: We need to refactor RenderObject::absoluteQuads to be able to spli
t the quads across regions, | 326 // FIXME: We need to refactor RenderObject::absoluteQuads to be able to spli
t the quads across regions, |
| 338 // for now we just take the center of the mapped enclosing box and map it to
a region. | 327 // for now we just take the center of the mapped enclosing box and map it to
a region. |
| 339 // Note: Using the center in order to avoid rounding errors. | 328 // Note: Using the center in order to avoid rounding errors. |
| 340 | 329 |
| 341 LayoutPoint center = boxRect.center(); | 330 LayoutPoint center = boxRect.center(); |
| 342 RenderRegion* renderRegion = const_cast<RenderFlowThread*>(this)->regionAtBl
ockOffset(isHorizontalWritingMode() ? center.y() : center.x(), true, DisallowReg
ionAutoGeneration); | 331 RenderRegion* renderRegion = regionAtBlockOffset(isHorizontalWritingMode() ?
center.y() : center.x()); |
| 343 if (!renderRegion) | 332 if (!renderRegion) |
| 344 return 0; | 333 return 0; |
| 345 | 334 |
| 346 LayoutRect flippedRegionRect(renderRegion->flowThreadPortionRect()); | 335 LayoutRect flippedRegionRect(renderRegion->flowThreadPortionRect()); |
| 347 flipForWritingMode(flippedRegionRect); | 336 flipForWritingMode(flippedRegionRect); |
| 348 | 337 |
| 349 transformState.move(renderRegion->contentBoxRect().location() - flippedRegio
nRect.location()); | 338 transformState.move(renderRegion->contentBoxRect().location() - flippedRegio
nRect.location()); |
| 350 | 339 |
| 351 return renderRegion; | 340 return renderRegion; |
| 352 } | 341 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 364 return 0; | 353 return 0; |
| 365 return m_regionList.last(); | 354 return m_regionList.last(); |
| 366 } | 355 } |
| 367 | 356 |
| 368 void RenderFlowThread::setRegionRangeForBox(const RenderBox* box, LayoutUnit off
setFromLogicalTopOfFirstPage) | 357 void RenderFlowThread::setRegionRangeForBox(const RenderBox* box, LayoutUnit off
setFromLogicalTopOfFirstPage) |
| 369 { | 358 { |
| 370 if (!hasRegions()) | 359 if (!hasRegions()) |
| 371 return; | 360 return; |
| 372 | 361 |
| 373 // FIXME: Not right for differing writing-modes. | 362 // FIXME: Not right for differing writing-modes. |
| 374 RenderRegion* startRegion = regionAtBlockOffset(offsetFromLogicalTopOfFirstP
age, true); | 363 RenderRegion* startRegion = regionAtBlockOffset(offsetFromLogicalTopOfFirstP
age); |
| 375 RenderRegion* endRegion = regionAtBlockOffset(offsetFromLogicalTopOfFirstPag
e + box->logicalHeight(), true); | 364 RenderRegion* endRegion = regionAtBlockOffset(offsetFromLogicalTopOfFirstPag
e + box->logicalHeight()); |
| 376 RenderRegionRangeMap::iterator it = m_regionRangeMap.find(box); | 365 RenderRegionRangeMap::iterator it = m_regionRangeMap.find(box); |
| 377 if (it == m_regionRangeMap.end()) { | 366 if (it == m_regionRangeMap.end()) { |
| 378 m_regionRangeMap.set(box, RenderRegionRange(startRegion, endRegion)); | 367 m_regionRangeMap.set(box, RenderRegionRange(startRegion, endRegion)); |
| 379 return; | 368 return; |
| 380 } | 369 } |
| 381 | 370 |
| 382 // If nothing changed, just bail. | 371 // If nothing changed, just bail. |
| 383 RenderRegionRange& range = it->value; | 372 RenderRegionRange& range = it->value; |
| 384 if (range.startRegion() == startRegion && range.endRegion() == endRegion) | 373 if (range.startRegion() == startRegion && range.endRegion() == endRegion) |
| 385 return; | 374 return; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 } | 559 } |
| 571 | 560 |
| 572 void RenderFlowThread::mapLocalToContainer(const RenderLayerModelObject* repaint
Container, TransformState& transformState, MapCoordinatesFlags mode, bool* wasFi
xed) const | 561 void RenderFlowThread::mapLocalToContainer(const RenderLayerModelObject* repaint
Container, TransformState& transformState, MapCoordinatesFlags mode, bool* wasFi
xed) const |
| 573 { | 562 { |
| 574 if (this == repaintContainer) | 563 if (this == repaintContainer) |
| 575 return; | 564 return; |
| 576 | 565 |
| 577 if (RenderRegion* region = mapFromFlowToRegion(transformState)) { | 566 if (RenderRegion* region = mapFromFlowToRegion(transformState)) { |
| 578 // FIXME: The cast below is probably not the best solution, we may need
to find a better way. | 567 // FIXME: The cast below is probably not the best solution, we may need
to find a better way. |
| 579 static_cast<const RenderObject*>(region)->mapLocalToContainer(region->co
ntainerForRepaint(), transformState, mode, wasFixed); | 568 static_cast<const RenderObject*>(region)->mapLocalToContainer(region->co
ntainerForRepaint(), transformState, mode, wasFixed); |
| 569 } else { |
| 570 // This will happen for multicol when the flow thread is empty. |
| 571 RenderBlockFlow::mapLocalToContainer(repaintContainer, transformState, m
ode, wasFixed); |
| 580 } | 572 } |
| 581 } | 573 } |
| 582 | 574 |
| 583 CurrentRenderFlowThreadMaintainer::CurrentRenderFlowThreadMaintainer(RenderFlowT
hread* renderFlowThread) | 575 CurrentRenderFlowThreadMaintainer::CurrentRenderFlowThreadMaintainer(RenderFlowT
hread* renderFlowThread) |
| 584 : m_renderFlowThread(renderFlowThread) | 576 : m_renderFlowThread(renderFlowThread) |
| 585 , m_previousRenderFlowThread(0) | 577 , m_previousRenderFlowThread(0) |
| 586 { | 578 { |
| 587 if (!m_renderFlowThread) | 579 if (!m_renderFlowThread) |
| 588 return; | 580 return; |
| 589 RenderView* view = m_renderFlowThread->view(); | 581 RenderView* view = m_renderFlowThread->view(); |
| 590 m_previousRenderFlowThread = view->flowThreadController()->currentRenderFlow
Thread(); | 582 m_previousRenderFlowThread = view->flowThreadController()->currentRenderFlow
Thread(); |
| 591 view->flowThreadController()->setCurrentRenderFlowThread(m_renderFlowThread)
; | 583 view->flowThreadController()->setCurrentRenderFlowThread(m_renderFlowThread)
; |
| 592 } | 584 } |
| 593 | 585 |
| 594 CurrentRenderFlowThreadMaintainer::~CurrentRenderFlowThreadMaintainer() | 586 CurrentRenderFlowThreadMaintainer::~CurrentRenderFlowThreadMaintainer() |
| 595 { | 587 { |
| 596 if (!m_renderFlowThread) | 588 if (!m_renderFlowThread) |
| 597 return; | 589 return; |
| 598 RenderView* view = m_renderFlowThread->view(); | 590 RenderView* view = m_renderFlowThread->view(); |
| 599 ASSERT(view->flowThreadController()->currentRenderFlowThread() == m_renderFl
owThread); | 591 ASSERT(view->flowThreadController()->currentRenderFlowThread() == m_renderFl
owThread); |
| 600 view->flowThreadController()->setCurrentRenderFlowThread(m_previousRenderFlo
wThread); | 592 view->flowThreadController()->setCurrentRenderFlowThread(m_previousRenderFlo
wThread); |
| 601 } | 593 } |
| 602 | 594 |
| 603 | 595 |
| 604 } // namespace WebCore | 596 } // namespace WebCore |
| OLD | NEW |