| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/dom/Element.h" | 5 #include "core/dom/Element.h" |
| 6 #include "core/dom/StyleEngine.h" | 6 #include "core/dom/StyleEngine.h" |
| 7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
| 8 #include "core/html/HTMLDocument.h" | 8 #include "core/html/HTMLDocument.h" |
| 9 #include "core/html/HTMLElement.h" | 9 #include "core/html/HTMLElement.h" |
| 10 #include "core/layout/LayoutObject.h" | 10 #include "core/layout/LayoutObject.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 OwnPtr<DummyPageHolder> dummyPageHolder = DummyPageHolder::create(IntSize(80
0, 600)); | 47 OwnPtr<DummyPageHolder> dummyPageHolder = DummyPageHolder::create(IntSize(80
0, 600)); |
| 48 HTMLDocument& document = toHTMLDocument(dummyPageHolder->document()); | 48 HTMLDocument& document = toHTMLDocument(dummyPageHolder->document()); |
| 49 document.documentElement()->setInnerHTML("<style>div {width:100px;height:100
px} div:-webkit-drag .drag { background-color: green }</style>" | 49 document.documentElement()->setInnerHTML("<style>div {width:100px;height:100
px} div:-webkit-drag .drag { background-color: green }</style>" |
| 50 "<div>" | 50 "<div>" |
| 51 "<span></span>" | 51 "<span></span>" |
| 52 "<span></span>" | 52 "<span></span>" |
| 53 "<span class='drag'></span>" | 53 "<span class='drag'></span>" |
| 54 "<span></span>" | 54 "<span></span>" |
| 55 "</div>", ASSERT_NO_EXCEPTION); | 55 "</div>", ASSERT_NO_EXCEPTION); |
| 56 | 56 |
| 57 document.updateLayout(); | 57 document.updateStyleAndLayout(); |
| 58 unsigned startCount = document.styleEngine().styleForElementCount(); | 58 unsigned startCount = document.styleEngine().styleForElementCount(); |
| 59 | 59 |
| 60 document.documentElement()->layoutObject()->updateDragState(true); | 60 document.documentElement()->layoutObject()->updateDragState(true); |
| 61 document.updateLayout(); | 61 document.updateStyleAndLayout(); |
| 62 | 62 |
| 63 unsigned elementCount = document.styleEngine().styleForElementCount() - star
tCount; | 63 unsigned elementCount = document.styleEngine().styleForElementCount() - star
tCount; |
| 64 | 64 |
| 65 ASSERT_EQ(1U, elementCount); | 65 ASSERT_EQ(1U, elementCount); |
| 66 } | 66 } |
| 67 | 67 |
| 68 TEST(DragUpdateTest, SiblingAffectedByDragUpdate) | 68 TEST(DragUpdateTest, SiblingAffectedByDragUpdate) |
| 69 { | 69 { |
| 70 // Check that when dragging the div in the document below, you get a | 70 // Check that when dragging the div in the document below, you get a |
| 71 // single element style recalc. | 71 // single element style recalc. |
| 72 | 72 |
| 73 OwnPtr<DummyPageHolder> dummyPageHolder = DummyPageHolder::create(IntSize(80
0, 600)); | 73 OwnPtr<DummyPageHolder> dummyPageHolder = DummyPageHolder::create(IntSize(80
0, 600)); |
| 74 HTMLDocument& document = toHTMLDocument(dummyPageHolder->document()); | 74 HTMLDocument& document = toHTMLDocument(dummyPageHolder->document()); |
| 75 document.documentElement()->setInnerHTML("<style>div {width:100px;height:100
px} div:-webkit-drag + .drag { background-color: green }</style>" | 75 document.documentElement()->setInnerHTML("<style>div {width:100px;height:100
px} div:-webkit-drag + .drag { background-color: green }</style>" |
| 76 "<div>" | 76 "<div>" |
| 77 "<span></span>" | 77 "<span></span>" |
| 78 "<span></span>" | 78 "<span></span>" |
| 79 "<span></span>" | 79 "<span></span>" |
| 80 "<span></span>" | 80 "<span></span>" |
| 81 "</div>" | 81 "</div>" |
| 82 "<span class='drag'></span>", ASSERT_NO_EXCEPTION); | 82 "<span class='drag'></span>", ASSERT_NO_EXCEPTION); |
| 83 | 83 |
| 84 document.updateLayout(); | 84 document.updateStyleAndLayout(); |
| 85 unsigned startCount = document.styleEngine().styleForElementCount(); | 85 unsigned startCount = document.styleEngine().styleForElementCount(); |
| 86 | 86 |
| 87 document.documentElement()->layoutObject()->updateDragState(true); | 87 document.documentElement()->layoutObject()->updateDragState(true); |
| 88 document.updateLayout(); | 88 document.updateStyleAndLayout(); |
| 89 | 89 |
| 90 unsigned elementCount = document.styleEngine().styleForElementCount() - star
tCount; | 90 unsigned elementCount = document.styleEngine().styleForElementCount() - star
tCount; |
| 91 | 91 |
| 92 ASSERT_EQ(1U, elementCount); | 92 ASSERT_EQ(1U, elementCount); |
| 93 } | 93 } |
| 94 | 94 |
| 95 } // namespace blink | 95 } // namespace blink |
| OLD | NEW |