| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 webViewHelper.webViewImpl()->setFixedLayoutSize(WebCore::IntSize(100, 100)); | 680 webViewHelper.webViewImpl()->setFixedLayoutSize(WebCore::IntSize(100, 100)); |
| 681 EXPECT_TRUE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->needs
Layout()); | 681 EXPECT_TRUE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->needs
Layout()); |
| 682 | 682 |
| 683 int prevLayoutCount = webViewHelper.webViewImpl()->mainFrameImpl()->frameVie
w()->layoutCount(); | 683 int prevLayoutCount = webViewHelper.webViewImpl()->mainFrameImpl()->frameVie
w()->layoutCount(); |
| 684 webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->setFrameRect(WebC
ore::IntRect(0, 0, 641, 481)); | 684 webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->setFrameRect(WebC
ore::IntRect(0, 0, 641, 481)); |
| 685 EXPECT_EQ(prevLayoutCount, webViewHelper.webViewImpl()->mainFrameImpl()->fra
meView()->layoutCount()); | 685 EXPECT_EQ(prevLayoutCount, webViewHelper.webViewImpl()->mainFrameImpl()->fra
meView()->layoutCount()); |
| 686 | 686 |
| 687 webViewHelper.webViewImpl()->layout(); | 687 webViewHelper.webViewImpl()->layout(); |
| 688 } | 688 } |
| 689 | 689 |
| 690 TEST_F(WebFrameTest, ChangeInFixedLayoutTriggersTextAutosizingRecalculate) | 690 // Helper function to check or set text autosizing multipliers on a document. |
| 691 static bool checkOrSetTextAutosizingMultiplier(Document* document, float multipl
ier, bool setMultiplier) |
| 692 { |
| 693 bool multiplierCheckedOrSetAtLeastOnce = false; |
| 694 for (WebCore::RenderObject* renderer = document->renderer(); renderer; rende
rer = renderer->nextInPreOrder()) { |
| 695 if (renderer->style()) { |
| 696 if (setMultiplier) |
| 697 renderer->style()->setTextAutosizingMultiplier(multiplier); |
| 698 EXPECT_EQ(multiplier, renderer->style()->textAutosizingMultiplier())
; |
| 699 multiplierCheckedOrSetAtLeastOnce = true; |
| 700 } |
| 701 } |
| 702 return multiplierCheckedOrSetAtLeastOnce; |
| 703 |
| 704 } |
| 705 |
| 706 static bool setTextAutosizingMultiplier(Document* document, float multiplier) |
| 707 { |
| 708 return checkOrSetTextAutosizingMultiplier(document, multiplier, true); |
| 709 } |
| 710 |
| 711 static bool checkTextAutosizingMultiplier(Document* document, float multiplier) |
| 712 { |
| 713 return checkOrSetTextAutosizingMultiplier(document, multiplier, false); |
| 714 } |
| 715 |
| 716 TEST_F(WebFrameTest, ChangeInFixedLayoutResetsTextAutosizingMultipliers) |
| 691 { | 717 { |
| 692 UseMockScrollbarSettings mockScrollbarSettings; | 718 UseMockScrollbarSettings mockScrollbarSettings; |
| 693 registerMockedHttpURLLoad("fixed_layout.html"); | 719 registerMockedHttpURLLoad("fixed_layout.html"); |
| 694 | 720 |
| 695 FixedLayoutTestWebViewClient client; | 721 FixedLayoutTestWebViewClient client; |
| 696 int viewportWidth = 640; | 722 int viewportWidth = 640; |
| 697 int viewportHeight = 480; | 723 int viewportHeight = 480; |
| 698 | 724 |
| 699 // Make sure we initialize to minimum scale, even if the window size | |
| 700 // only becomes available after the load begins. | |
| 701 FrameTestHelpers::WebViewHelper webViewHelper; | 725 FrameTestHelpers::WebViewHelper webViewHelper; |
| 702 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &c
lient, enableViewportSettings); | 726 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &c
lient, enableViewportSettings); |
| 703 | 727 |
| 704 WebCore::Document* document = webViewHelper.webViewImpl()->page()->mainFrame
()->document(); | 728 WebCore::Document* document = webViewHelper.webViewImpl()->page()->mainFrame
()->document(); |
| 705 document->settings()->setTextAutosizingEnabled(true); | 729 document->settings()->setTextAutosizingEnabled(true); |
| 706 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); | 730 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); |
| 707 webViewHelper.webViewImpl()->resize(WebSize(viewportWidth, viewportHeight)); | 731 webViewHelper.webViewImpl()->resize(WebSize(viewportWidth, viewportHeight)); |
| 708 webViewHelper.webViewImpl()->layout(); | 732 webViewHelper.webViewImpl()->layout(); |
| 709 | 733 |
| 710 WebCore::RenderObject* renderer = document->renderer(); | 734 EXPECT_TRUE(setTextAutosizingMultiplier(document, 2)); |
| 711 bool multiplierSetAtLeastOnce = false; | |
| 712 while (renderer) { | |
| 713 if (renderer->style()) { | |
| 714 renderer->style()->setTextAutosizingMultiplier(2); | |
| 715 EXPECT_EQ(2, renderer->style()->textAutosizingMultiplier()); | |
| 716 multiplierSetAtLeastOnce = true; | |
| 717 } | |
| 718 renderer = renderer->nextInPreOrder(); | |
| 719 } | |
| 720 EXPECT_TRUE(multiplierSetAtLeastOnce); | |
| 721 | 735 |
| 722 WebCore::ViewportDescription description = document->viewportDescription(); | 736 WebCore::ViewportDescription description = document->viewportDescription(); |
| 723 // Choose a width that's not going match the viewport width of the loaded do
cument. | 737 // Choose a width that's not going match the viewport width of the loaded do
cument. |
| 724 description.minWidth = WebCore::Length(100, WebCore::Fixed); | 738 description.minWidth = WebCore::Length(100, WebCore::Fixed); |
| 725 description.maxWidth = WebCore::Length(100, WebCore::Fixed); | 739 description.maxWidth = WebCore::Length(100, WebCore::Fixed); |
| 726 webViewHelper.webViewImpl()->updatePageDefinedViewportConstraints(descriptio
n); | 740 webViewHelper.webViewImpl()->updatePageDefinedViewportConstraints(descriptio
n); |
| 727 | 741 |
| 728 bool multiplierCheckedAtLeastOnce = false; | 742 EXPECT_TRUE(checkTextAutosizingMultiplier(document, 1)); |
| 729 renderer = document->renderer(); | 743 } |
| 730 while (renderer) { | 744 |
| 731 if (renderer->style()) { | 745 TEST_F(WebFrameTest, SetFrameRectResetsTextAutosizingMultipliers) |
| 732 EXPECT_EQ(1, renderer->style()->textAutosizingMultiplier()); | 746 { |
| 733 multiplierCheckedAtLeastOnce = true; | 747 UseMockScrollbarSettings mockScrollbarSettings; |
| 734 } | 748 registerMockedHttpURLLoad("iframe_reload.html"); |
| 735 renderer = renderer->nextInPreOrder(); | 749 registerMockedHttpURLLoad("visible_iframe.html"); |
| 736 } | 750 |
| 737 EXPECT_TRUE(multiplierCheckedAtLeastOnce); | 751 FixedLayoutTestWebViewClient client; |
| 752 int viewportWidth = 640; |
| 753 int viewportHeight = 480; |
| 754 |
| 755 FrameTestHelpers::WebViewHelper webViewHelper; |
| 756 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, 0, &
client, enableViewportSettings); |
| 757 |
| 758 WebCore::LocalFrame* mainFrame = webViewHelper.webViewImpl()->page()->mainFr
ame(); |
| 759 WebCore::Document* document = mainFrame->document(); |
| 760 WebCore::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()
->frameView(); |
| 761 document->settings()->setTextAutosizingEnabled(true); |
| 762 EXPECT_TRUE(document->settings()->textAutosizingEnabled()); |
| 763 webViewHelper.webViewImpl()->resize(WebSize(viewportWidth, viewportHeight)); |
| 764 webViewHelper.webViewImpl()->layout(); |
| 765 |
| 766 for (WebCore::LocalFrame* frame = mainFrame; frame; frame = frame->tree().tr
averseNext()) |
| 767 EXPECT_TRUE(setTextAutosizingMultiplier(frame->document(), 2)); |
| 768 |
| 769 frameView->setFrameRect(WebCore::IntRect(0, 0, 200, 200)); |
| 770 |
| 771 for (WebCore::LocalFrame* frame = mainFrame; frame; frame = frame->tree().tr
averseNext()) |
| 772 EXPECT_TRUE(checkTextAutosizingMultiplier(frame->document(), 1)); |
| 738 } | 773 } |
| 739 | 774 |
| 740 TEST_F(WebFrameTest, FixedLayoutSizeStopsResizeFromChangingLayoutSize) | 775 TEST_F(WebFrameTest, FixedLayoutSizeStopsResizeFromChangingLayoutSize) |
| 741 { | 776 { |
| 742 UseMockScrollbarSettings mockScrollbarSettings; | 777 UseMockScrollbarSettings mockScrollbarSettings; |
| 743 registerMockedHttpURLLoad("fixed_layout.html"); | 778 registerMockedHttpURLLoad("fixed_layout.html"); |
| 744 | 779 |
| 745 int viewportWidth = 640; | 780 int viewportWidth = 640; |
| 746 int viewportHeight = 480; | 781 int viewportHeight = 480; |
| 747 | 782 |
| (...skipping 4489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5237 webViewHelper.initializeAndLoad("about:blank"); | 5272 webViewHelper.initializeAndLoad("about:blank"); |
| 5238 | 5273 |
| 5239 WebCore::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()
->frameView(); | 5274 WebCore::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()
->frameView(); |
| 5240 frameView->setFrameRect(WebCore::IntRect(0, 0, 200, 200)); | 5275 frameView->setFrameRect(WebCore::IntRect(0, 0, 200, 200)); |
| 5241 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 200), frameView->frameRect()); | 5276 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 200, 200), frameView->frameRect()); |
| 5242 frameView->setFrameRect(WebCore::IntRect(100, 100, 200, 200)); | 5277 frameView->setFrameRect(WebCore::IntRect(100, 100, 200, 200)); |
| 5243 EXPECT_EQ_RECT(WebCore::IntRect(100, 100, 200, 200), frameView->frameRect())
; | 5278 EXPECT_EQ_RECT(WebCore::IntRect(100, 100, 200, 200), frameView->frameRect())
; |
| 5244 } | 5279 } |
| 5245 | 5280 |
| 5246 } // namespace | 5281 } // namespace |
| OLD | NEW |