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

Side by Side Diff: third_party/WebKit/Source/web/ValidationMessageClientImpl.cpp

Issue 2644083005: Use a frame-specific timer task runner for ValidationMessageClientImpl. (Closed)
Patch Set: Created 3 years, 11 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 | « third_party/WebKit/Source/web/ValidationMessageClientImpl.h ('k') | 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE 16 * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 20 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE. 23 * SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "web/ValidationMessageClientImpl.h" 26 #include "web/ValidationMessageClientImpl.h"
27 27
28 #include "core/dom/Element.h" 28 #include "core/dom/Element.h"
29 #include "core/dom/TaskRunnerHelper.h"
29 #include "core/frame/FrameView.h" 30 #include "core/frame/FrameView.h"
30 #include "platform/HostWindow.h" 31 #include "platform/HostWindow.h"
31 #include "public/platform/WebRect.h" 32 #include "public/platform/WebRect.h"
32 #include "public/platform/WebString.h" 33 #include "public/platform/WebString.h"
33 #include "public/web/WebTextDirection.h" 34 #include "public/web/WebTextDirection.h"
34 #include "public/web/WebViewClient.h" 35 #include "public/web/WebViewClient.h"
35 #include "web/WebViewImpl.h" 36 #include "web/WebViewImpl.h"
36 #include "wtf/CurrentTime.h" 37 #include "wtf/CurrentTime.h"
37 38
38 namespace blink { 39 namespace blink {
39 40
40 ValidationMessageClientImpl::ValidationMessageClientImpl(WebViewImpl& webView) 41 ValidationMessageClientImpl::ValidationMessageClientImpl(WebViewImpl& webView)
41 : m_webView(webView), 42 : m_webView(webView),
42 m_currentAnchor(nullptr), 43 m_currentAnchor(nullptr),
43 m_lastPageScaleFactor(1), 44 m_lastPageScaleFactor(1),
44 m_finishTime(0), 45 m_finishTime(0) {}
45 m_timer(this, &ValidationMessageClientImpl::checkAnchorStatus) {}
46 46
47 ValidationMessageClientImpl* ValidationMessageClientImpl::create( 47 ValidationMessageClientImpl* ValidationMessageClientImpl::create(
48 WebViewImpl& webView) { 48 WebViewImpl& webView) {
49 return new ValidationMessageClientImpl(webView); 49 return new ValidationMessageClientImpl(webView);
50 } 50 }
51 51
52 ValidationMessageClientImpl::~ValidationMessageClientImpl() {} 52 ValidationMessageClientImpl::~ValidationMessageClientImpl() {}
53 53
54 FrameView* ValidationMessageClientImpl::currentView() { 54 FrameView* ValidationMessageClientImpl::currentView() {
55 return m_currentAnchor->document().view(); 55 return m_currentAnchor->document().view();
(...skipping 27 matching lines...) Expand all
83 m_webView.client()->showValidationMessage( 83 m_webView.client()->showValidationMessage(
84 anchorInViewport, m_message, toWebTextDirection(messageDir), subMessage, 84 anchorInViewport, m_message, toWebTextDirection(messageDir), subMessage,
85 toWebTextDirection(subMessageDir)); 85 toWebTextDirection(subMessageDir));
86 86
87 m_finishTime = 87 m_finishTime =
88 monotonicallyIncreasingTime() + 88 monotonicallyIncreasingTime() +
89 std::max(minimumSecondToShowValidationMessage, 89 std::max(minimumSecondToShowValidationMessage,
90 (message.length() + subMessage.length()) * secondPerCharacter); 90 (message.length() + subMessage.length()) * secondPerCharacter);
91 // FIXME: We should invoke checkAnchorStatus actively when layout, scroll, 91 // FIXME: We should invoke checkAnchorStatus actively when layout, scroll,
92 // or page scale change happen. 92 // or page scale change happen.
93 m_timer.startRepeating(statusCheckInterval, BLINK_FROM_HERE); 93 m_timer = WTF::makeUnique<TaskRunnerTimer<ValidationMessageClientImpl>>(
94 TaskRunnerHelper::get(TaskType::UnspecedTimer, &anchor.document()), this,
95 &ValidationMessageClientImpl::checkAnchorStatus);
96 m_timer->startRepeating(statusCheckInterval, BLINK_FROM_HERE);
94 } 97 }
95 98
96 void ValidationMessageClientImpl::hideValidationMessage(const Element& anchor) { 99 void ValidationMessageClientImpl::hideValidationMessage(const Element& anchor) {
97 if (!m_currentAnchor || !isValidationMessageVisible(anchor)) 100 if (!m_currentAnchor || !isValidationMessageVisible(anchor))
98 return; 101 return;
99 m_timer.stop(); 102 m_timer = nullptr;
100 m_currentAnchor = nullptr; 103 m_currentAnchor = nullptr;
101 m_message = String(); 104 m_message = String();
102 m_finishTime = 0; 105 m_finishTime = 0;
103 m_webView.client()->hideValidationMessage(); 106 m_webView.client()->hideValidationMessage();
104 } 107 }
105 108
106 bool ValidationMessageClientImpl::isValidationMessageVisible( 109 bool ValidationMessageClientImpl::isValidationMessageVisible(
107 const Element& anchor) { 110 const Element& anchor) {
108 return m_currentAnchor == &anchor; 111 return m_currentAnchor == &anchor;
109 } 112 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 if (m_currentAnchor) 145 if (m_currentAnchor)
143 hideValidationMessage(*m_currentAnchor); 146 hideValidationMessage(*m_currentAnchor);
144 } 147 }
145 148
146 DEFINE_TRACE(ValidationMessageClientImpl) { 149 DEFINE_TRACE(ValidationMessageClientImpl) {
147 visitor->trace(m_currentAnchor); 150 visitor->trace(m_currentAnchor);
148 ValidationMessageClient::trace(visitor); 151 ValidationMessageClient::trace(visitor);
149 } 152 }
150 153
151 } // namespace blink 154 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/ValidationMessageClientImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698