| OLD | NEW |
| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } | 57 } |
| 58 | 58 |
| 59 ValidationMessageClientImpl::~ValidationMessageClientImpl() | 59 ValidationMessageClientImpl::~ValidationMessageClientImpl() |
| 60 { | 60 { |
| 61 if (m_currentAnchor) | 61 if (m_currentAnchor) |
| 62 hideValidationMessage(*m_currentAnchor); | 62 hideValidationMessage(*m_currentAnchor); |
| 63 } | 63 } |
| 64 | 64 |
| 65 FrameView* ValidationMessageClientImpl::currentView() | 65 FrameView* ValidationMessageClientImpl::currentView() |
| 66 { | 66 { |
| 67 return m_currentAnchor->document()->view(); | 67 return m_currentAnchor->document().view(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void ValidationMessageClientImpl::showValidationMessage(const Element& anchor, c
onst String& message) | 70 void ValidationMessageClientImpl::showValidationMessage(const Element& anchor, c
onst String& message) |
| 71 { | 71 { |
| 72 if (message.isEmpty()) { | 72 if (message.isEmpty()) { |
| 73 hideValidationMessage(anchor); | 73 hideValidationMessage(anchor); |
| 74 return; | 74 return; |
| 75 } | 75 } |
| 76 if (!anchor.renderBox()) | 76 if (!anchor.renderBox()) |
| 77 return; | 77 return; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 107 m_client.hideValidationMessage(); | 107 m_client.hideValidationMessage(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 bool ValidationMessageClientImpl::isValidationMessageVisible(const Element& anch
or) | 110 bool ValidationMessageClientImpl::isValidationMessageVisible(const Element& anch
or) |
| 111 { | 111 { |
| 112 return m_currentAnchor == &anchor; | 112 return m_currentAnchor == &anchor; |
| 113 } | 113 } |
| 114 | 114 |
| 115 void ValidationMessageClientImpl::documentDetached(const Document& document) | 115 void ValidationMessageClientImpl::documentDetached(const Document& document) |
| 116 { | 116 { |
| 117 if (m_currentAnchor && m_currentAnchor->document() == &document) | 117 if (m_currentAnchor && &m_currentAnchor->document() == &document) |
| 118 hideValidationMessage(*m_currentAnchor); | 118 hideValidationMessage(*m_currentAnchor); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void ValidationMessageClientImpl::checkAnchorStatus(Timer<ValidationMessageClien
tImpl>*) | 121 void ValidationMessageClientImpl::checkAnchorStatus(Timer<ValidationMessageClien
tImpl>*) |
| 122 { | 122 { |
| 123 ASSERT(m_currentAnchor); | 123 ASSERT(m_currentAnchor); |
| 124 if (monotonicallyIncreasingTime() >= m_finishTime || !currentView()) { | 124 if (monotonicallyIncreasingTime() >= m_finishTime || !currentView()) { |
| 125 hideValidationMessage(*m_currentAnchor); | 125 hideValidationMessage(*m_currentAnchor); |
| 126 return; | 126 return; |
| 127 } | 127 } |
| 128 | 128 |
| 129 // Check the visibility of the element. | 129 // Check the visibility of the element. |
| 130 // FIXME: Can we check invisibility by scrollable non-frame elements? | 130 // FIXME: Can we check invisibility by scrollable non-frame elements? |
| 131 IntRect newAnchorRect = currentView()->contentsToRootView(m_currentAnchor->p
ixelSnappedBoundingBox()); | 131 IntRect newAnchorRect = currentView()->contentsToRootView(m_currentAnchor->p
ixelSnappedBoundingBox()); |
| 132 newAnchorRect = intersection(currentView()->convertToRootView(currentView()-
>boundsRect()), newAnchorRect); | 132 newAnchorRect = intersection(currentView()->convertToRootView(currentView()-
>boundsRect()), newAnchorRect); |
| 133 if (newAnchorRect.isEmpty()) { | 133 if (newAnchorRect.isEmpty()) { |
| 134 hideValidationMessage(*m_currentAnchor); | 134 hideValidationMessage(*m_currentAnchor); |
| 135 return; | 135 return; |
| 136 } | 136 } |
| 137 | 137 |
| 138 IntRect newAnchorRectInScreen = currentView()->hostWindow()->rootViewToScree
n(newAnchorRect); | 138 IntRect newAnchorRectInScreen = currentView()->hostWindow()->rootViewToScree
n(newAnchorRect); |
| 139 if (newAnchorRectInScreen == m_lastAnchorRectInScreen && m_webView.pageScale
Factor() == m_lastPageScaleFactor) | 139 if (newAnchorRectInScreen == m_lastAnchorRectInScreen && m_webView.pageScale
Factor() == m_lastPageScaleFactor) |
| 140 return; | 140 return; |
| 141 m_lastAnchorRectInScreen = newAnchorRectInScreen; | 141 m_lastAnchorRectInScreen = newAnchorRectInScreen; |
| 142 m_lastPageScaleFactor = m_webView.pageScaleFactor(); | 142 m_lastPageScaleFactor = m_webView.pageScaleFactor(); |
| 143 m_client.moveValidationMessage(newAnchorRect); | 143 m_client.moveValidationMessage(newAnchorRect); |
| 144 } | 144 } |
| 145 | 145 |
| 146 } | 146 } |
| OLD | NEW |