WKRenderLayer.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * Copyright (C) 2012 Apple Inc. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. * 1. Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * 2. Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. *
  13. * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
  14. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  15. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
  17. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  18. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  19. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  20. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  21. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  22. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  23. * THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #include "config.h"
  26. #include "WKRenderLayer.h"
  27. #include "WKAPICast.h"
  28. #include "WebRenderLayer.h"
  29. using namespace WebCore;
  30. using namespace WebKit;
  31. WKTypeID WKRenderLayerGetTypeID()
  32. {
  33. return toAPI(WebRenderLayer::APIType);
  34. }
  35. WKRenderObjectRef WKRenderLayerGetRenderer(WKRenderLayerRef renderLayerRef)
  36. {
  37. return toAPI(toImpl(renderLayerRef)->renderer());
  38. }
  39. WKStringRef WKRenderLayerCopyRendererName(WKRenderLayerRef renderLayerRef)
  40. {
  41. return toCopiedAPI(toImpl(renderLayerRef)->renderer()->name());
  42. }
  43. WKStringRef WKRenderLayerCopyElementTagName(WKRenderLayerRef renderLayerRef)
  44. {
  45. WebRenderLayer* renderLayer = toImpl(renderLayerRef);
  46. if (!renderLayer->renderer()->elementTagName().isNull())
  47. return toCopiedAPI(renderLayer->renderer()->elementTagName());
  48. return 0;
  49. }
  50. WKStringRef WKRenderLayerCopyElementID(WKRenderLayerRef renderLayerRef)
  51. {
  52. WebRenderLayer* renderLayer = toImpl(renderLayerRef);
  53. if (!renderLayer->renderer()->elementID().isNull())
  54. return toCopiedAPI(renderLayer->renderer()->elementID());
  55. return 0;
  56. }
  57. WKArrayRef WKRenderLayerGetElementClassNames(WKRenderLayerRef renderLayerRef)
  58. {
  59. return toAPI(toImpl(renderLayerRef)->renderer()->elementClassNames());
  60. }
  61. WKRect WKRenderLayerGetAbsoluteBounds(WKRenderLayerRef renderLayerRef)
  62. {
  63. IntRect bounds = toImpl(renderLayerRef)->absoluteBoundingBox();
  64. return WKRectMake(bounds.x(), bounds.y(), bounds.width(), bounds.height());
  65. }
  66. bool WKRenderLayerIsClipping(WKRenderLayerRef renderLayerRef)
  67. {
  68. return toImpl(renderLayerRef)->isClipping();
  69. }
  70. bool WKRenderLayerIsClipped(WKRenderLayerRef renderLayerRef)
  71. {
  72. return toImpl(renderLayerRef)->isClipped();
  73. }
  74. bool WKRenderLayerIsReflection(WKRenderLayerRef renderLayerRef)
  75. {
  76. return toImpl(renderLayerRef)->isReflection();
  77. }
  78. WKCompositingLayerType WKRenderLayerGetCompositingLayerType(WKRenderLayerRef renderLayerRef)
  79. {
  80. switch (toImpl(renderLayerRef)->compositingLayerType()) {
  81. case WebRenderLayer::None:
  82. return kWKCompositingLayerTypeNone;
  83. case WebRenderLayer::Normal:
  84. return kWKCompositingLayerTypeNormal;
  85. case WebRenderLayer::Tiled:
  86. return kWKCompositingLayerTypeTiled;
  87. case WebRenderLayer::Media:
  88. return kWKCompositingLayerTypeMedia;
  89. case WebRenderLayer::Container:
  90. return kWKCompositingLayerTypeContainer;
  91. }
  92. ASSERT_NOT_REACHED();
  93. return kWKCompositingLayerTypeNone;
  94. }
  95. WKArrayRef WKRenderLayerGetNegativeZOrderList(WKRenderLayerRef renderLayerRef)
  96. {
  97. return toAPI(toImpl(renderLayerRef)->negativeZOrderList());
  98. }
  99. WKArrayRef WKRenderLayerGetNormalFlowList(WKRenderLayerRef renderLayerRef)
  100. {
  101. return toAPI(toImpl(renderLayerRef)->normalFlowList());
  102. }
  103. WKArrayRef WKRenderLayerGetPositiveZOrderList(WKRenderLayerRef renderLayerRef)
  104. {
  105. return toAPI(toImpl(renderLayerRef)->positiveZOrderList());
  106. }