Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(645)

Side by Side Diff: third_party/WebKit/Source/core/style/ComputedStyle.cpp

Issue 2785343002: Use getters for StyleSurroundData members in ComputedStyle.cpp (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 521
522 if ((!diff.needsFullLayout() || !diff.needsFullPaintInvalidation()) && 522 if ((!diff.needsFullLayout() || !diff.needsFullPaintInvalidation()) &&
523 diffNeedsFullLayoutAndPaintInvalidation(other)) { 523 diffNeedsFullLayoutAndPaintInvalidation(other)) {
524 diff.setNeedsFullLayout(); 524 diff.setNeedsFullLayout();
525 diff.setNeedsPaintInvalidationObject(); 525 diff.setNeedsPaintInvalidationObject();
526 } 526 }
527 527
528 if (!diff.needsFullLayout() && diffNeedsFullLayout(other)) 528 if (!diff.needsFullLayout() && diffNeedsFullLayout(other))
529 diff.setNeedsFullLayout(); 529 diff.setNeedsFullLayout();
530 530
531 if (!diff.needsFullLayout() && 531 if (!diff.needsFullLayout() && margin() != other.margin()) {
532 m_surround->m_margin != other.m_surround->m_margin) {
533 // Relative-positioned elements collapse their margins so need a full 532 // Relative-positioned elements collapse their margins so need a full
534 // layout. 533 // layout.
535 if (hasOutOfFlowPosition()) 534 if (hasOutOfFlowPosition())
536 diff.setNeedsPositionedMovementLayout(); 535 diff.setNeedsPositionedMovementLayout();
537 else 536 else
538 diff.setNeedsFullLayout(); 537 diff.setNeedsFullLayout();
539 } 538 }
540 539
541 if (!diff.needsFullLayout() && position() != EPosition::kStatic && 540 if (!diff.needsFullLayout() && position() != EPosition::kStatic &&
542 !offsetEqual(other)) { 541 !offsetEqual(other)) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 if (m_box->width() != other.m_box->width() || 580 if (m_box->width() != other.m_box->width() ||
582 m_box->minWidth() != other.m_box->minWidth() || 581 m_box->minWidth() != other.m_box->minWidth() ||
583 m_box->maxWidth() != other.m_box->maxWidth() || 582 m_box->maxWidth() != other.m_box->maxWidth() ||
584 m_box->height() != other.m_box->height() || 583 m_box->height() != other.m_box->height() ||
585 m_box->minHeight() != other.m_box->minHeight() || 584 m_box->minHeight() != other.m_box->minHeight() ||
586 m_box->maxHeight() != other.m_box->maxHeight()) 585 m_box->maxHeight() != other.m_box->maxHeight())
587 return true; 586 return true;
588 } 587 }
589 588
590 if (m_surround.get() != other.m_surround.get()) { 589 if (m_surround.get() != other.m_surround.get()) {
591 if (m_surround->m_margin != other.m_surround->m_margin || 590 if (margin() != other.margin() || !offsetEqual(other) ||
Bugs Nash 2017/04/03 00:12:48 what methods are these margin() and padding() call
shend 2017/04/03 00:58:48 It's being added in a parent patch (https://codere
592 !offsetEqual(other) || 591 padding() != other.padding())
593 m_surround->m_padding != other.m_surround->m_padding)
594 return true; 592 return true;
595 } 593 }
596 594
597 if (diff.transformChanged()) 595 if (diff.transformChanged())
598 return true; 596 return true;
599 597
600 return false; 598 return false;
601 } 599 }
602 600
603 bool ComputedStyle::diffNeedsFullLayoutAndPaintInvalidation( 601 bool ComputedStyle::diffNeedsFullLayoutAndPaintInvalidation(
604 const ComputedStyle& other) const { 602 const ComputedStyle& other) const {
605 // FIXME: Not all cases in this method need both full layout and paint 603 // FIXME: Not all cases in this method need both full layout and paint
606 // invalidation. 604 // invalidation.
607 // Should move cases into diffNeedsFullLayout() if 605 // Should move cases into diffNeedsFullLayout() if
608 // - don't need paint invalidation at all; 606 // - don't need paint invalidation at all;
609 // - or the layoutObject knows how to exactly invalidate paints caused by the 607 // - or the layoutObject knows how to exactly invalidate paints caused by the
610 // layout change instead of forced full paint invalidation. 608 // layout change instead of forced full paint invalidation.
611 609
612 if (m_surround.get() != other.m_surround.get()) { 610 if (m_surround.get() != other.m_surround.get()) {
613 // If our border widths change, then we need to layout. Other changes to 611 // If our border widths change, then we need to layout. Other changes to
614 // borders only necessitate a paint invalidation. 612 // borders only necessitate a paint invalidation.
615 if (borderLeftWidth() != other.borderLeftWidth() || 613 if (borderLeftWidth() != other.borderLeftWidth() ||
616 borderTopWidth() != other.borderTopWidth() || 614 borderTopWidth() != other.borderTopWidth() ||
617 borderBottomWidth() != other.borderBottomWidth() || 615 borderBottomWidth() != other.borderBottomWidth() ||
618 borderRightWidth() != other.borderRightWidth()) 616 borderRightWidth() != other.borderRightWidth())
619 return true; 617 return true;
620 618
621 if (m_surround->m_padding != other.m_surround->m_padding) 619 if (padding() != other.padding())
622 return true; 620 return true;
623 } 621 }
624 622
625 if (m_rareNonInheritedData.get() != other.m_rareNonInheritedData.get()) { 623 if (m_rareNonInheritedData.get() != other.m_rareNonInheritedData.get()) {
626 if (m_rareNonInheritedData->m_appearance != 624 if (m_rareNonInheritedData->m_appearance !=
627 other.m_rareNonInheritedData->m_appearance || 625 other.m_rareNonInheritedData->m_appearance ||
628 m_rareNonInheritedData->marginBeforeCollapse != 626 m_rareNonInheritedData->marginBeforeCollapse !=
629 other.m_rareNonInheritedData->marginBeforeCollapse || 627 other.m_rareNonInheritedData->marginBeforeCollapse ||
630 m_rareNonInheritedData->marginAfterCollapse != 628 m_rareNonInheritedData->marginAfterCollapse !=
631 other.m_rareNonInheritedData->marginAfterCollapse || 629 other.m_rareNonInheritedData->marginAfterCollapse ||
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 } 897 }
900 898
901 return false; 899 return false;
902 } 900 }
903 901
904 bool ComputedStyle::diffNeedsPaintInvalidationObject( 902 bool ComputedStyle::diffNeedsPaintInvalidationObject(
905 const ComputedStyle& other) const { 903 const ComputedStyle& other) const {
906 if (visibility() != other.visibility() || 904 if (visibility() != other.visibility() ||
907 printColorAdjust() != other.printColorAdjust() || 905 printColorAdjust() != other.printColorAdjust() ||
908 insideLink() != other.insideLink() || 906 insideLink() != other.insideLink() ||
909 !m_surround->m_border.visuallyEqual(other.m_surround->m_border) || 907 !border().visuallyEqual(other.border()) ||
910 *m_background != *other.m_background) 908 *m_background != *other.m_background)
911 return true; 909 return true;
912 910
913 if (m_rareInheritedData.get() != other.m_rareInheritedData.get()) { 911 if (m_rareInheritedData.get() != other.m_rareInheritedData.get()) {
914 if (m_rareInheritedData->userModify != 912 if (m_rareInheritedData->userModify !=
915 other.m_rareInheritedData->userModify || 913 other.m_rareInheritedData->userModify ||
916 m_rareInheritedData->userSelect != 914 m_rareInheritedData->userSelect !=
917 other.m_rareInheritedData->userSelect || 915 other.m_rareInheritedData->userSelect ||
918 m_rareInheritedData->m_imageRendering != 916 m_rareInheritedData->m_imageRendering !=
919 other.m_rareInheritedData->m_imageRendering) 917 other.m_rareInheritedData->m_imageRendering)
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 1030
1033 if (!m_rareNonInheritedData->reflectionDataEquivalent( 1031 if (!m_rareNonInheritedData->reflectionDataEquivalent(
1034 *other.m_rareNonInheritedData.get())) 1032 *other.m_rareNonInheritedData.get()))
1035 diff.setFilterChanged(); 1033 diff.setFilterChanged();
1036 1034
1037 if (!m_rareNonInheritedData->m_outline.visuallyEqual( 1035 if (!m_rareNonInheritedData->m_outline.visuallyEqual(
1038 other.m_rareNonInheritedData->m_outline)) 1036 other.m_rareNonInheritedData->m_outline))
1039 diff.setNeedsRecomputeOverflow(); 1037 diff.setNeedsRecomputeOverflow();
1040 } 1038 }
1041 1039
1042 if (!m_surround->m_border.visualOverflowEqual(other.m_surround->m_border)) 1040 if (border().visualOverflowEqual(other.border()))
1043 diff.setNeedsRecomputeOverflow(); 1041 diff.setNeedsRecomputeOverflow();
1044 1042
1045 if (!diff.needsFullPaintInvalidation()) { 1043 if (!diff.needsFullPaintInvalidation()) {
1046 if (m_styleInheritedData->color != other.m_styleInheritedData->color || 1044 if (m_styleInheritedData->color != other.m_styleInheritedData->color ||
1047 m_styleInheritedData->visitedLinkColor != 1045 m_styleInheritedData->visitedLinkColor !=
1048 other.m_styleInheritedData->visitedLinkColor || 1046 other.m_styleInheritedData->visitedLinkColor ||
1049 m_hasSimpleUnderline != other.m_hasSimpleUnderline || 1047 m_hasSimpleUnderline != other.m_hasSimpleUnderline ||
1050 m_visual->textDecoration != other.m_visual->textDecoration) { 1048 m_visual->textDecoration != other.m_visual->textDecoration) {
1051 diff.setTextDecorationOrColorChanged(); 1049 diff.setTextDecorationOrColorChanged();
1052 } else if (m_rareNonInheritedData.get() != 1050 } else if (m_rareNonInheritedData.get() !=
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 void ComputedStyle::setVerticalBorderSpacing(short v) { 1441 void ComputedStyle::setVerticalBorderSpacing(short v) {
1444 SET_VAR(m_styleInheritedData, vertical_border_spacing, v); 1442 SET_VAR(m_styleInheritedData, vertical_border_spacing, v);
1445 } 1443 }
1446 1444
1447 FloatRoundedRect ComputedStyle::getRoundedBorderFor( 1445 FloatRoundedRect ComputedStyle::getRoundedBorderFor(
1448 const LayoutRect& borderRect, 1446 const LayoutRect& borderRect,
1449 bool includeLogicalLeftEdge, 1447 bool includeLogicalLeftEdge,
1450 bool includeLogicalRightEdge) const { 1448 bool includeLogicalRightEdge) const {
1451 FloatRoundedRect roundedRect(pixelSnappedIntRect(borderRect)); 1449 FloatRoundedRect roundedRect(pixelSnappedIntRect(borderRect));
1452 if (hasBorderRadius()) { 1450 if (hasBorderRadius()) {
1453 FloatRoundedRect::Radii radii = 1451 FloatRoundedRect::Radii radii = calcRadiiFor(border(), borderRect.size());
1454 calcRadiiFor(m_surround->m_border, borderRect.size());
1455 roundedRect.includeLogicalEdges(radii, isHorizontalWritingMode(), 1452 roundedRect.includeLogicalEdges(radii, isHorizontalWritingMode(),
1456 includeLogicalLeftEdge, 1453 includeLogicalLeftEdge,
1457 includeLogicalRightEdge); 1454 includeLogicalRightEdge);
1458 roundedRect.constrainRadii(); 1455 roundedRect.constrainRadii();
1459 } 1456 }
1460 return roundedRect; 1457 return roundedRect;
1461 } 1458 }
1462 1459
1463 FloatRoundedRect ComputedStyle::getRoundedInnerBorderFor( 1460 FloatRoundedRect ComputedStyle::getRoundedInnerBorderFor(
1464 const LayoutRect& borderRect, 1461 const LayoutRect& borderRect,
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
2353 const NinePieceImage& image) const { 2350 const NinePieceImage& image) const {
2354 return LayoutRectOutsets( 2351 return LayoutRectOutsets(
2355 NinePieceImage::computeOutset(image.outset().top(), borderTopWidth()), 2352 NinePieceImage::computeOutset(image.outset().top(), borderTopWidth()),
2356 NinePieceImage::computeOutset(image.outset().right(), borderRightWidth()), 2353 NinePieceImage::computeOutset(image.outset().right(), borderRightWidth()),
2357 NinePieceImage::computeOutset(image.outset().bottom(), 2354 NinePieceImage::computeOutset(image.outset().bottom(),
2358 borderBottomWidth()), 2355 borderBottomWidth()),
2359 NinePieceImage::computeOutset(image.outset().left(), borderLeftWidth())); 2356 NinePieceImage::computeOutset(image.outset().left(), borderLeftWidth()));
2360 } 2357 }
2361 2358
2362 void ComputedStyle::setBorderImageSource(StyleImage* image) { 2359 void ComputedStyle::setBorderImageSource(StyleImage* image) {
2363 if (m_surround->m_border.m_image.image() == image) 2360 if (border().m_image.image() == image)
2364 return; 2361 return;
2365 m_surround.access()->m_border.m_image.setImage(image); 2362 m_surround.access()->m_border.m_image.setImage(image);
2366 } 2363 }
2367 2364
2368 void ComputedStyle::setBorderImageSlices(const LengthBox& slices) { 2365 void ComputedStyle::setBorderImageSlices(const LengthBox& slices) {
2369 if (m_surround->m_border.m_image.imageSlices() == slices) 2366 if (border().m_image.imageSlices() == slices)
2370 return; 2367 return;
2371 m_surround.access()->m_border.m_image.setImageSlices(slices); 2368 m_surround.access()->m_border.m_image.setImageSlices(slices);
2372 } 2369 }
2373 2370
2374 void ComputedStyle::setBorderImageSlicesFill(bool fill) { 2371 void ComputedStyle::setBorderImageSlicesFill(bool fill) {
2375 if (m_surround->m_border.m_image.fill() == fill) 2372 if (border().m_image.fill() == fill)
2376 return; 2373 return;
2377 m_surround.access()->m_border.m_image.setFill(fill); 2374 m_surround.access()->m_border.m_image.setFill(fill);
2378 } 2375 }
2379 2376
2380 void ComputedStyle::setBorderImageWidth(const BorderImageLengthBox& slices) { 2377 void ComputedStyle::setBorderImageWidth(const BorderImageLengthBox& slices) {
2381 if (m_surround->m_border.m_image.borderSlices() == slices) 2378 if (border().m_image.borderSlices() == slices)
2382 return; 2379 return;
2383 m_surround.access()->m_border.m_image.setBorderSlices(slices); 2380 m_surround.access()->m_border.m_image.setBorderSlices(slices);
2384 } 2381 }
2385 2382
2386 void ComputedStyle::setBorderImageOutset(const BorderImageLengthBox& outset) { 2383 void ComputedStyle::setBorderImageOutset(const BorderImageLengthBox& outset) {
2387 if (m_surround->m_border.m_image.outset() == outset) 2384 if (border().m_image.outset() == outset)
2388 return; 2385 return;
2389 m_surround.access()->m_border.m_image.setOutset(outset); 2386 m_surround.access()->m_border.m_image.setOutset(outset);
2390 } 2387 }
2391 2388
2392 bool ComputedStyle::borderObscuresBackground() const { 2389 bool ComputedStyle::borderObscuresBackground() const {
2393 if (!hasBorder()) 2390 if (!hasBorder())
2394 return false; 2391 return false;
2395 2392
2396 // Bail if we have any border-image for now. We could look at the image alpha 2393 // Bail if we have any border-image for now. We could look at the image alpha
2397 // to improve this. 2394 // to improve this.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
2473 if (value < 0) 2470 if (value < 0)
2474 fvalue -= 0.5f; 2471 fvalue -= 0.5f;
2475 else 2472 else
2476 fvalue += 0.5f; 2473 fvalue += 0.5f;
2477 } 2474 }
2478 2475
2479 return roundForImpreciseConversion<int>(fvalue / zoomFactor); 2476 return roundForImpreciseConversion<int>(fvalue / zoomFactor);
2480 } 2477 }
2481 2478
2482 } // namespace blink 2479 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698