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

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

Issue 2215333002: Fix element visibility check for validation bubbles and SELECT popups. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename to visibleBoundsInVisualViewport(), etc. Created 4 years, 4 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
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
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 111 }
112 112
113 void ValidationMessageClientImpl::checkAnchorStatus(TimerBase*) 113 void ValidationMessageClientImpl::checkAnchorStatus(TimerBase*)
114 { 114 {
115 DCHECK(m_currentAnchor); 115 DCHECK(m_currentAnchor);
116 if (monotonicallyIncreasingTime() >= m_finishTime || !currentView()) { 116 if (monotonicallyIncreasingTime() >= m_finishTime || !currentView()) {
117 hideValidationMessage(*m_currentAnchor); 117 hideValidationMessage(*m_currentAnchor);
118 return; 118 return;
119 } 119 }
120 120
121 // Check the visibility of the element. 121 IntRect newAnchorRectInViewport = m_currentAnchor->visibleBoundsInVisualView port();
122 // FIXME: Can we check invisibility by scrollable non-frame elements?
123 IntRect newAnchorRectInViewport = currentView()->contentsToViewport(m_curren tAnchor->pixelSnappedBoundingBox());
124
125 // FIXME: This intersection eliminates the part of the rect outside the root view.
126 // If this is meant as a visiblity test, intersecting it against the viewpor t rect
127 // likely makes more sense.
128 newAnchorRectInViewport = intersection(currentView()->convertToRootFrame(cur rentView()->boundsRect()), newAnchorRectInViewport);
129 if (newAnchorRectInViewport.isEmpty()) { 122 if (newAnchorRectInViewport.isEmpty()) {
130 hideValidationMessage(*m_currentAnchor); 123 hideValidationMessage(*m_currentAnchor);
131 return; 124 return;
132 } 125 }
133 126
134 IntRect newAnchorRectInViewportInScreen = currentView()->getHostWindow()->vi ewportToScreen(newAnchorRectInViewport, currentView()); 127 IntRect newAnchorRectInViewportInScreen = currentView()->getHostWindow()->vi ewportToScreen(newAnchorRectInViewport, currentView());
135 if (newAnchorRectInViewportInScreen == m_lastAnchorRectInScreen && m_webView .pageScaleFactor() == m_lastPageScaleFactor) 128 if (newAnchorRectInViewportInScreen == m_lastAnchorRectInScreen && m_webView .pageScaleFactor() == m_lastPageScaleFactor)
136 return; 129 return;
137 m_lastAnchorRectInScreen = newAnchorRectInViewportInScreen; 130 m_lastAnchorRectInScreen = newAnchorRectInViewportInScreen;
138 m_lastPageScaleFactor = m_webView.pageScaleFactor(); 131 m_lastPageScaleFactor = m_webView.pageScaleFactor();
139 m_webView.client()->moveValidationMessage(newAnchorRectInViewport); 132 m_webView.client()->moveValidationMessage(newAnchorRectInViewport);
140 } 133 }
141 134
142 void ValidationMessageClientImpl::willBeDestroyed() 135 void ValidationMessageClientImpl::willBeDestroyed()
143 { 136 {
144 if (m_currentAnchor) 137 if (m_currentAnchor)
145 hideValidationMessage(*m_currentAnchor); 138 hideValidationMessage(*m_currentAnchor);
146 } 139 }
147 140
148 DEFINE_TRACE(ValidationMessageClientImpl) 141 DEFINE_TRACE(ValidationMessageClientImpl)
149 { 142 {
150 visitor->trace(m_currentAnchor); 143 visitor->trace(m_currentAnchor);
151 ValidationMessageClient::trace(visitor); 144 ValidationMessageClient::trace(visitor);
152 } 145 }
153 146
154 } // namespace blink 147 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/PopupMenuImpl.cpp ('k') | third_party/WebKit/Source/web/tests/VisualViewportTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698