OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Peter Kelly (pmk@post.com) | 4 * (C) 2001 Peter Kelly (pmk@post.com) |
5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
6 * (C) 2007 David Smith (catfish.man@gmail.com) | 6 * (C) 2007 David Smith (catfish.man@gmail.com) |
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. | 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. |
8 * (C) 2007 Eric Seidel (eric@webkit.org) | 8 * (C) 2007 Eric Seidel (eric@webkit.org) |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 ASSERT(!hasPendingResources()); | 233 ASSERT(!hasPendingResources()); |
234 } | 234 } |
235 } | 235 } |
236 | 236 |
237 inline ElementRareData* Element::elementRareData() const | 237 inline ElementRareData* Element::elementRareData() const |
238 { | 238 { |
239 ASSERT(hasRareData()); | 239 ASSERT(hasRareData()); |
240 return static_cast<ElementRareData*>(rareData()); | 240 return static_cast<ElementRareData*>(rareData()); |
241 } | 241 } |
242 | 242 |
243 inline ElementRareData* Element::ensureElementRareData() | 243 inline ElementRareData& Element::ensureElementRareData() |
244 { | 244 { |
245 return static_cast<ElementRareData*>(ensureRareData()); | 245 return static_cast<ElementRareData&>(ensureRareData()); |
246 } | 246 } |
247 | 247 |
248 void Element::clearTabIndexExplicitlyIfNeeded() | 248 void Element::clearTabIndexExplicitlyIfNeeded() |
249 { | 249 { |
250 if (hasRareData()) | 250 if (hasRareData()) |
251 elementRareData()->clearTabIndexExplicitly(); | 251 elementRareData()->clearTabIndexExplicitly(); |
252 } | 252 } |
253 | 253 |
254 void Element::setTabIndexExplicitly(short tabIndex) | 254 void Element::setTabIndexExplicitly(short tabIndex) |
255 { | 255 { |
256 ensureElementRareData()->setTabIndexExplicitly(tabIndex); | 256 ensureElementRareData().setTabIndexExplicitly(tabIndex); |
257 } | 257 } |
258 | 258 |
259 bool Element::supportsFocus() const | 259 bool Element::supportsFocus() const |
260 { | 260 { |
261 return hasRareData() && elementRareData()->tabIndexSetExplicitly(); | 261 return hasRareData() && elementRareData()->tabIndexSetExplicitly(); |
262 } | 262 } |
263 | 263 |
264 short Element::tabIndex() const | 264 short Element::tabIndex() const |
265 { | 265 { |
266 return hasRareData() ? elementRareData()->tabIndex() : 0; | 266 return hasRareData() ? elementRareData()->tabIndex() : 0; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 void Element::setBooleanAttribute(const QualifiedName& name, bool value) | 372 void Element::setBooleanAttribute(const QualifiedName& name, bool value) |
373 { | 373 { |
374 if (value) | 374 if (value) |
375 setAttribute(name, emptyAtom); | 375 setAttribute(name, emptyAtom); |
376 else | 376 else |
377 removeAttribute(name); | 377 removeAttribute(name); |
378 } | 378 } |
379 | 379 |
380 NamedNodeMap* Element::attributes() const | 380 NamedNodeMap* Element::attributes() const |
381 { | 381 { |
382 ElementRareData* rareData = const_cast<Element*>(this)->ensureElementRareDat
a(); | 382 ElementRareData& rareData = const_cast<Element*>(this)->ensureElementRareDat
a(); |
383 if (NamedNodeMap* attributeMap = rareData->attributeMap()) | 383 if (NamedNodeMap* attributeMap = rareData.attributeMap()) |
384 return attributeMap; | 384 return attributeMap; |
385 | 385 |
386 rareData->setAttributeMap(NamedNodeMap::create(const_cast<Element*>(this))); | 386 rareData.setAttributeMap(NamedNodeMap::create(const_cast<Element*>(this))); |
387 return rareData->attributeMap(); | 387 return rareData.attributeMap(); |
388 } | 388 } |
389 | 389 |
390 ActiveAnimations* Element::activeAnimations() const | 390 ActiveAnimations* Element::activeAnimations() const |
391 { | 391 { |
392 if (hasActiveAnimations()) | 392 if (hasActiveAnimations()) |
393 return elementRareData()->activeAnimations(); | 393 return elementRareData()->activeAnimations(); |
394 return 0; | 394 return 0; |
395 } | 395 } |
396 | 396 |
397 ActiveAnimations* Element::ensureActiveAnimations() | 397 ActiveAnimations* Element::ensureActiveAnimations() |
398 { | 398 { |
399 ElementRareData* rareData = ensureElementRareData(); | 399 ElementRareData& rareData = ensureElementRareData(); |
400 if (!elementRareData()->activeAnimations()) | 400 if (!rareData.activeAnimations()) |
401 rareData->setActiveAnimations(adoptPtr(new ActiveAnimations())); | 401 rareData.setActiveAnimations(adoptPtr(new ActiveAnimations())); |
402 return rareData->activeAnimations(); | 402 return rareData.activeAnimations(); |
403 } | 403 } |
404 | 404 |
405 bool Element::hasActiveAnimations() const | 405 bool Element::hasActiveAnimations() const |
406 { | 406 { |
407 if (!RuntimeEnabledFeatures::webAnimationsEnabled()) | 407 if (!RuntimeEnabledFeatures::webAnimationsEnabled()) |
408 return false; | 408 return false; |
409 | 409 |
410 if (!hasRareData()) | 410 if (!hasRareData()) |
411 return false; | 411 return false; |
412 | 412 |
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1672 } | 1672 } |
1673 } | 1673 } |
1674 | 1674 |
1675 ElementShadow* Element::shadow() const | 1675 ElementShadow* Element::shadow() const |
1676 { | 1676 { |
1677 return hasRareData() ? elementRareData()->shadow() : 0; | 1677 return hasRareData() ? elementRareData()->shadow() : 0; |
1678 } | 1678 } |
1679 | 1679 |
1680 ElementShadow* Element::ensureShadow() | 1680 ElementShadow* Element::ensureShadow() |
1681 { | 1681 { |
1682 return ensureElementRareData()->ensureShadow(); | 1682 return ensureElementRareData().ensureShadow(); |
1683 } | 1683 } |
1684 | 1684 |
1685 void Element::didAffectSelector(AffectedSelectorMask mask) | 1685 void Element::didAffectSelector(AffectedSelectorMask mask) |
1686 { | 1686 { |
1687 setNeedsStyleRecalc(); | 1687 setNeedsStyleRecalc(); |
1688 if (ElementShadow* elementShadow = shadowOfParentForDistribution(this)) | 1688 if (ElementShadow* elementShadow = shadowOfParentForDistribution(this)) |
1689 elementShadow->didAffectSelector(mask); | 1689 elementShadow->didAffectSelector(mask); |
1690 } | 1690 } |
1691 | 1691 |
1692 PassRefPtr<ShadowRoot> Element::createShadowRoot(ExceptionState& es) | 1692 PassRefPtr<ShadowRoot> Element::createShadowRoot(ExceptionState& es) |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2122 // does not make sense to continue and update appearence. | 2122 // does not make sense to continue and update appearence. |
2123 protect = this; | 2123 protect = this; |
2124 if (!page->focusController().setFocusedElement(this, doc.frame(), direct
ion)) | 2124 if (!page->focusController().setFocusedElement(this, doc.frame(), direct
ion)) |
2125 return; | 2125 return; |
2126 } | 2126 } |
2127 | 2127 |
2128 // Setting the focused node above might have invalidated the layout due to s
cripts. | 2128 // Setting the focused node above might have invalidated the layout due to s
cripts. |
2129 doc.updateLayoutIgnorePendingStylesheets(); | 2129 doc.updateLayoutIgnorePendingStylesheets(); |
2130 | 2130 |
2131 if (!isFocusable()) { | 2131 if (!isFocusable()) { |
2132 ensureElementRareData()->setNeedsFocusAppearanceUpdateSoonAfterAttach(tr
ue); | 2132 ensureElementRareData().setNeedsFocusAppearanceUpdateSoonAfterAttach(tru
e); |
2133 return; | 2133 return; |
2134 } | 2134 } |
2135 | 2135 |
2136 cancelFocusAppearanceUpdate(); | 2136 cancelFocusAppearanceUpdate(); |
2137 updateFocusAppearance(restorePreviousSelection); | 2137 updateFocusAppearance(restorePreviousSelection); |
2138 } | 2138 } |
2139 | 2139 |
2140 void Element::updateFocusAppearance(bool /*restorePreviousSelection*/) | 2140 void Element::updateFocusAppearance(bool /*restorePreviousSelection*/) |
2141 { | 2141 { |
2142 if (isRootEditableElement()) { | 2142 if (isRootEditableElement()) { |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2288 | 2288 |
2289 LayoutSize Element::minimumSizeForResizing() const | 2289 LayoutSize Element::minimumSizeForResizing() const |
2290 { | 2290 { |
2291 return hasRareData() ? elementRareData()->minimumSizeForResizing() : default
MinimumSizeForResizing(); | 2291 return hasRareData() ? elementRareData()->minimumSizeForResizing() : default
MinimumSizeForResizing(); |
2292 } | 2292 } |
2293 | 2293 |
2294 void Element::setMinimumSizeForResizing(const LayoutSize& size) | 2294 void Element::setMinimumSizeForResizing(const LayoutSize& size) |
2295 { | 2295 { |
2296 if (!hasRareData() && size == defaultMinimumSizeForResizing()) | 2296 if (!hasRareData() && size == defaultMinimumSizeForResizing()) |
2297 return; | 2297 return; |
2298 ensureElementRareData()->setMinimumSizeForResizing(size); | 2298 ensureElementRareData().setMinimumSizeForResizing(size); |
2299 } | 2299 } |
2300 | 2300 |
2301 RenderStyle* Element::computedStyle(PseudoId pseudoElementSpecifier) | 2301 RenderStyle* Element::computedStyle(PseudoId pseudoElementSpecifier) |
2302 { | 2302 { |
2303 if (PseudoElement* element = pseudoElement(pseudoElementSpecifier)) | 2303 if (PseudoElement* element = pseudoElement(pseudoElementSpecifier)) |
2304 return element->computedStyle(); | 2304 return element->computedStyle(); |
2305 | 2305 |
2306 // FIXME: Find and use the renderer from the pseudo element instead of the a
ctual element so that the 'length' | 2306 // FIXME: Find and use the renderer from the pseudo element instead of the a
ctual element so that the 'length' |
2307 // properties, which are only known by the renderer because it did the layou
t, will be correct and so that the | 2307 // properties, which are only known by the renderer because it did the layou
t, will be correct and so that the |
2308 // values returned for the ":selection" pseudo-element will be correct. | 2308 // values returned for the ":selection" pseudo-element will be correct. |
2309 if (RenderStyle* usedStyle = renderStyle()) { | 2309 if (RenderStyle* usedStyle = renderStyle()) { |
2310 if (pseudoElementSpecifier) { | 2310 if (pseudoElementSpecifier) { |
2311 RenderStyle* cachedPseudoStyle = usedStyle->getCachedPseudoStyle(pse
udoElementSpecifier); | 2311 RenderStyle* cachedPseudoStyle = usedStyle->getCachedPseudoStyle(pse
udoElementSpecifier); |
2312 return cachedPseudoStyle ? cachedPseudoStyle : usedStyle; | 2312 return cachedPseudoStyle ? cachedPseudoStyle : usedStyle; |
2313 } else | 2313 } else |
2314 return usedStyle; | 2314 return usedStyle; |
2315 } | 2315 } |
2316 | 2316 |
2317 if (!confusingAndOftenMisusedAttached()) | 2317 if (!confusingAndOftenMisusedAttached()) |
2318 // FIXME: Try to do better than this. Ensure that styleForElement() work
s for elements that are not in the | 2318 // FIXME: Try to do better than this. Ensure that styleForElement() work
s for elements that are not in the |
2319 // document tree and figure out when to destroy the computed style for s
uch elements. | 2319 // document tree and figure out when to destroy the computed style for s
uch elements. |
2320 return 0; | 2320 return 0; |
2321 | 2321 |
2322 ElementRareData* data = ensureElementRareData(); | 2322 ElementRareData& rareData = ensureElementRareData(); |
2323 if (!data->computedStyle()) | 2323 if (!rareData.computedStyle()) |
2324 data->setComputedStyle(document().styleForElementIgnoringPendingStyleshe
ets(this)); | 2324 rareData.setComputedStyle(document().styleForElementIgnoringPendingStyle
sheets(this)); |
2325 return pseudoElementSpecifier ? data->computedStyle()->getCachedPseudoStyle(
pseudoElementSpecifier) : data->computedStyle(); | 2325 return pseudoElementSpecifier ? rareData.computedStyle()->getCachedPseudoSty
le(pseudoElementSpecifier) : rareData.computedStyle(); |
2326 } | 2326 } |
2327 | 2327 |
2328 void Element::setStyleAffectedByEmpty() | 2328 void Element::setStyleAffectedByEmpty() |
2329 { | 2329 { |
2330 ensureElementRareData()->setStyleAffectedByEmpty(true); | 2330 ensureElementRareData().setStyleAffectedByEmpty(true); |
2331 } | 2331 } |
2332 | 2332 |
2333 void Element::setChildrenAffectedByHover(bool value) | 2333 void Element::setChildrenAffectedByHover(bool value) |
2334 { | 2334 { |
2335 if (value || hasRareData()) | 2335 if (value || hasRareData()) |
2336 ensureElementRareData()->setChildrenAffectedByHover(value); | 2336 ensureElementRareData().setChildrenAffectedByHover(value); |
2337 } | 2337 } |
2338 | 2338 |
2339 void Element::setChildrenAffectedByActive(bool value) | 2339 void Element::setChildrenAffectedByActive(bool value) |
2340 { | 2340 { |
2341 if (value || hasRareData()) | 2341 if (value || hasRareData()) |
2342 ensureElementRareData()->setChildrenAffectedByActive(value); | 2342 ensureElementRareData().setChildrenAffectedByActive(value); |
2343 } | 2343 } |
2344 | 2344 |
2345 void Element::setChildrenAffectedByDrag(bool value) | 2345 void Element::setChildrenAffectedByDrag(bool value) |
2346 { | 2346 { |
2347 if (value || hasRareData()) | 2347 if (value || hasRareData()) |
2348 ensureElementRareData()->setChildrenAffectedByDrag(value); | 2348 ensureElementRareData().setChildrenAffectedByDrag(value); |
2349 } | 2349 } |
2350 | 2350 |
2351 void Element::setChildrenAffectedByFirstChildRules() | 2351 void Element::setChildrenAffectedByFirstChildRules() |
2352 { | 2352 { |
2353 ensureElementRareData()->setChildrenAffectedByFirstChildRules(true); | 2353 ensureElementRareData().setChildrenAffectedByFirstChildRules(true); |
2354 } | 2354 } |
2355 | 2355 |
2356 void Element::setChildrenAffectedByLastChildRules() | 2356 void Element::setChildrenAffectedByLastChildRules() |
2357 { | 2357 { |
2358 ensureElementRareData()->setChildrenAffectedByLastChildRules(true); | 2358 ensureElementRareData().setChildrenAffectedByLastChildRules(true); |
2359 } | 2359 } |
2360 | 2360 |
2361 void Element::setChildrenAffectedByDirectAdjacentRules() | 2361 void Element::setChildrenAffectedByDirectAdjacentRules() |
2362 { | 2362 { |
2363 ensureElementRareData()->setChildrenAffectedByDirectAdjacentRules(true); | 2363 ensureElementRareData().setChildrenAffectedByDirectAdjacentRules(true); |
2364 } | 2364 } |
2365 | 2365 |
2366 void Element::setChildrenAffectedByForwardPositionalRules() | 2366 void Element::setChildrenAffectedByForwardPositionalRules() |
2367 { | 2367 { |
2368 ensureElementRareData()->setChildrenAffectedByForwardPositionalRules(true); | 2368 ensureElementRareData().setChildrenAffectedByForwardPositionalRules(true); |
2369 } | 2369 } |
2370 | 2370 |
2371 void Element::setChildrenAffectedByBackwardPositionalRules() | 2371 void Element::setChildrenAffectedByBackwardPositionalRules() |
2372 { | 2372 { |
2373 ensureElementRareData()->setChildrenAffectedByBackwardPositionalRules(true); | 2373 ensureElementRareData().setChildrenAffectedByBackwardPositionalRules(true); |
2374 } | 2374 } |
2375 | 2375 |
2376 void Element::setChildIndex(unsigned index) | 2376 void Element::setChildIndex(unsigned index) |
2377 { | 2377 { |
2378 ElementRareData* rareData = ensureElementRareData(); | 2378 ElementRareData& rareData = ensureElementRareData(); |
2379 if (RenderStyle* style = renderStyle()) | 2379 if (RenderStyle* style = renderStyle()) |
2380 style->setUnique(); | 2380 style->setUnique(); |
2381 rareData->setChildIndex(index); | 2381 rareData.setChildIndex(index); |
2382 } | 2382 } |
2383 | 2383 |
2384 bool Element::hasFlagsSetDuringStylingOfChildren() const | 2384 bool Element::hasFlagsSetDuringStylingOfChildren() const |
2385 { | 2385 { |
2386 if (!hasRareData()) | 2386 if (!hasRareData()) |
2387 return false; | 2387 return false; |
2388 return rareDataChildrenAffectedByHover() | 2388 return rareDataChildrenAffectedByHover() |
2389 || rareDataChildrenAffectedByActive() | 2389 || rareDataChildrenAffectedByActive() |
2390 || rareDataChildrenAffectedByDrag() | 2390 || rareDataChildrenAffectedByDrag() |
2391 || rareDataChildrenAffectedByFirstChildRules() | 2391 || rareDataChildrenAffectedByFirstChildRules() |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2450 } | 2450 } |
2451 | 2451 |
2452 unsigned Element::rareDataChildIndex() const | 2452 unsigned Element::rareDataChildIndex() const |
2453 { | 2453 { |
2454 ASSERT(hasRareData()); | 2454 ASSERT(hasRareData()); |
2455 return elementRareData()->childIndex(); | 2455 return elementRareData()->childIndex(); |
2456 } | 2456 } |
2457 | 2457 |
2458 void Element::setIsInCanvasSubtree(bool isInCanvasSubtree) | 2458 void Element::setIsInCanvasSubtree(bool isInCanvasSubtree) |
2459 { | 2459 { |
2460 ensureElementRareData()->setIsInCanvasSubtree(isInCanvasSubtree); | 2460 ensureElementRareData().setIsInCanvasSubtree(isInCanvasSubtree); |
2461 } | 2461 } |
2462 | 2462 |
2463 bool Element::isInCanvasSubtree() const | 2463 bool Element::isInCanvasSubtree() const |
2464 { | 2464 { |
2465 return hasRareData() && elementRareData()->isInCanvasSubtree(); | 2465 return hasRareData() && elementRareData()->isInCanvasSubtree(); |
2466 } | 2466 } |
2467 | 2467 |
2468 void Element::setIsInsideRegion(bool value) | 2468 void Element::setIsInsideRegion(bool value) |
2469 { | 2469 { |
2470 if (value == isInsideRegion()) | 2470 if (value == isInsideRegion()) |
2471 return; | 2471 return; |
2472 | 2472 |
2473 ensureElementRareData()->setIsInsideRegion(value); | 2473 ensureElementRareData().setIsInsideRegion(value); |
2474 } | 2474 } |
2475 | 2475 |
2476 bool Element::isInsideRegion() const | 2476 bool Element::isInsideRegion() const |
2477 { | 2477 { |
2478 return hasRareData() ? elementRareData()->isInsideRegion() : false; | 2478 return hasRareData() ? elementRareData()->isInsideRegion() : false; |
2479 } | 2479 } |
2480 | 2480 |
2481 void Element::setRegionOversetState(RegionOversetState state) | 2481 void Element::setRegionOversetState(RegionOversetState state) |
2482 { | 2482 { |
2483 ensureElementRareData()->setRegionOversetState(state); | 2483 ensureElementRareData().setRegionOversetState(state); |
2484 } | 2484 } |
2485 | 2485 |
2486 RegionOversetState Element::regionOversetState() const | 2486 RegionOversetState Element::regionOversetState() const |
2487 { | 2487 { |
2488 return hasRareData() ? elementRareData()->regionOversetState() : RegionUndef
ined; | 2488 return hasRareData() ? elementRareData()->regionOversetState() : RegionUndef
ined; |
2489 } | 2489 } |
2490 | 2490 |
2491 AtomicString Element::computeInheritedLanguage() const | 2491 AtomicString Element::computeInheritedLanguage() const |
2492 { | 2492 { |
2493 const Node* n = this; | 2493 const Node* n = this; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2582 | 2582 |
2583 void Element::createPseudoElement(PseudoId pseudoId) | 2583 void Element::createPseudoElement(PseudoId pseudoId) |
2584 { | 2584 { |
2585 ASSERT(needsPseudoElement(pseudoId)); | 2585 ASSERT(needsPseudoElement(pseudoId)); |
2586 ASSERT(!isPseudoElement()); | 2586 ASSERT(!isPseudoElement()); |
2587 RefPtr<PseudoElement> element = PseudoElement::create(this, pseudoId); | 2587 RefPtr<PseudoElement> element = PseudoElement::create(this, pseudoId); |
2588 if (pseudoId == BACKDROP) | 2588 if (pseudoId == BACKDROP) |
2589 document().addToTopLayer(element.get(), this); | 2589 document().addToTopLayer(element.get(), this); |
2590 element->attach(); | 2590 element->attach(); |
2591 | 2591 |
2592 ensureElementRareData()->setPseudoElement(pseudoId, element.release()); | 2592 ensureElementRareData().setPseudoElement(pseudoId, element.release()); |
2593 } | 2593 } |
2594 | 2594 |
2595 PseudoElement* Element::pseudoElement(PseudoId pseudoId) const | 2595 PseudoElement* Element::pseudoElement(PseudoId pseudoId) const |
2596 { | 2596 { |
2597 return hasRareData() ? elementRareData()->pseudoElement(pseudoId) : 0; | 2597 return hasRareData() ? elementRareData()->pseudoElement(pseudoId) : 0; |
2598 } | 2598 } |
2599 | 2599 |
2600 RenderObject* Element::pseudoElementRenderer(PseudoId pseudoId) const | 2600 RenderObject* Element::pseudoElementRenderer(PseudoId pseudoId) const |
2601 { | 2601 { |
2602 if (PseudoElement* element = pseudoElement(pseudoId)) | 2602 if (PseudoElement* element = pseudoElement(pseudoId)) |
2603 return element->renderer(); | 2603 return element->renderer(); |
2604 return 0; | 2604 return 0; |
2605 } | 2605 } |
2606 | 2606 |
2607 bool Element::webkitMatchesSelector(const String& selector, ExceptionState& es) | 2607 bool Element::webkitMatchesSelector(const String& selector, ExceptionState& es) |
2608 { | 2608 { |
2609 if (selector.isEmpty()) { | 2609 if (selector.isEmpty()) { |
2610 es.throwUninformativeAndGenericDOMException(SyntaxError); | 2610 es.throwUninformativeAndGenericDOMException(SyntaxError); |
2611 return false; | 2611 return false; |
2612 } | 2612 } |
2613 | 2613 |
2614 SelectorQuery* selectorQuery = document().selectorQueryCache()->add(selector
, document(), es); | 2614 SelectorQuery* selectorQuery = document().selectorQueryCache()->add(selector
, document(), es); |
2615 if (!selectorQuery) | 2615 if (!selectorQuery) |
2616 return false; | 2616 return false; |
2617 return selectorQuery->matches(this); | 2617 return selectorQuery->matches(this); |
2618 } | 2618 } |
2619 | 2619 |
2620 DOMTokenList* Element::classList() | 2620 DOMTokenList* Element::classList() |
2621 { | 2621 { |
2622 ElementRareData* data = ensureElementRareData(); | 2622 ElementRareData& rareData = ensureElementRareData(); |
2623 if (!data->classList()) | 2623 if (!rareData.classList()) |
2624 data->setClassList(ClassList::create(this)); | 2624 rareData.setClassList(ClassList::create(this)); |
2625 return data->classList(); | 2625 return rareData.classList(); |
2626 } | 2626 } |
2627 | 2627 |
2628 DOMStringMap* Element::dataset() | 2628 DOMStringMap* Element::dataset() |
2629 { | 2629 { |
2630 ElementRareData* data = ensureElementRareData(); | 2630 ElementRareData& rareData = ensureElementRareData(); |
2631 if (!data->dataset()) | 2631 if (!rareData.dataset()) |
2632 data->setDataset(DatasetDOMStringMap::create(this)); | 2632 rareData.setDataset(DatasetDOMStringMap::create(this)); |
2633 return data->dataset(); | 2633 return rareData.dataset(); |
2634 } | 2634 } |
2635 | 2635 |
2636 KURL Element::getURLAttribute(const QualifiedName& name) const | 2636 KURL Element::getURLAttribute(const QualifiedName& name) const |
2637 { | 2637 { |
2638 #if !ASSERT_DISABLED | 2638 #if !ASSERT_DISABLED |
2639 if (elementData()) { | 2639 if (elementData()) { |
2640 if (const Attribute* attribute = getAttributeItem(name)) | 2640 if (const Attribute* attribute = getAttributeItem(name)) |
2641 ASSERT(isURLAttribute(*attribute)); | 2641 ASSERT(isURLAttribute(*attribute)); |
2642 } | 2642 } |
2643 #endif | 2643 #endif |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2699 FullscreenElementStack::from(&document())->requestFullScreenForElement(this,
(flags | LEGACY_MOZILLA_REQUEST), FullscreenElementStack::EnforceIFrameAllowFul
lScreenRequirement); | 2699 FullscreenElementStack::from(&document())->requestFullScreenForElement(this,
(flags | LEGACY_MOZILLA_REQUEST), FullscreenElementStack::EnforceIFrameAllowFul
lScreenRequirement); |
2700 } | 2700 } |
2701 | 2701 |
2702 bool Element::containsFullScreenElement() const | 2702 bool Element::containsFullScreenElement() const |
2703 { | 2703 { |
2704 return hasRareData() && elementRareData()->containsFullScreenElement(); | 2704 return hasRareData() && elementRareData()->containsFullScreenElement(); |
2705 } | 2705 } |
2706 | 2706 |
2707 void Element::setContainsFullScreenElement(bool flag) | 2707 void Element::setContainsFullScreenElement(bool flag) |
2708 { | 2708 { |
2709 ensureElementRareData()->setContainsFullScreenElement(flag); | 2709 ensureElementRareData().setContainsFullScreenElement(flag); |
2710 setNeedsStyleRecalc(SubtreeStyleChange); | 2710 setNeedsStyleRecalc(SubtreeStyleChange); |
2711 } | 2711 } |
2712 | 2712 |
2713 static Element* parentCrossingFrameBoundaries(Element* element) | 2713 static Element* parentCrossingFrameBoundaries(Element* element) |
2714 { | 2714 { |
2715 ASSERT(element); | 2715 ASSERT(element); |
2716 return element->parentElement() ? element->parentElement() : element->docume
nt().ownerElement(); | 2716 return element->parentElement() ? element->parentElement() : element->docume
nt().ownerElement(); |
2717 } | 2717 } |
2718 | 2718 |
2719 void Element::setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(boo
l flag) | 2719 void Element::setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(boo
l flag) |
2720 { | 2720 { |
2721 Element* element = this; | 2721 Element* element = this; |
2722 while ((element = parentCrossingFrameBoundaries(element))) | 2722 while ((element = parentCrossingFrameBoundaries(element))) |
2723 element->setContainsFullScreenElement(flag); | 2723 element->setContainsFullScreenElement(flag); |
2724 } | 2724 } |
2725 | 2725 |
2726 bool Element::isInTopLayer() const | 2726 bool Element::isInTopLayer() const |
2727 { | 2727 { |
2728 return hasRareData() && elementRareData()->isInTopLayer(); | 2728 return hasRareData() && elementRareData()->isInTopLayer(); |
2729 } | 2729 } |
2730 | 2730 |
2731 void Element::setIsInTopLayer(bool inTopLayer) | 2731 void Element::setIsInTopLayer(bool inTopLayer) |
2732 { | 2732 { |
2733 if (isInTopLayer() == inTopLayer) | 2733 if (isInTopLayer() == inTopLayer) |
2734 return; | 2734 return; |
2735 ensureElementRareData()->setIsInTopLayer(inTopLayer); | 2735 ensureElementRareData().setIsInTopLayer(inTopLayer); |
2736 | 2736 |
2737 // We must ensure a reattach occurs so the renderer is inserted in the corre
ct sibling order under RenderView according to its | 2737 // We must ensure a reattach occurs so the renderer is inserted in the corre
ct sibling order under RenderView according to its |
2738 // top layer position, or in its usual place if not in the top layer. | 2738 // top layer position, or in its usual place if not in the top layer. |
2739 lazyReattachIfAttached(); | 2739 lazyReattachIfAttached(); |
2740 } | 2740 } |
2741 | 2741 |
2742 void Element::webkitRequestPointerLock() | 2742 void Element::webkitRequestPointerLock() |
2743 { | 2743 { |
2744 if (document().page()) | 2744 if (document().page()) |
2745 document().page()->pointerLockController().requestPointerLock(this); | 2745 document().page()->pointerLockController().requestPointerLock(this); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3006 } | 3006 } |
3007 | 3007 |
3008 PassRefPtr<HTMLCollection> Element::ensureCachedHTMLCollection(CollectionType ty
pe) | 3008 PassRefPtr<HTMLCollection> Element::ensureCachedHTMLCollection(CollectionType ty
pe) |
3009 { | 3009 { |
3010 if (HTMLCollection* collection = cachedHTMLCollection(type)) | 3010 if (HTMLCollection* collection = cachedHTMLCollection(type)) |
3011 return collection; | 3011 return collection; |
3012 | 3012 |
3013 RefPtr<HTMLCollection> collection; | 3013 RefPtr<HTMLCollection> collection; |
3014 if (type == TableRows) { | 3014 if (type == TableRows) { |
3015 ASSERT(hasTagName(tableTag)); | 3015 ASSERT(hasTagName(tableTag)); |
3016 return ensureRareData()->ensureNodeLists()->addCacheWithAtomicName<HTMLT
ableRowsCollection>(this, type); | 3016 return ensureRareData().ensureNodeLists()->addCacheWithAtomicName<HTMLTa
bleRowsCollection>(this, type); |
3017 } else if (type == SelectOptions) { | 3017 } else if (type == SelectOptions) { |
3018 ASSERT(hasTagName(selectTag)); | 3018 ASSERT(hasTagName(selectTag)); |
3019 return ensureRareData()->ensureNodeLists()->addCacheWithAtomicName<HTMLO
ptionsCollection>(this, type); | 3019 return ensureRareData().ensureNodeLists()->addCacheWithAtomicName<HTMLOp
tionsCollection>(this, type); |
3020 } else if (type == FormControls) { | 3020 } else if (type == FormControls) { |
3021 ASSERT(hasTagName(formTag) || hasTagName(fieldsetTag)); | 3021 ASSERT(hasTagName(formTag) || hasTagName(fieldsetTag)); |
3022 return ensureRareData()->ensureNodeLists()->addCacheWithAtomicName<HTMLF
ormControlsCollection>(this, type); | 3022 return ensureRareData().ensureNodeLists()->addCacheWithAtomicName<HTMLFo
rmControlsCollection>(this, type); |
3023 } | 3023 } |
3024 return ensureRareData()->ensureNodeLists()->addCacheWithAtomicName<HTMLColle
ction>(this, type); | 3024 return ensureRareData().ensureNodeLists()->addCacheWithAtomicName<HTMLCollec
tion>(this, type); |
3025 } | 3025 } |
3026 | 3026 |
3027 static void scheduleLayerUpdateCallback(Node* node) | 3027 static void scheduleLayerUpdateCallback(Node* node) |
3028 { | 3028 { |
3029 // Notify the renderer even is the styles are identical since it may need to | 3029 // Notify the renderer even is the styles are identical since it may need to |
3030 // create or destroy a RenderLayer. | 3030 // create or destroy a RenderLayer. |
3031 node->setNeedsStyleRecalc(LocalStyleChange, StyleChangeFromRenderer); | 3031 node->setNeedsStyleRecalc(LocalStyleChange, StyleChangeFromRenderer); |
3032 } | 3032 } |
3033 | 3033 |
3034 void Element::scheduleLayerUpdate() | 3034 void Element::scheduleLayerUpdate() |
(...skipping 11 matching lines...) Expand all Loading... |
3046 | 3046 |
3047 IntSize Element::savedLayerScrollOffset() const | 3047 IntSize Element::savedLayerScrollOffset() const |
3048 { | 3048 { |
3049 return hasRareData() ? elementRareData()->savedLayerScrollOffset() : IntSize
(); | 3049 return hasRareData() ? elementRareData()->savedLayerScrollOffset() : IntSize
(); |
3050 } | 3050 } |
3051 | 3051 |
3052 void Element::setSavedLayerScrollOffset(const IntSize& size) | 3052 void Element::setSavedLayerScrollOffset(const IntSize& size) |
3053 { | 3053 { |
3054 if (size.isZero() && !hasRareData()) | 3054 if (size.isZero() && !hasRareData()) |
3055 return; | 3055 return; |
3056 ensureElementRareData()->setSavedLayerScrollOffset(size); | 3056 ensureElementRareData().setSavedLayerScrollOffset(size); |
3057 } | 3057 } |
3058 | 3058 |
3059 PassRefPtr<Attr> Element::attrIfExists(const QualifiedName& name) | 3059 PassRefPtr<Attr> Element::attrIfExists(const QualifiedName& name) |
3060 { | 3060 { |
3061 if (AttrNodeList* attrNodeList = attrNodeListForElement(this)) | 3061 if (AttrNodeList* attrNodeList = attrNodeListForElement(this)) |
3062 return findAttrNodeInList(attrNodeList, name); | 3062 return findAttrNodeInList(attrNodeList, name); |
3063 return 0; | 3063 return 0; |
3064 } | 3064 } |
3065 | 3065 |
3066 PassRefPtr<Attr> Element::ensureAttr(const QualifiedName& name) | 3066 PassRefPtr<Attr> Element::ensureAttr(const QualifiedName& name) |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3183 if (!m_elementData) | 3183 if (!m_elementData) |
3184 m_elementData = UniqueElementData::create(); | 3184 m_elementData = UniqueElementData::create(); |
3185 else { | 3185 else { |
3186 ASSERT(!m_elementData->isUnique()); | 3186 ASSERT(!m_elementData->isUnique()); |
3187 m_elementData = static_cast<ShareableElementData*>(m_elementData.get())-
>makeUniqueCopy(); | 3187 m_elementData = static_cast<ShareableElementData*>(m_elementData.get())-
>makeUniqueCopy(); |
3188 } | 3188 } |
3189 } | 3189 } |
3190 | 3190 |
3191 InputMethodContext* Element::inputMethodContext() | 3191 InputMethodContext* Element::inputMethodContext() |
3192 { | 3192 { |
3193 return ensureElementRareData()->ensureInputMethodContext(toHTMLElement(this)
); | 3193 return ensureElementRareData().ensureInputMethodContext(toHTMLElement(this))
; |
3194 } | 3194 } |
3195 | 3195 |
3196 bool Element::hasPendingResources() const | 3196 bool Element::hasPendingResources() const |
3197 { | 3197 { |
3198 return hasRareData() && elementRareData()->hasPendingResources(); | 3198 return hasRareData() && elementRareData()->hasPendingResources(); |
3199 } | 3199 } |
3200 | 3200 |
3201 void Element::setHasPendingResources() | 3201 void Element::setHasPendingResources() |
3202 { | 3202 { |
3203 ensureElementRareData()->setHasPendingResources(true); | 3203 ensureElementRareData().setHasPendingResources(true); |
3204 } | 3204 } |
3205 | 3205 |
3206 void Element::clearHasPendingResources() | 3206 void Element::clearHasPendingResources() |
3207 { | 3207 { |
3208 ensureElementRareData()->setHasPendingResources(false); | 3208 ensureElementRareData().setHasPendingResources(false); |
3209 } | 3209 } |
3210 | 3210 |
3211 struct PresentationAttributeCacheKey { | 3211 struct PresentationAttributeCacheKey { |
3212 PresentationAttributeCacheKey() : tagName(0) { } | 3212 PresentationAttributeCacheKey() : tagName(0) { } |
3213 StringImpl* tagName; | 3213 StringImpl* tagName; |
3214 // Only the values need refcounting. | 3214 // Only the values need refcounting. |
3215 Vector<pair<StringImpl*, AtomicString>, 3> attributesAndValues; | 3215 Vector<pair<StringImpl*, AtomicString>, 3> attributesAndValues; |
3216 }; | 3216 }; |
3217 | 3217 |
3218 struct PresentationAttributeCacheEntry { | 3218 struct PresentationAttributeCacheEntry { |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3743 return 0; | 3743 return 0; |
3744 } | 3744 } |
3745 | 3745 |
3746 Attribute* UniqueElementData::attributeItem(unsigned index) | 3746 Attribute* UniqueElementData::attributeItem(unsigned index) |
3747 { | 3747 { |
3748 ASSERT_WITH_SECURITY_IMPLICATION(index < length()); | 3748 ASSERT_WITH_SECURITY_IMPLICATION(index < length()); |
3749 return &m_attributeVector.at(index); | 3749 return &m_attributeVector.at(index); |
3750 } | 3750 } |
3751 | 3751 |
3752 } // namespace WebCore | 3752 } // namespace WebCore |
OLD | NEW |