Example #1
0
void GridPainter::paintChildren(const PaintInfo& paintInfo,
                                const LayoutPoint& paintOffset) {
  DCHECK(!m_layoutGrid.needsLayout());

  LayoutRect localVisualRect = LayoutRect(paintInfo.cullRect().m_rect);
  localVisualRect.moveBy(-paintOffset);

  Vector<LayoutUnit> columnPositions = m_layoutGrid.columnPositions();
  if (!m_layoutGrid.styleRef().isLeftToRightDirection()) {
    // Translate columnPositions in RTL as we need the physical coordinates of
    // the columns in order to call dirtiedGridAreas().
    for (size_t i = 0; i < columnPositions.size(); i++)
      columnPositions[i] =
          m_layoutGrid.translateRTLCoordinate(columnPositions[i]);
    // We change the order of tracks in columnPositions, as in RTL the leftmost
    // track will be the last one.
    std::sort(columnPositions.begin(), columnPositions.end());
  }

  GridSpan dirtiedColumns = dirtiedGridAreas(
      columnPositions, localVisualRect.x(), localVisualRect.maxX());
  GridSpan dirtiedRows = dirtiedGridAreas(
      m_layoutGrid.rowPositions(), localVisualRect.y(), localVisualRect.maxY());

  if (!m_layoutGrid.styleRef().isLeftToRightDirection()) {
    // As we changed the order of tracks previously, we need to swap the dirtied
    // columns in RTL.
    size_t lastLine = columnPositions.size() - 1;
    dirtiedColumns = GridSpan::translatedDefiniteGridSpan(
        lastLine - dirtiedColumns.endLine(),
        lastLine - dirtiedColumns.startLine());
  }

  Vector<std::pair<LayoutBox*, size_t>> gridItemsToBePainted;

  for (const auto& row : dirtiedRows) {
    for (const auto& column : dirtiedColumns) {
      const Vector<LayoutBox*, 1>& children =
          m_layoutGrid.gridCell(row, column);
      for (auto* child : children)
        gridItemsToBePainted.append(
            std::make_pair(child, m_layoutGrid.paintIndexForGridItem(child)));
    }
  }

  for (auto* item : m_layoutGrid.itemsOverflowingGridArea()) {
    if (item->frameRect().intersects(localVisualRect))
      gridItemsToBePainted.append(
          std::make_pair(item, m_layoutGrid.paintIndexForGridItem(item)));
  }

  std::stable_sort(gridItemsToBePainted.begin(), gridItemsToBePainted.end(),
                   compareOrderModifiedDocumentOrder);

  LayoutBox* previous = 0;
  for (const auto& gridItemAndPaintIndex : gridItemsToBePainted) {
    // We might have duplicates because of spanning children are included in all
    // cells they span.  Skip them here to avoid painting items several times.
    LayoutBox* current = gridItemAndPaintIndex.first;
    if (current == previous)
      continue;

    BlockPainter(m_layoutGrid)
        .paintAllChildPhasesAtomically(*current, paintInfo, paintOffset);
    previous = current;
  }
}
void WebPageSerializer::serialize(WebView* view, WebVector<WebPageSerializer::Resource>* resourcesParam)
{
    Vector<SerializedResource> resources;
    PageSerializer serializer(&resources);
    serializer.serialize(toWebViewImpl(view)->page());

    Vector<Resource> result;
    for (Vector<SerializedResource>::const_iterator iter = resources.begin(); iter != resources.end(); ++iter) {
        Resource resource;
        resource.url = iter->url;
        resource.mimeType = iter->mimeType.ascii();
        // FIXME: we are copying all the resource data here. Idealy we would have a WebSharedData().
        resource.data = WebCString(iter->data->data(), iter->data->size());
        result.append(resource);
    }

    *resourcesParam = result;
}
bool PopupLayer::onTouchBegan(Touch* touch, Event* event)
{
    bool touched = false;
    Vector<Node *> thisSelectionChildren = pBackgroundSprite->getChildren();        
    for (auto iter = thisSelectionChildren.begin(); iter != thisSelectionChildren.end(); ++iter) 
    {
        Node *childNode = *iter; 
          
        if(containsPointInSprite(childNode,sign_tags::NONE,GET_ADDCHAR_FOR5,touch,pBackgroundSprite))
        {
            Sprite* pSprite = static_cast<Sprite*>(*iter); 
            core::Settings::getInstance()->getSoundManager().playSoundEffect(SINGLE_CLICK_1);   
            setBuyPoints(GET_ADDCHAR_FOR5);
            log("GET_ADDCHAR_FOR5");
            touched = true;
            break;
                
        }
        
        if(containsPointInSprite(childNode,sign_tags::NONE,GET_REMOVECHAR_FOR5,touch,pBackgroundSprite))
        {
            Sprite* pSprite = static_cast<Sprite*>(*iter); 
            core::Settings::getInstance()->getSoundManager().playSoundEffect(SINGLE_CLICK_1);
            setBuyPoints(GET_REMOVECHAR_FOR5);
            log("GET_REMOVECHAR_FOR5");
            touched = true;
            break;
                
        }

        if(containsPointInSprite(childNode,sign_tags::NONE,BUY_FOR099,touch,pBackgroundSprite))
        {
            Sprite* pSprite = static_cast<Sprite*>(*iter); 
            core::Settings::getInstance()->getSoundManager().playSoundEffect(SINGLE_CLICK_1);
            setBuyPoints(BUY_FOR099);
            log("BUY_FOR099");
            touched = true;
            break;
                
        }

        if(containsPointInSprite(childNode,sign_tags::NONE,BUY_FOR999,touch,pBackgroundSprite))
        {
            Sprite* pSprite = static_cast<Sprite*>(*iter); 
            core::Settings::getInstance()->getSoundManager().playSoundEffect(SINGLE_CLICK_1);	
            log("BUY_FOR999");
            setBuyPoints(BUY_FOR999);
            touched = true;
            break;
                
        }

        if(containsPointInSprite(childNode,sign_tags::NONE,BUY_FOR1999,touch,pBackgroundSprite))
        {
            Sprite* pSprite = static_cast<Sprite*>(*iter); 
            core::Settings::getInstance()->getSoundManager().playSoundEffect(SINGLE_CLICK_1);
            log("BUY_FOR1999");
            setBuyPoints(BUY_FOR1999);
            touched = true;
            break;
                
        }
    }
    event->stopPropagation();
    return touched;  
   
}
Example #4
0
PassRefPtr<JSONObject> GraphicsLayer::layerTreeAsJSON(LayerTreeFlags flags, RenderingContextMap& renderingContextMap) const
{
    RefPtr<JSONObject> json = adoptRef(new JSONObject);

    if (flags & LayerTreeIncludesDebugInfo) {
        json->setString("this", pointerAsString(this));
        json->setString("debugName", m_client->debugName(this));
    }

    if (m_position != FloatPoint())
        json->setArray("position", pointAsJSONArray(m_position));

    if (m_hasTransformOrigin && m_transformOrigin != FloatPoint3D(m_size.width() * 0.5f, m_size.height() * 0.5f, 0))
        json->setArray("transformOrigin", pointAsJSONArray(m_transformOrigin));

    if (m_size != IntSize())
        json->setArray("bounds", sizeAsJSONArray(m_size));

    if (m_opacity != 1)
        json->setNumber("opacity", m_opacity);

    if (m_blendMode != WebBlendModeNormal)
        json->setString("blendMode", compositeOperatorName(CompositeSourceOver, m_blendMode));

    if (m_isRootForIsolatedGroup)
        json->setBoolean("isolate", m_isRootForIsolatedGroup);

    if (m_contentsOpaque)
        json->setBoolean("contentsOpaque", m_contentsOpaque);

    if (!m_shouldFlattenTransform)
        json->setBoolean("shouldFlattenTransform", m_shouldFlattenTransform);

    if (m_3dRenderingContext) {
        RenderingContextMap::const_iterator it = renderingContextMap.find(m_3dRenderingContext);
        int contextId = renderingContextMap.size() + 1;
        if (it == renderingContextMap.end())
            renderingContextMap.set(m_3dRenderingContext, contextId);
        else
            contextId = it->value;

        json->setNumber("3dRenderingContext", contextId);
    }

    if (m_drawsContent)
        json->setBoolean("drawsContent", m_drawsContent);

    if (!m_contentsVisible)
        json->setBoolean("contentsVisible", m_contentsVisible);

    if (!m_backfaceVisibility)
        json->setString("backfaceVisibility", m_backfaceVisibility ? "visible" : "hidden");

    if (flags & LayerTreeIncludesDebugInfo)
        json->setString("client", pointerAsString(m_client));

    if (m_backgroundColor.alpha())
        json->setString("backgroundColor", m_backgroundColor.nameForRenderTreeAsText());

    if (!m_transform.isIdentity())
        json->setArray("transform", transformAsJSONArray(m_transform));

    if (m_replicaLayer)
        json->setObject("replicaLayer", m_replicaLayer->layerTreeAsJSON(flags, renderingContextMap));

    if (m_replicatedLayer)
        json->setString("replicatedLayer", flags & LayerTreeIncludesDebugInfo ? pointerAsString(m_replicatedLayer) : "");

    if ((flags & LayerTreeIncludesPaintInvalidationRects) && repaintRectMap().contains(this) && !repaintRectMap().get(this).isEmpty()) {
        Vector<FloatRect> repaintRectsCopy = repaintRectMap().get(this);
        std::sort(repaintRectsCopy.begin(), repaintRectsCopy.end(), &compareFloatRects);
        RefPtr<JSONArray> repaintRectsJSON = adoptRef(new JSONArray);
        for (size_t i = 0; i < repaintRectsCopy.size(); ++i) {
            if (repaintRectsCopy[i].isEmpty())
                continue;
            repaintRectsJSON->pushArray(rectAsJSONArray(repaintRectsCopy[i]));
        }
        json->setArray("repaintRects", repaintRectsJSON);
    }

    if ((flags & LayerTreeIncludesPaintingPhases) && m_paintingPhase) {
        RefPtr<JSONArray> paintingPhasesJSON = adoptRef(new JSONArray);
        if (m_paintingPhase & GraphicsLayerPaintBackground)
            paintingPhasesJSON->pushString("GraphicsLayerPaintBackground");
        if (m_paintingPhase & GraphicsLayerPaintForeground)
            paintingPhasesJSON->pushString("GraphicsLayerPaintForeground");
        if (m_paintingPhase & GraphicsLayerPaintMask)
            paintingPhasesJSON->pushString("GraphicsLayerPaintMask");
        if (m_paintingPhase & GraphicsLayerPaintChildClippingMask)
            paintingPhasesJSON->pushString("GraphicsLayerPaintChildClippingMask");
        if (m_paintingPhase & GraphicsLayerPaintOverflowContents)
            paintingPhasesJSON->pushString("GraphicsLayerPaintOverflowContents");
        if (m_paintingPhase & GraphicsLayerPaintCompositedScroll)
            paintingPhasesJSON->pushString("GraphicsLayerPaintCompositedScroll");
        json->setArray("paintingPhases", paintingPhasesJSON);
    }

    if (flags & LayerTreeIncludesClipAndScrollParents) {
        if (m_hasScrollParent)
            json->setBoolean("hasScrollParent", true);
        if (m_hasClipParent)
            json->setBoolean("hasClipParent", true);
    }

    if (flags & LayerTreeIncludesDebugInfo) {
        RefPtr<JSONArray> compositingReasonsJSON = adoptRef(new JSONArray);
        for (size_t i = 0; i < kNumberOfCompositingReasons; ++i) {
            if (m_debugInfo.compositingReasons() & kCompositingReasonStringMap[i].reason)
                compositingReasonsJSON->pushString(kCompositingReasonStringMap[i].description);
        }
        json->setArray("compositingReasons", compositingReasonsJSON);
    }

    if (m_children.size()) {
        RefPtr<JSONArray> childrenJSON = adoptRef(new JSONArray);
        for (size_t i = 0; i < m_children.size(); i++)
            childrenJSON->pushObject(m_children[i]->layerTreeAsJSON(flags, renderingContextMap));
        json->setArray("children", childrenJSON);
    }

    return json;
}
Example #5
0
 // Because end() in Vector points passed the last element
 // we need to subtract one to get the last leaf node of
 // the heap
 int *end() {return __min_heap.end()-1;}
Example #6
0
void Platform::getVolumeInformationList( Vector<VolumeInformation>& out_rVolumeInfoVector, bool bOnlyFixedDrives )
{
   Vector<const char*> drives;

   getVolumeNamesList( drives, bOnlyFixedDrives );

   if( ! drives.empty() )
   {
      Vector<StringTableEntry>::iterator i;
      for( i = drives.begin(); i != drives.end(); i++ )
      {
         VolumeInformation info;
         TCHAR lpszVolumeName[ 256 ];
         TCHAR lpszFileSystem[ 256 ];
         DWORD dwSerial = 0;
         DWORD dwMaxComponentLength = 0;
         DWORD dwFileSystemFlags = 0;

         dMemset( lpszVolumeName, 0, sizeof( lpszVolumeName ) );
         dMemset( lpszFileSystem, 0, sizeof( lpszFileSystem ) );
         dMemset( &info, 0, sizeof( VolumeInformation ) );

         // More volume information
         UINT uDriveType = GetDriveTypeA( (*i) );
         if( uDriveType == DRIVE_UNKNOWN )
            info.Type = DRIVETYPE_UNKNOWN;
         else if( uDriveType == DRIVE_REMOVABLE )
            info.Type = DRIVETYPE_REMOVABLE;
         else if( uDriveType == DRIVE_FIXED )
            info.Type = DRIVETYPE_FIXED;
         else if( uDriveType == DRIVE_CDROM )
            info.Type = DRIVETYPE_CDROM;
         else if( uDriveType == DRIVE_RAMDISK )
            info.Type = DRIVETYPE_RAMDISK;
         else if( uDriveType == DRIVE_REMOTE )
            info.Type = DRIVETYPE_REMOTE;

         info.RootPath = StringTable->insert( (*i) );

         // We don't retrieve drive volume info for removable drives, because it's loud :(
         if( info.Type != DRIVETYPE_REMOVABLE )
         {
#ifdef UNICODE
            WCHAR ibuf[ 3 ];
            ibuf[ 0 ] = ( *i )[ 0 ];
            ibuf[ 1 ] = ':';
            ibuf[ 2 ] = '\0';
#else
            char* ibuf = *i;
#endif
            // Standard volume information
            GetVolumeInformation( ibuf, lpszVolumeName, sizeof( lpszVolumeName ) / sizeof( lpszVolumeName[ 0 ] ),
               &dwSerial, &dwMaxComponentLength, &dwFileSystemFlags, lpszFileSystem,
               sizeof( lpszFileSystem ) / sizeof( lpszFileSystem[ 0 ] ) );

#ifdef UNICODE
            char buf[ sizeof( lpszFileSystem ) / sizeof( lpszFileSystem[ 0 ] ) * 3 + 1 ];
            convertUTF16toUTF8( lpszFileSystem, buf, sizeof( buf ) / sizeof( buf[ 0 ] ) );
            info.FileSystem = StringTable->insert( buf );

            convertUTF16toUTF8( lpszVolumeName, buf, sizeof( buf ) / sizeof( buf[ 0 ] ) );
            info.Name = StringTable->insert( buf );
#else
            info.FileSystem = StringTable->insert( lpszFileSystem );
            info.Name = StringTable->insert( lpszVolumeName );
#endif
            info.SerialNumber = dwSerial;
            // Won't compile on something prior to XP.
            info.ReadOnly = dwFileSystemFlags & FILE_READ_ONLY_VOLUME;
         }
         out_rVolumeInfoVector.push_back( info );

         // I opted not to get free disk space because of the overhead of the calculations required for it

      }
   }
}
Example #7
0
void CookieManager::getRawCookies(Vector<ParsedCookie*> &stackOfCookies, const KURL& requestURL, CookieFilter filter) const
{
    if (!m_syncedWithDatabase && !m_privateMode) {
        LOG_ERROR("CookieManager is calling getRawCookies before database values are loaded.");
        return;
    }

    CookieLog("CookieManager - getRawCookies - processing url with domain - %s & protocol: %s & path: %s\n", requestURL.host().utf8().data(), requestURL.protocol().utf8().data(), requestURL.path().utf8().data());

    const bool invalidScheme = shouldIgnoreScheme(requestURL.protocol());
    const bool specialCaseForWebWorks = invalidScheme && m_shouldDumpAllCookies;
    const bool isConnectionSecure = requestURL.protocolIs("https") || requestURL.protocolIs("wss") || specialCaseForWebWorks;

    Vector<ParsedCookie*> cookieCandidates;
    Vector<CookieMap*> protocolsToSearch;

    // Special Case: If a server sets a "secure" cookie over a non-secure channel and tries to access the cookie
    // over a secure channel, it will not succeed because the secure protocol isn't mapped to the insecure protocol yet.
    // Set the map to the non-secure version, so it'll search the mapping for a secure cookie.
    CookieMap* targetMap = m_managerMap.get(requestURL.protocol());
    if (!targetMap && isConnectionSecure) {
        CookieLog("CookieManager - special case: secure protocol are not linked yet.");
        if (requestURL.protocolIs("https"))
            targetMap = m_managerMap.get("http");
        else if (requestURL.protocolIs("wss"))
            targetMap = m_managerMap.get("ws");
    }

    // Decide which scheme tree we should look at.
    // Return on invalid schemes. cookies are currently disabled on file and local.
    // We only want to enable them for WebWorks that enabled a special flag.
    if (specialCaseForWebWorks)
        copyValuesToVector(m_managerMap, protocolsToSearch);
    else if (invalidScheme)
        return;
    else {
        protocolsToSearch.append(targetMap);
        // FIXME: this is a hack for webworks apps; RFC 6265 says "Cookies do not provide isolation by scheme"
        // so we should not be checking protocols at all. See PR 135595
        if (m_shouldDumpAllCookies) {
            protocolsToSearch.append(m_managerMap.get("file"));
            protocolsToSearch.append(m_managerMap.get("local"));
       }
    }

    Vector<String> delimitedHost;

    // IP addresses are stored in a particular format (due to ipv6). Reduce the ip address so we can match
    // it with the one in memory.
    string canonicalIP = BlackBerry::Platform::getCanonicalIPFormat(requestURL.host().utf8().data());
    if (!canonicalIP.empty())
        delimitedHost.append(String(canonicalIP.c_str()));
    else
        requestURL.host().lower().split(".", true, delimitedHost);

    // Go through all the protocol trees that we need to search for
    // and get all cookies that are valid for this domain
    for (size_t k = 0; k < protocolsToSearch.size(); k++) {
        CookieMap* currentMap = protocolsToSearch[k];

        // if no cookies exist for this protocol, break right away
        if (!currentMap)
            continue;

        CookieLog("CookieManager - looking at protocol map %s \n", currentMap->getName().utf8().data());

        // Special case for local and files - because WebApps expect to get ALL cookies from the backing-store on local protocol
        if (specialCaseForWebWorks) {
            CookieLog("CookieManager - special case find in protocol map - %s\n", currentMap->getName().utf8().data());
            currentMap->getAllChildCookies(&cookieCandidates);
        } else {
            // Get cookies from the null domain map
            currentMap->getAllCookies(&cookieCandidates);

            // Get cookies from the valid domain maps
            int i = delimitedHost.size() - 1;
            while (i >= 0) {
                CookieLog("CookieManager - finding %s in currentmap\n", delimitedHost[i].utf8().data());
                currentMap = currentMap->getSubdomainMap(delimitedHost[i]);
                // if this subdomain/domain does not exist in our mapping then we simply exit
                if (!currentMap) {
                    CookieLog("CookieManager - cannot find next map exiting the while loop.\n");
                    break;
                }
                CookieLog("CookieManager - found the map, grabbing cookies from this map\n");
                currentMap->getAllCookies(&cookieCandidates);
                i--;
            }
        }
    }

    CookieLog("CookieManager - there are %d cookies in candidate\n", cookieCandidates.size());

    for (size_t i = 0; i < cookieCandidates.size(); ++i) {
        ParsedCookie* cookie = cookieCandidates[i];

        // According to the path-matches rules in RFC6265, section 5.1.4,
        // we should add a '/' at the end of cookie-path for comparison if the cookie-path is not end with '/'.
        String path = cookie->path();
        CookieLog("CookieManager - comparing cookie path %s (len %d) to request path %s (len %d)", path.utf8().data(), path.length(), requestURL.path().utf8().data(), path.length());
        if (!equalIgnoringCase(path, requestURL.path()) && !path.endsWith("/", false))
            path = path + "/";

        // Only secure connections have access to secure cookies. Unless specialCaseForWebWorks is true.
        // Get the cookies filtering out HttpOnly cookies if requested.
        if (requestURL.path().startsWith(path, false) && (isConnectionSecure || !cookie->isSecure()) && (filter == WithHttpOnlyCookies || !cookie->isHttpOnly())) {
            CookieLog("CookieManager - cookie chosen - %s\n", cookie->toString().utf8().data());
            cookie->setLastAccessed(currentTime());
            stackOfCookies.append(cookie);
        }
    }

    std::stable_sort(stackOfCookies.begin(), stackOfCookies.end(), cookieSorter);
}
int main () {
  std::cout.setf(std::ios::boolalpha);
  {
    X holder;
    {
      Vector<X> v1;
      Vector<X> v2(5,X(1));
      Vector<X> v3(v2);

      cout << "Current v1.empty() == " << v1.empty() << endl;
      cout << "Current v2.size() == " << v2.size() << endl;
      cout << "Current v3.size() == " << v3.size() << endl;

      v1 = v3;
      cout << "Current v1.size() == " << v1.size() << endl;
      cout << "Current v1.empty() == " << v1.empty() << endl;

      int n;
      for (n = 5; n < 20; n++) v1.push_back(X(n));
      cout << "Current v1.size() == " << v1.size() << endl;

      v1.resize(10);
      cout << "Current v1.size() == " << v1.size() << endl;
      v1.resize(15);
      cout << "Current v1.size() == " << v1.size() << endl;
      for (n = 10; n < 13; n++) v1[n] = X(100 + n);
      cout << "v1 values:";
      for (n = 0; n < 15; n++) cout << " " << v1[n];
      cout << endl;

    }
    X::useNotify();

    //test int sort
    Vector<int>intTest;
    intTest.push_back(5);
    intTest.push_back(12);
    intTest.push_back(86);
    intTest.push_back(1);
    intTest.push_back(4);
    intTest.push_back(99);
    cout<<"after sort: ";
    sort(intTest.begin(),intTest.end());
    int size = intTest.size();
    cout<<"original: ";
    for (int i = 0; i < size; i ++)
    {
      cout<<intTest[i]<<" ";
    }
    cout<<endl;

    Vector<int>::iterator iter;
    iter = intTest.begin();
    cout<<*iter<<endl;
    cout<<*(iter++)<<endl;
    cout<<*(++iter)<<endl;
    cout<<*iter<<endl;
    cout<<*(--iter)<<endl;
    cout<<*(iter--)<<endl;
    cout<<*iter<<endl;
    iter = iter + 3;
    cout<<*iter<<endl;
    cout<<iter - intTest.begin()<<endl;
    iter = iter - 2;
    cout<<iter[1]<<endl;
    Vector<int>::iterator iter2 = intTest.begin();
    cout <<(iter2 == iter)<<endl;
    cout <<(iter2 != iter)<<endl;
    cout <<(iter2 >= iter)<<endl;
    cout <<(iter2 <= iter)<<endl;
    cout <<(iter2 < iter)<<endl;
    cout <<(iter2 > iter)<<endl;

    //test string sort
    Vector<string> stringTest;
    stringTest.push_back("abc");
    stringTest.push_back("asd");
    stringTest.push_back("dagege");
    stringTest.push_back("gagee");
    stringTest.push_back("gegege");
    stringTest.push_back("fegeege");
    stringTest.push_back("sgegeg");
    stringTest.push_back("142ijga");
    stringTest.push_back("gewq9354");
    stringTest.push_back("q929");
    stringTest.push_back("zgaw");
    cout<<"after sort: ";
    sort(stringTest.begin(),stringTest.end());
    size = stringTest.size();
    cout<<"original: ";
    for (int i = 0; i < size; i ++)
    {
      cout<<stringTest[i]<<" ";
    }
    cout<<endl;
  }
  cout << endl;
  return 0;
}
void computePreciseJumpTargets(CodeBlock* codeBlock, Vector<unsigned, 32>& out)
{
    ASSERT(out.isEmpty());
    
    // We will derive a superset of the jump targets that the code block thinks it has.
    // So, if the code block claims there are none, then we are done.
    if (!codeBlock->numberOfJumpTargets())
        return;
    
    for (unsigned i = codeBlock->numberOfExceptionHandlers(); i--;)
        out.append(codeBlock->exceptionHandler(i).target);
    
    Interpreter* interpreter = codeBlock->vm()->interpreter;
    Instruction* instructionsBegin = codeBlock->instructions().begin();
    unsigned instructionCount = codeBlock->instructions().size();
    for (unsigned bytecodeOffset = 0; bytecodeOffset < instructionCount;) {
        OpcodeID opcodeID = interpreter->getOpcodeID(instructionsBegin[bytecodeOffset].u.opcode);
        Instruction* current = instructionsBegin + bytecodeOffset;
        switch (opcodeID) {
        case op_jmp:
            out.append(bytecodeOffset + current[1].u.operand);
            break;
        case op_jtrue:
        case op_jfalse:
        case op_jeq_null:
        case op_jneq_null:
            out.append(bytecodeOffset + current[2].u.operand);
            break;
        case op_jneq_ptr:
        case op_jless:
        case op_jlesseq:
        case op_jgreater:
        case op_jgreatereq:
        case op_jnless:
        case op_jnlesseq:
        case op_jngreater:
        case op_jngreatereq:
            out.append(bytecodeOffset + current[3].u.operand);
            break;
        case op_switch_imm:
            addSimpleSwitchTargets(codeBlock->immediateSwitchJumpTable(current[1].u.operand), bytecodeOffset, out);
            out.append(bytecodeOffset + current[2].u.operand);
            break;
        case op_switch_char:
            addSimpleSwitchTargets(codeBlock->characterSwitchJumpTable(current[1].u.operand), bytecodeOffset, out);
            out.append(bytecodeOffset + current[2].u.operand);
            break;
        case op_switch_string: {
            StringJumpTable& table = codeBlock->stringSwitchJumpTable(current[1].u.operand);
            StringJumpTable::StringOffsetTable::iterator iter = table.offsetTable.begin();
            StringJumpTable::StringOffsetTable::iterator end = table.offsetTable.end();
            for (; iter != end; ++iter)
                out.append(bytecodeOffset + iter->value.branchOffset);
            out.append(bytecodeOffset + current[2].u.operand);
            break;
        }
        case op_get_pnames:
            out.append(bytecodeOffset + current[5].u.operand);
            break;
        case op_next_pname:
            out.append(bytecodeOffset + current[6].u.operand);
            break;
        case op_check_has_instance:
            out.append(bytecodeOffset + current[4].u.operand);
            break;
        case op_loop_hint:
            out.append(bytecodeOffset);
            break;
        default:
            break;
        }
        bytecodeOffset += opcodeLengths[opcodeID];
    }
    
    std::sort(out.begin(), out.end());
    
    // We will have duplicates, and we must remove them.
    unsigned toIndex = 0;
    unsigned fromIndex = 0;
    unsigned lastValue = UINT_MAX;
    while (fromIndex < out.size()) {
        unsigned value = out[fromIndex++];
        if (value == lastValue)
            continue;
        out[toIndex++] = value;
        lastValue = value;
    }
    out.resize(toIndex);
}
Example #10
0
void ExclusionPolygon::computeXIntersections(float y, bool isMinY, Vector<ExclusionInterval>& result) const
{
    Vector<ExclusionPolygon::EdgeInterval> overlappingEdges;
    m_edgeTree.allOverlaps(ExclusionPolygon::EdgeInterval(y, y, 0), overlappingEdges);

    Vector<EdgeIntersection> intersections;
    EdgeIntersection intersection;
    for (unsigned i = 0; i < overlappingEdges.size(); i++) {
        ExclusionPolygonEdge* edge = static_cast<ExclusionPolygonEdge*>(overlappingEdges[i].data());
        if (computeXIntersection(edge, y, intersection) && intersection.type != VertexYBoth)
            intersections.append(intersection);
    }
    if (intersections.size() < 2)
        return;

    std::sort(intersections.begin(), intersections.end(), WebCore::compareEdgeIntersectionX);

    unsigned index = 0;
    int windCount = 0;
    bool inside = false;

    while (index < intersections.size()) {
        const EdgeIntersection& thisIntersection = intersections[index];
        if (index + 1 < intersections.size()) {
            const EdgeIntersection& nextIntersection = intersections[index + 1];
            if ((thisIntersection.point.x() == nextIntersection.point.x()) && (thisIntersection.type == VertexMinY || thisIntersection.type == VertexMaxY)) {
                if (thisIntersection.type == nextIntersection.type) {
                    // Skip pairs of intersections whose types are VertexMaxY,VertexMaxY and VertexMinY,VertexMinY.
                    index += 2;
                } else {
                    // Replace pairs of intersections whose types are VertexMinY,VertexMaxY or VertexMaxY,VertexMinY with one intersection.
                    index++;
                }
                continue;
            }
        }

        const ExclusionPolygonEdge& thisEdge = *thisIntersection.edge;
        bool evenOddCrossing = !windCount;

        if (fillRule() == RULE_EVENODD) {
            windCount += (thisEdge.vertex2().y() > thisEdge.vertex1().y()) ? 1 : -1;
            evenOddCrossing = evenOddCrossing || !windCount;
        }

        if (evenOddCrossing) {
            bool edgeCrossing = thisIntersection.type == Normal;
            if (!edgeCrossing) {
                FloatPoint prevVertex;
                FloatPoint thisVertex;
                FloatPoint nextVertex;

                if (getVertexIntersectionVertices(thisIntersection, prevVertex, thisVertex, nextVertex)) {
                    if (nextVertex.y() == y)
                        edgeCrossing = (isMinY) ? prevVertex.y() > y : prevVertex.y() < y;
                    else if (prevVertex.y() == y)
                        edgeCrossing = (isMinY) ? nextVertex.y() > y : nextVertex.y() < y;
                    else
                        edgeCrossing = true;
                }
            }
            if (edgeCrossing)
                inside = appendIntervalX(thisIntersection.point.x(), inside, result);
        }

        index++;
    }
}
Example #11
0
bool GameScene::init()
{
	if (!Layer::init()){
		return false;
	}

	Size visibleSize = Director::getInstance()->getVisibleSize();
	UserDefault::getInstance()->setIntegerForKey("test", 10);
	SpriteFrameCache::getInstance()->addSpriteFramesWithFile("pukeImage.plist");

	SimpleAudioEngine::getInstance()->preloadEffect("click.mp3");
	//添加背景图
	Sprite* _bg = Sprite::create("bk.png");
	_bg->setAnchorPoint(Vec2::ZERO);
	_bg->setOpacity(180);
	this->addChild(_bg,-1);

	//按钮层
	auto layer = Layer::create();
	Sprite* _bar = Sprite::create("bar.png");
	_bar->setAnchorPoint(Vec2(0, 1));
	_bar->setPosition(Vec2(0, visibleSize.height));

	layer->addChild(_bar, 0);

	auto _ret = MenuItemImage::create("canNormal.png", "canClicked.png", [](Ref* pSender){Director::getInstance()->popScene(); });
	auto _pro = MenuItemImage::create("proNormal.png", "proClicked.png", CC_CALLBACK_1(GameScene::prompt, this));
	auto _can = MenuItemImage::create("cheNormal.png", "cheClicked.png", CC_CALLBACK_1(GameScene::cancel, this));

	auto menu = Menu::create(_ret, _pro, _can, NULL);
	menu->setAnchorPoint(Vec2(0,1));
	menu->setPosition(Vec2(0, 595));
	_ret->setPosition(Vec2(50, 0));
	_ret->setAnchorPoint(Vec2(0,0));
	_pro->setPosition(Vec2(750, 0));
	_pro->setAnchorPoint(Vec2(0,0));
	_can->setPosition(Vec2(850, 0));
	_can->setAnchorPoint(Vec2(0,0));

	layer->addChild(menu,1);

	layer->setAnchorPoint(Vec2(0, 0));
	layer->setPosition(Vec2(0, 0));
	this->addChild(layer,1);


	gInfo = GameData::getInstance();
	log("%d  %d", gInfo->getHard(), gInfo->getScores());
	//计算每张牌的大小
	int each = 20;
	int boarder = 50;
	int eachcard =( visibleSize.width - (2 * boarder) - (9 * each)) / 10;

	//放置十个卡槽
	for (int i = 0; i < 11; i++){
	//	const auto p =Sprite::create("k.jpg");
		const auto p = Sprite::createWithSpriteFrameName("k.jpg");
		p->setPosition(Vec2(boarder + eachcard*i + i*each, visibleSize.height-80));
		p->setAnchorPoint(Vec2(0,1));
		p->setScale(0.7);
		this->addChild(p,1);
		this->slots.push_back(p);
		this->tails.push_back(p);
	}
	this->slots.at(10)->setVisible(false);;

	//放置5个发牌卡槽
	for (int i = 0; i < 5; i++){
		//const auto p = Sprite::create("bk2.png");
		const auto p = Sprite::createWithSpriteFrameName("bk2.png");
		p->setScale(0.7);
		p->setPosition(Vec2(slots.at(9)->getPosition().x-i*10, 100));
		this->dealCards.push_back(p);
		this->addChild(p);
	}

	//放置8个完成卡槽
	for (int i = 0; i < 8; i++){
		const auto p = Node::create();
		p->setScale(0.7);
		p->setPosition(Vec2(slots.at(1)->getPosition().x+i*10, 100));
		this->finishSlots.push_back(p);
		this->addChild(p);
	}



	//注册发牌事件监听
	auto dealListener = EventListenerTouchOneByOne::create();
	dealListener->setSwallowTouches(true);
	dealListener->onTouchBegan = [&](Touch* touch, Event* event){

		auto target = static_cast<Sprite*>(event->getCurrentTarget());
		Vec2 location = target->convertToNodeSpace(touch->getLocation());

		Size s = target->getContentSize();
		Rect rect = Rect(0, 0, s.width, s.height);

		if (rect.containsPoint(location)){
			//卡槽全不为空
			bool emp = false;
			for (int i = 0; i < 10; i++){
				if (tails.at(i) == slots.at(i)){
					emp = true;
					break;
				}
			}
			if (!emp){

				//是否在区域内
				if (this->resNum >= 0){

					//获取一列牌
					auto dealQueue = this->dealCards.at(resNum--);

					for (int i = 0; i < 10; i++){
						auto ptr = dealQueue->getChildren().back();
						static_cast<Card*>(ptr)->setX(i);
						static_cast<Card*>(ptr)->setY(static_cast<Card*>(tails.at(i))->getY() + 1);

						Vec2 v = tails.at(i)->convertToNodeSpace(dealQueue->getPosition());

						ptr->retain();
						ptr->removeFromParentAndCleanup(false);
						tails.at(i)->addChild(ptr);
						ptr->setPosition(v);
						ptr->setAnchorPoint(Vec2(0, 0.2));
						ptr->release();

					//移动到牌尾
						auto que = Sequence::create(DelayTime::create(0.2f*i),MoveTo::create(0.5, Vec2::ZERO),DelayTime::create(0.1f),CCCallFunc::create(ptr,callfunc_selector(Card::change)),nullptr);
						ptr->runAction(que);
						SimpleAudioEngine::getInstance()->playEffect("click.mp3");
						tails.at(i) = static_cast<Card*>(ptr);
					//	(static_cast<Card*>(ptr))->change();
						isChange = true;

					}
					dealQueue->setVisible(false);
					this->records.push_back(std::pair<Vec2, Vec2>(Vec2(-1, -1), Vec2(-1, -1)));
				}
			}
		}
		return true;
	};

	for (int i = 0; i < 5; i++){
		//注册发牌事件
		Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(dealListener->clone(), this->dealCards.at(i));
	}

	//注册触摸事件
	auto listener = EventListenerTouchOneByOne::create();
	listener->setSwallowTouches(true);

	listener->onTouchBegan = [=](Touch* touch, Event* event){

		auto target = static_cast<Card*>(event->getCurrentTarget());
		Vec2 location = target->convertToNodeSpace(touch->getLocation());


		Size s = target->getContentSize();
		Rect rect = Rect(0,0, s.width, s.height);

		if (rect.containsPoint(location)){
			//可以移动		
			SimpleAudioEngine::getInstance()->playEffect("click.mp3");
			if (canBeMoved(target)){
				//用于顶置和透明
				setZorder(target, 2000);
				setOp(target, 200);
				return true;
			}
		}
		return false;
	};
	listener->onTouchMoved = [=](Touch* touch, Event* event){
		//跟随鼠标移动
		auto target = static_cast<Card*>(event->getCurrentTarget());
		target->setPosition(target->getPosition() + touch->getDelta()/0.7);
	};

	listener->onTouchEnded = [&](Touch* touch, Event* event){
		SimpleAudioEngine::getInstance()->playEffect("click.mp3");
		auto target = static_cast<Card*>(event->getCurrentTarget());
		Vec2 pos = this->convertToNodeSpace(touch->getLocation());

		bool isOk = false;
		for (int i = 1; i <11; i++){
			if (pos.x > slots.at(i - 1)->getPosition().x&&pos.x <slots.at(i)->getPosition().x){
				//找到结点,移动
				if (tails.at(i-1) == slots.at(i-1) || static_cast<Card*>(tails.at(i-1))->getNum() == target->getNum() + 1){
					moveTail(target, i-1,true);
					isOk = true;
				}
				//判断i-1列是否完成
				Card* p;
				if ((p=judge(i - 1))!=NULL){
					moveToWin(p);
					if (finishNum > 8)
						log("You Win!!");
				}
				break;
			}
		}
		if (!isOk) target->runAction(MoveTo::create(0.2,Vec2::ZERO));
		
		//恢复顶置,透明状态
		reserveZorder(target);
		setOp(target, 255);
	};

	//读入所有牌组
	Vector<Card*> cards;
	int start = 3;
	char str[100] = { 0 };
	for (int i = 0; i <4 ; i++){
		for (int j = 0; j < 13; j++){
			//将int转化为string
			
			sprintf(str,"%d.jpg", start++);
			auto cc = Card::create(str,(j + 2) % 13,(Suit)i, false);
			auto cc2 = Card::create(str, (j + 2) % 13, (Suit)i, false);

			cards.pushBack(cc);
			cards.pushBack(cc2);
		}
	}


	//洗牌
	unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
	std::shuffle(cards.begin(), cards.end(), std::default_random_engine(seed));
	isChange = true;

	//发牌
	int index = 0;
	int count = 0;
	int dindex = 0;
	for (auto card : cards){

		if (count < 54){
			if (count < 10){
				this->tails.at(index)->addChild(card);
				card->setX(index);
				card->setY(0);
				card->setAnchorPoint(Vec2(0, 0));
			//	card->setPosition(Vec2(0, card->getContentSize().height*0.2));
			}
			else{
				this->tails.at(index)->addChild(card);
				card->setX(index);
				card->setY(static_cast<Card*>(card->getParent())->getY() + 1);
				card->setAnchorPoint(Vec2(0,.2));
			}
			//更新尾位置
			this->tails.at(index) = card;
			//注册卡牌事件
			Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener->clone(), card);
			//翻牌最后行的牌
			if (count > 43)
				card->change();
			index = (index + 1) % 10;
		}
		else{
			//剩余放入发牌槽
				card->setAnchorPoint(Vec2(0,0));
				this->dealCards.at(dindex)->addChild(card);
				Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener->clone(), card);
				dindex = (dindex + 1) % 5;
		}
		count++;
	}
	return true;
}
Example #12
0
void KNNData::initialize(const Vector<VectorWithIndex>& v) {
  vsi_ = v;
  tree_ = new RealRCTree(v.begin(), v.end());
}
Example #13
0
inline
bool operator==(const Vector& u, const Vector& v)
{
    bool rv = std::equal(u.begin(), u.end(), v.begin());
    return rv;
}
Example #14
0
 void trace(JSTracer *trc) {
     AutoLock hold(lock);
     for (T *p = busy.begin(); p != busy.end(); p++)
         (*p)->trace(trc);
     queue.trace(trc);
 }
Example #15
0
void BlendMap<DATA_T>::Set(const Vector& data)
{
    Blend_Map_Entries.reserve(data.size());
    Blend_Map_Entries.assign(data.begin(), data.end());
}
BoundingBox::BoundingBox(const Vector& v) :
	min(Vertex::allmin(v.beg(), v.end())),
	max(Vertex::allmax(v.beg(), v.end()))
{
}
Example #17
0
		void getBlobs(Vector<String>& out) {
			Vector<String> blobs;
			for ( Vector<String>::const_iterator it = _blobAttrs.begin(); it != _blobAttrs.end(); ++it ) {
				requestBlobsForAttrib(*it,out);
			}
		}
Example #18
0
FontData* CSSFontSelector::getFontData(const FontDescription& fontDescription, const AtomicString& familyName)
{
    if (m_fontFaces.isEmpty()) {
        if (familyName.startsWith("-webkit-"))
            return fontDataForGenericFamily(m_document, fontDescription, familyName);
        return 0;
    }

    String family = familyName.string();

#if ENABLE(SVG_FONTS)
    if (fontDescription.smallCaps())
        family += "-webkit-svg-small-caps";
#endif

    Vector<RefPtr<CSSFontFace> >* familyFontFaces = m_fontFaces.get(family);
    // If no face was found, then return 0 and let the OS come up with its best match for the name.
    if (!familyFontFaces || familyFontFaces->isEmpty()) {
        // If we were handed a generic family, but there was no match, go ahead and return the correct font based off our
        // settings.
        return fontDataForGenericFamily(m_document, fontDescription, familyName);
    }

    HashMap<unsigned, RefPtr<CSSSegmentedFontFace> >* segmentedFontFaceCache = m_fonts.get(family);
    if (!segmentedFontFaceCache) {
        segmentedFontFaceCache = new HashMap<unsigned, RefPtr<CSSSegmentedFontFace> >;
        m_fonts.set(family, segmentedFontFaceCache);
    }

    FontTraitsMask traitsMask = fontDescription.traitsMask();

    RefPtr<CSSSegmentedFontFace> face = segmentedFontFaceCache->get(traitsMask);

    if (!face) {
        face = CSSSegmentedFontFace::create(this);
        segmentedFontFaceCache->set(traitsMask, face);
        // Collect all matching faces and sort them in order of preference.
        Vector<CSSFontFace*, 32> candidateFontFaces;
        for (int i = familyFontFaces->size() - 1; i >= 0; --i) {
            CSSFontFace* candidate = familyFontFaces->at(i).get();
            unsigned candidateTraitsMask = candidate->traitsMask();
            if ((traitsMask & FontStyleNormalMask) && !(candidateTraitsMask & FontStyleNormalMask))
                continue;
            if ((traitsMask & FontVariantNormalMask) && !(candidateTraitsMask & FontVariantNormalMask))
                continue;
            candidateFontFaces.append(candidate);
        }

        if (Vector<RefPtr<CSSFontFace> >* familyLocallyInstalledFontFaces = m_locallyInstalledFontFaces.get(family)) {
            unsigned numLocallyInstalledFontFaces = familyLocallyInstalledFontFaces->size();
            for (unsigned i = 0; i < numLocallyInstalledFontFaces; ++i) {
                CSSFontFace* candidate = familyLocallyInstalledFontFaces->at(i).get();
                unsigned candidateTraitsMask = candidate->traitsMask();
                if ((traitsMask & FontStyleNormalMask) && !(candidateTraitsMask & FontStyleNormalMask))
                    continue;
                if ((traitsMask & FontVariantNormalMask) && !(candidateTraitsMask & FontVariantNormalMask))
                    continue;
                candidateFontFaces.append(candidate);
            }
        }

        desiredTraitsMaskForComparison = traitsMask;
        std::stable_sort(candidateFontFaces.begin(), candidateFontFaces.end(), compareFontFaces);
        unsigned numCandidates = candidateFontFaces.size();
        for (unsigned i = 0; i < numCandidates; ++i)
            face->appendFontFace(candidateFontFaces[i]);
    }

    // We have a face.  Ask it for a font data.  If it cannot produce one, it will fail, and the OS will take over.
    return face->getFontData(fontDescription);
}
Example #19
0
void StringPool::sortByConfig() {
    LOG_ALWAYS_FATAL_IF(mOriginalPosToNewPos.size() > 0,
                        "Can't sort string pool after already sorted.");

    const size_t N = mEntryArray.size();

    // This is a vector that starts out with a 1:1 mapping to entries
    // in the array, which we will sort to come up with the desired order.
    // At that point it maps from the new position in the array to the
    // original position the entry appeared.
    Vector<size_t> newPosToOriginalPos;
    newPosToOriginalPos.setCapacity(N);
    for (size_t i = 0; i < N; i++) {
        newPosToOriginalPos.add(i);
    }

    // Sort the array.
    if (kIsDebug) {
        printf("SORTING STRINGS BY CONFIGURATION...\n");
    }
    ConfigSorter sorter(*this);
    std::sort(newPosToOriginalPos.begin(), newPosToOriginalPos.end(), sorter);
    if (kIsDebug) {
        printf("DONE SORTING STRINGS BY CONFIGURATION.\n");
    }

    // Create the reverse mapping from the original position in the array
    // to the new position where it appears in the sorted array.  This is
    // so that clients can re-map any positions they had previously stored.
    mOriginalPosToNewPos = newPosToOriginalPos;
    for (size_t i = 0; i < N; i++) {
        mOriginalPosToNewPos.editItemAt(newPosToOriginalPos[i]) = i;
    }

#if 0
    SortedVector<entry> entries;

    for (size_t i=0; i<N; i++) {
        printf("#%d was %d: %s\n", i, newPosToOriginalPos[i],
                mEntries[mEntryArray[newPosToOriginalPos[i]]].makeConfigsString().string());
        entries.add(mEntries[mEntryArray[i]]);
    }

    for (size_t i=0; i<entries.size(); i++) {
        printf("Sorted config #%d: %s\n", i,
                entries[i].makeConfigsString().string());
    }
#endif

    // Now we rebuild the arrays.
    Vector<entry> newEntries;
    Vector<size_t> newEntryArray;
    Vector<entry_style> newEntryStyleArray;
    DefaultKeyedVector<size_t, size_t> origOffsetToNewOffset;

    for (size_t i = 0; i < N; i++) {
        // We are filling in new offset 'i'; oldI is where we can find it
        // in the original data structure.
        size_t oldI = newPosToOriginalPos[i];
        // This is the actual entry associated with the old offset.
        const entry &oldEnt = mEntries[mEntryArray[oldI]];
        // This is the same entry the last time we added it to the
        // new entry array, if any.
        ssize_t newIndexOfOffset = origOffsetToNewOffset.indexOfKey(oldI);
        size_t newOffset;
        if (newIndexOfOffset < 0) {
            // This is the first time we have seen the entry, so add
            // it.
            newOffset = newEntries.add(oldEnt);
            newEntries.editItemAt(newOffset).indices.clear();
        } else {
            // We have seen this entry before, use the existing one
            // instead of adding it again.
            newOffset = origOffsetToNewOffset.valueAt(newIndexOfOffset);
        }
        // Update the indices to include this new position.
        newEntries.editItemAt(newOffset).indices.add(i);
        // And add the offset of the entry to the new entry array.
        newEntryArray.add(newOffset);
        // Add any old style to the new style array.
        if (mEntryStyleArray.size() > 0) {
            if (oldI < mEntryStyleArray.size()) {
                newEntryStyleArray.add(mEntryStyleArray[oldI]);
            } else {
                newEntryStyleArray.add(entry_style());
            }
        }
    }

    // Now trim any entries at the end of the new style array that are
    // not needed.
    for (ssize_t i = newEntryStyleArray.size() - 1; i >= 0; i--) {
        const entry_style &style = newEntryStyleArray[i];
        if (style.spans.size() > 0) {
            // That's it.
            break;
        }
        // This one is not needed; remove.
        newEntryStyleArray.removeAt(i);
    }

    // All done, install the new data structures and upate mValues with
    // the new positions.
    mEntries = newEntries;
    mEntryArray = newEntryArray;
    mEntryStyleArray = newEntryStyleArray;
    mValues.clear();
    for (size_t i = 0; i < mEntries.size(); i++) {
        const entry &ent = mEntries[i];
        mValues.add(ent.value, ent.indices[0]);
    }

#if 0
    printf("FINAL SORTED STRING CONFIGS:\n");
    for (size_t i=0; i<mEntries.size(); i++) {
        const entry& ent = mEntries[i];
        printf("#" ZD " %s: %s\n", (ZD_TYPE)i, ent.makeConfigsString().string(),
                String8(ent.value).string());
    }
#endif
}
Example #20
0
Vertex Vertex::rotate(const Vertex& point, const Matrix3d& rotmat) const
{
	Vector vec = Vector::diff(point, *this);
	vec.rotate(rotmat);
	return Vertex(vec.end());
}
Example #21
0
void TableSectionPainter::paintObject(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
    LayoutRect localPaintInvalidationRect = LayoutRect(paintInfo.rect);
    localPaintInvalidationRect.moveBy(-paintOffset);

    LayoutRect tableAlignedRect = m_layoutTableSection.logicalRectForWritingModeAndDirection(localPaintInvalidationRect);

    CellSpan dirtiedRows = m_layoutTableSection.dirtiedRows(tableAlignedRect);
    CellSpan dirtiedColumns = m_layoutTableSection.dirtiedColumns(tableAlignedRect);

    HashSet<LayoutTableCell*> overflowingCells = m_layoutTableSection.overflowingCells();
    if (dirtiedColumns.start() < dirtiedColumns.end()) {
        if (!m_layoutTableSection.hasMultipleCellLevels() && !overflowingCells.size()) {
            if (paintInfo.phase == PaintPhaseCollapsedTableBorders) {
                // Collapsed borders are painted from the bottom right to the top left so that precedence
                // due to cell position is respected.
                for (unsigned r = dirtiedRows.end(); r > dirtiedRows.start(); r--) {
                    unsigned row = r - 1;
                    for (unsigned c = dirtiedColumns.end(); c > dirtiedColumns.start(); c--) {
                        unsigned col = c - 1;
                        LayoutTableSection::CellStruct& current = m_layoutTableSection.cellAt(row, col);
                        LayoutTableCell* cell = current.primaryCell();
                        if (!cell || (row > dirtiedRows.start() && m_layoutTableSection.primaryCellAt(row - 1, col) == cell) || (col > dirtiedColumns.start() && m_layoutTableSection.primaryCellAt(row, col - 1) == cell))
                            continue;
                        LayoutPoint cellPoint = m_layoutTableSection.flipForWritingModeForChild(cell, paintOffset);
                        TableCellPainter(*cell).paintCollapsedBorders(paintInfo, cellPoint);
                    }
                }
            } else {
                // Draw the dirty cells in the order that they appear.
                for (unsigned r = dirtiedRows.start(); r < dirtiedRows.end(); r++) {
                    LayoutTableRow* row = m_layoutTableSection.rowLayoutObjectAt(r);
                    if (row && !row->hasSelfPaintingLayer())
                        TableRowPainter(*row).paintOutlineForRowIfNeeded(paintInfo, paintOffset);
                    for (unsigned c = dirtiedColumns.start(); c < dirtiedColumns.end(); c++) {
                        LayoutTableSection::CellStruct& current = m_layoutTableSection.cellAt(r, c);
                        LayoutTableCell* cell = current.primaryCell();
                        if (!cell || (r > dirtiedRows.start() && m_layoutTableSection.primaryCellAt(r - 1, c) == cell) || (c > dirtiedColumns.start() && m_layoutTableSection.primaryCellAt(r, c - 1) == cell))
                            continue;
                        paintCell(cell, paintInfo, paintOffset);
                    }
                }
            }
        } else {
            // The overflowing cells should be scarce to avoid adding a lot of cells to the HashSet.
#if ENABLE(ASSERT)
            unsigned totalRows = m_layoutTableSection.numRows();
            unsigned totalCols = m_layoutTableSection.table()->columns().size();
            ASSERT(overflowingCells.size() < totalRows * totalCols * gMaxAllowedOverflowingCellRatioForFastPaintPath);
#endif

            // To make sure we properly paint invalidate the section, we paint invalidated all the overflowing cells that we collected.
            Vector<LayoutTableCell*> cells;
            copyToVector(overflowingCells, cells);

            HashSet<LayoutTableCell*> spanningCells;

            for (unsigned r = dirtiedRows.start(); r < dirtiedRows.end(); r++) {
                LayoutTableRow* row = m_layoutTableSection.rowLayoutObjectAt(r);
                if (row && !row->hasSelfPaintingLayer())
                    TableRowPainter(*row).paintOutlineForRowIfNeeded(paintInfo, paintOffset);
                for (unsigned c = dirtiedColumns.start(); c < dirtiedColumns.end(); c++) {
                    LayoutTableSection::CellStruct& current = m_layoutTableSection.cellAt(r, c);
                    if (!current.hasCells())
                        continue;
                    for (unsigned i = 0; i < current.cells.size(); ++i) {
                        if (overflowingCells.contains(current.cells[i]))
                            continue;

                        if (current.cells[i]->rowSpan() > 1 || current.cells[i]->colSpan() > 1) {
                            if (!spanningCells.add(current.cells[i]).isNewEntry)
                                continue;
                        }

                        cells.append(current.cells[i]);
                    }
                }
            }

            // Sort the dirty cells by paint order.
            if (!overflowingCells.size())
                std::stable_sort(cells.begin(), cells.end(), compareCellPositions);
            else
                std::sort(cells.begin(), cells.end(), compareCellPositionsWithOverflowingCells);

            if (paintInfo.phase == PaintPhaseCollapsedTableBorders) {
                for (unsigned i = cells.size(); i > 0; --i) {
                    LayoutPoint cellPoint = m_layoutTableSection.flipForWritingModeForChild(cells[i - 1], paintOffset);
                    TableCellPainter(*cells[i - 1]).paintCollapsedBorders(paintInfo, cellPoint);
                }
            } else {
                for (unsigned i = 0; i < cells.size(); ++i)
                    paintCell(cells[i], paintInfo, paintOffset);
            }
        }
    }
}
Example #22
0
	void ScriptGizmoManager::update()
	{
		GizmoManager::instance().clearGizmos();

		HSceneObject rootSO = SceneManager::instance().getRootNode();

		Stack<HSceneObject> todo;
		todo.push(rootSO);

		bool isParentSelected = false;
		UINT32 parentSelectedPopIdx = 0;
		
		Vector<HSceneObject> selectedObjects = Selection::instance().getSceneObjects();

		while (!todo.empty())
		{
			if (isParentSelected && parentSelectedPopIdx == (UINT32)todo.size())
			{
				isParentSelected = false;
			}

			HSceneObject curSO = todo.top();
			todo.pop();

			bool isSelected = std::count(selectedObjects.begin(), selectedObjects.end(), curSO) > 0;
			if (isSelected && !isParentSelected)
			{
				isParentSelected = true;
				parentSelectedPopIdx = (UINT32)todo.size();
			}

			const Vector<HComponent>& components = curSO->getComponents();
			for (auto& component : components)
			{
				if (rtti_is_of_type<ManagedComponent>(component.get()))
				{
					ManagedComponent* managedComponent = static_cast<ManagedComponent*>(component.get());

					auto iterFind = mGizmoDrawers.find(managedComponent->getManagedFullTypeName());
					if (iterFind != mGizmoDrawers.end())
					{
						UINT32 flags = iterFind->second.flags;

						bool drawGizmo = false;
						if (((flags & (UINT32)DrawGizmoFlags::Selected) != 0) && isSelected)
							drawGizmo = true;

						if (((flags & (UINT32)DrawGizmoFlags::ParentSelected) != 0) && isParentSelected)
							drawGizmo = true;

						if (((flags & (UINT32)DrawGizmoFlags::NotSelected) != 0) && !isSelected && !isParentSelected)
							drawGizmo = true;

						if (drawGizmo)
						{
							bool pickable = (flags & (UINT32)DrawGizmoFlags::Pickable) != 0;
							GizmoManager::instance().startGizmo(curSO);
							GizmoManager::instance().setPickable(pickable);

							void* params[1] = { managedComponent->getManagedInstance() };
							iterFind->second.drawGizmosMethod->invoke(nullptr, params);

							GizmoManager::instance().endGizmo();
						}
					}
				}
			}

			for (UINT32 i = 0; i < curSO->getNumChildren(); i++)
				todo.push(curSO->getChild(i));
		}
	}
static void sortByApplyOrder(Vector<SVGSMILElement*>& smilElements)
{
    std::sort(smilElements.begin(), smilElements.end(), applyOrderSortFunction);
}
static void sortTimeList(Vector<SMILTimeWithOrigin>& timeList)
{
    std::sort(timeList.begin(), timeList.end());
}
Example #25
0
 // print the element values from root to end.
 void print() {
     std::cout << "Min heap elements: ";
     for(int *i = __min_heap.begin(); i < __min_heap.end(); ++i)
         std::cout << *i << " ";
     std::cout << "\n";
 }
Example #26
0
bool convertWOFFToSfnt(SharedBuffer* woff, Vector<char>& sfnt)
{
    ASSERT_ARG(sfnt, sfnt.isEmpty());

    size_t offset = 0;

    // Read the WOFF header.
    uint32_t signature;
    if (!readUInt32(woff, offset, signature) || signature != woffSignature) {
        ASSERT_NOT_REACHED();
        return false;
    }

    uint32_t flavor;
    if (!readUInt32(woff, offset, flavor))
        return false;

    uint32_t length;
    if (!readUInt32(woff, offset, length) || length != woff->size())
        return false;

    uint16_t numTables;
    if (!readUInt16(woff, offset, numTables))
        return false;

    if (!numTables || numTables > 0x0fff)
        return false;

    uint16_t reserved;
    if (!readUInt16(woff, offset, reserved) || reserved)
        return false;

    uint32_t totalSfntSize;
    if (!readUInt32(woff, offset, totalSfntSize))
        return false;

    if (woff->size() - offset < sizeof(uint16_t) + sizeof(uint16_t) + sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint32_t))
        return false;

    offset += sizeof(uint16_t); // majorVersion
    offset += sizeof(uint16_t); // minorVersion
    offset += sizeof(uint32_t); // metaOffset
    offset += sizeof(uint32_t); // metaLength
    offset += sizeof(uint32_t); // metaOrigLength
    offset += sizeof(uint32_t); // privOffset
    offset += sizeof(uint32_t); // privLength

    // Check if the WOFF can supply as many tables as it claims it has.
    if (woff->size() - offset < numTables * 5 * sizeof(uint32_t))
        return false;

    // Write the sfnt offset subtable.
    uint16_t entrySelector = 0;
    uint16_t searchRange = 1;
    while (searchRange < numTables >> 1) {
        entrySelector++;
        searchRange <<= 1;
    }
    searchRange <<= 4;
    uint16_t rangeShift = (numTables << 4) - searchRange;

    if (!writeUInt32(sfnt, flavor)
        || !writeUInt16(sfnt, numTables)
        || !writeUInt16(sfnt, searchRange)
        || !writeUInt16(sfnt, entrySelector)
        || !writeUInt16(sfnt, rangeShift))
        return false;

    if (sfnt.size() > totalSfntSize)
        return false;

    if (totalSfntSize - sfnt.size() < numTables * 4 * sizeof(uint32_t))
        return false;

    size_t sfntTableDirectoryCursor = sfnt.size();
    sfnt.grow(sfnt.size() + numTables * 4 * sizeof(uint32_t));

    // Process tables.
    for (uint16_t i = 0; i < numTables; ++i) {
        // Read a WOFF table directory entry.
        uint32_t tableTag;
        if (!readUInt32(woff, offset, tableTag))
            return false;

        uint32_t tableOffset;
        if (!readUInt32(woff, offset, tableOffset))
            return false;

        uint32_t tableCompLength;
        if (!readUInt32(woff, offset, tableCompLength))
            return false;

        if (tableOffset > woff->size() || tableCompLength > woff->size() - tableOffset)
            return false;

        uint32_t tableOrigLength;
        if (!readUInt32(woff, offset, tableOrigLength) || tableCompLength > tableOrigLength)
            return false;

        if (tableOrigLength > totalSfntSize || sfnt.size() > totalSfntSize - tableOrigLength)
            return false;

        uint32_t tableOrigChecksum;
        if (!readUInt32(woff, offset, tableOrigChecksum))
            return false;

        // Write an sfnt table directory entry.
        uint32_t* sfntTableDirectoryPtr = reinterpret_cast_ptr<uint32_t*>(sfnt.data() + sfntTableDirectoryCursor);
        *sfntTableDirectoryPtr++ = htonl(tableTag);
        *sfntTableDirectoryPtr++ = htonl(tableOrigChecksum);
        *sfntTableDirectoryPtr++ = htonl(sfnt.size());
        *sfntTableDirectoryPtr++ = htonl(tableOrigLength);
        sfntTableDirectoryCursor += 4 * sizeof(uint32_t);

        if (tableCompLength == tableOrigLength) {
            // The table is not compressed.
            if (!sfnt.tryAppend(woff->data() + tableOffset, tableCompLength))
                return false;
        } else {
            uLongf destLen = tableOrigLength;
            if (!sfnt.tryReserveCapacity(sfnt.size() + tableOrigLength))
                return false;
            Bytef* dest = reinterpret_cast<Bytef*>(sfnt.end());
            sfnt.grow(sfnt.size() + tableOrigLength);
            if (uncompress(dest, &destLen, reinterpret_cast<const Bytef*>(woff->data() + tableOffset), tableCompLength) != Z_OK)
                return false;
            if (destLen != tableOrigLength)
                return false;
        }

        // Pad to a multiple of 4 bytes.
        while (sfnt.size() % 4)
            sfnt.append(0);
    }

    return sfnt.size() == totalSfntSize;
}
Example #27
0
int main()
{

	cout << "	DEFAULT CONSTRUCTOR TEST" << endl;
	cout << "(1)	-	Create Vector<int> " << endl;
	Vector<int> a1;
	cout << "Size: " << a1.size() <<" ptr " << a1.vector_ptr << endl;
	cout << "(2)	-	Create Vector<char> " << endl;
	Vector<char> a2;
	cout << "Size: " << a2.size() <<" ptr " << a2.vector_ptr << endl;
	cout << "(3)	-	Create Vector<double> " << endl;
	Vector<double> a3;
	cout << "Size: " << a3.size() <<" ptr " << a3.vector_ptr << endl;
	cout << "(4)	-	Create Vector<char> " << endl;
	Vector<float> a4;
	cout << "Size: " << a4.size() <<" ptr " << a4.vector_ptr << endl;
	cout << "(5)	-	Create Vector<unsigned int>" << endl;
	Vector<unsigned int> a5;
	cout << "Size: " << a5.size() <<" ptr " << a5.vector_ptr << endl<< endl<< endl;



	cout << "	SIZE CONSTRUCTOR TEST" << endl;
	cout << "(1)	-	Create Vector<int> = 0 " << endl;
	Vector<int> b1(0);
	cout << "Size: " << b1.size() <<" ptr " << b1.vector_ptr << endl;
	cout << "(2)	-	Create Vector<char> = 11" << endl;
	Vector<char> b2(11);
	cout << "Size: " << b2.size() <<" ptr " << b2.vector_ptr << endl;
	cout << "(3)	-	Create Vector<double> = 12" << endl;
	Vector<double> b3(12);
	cout << "Size: " << b3.size() <<" ptr " << b3.vector_ptr << endl;
	cout << "(4)	-	Create Vector<char> = 13" << endl;
	Vector<float> b4(13);
	cout << "Size: " << b4.size() <<" ptr " << b4.vector_ptr << endl;
	cout << "(5)	-	Create Vector<unsigned int> = 14" << endl;
	Vector<unsigned int> b5(14);
	cout << "Size: " << b5.size() <<" ptr " << b5.vector_ptr << endl<< endl<< endl;


	std::initializer_list<int> list1 = {1,2,3}; initializer_list<char> list2 = {'b','d','p'};
	initializer_list<double> list3 = {-1.33132,2.313}; initializer_list<float> list4 = {-1123133,0.01,0};
	std::initializer_list<unsigned int> list5 = {};

	cout << "	SIZE LIST TEST" << endl;
	cout << "(1)	-	Create Vector<int> = {1,2,3} " << endl;
	Vector<int> c1(list1);
	cout << "Size: " << c1.size() <<" ptr " << c1.vector_ptr << endl;
	cout << "[0],[2]" << c1[0] << " " << c1[2] << endl;
	cout << "(2)	-	Create Vector<char> = {'b','d','p'}" << endl;
	Vector<char> c2(list2);
	cout << "[0],[2]" << c2[0] << " " << c2[2] << endl;
	cout << "Size: " << c2.size() <<" ptr " << c2.vector_ptr << endl;
	cout << "(3)	-	Create Vector<double> = {-1.33132,2.313} " << endl;
	Vector<double> c3(list3);
	cout << "[0]" << c3[0]  << endl;
	cout << "Size: " << c3.size() <<" ptr " << c3.vector_ptr << endl;
	cout << "(4)	-	Create Vector<char>  = {-1123133,0.01,0};" << endl;
	Vector<float> c4(list4);
	cout << "[0]" << c4[0]  << endl;
	cout << "Size: " << c4.size() <<" ptr " << c4.vector_ptr << endl;
	cout << "(5)	-	Create Vector<unsigned int> = {} " << endl;
	Vector<unsigned int> c5(list5);
	cout << "Size: " << c5.size() <<" ptr " << c5.vector_ptr << endl<< endl<< endl;



	cout << "	COPY TEST" << endl;
	cout << "(1)	-	Create Vector<int> = {1,2,3} " << endl;
	Vector<int> d1(c1);
	cout << "Size: " << d1.size() <<" ptr " << d1.vector_ptr << endl;
	cout << "[0],[2]" << d1[0] << " " << d1[2] << endl;
	cout << "(2)	-	Create Vector<char> = {'b','d','p'}" << endl;
	Vector<char> d2(c2);
	cout << "[0],[2]" << d2[0] << " " << d2[2] << endl;
	cout << "Size: " << d2.size() <<" ptr " << d2.vector_ptr << endl;
	cout << "(3)	-	Create Vector<double> = {-1.33132,2.313} " << endl;
	Vector<double> d3(c3);
	cout << "[0]" << d3[0]  << endl;
	cout << "Size: " << d3.size() <<" ptr " << d3.vector_ptr << endl;
	cout << "(4)	-	Create Vector<char>  = {-1123133,0.01,0};" << endl;
	Vector<float> d4(c4);
	cout << "[0]" << d4[0]  << endl;
	cout << "Size: " << d4.size() <<" ptr " << d4.vector_ptr << endl;
	cout << "(5)	-	Create Vector<unsigned int> = {} " << endl;
	Vector<unsigned int> d5(c5);
	cout << "Size: " << d5.size() <<" ptr " << d5.vector_ptr << endl<< endl<< endl;


	//OBS vector ptr till chars är jobbiga att skriva ut (blir ej adressen utan värdet)
	cout << "	MOVE	TEST" << endl;
	cout << "(1)	-	Create Vector<int> " << endl;
	Vector<int> e1(move(c1)); 
	cout << "From size: " << c1.size() <<" ptr:" << c1.vector_ptr << endl;
	cout << "To size: " << e1.size() <<" ptr:" << e1.vector_ptr << endl;
	cout << "(2)	-	Create Vector<char> " << endl;
	Vector<char> e2(move(c2)); 
	cout << "From size: " << c2.size() << endl;
	cout << "To size: " << e2.size() <<" ptr:" << e2.vector_ptr << endl;
	cout << "(3)	-	Create Vector<double> " << endl;
	Vector<double> e3(move(c3)); 
	cout << "From size: " << c3.size() <<" ptr:" << c3.vector_ptr << endl;
	cout << "To size: " << e3.size() <<" ptr:" << e3.vector_ptr << endl;
	cout << "(4)	-	Create Vector<char> " << endl;
	Vector<float> e4(move(c4)); 
	cout << "From size: " << c4.size() <<" ptr:" << c4.vector_ptr << endl;
	cout << "To size: " << e4.size() <<" ptr:" << e4.vector_ptr << endl;
	cout << "(5)	-	Create Vector<unsigned int>" << endl;
	Vector<unsigned int> e5(move(c5)); 
	cout << "From size: " << c5.size() <<" ptr:" << c5.vector_ptr << endl;
	cout << "To size: " << e5.size() <<" ptr:" << e5.vector_ptr << endl << endl << endl;





	cout << "	ASSIGNMENT =  TEST" << endl;
	cout << "(1)	-	Create Vector<int> " << endl;
	cout << "Innan a " << a1.size() << " d " << d1.size() << endl;
	a1 = d1;
	cout << "efter a " << a1.size() << " d " << d1.size() << endl;
	
	cout << "(2)	-	Create Vector<char> " << endl;
	cout << "Innan e2 " << e2.size() << " a2 " << a2.size() << endl;
	e2 = a2;
	cout << "efter e2 " << e2.size() << " a2 " << a2.size() << endl;

	cout << "(3)	-	Create Vector<double> " << endl;
	cout << "Innan c3 " << c3.size() << " c3 " << c3.size() << endl;
	c3 = c3;
	cout << "efter c3 " << c3.size() << " c3 " << c3.size() << endl;

	cout << "(4)	-	Create Vector<char> " << endl;
	cout << "Innan e4 " << e4.size() << " b4 " << b4.size() << endl;
	e4 = b4;
	cout << "efter e4 " << e4.size() << " b4 " << b4.size() << endl;

	cout << "(5)	-	Create Vector<unsigned int>" << endl;
	cout << "Innan a " << b5.size() << " d5 " << d5.size() << endl;
	b5 = d5;
	cout << "efter a " << b5.size() <<"  d5 " << d5.size() << endl<< endl<< endl;




	cout << "	ASSIGNMENT =  MOVE-ASSIMENT	" << endl;
	cout << "(1)	-	Till sig själv " << endl;
	cout << "Innan e1 " << e1.size() << " ptr " << e1.vector_ptr << endl;
	e1 = move(e1);
	cout << "Efter e1 " << e1.size() << " ptr " << e1.vector_ptr << endl;

	cout << "(2)	-	Annan <int> -> <int> " << endl;
	cout << "Innan d1 " << d1.size() << " ptr " << d1.vector_ptr << endl;
	e1 = move(d1);
	cout << "Efter e1 " << e1.size() << " ptr " << e1.vector_ptr << endl;
	cout << "Efter d1 " << d1.size() << " ptr " << d1.vector_ptr << endl;

	cout << "(3)	-	Annan <int> -> <int> " << endl;
	cout << "Innan e1 " << c3.size() << " ptr " << c3.vector_ptr << endl;
	b3 = move(c3);
	cout << "Efter e1 " << c3.size() << " ptr " << c3.vector_ptr << endl;
	cout << "Efter b3 " << b3.size() << " ptr " << b3.vector_ptr << endl<< endl<< endl;




	cout << "	OPERATOR  []  READ-WRITE 	" << endl;
	Vector<int> f1(list1); Vector<char> f2(list2); Vector<float> f3(list4);
	cout << "(1)	-	Create Vector<int> " << endl;
	cout << "size: " << f1.size() << endl;
	cout << "Ta ut f1[2]" << f1[2] << endl;

	cout << "(2)	-	Create Vector<char> " << endl;
	cout << "size: " << f2.size() << endl;
	cout << "f2[1] = 1;" << endl;
	f2[1] = 1;

	cout << "(3)	-	Create Vector<float> " << endl;
	cout << "size: " << f3.size() << endl;
	cout << "Ta ut f3[0]" << f3[0] << endl << endl << endl;



	cout << "	OPERATOR  []  OPERATOR  []  READ-ONLY 	" << endl;
	const Vector<int> aa(list1);
	cout << "(1)	aa[2]" << "size" << aa.size() << endl;
	cout << "aa[2]" << aa[2] << endl;
	const Vector<char> cc(list2);
	cout << "(2)	cc[2]" << "size" << cc.size() << endl;
	cout << "cc[2]" << cc[2] << endl;
	const Vector<float> dd(list4);
	cout << "(3)	dd[2]" << "size" << dd.size() << endl;
	cout << "dd[2]" << dd[2] << endl <<endl << endl;

	cout << "	OPERATOR  []  OPERATOR  []  READ-ONLY 	" << endl;
	Vector<int> a10(10,3);
	cout << "a10 size: " << a10.size() <<endl;
	cout << a10[0] << a10[1] << a10[9] << endl;

	cout << "	clear(); 	" << endl;
	cout << "BEFORE a10 size: " << a10.size() << " ptr " << a10.vector_ptr <<endl;
	a10.clear();
	cout << "AFTER a10 size: " << a10.size() << " ptr " << a10.vector_ptr <<endl;

	cout << "TESTING PUSHBACK()" << endl;
	Vector<int> a11(11,14);
	Vector<float> b11;
	cout << "size a11 = " << a11.size() << endl;
	a11.push_back(12);
	cout << "testar pushbak 12, a11 size = " << a11.size() <<endl;
	cout << "a11[11]= "  << a11[11] << endl;

	for(int i=0; i<15;i++) {
		b11.push_back(1.05f);
		cout << "size b11 = " << b11.size() << endl;
		cout << "capacity b11 = " << b11.tot_capacity << endl;
	}


	cout << "TESTING INSERT()" << endl;
	Vector<int> a12;
	for(int i=0; i<20;i++)
	{
		a12.insert(0,10);
		cout << "size a12 = " << a12.size() << endl;
		cout << "capacity a12 = " << a12.tot_capacity << endl;
	}



	std::initializer_list<int> list11 = {1,2,3,4,5,6};
	cout << "TESTING ERASE()" << endl;
	Vector<int> a13(list11);
	cout << "size a13 = " << a13.size() << endl;
	for(int i = 0; i < a13.size(); i++)
	{
		cout << a13[i] << endl;
	}
	a13.erase(0);
	cout << "ERASE" << endl;
	cout << "size a13 = " << a13.size() << endl;
	for(int i = 0; i < a13.size(); i++)
	{
		cout << a13[i]<< endl;
	}


	cout << "TESTING BEGIN()" << endl;
	Vector<int> a14(list11);
	const int* x;
	x = a14.begin();
	for(int i = 0; i < (a14.size()-1); i++)
	{

		cout << *x << endl;
		x++;
	}

	cout << "TESTING END()" << endl;
	const int* y;
	y = a14.end();

	cout << y << "   " << x << endl;
	cout << *y << "   " << *x << endl;
	if(y == x)
	{
		cout << "TRUE" << endl;
	}
	for(int i = (a14.length); i > 0; i--)
	{
		// cout << i << endl;
		cout << *y << endl;
		y--;
	}


	cout << "CONST VECTOR" << endl;
	const Vector<int> x10(10);
	Vector<int> x11;
	x10.begin();
	x10.end();

	const int* x20;
	const int& x20_r = 3;
	x20 = x11.begin();
	x11.end();

	cout << "FIND" << endl;
	std::initializer_list<int> listFind = {1,2,3,4,3,2,1}; 
	Vector<int> x25(5);
	const int a = 3;
	const int& x25_r = a;

	x20 = x25.find(a);

	cout << "INSERT" << endl;
	Vector<int> x_size(100);
	Vector<int> x_insert;
	x_insert.insert(0,42);
	cout << x_insert[0] <<  endl;
	x_insert.insert(0,-43);
	cout << x_insert[0] << " " << x_insert[1] << endl;
	x_insert.insert(0,-43);
	x_insert.insert(0,1);
	x_insert.insert(0,2);
	x_insert.insert(0,3);
	cout << x_insert[0] << " " << x_insert[1] << x_insert[2] << x_insert[3] << x_insert[4]<< x_insert[5] << endl;


	cout << "1024" << endl;
	Vector<int> x1024(1025);
	cout << x1024.size() << endl;

	// cout << "TESTING FIND()" << endl;
	// const int& x_r = 3;
	// int* a_p;
	// const int* z;
	// z = a14.begin();
	// a_p = a14.find(&&z);





	return 0;
}
Example #28
0
void TestVectorCppZeroSize(void)
{
    Vector v;
    ASSERT_EQUAL(v.size(), 0);
    ASSERT_EQUAL((v.begin() == v.end()), true);
}
Example #29
0
void SMILTimeContainer::sortByPriority(Vector<SVGSMILElement*>& smilElements, SMILTime elapsed)
{
    if (m_documentOrderIndexesDirty)
        updateDocumentOrderIndexes();
    std::sort(smilElements.begin(), smilElements.end(), PriorityCompare(elapsed));
}
Example #30
0
PassRefPtr<RTCConfiguration> RTCPeerConnection::parseConfiguration(const Dictionary& configuration, ExceptionState& exceptionState)
{
    if (configuration.isUndefinedOrNull())
        return nullptr;

    ArrayValue iceServers;
    bool ok = configuration.get("iceServers", iceServers);
    if (!ok || iceServers.isUndefinedOrNull()) {
        exceptionState.throwTypeError("Malformed RTCConfiguration");
        return nullptr;
    }

    size_t numberOfServers;
    ok = iceServers.length(numberOfServers);
    if (!ok) {
        exceptionState.throwTypeError("Malformed RTCConfiguration");
        return nullptr;
    }

    RefPtr<RTCConfiguration> rtcConfiguration = RTCConfiguration::create();

    for (size_t i = 0; i < numberOfServers; ++i) {
        Dictionary iceServer;
        ok = iceServers.get(i, iceServer);
        if (!ok) {
            exceptionState.throwTypeError("Malformed RTCIceServer");
            return nullptr;
        }

        Vector<String> names;
        iceServer.getOwnPropertyNames(names);

        Vector<String> urlStrings;
        if (names.contains("urls")) {
            if (!iceServer.get("urls", urlStrings) || !urlStrings.size()) {
                String urlString;
                if (iceServer.get("urls", urlString)) {
                    urlStrings.append(urlString);
                } else {
                    exceptionState.throwTypeError("Malformed RTCIceServer");
                    return nullptr;
                }
            }
        } else if (names.contains("url")) {
            String urlString;
            if (iceServer.get("url", urlString)) {
                urlStrings.append(urlString);
            } else {
                exceptionState.throwTypeError("Malformed RTCIceServer");
                return nullptr;
            }
        } else {
            exceptionState.throwTypeError("Malformed RTCIceServer");
            return nullptr;
        }

        String username, credential;
        iceServer.get("username", username);
        iceServer.get("credential", credential);

        for (Vector<String>::iterator iter = urlStrings.begin(); iter != urlStrings.end(); ++iter) {
            KURL url(KURL(), *iter);
            if (!url.isValid() || !(url.protocolIs("turn") || url.protocolIs("turns") || url.protocolIs("stun"))) {
                exceptionState.throwTypeError("Malformed URL");
                return nullptr;
            }

            rtcConfiguration->appendServer(RTCIceServer::create(url, username, credential));
        }
    }

    return rtcConfiguration.release();
}