OLD | NEW |
1 /** | 1 /** |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 2000 Simon Hausmann <hausmann@kde.org> | 3 * (C) 2000 Simon Hausmann <hausmann@kde.org> |
4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de) | 4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de) |
5 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. | 5 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 | 464 |
465 if (m_rows.m_sizes.size() != rows || m_cols.m_sizes.size() != cols) { | 465 if (m_rows.m_sizes.size() != rows || m_cols.m_sizes.size() != cols) { |
466 m_rows.resize(rows); | 466 m_rows.resize(rows); |
467 m_cols.resize(cols); | 467 m_cols.resize(cols); |
468 } | 468 } |
469 | 469 |
470 LayoutUnit borderThickness = frameSet()->border(); | 470 LayoutUnit borderThickness = frameSet()->border(); |
471 layOutAxis(m_rows, frameSet()->rowLengths(), height() - (rows - 1) * borderT
hickness); | 471 layOutAxis(m_rows, frameSet()->rowLengths(), height() - (rows - 1) * borderT
hickness); |
472 layOutAxis(m_cols, frameSet()->colLengths(), width() - (cols - 1) * borderTh
ickness); | 472 layOutAxis(m_cols, frameSet()->colLengths(), width() - (cols - 1) * borderTh
ickness); |
473 | 473 |
474 if (flattenFrameSet()) | 474 positionFrames(); |
475 positionFramesWithFlattening(); | |
476 else | |
477 positionFrames(); | |
478 | 475 |
479 RenderBox::layout(); | 476 RenderBox::layout(); |
480 | 477 |
481 computeEdgeInfo(); | 478 computeEdgeInfo(); |
482 | 479 |
483 updateLayerTransform(); | 480 updateLayerTransform(); |
484 | 481 |
485 if (doFullRepaint) { | 482 if (doFullRepaint) { |
486 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(oldBounds)); | 483 repaintUsingContainer(repaintContainer, pixelSnappedIntRect(oldBounds)); |
487 LayoutRect newBounds = clippedOverflowRectForRepaint(repaintContainer); | 484 LayoutRect newBounds = clippedOverflowRectForRepaint(repaintContainer); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 } | 525 } |
529 | 526 |
530 // all the remaining frames are hidden to avoid ugly spurious unflowed frame
s | 527 // all the remaining frames are hidden to avoid ugly spurious unflowed frame
s |
531 for (; child; child = child->nextSiblingBox()) { | 528 for (; child; child = child->nextSiblingBox()) { |
532 child->setWidth(0); | 529 child->setWidth(0); |
533 child->setHeight(0); | 530 child->setHeight(0); |
534 child->setNeedsLayout(false); | 531 child->setNeedsLayout(false); |
535 } | 532 } |
536 } | 533 } |
537 | 534 |
538 void RenderFrameSet::positionFramesWithFlattening() | |
539 { | |
540 RenderBox* child = firstChildBox(); | |
541 if (!child) | |
542 return; | |
543 | |
544 int rows = frameSet()->totalRows(); | |
545 int cols = frameSet()->totalCols(); | |
546 | |
547 int borderThickness = frameSet()->border(); | |
548 bool repaintNeeded = false; | |
549 | |
550 // calculate frameset height based on actual content height to eliminate scr
olling | |
551 bool out = false; | |
552 for (int r = 0; r < rows && !out; r++) { | |
553 int extra = 0; | |
554 int height = m_rows.m_sizes[r]; | |
555 | |
556 for (int c = 0; c < cols; c++) { | |
557 IntRect oldFrameRect = pixelSnappedIntRect(child->frameRect()); | |
558 | |
559 int width = m_cols.m_sizes[c]; | |
560 | |
561 bool fixedWidth = frameSet()->colLengths() && frameSet()->colLengths
()[c].isFixed(); | |
562 bool fixedHeight = frameSet()->rowLengths() && frameSet()->rowLength
s()[r].isFixed(); | |
563 | |
564 // has to be resized and itself resize its contents | |
565 if (!fixedWidth) | |
566 child->setWidth(width ? width + extra / (cols - c) : 0); | |
567 else | |
568 child->setWidth(width); | |
569 child->setHeight(height); | |
570 | |
571 child->setNeedsLayout(true); | |
572 | |
573 if (child->isFrameSet()) | |
574 toRenderFrameSet(child)->layout(); | |
575 else | |
576 toRenderFrame(child)->layoutWithFlattening(fixedWidth, fixedHeig
ht); | |
577 | |
578 if (child->height() > m_rows.m_sizes[r]) | |
579 m_rows.m_sizes[r] = child->height(); | |
580 if (child->width() > m_cols.m_sizes[c]) | |
581 m_cols.m_sizes[c] = child->width(); | |
582 | |
583 if (child->frameRect() != oldFrameRect) | |
584 repaintNeeded = true; | |
585 | |
586 // difference between calculated frame width and the width it actual
ly decides to have | |
587 extra += width - m_cols.m_sizes[c]; | |
588 | |
589 child = child->nextSiblingBox(); | |
590 if (!child) { | |
591 out = true; | |
592 break; | |
593 } | |
594 } | |
595 } | |
596 | |
597 int xPos = 0; | |
598 int yPos = 0; | |
599 out = false; | |
600 child = firstChildBox(); | |
601 for (int r = 0; r < rows && !out; r++) { | |
602 xPos = 0; | |
603 for (int c = 0; c < cols; c++) { | |
604 // ensure the rows and columns are filled | |
605 IntRect oldRect = pixelSnappedIntRect(child->frameRect()); | |
606 | |
607 child->setLocation(IntPoint(xPos, yPos)); | |
608 child->setHeight(m_rows.m_sizes[r]); | |
609 child->setWidth(m_cols.m_sizes[c]); | |
610 | |
611 if (child->frameRect() != oldRect) { | |
612 repaintNeeded = true; | |
613 | |
614 // update to final size | |
615 child->setNeedsLayout(true); | |
616 if (child->isFrameSet()) | |
617 toRenderFrameSet(child)->layout(); | |
618 else | |
619 toRenderFrame(child)->layoutWithFlattening(true, true); | |
620 } | |
621 | |
622 xPos += m_cols.m_sizes[c] + borderThickness; | |
623 child = child->nextSiblingBox(); | |
624 if (!child) { | |
625 out = true; | |
626 break; | |
627 } | |
628 } | |
629 yPos += m_rows.m_sizes[r] + borderThickness; | |
630 } | |
631 | |
632 setWidth(xPos - borderThickness); | |
633 setHeight(yPos - borderThickness); | |
634 | |
635 if (repaintNeeded) | |
636 repaint(); | |
637 | |
638 // all the remaining frames are hidden to avoid ugly spurious unflowed frame
s | |
639 for (; child; child = child->nextSiblingBox()) { | |
640 child->setWidth(0); | |
641 child->setHeight(0); | |
642 child->setNeedsLayout(false); | |
643 } | |
644 } | |
645 | |
646 bool RenderFrameSet::flattenFrameSet() const | |
647 { | |
648 return frame() && frame()->settings() && frame()->settings()->frameFlattenin
gEnabled(); | |
649 } | |
650 | |
651 void RenderFrameSet::startResizing(GridAxis& axis, int position) | 535 void RenderFrameSet::startResizing(GridAxis& axis, int position) |
652 { | 536 { |
653 int split = hitTestSplit(axis, position); | 537 int split = hitTestSplit(axis, position); |
654 if (split == noSplit || axis.m_preventResize[split]) { | 538 if (split == noSplit || axis.m_preventResize[split]) { |
655 axis.m_splitBeingResized = noSplit; | 539 axis.m_splitBeingResized = noSplit; |
656 return; | 540 return; |
657 } | 541 } |
658 axis.m_splitBeingResized = split; | 542 axis.m_splitBeingResized = split; |
659 axis.m_splitResizeOffset = position - splitPosition(axis, split); | 543 axis.m_splitResizeOffset = position - splitPosition(axis, split); |
660 } | 544 } |
661 | 545 |
662 void RenderFrameSet::continueResizing(GridAxis& axis, int position) | 546 void RenderFrameSet::continueResizing(GridAxis& axis, int position) |
663 { | 547 { |
664 if (needsLayout()) | 548 if (needsLayout()) |
665 return; | 549 return; |
666 if (axis.m_splitBeingResized == noSplit) | 550 if (axis.m_splitBeingResized == noSplit) |
667 return; | 551 return; |
668 int currentSplitPosition = splitPosition(axis, axis.m_splitBeingResized); | 552 int currentSplitPosition = splitPosition(axis, axis.m_splitBeingResized); |
669 int delta = (position - currentSplitPosition) - axis.m_splitResizeOffset; | 553 int delta = (position - currentSplitPosition) - axis.m_splitResizeOffset; |
670 if (!delta) | 554 if (!delta) |
671 return; | 555 return; |
672 axis.m_deltas[axis.m_splitBeingResized - 1] += delta; | 556 axis.m_deltas[axis.m_splitBeingResized - 1] += delta; |
673 axis.m_deltas[axis.m_splitBeingResized] -= delta; | 557 axis.m_deltas[axis.m_splitBeingResized] -= delta; |
674 setNeedsLayout(true); | 558 setNeedsLayout(true); |
675 } | 559 } |
676 | 560 |
677 bool RenderFrameSet::userResize(MouseEvent* evt) | 561 bool RenderFrameSet::userResize(MouseEvent* evt) |
678 { | 562 { |
679 if (flattenFrameSet()) | |
680 return false; | |
681 | |
682 if (!m_isResizing) { | 563 if (!m_isResizing) { |
683 if (needsLayout()) | 564 if (needsLayout()) |
684 return false; | 565 return false; |
685 if (evt->type() == eventNames().mousedownEvent && evt->button() == LeftB
utton) { | 566 if (evt->type() == eventNames().mousedownEvent && evt->button() == LeftB
utton) { |
686 FloatPoint localPos = absoluteToLocal(evt->absoluteLocation(), UseTr
ansforms); | 567 FloatPoint localPos = absoluteToLocal(evt->absoluteLocation(), UseTr
ansforms); |
687 startResizing(m_cols, localPos.x()); | 568 startResizing(m_cols, localPos.x()); |
688 startResizing(m_rows, localPos.y()); | 569 startResizing(m_rows, localPos.y()); |
689 if (m_cols.m_splitBeingResized != noSplit || m_rows.m_splitBeingResi
zed != noSplit) { | 570 if (m_cols.m_splitBeingResized != noSplit || m_rows.m_splitBeingResi
zed != noSplit) { |
690 setIsResizing(true); | 571 setIsResizing(true); |
691 return true; | 572 return true; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 void RenderFrameSet::GridAxis::reportMemoryUsage(MemoryObjectInfo* memoryObjectI
nfo) const | 690 void RenderFrameSet::GridAxis::reportMemoryUsage(MemoryObjectInfo* memoryObjectI
nfo) const |
810 { | 691 { |
811 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Rendering)
; | 692 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Rendering)
; |
812 info.addMember(m_sizes, "sizes"); | 693 info.addMember(m_sizes, "sizes"); |
813 info.addMember(m_deltas, "deltas"); | 694 info.addMember(m_deltas, "deltas"); |
814 info.addMember(m_preventResize, "preventResize"); | 695 info.addMember(m_preventResize, "preventResize"); |
815 info.addMember(m_allowBorder, "allowBorder"); | 696 info.addMember(m_allowBorder, "allowBorder"); |
816 } | 697 } |
817 | 698 |
818 } // namespace WebCore | 699 } // namespace WebCore |
OLD | NEW |