OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "webkit/glue/dom_operations.h" | 5 #include "webkit/glue/dom_operations.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | 12 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" |
13 #include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h" | 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAnimationControlle
r.h" | |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" |
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeCollection.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeCollection.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
23 | 22 |
24 using WebKit::WebAnimationController; | |
25 using WebKit::WebDocument; | 23 using WebKit::WebDocument; |
26 using WebKit::WebElement; | 24 using WebKit::WebElement; |
27 using WebKit::WebFrame; | 25 using WebKit::WebFrame; |
28 using WebKit::WebInputElement; | 26 using WebKit::WebInputElement; |
29 using WebKit::WebNode; | 27 using WebKit::WebNode; |
30 using WebKit::WebNodeCollection; | 28 using WebKit::WebNodeCollection; |
31 using WebKit::WebNodeList; | 29 using WebKit::WebNodeList; |
32 using WebKit::WebString; | 30 using WebKit::WebString; |
33 using WebKit::WebVector; | 31 using WebKit::WebVector; |
34 using WebKit::WebView; | 32 using WebKit::WebView; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 for (std::set<GURL>::iterator it = frames_set.begin(); | 230 for (std::set<GURL>::iterator it = frames_set.begin(); |
233 it != frames_set.end(); ++it) { | 231 it != frames_set.end(); ++it) { |
234 // Append unique frame source to savable frame list. | 232 // Append unique frame source to savable frame list. |
235 if (resources_set.find(*it) == resources_set.end()) | 233 if (resources_set.find(*it) == resources_set.end()) |
236 result->frames_list->push_back(*it); | 234 result->frames_list->push_back(*it); |
237 } | 235 } |
238 | 236 |
239 return true; | 237 return true; |
240 } | 238 } |
241 | 239 |
242 bool PauseAnimationAtTimeOnElementWithId(WebView* view, | |
243 const std::string& animation_name, | |
244 double time, | |
245 const std::string& element_id) { | |
246 WebFrame* web_frame = view->mainFrame(); | |
247 if (!web_frame) | |
248 return false; | |
249 | |
250 WebAnimationController* controller = web_frame->animationController(); | |
251 if (!controller) | |
252 return false; | |
253 | |
254 WebElement element = | |
255 web_frame->document().getElementById(WebString::fromUTF8(element_id)); | |
256 if (element.isNull()) | |
257 return false; | |
258 return controller->pauseAnimationAtTime(element, | |
259 WebString::fromUTF8(animation_name), | |
260 time); | |
261 } | |
262 | |
263 bool PauseTransitionAtTimeOnElementWithId(WebView* view, | |
264 const std::string& property_name, | |
265 double time, | |
266 const std::string& element_id) { | |
267 WebFrame* web_frame = view->mainFrame(); | |
268 if (!web_frame) | |
269 return false; | |
270 | |
271 WebAnimationController* controller = web_frame->animationController(); | |
272 if (!controller) | |
273 return false; | |
274 | |
275 WebElement element = | |
276 web_frame->document().getElementById(WebString::fromUTF8(element_id)); | |
277 if (element.isNull()) | |
278 return false; | |
279 return controller->pauseTransitionAtTime(element, | |
280 WebString::fromUTF8(property_name), | |
281 time); | |
282 } | |
283 | |
284 bool ElementDoesAutoCompleteForElementWithId(WebView* view, | 240 bool ElementDoesAutoCompleteForElementWithId(WebView* view, |
285 const std::string& element_id) { | 241 const std::string& element_id) { |
286 WebFrame* web_frame = view->mainFrame(); | 242 WebFrame* web_frame = view->mainFrame(); |
287 if (!web_frame) | 243 if (!web_frame) |
288 return false; | 244 return false; |
289 | 245 |
290 WebElement element = web_frame->document().getElementById( | 246 WebElement element = web_frame->document().getElementById( |
291 WebString::fromUTF8(element_id)); | 247 WebString::fromUTF8(element_id)); |
292 if (element.isNull() || !element.hasHTMLTagName("input")) | 248 if (element.isNull() || !element.hasHTMLTagName("input")) |
293 return false; | 249 return false; |
294 | 250 |
295 WebInputElement input_element = element.to<WebInputElement>(); | 251 WebInputElement input_element = element.to<WebInputElement>(); |
296 return input_element.autoComplete(); | 252 return input_element.autoComplete(); |
297 } | 253 } |
298 | 254 |
299 int NumberOfActiveAnimations(WebView* view) { | |
300 WebFrame* web_frame = view->mainFrame(); | |
301 if (!web_frame) | |
302 return -1; | |
303 | |
304 WebAnimationController* controller = web_frame->animationController(); | |
305 if (!controller) | |
306 return -1; | |
307 | |
308 return controller->numberOfActiveAnimations(); | |
309 } | |
310 | |
311 void GetMetaElementsWithAttribute(WebDocument* document, | 255 void GetMetaElementsWithAttribute(WebDocument* document, |
312 const string16& attribute_name, | 256 const string16& attribute_name, |
313 const string16& attribute_value, | 257 const string16& attribute_value, |
314 std::vector<WebElement>* meta_elements) { | 258 std::vector<WebElement>* meta_elements) { |
315 DCHECK(document); | 259 DCHECK(document); |
316 DCHECK(meta_elements); | 260 DCHECK(meta_elements); |
317 meta_elements->clear(); | 261 meta_elements->clear(); |
318 WebElement head = document->head(); | 262 WebElement head = document->head(); |
319 if (head.isNull() || !head.hasChildNodes()) | 263 if (head.isNull() || !head.hasChildNodes()) |
320 return; | 264 return; |
321 | 265 |
322 WebNodeList children = head.childNodes(); | 266 WebNodeList children = head.childNodes(); |
323 for (size_t i = 0; i < children.length(); ++i) { | 267 for (size_t i = 0; i < children.length(); ++i) { |
324 WebNode node = children.item(i); | 268 WebNode node = children.item(i); |
325 if (!node.isElementNode()) | 269 if (!node.isElementNode()) |
326 continue; | 270 continue; |
327 WebElement element = node.to<WebElement>(); | 271 WebElement element = node.to<WebElement>(); |
328 if (!element.hasTagName("meta")) | 272 if (!element.hasTagName("meta")) |
329 continue; | 273 continue; |
330 WebString value = element.getAttribute(attribute_name); | 274 WebString value = element.getAttribute(attribute_name); |
331 if (value.isNull() || value != attribute_value) | 275 if (value.isNull() || value != attribute_value) |
332 continue; | 276 continue; |
333 meta_elements->push_back(element); | 277 meta_elements->push_back(element); |
334 } | 278 } |
335 } | 279 } |
336 | 280 |
337 } // webkit_glue | 281 } // webkit_glue |
OLD | NEW |