OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All Rights Reserved. | 2 * Copyright (C) 2011 Google Inc. All Rights Reserved. |
3 * Copyright (C) 2012 Apple Inc. All rights reserved. | 3 * Copyright (C) 2012 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 } | 202 } |
203 | 203 |
204 HTMLMapElement* TreeScope::getImageMap(const String& url) const | 204 HTMLMapElement* TreeScope::getImageMap(const String& url) const |
205 { | 205 { |
206 if (url.isNull()) | 206 if (url.isNull()) |
207 return 0; | 207 return 0; |
208 if (!m_imageMapsByName) | 208 if (!m_imageMapsByName) |
209 return 0; | 209 return 0; |
210 size_t hashPos = url.find('#'); | 210 size_t hashPos = url.find('#'); |
211 String name = (hashPos == notFound ? url : url.substring(hashPos + 1)).impl(
); | 211 String name = (hashPos == notFound ? url : url.substring(hashPos + 1)).impl(
); |
212 if (rootNode()->document()->isHTMLDocument()) | 212 if (rootNode()->document().isHTMLDocument()) |
213 return toHTMLMapElement(m_imageMapsByName->getElementByLowercasedMapName
(AtomicString(name.lower()).impl(), this)); | 213 return toHTMLMapElement(m_imageMapsByName->getElementByLowercasedMapName
(AtomicString(name.lower()).impl(), this)); |
214 return toHTMLMapElement(m_imageMapsByName->getElementByMapName(AtomicString(
name).impl(), this)); | 214 return toHTMLMapElement(m_imageMapsByName->getElementByMapName(AtomicString(
name).impl(), this)); |
215 } | 215 } |
216 | 216 |
217 Node* nodeFromPoint(Document* document, int x, int y, LayoutPoint* localPoint) | 217 Node* nodeFromPoint(Document* document, int x, int y, LayoutPoint* localPoint) |
218 { | 218 { |
219 Frame* frame = document->frame(); | 219 Frame* frame = document->frame(); |
220 | 220 |
221 if (!frame) | 221 if (!frame) |
222 return 0; | 222 return 0; |
(...skipping 12 matching lines...) Expand all Loading... |
235 document->renderView()->hitTest(request, result); | 235 document->renderView()->hitTest(request, result); |
236 | 236 |
237 if (localPoint) | 237 if (localPoint) |
238 *localPoint = result.localPoint(); | 238 *localPoint = result.localPoint(); |
239 | 239 |
240 return result.innerNode(); | 240 return result.innerNode(); |
241 } | 241 } |
242 | 242 |
243 Element* TreeScope::elementFromPoint(int x, int y) const | 243 Element* TreeScope::elementFromPoint(int x, int y) const |
244 { | 244 { |
245 Node* node = nodeFromPoint(rootNode()->document(), x, y); | 245 Node* node = nodeFromPoint(&rootNode()->document(), x, y); |
246 if (node && node->isTextNode()) | 246 if (node && node->isTextNode()) |
247 node = node->parentNode(); | 247 node = node->parentNode(); |
248 ASSERT(!node || node->isElementNode() || node->isShadowRoot()); | 248 ASSERT(!node || node->isElementNode() || node->isShadowRoot()); |
249 node = ancestorInThisScope(node); | 249 node = ancestorInThisScope(node); |
250 if (!node || !node->isElementNode()) | 250 if (!node || !node->isElementNode()) |
251 return 0; | 251 return 0; |
252 return toElement(node); | 252 return toElement(node); |
253 } | 253 } |
254 | 254 |
255 void TreeScope::addLabel(const AtomicString& forAttributeValue, HTMLLabelElement
* element) | 255 void TreeScope::addLabel(const AtomicString& forAttributeValue, HTMLLabelElement
* element) |
(...skipping 24 matching lines...) Expand all Loading... |
280 addLabel(forValue, label); | 280 addLabel(forValue, label); |
281 } | 281 } |
282 } | 282 } |
283 } | 283 } |
284 | 284 |
285 return toHTMLLabelElement(m_labelsByForAttribute->getElementByLabelForAttrib
ute(forAttributeValue.impl(), this)); | 285 return toHTMLLabelElement(m_labelsByForAttribute->getElementByLabelForAttrib
ute(forAttributeValue.impl(), this)); |
286 } | 286 } |
287 | 287 |
288 DOMSelection* TreeScope::getSelection() const | 288 DOMSelection* TreeScope::getSelection() const |
289 { | 289 { |
290 if (!rootNode()->document()->frame()) | 290 if (!rootNode()->document().frame()) |
291 return 0; | 291 return 0; |
292 | 292 |
293 if (m_selection) | 293 if (m_selection) |
294 return m_selection.get(); | 294 return m_selection.get(); |
295 | 295 |
296 // FIXME: The correct selection in Shadow DOM requires that Position can hav
e a ShadowRoot | 296 // FIXME: The correct selection in Shadow DOM requires that Position can hav
e a ShadowRoot |
297 // as a container. | 297 // as a container. |
298 // See https://bugs.webkit.org/show_bug.cgi?id=82697 | 298 // See https://bugs.webkit.org/show_bug.cgi?id=82697 |
299 m_selection = DOMSelection::create(this); | 299 m_selection = DOMSelection::create(this); |
300 return m_selection.get(); | 300 return m_selection.get(); |
301 } | 301 } |
302 | 302 |
303 Element* TreeScope::findAnchor(const String& name) | 303 Element* TreeScope::findAnchor(const String& name) |
304 { | 304 { |
305 if (name.isEmpty()) | 305 if (name.isEmpty()) |
306 return 0; | 306 return 0; |
307 if (Element* element = getElementById(name)) | 307 if (Element* element = getElementById(name)) |
308 return element; | 308 return element; |
309 for (Element* element = ElementTraversal::firstWithin(rootNode()); element;
element = ElementTraversal::next(element)) { | 309 for (Element* element = ElementTraversal::firstWithin(rootNode()); element;
element = ElementTraversal::next(element)) { |
310 if (isHTMLAnchorElement(element)) { | 310 if (isHTMLAnchorElement(element)) { |
311 HTMLAnchorElement* anchor = toHTMLAnchorElement(element); | 311 HTMLAnchorElement* anchor = toHTMLAnchorElement(element); |
312 if (rootNode()->document()->inQuirksMode()) { | 312 if (rootNode()->document().inQuirksMode()) { |
313 // Quirks mode, case insensitive comparison of names. | 313 // Quirks mode, case insensitive comparison of names. |
314 if (equalIgnoringCase(anchor->name(), name)) | 314 if (equalIgnoringCase(anchor->name(), name)) |
315 return anchor; | 315 return anchor; |
316 } else { | 316 } else { |
317 // Strict mode, names need to match exactly. | 317 // Strict mode, names need to match exactly. |
318 if (anchor->name() == name) | 318 if (anchor->name() == name) |
319 return anchor; | 319 return anchor; |
320 } | 320 } |
321 } | 321 } |
322 } | 322 } |
(...skipping 20 matching lines...) Expand all Loading... |
343 { | 343 { |
344 for (; focusedFrame; focusedFrame = focusedFrame->tree()->parent()) { | 344 for (; focusedFrame; focusedFrame = focusedFrame->tree()->parent()) { |
345 if (focusedFrame->tree()->parent() == currentFrame) | 345 if (focusedFrame->tree()->parent() == currentFrame) |
346 return focusedFrame->ownerElement(); | 346 return focusedFrame->ownerElement(); |
347 } | 347 } |
348 return 0; | 348 return 0; |
349 } | 349 } |
350 | 350 |
351 Element* TreeScope::adjustedFocusedElement() | 351 Element* TreeScope::adjustedFocusedElement() |
352 { | 352 { |
353 Document* document = rootNode()->document(); | 353 Document& document = rootNode()->document(); |
354 Element* element = document->focusedElement(); | 354 Element* element = document.focusedElement(); |
355 if (!element && document->page()) | 355 if (!element && document.page()) |
356 element = focusedFrameOwnerElement(document->page()->focusController().f
ocusedFrame(), document->frame()); | 356 element = focusedFrameOwnerElement(document.page()->focusController().fo
cusedFrame(), document.frame()); |
357 if (!element) | 357 if (!element) |
358 return 0; | 358 return 0; |
359 Vector<Node*> targetStack; | 359 Vector<Node*> targetStack; |
360 for (EventPathWalker walker(element); walker.node(); walker.moveToParent())
{ | 360 for (EventPathWalker walker(element); walker.node(); walker.moveToParent())
{ |
361 Node* node = walker.node(); | 361 Node* node = walker.node(); |
362 if (targetStack.isEmpty()) | 362 if (targetStack.isEmpty()) |
363 targetStack.append(node); | 363 targetStack.append(node); |
364 else if (walker.isVisitingInsertionPointInReprojection()) | 364 else if (walker.isVisitingInsertionPointInReprojection()) |
365 targetStack.append(targetStack.last()); | 365 targetStack.append(targetStack.last()); |
366 if (node == rootNode()) { | 366 if (node == rootNode()) { |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 result = element; | 498 result = element; |
499 for (ShadowRoot* shadowRoot = element->youngestShadowRoot(); shadowRoot;
shadowRoot = shadowRoot->olderShadowRoot()) { | 499 for (ShadowRoot* shadowRoot = element->youngestShadowRoot(); shadowRoot;
shadowRoot = shadowRoot->olderShadowRoot()) { |
500 if (Element* shadowResult = shadowRoot->getElementByAccessKey(key)) | 500 if (Element* shadowResult = shadowRoot->getElementByAccessKey(key)) |
501 result = shadowResult; | 501 result = shadowResult; |
502 } | 502 } |
503 } | 503 } |
504 return result; | 504 return result; |
505 } | 505 } |
506 | 506 |
507 } // namespace WebCore | 507 } // namespace WebCore |
OLD | NEW |