OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) | 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights |
4 * reserved. | 4 * reserved. |
5 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. | 5 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. |
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 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 | 520 |
521 if ((!diff.NeedsFullLayout() || !diff.NeedsFullPaintInvalidation()) && | 521 if ((!diff.NeedsFullLayout() || !diff.NeedsFullPaintInvalidation()) && |
522 DiffNeedsFullLayoutAndPaintInvalidation(other)) { | 522 DiffNeedsFullLayoutAndPaintInvalidation(other)) { |
523 diff.SetNeedsFullLayout(); | 523 diff.SetNeedsFullLayout(); |
524 diff.SetNeedsPaintInvalidationObject(); | 524 diff.SetNeedsPaintInvalidationObject(); |
525 } | 525 } |
526 | 526 |
527 if (!diff.NeedsFullLayout() && DiffNeedsFullLayout(other)) | 527 if (!diff.NeedsFullLayout() && DiffNeedsFullLayout(other)) |
528 diff.SetNeedsFullLayout(); | 528 diff.SetNeedsFullLayout(); |
529 | 529 |
530 if (!diff.NeedsFullLayout() && | 530 if (!diff.NeedsFullLayout() && Margin() != other.Margin()) { |
531 surround_->margin_ != other.surround_->margin_) { | |
532 // Relative-positioned elements collapse their margins so need a full | 531 // Relative-positioned elements collapse their margins so need a full |
533 // layout. | 532 // layout. |
534 if (HasOutOfFlowPosition()) | 533 if (HasOutOfFlowPosition()) |
535 diff.SetNeedsPositionedMovementLayout(); | 534 diff.SetNeedsPositionedMovementLayout(); |
536 else | 535 else |
537 diff.SetNeedsFullLayout(); | 536 diff.SetNeedsFullLayout(); |
538 } | 537 } |
539 | 538 |
540 if (!diff.NeedsFullLayout() && GetPosition() != EPosition::kStatic && | 539 if (!diff.NeedsFullLayout() && GetPosition() != EPosition::kStatic && |
541 !OffsetEqual(other)) { | 540 !OffsetEqual(other)) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 if (box_->Width() != other.box_->Width() || | 582 if (box_->Width() != other.box_->Width() || |
584 box_->MinWidth() != other.box_->MinWidth() || | 583 box_->MinWidth() != other.box_->MinWidth() || |
585 box_->MaxWidth() != other.box_->MaxWidth() || | 584 box_->MaxWidth() != other.box_->MaxWidth() || |
586 box_->Height() != other.box_->Height() || | 585 box_->Height() != other.box_->Height() || |
587 box_->MinHeight() != other.box_->MinHeight() || | 586 box_->MinHeight() != other.box_->MinHeight() || |
588 box_->MaxHeight() != other.box_->MaxHeight()) | 587 box_->MaxHeight() != other.box_->MaxHeight()) |
589 return true; | 588 return true; |
590 } | 589 } |
591 | 590 |
592 if (surround_.Get() != other.surround_.Get()) { | 591 if (surround_.Get() != other.surround_.Get()) { |
593 if (surround_->margin_ != other.surround_->margin_ || !OffsetEqual(other) || | 592 if (Margin() != other.Margin() || !OffsetEqual(other) || |
594 surround_->padding_ != other.surround_->padding_) | 593 Padding() != other.Padding()) |
595 return true; | 594 return true; |
596 } | 595 } |
597 | 596 |
598 if (diff.TransformChanged()) | 597 if (diff.TransformChanged()) |
599 return true; | 598 return true; |
600 | 599 |
601 return false; | 600 return false; |
602 } | 601 } |
603 | 602 |
604 bool ComputedStyle::DiffNeedsFullLayoutAndPaintInvalidation( | 603 bool ComputedStyle::DiffNeedsFullLayoutAndPaintInvalidation( |
605 const ComputedStyle& other) const { | 604 const ComputedStyle& other) const { |
606 // FIXME: Not all cases in this method need both full layout and paint | 605 // FIXME: Not all cases in this method need both full layout and paint |
607 // invalidation. | 606 // invalidation. |
608 // Should move cases into DiffNeedsFullLayout() if | 607 // Should move cases into DiffNeedsFullLayout() if |
609 // - don't need paint invalidation at all; | 608 // - don't need paint invalidation at all; |
610 // - or the layoutObject knows how to exactly invalidate paints caused by the | 609 // - or the layoutObject knows how to exactly invalidate paints caused by the |
611 // layout change instead of forced full paint invalidation. | 610 // layout change instead of forced full paint invalidation. |
612 | 611 |
613 if (surround_.Get() != other.surround_.Get()) { | 612 if (surround_.Get() != other.surround_.Get()) { |
614 // If our border widths change, then we need to layout. Other changes to | 613 // If our border widths change, then we need to layout. Other changes to |
615 // borders only necessitate a paint invalidation. | 614 // borders only necessitate a paint invalidation. |
616 if (BorderLeftWidth() != other.BorderLeftWidth() || | 615 if (BorderLeftWidth() != other.BorderLeftWidth() || |
617 BorderTopWidth() != other.BorderTopWidth() || | 616 BorderTopWidth() != other.BorderTopWidth() || |
618 BorderBottomWidth() != other.BorderBottomWidth() || | 617 BorderBottomWidth() != other.BorderBottomWidth() || |
619 BorderRightWidth() != other.BorderRightWidth()) | 618 BorderRightWidth() != other.BorderRightWidth()) |
620 return true; | 619 return true; |
621 | 620 |
622 if (surround_->padding_ != other.surround_->padding_) | 621 if (Padding() != other.Padding()) |
623 return true; | 622 return true; |
624 } | 623 } |
625 | 624 |
626 if (rare_non_inherited_data_.Get() != other.rare_non_inherited_data_.Get()) { | 625 if (rare_non_inherited_data_.Get() != other.rare_non_inherited_data_.Get()) { |
627 if (rare_non_inherited_data_->appearance_ != | 626 if (rare_non_inherited_data_->appearance_ != |
628 other.rare_non_inherited_data_->appearance_ || | 627 other.rare_non_inherited_data_->appearance_ || |
629 rare_non_inherited_data_->margin_before_collapse != | 628 rare_non_inherited_data_->margin_before_collapse != |
630 other.rare_non_inherited_data_->margin_before_collapse || | 629 other.rare_non_inherited_data_->margin_before_collapse || |
631 rare_non_inherited_data_->margin_after_collapse != | 630 rare_non_inherited_data_->margin_after_collapse != |
632 other.rare_non_inherited_data_->margin_after_collapse || | 631 other.rare_non_inherited_data_->margin_after_collapse || |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 } | 898 } |
900 | 899 |
901 return false; | 900 return false; |
902 } | 901 } |
903 | 902 |
904 bool ComputedStyle::DiffNeedsPaintInvalidationObject( | 903 bool ComputedStyle::DiffNeedsPaintInvalidationObject( |
905 const ComputedStyle& other) const { | 904 const ComputedStyle& other) const { |
906 if (Visibility() != other.Visibility() || | 905 if (Visibility() != other.Visibility() || |
907 PrintColorAdjust() != other.PrintColorAdjust() || | 906 PrintColorAdjust() != other.PrintColorAdjust() || |
908 InsideLink() != other.InsideLink() || | 907 InsideLink() != other.InsideLink() || |
909 !surround_->border_.VisuallyEqual(other.surround_->border_) || | 908 !Border().VisuallyEqual(other.Border()) || |
910 *background_ != *other.background_) | 909 *background_ != *other.background_) |
911 return true; | 910 return true; |
912 | 911 |
913 if (rare_inherited_data_.Get() != other.rare_inherited_data_.Get()) { | 912 if (rare_inherited_data_.Get() != other.rare_inherited_data_.Get()) { |
914 if (rare_inherited_data_->user_modify != | 913 if (rare_inherited_data_->user_modify != |
915 other.rare_inherited_data_->user_modify || | 914 other.rare_inherited_data_->user_modify || |
916 rare_inherited_data_->user_select != | 915 rare_inherited_data_->user_select != |
917 other.rare_inherited_data_->user_select || | 916 other.rare_inherited_data_->user_select || |
918 rare_inherited_data_->image_rendering_ != | 917 rare_inherited_data_->image_rendering_ != |
919 other.rare_inherited_data_->image_rendering_) | 918 other.rare_inherited_data_->image_rendering_) |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1047 | 1046 |
1048 if (!rare_non_inherited_data_->ReflectionDataEquivalent( | 1047 if (!rare_non_inherited_data_->ReflectionDataEquivalent( |
1049 *other.rare_non_inherited_data_.Get())) | 1048 *other.rare_non_inherited_data_.Get())) |
1050 diff.SetFilterChanged(); | 1049 diff.SetFilterChanged(); |
1051 | 1050 |
1052 if (!rare_non_inherited_data_->outline_.VisuallyEqual( | 1051 if (!rare_non_inherited_data_->outline_.VisuallyEqual( |
1053 other.rare_non_inherited_data_->outline_)) | 1052 other.rare_non_inherited_data_->outline_)) |
1054 diff.SetNeedsRecomputeOverflow(); | 1053 diff.SetNeedsRecomputeOverflow(); |
1055 } | 1054 } |
1056 | 1055 |
1057 if (!surround_->border_.VisualOverflowEqual(other.surround_->border_)) | 1056 if (!Border().VisualOverflowEqual(other.Border())) |
1058 diff.SetNeedsRecomputeOverflow(); | 1057 diff.SetNeedsRecomputeOverflow(); |
1059 | 1058 |
1060 if (!diff.NeedsFullPaintInvalidation()) { | 1059 if (!diff.NeedsFullPaintInvalidation()) { |
1061 if (style_inherited_data_->color != other.style_inherited_data_->color || | 1060 if (style_inherited_data_->color != other.style_inherited_data_->color || |
1062 style_inherited_data_->visited_link_color != | 1061 style_inherited_data_->visited_link_color != |
1063 other.style_inherited_data_->visited_link_color || | 1062 other.style_inherited_data_->visited_link_color || |
1064 has_simple_underline_ != other.has_simple_underline_ || | 1063 has_simple_underline_ != other.has_simple_underline_ || |
1065 visual_->text_decoration != other.visual_->text_decoration) { | 1064 visual_->text_decoration != other.visual_->text_decoration) { |
1066 diff.SetTextDecorationOrColorChanged(); | 1065 diff.SetTextDecorationOrColorChanged(); |
1067 } else if (rare_non_inherited_data_.Get() != | 1066 } else if (rare_non_inherited_data_.Get() != |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1458 void ComputedStyle::SetVerticalBorderSpacing(short v) { | 1457 void ComputedStyle::SetVerticalBorderSpacing(short v) { |
1459 SET_VAR(style_inherited_data_, vertical_border_spacing, v); | 1458 SET_VAR(style_inherited_data_, vertical_border_spacing, v); |
1460 } | 1459 } |
1461 | 1460 |
1462 FloatRoundedRect ComputedStyle::GetRoundedBorderFor( | 1461 FloatRoundedRect ComputedStyle::GetRoundedBorderFor( |
1463 const LayoutRect& border_rect, | 1462 const LayoutRect& border_rect, |
1464 bool include_logical_left_edge, | 1463 bool include_logical_left_edge, |
1465 bool include_logical_right_edge) const { | 1464 bool include_logical_right_edge) const { |
1466 FloatRoundedRect rounded_rect(PixelSnappedIntRect(border_rect)); | 1465 FloatRoundedRect rounded_rect(PixelSnappedIntRect(border_rect)); |
1467 if (HasBorderRadius()) { | 1466 if (HasBorderRadius()) { |
1468 FloatRoundedRect::Radii radii = | 1467 FloatRoundedRect::Radii radii = CalcRadiiFor(Border(), border_rect.Size()); |
1469 CalcRadiiFor(surround_->border_, border_rect.Size()); | |
1470 rounded_rect.IncludeLogicalEdges(radii, IsHorizontalWritingMode(), | 1468 rounded_rect.IncludeLogicalEdges(radii, IsHorizontalWritingMode(), |
1471 include_logical_left_edge, | 1469 include_logical_left_edge, |
1472 include_logical_right_edge); | 1470 include_logical_right_edge); |
1473 rounded_rect.ConstrainRadii(); | 1471 rounded_rect.ConstrainRadii(); |
1474 } | 1472 } |
1475 return rounded_rect; | 1473 return rounded_rect; |
1476 } | 1474 } |
1477 | 1475 |
1478 FloatRoundedRect ComputedStyle::GetRoundedInnerBorderFor( | 1476 FloatRoundedRect ComputedStyle::GetRoundedInnerBorderFor( |
1479 const LayoutRect& border_rect, | 1477 const LayoutRect& border_rect, |
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2383 const NinePieceImage& image) const { | 2381 const NinePieceImage& image) const { |
2384 return LayoutRectOutsets( | 2382 return LayoutRectOutsets( |
2385 NinePieceImage::ComputeOutset(image.Outset().Top(), BorderTopWidth()), | 2383 NinePieceImage::ComputeOutset(image.Outset().Top(), BorderTopWidth()), |
2386 NinePieceImage::ComputeOutset(image.Outset().Right(), BorderRightWidth()), | 2384 NinePieceImage::ComputeOutset(image.Outset().Right(), BorderRightWidth()), |
2387 NinePieceImage::ComputeOutset(image.Outset().Bottom(), | 2385 NinePieceImage::ComputeOutset(image.Outset().Bottom(), |
2388 BorderBottomWidth()), | 2386 BorderBottomWidth()), |
2389 NinePieceImage::ComputeOutset(image.Outset().Left(), BorderLeftWidth())); | 2387 NinePieceImage::ComputeOutset(image.Outset().Left(), BorderLeftWidth())); |
2390 } | 2388 } |
2391 | 2389 |
2392 void ComputedStyle::SetBorderImageSource(StyleImage* image) { | 2390 void ComputedStyle::SetBorderImageSource(StyleImage* image) { |
2393 if (surround_->border_.image_.GetImage() == image) | 2391 if (Border().image_.GetImage() == image) |
2394 return; | 2392 return; |
2395 surround_.Access()->border_.image_.SetImage(image); | 2393 surround_.Access()->border_.image_.SetImage(image); |
2396 } | 2394 } |
2397 | 2395 |
2398 void ComputedStyle::SetBorderImageSlices(const LengthBox& slices) { | 2396 void ComputedStyle::SetBorderImageSlices(const LengthBox& slices) { |
2399 if (surround_->border_.image_.ImageSlices() == slices) | 2397 if (Border().image_.ImageSlices() == slices) |
2400 return; | 2398 return; |
2401 surround_.Access()->border_.image_.SetImageSlices(slices); | 2399 surround_.Access()->border_.image_.SetImageSlices(slices); |
2402 } | 2400 } |
2403 | 2401 |
2404 void ComputedStyle::SetBorderImageSlicesFill(bool fill) { | 2402 void ComputedStyle::SetBorderImageSlicesFill(bool fill) { |
2405 if (surround_->border_.image_.Fill() == fill) | 2403 if (Border().image_.Fill() == fill) |
2406 return; | 2404 return; |
2407 surround_.Access()->border_.image_.SetFill(fill); | 2405 surround_.Access()->border_.image_.SetFill(fill); |
2408 } | 2406 } |
2409 | 2407 |
2410 void ComputedStyle::SetBorderImageWidth(const BorderImageLengthBox& slices) { | 2408 void ComputedStyle::SetBorderImageWidth(const BorderImageLengthBox& slices) { |
2411 if (surround_->border_.image_.BorderSlices() == slices) | 2409 if (Border().image_.BorderSlices() == slices) |
2412 return; | 2410 return; |
2413 surround_.Access()->border_.image_.SetBorderSlices(slices); | 2411 surround_.Access()->border_.image_.SetBorderSlices(slices); |
2414 } | 2412 } |
2415 | 2413 |
2416 void ComputedStyle::SetBorderImageOutset(const BorderImageLengthBox& outset) { | 2414 void ComputedStyle::SetBorderImageOutset(const BorderImageLengthBox& outset) { |
2417 if (surround_->border_.image_.Outset() == outset) | 2415 if (Border().image_.Outset() == outset) |
2418 return; | 2416 return; |
2419 surround_.Access()->border_.image_.SetOutset(outset); | 2417 surround_.Access()->border_.image_.SetOutset(outset); |
2420 } | 2418 } |
2421 | 2419 |
2422 bool ComputedStyle::BorderObscuresBackground() const { | 2420 bool ComputedStyle::BorderObscuresBackground() const { |
2423 if (!HasBorder()) | 2421 if (!HasBorder()) |
2424 return false; | 2422 return false; |
2425 | 2423 |
2426 // Bail if we have any border-image for now. We could look at the image alpha | 2424 // Bail if we have any border-image for now. We could look at the image alpha |
2427 // to improve this. | 2425 // to improve this. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2503 if (value < 0) | 2501 if (value < 0) |
2504 fvalue -= 0.5f; | 2502 fvalue -= 0.5f; |
2505 else | 2503 else |
2506 fvalue += 0.5f; | 2504 fvalue += 0.5f; |
2507 } | 2505 } |
2508 | 2506 |
2509 return RoundForImpreciseConversion<int>(fvalue / zoom_factor); | 2507 return RoundForImpreciseConversion<int>(fvalue / zoom_factor); |
2510 } | 2508 } |
2511 | 2509 |
2512 } // namespace blink | 2510 } // namespace blink |
OLD | NEW |